Francesco Bochicchio wrote:
On Aug 10, 5:12 pm, "Diez B. Roggisch" <de...@nospam.web.de> wrote:
Cornelius Keller wrote:
Hi,
I'm a quite fresh python programmer, (6 Month python experience).
Today I found something I absolotly don'nt understand:
given the following function:
def test_effect(class_id=None,class_ids=[]):
    if class_id is not None:
        if class_id not in class_ids:
            class_ids.append(int(class_id))
    print class_ids
I observe that the class_ids array is growing when it is called with
different class id's.
I expected class_ids to be [] if the keyword argument is not set, but
it seems to beahve like a static variable if not set.
http://effbot.org/zone/default-values.htm

Diez

Maybe on the first page of python.org there should be a 'python
gotchas' link to a page listing these few
non-intuituive peculiarities of our beloved snake ... same goes for
the official python tutorial ...

Should they be called 'snake bites'? Well, pythons are constrictors, not
biters, but if Python is being non-intuitive... :-)
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to