Hello everyone!
I started reading web2py book 3 days ago and I ran into a following
problem. Discussing the new instance of the class variables like in:
>>> class MyClass(object): pass
>>> myinstance = MyClass()
>>> myinstance.myvariable = 3
>>> print myinstance.myvariable
3
That's all fine but when I try:
>>> class MyClass(object): pass
>>> myinstance = MyClass()
>>> if not myinstance.myvariable:
...: myinstance.myvariable = 1
...: else:
...: myinstance.myvariable += 1
I get " AttributeError: 'MyClass' object has no attribute 'myvariable'
" and still this is the mechanism applied in web2py official book
under chapter 3, part "Let's Count"
def index():
if not session.counter:
session.counter = 1
else:
session.counter += 1
return dict(message="Hello from MyApp", counter=session.counter)
How;s that possible?
Thank You
Boyan
--
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en