Can I reference 1 instance of an object by more names ? rephrase
Stef Mientki
S.Mientki-nospam at mailbox.kun.nl
Thu May 24 15:51:00 EDT 2007
Maric Michaud wrote:
> def bit():
> def fset(self, value):
> index = 5
> value = ( value & 1L ) << index
> mask = ( 1L ) << index
> self._d = ( self._d & ~mask ) | value
> def fget(self):
> index = 5
> return ( self._d >> index ) & 1
> return property(**locals())
>
>
> class cpu_ports(object) :
>
> p1 = bit()
> p2 = bit()
> p3 = bit()
> p4 = bit()
> p5 = bit()
>
Looks good, but I miss the index :-(
p3 = bit(3)
I tried several of these kind of constructs,
but I can't find a way to pass the index of the bit,
all trials gave Python errors.
This is obvious above my level of knowledge.
So if this isn't possible, I just use the 8 copies ;-)
> But i wonder if you shouldn't use arrays instead :
>
> In [6]:import array
>
> In [7]:help(array)
>
I don't think arrays will help, because most operations will be done on a complete byte.
btw, the first notes about what I'm planning to do, can be seen here:
http://oase.uci.ru.nl/~mientki/data_www/pic/jalcc/python/jal_simulation.html
thanks,
Stef Mientki
>
>
>
More information about the Python-list
mailing list