Extending long

Freeman Stopjohn estama at dblab.ntua.gr
Wed Jun 19 16:20:39 EDT 2002

I'm trying to extend the long basic type with some bit manipulation
methods (using Python 2.2).
Below is the code fragment.

class bitnum(long):
    def getbit(self,bitn):
        if self & (1 << bitn) >0:
            return 1
            return 0
    def setbit(self,bitn):
        self=self ^ ( 1 << bitn )

 The getbit method works ok.
 The setbit doesn't (it doesn't change the number).

 What am i doing wrong?


More information about the Python-list mailing list