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

Upgrading Class Instances Automatically on Reload

Upgrading Class Instances Automatically on Reload:
Recipe 20.15 out of Python Cookbook #2.
Did anybody get this recipe to work?

The original example by Michael Hudson works without problems.
I'm using Python 2.4.1

malv

May 10 '06 #1
4 1928
malv:
Did anybody get this recipe to work?


Did you?

--
René Pijlman
May 10 '06 #2
Rene,

No, I couldn't get it to work. Sorry, I should have included that
information.

At the statement b = Bar(), the following error occurs:
The debugged program raised the exception unhandled AttributeError
"type object 'Bar' has no attribute '__instance_refs__'"

malv

May 10 '06 #3
malv:
At the statement b = Bar(), the following error occurs:
The debugged program raised the exception unhandled AttributeError
"type object 'Bar' has no attribute '__instance_refs__'"


I haven't studied it at all, but the code on
http://aspn.activestate.com/ASPN/Coo.../Recipe/160164 seems to
run fine with Python 2.4.2 in WingIDE on Windows XP. There's no exception
and it prints:
1
2
3

Are you perhaps using an older dead tree version of the Cookbook?

--
René Pijlman
May 10 '06 #4
Indeed, as I indicated the old recipe/160164 by Michael Hudson works
flawlessly for me.

I am referring here to the latest edition: cookbook #2 which features
an upgraded version.
You find the examples in:
http://examples.oreilly.com/pythonco...2_examples.zip

The files are named cb2_6_21_*.py, but the book has the recipe in
chapter
20.15.

malv

May 10 '06 #5

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

Similar topics

7
by: Carlos Ribeiro | last post by:
I'm looking for ways to load new class definitions at runtime (I'm not talking about object instances here, so a persistent object database isn't what I am looking for ). I'm aware of a few...
6
by: Brian Jones | last post by:
I'm sure the solution may be obvious, but this problem is driving me mad. The following is my code: class a(object): mastervar = def __init__(self): print 'called a'
30
by: Neil Zanella | last post by:
Hello, Suppose I have some method: Foo::foo() { static int x; int y; /* ... */ }
3
by: chrisspen | last post by:
Is there a way to loop through all instantiated objects and update their classes when a source file changes? I know about Michael Hudson's method...
9
by: Dave Kelly | last post by:
I have generated a class, which contains configuration data for my application. Unfortunately I cannot use a static implementation of the class, as it requires a constructor. I generate...
6
by: Tim Hunter | last post by:
I am using Access 2003 under WinXP. I currently support a huge Excel Wokbook that is a maintenance nightmare. There are about 15 worksheets each with lots of formulas...Anyway I am thinking of...
5
by: kkirtac | last post by:
Hi, i have a class "myClass", and i want to return two instances of the same class from a function. I define an array as follows : "myClass sample ;" and i initialize two instances: "myClass...
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
0
by: idealfellow | last post by:
Hi Guys, I have multiple Mysql DB instances containing same schema but different data in the tables, running in my unix server. I always have the issue of not upgrading...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
tracyyun
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 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.