How do I modify my callers local variables?

Andreas Dietrich andreas.dietrich at news.online.de
Mon Feb 12 17:48:08 EST 2001


On Mon, 12 Feb 2001 21:27:10 +0100, I wrote:
>def test(**kw):
>    parse_keywords({'a':1,'b':2,'c':3},kw)
>    #didn't work
>    print a,b,c
>
>test()

I hate to post a followup to my own posting, but I forgot to point out the
_real_ problem. It doesn't work even if I replace test() with

def test(**kw):
    a=b=c=0
    parse_keywords({'a':1,'b':2,'c':3},kw)
    #didn't work
    print a,b,c

I'm aware of the fact that python considers variables as global that are
not assigned to (Could I modify _that_ from parse_keywords ? If not, this
not a showstopper. )

Andreas

-- 
"We've heard that a million monkeys at a million keyboards could produce the
complete works of Shakespeare. Now, thanks to the Internet, we know this is not
true."  -- Robert Wilensky




More information about the Python-list mailing list