--- Begin Message ---
El Fri, 25 Jun 2010 18:30:26 +0200
Jesús Genicio <jgeni...@gmail.com> dijo:


Hola 


Mira esto a ver si te ayuda.

http://docs.python.org/faq/programming#id9

Saludos

Dr. Bobus

> Hola:
> 
> Necesito poder modificar los bits individuales de un valor determiando.
> Por ejemplo
> 
> Figure 6. CONFIGURATION REGISTER
> 
> MSb  bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 LSb
> DONE THF   TLF   NVB   R1    R0    POL*  1SHOT*
> 
> He declarado las siguientes variables:
> 
>       b_1Shot= 1
>       b_Pol= 2
>       b_R0= 4
>       b_R1= 8
>       b_TLF= 32
>       b_THF= 64
>       byt_Configuracion= 0
> 
> Y enciendo los bits de la manera:
> 
> byt_Configuracion |= b_R0
> 
> Y los apago:
> 
> byt_Configuracion ^= b_R0
> 
> El problema es que cuando se cambia una configuración, al intentar
> ejecutar el cambio me da este error "de novato claro :))"
> 
> Traceback (most recent call last):
>   File "ds1631.py", line 257, in cambio_grupo_resolucion
>     bit_Configuracion ^= b_R0
> UnboundLocalError: local variable 'bit_Configuracion' referenced before
> assignment
> 
> En fin.
> 
> S2
> 
> _______________________________________________
> Python-es mailing list
> Python-es@python.org
> http://mail.python.org/mailman/listinfo/python-es
> FAQ: http://python-es-faq.wikidot.com/


-- 
"Besides, I think Slackware sounds better than 'Microsoft,' don't you?"
(By Patrick Volkerding)

Attachment: signature.asc
Description: PGP signature


--- End Message ---
_______________________________________________
Python-es mailing list
Python-es@python.org
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a