this may sound dumb, but I am still fairly new, is there clear way to spot if I have tabs or spaces in the wrong place with PyCharm? Or even to display all tabs and spaces visually?
I just spent ages looking for problem with 'invalid syntax' error at Def line of function, I had thought it might still be some wrong indent, which I did have before, so checked this painstakingly and found nothing. In the end, was missing ) from end of function before this. I realised the coloured lines on right hand side show errors and got this one from there.
Also I understand you can mix tabs and 4 space character indents in PyCharm with no problem?
But if you use tab one line and 4 spaces the next with, for example, simple text editor, Python will say 'no I'm not going to run this because I'm a strict pedant and this is just too naughty'? Any other common sense best practice habits in this area?
How to 'see' / highlight tabs and spaces in PyCharm for checking indentation?
You can tell Pycharm to visually show tabs and spaces by going to View -> Active Editor -> Show Whitespaces:
Also I understand you can mix tabs and 4 space character indents in PyCharm with no problem?
Yes you can. But you shouldn't. Even if you choose to however, PyCharm will convert them all to spaces by default. You can change this behavior by going to Settings -> Editor -> Code Style -> Python and then selecting the Use tab character check box:
There's a setting to make white space visible in:Settings -> Editor -> General -> Appearance -> Show whitespaces
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With