variables with loop-local scope?
Skip Montanaro
skip at pobox.com
Sat Oct 25 23:21:18 EDT 2003
>>>>> "Brian" == Brian Alexander <brian094 at sympatico.ca> writes:
Brian> Can Python do this?
Sure:
for i in listOfNames:
prefixMr = 'Mr'
prefixMs = 'Ms'
if i in mansName:
salutation = prefixMr + i
else:
salutation = prefixMs + i
else:
del prefixMr
del prefixMs
print 'Hello,' + salutation
Probably not quite what you wanted. Is there a reason you need/want the
variable to disappear before the function returns?
Skip
More information about the Python-list
mailing list