default variable in python $_

rh0dium steven.klass at gmail.com
Tue Oct 10 18:23:07 EDT 2006


Hi all,

So I have this simple little routine..  say like this..


def foo()
   return {"a":"b", "b":"c"}

if foo():
   print "Have foo"


Now I want the dictionary item a (ie. b)

How can I do it the above way or do I still have to go like this..

def foo()
   return {"a":"b", "b":"c"}

z = foo()
if z:
   print "Have foo"
   print z['a']

This is where $_ in perl is awesome - There must be a default variable
in python right?




More information about the Python-list mailing list