Connecting Tech Pros Worldwide Help | Site Map

Python beginner, global variables, pointers

Newbie
 
Join Date: Jul 2009
Posts: 1
#1: Jul 8 '09
Hi. I've coded some stuff a long time ago, and didn't have reason to take up programming until now. I've learned Python 'on-the-go' and now ran into the idea of avoiding global variables of any kind.

Are there any basic techniques used to avoid global variables? I have a bunch of functions defined to make it easier to debug and develop. The only way I came up with is to send all the necessary variables to each function, but I'm not sure if it's the right way to go.

Also, I've missed pointers in Python. My program is a version of the maze-solver, which needs to dynamically approach multi-way intersections and search for solutions that dwell further into the 'maze'. The intersections are stored in a list of class items. Once it determines that it has reached a dead end, it needs to access previous nodes in the database. Back in BP 7.0 I would have used pointers to at least parent node, but I haven't figured out a similar solution in Python. Is there such a way?
Reply