Re: Indexed variables

2005-09-27 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: > Hello, > > being an almost complete Python AND programming neophyte I would like to ask > the following - very elementary, as I might suspect - question: > > How do I do the following flawed things right: > > > a1=a2=0 > > def f(x): > if x == a1: > a1 =

Re: Indexed variables

2005-09-22 Thread Laszlo Zsolt Nagy
>If you really want to change an actual parameter inside an object, then > > inside a function, I mean -- http://mail.python.org/mailman/listinfo/python-list

Re: Indexed variables

2005-09-22 Thread Tom Anderson
On Thu, 22 Sep 2005 [EMAIL PROTECTED] wrote: > How do I do the following flawed things right: Well, that depends on what you mean by 'right'. I'm going to give you two solutions; one that answers your apparent question, and one that addresses what i suspect is your true question. > a1=a2=0 > >

Re: Indexed variables

2005-09-22 Thread Rocco Moretti
[EMAIL PROTECTED] wrote: > So how do I define the function such as to discrimate wheter I call it by > f(a1) or f(a2) ? I don't want to sound rude, but I think you'll be better served by telling us why you would want to do such a thing - ten to one someone can suggest a better way to acomplish

Re: Indexed variables

2005-09-22 Thread Laszlo Zsolt Nagy
>a1=a2=0 > >def f(x): >if x == a1: >a1 = a1 + 1 >elif x == a2: >a2 = a2 + 1 > > >Now if I call f with f(a2) only a1, of course, is incremented because the >if-clause does only check for the value of the input and the values of a1 >and a2 are identical. > >So how do I define

Indexed variables

2005-09-22 Thread python-novice
Hello, being an almost complete Python AND programming neophyte I would like to ask the following - very elementary, as I might suspect - question: How do I do the following flawed things right: a1=a2=0 def f(x): if x == a1: a1 = a1 + 1 elif x == a2: a2 = a2 + 1 Now