473,911 Members | 5,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2619
In <11************ *********@74g20 00cwt.googlegro ups.com>,
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
2014
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. I started with the getattribute/descriptor system as it seems that this is in many ways the "core" of the interpreter, and have come across a few questions.
0
1558
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. Basically I'm coming up with a duration between 3 sets of dates (subtracting off hours - eve, lunch, weekends, holiday) and coming up with the number of seconds. In the detail list I can easily print the value of n days, n hours, n minuts, n...
7
2984
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, I see that first two paragraphs shows me as Unbound and text is not displayed. Can anybody guide me how can I change the text from Unbound section as I want to change some text so that when I access Form it should show me with updated text. ...
6
2413
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
46508
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 regarding them, but haven't come across these descriptions in any of my reading material so far. Thanks!
2
1975
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(). Within that class I call various methods, including drawGUI() and authorizeDump(). My problem comes when I try to call authorizeDump from the Tkinter menu. Here is the code that calls authorizeDump(): self.packetmenu.add_command(label="Start...
14
3060
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
12517
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 programs are not really user friendly. I have searched and searched and tried numerous times to get the following right to no avail - and I think its really becuase of my lack of understanding.
6
1769
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 2.6, run with the -3 flag, gives a warning that the new module is going away in python 3.0, so the equivalent code is: method = types.MethodType(raw_func, None, cls)
0
10038
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11349
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10921
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9728
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8099
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7250
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6142
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.