how do i make an array global
Bruno Desthuilliers
onurb at xiludom.gro
Wed Jun 28 06:32:19 EDT 2006
a wrote:
> 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.
> error:
> global name 'count' is not defined
He...
*but*
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)
--
bruno desthuilliers
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
mailing list