On 2006-10-06 04:50:33 +0200, s99999999s2003 at yahoo.com wrote:
> say i have variables like these
>> var1 = "blah"
> var2 = "blahblah"
> var3 = "blahblahblah"
> var4 = "...."
> var5 = "..."..
>> bcos all the variable names start with "var", is there a way to
> conveniently print those variables out...
> eg print var* ??
> i don't want to do :
>> print var1, var2, var3, var4 ......etc...
Don't do this:
>>> import fnmatch
>>> var1, var2, var3 = "foo", "bar", "baz"
>>> for k in fnmatch.filter(locals(), "var*"):
... print locals()[k]
...
foo
baz
bar
This is evil.
It's unpythonic.
This is yet another way to do it - QED.
Gerrit.