Re: [Python-3000] __format__ and datetime

2007-09-14 Thread Nick Coghlan
Greg Ewing wrote: > [EMAIL PROTECTED] wrote: >> I was just thinking about the folks at places like FermiLab and CERN. ;-) > > Those guys probably need picoseconds... With the suggested %f format character and the mention of Fermilab and CERN, I started thinking about femtoseconds :) Cheers, Nic

Re: [Python-3000] __format__ and datetime

2007-09-13 Thread Greg Ewing
[EMAIL PROTECTED] wrote: > I was just thinking about the folks at places like FermiLab and CERN. ;-) Those guys probably need picoseconds... -- Greg ___ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000

Re: [Python-3000] __format__ and datetime

2007-09-12 Thread Skip Montanaro
> Given how long strftime has been around I think %f is fine. We may > even influence the future of the C library. :-) Patch for datetime (py3k only at this point, no tests either) here: http://bugs.python.org/issue1158 Skip ___ Python-3000 mailing

Re: [Python-3000] __format__ and datetime

2007-09-12 Thread skip
Guido> Which ones are two letters? All the locale-specific stuff on Solaris 10. I guess technically the first letter of the pair is a modifier of the actual code, which comes next. From the man page: Modified Conversion Specifications Some conversion specifications can be modified b

Re: [Python-3000] __format__ and datetime

2007-09-12 Thread Guido van Rossum
On 9/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > So, is '%f" okay to coopt? Is there some sort of future-proofing we can do > so that if the libc folks decide later to use "%f" for something we're not > (mildly) hosed? Maybe "%."? It appears that all strftime codes are one or > two let

Re: [Python-3000] __format__ and datetime

2007-09-12 Thread skip
Guido> No, the datetime module is explicitly defined to use Guido> microseconds. I don't expect there to be a practical use for Guido> nanoseconds (even microseconds are doubtful, but useful since one Guido> might want unique timestamps for more than 1000 events per Guido> seco

Re: [Python-3000] __format__ and datetime

2007-09-11 Thread Guido van Rossum
On 9/11/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > I don't expect there to be a practical use for nanoseconds (even > > microseconds are doubtful, but useful since one might want unique > > timestamps for more than 1000 events per second). > > But... what if you want un

Re: [Python-3000] __format__ and datetime

2007-09-11 Thread Greg Ewing
Guido van Rossum wrote: > I don't expect there to be a practical use for nanoseconds (even > microseconds are doubtful, but useful since one might want unique > timestamps for more than 1000 events per second). But... what if you want unique timestamps for more than 100 events per second? :-)

Re: [Python-3000] __format__ and datetime

2007-09-11 Thread Guido van Rossum
On 9/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Skip> I would like to see an analog to %S which preserves fractions of a > Skip> second as the default formatting for time and datetime objects > Skip> does: > > Skip> >>> print(now) > Skip> 2007-09-10 22:07:53.654774

Re: [Python-3000] __format__ and datetime

2007-09-11 Thread skip
Skip> I would like to see an analog to %S which preserves fractions of a Skip> second as the default formatting for time and datetime objects Skip> does: Skip> >>> print(now) Skip> 2007-09-10 22:07:53.654774 Guido> Right. It's odd that there's nothing explicit that exactl

Re: [Python-3000] __format__ and datetime

2007-09-11 Thread Eric Smith
Nick Coghlan wrote: > Eric Smith wrote: >> Eric Smith wrote: >>> I have a patch to add __format__ to datetime.time, .date, and >>> .datetime. For non-empty format_spec's, I just pass on to >>> .strftime. For empty format_spec's, it returns str(self). >> >> What's the best way to call str(self)

Re: [Python-3000] __format__ and datetime

2007-09-11 Thread Nick Coghlan
Eric Smith wrote: > Eric Smith wrote: >> I have a patch to add __format__ to datetime.time, .date, and .datetime. >> For non-empty format_spec's, I just pass on to .strftime. For empty >> format_spec's, it returns str(self). > > What's the best way to call str(self)? > > I'm currently doing:

Re: [Python-3000] __format__ and datetime

2007-09-11 Thread Eric Smith
Eric Smith wrote: > I have a patch to add __format__ to datetime.time, .date, and .datetime. > For non-empty format_spec's, I just pass on to .strftime. For empty > format_spec's, it returns str(self). What's the best way to call str(self)? I'm currently doing: if (PyUnicode_GetSize(for

Re: [Python-3000] __format__ and datetime

2007-09-10 Thread Guido van Rossum
Right. It's odd that there's nothing explicit that exactly produces the default. (Though floats have this issue too -- I wish it could be fixed there too.) On 9/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Paul> The date and time defaults (which appear to be %Y-%m-%d and > Paul>

Re: [Python-3000] __format__ and datetime

2007-09-10 Thread skip
Paul> The date and time defaults (which appear to be %Y-%m-%d and Paul> %H:%M:%s) seem perfectly acceptable, on the other hand. I would like to see an analog to %S which preserves fractions of a second as the default formatting for time and datetime objects does: >>> print(now) 2

Re: [Python-3000] __format__ and datetime

2007-09-10 Thread Eric Smith
Paul Moore wrote: > I'd like to see the default format specified (somewhere). I note that > the default format for datetime values seems to differ for me (on > 3.0a1 on Windows) > > Python 3.0a1 (py3k:57844, Aug 31 2007, 16:54:27) [MSC v.1310 32 bit > (Intel)] on win32 > Type "help", "copyright",

Re: [Python-3000] __format__ and datetime

2007-09-10 Thread Guido van Rossum
On 9/10/07, Eric Smith <[EMAIL PROTECTED]> wrote: > I have a patch to add __format__ to datetime.time, .date, and .datetime. > For non-empty format_spec's, I just pass on to .strftime. For empty > format_spec's, it returns str(self). > > I think this is the only reasonable interpretation of form

Re: [Python-3000] __format__ and datetime

2007-09-10 Thread Eric Smith
Eric Smith wrote: > Martin v. Löwis wrote: >>> I have a patch to add __format__ to datetime.time, .date, and .datetime. >>> For non-empty format_spec's, I just pass on to .strftime. For empty >>> format_spec's, it returns str(self). >>> >>> I think this is the only reasonable interpretation of

Re: [Python-3000] __format__ and datetime

2007-09-10 Thread Paul Moore
On 10/09/2007, Eric Smith <[EMAIL PROTECTED]> wrote: > Martin v. Löwis wrote: > >> I have a patch to add __format__ to datetime.time, .date, and .datetime. > >> For non-empty format_spec's, I just pass on to .strftime. For empty > >> format_spec's, it returns str(self). > >> > >> I think this is

Re: [Python-3000] __format__ and datetime

2007-09-10 Thread Eric Smith
Martin v. Löwis wrote: >> I have a patch to add __format__ to datetime.time, .date, and .datetime. >> For non-empty format_spec's, I just pass on to .strftime. For empty >> format_spec's, it returns str(self). >> >> I think this is the only reasonable interpretation of format_spec's for >> da

Re: [Python-3000] __format__ and datetime

2007-09-10 Thread Martin v. Löwis
> I have a patch to add __format__ to datetime.time, .date, and .datetime. > For non-empty format_spec's, I just pass on to .strftime. For empty > format_spec's, it returns str(self). > > I think this is the only reasonable interpretation of format_spec's for > datetime. Does anyone think o

[Python-3000] __format__ and datetime

2007-09-10 Thread Eric Smith
I have a patch to add __format__ to datetime.time, .date, and .datetime. For non-empty format_spec's, I just pass on to .strftime. For empty format_spec's, it returns str(self). I think this is the only reasonable interpretation of format_spec's for datetime. Does anyone think otherwise? E