Talin wrote:
> In the case where you want direct access to global variables, you can
> make it even more convenient by caching the Formatter:
>
> f = Formatter(globals()).format
> a = 1
> print(f("The value of a is {a}"))
>
> (You can't do this with locals() because you can't keep the dict around.)
>
> My question to the groupmind out there is: Do you find this extra syntax
> too inconvenient and wordy, or does it seem acceptable?
I like it - even with locals, it works well for multi-line output:
fmt = Formatter(locals()).format
print(fmt('Count: {count}'))
print(fmt('Total: {total}'))
print(fmt('Average: {avg}'))
(Hmm, the extra parentheses on print statements are annoying me
already... but I imagine I will get over it :)
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com