Python IDLE: How to type correct indentation?
Posted
by
user2988464
on Stack Overflow
See other posts from Stack Overflow
or by user2988464
Published on 2014-08-24T03:13:49Z
Indexed on
2014/08/24
4:20 UTC
Read the original article
Hit count: 376
Mac: Maverick Python: 3.4
I tried to testtimeit
module in Python's IDLE
import timeit
>>> timeit.timeit( "obj.method", """
class SomeClass:
def method(self):
pass
obj = SomeClass()
""")
When I tried to type def method(self):
on the next line of class SomeClass
, I hit Tab
, it prompted a window showing the files inside my Document
directory. So I hit Ctrl+Tab
instead.
But I still got the error:
Traceback (most recent call last):
File "<pyshell#26>", line 6, in <module>
""")
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/timeit.py", line 213, in timeit
return Timer(stmt, setup, timer).timeit(number)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/timeit.py", line 122, in __init__
code = compile(src, dummy_src_name, "exec")
File "<timeit-src>", line 9
_t0 = _timer()
^
IndentationError: unindent does not match any outer indentation level
Can someone explain:
- how to fix it, and
- how to avoid the prompt of
My Document
appear?
Thx!!!
© Stack Overflow or respective owner