python editor not telling me what the problem is

This is the place for queries that don't fit in any of the other categories.

python editor not telling me what the problem is

Postby Hissing Cockroach » Fri Nov 15, 2013 9:46 pm

Hi. Whenever I type a certain error(I think it's an error), run module
just either creates an indentation error itself and makes me fix it, or
thinks there is a syntax error where there isn't. Does anyone else get this
problem? If so, can anyone tell me how to fix it?
User avatar
Hissing Cockroach
 
Posts: 108
Joined: Sat Sep 14, 2013 2:35 pm
Location: Earth

Re: python editor not telling me what the problem is

Postby stranac » Fri Nov 15, 2013 10:08 pm

Err, what?
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1093
Joined: Thu Feb 07, 2013 3:42 pm

Re: python editor not telling me what the problem is

Postby micseydel » Fri Nov 15, 2013 10:09 pm

What "certain error"? Where's the code? Does fixing your indentation errors help? What editor are you using? Did you not think to answer any of these questions before I asked them?
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1179
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: python editor not telling me what the problem is

Postby metulburr » Fri Nov 15, 2013 10:13 pm

Have you copy and pasted code from here and there and mixed them together a lot? If you copy a piece of code that had indentation as TABS, and yours is SPACES, and its within a block of code, it will cause an indentation error. Then it LOOKS like the indentation is accurate. But you really cannot tell without an IDE that tells you what the indenation is. It appears as if you are using IDLE still. I am not sure if that IDE allows for showing indentation type or not. Most good ones do.

For example this is the IDE Geany showing indentation. the dots indicate spaces, while the arrows indicate tabs.
indenterr.png
indenterr.png (16.68 KiB) Viewed 420 times

If you look closesly, you can see the class' first two lines are indented by spaces while the rest are indented in tabs. This is going to cause:
Code: Select all
  File "test3.py", line 19
    self.surf = pygame.Surface((5,10)).convert()
                                               ^
TabError: inconsistent use of tabs and spaces in indentation

or if the tabs and spaces are in reverse order it will cause:
Code: Select all
IndentationError: unindent does not match any outer indentation level

However you cannot see it unless your IDE has that. Which in Geany you just convert the whole file to use spaces as indentation in which fixes the problem
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1366
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: python editor not telling me what the problem is

Postby Hissing Cockroach » Sun Nov 17, 2013 7:29 am

The tabs mixed with spaces doesn't seem to be the problem. What is happening
is I type something like pygame.mouse.get_visible in the wrong place, then, in
run module(No other python editors have run module, so that's why I sometimes use IDLE), It just
creates an indentation error, and when I fix it and do run module again, it just creates another
indentation error.
User avatar
Hissing Cockroach
 
Posts: 108
Joined: Sat Sep 14, 2013 2:35 pm
Location: Earth

Re: python editor not telling me what the problem is

Postby Mekire » Sun Nov 17, 2013 7:46 am

Hissing Cockroach wrote:No other python editors have run module, so that's why I sometimes use IDLE
This isn't true at all. Give Pyscripter a try (I do believe you are on windows). There are plenty of other options too.

This aside, IDLE is almost definitely not your problem here. Don't cry glitch. If you are getting on error in IDLE saying you have an indentation error, then you have an indentation error. Select the whole file by pressing ctrl+a; then press alt+6; a window will pop up; make sure it says 4 and press ok. Then retry your program. In the future never use tabs. Note that I am not telling you not to use the tab key; just make sure your IDE is set up so that the tab key adds 4 spaces rather than 1 tab. All good IDEs (and even IDLE) have this capability.

-Mek
User avatar
Mekire
 
Posts: 986
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: python editor not telling me what the problem is

Postby octopez » Mon Nov 18, 2013 10:26 am

Hm, despite the indentation problems, could it be, that you really have to use an other editor?
IDLE is known to have problems with Pygame and other graphical modules.
Greetings and all the best,
Octopez

Strange women lying in ponds distributing swords is no basis for a system of government.
User avatar
octopez
 
Posts: 25
Joined: Fri Feb 08, 2013 11:26 pm

Re: python editor not telling me what the problem is

Postby metulburr » Mon Nov 18, 2013 1:17 pm

The tabs mixed with spaces doesn't seem to be the problem.

I do believe it is. I think what is happening is your pushing either tab or spaces to the next line. To completely ensure to get rid of all tabs, convert the whole file to tabs using spaces. When i first started on python i always used tabs to indent, and it caused a lot of problems identical to the one you are having. Now, by habit, the first thing i do when i grab a piece of code off the internet is, check for tab/space mixing and sometimes just convert it all to spaces anyways just to ensure to not have the problem you are having.

(No other python editors have run module, so that's why I sometimes use IDLE)

just because there is not a GUI button that says "Run Module" does not mean other IDE's do not have such capabilities. Every IDE has a way to quickly execute python and the file. Again i am going to use geany for an example... In Geany The equivalent to IDLE's run module is Build -> Execute. However Execute is just a command line/terminal command. under the hood it just executes
Code: Select all
/path/to/python path/to/file.py
, in which you can modify the command and save it. I would suggest executing from your command line for awhile to figure out what happens under the hood of your IDE's. After that point, then use IDE's and you will know how to modify/ or even find the IDE's execute button
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1366
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: python editor not telling me what the problem is

Postby Hissing Cockroach » Tue Nov 19, 2013 6:13 pm

metulburr wrote:To completely ensure to get rid of all tabs, convert the whole file to tabs using spaces.


I have done that almost every time I get this problem. Unfortunately, it doesn't help.
Last edited by Hissing Cockroach on Tue Nov 19, 2013 6:16 pm, edited 1 time in total.
User avatar
Hissing Cockroach
 
Posts: 108
Joined: Sat Sep 14, 2013 2:35 pm
Location: Earth

Re: python editor not telling me what the problem is

Postby micseydel » Tue Nov 19, 2013 6:15 pm

micseydel wrote:Where's the code?
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1179
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 6 guests