473,387 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

unreferenced (???) variable; prob. simple

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()

Jul 18 '05 #1
2 2062
On Mon, 15 Sep 2003 21:31:07 +0200, "Halfdan Holger Knudsen"
<s0*****@student.dtu.dk> wrote:
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.
begind = 0
endind = 0

These variables are not know inside the function. The best solution is
to declare them as local variables in the function, as they really are
only of use in there, i.e.:

def stripfunc()
begind=0
endind=0
[... here goes the rest ...]

-PU

Jul 18 '05 #2

"Halfdan Holger Knudsen" <s0*****@student.dtu.dk> wrote in message
news:ma*********************************@python.or g...
goodday all - here's a snippet of code that just doesn't seem to work...atall! But I haven't got the faintest idea why I keep getting an unref.
local var. error.


When asking a question about 'why do I get this error message', please
copy and paste the complete error message, including the traceback.

TJR
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PONTEPRIMO | last post by:
Hello, I've just installed EasyPHP 1.7, ( before i was in 1.6 release ), and my application does not run anymore !!! ... I've 2 problems : ------------------------------------ FIRST PROB. In...
1
by: Tzu-Chien Chiu | last post by:
I know many linkers can remove unreferenced functions while linking the object files, but I need a tool/script to list all unreferenced symbols. -- Tzu-Chien Chiu XGI Technology, Inc - Extreme...
5
by: David Sobey | last post by:
Hi Sorry bout this basic prob. Got a file called file.obj. tryna read the first line from it as a string and print it to the screen. getting errors: #include "stdafx.h" #include <stdio.h>...
11
by: Alzane | last post by:
I'm new to C++ programming. I have an exercise that I have written code for but getting warnings. Can I get some help? #include "stdafx.h" #include <string.h> #include <stdio.h> #include...
15
by: Raj | last post by:
Hello all: We have a table with about 2400 cells. Our requirement is to highlight the cells in the table whose data has changed, every 5 seconds. Our script behaves relatively ok in Firefox, but...
22
by: John Fisher | last post by:
void f(int p) { } Many (most?) compilers will report that p is unreferenced here. This may not be a problem as f may have to match some common prototype. Typically pointers to functions are...
5
by: Ron | last post by:
I'm not really new to dotnet but am getting stumped by what I think is something easy. Any insights as to what i'm doing wrong? Thanks in advanced (see below) ------------------- This...
9
by: dotnetismylife | last post by:
Hi all, I have a question, in the following code: using System; using System.Diagnostics; namespace ConsoleApplication1 { class TestClass {
0
Savage
by: Savage | last post by:
I'm making for fun a simple program which format a input file.Input file sustain of person name,lastname and date of birth.Output file si supposed to be forammted as following: NAME ...
0
by: Greg Corradini | last post by:
Hello all, I'm having trouble inserting an SQL selection into a new MS Access table. I get a parameter error on my insert statement when I try this (see below for code and error msg). I'm not sure...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.