attributeerror

AttributeError: 'str' object has no attribute 'format'

I am using Python 2.5.2 >>> for x in range(1,11): print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x) Traceback (most recent call last): File "", line 2, in print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x) AttributeError: 'str' object has no attribute 'format' I am not getting the problem When i did dir('hello') there was no...

Attribute error in Python

Hello, i have class class SomeClass: def __init__(self): self.SomeFunction() def SomeFunction(self): try: self.something = 5 except: print 'error' print self.something tempObject = SomeClass() And the last string occurs an error: AttributeError: something Why? ...

pycurl: RETURNTRANSFER option doesn't exist

I'm using pycurl to access a JSON web API, but when I try to use the following: ocurl.setopt(pycurl.URL, gaurl) # host + endpoint ocurl.setopt(pycurl.RETURNTRANSFER, 1) ocurl.setopt(pycurl.HTTPHEADER, gaheader) # Send extra headers ocurl.setopt(pycurl.CUSTOMREQUEST, "POST") # HTTP POST req ocurl.setopt(pycurl.CONNECTTIMEOUT, 2) ...

Python: accessing DLL function using ctypes -- access by function *name* fails

myPythonClient (below) wants to invoke a ringBell function (loaded from a DLL using ctypes). However, attempting to access ringBell via its name results in an AttributeError. Why? RingBell.h contains namespace MyNamespace { class MyClass { public: static __declspec(dllexport) int ringBell ( void ) ; } ; ...

Attribute Error in Python

I'm trying to add a unittest attribute to an object in Python class Boy: def run(self, args): print("Hello") class BoyTest(unittest.TestCase) def test(self) self.assertEqual('2' , '2') def self_test(): suite = unittest.TestSuite() loader = unittest.TestLoader() suite.addTest(loader.loadTestsFromT...

Python Tornado Web - AttributeError: 'Connection' object has no attribute '_execute'

I'm experiencing a strange behaviour working with the latest branch of tornadoweb when I deploy my app on my production server. I tested several times the code and it is fully working when I test it on my laptop (Archlinux) with python 2.6.3 and MySQLdb 1.2.3b2. As soon as I deploy on my production server (Ubuntu x64) with python 2.6.2...

Python attribute error: type object '_socketobject' has no attribute 'gethostbyname'

Hi Everyone, I am trying to do this in my program: dest = socket.gethostbyname(host) I have included the line from socket import * in the beginning of the file I am getting an Attribute Error that says: AttributeError: type object '_socketobject' has no attribute 'gethostbyname' I really do not understand what I need to...

Why am I getting an AttributeError when I have the attribute?

Hi, I keep getting the following error: AttributeError: Caribou instance has no attribute 'on_key_up' The problem is, I'm pretty sure I do have that attribute... Here are some excerpts from my code (from caribou.py): def on_key_up(self, event): if event.event_string == "Shift_R": _r_shift_down = False elif event.event_string...

What special method in Python handles AttributeError?

What special method(s?) should I redefine in my class so that it handled AttributeErrors exceptions and returned a special value in those cases? For example, >>> class MySpecialObject(AttributeErrorHandlingClass): a = 5 b = 9 pass >>> >>> obj = MySpecialObject() >>> >>> obj.nonexistent 'special value' >>> obj.a 5 >>> ...

__getattr__ on a module

How can implement the equivalent of a __getattr__ on a class, on a module? Example When calling a function that does not exist in a module's statically defined attributes, I wish to create an instance of a class in that module, and invoke the method on it with the same name as failed in the attribute lookup on the module. class A(obje...

GAE AttributeError

My GAE app runs fine from my computer, but when I upload it, I start getting an AttributeError, specifically: AttributeError: 'dict' object has no attribute 'item' I am using the pylast interface (an API for last.fm--link). Specifically, I am accessing a list of variables of this type: SimilarItem = _namedtuple("SimilarItem", ["item"...

Getting Started with Python: Attribute Error

I am new to python and just downloaded it today. I am using it to work on a web spider, so to test it out and make sure everything was working, I downloaded a sample code. Unfortunately, it does not work and gives me the error: "AttributeError: 'MyShell' object has no attribute 'loaded' " I am not sure if the code its self has an erro...

Pylons 1.0 AttributeError: 'module' object has no attribute 'metadata'

Python noob trying to learn Pylons. I'm using the QuickWiki tutorial (http://pylonshq.com/docs/en/1.0/tutorials/quickwiki_tutorial/) from the 1.0 documentation, but this alleged "1.0" doc seems to just be "0.9.7"; I suspect that this has something to do with the error I'm getting. When I execute "paster setup-app development.ini", I get...

Python 2.5 Import dll AttributeError

I have a program that runs peachy in Py2.4. I import the TobiiPlugin.dll file and then run my scripts. import TobiiPlugin as tobii tobii.setGazeSubjectProfile(3, 0) However, when I moved the code to Py2.5 it gets angry at me and I get Traceback (most recent call last): File "C:\tobiiDll\TobiiPlugin\Debug\logger_speech.py", line 27...

Python - TypeError: unbound method

So this Python problem has been giving me problems since I've tried refactoring the code into different files. I have a file called object.py and in it, the related code is: class Object: #this is a generic object: the player, a monster, an item, the stairs... #it's always represented by a character on screen. def __init__(self, x, y, ...