En Fri, 21 Nov 2008 13:58:59 -0200, r0g [EMAIL PROTECTED]
escribió:
I hadn't really appreciated the consequences of this till now though
e.g. that an instance might do a = a + 1 without affecting it's siblings
but that b.append(fish) would affect b for everyone. I don't know if I
will find any
Scott David Daniels wrote:
r0g wrote:
...
A class is like a template which combines a complex data type (made from
a combination of other data types) and the methods that operate on that
data type.
You generally don't work with classes directly but you make instances of
them, each instance
On Nov 21, 2008, at 8:58 AM, r0g wrote:
I hadn't really appreciated the consequences of this till now though
e.g. that an instance might do a = a + 1 without affecting it's
siblings
but that b.append(fish) would affect b for everyone. I don't know
if I
will find any uses for that kind of
I forgot to include a few cases:
(1) Inspired by your calling the class attributes templates:
class Demo3(object):
pass
d = Demo3()
print d.non_template # raises exception
d.non_template = 45
print d.non_template
print Demo3.non_template # raises exception
Scott David Daniels wrote:
I forgot to include a few cases:
(1) Inspired by your calling the class attributes templates:
I did no such thing, I likened classes to templates and as far as I can
tell they are _like_ templates albeit dynamic ones.
class Demo3(object):
All the above to
r0g wrote:
John Machin wrote:
You mention variables of a class but you then proceed to poke
at an instance of the class
Check out setattr (and getattr) in the docs.
The former i.e. the variables of an instance of a class. Thanks :-)
Careful here. Your wording seems to indicate you
Scott David Daniels wrote:
r0g wrote:
John Machin wrote:
You mention variables of a class but you then proceed to poke
at an instance of the class
Check out setattr (and getattr) in the docs.
The former i.e. the variables of an instance of a class. Thanks :-)
Careful here. Your
On Thu, Nov 20, 2008 at 3:54 PM, r0g [EMAIL PROTECTED] wrote:
Scott David Daniels wrote:
r0g wrote:
John Machin wrote:
You mention variables of a class but you then proceed to poke
at an instance of the class
Check out setattr (and getattr) in the docs.
The former i.e. the
r0g wrote:
...
A class is like a template which combines a complex data type (made from
a combination of other data types) and the methods that operate on that
data type.
You generally don't work with classes directly but you make instances of
them, each instance has it's own internal state and
On Nov 20, 6:54 pm, r0g [EMAIL PROTECTED] wrote:
It would seem from this setattr function that the proper term for these
is 'attributes'. That for many years I have considered pretty much any
named thing that may vary a 'variable' might be at the root of the
problem here as it's a very
On Thu, 20 Nov 2008 11:12:56 +1000, James Mills wrote:
DON'T USE eval!
If you're going to make a sweeping generalization like that, at least
offer some alternatives, and explain why eval should be avoided.
Otherwise your advice is just cargo-cult programming.
eval is not inherently bad, it
Hi There,
I know you can use eval to dynamically generate the name of a function
you may want to call. Can it (or some equivalent method) also be used to
do the same thing for the variables of a class e.g.
class Foo():
bar = 1
gum = 2
mylist = ['bar','gum']
a = Foo()
for each in mylist:
DON'T USE eval!
On Thu, Nov 20, 2008 at 10:44 AM, r0g [EMAIL PROTECTED] wrote:
Hi There,
I know you can use eval to dynamically generate the name of a function
you may want to call. Can it (or some equivalent method) also be used to
do the same thing for the variables of a class e.g.
class
On Nov 19, 7:44 pm, r0g [EMAIL PROTECTED] wrote:
Hi There,
I know you can use eval to dynamically generate the name of a function
you may want to call. Can it (or some equivalent method) also be used to
do the same thing for the variables of a class e.g.
class Foo():
bar = 1
gum = 2
On Nov 20, 11:44 am, r0g [EMAIL PROTECTED] wrote:
Hi There,
I know you can use eval to dynamically generate the name of a function
you may want to call. Can it (or some equivalent method) also be used to
do the same thing for the variables of a class e.g.
class Foo():
bar = 1
gum = 2
George Sakkis wrote:
On Nov 19, 7:44 pm, r0g [EMAIL PROTECTED] wrote:
Hi There,
I know you can use eval to dynamically generate the name of a function
you may want to call. Can it (or some equivalent method) also be used to
do the same thing for the variables of a class e.g.
class Foo():
John Machin wrote:
On Nov 20, 11:44 am, r0g [EMAIL PROTECTED] wrote:
Hi There,
I know you can use eval to dynamically generate the name of a function
you may want to call. Can it (or some equivalent method) also be used to
do the same thing for the variables of a class e.g.
class Foo():
17 matches
Mail list logo