[Hampshire] Python query

Top Page
Author: Hugo Mills
Date:  
To: Hants LUG
Subject: [Hampshire] Python query

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x5762b100.hantslug.org.uk.14320': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Wed Apr 29 12:20:52 2009 BST
gpg: using DSA key 20ACB3BE515C238D
gpg: Can't check signature: No public key
One for the Python programmers:

Given a class:

class Foo(object):
    def __init__(self):
        self.value = 0
        self.othervalue = 0


Is there an way I can sanely make this class behave like an
integer-with-extensions, with the value of .value?

i.e., allowing behaviours something like this:

x = Foo()
x = 4              # This one may be a bit tricky. :)
x += 3
print x - 2


Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
         --- If you're not part of the solution, you're part ---         
                           of the precipiate.