jeffp at crusoe.net
Fri Mar 17 15:33:36 CET 2000
On Mar 17, Michal Bozon said:
>I want to have a function (of course in Python) equivalent to Pascal
>function int(). (It increments an integer stored in argument by 1).
>>>> int(i, 2)
First, you'd better not call it int(), because that'd cause some sillyness
-- there's a builtin int(). For sake of argument, I'll call it inc().
globals()[var] = globals()[var] + i
foo = 20
print foo # 21
print foo # 31
Notice I passed the variable's NAME in a string. That's the only way I've
figured out so far to muck with a global object like a string or number
inside a function. I can't even assure that it's bug-free.
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve japhy at pobox.com
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
More information about the Python-list