Python Programming Ettiquette

Aahz Maruch aahz at panix.com
Thu Apr 12 14:54:17 EDT 2001


In article <vnfadtk88jubujk8b4egfmkrjgehumnh26 at 4ax.com>,
zzzzz  <zzizz_ at notmail.com> wrote:
>
>If I want to change a variable value from within a function I believe
>I have two options:
>
>a) Directly modify the parameter:
>x=[1,2,3]
>def add4tolist(inputlist):
>   inputlist.append(4)
>add4tolist(x)
>x
>[1,2,3,4]

If you want to do this, you should make x a class instance, so that
instead you're doing x.add4tolist()
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het Pythonista   http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Why is this newsgroup different from all other newsgroups?



More information about the Python-list mailing list