pythonic equivalent of upvar?

Richie Hindle richie at entrian.com
Tue Dec 20 09:56:25 EST 2005


[David]
> I'm trying to write something with the same brevity 
> as perl's one-liner
> 
> eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift;

import sys, re
for arg in sys.argv[1:]:
    if re.match(r'\w+=.*', arg):
        exec arg
    else:
        break

-- 
Richie Hindle
richie at entrian.com



More information about the Python-list mailing list