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

J

jeni

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?
 
U

Ulrich Eckhardt

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)
--> 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
 
D

Dave Angel

Ulrich said:
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.
 
U

Ulrich Eckhardt

Dave said:
Ulrich said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top