variable & scoping question.
bieffe62 at gmail.com
Mon Aug 10 17:36:52 CEST 2009
On Aug 10, 5:12 pm, "Diez B. Roggisch" <de... at 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.
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 ...
More information about the Python-list