[Python-3000] PEP 3101 clarification requests
Talin
talin at acm.org
Sat Aug 18 03:48:54 CEST 2007
Wow, excellent feedback. I've added your email to the list of reminders
for the next round of edits.
Jim Jewett wrote:
> The PEP says:
>
> The general form of a standard format specifier is:
>
> [[fill]align][sign][width][.precision][type]
>
> but then says:
>
> A zero fill character without an alignment flag
> implies an alignment type of '='.
>
> In the above form, how can you get a fill character without an
> alignment character? And why would you want to support it; It just
> makes the width look like an (old-style) octal. (The spec already
> says that you need the alignment if you use a digit other than zero.)
>
> --------------
>
> The explicit conversion flag is limited to "r" and "s", but I assume
> that can be overridden in a Formatter subclass. That possibility
> might be worth mentioning explicitly.
>
> --------------
>
>
> 'check_unused_args' is used to implement checking
> for unused arguments ... The intersection of these two
> sets will be the set of unused args.
>
> Huh? I *think* the actual intent is (args union kwargs)-used. I
> can't find an intersection in there.
>
> -----------------
> This can easily be done by overriding get_named() as follows:
>
> I assume that should be get_value.
>
> class NamespaceFormatter(Formatter):
> def __init__(self, namespace={}, flags=0):
> Formatter.__init__(self, flags)
>
> but the Formatter class took no init parameters -- should flags be
> added to the Formatter constructor, or taken out of here?
>
> The get_value override can be expressed more simply as
>
> def get_value(self, key, args, kwds):
> try:
> # simplify even more by assuming PEP 3135?
> super(NamespaceFormatter, self).get_value(key, args, kwds)
> except KeyError:
> return self.namespace[name]
>
> The example usage then takes globals()...
>
> fmt = NamespaceFormatter(globals())
> greeting = "hello"
> print(fmt("{greeting}, world!"))
>
> Is there now a promise that the objects returned by locals() and
> globals() will be "live", so that they would reflect the new value of
> "greeting", even though it was set after the Formatter was created?
>
> -jJ
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/talin%40acm.org
>
More information about the Python-3000
mailing list