[Tutor] Wrapping with list
Dotan Cohen
dotancohen at gmail.com
Fri Sep 13 12:24:40 CEST 2013
A function that I wrote works on a list or on a string. If the
function is passed a string, then it wraps the string in a list at the
top of the function. Is it bad form to wrap the sting in place?
if not isinstance(someVar, list):
someVar = [someVar]
To avoid that, I am creating a list then appending the original value:
if not isinstance(someVar, list):
temp = someVar
someVar = []
someVar.append(temp)
Is my prudence unwarrented?
Thanks!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
More information about the Tutor
mailing list