How do I chain methods?

chad cdalten at gmail.com
Sun Oct 24 18:47:47 EDT 2010


I tried the following...



#!/usr/bin/python

class foo:
    def first(self):
        print "Chad "

    def last(self):
        print "A "

x = foo()
y = x.first()
y.last()

But when I ran it, I got the following...

[cdalten at localhost oakland]$ ./chain.py
Chad
Traceback (most recent call last):
  File "./chain.py", line 12, in ?
    y.last()
AttributeError: 'NoneType' object has no attribute 'last'
[cdalten at localhost oakland]$



More information about the Python-list mailing list