+ 3

Upon searching, I realize that Python can execute code that's commented out, and produce error. Could you explain this?

Internet search brings up results but they are advanced for me, because they're a bit situation specific, while I'm looking to learn to watch out for it more generally. Can you tell me about it or, redirect me to a source that uses layman's terms, such that, I understand when to expect this or other parsing problems independent of individual cases? Thank you.

21st Jun 2022, 7:37 PM
Korkunç el Gato
Korkunç el Gato - avatar
22 Respuestas
+ 3
DinoBambino this is a public Q&A *with rules*.
23rd Jun 2022, 5:59 PM
Simon Sauter
Simon Sauter - avatar
+ 2
Korkunç the Terrible Frusciante I guess, you are missing something else, the reason may be other.. And python has only single line comments.... The multiline comment is actually a multi line string only.. It will read by python interpreter anyways... You just using as it as comment but actually it's a multi line string which you not usingusing in program but interpretor reads it.
21st Jun 2022, 8:54 PM
Jayakrishna 🇮🇳
+ 1
Are you sure you saved your file changes before running it or made sure that the comment was on the same line since Python does not do multiline comments?
21st Jun 2022, 7:46 PM
Justice
Justice - avatar
+ 1
Justice The code ran on my editor successfully before. I saved the commented out version ran it, I uninstalled repo, I I cleared all data and cache, uninstalled the editor and reinstalled it. It didn't work. I was splitting hairs, started looking for other editors. By the way I now know a possible cause of the error: using print and plot (not like plot inside print, still to no avail) But it was no use. All that didn't work. Then I had this hunch. Let me savor this as a slapped noOb. That comnented out part was looking sneakily at me. I squinted and stared back. Then I highlighted it and sent it to oblivion. Voila. lol the noob struck back (part 2 in theaters. how I'm laughing at my cheesy self, lolzzz)
21st Jun 2022, 7:53 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
Korkunç the Terrible Frusciante 🤣 "the noob struck back". Love that. I've had the same happen to me but it was really only because I didn't save my file before running. Same thing happens with my C codes. If I don't remember to compile, I'll run old code like a ding-bat and wonder why things won't work until I remember I have to recompile LOL.
21st Jun 2022, 7:56 PM
Justice
Justice - avatar
+ 1
Justice This editor has a setting at the start for autosaving. I had that ticked so that was no problem, but I couldn't tell if installing repo itself altered Pydroid in a way I wouldn't know. Cool to know that btw. There's so much to learn (I haven't worked with anything other than Python yet)
21st Jun 2022, 8:02 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
Korkunç the Terrible Frusciante I've learned over the last couple months that while I love auto save, I can't always trust it. 🧐 Sometimes things fall through the cracks so you gotta be sure to sometimes manually save it yourself! And sometimes, you may run code BEFORE the autosave got triggered in the first place. So it may run what you think is "old", but the compiler doesn't yet know that it's old until the autosave event is triggered.
21st Jun 2022, 8:05 PM
Justice
Justice - avatar
+ 1
Justice python does have multiline comments. You use triple quotes for it """ comment comment """
21st Jun 2022, 8:23 PM
Simon Sauter
Simon Sauter - avatar
+ 1
Jayakrishna🇮🇳 But: 1) Lines are numbered on editor. As such, even if a comment takes up more than one line, that passes off as a single line - and this had never produced an error before It reads, alright, the question is why does it execute? 2) You haven't seen the part I commented out. # import matplotlib.pyplot as plt # plt.plot(x, m*x+b) I was trying matplotlib for the first time to see how it works. Doesn't/shouldn't have mattered how stupid this code is. Because it is/was commented out. (I had mentioned this in my question statement in my previous question, only someone who read it thoroughly would know what I was talking about) There's also code in between. Does it matter, though, when it's commented out? Turns out, it does, at least on this editor.
21st Jun 2022, 9:12 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
Jayakrishna🇮🇳 Here's an example. People say it can't happen, the person solves the problem, says it's due to plugin. I don't know anything about eclipse, apanta, etc. But I do know my saving after commenting out didn't work, as well as a myriad of things I did. https://stackoverflow.com/questions/29367653/why-JUMP_LINK__&&__python__&&__JUMP_LINK-code-is-still-executed-after-i-commented-at-eclipse Another example: The problem here, they are guessing, is a saving problem. Or rather a lag, where because the previous code keeps executing, even if the person saved the new version, they get an error when running it. Something like that? https://stackoverflow.com/questions/62931692/why-did-python3-execute-a-piece-of-commented-out-code The thing is, I saved mine, shut down pydroid and opened it again, and I got the same error nevertheless. Then I actually cleared the cache. Nope. I mean surely I'm not seeing it and was at my wit's end but I just don't know what it is. I just got rid of it without understanding it. Hence the question.
21st Jun 2022, 9:28 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
I have no clue. But above your code of 2 comments are perfectly fine. How much the link related to your problem in don't know check for python debug setting.. As far link, # in not a comment in java but it is comment in python.. "More bugs: more curiouasity to learn more information " . Happy learning..
21st Jun 2022, 9:50 PM
Jayakrishna 🇮🇳
+ 1
Thanks to those who spent time reading all this, and thank you Jayakrishna for the feedback. I think the conclusion is: *This is not all that common *Whatever happened is something very specific and cannot be generalized *Whatever happened doesn't inherently have to do with Python but plugins, apps and whatnot. *Wasting more time on this is a bad idea until additional knowledge is somehow obtained. Thanks to all who responded, even confirming an oddity helps a lot.
21st Jun 2022, 10:10 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
Vkd I should tell you: When too much trolling infests a question and reportings start, they sometimes delete the whole question. Is that really what you want? There is "posts" for banter, fun chatting etc. But when you humor someone's trollish post with an answer, it really does disservice to Discussions functionality. I stopped reporting people from the discussions menu, I try to report them using their accounts. I do it rarely, it feels drastic to me and I'm drfinitely not doing it now. I just want to stress the fact that you can actually use Posts for fun and games.
23rd Jun 2022, 4:14 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
DinoBambino This isn't a comedy section. They didn't ask for a joke, they were asking a serious question. And you saw that they already got answer they were alright with so you should have left it at that. Your jokes could potentially get her question removed and she or others who find it useful, including myself, wouldn't be able to reference it. So please think twice before you spam unnecessary jokes in a section where people are seeking genuine and specific help.
23rd Jun 2022, 5:46 PM
Justice
Justice - avatar
+ 1
I know what someone can mean when they say "dang cosmic rays". But I don't think anyone asks here a question so that people just make jokes in passing. You can always downvote my question. But irrelevant comments that are posted just because, are trollish. I didn't say you were a troll, I said the comment was trollish. FYI: I had spent quite some time to make things right before I asked the question. Confidence about things one hardly knows is a guaranteed recipe for failure and more time loss. Its working well at first was one of the very reasons that made it all the more weird. What you fail to realize is I cannot accept something as something because I simply don't know. Back to irrelevancy: This place is for people who think they don't know and those who think they know and would like to share. You always have the right to not share or to downvote.
23rd Jun 2022, 5:58 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 1
DinoBambino Look, make jokes all you want, ALONG with the relevant answer. This is not even as up for negotiation as you'd like to think.
23rd Jun 2022, 6:04 PM
Korkunç el Gato
Korkunç el Gato - avatar
0
Korkunç the Terrible Frusciante I wasn't joking and was talking about soft errors which are caused by cosmic rays... nowadays it isn't common but used to happen regularly in older computing devices. Even forcasting devices happened to have given wrong output because of soft errors
24th Jun 2022, 3:46 AM
Vkd
Vkd - avatar
- 1
Simon Sauter Oh, you're right! I completely forgot about that. Probably because I hate the syntax so much. I don't like the '#' either for single lines. 🤣
21st Jun 2022, 8:24 PM
Justice
Justice - avatar
- 2
DinoBambino Lol😂 I think it really happened in history when ejected electrons did cause a bit to change in random computers which caused lots of confusion and problems
23rd Jun 2022, 4:05 PM
Vkd
Vkd - avatar
- 3
Dang cosmic rays
22nd Jun 2022, 12:38 AM
DinoBambino