[Python-ideas] strptime without second argument as an inverse to __str__

Ethan Furman ethan at stoneleaf.us
Wed Aug 6 19:01:45 CEST 2014


On 08/06/2014 09:47 AM, Alexander Belopolsky wrote:
> On Wed, Aug 6, 2014 at 12:20 PM, Wolfgang Maier wrote:
>>
>> BTW, Terry's suggestion of datetime.fromstr(s) sounds very reasonable.
>
> We don't have int.fromstr, float.fromstr, or in fact a .fromstr
> constructor for any other type.  IMO, date(str) is "the obvious
>  way to do it."

int, float, and, I suspect, all the core data types, have the same __str__ as __repr__, so there's really no difference. 
  datetime objects, on the other hand, definitely have different __str__ and __repr__, and the desire is to be able no 
eval(obj.__repr__()), not of __str__.

--
~Ethan~


More information about the Python-ideas mailing list