mark.sea...@gmail.com wrote:
On Mar 29, 9:52 pm, Chris Rebert <c...@rebertia.com> wrote:
On Sun, Mar 29, 2009 at 9:18 PM,  <mark.sea...@gmail.com> wrote:
...
... Also, you shouldn't use `class_ ` as the name of the first argument to
__new__(). Use `cls` instead since that's the conventional name for
it.
Actually, according to PEP 8, class_ is the preferred name.

My best guess as to what you're trying to do is (completely untested):
class myclass(long):
    def __new__(cls, init_val, reg_info):
        print reg_info.message
        instance = long.__new__(cls, init_val)
        instance.reg_info = reg_info
        return instance

Normally, these changes are done in the __init__ phase (post-instance creation), so you might go for something like:

    class myclass(long):
        def __new__(class_, init_val, reg_info):
            return long.__new__(class_, init_val)

        def __init__(self, init_val, reg_info):
            self.reg_info = reg_info


--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to