how do i make an array global
onurb at xiludom.gro
Wed Jun 28 12:32:19 CEST 2006
> def fn():
> for i in range(l)
l is not defined - you should have an error here.
> global count
> count[i]= ....
> how do i declare count to be global if it is an array
Just like it was an integer
> subsequently i should access or define count as an array
You need to define count before.
> global name 'count' is not defined
You probably should not do that anyway. Globals are *evil*. And
functions modifying globals is the worst possible thing. There are very
few chances you *need* a global here.
Also, and FWIW:
- Python has lists, not arrays (there's an array type in some numerical
package, but that's another beast)
- 'l' is a very bad name
- 'count' is a bad name for a list - 'counts' would be better (when I
see the name 'count', I think of an integer)
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list