Wednesday, April 11, 2012

Python programming issues for today

Technically, globals for read and write back, I've read tend to be less desirable in programming, but I've resorted this only for the sake of easing flow of data in read/write chains.

If you one needs access to a global, the reserved python token 'global' followed by your variable name, will inside class function or function regardless ensure that a the object variable is in reference to a global object and not a function scope limited or class limited variable. 

Why to use globals at the moment?!  Well it seems the problem were the instantiation of numerous class objects from a parent object that neither provided object inheritance to such child objects.  Here the parent object having reference to object variable data is no good, and otherwise, it seems to me logically one would have to pass on each read/write call back from parent to child necessarily object data along the pathway outside of using a global object that could be referenced to both parent and child, or the other dreadful, method is to use some input/output method to a datafile.  Literally reading from the harddrive...yuck...if I can avoid it would rather avoid here.  The later actually happened to me first, as I carelessly put an file read i/o inside a class instantiation that would be called numerous times just for program initialisation.  Here I instead opted to decrease read/write loads to single i/o operations and then globalized this particular data, here any child class object could access this and refreshes to such data could be done in single as opposed to multiplicity based transactions.  This is to say instead of refreshing data inside all such child class objects at once, data is refreshed on an as needed basis when the child class object calls for need of such data.  The 'better' method of this, however, were to pass a data access or class object through the class object hierarchy which will probably be code revision point in days ahead.

 

No comments:

Post a Comment

Oblivion

 Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...