Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10095 > unrolled thread
| Started by | caccolangrifata <caccolangrifata@gmail.com> |
|---|---|
| First post | 2011-07-22 04:12 -0700 |
| Last post | 2011-07-22 22:22 +0000 |
| Articles | 19 — 8 participants |
Back to article view | Back to comp.lang.python
Use self.vars in class.method(parameters, self.vars) caccolangrifata <caccolangrifata@gmail.com> - 2011-07-22 04:12 -0700
Re: Use self.vars in class.method(parameters, self.vars) Karim <karim.liateni@free.fr> - 2011-07-22 13:32 +0200
Re: Use self.vars in class.method(parameters, self.vars) Thomas Jollans <t@jollybox.de> - 2011-07-22 13:33 +0200
Re: Use self.vars in class.method(parameters, self.vars) caccolangrifata <caccolangrifata@gmail.com> - 2011-07-22 05:02 -0700
Re: Use self.vars in class.method(parameters, self.vars) Thomas Jollans <t@jollybox.de> - 2011-07-22 14:06 +0200
Re: Use self.vars in class.method(parameters, self.vars) "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> - 2011-07-22 08:43 -0700
Re: Use self.vars in class.method(parameters, self.vars) caccolangrifata <caccolangrifata@gmail.com> - 2011-07-22 09:50 -0700
Re: Use self.vars in class.method(parameters, self.vars) Thomas Jollans <t@jollybox.de> - 2011-07-22 20:58 +0200
Re: Use self.vars in class.method(parameters, self.vars) rantingrick <rantingrick@gmail.com> - 2011-07-22 11:38 -0700
Re: Use self.vars in class.method(parameters, self.vars) Thomas Jollans <t@jollybox.de> - 2011-07-22 20:49 +0200
Re: Use self.vars in class.method(parameters, self.vars) John Gordon <gordon@panix.com> - 2011-07-22 19:00 +0000
Re: Use self.vars in class.method(parameters, self.vars) Chris Angelico <rosuav@gmail.com> - 2011-07-23 05:12 +1000
Re: Use self.vars in class.method(parameters, self.vars) caccolangrifata <caccolangrifata@gmail.com> - 2011-07-22 12:41 -0700
Re: Use self.vars in class.method(parameters, self.vars) rantingrick <rantingrick@gmail.com> - 2011-07-22 12:16 -0700
Re: Use self.vars in class.method(parameters, self.vars) Chris Angelico <rosuav@gmail.com> - 2011-07-23 06:20 +1000
Re: Use self.vars in class.method(parameters, self.vars) Karim <karim.liateni@free.fr> - 2011-07-22 18:54 +0200
Re: Use self.vars in class.method(parameters, self.vars) caccolangrifata <caccolangrifata@gmail.com> - 2011-07-22 09:59 -0700
Re: Use self.vars in class.method(parameters, self.vars) Karim <karim.liateni@free.fr> - 2011-07-22 19:26 +0200
Re: Use self.vars in class.method(parameters, self.vars) Chris Torek <nospam@torek.net> - 2011-07-22 22:22 +0000
| From | caccolangrifata <caccolangrifata@gmail.com> |
|---|---|
| Date | 2011-07-22 04:12 -0700 |
| Subject | Use self.vars in class.method(parameters, self.vars) |
| Message-ID | <0ddc2626-7b99-46ee-9974-87439ae09f1e@e40g2000yqn.googlegroups.com> |
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 = len
def foo2(self, len = self_myvar):
while i < len:
dosomething
I want to use optional parameter, so i can use
myfoo = foo() or myfoo = foo(20)
and also
foo.foo2(20) or foo.foo2()
but in def foo2(self, len = self_myvar):
^
self is undefined, so:
How can I do this stuff?
[toc] | [next] | [standalone]
| From | Karim <karim.liateni@free.fr> |
|---|---|
| Date | 2011-07-22 13:32 +0200 |
| Message-ID | <mailman.1361.1311334346.1164.python-list@python.org> |
| In reply to | #10095 |
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 case you want
to access it.
Regards
Karim
On 07/22/2011 01:12 PM, 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):
>
> __init__(self, len = 9):
> self.__myvar = len
>
> def foo2(self, len = self_myvar):
> while i< len:
> dosomething
>
>
> I want to use optional parameter, so i can use
> myfoo = foo() or myfoo = foo(20)
> and also
> foo.foo2(20) or foo.foo2()
>
> but in def foo2(self, len = self_myvar):
> ^
> self is undefined, so:
> How can I do this stuff?
[toc] | [prev] | [next] | [standalone]
| From | Thomas Jollans <t@jollybox.de> |
|---|---|
| Date | 2011-07-22 13:33 +0200 |
| Message-ID | <mailman.1362.1311334382.1164.python-list@python.org> |
| In reply to | #10095 |
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):
>
> __init__(self, len = 9):
> self.__myvar = len
>
> def foo2(self, len = self_myvar):
> while i < len:
> dosomething
>
I think what you want to do is this:
class foo (object):
def __init__(self, len=9):
self._len = len
def foo2(self, len=None):
if len is None:
len = self._len
# ...
Default arguments are for when you want to use exactly the same object
each time the function/method is called. If you the object you want to
use depends on something, you can use this arg=None idiom.
[toc] | [prev] | [next] | [standalone]
| From | caccolangrifata <caccolangrifata@gmail.com> |
|---|---|
| Date | 2011-07-22 05:02 -0700 |
| Message-ID | <018812a9-1c2c-45eb-a85e-1094263f2b47@y13g2000yqy.googlegroups.com> |
| In reply to | #10099 |
On Jul 22, 1:33 pm, Thomas Jollans <t...@jollybox.de> 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 parameter, something like > > that > > > class foo(object): > > > __init__(self, len = 9): > > self.__myvar = len > > > def foo2(self, len = self_myvar): > > while i < len: > > dosomething > > I think what you want to do is this: > > class foo (object): > def __init__(self, len=9): > self._len = len > def foo2(self, len=None): > if len is None: > len = self._len > # ... > > Default arguments are for when you want to use exactly the same object > each time the function/method is called. If you the object you want to > use depends on something, you can use this arg=None idiom. Yep! Leaving aside the typos, that's exactly I want to do. Thanks!
[toc] | [prev] | [next] | [standalone]
| From | Thomas Jollans <t@jollybox.de> |
|---|---|
| Date | 2011-07-22 14:06 +0200 |
| Message-ID | <mailman.1363.1311336366.1164.python-list@python.org> |
| In reply to | #10095 |
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 the function. "self" does not exist at that point. (or, if it does, it's the wrong "self")
[toc] | [prev] | [next] | [standalone]
| From | "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> |
|---|---|
| Date | 2011-07-22 08:43 -0700 |
| Message-ID | <cd43a7b5-a6fd-4a9f-9193-936600462c63@a1g2000yqp.googlegroups.com> |
| In reply to | #10095 |
On Jul 22, 1:12 pm, caccolangrifata <caccolangrif...@gmail.com> 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 argument name ('len') will shadow the builtin 'len' function
within this function's scope.
> self.__myvar = len
There are very few reasons to invoke the __name_mangling mechanism.
Canonically, implementation attributes (ie: not part of the API) are
written with a *single* leading underscore. Also and FWIW, there's no
need to "hide" public attributes and add dummy accessors in Python
since you can turn a plain attribute into a computed one latter
without breaking client code, so only use _implementation attributes
if you really mean implementation.
> def foo2(self, len = self_myvar):
> while i < len:
> dosomething
Most of the time, this is spelled:
for x in <somesquence>:
do_something
Note that range() can provide the required sequence.
> I want to use optional parameter, so i can use
> myfoo = foo() or myfoo = foo(20)
> and also
> foo.foo2(20) or foo.foo2()
Note that default values for function params are only computed once,
when the def statement is evaluated. This is a famous gotcha,
specially if you use some mutable object as default value...
Also, since neither the class nor - a fortiori - the instance exist
when the def statement is evaluated, there's no way to make reference
to the instance at this time.
[toc] | [prev] | [next] | [standalone]
| From | caccolangrifata <caccolangrifata@gmail.com> |
|---|---|
| Date | 2011-07-22 09:50 -0700 |
| Message-ID | <3bff4eaa-b2ed-4a72-b7ec-eddee75159a1@l18g2000vbe.googlegroups.com> |
| In reply to | #10114 |
On Jul 22, 5:43 pm, "bruno.desthuilli...@gmail.com"
<bruno.desthuilli...@gmail.com> wrote:
> On Jul 22, 1:12 pm, caccolangrifata <caccolangrif...@gmail.com> 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__"
as just said, Leaving aside the typos ...
> 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
>
> There are very few reasons to invoke the __name_mangling mechanism.
> Canonically, implementation attributes (ie: not part of the API) are
> written with a *single* leading underscore. Also and FWIW, there's no
> need to "hide" public attributes and add dummy accessors in Python
> since you can turn a plain attribute into a computed one latter
> without breaking client code, so only use _implementation attributes
> if you really mean implementation.
I do not really already understand the mechanism of using private
public vars in python.
>
> > def foo2(self, len = self_myvar):
> > while i < len:
> > dosomething
>
> Most of the time, this is spelled:
>
> for x in <somesquence>:
> do_something
>
> Note that range() can provide the required sequence.
yep..when the range is known is better use for right.
>
> > I want to use optional parameter, so i can use
> > myfoo = foo() or myfoo = foo(20)
> > and also
> > foo.foo2(20) or foo.foo2()
>
> Note that default values for function params are only computed once,
> when the def statement is evaluated. This is a famous gotcha,
> specially if you use some mutable object as default value...
>
> Also, since neither the class nor - a fortiori - the instance exist
> when the def statement is evaluated, there's no way to make reference
> to the instance at this time.
[toc] | [prev] | [next] | [standalone]
| From | Thomas Jollans <t@jollybox.de> |
|---|---|
| Date | 2011-07-22 20:58 +0200 |
| Message-ID | <mailman.1382.1311361087.1164.python-list@python.org> |
| In reply to | #10116 |
>> 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 called. It's just that if you tried using the len()
function within that method (where there is a variable called `len'), it
wouldn't work: Python would take your variable and try to call it, not
the builtin function object.
> I do not really already understand the mechanism of using private
> public vars in python.
Everything is public.
self._foo (leading underscore) is, by convention, used for internal
member variables and methods.
Two leading underscores are the closest thing there is to "private": The
name is mangled, and won't be visible to subclasses or external code
under that name (but there's nothing preventing anybody from changing it)
[toc] | [prev] | [next] | [standalone]
| From | rantingrick <rantingrick@gmail.com> |
|---|---|
| Date | 2011-07-22 11:38 -0700 |
| Message-ID | <8b6e5067-8861-4ffe-9e3f-4b932c79878e@gc8g2000vbb.googlegroups.com> |
| In reply to | #10114 |
On Jul 22, 10:43 am, "bruno.desthuilli...@gmail.com"
<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_Conventions.Class_Names
--------------------------------------------------
Almost without exception, class names use the CapWords convention.
Classes for internal use have a leading underscore in addition.
--------------------------------------------------
Make sure to follow this directive to a "T" because if you don't, i
can assure you that you will regret it! I would actually change
"Almost without exception" to "WITHOUT EXCEPTION" myself. Actually in
RickPy4000 naming conventions are going to be enforced -- follow them
or die of exceptions.
*Case in point:*
Some folks refuse to cap "all" words because they "think" some words
are actually a single "compound word". And in the real world they are
correct but in the case sensitve world of programming this can bite
you in the arse later.
Consider:
class Messagebox
class Listview
class Combobox
class ScrolledTextbox
Now later on when you are writing some code you cannot remember which
words you capped and which you did NOT cap. Best thing to do is ALWAYS
cap every word. In other words, be consistent!
class MessageBox
class ListView
class ComboBox
class ScrolledTextBox
*school-bell-rings*
PS: Someone needs to create links in the PEP for faster navigation to
topic of interest OR we need to create a new module called
"styleguide.py"
>>> import styleguide
>>> styleguide.naming_conventions('class')
"Almost without exception, class names use the CapWords convention.
Classes for internal use have a leading underscore in addition."
PEP8: http://www.python.org/dev/peps/pep-0008/
[toc] | [prev] | [next] | [standalone]
| From | Thomas Jollans <t@jollybox.de> |
|---|---|
| Date | 2011-07-22 20:49 +0200 |
| Message-ID | <mailman.1381.1311360555.1164.python-list@python.org> |
| In reply to | #10131 |
On 22/07/11 20:38, rantingrick wrote: > On Jul 22, 10:43 am, "bruno.desthuilli...@gmail.com" > <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 wrong. Twat.
[toc] | [prev] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2011-07-22 19:00 +0000 |
| Message-ID | <j0chcb$mh9$1@reader1.panix.com> |
| In reply to | #10131 |
In <8b6e5067-8861-4ffe-9e3f-4b932c79878e@gc8g2000vbb.googlegroups.com> rantingrick <rantingrick@gmail.com> writes:
> On Jul 22, 10:43=A0am, "bruno.desthuilli...@gmail.com"
> <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
But those names do, in fact, start with an uppercase letter as Bruno said.
Perhaps Bruno omitted how the remainder of the name should be handled, but
he was certainly right about the first letter being capitalized.
Why did you say he was wrong?
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-07-23 05:12 +1000 |
| Message-ID | <mailman.1383.1311361961.1164.python-list@python.org> |
| In reply to | #10135 |
On Sat, Jul 23, 2011 at 5:00 AM, John Gordon <gordon@panix.com> wrote: > ... rantingrick <rantingrick@gmail.com> writes ... > >> WRONG! > > Why did you say he was wrong? It's Ranting Rick. Why did you expect anything else? :) ChrisA
[toc] | [prev] | [next] | [standalone]
| From | caccolangrifata <caccolangrifata@gmail.com> |
|---|---|
| Date | 2011-07-22 12:41 -0700 |
| Message-ID | <11a2bee1-fc5f-4610-a01d-de05e2600ecf@y13g2000yqy.googlegroups.com> |
| In reply to | #10137 |
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.
[toc] | [prev] | [next] | [standalone]
| From | rantingrick <rantingrick@gmail.com> |
|---|---|
| Date | 2011-07-22 12:16 -0700 |
| Message-ID | <9ab08c6b-f672-4276-9bd0-00b565839528@k27g2000yqn.googlegroups.com> |
| In reply to | #10135 |
On Jul 22, 2:00 pm, John Gordon <gor...@panix.com> 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 at that point and does not explain the "CapWords convention" lots of people may start down the road of a foolish consistency. 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 the PEP8 when these type of style questions come up. It is SO very important that WE as a community are consistent in our syntactical conventions. For me PEP8 does not go far enough and very soon i will draft a "PyWart Expose" concerning the matter.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-07-23 06:20 +1000 |
| Message-ID | <mailman.1389.1311366020.1164.python-list@python.org> |
| In reply to | #10148 |
On Sat, Jul 23, 2011 at 5:16 AM, rantingrick <rantingrick@gmail.com> 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 the PEP8 when these type of style > questions come up. > In other words, every new Python programmer must be sat down with a massive manual and ordered to read it until his eyes bleed and he goes off and finds some other language to use. Is it better for Python if we ensure that all Python code written is written perfectly, or is it better to allow people to write code, use code, learn code, and then later on, learn to do things more conveniently? You really need to learn the difference between language requirements and stylistic advice. You're trying to turn the latter into the former, but there is a good reason for language flexibility. Why am I responding to these trolls? And why am I being so polite as I do so? Rick, put up or shut up. Get some code down or quit talking. (Oh and those are not exclusive ors.) ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Karim <karim.liateni@free.fr> |
|---|---|
| Date | 2011-07-22 18:54 +0200 |
| Message-ID | <mailman.1369.1311353663.1164.python-list@python.org> |
| In reply to | #10095 |
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. Thanks to take time to point that. Regards Karim On 07/22/2011 02:06 PM, Thomas Jollans wrote: > 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 the function. "self" does not exist at that point. (or, if it does, > it's the wrong "self") >
[toc] | [prev] | [next] | [standalone]
| From | caccolangrifata <caccolangrifata@gmail.com> |
|---|---|
| Date | 2011-07-22 09:59 -0700 |
| Message-ID | <4b8bf7a1-4d4f-4f72-9b5e-3dcce0dd6114@ft10g2000vbb.googlegroups.com> |
| In reply to | #10117 |
On Jul 22, 6:54 pm, Karim <karim.liat...@free.fr> 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 strange because he uses only one '_' after.
>
> Thanks to take time to point that.
>
> Regards
> Karim
>
> On 07/22/2011 02:06 PM, Thomas Jollans wrote:
>
>
>
>
>
>
>
> > 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 the function. "self" does not exist at that point. (or, if it does,
> > it's the wrong "self")
class foo(object):
def __init__(self, len = 9):
self.__myvar = len
def foo2(self, len = self.__myvar):
while i < len:
do_something
that the initial code, "." and "_" forgot
[toc] | [prev] | [next] | [standalone]
| From | Karim <karim.liateni@free.fr> |
|---|---|
| Date | 2011-07-22 19:26 +0200 |
| Message-ID | <mailman.1375.1311355578.1164.python-list@python.org> |
| In reply to | #10118 |
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 '_<class name>__myvar' appending the prefix '_<class name>' to it. See with your example: karim@Requiem4Dream:~$ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = foo() >>> dir(a) ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_foo__myvar', 'foo2'] In the instance namespace your attribute was transformed in '_foo__myvar'. This is a veritable mess when you want to access from outside your class this attribute. For maintenance when you inherited you have huge coupling NEVER DO THAT (advice): In case you change the name of your class and reference this attribute in external class you will end up with huge trouble to change the name in all referenced code. With one '_' it says to others well this is my non public variable don't use it (this is a convention because you can still modify it in python. Cheers Karim On 07/22/2011 06:59 PM, caccolangrifata wrote: > while i< len:
[toc] | [prev] | [next] | [standalone]
| From | Chris Torek <nospam@torek.net> |
|---|---|
| Date | 2011-07-22 22:22 +0000 |
| Message-ID | <j0ct7301fo4@news7.newsguy.com> |
| In reply to | #10095 |
In article <0ddc2626-7b99-46ee-9974-87439ae09f1e@e40g2000yqn.googlegroups.com>
caccolangrifata <caccolangrifata@gmail.com> 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 ...
Others have answered what appears to have been your actual
question. Here's an example of using an actual "class scope
variable".
(Note: I have a sinus headache, which is probably the source
of some of the weirder names :-) )
class Florg(object):
_DEFAULT_IPPY = 17
@classmethod
def set_default_ippy(cls, ippy):
cls._DEFAULT_IPPY = ippy
def __init__(self, name, ippy = None):
if ippy is None:
ippy = self.__class__._DEFAULT_IPPY
self.name = name
self.ippy = ippy
def zormonkle(self):
print('%s ippy = %s' % (self.name, self.ippy))
def example():
flist = [Florg('first')]
flist.append(Florg('second'))
flist.append(Florg('third', 5))
Florg.set_default_ippy(-4)
flist.append(Florg('fourth'))
flist.append(Florg('fifth', 5))
for florg in flist:
florg.zormonkle()
if __name__ == '__main__':
example()
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web