473,396 Members | 2,030 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.

why does this fail on python 2.2?


I'm trying to understand why some code from a module I'm using is
failing on 2.3 but working on 2.3. Here is the minimal example that
replicates the problem

class Results(object):
__slots__ = ( "__doinit" )
def __new__(cls):
retobj = object.__new__(cls)
retobj.__doinit = True
return retobj

x = Results()

On python2.2, this fails with

mother:~/tmp> python2.2 test.py
Traceback (most recent call last):
File "test.py", line 8, in ?
x = Results()
File "test.py", line 5, in __new__
retobj.__doinit = True
AttributeError: 'Results' object has no attribute '_Results__doinit'
Jul 18 '05 #1
3 1356
Because __slots__ and __new__ were added in 2.3.

Larry Bates
Syscon, Inc.

"John Hunter" <jd******@ace.bsd.uchicago.edu> wrote in message
news:ma**************************************@pyth on.org...

I'm trying to understand why some code from a module I'm using is
failing on 2.3 (sic) but working on 2.3. Here is the minimal example that
replicates the problem

class Results(object):
__slots__ = ( "__doinit" )
def __new__(cls):
retobj = object.__new__(cls)
retobj.__doinit = True
return retobj

x = Results()

On python2.2, this fails with

mother:~/tmp> python2.2 test.py
Traceback (most recent call last):
File "test.py", line 8, in ?
x = Results()
File "test.py", line 5, in __new__
retobj.__doinit = True
AttributeError: 'Results' object has no attribute '_Results__doinit'

Jul 18 '05 #2
>>>>> "Larry" == Larry Bates <lb****@swamisoft.com> writes:

Larry> Because __slots__ and __new__ were added in 2.3. Larry

I don't think so

http://python.org/2.2.3/descrintro.html
Jul 18 '05 #3
John Hunter wrote in news:mailman.2611.1093878644.5135.python-
li**@python.org in comp.lang.python:
class Results(object):
__slots__ = ( "__doinit" )
def __new__(cls):
AttributeError: 'Results' object has no attribute '_Results__doinit'


Its in the Traceback:

__slots__ = [ '_Results__doinit' ]

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 18 '05 #4

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

Similar topics

14
by: Dave Murray | last post by:
New to Python question, why does this fail? Thanks, Dave ---testcase.py--- import sys, urllib, htmllib def Checkit(URL): try: print "Opening", URL
2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
1
by: Chris Green | last post by:
Heyas folks, When does issubclass fail? That's a loaded question so here's my test case (also available at http://cmg.dok.org/code/classimports.tar.gz): directory structure: ../test.py...
6
by: Juho Saarikko | last post by:
The program attached to this message makes the Python interpreter segfault randomly. I have tried both Python 2.2 which came with Debian Stable, and self-compiled Python 2.3.3 (newest I could find...
5
by: Jason Smith | last post by:
Hi. I just have a question about optimizations Python does when converting to bytecode. import re for someString in someListOfStrings: if re.match('foo', someString): print someString,...
8
by: Bryan Olson | last post by:
Here's my algorithmic problem: Given a set of 'trigger' strings, and one 'path' string, find the longest of the triggers that is a prefix of the path. The trigger strings may number in the...
113
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside...
3
by: ChrisEdgemon | last post by:
I'd like to implement a subclass of string that works like this: True False True My best attempt for something like this is: class MyString(str): def __init__(self, seq):
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.