to_str should have default as repr?

Issue #105 closed
Anonymous created an issue

Should the default conversion from argument to key string be repr rather than str?

From the docs:

The str() function is meant to return representations of values which are fairly human-readable, while repr() is meant to generate representations which can be read by the interpreter (or will force a SyntaxError if there is no equivalent syntax). For objects which don’t have a particular representation for human consumption, str() will return the same value as repr(). Many values, such as numbers or structures like lists and dictionaries, have the same representation using either function. Strings and floating point numbers, in particular, have two distinct representations.

Comments (2)

  1. Michael Bayer repo owner

    to_str is customizable. set it to whatever you want. Python convention is that if you want a string representation of an object, that's what str() is for. repr() is intended to create a Python contructor-form and has more requirements surrounding it as opposed to str().

  2. Log in to comment