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

unbound methods

I wrote a small class today at work playing with sockets in command
line windows. When attempting to call the handle function, I get a
TypeError. "Unbound method handle() must be called with connection
instance as first argument (got nothing instead). Any suggestions
would be greatly appreciated. Thanks!

-chase

Aug 12 '06 #1
2 2594
In <11*********************@74g2000cwt.googlegroups.c om>,
br************@gmail.com wrote:
I wrote a small class today at work playing with sockets in command
line windows. When attempting to call the handle function, I get a
TypeError. "Unbound method handle() must be called with connection
instance as first argument (got nothing instead). Any suggestions
would be greatly appreciated. Thanks!
I'd suggest that you post some actual code plus traceback so we don't have
to guess.

Ciao,
Marc 'BlackJack' Rintsch
Aug 12 '06 #2
br************@gmail.com wrote:
I wrote a small class today at work playing with sockets in command
line windows. When attempting to call the handle function, I get a
TypeError. "Unbound method handle() must be called with connection
instance as first argument (got nothing instead). Any suggestions
would be greatly appreciated. Thanks!
That happens if you call a (normal) method on the class instead of on an
instance.
>>class A:
.... def method(self, *args): print args
....

This works:
>>A().method(42)
(42,)

while this doesn't:
>>A.method(42)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: unbound method method() must be called with A instance as first
argument (got int instance instead)

For details you need to post some code illustrating the problem.

Peter
Aug 12 '06 #3

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

Similar topics

2
by: Ben | last post by:
Hi, I was recently writing a python interpreter (in python), partly to teach myself more about the python object system, and partly to learn more about how programming languages work in general....
0
by: ZRexRider | last post by:
Hi, I have a report driven by a SQL database. I have a populated recordset having a user name and a number of data/time fields. I process these time fields in the report's Detail_Print event. ...
7
by: mukeshhtrivedi | last post by:
Hi I have MS access form which has some text on it in four paragrpahs. Text in first two prargraphs can be changed if I want to and last two paragraphs are not modifiable. When I go to Design View,...
6
by: Ron Garret | last post by:
If I do this: def f(self): print self class c1: pass setattr(c1, 'm1', f) Then f is automagically transmogrified into the appropriate sort of method depending on how it is used:
10
true911m
by: true911m | last post by:
Can someone give me a quick rundown on the difference between bound and unbound methods? I ran into an error regarding an unbound method, and found lots of discussions about changing Python behavior...
2
by: Kevin Walzer | last post by:
I am trying to structure a Tkinter application with classes instead of just with simple functions, but I'm not sure how to call methods from my main class. My main class is packetstreamApp()....
14
by: 7stud | last post by:
Here is some example code that produces an error: class Test(object): def greet(): print "Hello" t = Test() t.greet() TypeError: greet() takes no arguments (1 given)
7
by: DeZZar | last post by:
Hi all, Unfortunately I am quite a novice with Access!! I've created a number of data bases for my work however becuase my skills are limited to really built in functionality and wizards my...
6
by: Thomas Heller | last post by:
I'm currently using code like this to create unbound methods from functions and stick them into classes: method = new.instancemethod(raw_func, None, cls) setattr(cls, name, method) Ok, python...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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...

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.