Uh, I think I've found another problem with the new snapshot.
According to Python reference manual, I should be able to use class
variables as default values to class instances. For example:
class Foo:
home = os.environ["HOME"]
... methods in which the class instance can change the value of
self.home; otherwise, self.home will refer to $HOME ...
However, this doesn't appear to work with lateish PyGtk snapshots when
Foo inherits from Gtk classes:
import os
from gtk import *
class Foo (GtkWindow):
home = os.environ["HOME"]
def __init__ (self):
GtkWindow.__init__ (self)
def changehome (self, newhome):
self.home = newhome
foo = Foo ()
print foo.home
foo.changehome ("/")
print foo.home
I would expect this example to print "/home/srce/hniksic" and then
"/". However, it prints "/home/srce/hniksic" twice because
foo.changehome() doesn't change foo.home at all. :-(
If I change this trivial example *not* to inherit from a Gtk class (or
to inherit from any other class), it works as expected. It took me
almost two hours to track this nasty gotcha. Could you please revert
to the old behaviour where I believe this problem did not occur?
The quote from the reference manual which recommends this practice
follows (note the last sentence):
*Programmer's note:* variables defined in the class definition are
class variables; they are shared by all instances. To define
instance variables, they must be given a value in the the
`__init__()' method or in another method. Both class and instance
variables are accessible through the notation "`codeself.name",
and an instance variable hides a class variable with the same name
when accessed in this way. Class variables with immutable values
can be used as defaults for instance variables.
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]