is this a valid import sequence ?
Scott David Daniels
scott.daniels at acm.org
Sat Jun 23 14:03:03 EDT 2007
Stef Mientki wrote:
> ... I've defined a class, like this, ...
>
> class T6963_device (tDevice):
> def __init__ (self):
> global LCD
> LCD = self
> ... In the same module I've a function,
> that runs a method of the above class instance, ...
>
> def Write_LCD_Data ( data ):
> global LCD
> LCD.Write_Data ( data )
The global statement in Write_LCD_Data is completely unnecessary. The
only time you need "global" is if you want to reassociate the global
name to another object (such as LCD = LCD + 1 or whatever). You only
read the global name-to-object mapping (though you may be using methods
on the named object to alter the referenced object). You only need
"global" when you need to "write" (re-bind) the global name-to-object
mapping.
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list