python's newbie question

2006-10-12 Thread tpochep
Hi. I have some strange problem (this is usual for newbies :) ):

#!/usr/bin/python
#sample.py

class Base1:
def __init__(self):
print "Base1.__init__", self
def __del__(self):
print "Base1.__del__", self

class Base2:
def __init__(self):
print "Base2.__init__", self
def __del__(self):
print "Base2.__del__", self

class Derived(Base1, Base2):
def __init__(self):
print "Derived.__init__:"
Base1.__init__(self)
Base2.__init__(self)
def __del__(self):
print "Derived.__del__:"
Base1.__del__(self)
Base2.__del__(self)

print "begin..."
d = Derived()
b = d
print "end..."

The output of this script:

begin...
Derived.__init__:
Base1.__init__ <__main__.Derived instance at 0x1869adcc>
Base2.__init__ <__main__.Derived instance at 0x1869adcc>
end...
Derived.__del__:
Base1.__del__ <__main__.Derived instance at 0x1869adcc>
Base2.__del__ <__main__.Derived instance at 0x1869adcc>

If I change this program a little:

#!/usr/bin/python
#skipped

print "begin..."
d = Derived()
b1 = d #Here
print "end..."

The output is:

begin...
Derived.__init__:
Base1.__init__ <__main__.Derived instance at 0x1869adcc>
Base2.__init__ <__main__.Derived instance at 0x1869adcc>
end...
Derived.__del__:
Exception exceptions.AttributeError: "'NoneType' object has no
attribute '__del__'" in > ignored

I tried different names instead of b1, sometimes programm works,
sometimes I have an exception. So it's clear, that I've done some
stupid mistake, but it's not clear for me, python's newbie, where :)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python's newbie question

2006-10-12 Thread tpochep

js  писал(а):

> http://mail.python.org/pipermail/python-list/2004-May/221591.html
> 
> HTH

Thank you!!!

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python's newbie question

2006-10-12 Thread tpochep

Fredrik Lundh писал(а):

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list

python under the hood

2006-10-20 Thread tpochep
Hello.

Is there any good information about python's internals and semantic? I
mean "under the hood".
For example, I want to understant what do these strings

x = 10
y = 10
x = 20

mean (memory allocation for object? ctors? etc.)
Unfortynatly, I'm too lazy to read python's source code :) (and I
guess, it's not very easy :) )

-- 
http://mail.python.org/mailman/listinfo/python-list


python grammar

2007-01-22 Thread tpochep
Hello.

In 'augop' non-terminal :

http://docs.python.org/ref/augassign.html

the delimiter '//=' was skipped. Why?

In 'Boolean operations':

http://docs.python.org/ref/Booleans.html

In 'expression' rule - what does 'if', 'else' mean? I guess 'if' and
'else' must be keywords, not non-terminals.

-- 
http://mail.python.org/mailman/listinfo/python-list