error: an integer is required

M

madigreece

I execute my code in linux environment.
My code is:

from os import *

def insert_text_file(self, strng):
t=open("elements_file.txt", "a")
t.write(strng)
t.close()

I'm getting this error:

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

Where is the mistake?
Help me, please!!
 
M

MRAB

I execute my code in linux environment.
My code is:

from os import *

def insert_text_file(self, strng):
t=open("elements_file.txt", "a")
t.write(strng)
t.close()

I'm getting this error:

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

Where is the mistake?
Help me, please!!

The os module has a function called 'open'. When you imported all of the
os module you hid the builtin 'open' with the one in the os module.

Wildcarded imports are generally not recommended for this reason.

Just use "import os" and then prefix with "os." wherever it's needed.
 
T

Terry Reedy

I execute my code in linux environment.
My code is:

from os import *

def insert_text_file(self, strng):
t=open("elements_file.txt", "a")
t.write(strng)
t.close()

I'm getting this error:

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

Where is the mistake?
Help me, please!!

Tell us the Python version and give the *full* traceback message, not
just the last line. I am pretty sure you also left out an important
part of the code you executed to get that message.

tjr
 
J

jeni

Tell us the Python version and give the *full* traceback message, not
just the last line.  I am pretty sure you also left out an important
part of the code you executed to get that message.

tjr- Áðüêñõøç êåéìÝíïõ óå ðáñÜèåóç -

- ÅìöÜíéóç êåéìÝíïõ óå ðáñÜèåóç -

With both import os and os.open there is the same error. 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?
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top