Whither SmallScript? (was Re: Integer micro-benchmarks)
wolfson at uchicago.edu
Wed May 2 14:21:19 EDT 2001
In article <3AF032C6.2F81D489 at san.rr.com>, "Darren New" <dnew at san.rr.com>
[in Python, ]
> instances of the same class must have the same set of instance
> variables. (In one sense, all instances of a class have the same
> instance variables, but one of those instance variables is a dictionary
> mapping instance variable names to values, and the syntax makes this
> mostly invisible.)
> I think if you want to add an instance variable to all instances of a
> class, you need to write a loop to iterate over all those instances. I'm
> not sure whether you could find them.
You can add attributes to either classes or instances in Python.
Python 2.1 (#1, Apr 21 2001, 18:56:55)
[GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> class C:
self.someval = 5
>>> c = C()
>>> C.someotherval = 'no'
>>> c.yetanotherval = (1,5)
Barnabas T. Rumjuggler
"Et tu, Brute?" sedulous.
-- barry in indy, in apihna
More information about the Python-list