FAQ
Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to
become more acquainted with the language. However, when I got to page 304 and
did my first example:


http://bin.cakephp.org/view/1107093008


And this is the error that I'm getting:


http://bin.cakephp.org/view/399711843


This is the code that came with the book:


http://bin.cakephp.org/view/514822432




What I don't understand is, why am I getting that error? I've done diff -w
and the code looks for the most part the same. What am I doing wrong when I
put the application together?

Search Discussions

  • Chris Angelico at Mar 16, 2013 at 3:08 pm

    On Sun, Mar 17, 2013 at 1:53 AM, Yves S. Garret wrote:
    Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to
    become more acquainted with the language. However, when I got to page 304 and
    did my first example:

    http://bin.cakephp.org/view/1107093008

    And this is the error that I'm getting:

    http://bin.cakephp.org/view/399711843

    This is the code that came with the book:

    http://bin.cakephp.org/view/514822432


    What I don't understand is, why am I getting that error? I've done diff -w
    and the code looks for the most part the same. What am I doing wrong when I
    put the application together?

    self.secret_txt.delete(0.0, END)
    self.secret_txt.delete(0.0, message)


    Is the second one supposed to be adding text? I'm not familiar with
    tkinter but that's the line with the error, and it looks a little odd.


    ChrisA
  • Mitya Sirenef at Mar 16, 2013 at 3:10 pm

    On 03/16/2013 10:53 AM, Yves S. Garret wrote:
    Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to
    become more acquainted with the language. However, when I got to page 304 and
    did my first example: >
    http://bin.cakephp.org/view/1107093008 >
    And this is the error that I'm getting: >
    http://bin.cakephp.org/view/399711843 >
    This is the code that came with the book: >
    http://bin.cakephp.org/view/514822432
    >
    >
    What I don't understand is, why am I getting that error? I've done diff -w
    and the code looks for the most part the same. What am I doing wrong when I
    put the application together?



    The error is that indexes are supposed to be integers, instead you have
    a text string:


    "That's not the correct password, so I can't s hare the secret with you."




    -m




    --
    Lark's Tongue Guide to Python: http://lightbird.net/larks/


    The existence of any evil anywhere at any time absolutely ruins a total
    optimism. George Santayana
  • Yves S. Garret at Mar 16, 2013 at 3:14 pm

    On Saturday, March 16, 2013 11:08:24 AM UTC-4, Chris Angelico wrote:
    On Sun, Mar 17, 2013 at 1:53 AM, Yves S. Garret

    wrote:
    Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to
    become more acquainted with the language. However, when I got to page 304 and
    did my first example:

    http://bin.cakephp.org/view/1107093008

    And this is the error that I'm getting:

    http://bin.cakephp.org/view/399711843

    This is the code that came with the book:

    http://bin.cakephp.org/view/514822432


    What I don't understand is, why am I getting that error? I've done diff -w
    and the code looks for the most part the same. What am I doing wrong when I
    put the application together?


    self.secret_txt.delete(0.0, END)

    self.secret_txt.delete(0.0, message)



    Is the second one supposed to be adding text? I'm not familiar with

    tkinter but that's the line with the error, and it looks a little odd.



    ChrisA

    Yes, the second line is supposed to add the text.
  • Christian Gollwitzer at Mar 16, 2013 at 3:31 pm

    Am 16.03.13 16:14, schrieb Yves S. Garret:
    On Saturday, March 16, 2013 11:08:24 AM UTC-4, Chris Angelico wrote:

    self.secret_txt.delete(0.0, END)
    self.secret_txt.delete(0.0, message)

    Is the second one supposed to be adding text? I'm not familiar with
    tkinter but that's the line with the error, and it looks a little odd.
    Yes, the second line is supposed to add the text.



    Think about it. "delete" is not going to add text. You want "insert"
    instead.


    Christian
  • Yves S. Garret at Mar 16, 2013 at 3:16 pm

    On Saturday, March 16, 2013 11:10:07 AM UTC-4, Mitya Sirenef wrote:
    On 03/16/2013 10:53 AM, Yves S. Garret wrote:

    Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to
    become more acquainted with the language. However, when I got to page 304 and
    did my first example:

    http://bin.cakephp.org/view/1107093008

    And this is the error that I'm getting:

    http://bin.cakephp.org/view/399711843

    This is the code that came with the book:

    http://bin.cakephp.org/view/514822432


    What I don't understand is, why am I getting that error? I've done diff -w
    and the code looks for the most part the same. What am I doing wrong when I
    put the application together?




    The error is that indexes are supposed to be integers, instead you have

    a text string:



    "That's not the correct password, so I can't s hare the secret with you."





    -m





    --

    Lark's Tongue Guide to Python: http://lightbird.net/larks/



    The existence of any evil anywhere at any time absolutely ruins a total

    optimism. George Santayana

    *shrug*


    In the example that I have posted from the book it works just fine. I also used
    this batch file to help me along.


    longevity.py
    pause


    Hence the question mark over my head at the moment :) .
  • Chris Angelico at Mar 16, 2013 at 3:23 pm

    On Sun, Mar 17, 2013 at 2:16 AM, Yves S. Garret wrote:
    In the example that I have posted from the book it works just fine.

    Yep, I just checked the book's version again and the difference is
    clear. Check out the two lines I quoted in my previous post, and look
    at the corresponding two lines in the book's version. You should see
    the difference. :)


    By the way, I like the choice of secret. It lends itself well to a
    discussion of recursion - how do you live to 99? Live to 98, then be
    careful. Etcetera. You need just one special case: How do you live to
    1? Be born, then be careful. And there you have it, a perfect problem
    for defining recursion vs iteration, as both can do the job!


    ChrisA
  • Yves S. Garret at Mar 16, 2013 at 3:34 pm

    On Saturday, March 16, 2013 11:23:07 AM UTC-4, Chris Angelico wrote:
    On Sun, Mar 17, 2013 at 2:16 AM, Yves S. Garret

    wrote:
    In the example that I have posted from the book it works just fine.


    Yep, I just checked the book's version again and the difference is

    clear. Check out the two lines I quoted in my previous post, and look

    at the corresponding two lines in the book's version. You should see

    the difference. :)



    By the way, I like the choice of secret. It lends itself well to a

    discussion of recursion - how do you live to 99? Live to 98, then be

    careful. Etcetera. You need just one special case: How do you live to

    1? Be born, then be careful. And there you have it, a perfect problem

    for defining recursion vs iteration, as both can do the job!



    ChrisA

    *facepalm*


    Yep, I see it :) . Thanks for your help.
  • Chris Angelico at Mar 16, 2013 at 3:44 pm

    On Sun, Mar 17, 2013 at 2:34 AM, Yves S. Garret wrote:
    *facepalm*

    Yep, I see it :) . Thanks for your help.

    Glad to be of service. Welcome to a life of programming, where the
    palm meets the face on a regular basis... more frequently if you use
    Microsoft Windows, tar, non-eight-bit-clean transmission methods, or
    Adobe products, and extremely common as soon as you take over someone
    else's code [1], but inevitable even without these stimuli. :)


    Have fun!


    [1] http://www.dilbert.com/strips/comic/2013-02-24/


    ChrisA
  • Neil Cerutti at Mar 19, 2013 at 2:11 pm

    On 2013-03-16, Chris Angelico wrote:
    On Sun, Mar 17, 2013 at 2:34 AM, Yves S. Garret
    wrote:
    *facepalm*

    Yep, I see it :) . Thanks for your help.
    Glad to be of service. Welcome to a life of programming, where
    the palm meets the face on a regular basis... more frequently
    if you use Microsoft Windows, tar, non-eight-bit-clean
    transmission methods, or Adobe products, and extremely common
    as soon as you take over someone else's code [1], but
    inevitable even without these stimuli. :)

    A pretty funny example of this is depicted in the fine film
    Office Space.


    --
    Neil Cerutti
  • Mitya Sirenef at Mar 16, 2013 at 3:48 pm

    On 03/16/2013 11:16 AM, Yves S. Garret wrote:
    On Saturday, March 16, 2013 11:10:07 AM UTC-4, Mitya Sirenef wrote:
    On 03/16/2013 10:53 AM, Yves S. Garret wrote:

    Hi all, I'm well into "Python Programming for the Absolute Beginner" in order to
    become more acquainted with the language. However, when I got to page 304 and
    did my first example:

    http://bin.cakephp.org/view/1107093008

    And this is the error that I'm getting:

    http://bin.cakephp.org/view/399711843

    This is the code that came with the book:

    http://bin.cakephp.org/view/514822432


    What I don't understand is, why am I getting that error? I've done diff -w
    and the code looks for the most part the same. What am I doing wrong when I
    put the application together?




    The error is that indexes are supposed to be integers, instead you have

    a text string:



    "That's not the correct password, so I can't s hare the secret with you."





    -m





    --

    Lark's Tongue Guide to Python: http://lightbird.net/larks/



    The existence of any evil anywhere at any time absolutely ruins a total

    optimism. George Santayana
    *shrug*

    In the example that I have posted from the book it works just fine. I also used
    this batch file to help me along.

    longevity.py
    pause

    Hence the question mark over my head at the moment :) .

    You are giving a message to the delete call, but delete call
    needs an integer to work. In the book, it's not a delete call
    but an insert call that's why it works there.


    -m


    --
    Lark's Tongue Guide to Python: http://lightbird.net/larks/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 16, '13 at 2:53p
activeMar 19, '13 at 2:11p
posts11
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase