creating dictionnaries

Christian Caremoli Christian.Caremoli at der.edf.fr
Wed Jun 23 08:07:27 CEST 1999


Thanks for all the answers
I know that it s invalid and what I use now is a function named _F to
avoid name clashes
def _F(**args):
   return args
What I want is to have an uniform syntax to write :
a=mycommand(x=1,y=2,z=(d=1,e=2),s=1)
or alike
instead of
a=mycommand(x=1,y=2,z=_F(d=1,e=2),s=1)
I wonder if it exists any syntactic sugar or any trick that could help me


Hans Nowak wrote:

> On 22 Jun 99, Christian Caremoli wrote:
>
> > Hi,
> > Dictionnaries can be created like that :
> > d={'a':1,'b':2}
> >
> > By calling a function you create a dictionnary like that :
> > def f(**d):
> >    return d
> >
> > d=f(a=1,b=2)
> >
> > I would like to be able to create dictionnaries with some similar syntax
> > like keyed tuples :
> > d=(a=1,b=2)
> >
> > Is there a way to do that ?
>
> Nope. :-) I wonder why you would want this? As far as I'm concerned,
> there's not screamingly much difference between
>
> d=f(a=1,b=2)    # valid
>
> and
>
> d=(a=1,b=2)     # invalid
>
> --Hans Nowak (ivnowa at hvision.nl)
> Homepage: http://fly.to/zephyrfalcon







More information about the Python-list mailing list