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

Discussion in 'Python' started by jeni, Jun 15, 2009.

  1. jeni

    jeni Guest

    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?
    jeni, Jun 15, 2009
    #1
    1. Advertising

  2. 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
    Ulrich Eckhardt, Jun 15, 2009
    #2
    1. Advertising

  3. jeni

    Dave Angel Guest

    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.
    Dave Angel, Jun 16, 2009
    #3
  4. 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
    Ulrich Eckhardt, Jun 16, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ahsan Imam
    Replies:
    4
    Views:
    5,683
    Josiah Carlson
    Feb 7, 2004
  2. Andi Clemens
    Replies:
    8
    Views:
    647
    Tim Heaney
    Sep 17, 2006
  3. jakecjacobson
    Replies:
    4
    Views:
    908
    Gabriel Genellina
    Jul 28, 2009
  4. MRAB
    Replies:
    1
    Views:
    526
    Nobody
    Nov 22, 2009
  5. Dave Angel

    Re: TypeError: an integer is required

    Dave Angel, Nov 22, 2009, in forum: Python
    Replies:
    0
    Views:
    1,890
    Dave Angel
    Nov 22, 2009
Loading...

Share This Page