How do I combine instance+string for variable

Terry Reedy tjreedy at udel.edu
Fri Aug 1 21:14:46 EDT 2003


> <snippett>
> conns = [conn2, conn3, conn4, conn5, conn6, conn7, conn8]
> ...
> for int in range(2,9):
>     qput(key.command, conns[int-2], act_user("user-ID" + str(int),
"CTAG",
> "t*sting" + str(int) ) )
> <end of snippett>

And what happens if you follow 'snippett' with anything like
  type(var)==int # or
  var=int(num/3) # or
  num = int(somestring)
or preceed it with something like
  for str in stringlist: .....
?

Please don't use type names (or other builtins) as variables in posted
code.
Experts may survive it, but it's a bad example for beginners. ;-)

Terry J. Reedy






More information about the Python-list mailing list