Life's better without braces

Christian Tismer tismer at tismer.com
Fri Feb 25 16:16:50 CET 2000


Gerrit Holl wrote:
> 
> Hello all,
> 
> 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?
> 
> I know I can do:
> >>> import os
> >>> d=os.environ.data
> >>> for k in d.keys():
> ...     del d[k]
> ...
> >>> d
> {}
> 
> But is there a more efficient way to do it? Does the 'new' modules has
> something I want?

>>> class braces:
... 	def __call__(self): return self.__dict__
... 	
>>> dic = braces()()
>>> dic
{}
>>> 

Well, the lack of [] doesn't make this too useful.
How about 

>>> help = braces()
>>> dic = help()
>>> help.thing = 42
>>> dic
{'thing': 42}
>>> 

> HELP!
> 
> If I'll rip off the ';' too, I won't be able to type blocks any more,
> since I won't be able to type a ':' either. Hmm, is it safe to rip
> off the '$'? I don't need a '4'!

I just successfully ripped out my ";", and it still works fine.
Hint : use a German keyboard.
Well, I'm missing the comma a little now.
No problem, since I can always change tuples to lists, modify
them and tuple them back.

Considering to remove the "o" key. It is too easily taken
as a zero. Now I don't write any for loops any longer,
back to the while 1 idiom.

ciao - chris  (xxps, cannot say "Pytxn" any longer)

-- 
Christian Tismer             :^)   <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
12163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home




More information about the Python-list mailing list