Re: Python
On Wed, 17 Dec 2025 03:11:09 -0500, c186282 wrote: >Probably 50% of the text in my code - doesn't matter which lang - is >'comments'. I looked at some of my code and it's pretty much comment free. There are a couple of .c files with comments that I reused from another project that have somebody's comments. I had a tendency to clone similar projects and inherit some code that I could tweak so the final executable did one thing well. We had a couple of nightmares that originally did one thing well but for the next project the programmer said 'That's close to what I need. A few configuration values here and there and it will work.' The next time around it got some more configuration values to do something else. I have a Swiss Army knife I found; it's in the junk drawer. -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
On 12/16/25 20:54, rbowman wrote: On Tue, 16 Dec 2025 21:45:42 - (UTC), Lawrence D’Oliveiro wrote: On Mon, 15 Dec 2025 12:57:57 +, mm0fmf wrote: On 14 Dec 2025 11:56:42 GMT, Stéphane CARPENTIER wrote: My issues with python are: - It's using indentations, so when I comment a block of code to see ''' and ''' are your friend Unless the block has triply-quoted strings inside it ... Yeah, well. I've been burned more than once by someone who added /* stupid comment */ someplace west of the 80th column in the code. Well .. reflex :-) Now most of my code lines have a "# WhatThisIs" comment at the end. I like to micro-document so I can remember what my own fuckin' code does a few years down the line. AMAZING how quickly the 'why' vanishes from the mind :-) Probably 50% of the text in my code - doesn't matter which lang - is 'comments'. ANYway ... you CAN easily do block commenting in Python ... P3 anyway, not so sure about P2 because I never used it. IF there's a P4 ... they really SHOULD accept "/*" as a start-comment. -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
On Wed, 17 Dec 2025 22:13:21 +, Richard Kettlewell wrote: > If you prefer the comment markers to match the indentation of the whole > block, that works too: I keep it simple and use the first column, s/^/#/ in vim. s/^#// to make them go away. -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
On 12/17/25 14:17, rbowman wrote: On Wed, 17 Dec 2025 03:11:09 -0500, c186282 wrote: Probably 50% of the text in my code - doesn't matter which lang - is 'comments'. I looked at some of my code and it's pretty much comment free. There are a couple of .c files with comments that I reused from another project that have somebody's comments. I had a tendency to clone similar projects and inherit some code that I could tweak so the final executable did one thing well. We had a couple of nightmares that originally did one thing well but for the next project the programmer said 'That's close to what I need. A few configuration values here and there and it will work.' The next time around it got some more configuration values to do something else. I have a Swiss Army knife I found; it's in the junk drawer. Well ... I'll better understand, and be able to mod, my old programs better than you. I find 'excessive' commenting anything BUT 'excessive'. I *enjoy* writing out the meaning and implications of almost every step. -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
Lawrence D’Oliveiro writes: > On Mon, 15 Dec 2025 12:57:57 +, mm0fmf wrote: > >> On 14 Dec 2025 11:56:42 GMT, Stéphane CARPENTIER wrote: >> >>> My issues with python are: >>> - It's using indentations, so when I comment a block of code to see >> >> ''' and ''' are your friend > > Unless the block has triply-quoted strings inside it ... Then """ and """ are your better friends. -- Dan Espen -- https://mail.python.org/mailman3//lists/python-list.python.org
RE: Python
Then """ and """ are your better friends. Dan Espen[-] It is interesting how the """ has to obey the indention rule. -- https://mail.python.org/mailman3//lists/python-list.python.org -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
On Thu, 18 Dec 2025 at 18:01, c186282 wrote: >Oh, I usually write "i=i+2". It's a bit more >clear and becomes the same code anyway. += >is more a 'C' thing. As are semicolons and /* */ comments. ChrisA -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
According to c186282 : > Well ... I'll better understand, and be able to mod, my > old programs better than you. I find 'excessive' commenting > anything BUT 'excessive'. I *enjoy* writing out the meaning > and implications of almost every step. That's fine as long as it's done with adequate discipline i += 2; /* add one more bloofus to i */ -- Regards, John Levine, [email protected], Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
On 12/17/25 22:28, John Levine wrote: According to c186282 : Well ... I'll better understand, and be able to mod, my old programs better than you. I find 'excessive' commenting anything BUT 'excessive'. I *enjoy* writing out the meaning and implications of almost every step. That's fine as long as it's done with adequate discipline i += 2; /* add one more bloofus to i */ Gotta add a couple of words explaining the *context* - WHY you are incrementing the var by 2, not one or three. Did a recent little app where you needed to inc by two ... and the comment explained why. Oh, I usually write "i=i+2". It's a bit more clear and becomes the same code anyway. += is more a 'C' thing. -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
On 12/17/25 17:11, Lawrence D’Oliveiro wrote: On Wed, 17 Dec 2025 16:17:30 -0500, Dan Espen wrote: Lawrence D’Oliveiro writes: On Mon, 15 Dec 2025 12:57:57 +, mm0fmf wrote: On 14 Dec 2025 11:56:42 GMT, Stéphane CARPENTIER wrote: My issues with python are: - It's using indentations, so when I comment a block of code to see ''' and ''' are your friend Unless the block has triply-quoted strings inside it ... Then """ and """ are your better friends. What if you have both present? Both ''' and """ work ... but you need to close the comment block with the same thing. ANYway, block-comments ARE (at least now) to be had in Python. Never used P1 or P2 worth anything, maybe they didn't have block comments ??? -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
On Thu, 18 Dec 2025 03:28:34 - (UTC), John Levine wrote: > According to c186282 : >> Well ... I'll better understand, and be able to mod, my old programs >> better than you. I find 'excessive' commenting anything BUT >> 'excessive'. I *enjoy* writing out the meaning and implications of >> almost every step. > > That's fine as long as it's done with adequate discipline > > i += 2; /* add one more bloofus to i */ /** obtain the list of units for the passed in object */ list_ret_val = (list_obj_ret *)ListObj(&obj_s, OTUnit); That's an actual example of a comment that doesn't add anything to the discussion. If you don't know what ListObj() does, the structure of the linked list it returns, or that you have to cast the data field of the linked list to a UnitStruct, that comment isn't going to help. If you do know it's readily apparent you're passing in a Cfs object to get the list of units attached to it. Doing a quick and dirty search there are 1752 calls to ListObj in the codebase very few of which are commented. If you're doing something quirky, comment it. -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: Rock Paper Scissors Code Bug?
The other recommendation i would make is to shorten the response the player
needs to give when choosing their option. "R", "P", "S" is sufficient to
determine the player's choice. Making the player enter the whole word
introduces opportunity for misspellings. I would also allow the player to
enter "Q" in case they decide to stop playing. And always check to make
sure the player entered something and didn't just hit enter. Also don't
use .lower() until you check to make sure you have a valid entry, the
player might enter a character that can't be converted to lower case, like
a number or punctuation.
while True:
player_choice = input("Please enter your choice (Rock, Paper, Scissors,
or Quit): "
If not player_choice or player_choice[0] not in "RPSQrpsq": # check
if None or invalid choice
print("Invalid choice...")
else:
If player_choice[0].lower() == "q":
print("Thanks for playing. Good-bye.")
break
# code to score the choices, blah, blah, blah
Good luck with your new version!
On Mon, Dec 8, 2025, 5:37 PM John Smith via Python-list <
[email protected]> wrote:
> Thanks for the recommendations. I'm building a whole new version based on
> the old one, with simpler code and functions to find win stats.
> --
> https://mail.python.org/mailman3//lists/python-list.python.org
>
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: Python
Dan Espen writes:
> Lawrence D’Oliveiro writes:
>> On Mon, 15 Dec 2025 12:57:57 +, mm0fmf wrote:
>>> On 14 Dec 2025 11:56:42 GMT, Stéphane CARPENTIER wrote:
My issues with python are:
- It's using indentations, so when I comment a block of code to see
what happens, it breaks everything and I have to manage the
indentations. I can't just comment/uncomment a block of code as I do
with other programming languages.
>>> ''' and ''' are your friend
>>
>> Unless the block has triply-quoted strings inside it ...
>
> Then """ and """ are your better friends.
Why bother? If you want to comment out a block, you can do just that,
much the same as in any other language.
$ cat t.py
def f(x):
#while x < 10:
#print(x)
#x += 1
print("done")
f(3)
$ python3 t.py
done
If you prefer the comment markers to match the indentation of the whole
block, that works too:
$ cat t.py
def f(x):
# while x < 10:
# print(x)
# x += 1
print("done")
f(3)
$ python3 t.py
done
Or perhaps you prefer the comment markets to follow the lines they’re
commenting out:
$ cat t.py
def f(x):
# while x < 10:
# print(x)
# x += 1
print("done")
f(3)
$ python3 t.py
done
--
https://www.greenend.org.uk/rjk/
--
https://mail.python.org/mailman3//lists/python-list.python.org
