Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > <type 'exceptions.TypeError'>: an integer is required

Reply
Thread Tools

<type 'exceptions.TypeError'>: an integer is required

 
 
jeni
Guest
Posts: n/a
 
      06-15-2009
I have developed in python a game for OPLC. When I run the game in
Python 2.5.2 at Windows there is no problem. But after I play a game
at OLPC I get the following message:

<type 'exceptions.TypeError'> Traceback (most recent call last)

/home/olpc/Activities/Kremala.activity/Kremala.py in add_letter
(self=<KremalaActivity object at 0x83e22d4 (SugarActivity at 0x86a7800)
>, widget=<gtk.Button object at 0x83f49dc (GtkButton at 0x8744920)>,

grama='i')
--> self.find_w()
self.find_w=<bound method KremalaActivity.find_w of <KremalaActivity
object at 0x83e22d4 (SugarActivity at 0x86a7800)>>

/home/Activities/Kremala.activity/Kremala.py in find_w
(self=<KremalaActivity object at 0x83e22d4 (SugarActivity at 0x86a7800)
>)

self.show_gr()
--> self.sosti_leksi()
self.sosti_leksi==<bound method KremalaActivity.sosti_leksi of
<KremalaActivity object at 0x83e22d4 (SugarActivity at 0x86a7800)>>

/home/Activities/Kremala.activity/Kremala.py in sosti_leksi
(self=<KremalaActivity object at 0x842e2fc (SugarActivity at 0x86b3000)
>)

s=self.categ+":"+str(1)+" nikh me "+str(6-self.m)+"prospatheies
\n"
--> self.insert_text_file(s)
self.insert_text_file===<bound method
KremalaActivity.insert_text_file of <KremalaActivity object at
0x83e22d4 (SugarActivity at 0x86a7800)>>

/home/Activities/Kremala.activity/Kremala.py in insert_text_file
(self=<KremalaActivity object at 0x83e22d4 (SugarActivity at 0x86a7800)
>, strng='geografia:1 nikh me 2 prospatheies\n')

--> t=open("elements_file.txt", "a")
global open=<built-in function open>
t.write(strng)
t.close()

<type 'exceptions.TypeError'>: an integer is required

OLPC's software is important?
 
Reply With Quote
 
 
 
 
Ulrich Eckhardt
Guest
Posts: n/a
 
      06-15-2009
jeni wrote:
[ ..large backtrace.. ]
For your own sake and that of your readers, try next time to reduce the code
that causes the problems to a minimal example. This prevents people from
guessing or simply ignoring your problems.

> /home/Activities/Kremala.activity/Kremala.py in insert_text_file
> (self=<KremalaActivity object at 0x83e22d4 (SugarActivity at 0x86a7800)
>>, strng='geografia:1 nikh me 2 prospatheies\n')

> --> t=open("elements_file.txt", "a")
> global open=<built-in function open>


open() doesn't take a string as second parameter, see 'help(open)'. Instead,
it takes one of the integers which are defined as symbols in the os module,
see 'dir(os)'.

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

 
Reply With Quote
 
 
 
 
Dave Angel
Guest
Posts: n/a
 
      06-16-2009
Ulrich Eckhardt wrote:
> open() doesn't take a string as second parameter, see 'help(open)'. Instead,
> it takes one of the integers which are defined as symbols in the os module,
> see 'dir(os)'.
>
>
>

Where'd you get that misinformation? The second parameter to the
builtin function open() is a string, such as 'r', 'wb', etc.

help(open) doesn't say much in 2.6, but in 3.1, it spells it out. For
2.6, look at the non-interactive documentation, such as the chm file in
Windows.

Now perhaps you're referring to open() in some other module, such as
os.open(). If so, it behooves you to specify that, as an unqualified
open() can only refer to the one in builltin.

 
Reply With Quote
 
Ulrich Eckhardt
Guest
Posts: n/a
 
      06-16-2009
Dave Angel wrote:
> Ulrich Eckhardt wrote:
>> open() doesn't take a string as second parameter, see 'help(open)'.
>> Instead, it takes one of the integers which are defined as symbols in the
>> os module, see 'dir(os)'.

>
> [...]The second parameter to the builtin function open() is a string[...]
> Now perhaps you're referring to open() in some other module, such as
> os.open().


True, mixed those up, as perhaps did the OP.

> an unqualified open() can only refer to the one in builltin.


....unless you explicitly imported an 'open' from somewhere else.

Thanks for the correction.

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add an Integer to another Integer? Sebastian Stelzer Java 6 04-07-2010 07:03 PM
CType(x,Integer) vs. Integer.Parse(x) =?Utf-8?B?Sm9l?= ASP .Net 7 02-07-2006 02:30 AM
how do I make Class.forName("Integer") returning java.lang.Integer? Johannes Zellner Java 22 12-19-2005 11:22 AM
How do I add an Integer to another Integer? Sebastian Stelzer Java 2 10-15-2004 01:17 PM
No Math.min(Integer, Integer)? =?ISO-8859-1?Q?Thomas_Gagn=E9?= Java 0 07-29-2003 07:46 PM



Advertisments