Life's better without braces

Fredrik Lundh effbot at telia.com
Mon Feb 21 16:04:01 EST 2000


Gerrit Holl wrote:
> I have a problem. In my Python enthuishasm, I ripped off the braces
> from my keyboard because I thought I didn't need them.
> Unfortunately, I have a problem now. I can't create dictionairies any
> more! And because braces aren't the only keys on the brace key,
> I can't create lists either. The solution for the latter is list(()),
> but how do I create an empty dictionairy without braces?

how about:

def List():
    return eval("\133\135")

def Dict():
    return eval("\173\175")

or the improved version:

def List(*args):
    return list(args)

def Dict(**args):
    return args

</F>







More information about the Python-list mailing list