convert ints in a range to strings

Raymond Hettinger vze4rx4y at verizon.net
Thu Sep 18 01:32:30 EDT 2003


[hokieghal99]
> a="192."
> b="168."
> c="1."
> r = range(256)
> for r in r:

This rebinding of r is an amazing non-error.
I had to read it twice before I believed that it worked.
Working or not, don't do this.  Changing the meaning
of variable like this drives some people off the edge
and they end up working in pure functional languages
and never recover.

> print a + b + c + r

As the others pointed out, str(r) will do the trick.


Raymond Hettinger






More information about the Python-list mailing list