Author Alexander.Belopolsky
Recipients Alexander.Belopolsky, Arfrever, belopolsky, eric.smith, loewis, mark.dickinson, pitrou, skrah, vstinner
Date 2012-01-30.22:49:29
SpamBayes Score 5.58265e-08
Marked as misclassified No
Message-id <CAP7h-xZBcrmnHGzLX-cztE3oZx2K9Rmwzb2GB1e2zhPi_ahK+A@mail.gmail.com>
In-reply-to <1327880535.51.0.390396847127.issue13882@psf.upfronthosting.co.za>
Content
On Sun, Jan 29, 2012 at 6:42 PM, STINNER Victor <report@bugs.python.org> wrote:
..
> What do you call a constant argument? "float" and "decimal"?
> You would prefer a constant like time.FLOAT_FORMAT?
> Or maybe a boolean (decimal=True)?

Yes. This was explained on python-dev not so long ago:

http://mail.python.org/pipermail/python-dev/2010-July/102100.html

The problem is not with the type of the argument (although boolean or
enum argument type is often a symptom pointing to the issue.)  The
issue is that an argument that is never given a variable value at the
call site is usually a sign of an awkward API.  For example, what
would you prefer:

math('log', x)

or

math.log(x)

?

>
> I chose a string because my first idea was to add a registry to support other format,
> maybe user defined formats, like the one used by Unicode codecs.

With all my respect for MAL, codecs are not my favorite part of the
python library.

One possibility (still awkward IMO) would be to use the return type as
the format specifier.  This would at least require the user to import
datetime or decimal before calling time() with corresponding format.
Few users would tolerate I/O delay when they want to get time with
nanosecond precision.
History
Date User Action Args
2012-01-30 22:49:31Alexander.Belopolskysetrecipients: + Alexander.Belopolsky, loewis, mark.dickinson, belopolsky, pitrou, vstinner, eric.smith, Arfrever, skrah
2012-01-30 22:49:30Alexander.Belopolskylinkissue13882 messages
2012-01-30 22:49:30Alexander.Belopolskycreate