[TransWarp] read tutorial...
Phillip J. Eby
pje at telecommunity.com
Sun Mar 2 17:19:36 EST 2003
At 09:21 PM 3/2/03 +0200, Vladimir Bormotov wrote:
> Hi!
>
> 2.2.1 Binding fundamental
>
>ws:~$ python
>Python 2.2.2 (#1, Feb 13 2003, 13:34:47)
>[GCC 2.96 20000731 (ASPLinux 7.3 2.96-113)] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
> >>> from peak.api import binding
> >>> class Car:
>.. passengers = binding.New(dict, 'passengers')
>..
> >>> aCar = Car()
> >>> print aCar.passengers
>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
>AttributeError: Car instance has no attribute 'passengers'
> >>> dir(aCar)
>['__doc__', '__module__', 'passengers']
>
>
> whats wrong?
It looks as though, during the time since I wrote that part of the
tutorial, that binding functions no longer work with "classic classes". I
suspect this must have happened when I rewrote the Once base class in
Pyrex/C. Also, the signature of binding.New() has changed slightly. So,
to correct the code above, it should read:
>>> class Car(object):
passengers = binding.New(dict, name='passengers')
There may be other out-of-date items in the tutorial as well. I'm checking
in the above change to the tutorial source code now, but it may be a while
before I can update the PDF version.
More information about the PEAK
mailing list