Python problems...
-
Using a programming language named after a snake (a constrictor, no less) is maybe a sign. "the devil made me do it" I do not use python for the reasons mentioned (invisible code, tab and space blindness, etc.) I do use other's python code as pseudo code, of sorts, for C.
"A little time, a little trouble, your better day" Badfinger
To be perfectly honest I think the retail price of Python has more to do with it popularity than anything else. Remember you get what you pay for. :omg:
-
As trønderen stated above, with braces whitespace becomes more or less immaterial and so it is, for the most part, with Java, C#, C, C++, etc. And that leads to not having to indent when structuring your code. I was always led to believe that one of the reasons Python made whitespace significant was to enforce "proper" code structure and now all those ugly 2-finger-typed brace characters can be eliminated. In a sense, they actually are there, they're just invisible - and therein lies the rub (at least to braceophiles like me).
Yes, I agree ... I even do not notice anymore how I type them :-). I got so much used to them that code without them seems odd (and my brain is warning me - this won't work, so I get in persistent confusion when looking at standard Python code). Also, the missing ; in some languages' code bugs me a lot ... It seems that in Go it is implicit, for some strange reason ... (there is always a good reason for something like this :-) of course )
-
:shudder: Not to diss on COBOL, but after thirty+ years I still remember having to help a fellow college student debug a COBOL program which wasn't working. She had used TABs to pad a string to the desired length -- it looked OK on a VT100, but the compiler knew better.
That's my main problem with Python as well. Tabs? Spaces? Who knows? Source code should not be invisible. I will make a grudging exception for line based grammars like Visual BASIC. At least that's manageable.
To err is human. Fortune favors the monsters.
-
OriginalGriff wrote:
"use tabs" to save file space
I'm quite certain that isn't the reasoning. I think some TABophiles use TABs to save keystrokes. I, of course, use two SPACEs per TAB and otherwise a whole :elephant:ing load of whitespace, vertical space in particular. I am not interested in "saving space" or "saving keystrokes" I need space so I can read the stuff. The simple IDE I developed for myself defaults to TABs because there is no reasonable number of SPACEs to use as a default instead. But what can save file space is that it right-trims SPACEs from lines when it saves a file -- that eliminates a lot more characters from saved files than using TABs.
The reason I use tabs is Shift+Arrow = Highlight - Tab/Shift-Tab = indent/deindent the block of text. I use this so often when I code that I could scarcely be productive without it.
To err is human. Fortune favors the monsters.
-
The reason I use tabs is Shift+Arrow = Highlight - Tab/Shift-Tab = indent/deindent the block of text. I use this so often when I code that I could scarcely be productive without it.
To err is human. Fortune favors the monsters.
honey the codewitch wrote:
Tab/Shift-Tab = indent/deindent the block of text
Yes, using the TAB key, but it actually inserts/removes the necessary number of SPACEs rather than TABs. I don't see that TAB characters makes a difference in doing that.
-
honey the codewitch wrote:
Tab/Shift-Tab = indent/deindent the block of text
Yes, using the TAB key, but it actually inserts/removes the necessary number of SPACEs rather than TABs. I don't see that TAB characters makes a difference in doing that.
Oh, I think my editor uses tabs. So I just use them too. It would be weird anyway for me switching between Tab and spacebar. In the end i always "Format Document" and I've got the process for that tailored more or less to my liking so it's easy and it works for me.
To err is human. Fortune favors the monsters.
-
Oh, I think my editor uses tabs. So I just use them too. It would be weird anyway for me switching between Tab and spacebar. In the end i always "Format Document" and I've got the process for that tailored more or less to my liking so it's easy and it works for me.
To err is human. Fortune favors the monsters.
I'm not talking about using the spacebar to indent code. I don't think the issue is about what key is pressed, but about what characters are produced and stored. Back when using a VT we had to indent by using the spacebar. But with modern(ish) IDEs we use the TAB key, and have it insert either SPACEs or TABs as configured -- the result looks the same, but it isn't. I don't recall what Turbo Pascal and C/C++ did with TABs. When I use Notepad, I still have to use the spacebar to indent because it uses eight-character-wide TAB-stops, but I don't use that for code.
-
I'm not talking about using the spacebar to indent code. I don't think the issue is about what key is pressed, but about what characters are produced and stored. Back when using a VT we had to indent by using the spacebar. But with modern(ish) IDEs we use the TAB key, and have it insert either SPACEs or TABs as configured -- the result looks the same, but it isn't. I don't recall what Turbo Pascal and C/C++ did with TABs. When I use Notepad, I still have to use the spacebar to indent because it uses eight-character-wide TAB-stops, but I don't use that for code.
Ah, I getcha. Sorry. Yeah, I think my editor inserts 4 spaces when I hit tab.
To err is human. Fortune favors the monsters.
-
Ah, I getcha. Sorry. Yeah, I think my editor inserts 4 spaces when I hit tab.
To err is human. Fortune favors the monsters.
I used to do four, but I've cut down to two. Which is bizarre considering the tiny (8 pt) font I use for code.
-
I used to do four, but I've cut down to two. Which is bizarre considering the tiny (8 pt) font I use for code.
No, it’s logical: four spaces would indent too much in relation to font size. Full disclosure: I also use two spaces and a tiny font :-D
Mircea
-
No, it’s logical: four spaces would indent too much in relation to font size. Full disclosure: I also use two spaces and a tiny font :-D
Mircea
I have the opposite opinion, I think the indent should remain constant (maybe about a 1/4 or a 1/2 inch) regardless of font size, so a tab-stop would use fewer character-places with a larger font and more with a smaller one. But I know of no IDE which uses absolute tab-stops -- I wouldn't willingly code in a word processor.
-
I have the opposite opinion, I think the indent should remain constant (maybe about a 1/4 or a 1/2 inch) regardless of font size, so a tab-stop would use fewer character-places with a larger font and more with a smaller one. But I know of no IDE which uses absolute tab-stops -- I wouldn't willingly code in a word processor.
Let’s agree to disagree :) There is a reason however why letters have a certain height to width ratio. Also paragraph indenting, in books that use it, is proportional to font size. Your artistic eye might know better than your logical brain :)
Mircea
-
Let’s agree to disagree :) There is a reason however why letters have a certain height to width ratio. Also paragraph indenting, in books that use it, is proportional to font size. Your artistic eye might know better than your logical brain :)
Mircea
Certainly, and a lot of this still stems from VT screens and such with only one or two character sizes. On a VT340 or such I used the 132 character-per-line setting because I didn't like to 80 character-per-line limit. I'm not real concerned with literature type setting. Don't get me started on illuminated letters at the start of every block... ;P
-
To be perfectly honest I think the retail price of Python has more to do with it popularity than anything else. Remember you get what you pay for. :omg:
Granted, the "price is right". Python is very handy for one-off kind of stuff. I am using it to debug/tune Chris's CP-AI used with Blue Iris, mostly BI settings. Watch for a change in the BI log, filter it with what I am looking for and send me an SMS. Handy to get a heads up so as to check out the event. Maybe trivial, but handy. Also use it from time to time as a syslog server when looking for people trying to access sites they don't belong on using the corp LAN. Cleanup after ransomware is no fun. Now, this payroll program I an writing with Python is more of a struggle. :) An intellectual is someone who can listen to the William Tell Overture and not think of the Lone Ranger. ¯\_(ツ)_/¯
>64 Some days the dragon wins. Suck it up.
-
I'm not talking about using the spacebar to indent code. I don't think the issue is about what key is pressed, but about what characters are produced and stored. Back when using a VT we had to indent by using the spacebar. But with modern(ish) IDEs we use the TAB key, and have it insert either SPACEs or TABs as configured -- the result looks the same, but it isn't. I don't recall what Turbo Pascal and C/C++ did with TABs. When I use Notepad, I still have to use the spacebar to indent because it uses eight-character-wide TAB-stops, but I don't use that for code.
Tab spaces should be in half-inches or centimeters, depending where you live. Not characters.
Nothing succeeds like a budgie without teeth. To err is human, to arr is pirate.
-
Worse: space and tab are not the same: so two lines which look to be identically indented in your chosen editor can be in different code blocks as a tab is one whitespace regardless of the visual effect. X|
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Why don't Python editors indicate tabs/spaces with some sort of symbol? Perhaps '{' for tab and ' ' for space. To be even more helpful, the editor could indicate the end of a block with '}' ?
-
Hi All, Being strongly encouraged (read forced) to use Python for a test rig. Okay need to get down with Kids etc. but syntactic white space 'align your tabs' (who came up with that, is it 1988, am I using a BBC micro) oh gord!!!:mad:
Ok, so, I'm going to give you the single best use-case for bothering with Python. Jupyter Notebooks. It's a webserver-based environment to document, script, and generate results in a single document. You can transform notebooks into slides, so you can teach a class. You can effectively collab with people on notebooks, so you can do research across the globe. You can generate and plot all manner of graphs, so you can use it to prove something. There's markup and HTML support if you need it. Anything else --> don't use Python
-
OriginalGriff wrote:
"use tabs" to save file space
I'm quite certain that isn't the reasoning. I think some TABophiles use TABs to save keystrokes. I, of course, use two SPACEs per TAB and otherwise a whole :elephant:ing load of whitespace, vertical space in particular. I am not interested in "saving space" or "saving keystrokes" I need space so I can read the stuff. The simple IDE I developed for myself defaults to TABs because there is no reasonable number of SPACEs to use as a default instead. But what can save file space is that it right-trims SPACEs from lines when it saves a file -- that eliminates a lot more characters from saved files than using TABs.
I do not understand why anyone uses spaces tbh. I also set my tab spacing to 2, but most of the legacy code I work on - and even some of the newer stuff added to that legacy code - uses spaces, and are thus untidy along the left margin and often not collapsible. Use tabs, for the love of pretty code, and for that matter, used blank lines between logical blocks. And concise comments.
-
Ok, so, I'm going to give you the single best use-case for bothering with Python. Jupyter Notebooks. It's a webserver-based environment to document, script, and generate results in a single document. You can transform notebooks into slides, so you can teach a class. You can effectively collab with people on notebooks, so you can do research across the globe. You can generate and plot all manner of graphs, so you can use it to prove something. There's markup and HTML support if you need it. Anything else --> don't use Python
Finished the tutorial I had to do, I can say it gets around some problems (& creates it own) but there never issues I have had I mean 'you can create a web server in two lines', a good 90% of the code I have written is embedded (except a few test rig software front ends), by embedded I mean small memory, limited output and tends to be mounted in a hole under ground or under water. So web is not an issue...
-
I do not understand why anyone uses spaces tbh. I also set my tab spacing to 2, but most of the legacy code I work on - and even some of the newer stuff added to that legacy code - uses spaces, and are thus untidy along the left margin and often not collapsible. Use tabs, for the love of pretty code, and for that matter, used blank lines between logical blocks. And concise comments.
I see no reason it wouldn't be collapsible. What IDE can't collapse it? How does your code look if you open it in another IDE/editor? Open it in Notepad for instance.