Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54439

Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

References <22b99b0a-598f-4500-9de9-5041c2ce2c8f@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2013-09-19 13:01 -0600
Subject Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?
Newsgroups comp.lang.python
Message-ID <mailman.158.1379617747.18130.python-list@python.org> (permalink)

Show all headers | View raw


Syntactically, it looks fine.  I would guess the problem is with
whatever editor you are using.  Or as John noted, it could be caused
by the code above it.

I do see an unrelated bug in there, though.  You are using the name
"restart" both for a string entered by the user and for the name of
the function, which is called recursively.  The name for the string,
which is local, shadows the name for the function, which is global.
So if the program ever hits the third branch of the if statement you
will get an error.

Python doesn't optimize tail-recursion, so you would get a different
error if the user hit that branch enough times (around 1000)
consecutively, as the interpreter hits the stack limit.  For example,
if they just held down the Enter key for a while.  So this looping
would be better accomplished with a while True loop and break
statements than with recursion.

On Thu, Sep 19, 2013 at 12:46 PM, William Bryant <gogobebe2@gmail.com> wrote:
> the word 'def' has  squiggily lines but the program works fine. It says: Syntax Error: expected an indented block. - why?
>
> def restart():
>     print("""
>
>     ~~~~~~~~~~~~~~~~
>
>     Cacluation DONE!
>
>     ~~~~~~~~~~~~~~~~
>
>     """)
>     restart = input("\nEnter yes if you want to make a new list and no if you want to close the program (yes/no):  ")
>     restart
>     if restart == "yes" or restart == "y" or restart == "new list":
>         print("You want make a new list...\n")
>         time.sleep(1)
>         NOS()
>     elif restart == "no" or restart == "n" or restart == "close":
>         print("Goodbye!")
>         time.sleep(1)
>         print("Goodbye!")
>         time.sleep(1)
>         print("Goodbye!")
>         time.sleep(1)
>         print("Goodbye!")
>         time.sleep(1)
>         print("Goodbye!")
>         time.sleep(1)
>         quit()
>     else:
>         print("type y or n")
>         time.sleep(0.5)
>         restart()
> --
> https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? William Bryant <gogobebe2@gmail.com> - 2013-09-19 11:46 -0700
  Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? John Gordon <gordon@panix.com> - 2013-09-19 18:51 +0000
    Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? patrick vrijlandt <patrick.vrijlandt@gmail.com> - 2013-09-19 19:08 +0000
  Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? Ian Kelly <ian.g.kelly@gmail.com> - 2013-09-19 13:01 -0600
  Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? Dave Angel <davea@davea.name> - 2013-09-19 20:18 +0000
  Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? Ian Kelly <ian.g.kelly@gmail.com> - 2013-09-19 17:09 -0600
    Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? William Bryant <gogobebe2@gmail.com> - 2013-09-20 00:01 -0700
      Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? William Ray Wing <wrw@mac.com> - 2013-09-20 09:04 -0400
      Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? Duncan Booth <duncan.booth@invalid.invalid> - 2013-09-20 13:39 +0000
        Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? William Bryant <gogobebe2@gmail.com> - 2013-09-20 22:59 -0700
        Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? William Bryant <gogobebe2@gmail.com> - 2013-09-20 23:07 -0700
          Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-21 10:25 +0000
          Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? Dave Angel <davea@davea.name> - 2013-09-21 12:53 +0000
          Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? MRAB <python@mrabarnett.plus.com> - 2013-09-21 17:18 +0100
          Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? Dave Angel <davea@davea.name> - 2013-09-21 18:09 +0000
      Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it? alex23 <wuwei23@gmail.com> - 2013-09-23 10:39 +1000

csiph-web