python errors

17 views
Skip to first unread message

scott harwood

unread,
May 16, 2014, 8:07:11 AM5/16/14
to python-n...@googlegroups.com
hello my name is scott and I am working on some code for school and im getting an error that me and a group of people do not know why it is happening. the error is "incossistant use of tabs and spaces in indentation.
The first file is my code the second is an print screen of the issue.
printscreen.docx
PiCubeBLT.py

David Jeffrey

unread,
May 16, 2014, 8:16:26 AM5/16/14
to python-n...@googlegroups.com

Hi Scott, what text editor are you using? Tabs and spaces are different and you need to use one or the other (preferably spaces) but a good text editor will have a setting that automatically uses spaces when you use the key. Idle even would help and you probably have that installed already.

On 16 May 2014 13:07, "scott harwood" <harwo...@googlemail.com> wrote:
hello my name is scott and I am working on some code for school and im getting an error that me and a group of people do not know why it is happening. the error is "incossistant use of tabs and spaces in indentation.
The first file is my code the second is an print screen of the issue.

--
You received this message because you are subscribed to the Google Groups "Python North East" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-north-e...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Kavanagh

unread,
May 16, 2014, 8:30:31 AM5/16/14
to python-n...@googlegroups.com, scott harwood
As David says, you’re missing spaces and tabs.  I’ve opened the code in Sublime Text and you’ve used spaces (4 per ‘tab’) on the first 30 lines and then from line 31 onwards, you’ve used tab characters.  As the default for Python is 8 spaces per tab character (but 4 spaces looks nicer!) then code won’t work.

Anyway, I fixed the space/tab problem in the attached file and also give you a better way to call test() at the bottom of the file.  You still have a couple of errors to sort out.

Best of luck
Alex.


On 16 May 2014 at 13:07:12, scott harwood (harwo...@googlemail.com) wrote:

hello my name is scott and I am working on some code for school and im getting an error that me and a group of people do not know why it is happening. the error is "incossistant use of tabs and spaces in indentation.
The first file is my code the second is an print screen of the issue.
--
You received this message because you are subscribed to the Google Groups "Python North East" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-north-e...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Alex Kavanagh
http://alex.kavanagh.name
PiCubeBLT.py

Rowan Hargreaves

unread,
May 16, 2014, 9:27:56 AM5/16/14
to python-n...@googlegroups.com
If you run into this problem again try running tabnanny on your source
code and it will identify indentation inconsistencies (tabs and
spaces). tabnanny is a part of the Python standard library from 2.1.

You can run it by typing at the command line:
python -m tabnanny <file_to_check>

where you need to substitute <file_to_check> for the path of the file
you are wanting to check.

Have a look here for more info:
http://pymotw.com/2/tabnanny/

Good luck with it!

Rowan
--
Rowan

scott harwood

unread,
May 16, 2014, 10:43:56 AM5/16/14
to python-n...@googlegroups.com, scott harwood, tinwo...@googlemail.com
thank you i guess it diednt like the text ediitor i was using

scott....@talktopebble.co.uk

unread,
May 18, 2014, 3:02:04 AM5/18/14
to python-n...@googlegroups.com
Hi Scott,

It's usually a case of setting up your text editor to switch tabs for whitespace.
Notepad++: https://stackoverflow.com/questions/455037/notepad-convert-tabs-to-spaces
Gedit: https://answers.launchpad.net/ubuntu/+source/gedit/+question/163516

Most decent editors have plugins/settings that will convert tabs into whitespaces whenever you save the file. Searching "Seting my_editor for Python" will yield some results (replacing my_editor with the name of your editor".

Legal status: Any views or opinions are solely those of the sender and do not necessarily represent those of SF Software Ltd unless expressly stated in the body of the text of the email, this email is not intended to form a binding contract.

Confidentiality: this communication may contain information that is confidential and/or privileged and is for the exclusive use of the intended recipient(s). Any form of distribution, copying or use of this communication by anyone else is strictly prohibited. If you have received this communication in error, please reply to this message or telephone +44 (0)845 310 1788 and delete this communication and destroy any copies. 

Security: this communication has been created and sent in the knowledge that internet e-mail is not secure. We strongly advise you to understand and to be aware of the lack of security when e-mailing us. If you communicate with us via e-mail, we will assume that you accept the security risk and that you authorise us to communicate with you in the same format. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. 

Warning: Although we take reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the use of this email or attachments. 
-----------------------------------------------------------------------------------------------------------------
In compliance with Directive on Disclosure, The Companies Regulations 2006, effective 01 January 2007 talktopebble.co.uk,schoolfund.co.ukschoolfundfinder.co.ukeasyusbooks.co.ukclubfund.co.uk are domain names registered to SF Software Limited.

SF Software Limited is a company registered in England and Wales with company number: 05580540. Our trading name is Pebble our trading address and registered office is: Media Exchange Three, Coquet Street, Newcastle upon Tyne, NE1 2QB
VAT Registration number is: GB 873 5186 95
Reply all
Reply to author
Forward
0 new messages