Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Chris Torek
In article <0ddc2626-7b99-46ee-9974-87439ae09...@e40g2000yqn.googlegroups.com> caccolangrifata wrote: >I'm very very new with python, and I have some experience with java >programming, so probably you guys will notice. >Anyway this is my question: >I'd like to use class scope vars in method param

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Chris Angelico
On Sat, Jul 23, 2011 at 5:16 AM, rantingrick wrote: > My chastisement of Bruno was only on the grounds of him failing to > offer the required amount of information to a new python programmer. > We should ALWAYS remove any ambiguities from our statements to new > users AND we should always link to

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread rantingrick
On Jul 22, 2:00 pm, John Gordon wrote: > Why did you say he (Bruno) was wrong? I'll admit my yelling the word "WRONG" may have been interpreted as me suggesting that bruno was completely wrong. Bruno is correct about all class identifiers starting with a capital letter HOWEVER if he just stops

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread caccolangrifata
Think that you can call you class as you want. If you use CamelCase notation than you are pro programmer? These are just conventions for better code reading and understanding, if I wanna call mYCLasS() python don't report an error, so I think it's useless discuss in that thread about that stuff.

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Chris Angelico
On Sat, Jul 23, 2011 at 5:00 AM, John Gordon wrote: > ... rantingrick writes ... > >> WRONG! > > Why did you say he was wrong? It's Ranting Rick. Why did you expect anything else? :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread John Gordon
In <8b6e5067-8861-4ffe-9e3f-4b932c798...@gc8g2000vbb.googlegroups.com> rantingrick writes: > On Jul 22, 10:43=A0am, "bruno.desthuilli...@gmail.com" > wrote: > > > > class names should start with an uppercase letter: > WRONG! Class identifiers should use the capwords convention > * class Foo

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Thomas Jollans
>> 2/ the argument name ('len') will shadow the builtin 'len' function >> within this function's scope. >> >>> self.__myvar = len > > I have experience in java programming so using function calling > without () is foolish for me XD, but that a great suggestion No function is being

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Thomas Jollans
On 22/07/11 20:38, rantingrick wrote: > On Jul 22, 10:43 am, "bruno.desthuilli...@gmail.com" > wrote: >> >> class names should start with an uppercase letter: > > WRONG! Class identifiers should use the capwords convention > All CamelCase names start with an uppercase letter. You "WRONG!" is wr

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread rantingrick
On Jul 22, 10:43 am, "bruno.desthuilli...@gmail.com" wrote: > > class names should start with an uppercase letter: WRONG! Class identifiers should use the capwords convention * class Foo * class FooBar * class FooBarBaz -- PEP8.Naming_Conventi

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Karim
Be careful when using double underscore prefix the variable is "said" to be private but in fact you can modify it. It is a convention to say don't change it. And to discourage to use it python change its name to '___myvar' appending the prefix '_' to it. See with your example: karim@Requiem

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread caccolangrifata
On Jul 22, 6:54 pm, Karim wrote: > You're right. Sure the method header is evaluated first I usually not > fall in this trap when default is a list but a singleton one with the same > id. > I answered too fast, I did not understand if he forget the dot or what. > And the double '_' in init was str

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread caccolangrifata
On Jul 22, 5:43 pm, "bruno.desthuilli...@gmail.com" wrote: > On Jul 22, 1:12 pm, caccolangrifata wrote: > > Totally OT but others already answered the question... > > > class foo(object): > > class names should start with an uppercase letter: > > class Foo(object): > > > > >         __init__(self

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Karim
You're right. Sure the method header is evaluated first I usually not fall in this trap when default is a list but a singleton one with the same id. I answered too fast, I did not understand if he forget the dot or what. And the double '_' in init was strange because he uses only one '_' after.

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread bruno.desthuilli...@gmail.com
On Jul 22, 1:12 pm, caccolangrifata wrote: Totally OT but others already answered the question... > class foo(object): class names should start with an uppercase letter: class Foo(object): > >         __init__(self, len = 9): 1/ you want to add a "def" statement before "__init__" 2/ the argu

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Thomas Jollans
On 22/07/11 13:32, Karim wrote: > > I think you did a typo > > it is > > def foo2(self, len = self._myvar): >while i< len: > dosomething > That, of course, won't work: the default argument (in this case: "self._myvar") is looked up when the function is created, and stored with th

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread caccolangrifata
On Jul 22, 1:33 pm, Thomas Jollans wrote: > On 22/07/11 13:12, caccolangrifata wrote: > > > I'm very very new with python, and I have some experience with java > > programming, so probably you guys will notice. > > Anyway this is my question: > > I'd like to use class scope vars in method paramete

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Thomas Jollans
On 22/07/11 13:12, caccolangrifata wrote: > I'm very very new with python, and I have some experience with java > programming, so probably you guys will notice. > Anyway this is my question: > I'd like to use class scope vars in method parameter, something like > that > > class foo(object): > >

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Karim
I think you did a typo it is def foo2(self, len = self._myvar): while i< len: dosomething You forget '.' dot between self and _myvar By the way in the function header you have only one '_' and in the init you have 2 '_'. Be careful that's not the same variable and behavior in

Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread caccolangrifata
I'm very very new with python, and I have some experience with java programming, so probably you guys will notice. Anyway this is my question: I'd like to use class scope vars in method parameter, something like that class foo(object): __init__(self, len = 9): self.__myvar