unreferenced (???) variable; prob. simple
Halfdan Holger Knudsen
s011362 at student.dtu.dk
Mon Sep 15 15:31:07 EDT 2003
goodday all - here's a snippet of code that just doesn't seem to work...at
all! But I haven't got the faintest idea why I keep getting an unref.
local var. error. Take a look - I know I can get good help here. And PS:
Thanks beforehand.
If you're wondering - it's an attempt at a (crude) reproduction of the string.split() functionality for learning purposes.
----------------------
#! /usr/bin/env python
import string
begind = 0
endind = 0
def stripfunc():
inpstr = raw_input('String to strip: ')
length = len(inpstr)
spacelst = list(string.whitespace)
print spacelst
for a in range(length):
if inpstr[a] not in spacelst:
begind = a
break
break
for b in range(1, length+1):
if inpstr[-b] not in spacelst:
endind = length-b
break
break
stripstring = inpstr[begind:(endind+1)]
print stripstring
print begind
print endind
if __name__ == '__main__':
stripfunc()
More information about the Python-list
mailing list