Overloading __getitem__

inhahe inhahe at gmail.com
Thu May 22 18:43:53 EDT 2008


"inhahe" <inhahe at gmail.com> wrote in message 
news:LymZj.61584$3v1.36344 at bignews3.bellsouth.net...

> crazy = True
> print foo['a',crazy]
>
just to clarify, you could use it like:
crazy = "I'm crazy" #this only has to be done once

print foo['a']          #not crazy
print foo['a',crazy] #crazy

(this may be totally unPythonic, i don't know.)







More information about the Python-list mailing list