home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.linux.misc      Linux-specific topics not covered by oth      135,536 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 133,690 of 135,536   
   rbowman to Richard Kettlewell   
   Re: Python   
   20 Dec 25 05:37:35   
   
   XPost: alt.folklore.computers   
   From: bowman@montana.com   
      
   On Fri, 19 Dec 2025 22:09:45 +0000, Richard Kettlewell wrote:   
      
   > StĂ©phane CARPENTIER  writes:   
   >> It's not my issu. Vim is able to comment blocks of code without issue.   
   >> It's python that can't always manage it. Let say I have that part of   
   >> code:   
   >>   
   >> if test1:   
   >>   if test2:   
   >>     do some stuff   
   >>   
   >> If I comment the second line to see what happens if I remove my test2,   
   >> like I would do with any normal language, then with python it just   
   >> doesn't work because it breaks the indentation.   
   >   
   >     $ cat t.py test1=True test2=False   
   >   
   >     if test1:   
   >       if test2:   
   >         print("L6")   
   >   
   >     if test1:   
   >       #if test2:   
   >         print("L10")   
   >     $ python3 t.py L10   
      
   $ ruff check t.py   
   All checks passed!   
      
   $ ruff format t.py   
   1 file reformatted   
      
      
   ruff did move the print(("L10") out so you wouldn't want to format the   
   file. Removing the # from the formatted file without fixing the   
   indentations gives   
      
   $ ruff check t.py   
   invalid-syntax: Expected an indented block after `if` statement   
     --> t.py:10:5   
      |   
    8 | if test1:   
    9 |     if test2:   
   10 |     print("L10")   
      |     ^^^^^   
      
   StĂ©phane doesn't like Python; I don't like Personal Home Page. We all have   
   our tastes.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca