473,396 Members | 1,990 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,396 software developers and data experts.

Class instantiation

In the example below, with the disassembly following that, we run into
trouble with the line:
self.connect(fileID, mode= 'r') # open sheet in the read mode

the traceback is:
Traceback (most recent call last):
File "C:\Documents and Settings\cjw\My Documents\OODev\tArray.py",
line 26, in __init__
self.connect(fileID, mode= 'r') # open sheet in the read mode
NameError: global name 'fileID' is not defined

At line 26, location 31, why is LOAD_GLOBAL generated for fileId, when
LOAD_FAST has done the job at locations 0 and 20?

I would appreciate advice.

Colin W.

class arSpread(object):
def __init__(self, fileId= None, ar= None):
if fileId:
if ar is not None:
print fileId
self.connect(fileID, mode= 'r') # open sheet in the read mode
else:
self.connect(fileID, mode= 'w') # open the sheet in the
write mode
if ar is not None:
self.setArray(ar)

[Dbg]>>dis.disassemble(arSpread.__init__.im_func.func_c ode)
23 0 LOAD_FAST 1 (fileId)
3 JUMP_IF_FALSE 64 (to 70)
6 POP_TOP

24 7 LOAD_FAST 2 (ar)
10 LOAD_GLOBAL 2 (None)
13 COMPARE_OP 9 (is not)
16 JUMP_IF_FALSE 28 (to 47)
19 POP_TOP

25 20 LOAD_FAST 1 (fileId)
23 PRINT_ITEM
24 PRINT_NEWLINE

26 25 LOAD_FAST 0 (self)
28 LOAD_ATTR 4 (connect)
31 LOAD_GLOBAL 5 (fileID)
34 LOAD_CONST 1 ('mode')
37 LOAD_CONST 2 ('r')
40 CALL_FUNCTION 257
43 POP_TOP
44 JUMP_ABSOLUTE 71
> 47 POP_TOP
Aug 23 '06 #1
0 1048

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

Similar topics

7
by: Drew McCormack | last post by:
I have a C++ template class which contains a static variable whose construction registers the class with a map. Something like this: template <typename T> class M { static Registrar<M>...
3
by: Patrick Guio | last post by:
Hi, I have trouble to compile the following piece of code with g++3.4 but not with earlier version // Foo.h template<typename T> class Foo { public:
23
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? ...
1
by: Frederiek | last post by:
Hi, When modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class. Does that mean that the address of...
3
by: dischdennis | last post by:
Hello List, I would like to make a singleton class in python 2.4.3, I found this pattern in the web: class Singleton: __single = None def __init__( self ): if Singleton.__single: raise...
3
by: erictham115 | last post by:
Error C2555 c:\C++ projects\stat1\stdmatrix_adapt.h(41) : error C2555: 'std_tools::Matrix_adapter<T>::at': overriding virtual function return type differs and is not covariant from...
12
by: titan nyquist | last post by:
I have a class with data and methods that use it. Everything is contained perfectly THE PROBLEM: A separate thread has to call a method in the current instantiation of this class. There is...
8
by: Ole Nielsby | last post by:
I want to create (with new) and delete a forward declared class. (I'll call them Zorgs here - the real-life Zorks are platform-dependent objects (mutexes, timestamps etc.) used by a...
4
by: Devon Null | last post by:
I have been exploring the concept of abstract classes and I was curious - If I do not define a base class as abstract, will it be instantiated (hope that is the right word) when a derived class is...
4
by: yuanhp_china | last post by:
I define a class in A.h: template <class Tclass A{ public: void get_elem( const T&) ; };
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
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:
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...
0
marktang
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,...
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...
0
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...
0
agi2029
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,...

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.