Re: [Hampshire] Python query

Góra strony
Autor: Chris Smith
Data:  
Dla: Hampshire LUG Discussion List
Temat: Re: [Hampshire] Python query

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x57a98100.hantslug.org.uk.25142': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: verify signatures failed: Unknown system error
Hugo Mills wrote:
[on creating a Python class]
>
>    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


You can redefine certain operators: __add__(), __sub__(), __mul__(),
etc. Unfortunately you don't appear to be able to do that for the
assignment operator. :(

Chris
--
Chris Smith <cjs94@???>