[Python-ideas] Improving fn(arg=arg, name=name, wibble=wibble) code

Jonathan Fine jfine2358 at gmail.com
Thu Sep 13 15:34:41 EDT 2018

Hi Anders and Michael

I think it would be great if plugging existing functions into our code
was as easy as, well, plugging an electrical appliance into a wall
socket. However, even this ease of use has taken time.


And travellers know that adapters are required. And for some
equipment, non-trivial transformers.

Even though there's been much progress, such as multiple inheritance,
super() and iterators, there's still nuisance, pain and errors.The
good news is that we've identified some ways of improving the

Although there are the usual contending views and differences of
opinion, there's also positive energy and shared values. So I'm

Anders, you wrote:

> I’ll repeat myself: what about .format()? If you localize you can’t use
> f-strings. What about templates in web apps? Obviously f-strings won’t do.
> What about json blobs in REST APIs? Again no help from f-strings. What about
> functions with more than 3 arguments generally?

For f-strings, can't we turn the dictionary into a namespace, like so

Python 3.6.2 (default, Jul 29 2017, 00:00:00)

    >>> d = dict(a='apple', b='banana', c='cherry', d=137)
    >>> class A: pass

    >>> ns = A()
    >>> ns.__dict__ = d # Yes, we can do this!

    >>> ns.a

    >>> f'The a-fruit is {ns.a}, and d is {ns.d}.'
   'The a-fruit is apple, and d is 137.'

I don't see why this doesn't help reduce the pain.

For functions with more than 3 arguments, perhaps you could give some
examples where you'd like improvement.

best wishes


More information about the Python-ideas mailing list