Python Forum
Help to understand my mistake
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help to understand my mistake
#8
Hi,

Quote:But why necessarily 4 spaces and not one ?
In Python, a couple of things are by convention, including things like indenting with four spaces (and always and only four spaces). Good Python programmers are picky about that - and that's correct. The general style guide for Python is the PEP 8, the holy grail of Python programming. Just read through it.

Line 31 is super wrong, using global like this is in a class is super wrong. Seems like there is a heavy lack on your side on understanding Python's classes and what attributes of classes are for. I would recommend to read through that in the official Python documentation.

Generally speaking, using global is wrong in 99% of the cases, it's just to a poor design of the program. Avoid global, as it makes it very hard to track the state of your program.

Other things:
Function names are written lowercase_with_underscore in Python, not camelCase or so.

When you start the number things like printMessage_1, printMessage_2, it's a code smell and you most likely want to use a different structure. In your case, all the printMessages have highly redundant code. Use _1_ function only and pass the message to be print e.g. from a dict or a list storing the actual text.

Line 256 is not a valid Python expression, see above. Except this, the while-loop will never run ...

Line 38 should give you a NameError, as gpsp is unknown in the scope of the method.

What's the purpose of line 313? If you intend to stop the thread -> it will not.

Regards, noisefloor

Some of your other functions are too long, they do too much things at a time. I would recommend to break them down in smaller chunks of code.
Reply


Messages In This Thread
Help to understand my mistake - by TeeMan - Jul-04-2019, 02:37 PM
RE: Help to understand my mistake - by Larz60+ - Jul-04-2019, 04:02 PM
RE: Help to understand my mistake - by TeeMan - Jul-04-2019, 04:09 PM
RE: Help to understand my mistake - by noisefloor - Jul-04-2019, 05:31 PM
RE: Help to understand my mistake - by snippsat - Jul-04-2019, 06:09 PM
RE: Help to understand my mistake - by TeeMan - Jul-05-2019, 10:57 AM
RE: Help to understand my mistake - by micseydel - Jul-04-2019, 11:06 PM
RE: Help to understand my mistake - by noisefloor - Jul-05-2019, 11:58 AM
RE: Help to understand my mistake - by TeeMan - Jul-05-2019, 01:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Solved] Please, help me find a simple mistake AlekseyPython 2 1,815 Jun-17-2021, 12:20 PM
Last Post: AlekseyPython
  [split] Could you please clarify where i did mistake also how run without admin right Abubakkar 1 1,841 Jun-14-2021, 09:32 AM
Last Post: Larz60+
  Please help to me to find my mistake in code leonardin 2 1,911 Nov-29-2020, 04:17 PM
Last Post: Larz60+
  minor mistake in code for factorial spalisetty06 2 1,960 Aug-22-2020, 05:00 PM
Last Post: spalisetty06
  Simple mistake about for Nomatter 4 2,369 Jul-16-2020, 02:24 PM
Last Post: Nomatter
  Install Mistake jlerette5 1 1,954 Feb-18-2020, 12:19 AM
Last Post: jefsummers
  What was my mistake in this Python code (easy)? voltman 4 3,550 Nov-19-2019, 09:58 PM
Last Post: snippsat
  countdown script not working..plz help what is mistake randyjack 1 2,174 Oct-28-2019, 06:57 AM
Last Post: perfringo
  Beginner mistake. bbweeg 1 2,105 Aug-17-2019, 07:27 AM
Last Post: perfringo
  Need to find a mistake in my code boris602 3 3,238 Jan-11-2018, 01:49 PM
Last Post: boris602

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020