I am stuck at the a small code as the following:
This is module main, the main entry of the application : -
from irc_log_mod import *
-
from irc_chatter_mod import *
-
from inspect import *
-
from irc_global_mod import *
-
-
def main():
-
try:
-
curFrame = currentframe()
-
writeLog(LOG,
-
curFrame.f_code.co_filename,
-
"",
-
"main()",
-
curFrame.f_lineno,
-
DBG_LEVEL_ONE,
-
"FUNCTION ENTRY")
-
finally:
-
del curFrame
-
-
# problem comes in this line
-
chatter = cchatter("nickname", "username", "fullname", 1)
-
-
# ... rest of the code .....
-
The class cchatter is coded in a module called irc_chatter_mod; and its constructor looks like this : -
def __init__(self, nickname, username, fullname, flag):
-
-
# cchatter::__init__ : BEGIN
-
-
# FUNCTION ENTRY
-
-
try:
-
curFrame = currentframe()
-
writeLog(LOG,
-
curFrame.f_code.co_filename,
-
"cchatter",
-
"__init__",
-
curFrame.f_lineno,
-
DBG_LEVEL_THREE,
-
"FUNCTION ENTRY")
-
finally:
-
# The problem is here
-
del curFrame
-
-
# ...rest of the codes......
-
-
Problem :
The compiler outputs : File "C:\public\projects\py\AmeL\irc_chatter_mod_unit_t est.py", line 41, in <module>
main()
File "C:\public\projects\py\AmeL\irc_chatter_mod_unit_t est.py", line 18, in main
chatter = cchatter("nickname", "username", "fullname", 1)
File "C:\public\projects\py\AmeL\irc_chatter_mod.py ", line 55, in __init__
del curFrame
UnboundLocalError: local variable 'curFrame' referenced before assignment
From my point of view, this error message should be thrown when a variable is referenced, or used, before it is assigned by any value. I found nothing go wrong with my code.
Could you guys please help me ?
1 1401
Oh god
The problem is at last solved, I forgot to import a module named inspect :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Brad Clements |
last post by:
I was going to file this as a bug in the tracker, but maybe it's not really
a bug. Poor Python code does what I consider to be unexpected. What's your
opinion?
With Python 2.3.2 (but also...
|
by: Alex Gittens |
last post by:
I'm trying to define a function that prints fields of given widths
with specified alignments; to do so, I wrote some helper functions
nested inside of the print function itself. I'm getting an...
|
by: silverburgh.meryl |
last post by:
Can you please tell me what is the meaning this error in general?
UnboundLocalError: local variable 'colorIndex' referenced before
assignment
In my python script,
I have a variable define and...
|
by: David Bear |
last post by:
I'm attempting to use the cgi module with code like this:
import cgi
fo = cgi.FieldStorage()
# form field names are in the form if 'name:part'
keys = fo.keys()
for i in keys:
try:...
|
by: Paddy |
last post by:
Hi,
I am trying to work out why I get UnboundLocalError when accessing an
int from a function where the int is at the global scope, without
explicitly declaring it as global but not when accessing...
|
by: Camellia |
last post by:
hi all
why it generates an "UnboundLocalError" when I do the following:
<code>
....
def main():
number = number()
number_user = user_guess()
while number_user != number:
|
by: Konstantinos Pachopoulos |
last post by:
Hi,
i have a problem, the source of which is probably the fact, that i have
not understood how to declare global variables - I use the Jython
compiler, but i think this is a Python issue...
...
|
by: defn noob |
last post by:
isPrime works when just calling a nbr but not when iterating on a
list, why? adding x=1 makes it work though but why do I have to add
it?
Is there a cleaner way to do it?
def isPrime(nbr):...
|
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
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |