Alexander Belopolsky <alexander.belopol...@gmail.com> added the comment:

On Sun, Jan 29, 2012 at 6:42 PM, STINNER Victor <rep...@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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to