473,467 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

TypeError: unbound method (got int instance instead)

2 New Member
Hi
I am making a calendar (in Swedish): have problems with the Type Error. The problem i s that the user type in under val_1 what year he or she want to se a calendar of. The I want to send that information (val_1) up to def. valt_ar to continue calculate..

------------------------------------

Expand|Select|Wrap|Line Numbers
  1. from time import*
  2. import time
  3.  
  4.  
  5. class Kalender:
  6.     # Kalendern=objektet
  7.     def __init__(self, ar, manad):
  8.         self.ar=ar
  9.         self.manad=manad
  10.  
  11.     # Räknar ut hur många år från år 1900 samt hur många dagar det är från 1 jan
  12.     def valt_ar(ar): 
  13.         beraknat_ar=ar-1900
  14.  
  15.         beraknade_dagar=365*int(beraknat_ar)
  16.         return (beraknade_dagar)
  17.  
  18.  
  19.  
  20. # Frågar personen vilket år han/hon vill se kalendern
  21. val_1=int(input("Ange vilket år du vill titta på: " ))
  22. val_2=float(input("Ange måndad:   "))
  23.  
  24. beraknat_totalt_dagar=Kalender.valt_ar(self,valt_ar,manad)
Oct 23 '12 #1
3 2651
jpersson
2 New Member
Hi Meetee. Sorry I dont understand what you mean...
Oct 23 '12 #2
Meetee
931 Recognized Expert Moderator Contributor
When you paste code, please click <code/> button around your code to format your post as per site policy.
Oct 23 '12 #3
dwblas
626 Recognized Expert Contributor
You have to first create an instance of the class. You then work with the class instance as the class is just a prototype and does nothing until an instance is created. Note that valt_ar and manad have not been declared in the code you posted but you did not include the complete error message so there is no way to know if that is the Type Error or not.
Expand|Select|Wrap|Line Numbers
  1. class Kalender:
  2.      # Kalendern=objektet
  3.      def __init__(self, ar, manad):
  4.          self.ar=ar
  5.          self.manad=manad
  6.          print self.ar, self.manad
  7.  
  8.      # Räknar ut hur många år från år 1900 samt hur många dagar det är från 1 jan
  9.      def valt_ar(self): 
  10.          beraknat_ar=self.ar-1900
  11.          beraknade_dagar=365*int(beraknat_ar)
  12.          return (beraknade_dagar)
  13.  
  14.  
  15.  
  16. # Frågar personen vilket år han/hon vill se kalendern
  17. val_1=int(input("Ange vilket år du vill titta på: " ))
  18. val_2=float(input("Ange måndad:   "))
  19.  
  20. Kal=Kalender(val_1, val_2)
  21. print Kal.valt_ar() 
Oct 23 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: ‘5ÛHH575-UAZWKVVP-7H2H48V3 | last post by:
(see end of message for example code) When an instance has a dynamically assigned instance method, deepcopy throws a TypeError with the message "TypeError: instancemethod expected at least 2...
2
by: Farshid Lashkari | last post by:
Hi, I have an object and I want to check if it is a bound or unbound method, or neither. I tried using the types module, but it seems as though types.UnboundMethodType and types.MethodType are...
4
by: arotem | last post by:
Hi, I am trying to call an unbound method (PrintInput) with the object instance as the first argument but getting the following error: "TypeError: unbound method PrintInput() must be called with...
4
by: MuZZy | last post by:
Hi, I'm retouching some utility classes used everywhere across our app, and there are certain methods used everywhere and pretty frequently. I'm changing them from instance methods to static...
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()....
2
by: void.no.spam.com | last post by:
I'm a novice at Python, and found some code samples on how to use threads. My script is being run by a product that contains a Jython interpreter. Can someone please explain why I get the...
1
by: cinsky | last post by:
Hi, I got confused when I learned the function datetime.today(). So far I learned, unless an instance is created, it is not possible to call the class method. For example: class Foo: def...
2
by: kevow123 | last post by:
TypeError: unbound method draw() must be called with Body instance as first argument (got Turtle instance instead) I get that error when I attempt to run my program in python. I have to use the...
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
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...
1
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
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.