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,720 of 135,536   
   Richard Kettlewell to Nuno Silva   
   Re: Python   
   20 Dec 25 16:36:29   
   
   XPost: alt.folklore.computers   
   From: invalid@invalid.invalid   
      
   Nuno Silva  writes:   
   > On 2025-12-19, 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   
   >   
   > Doesn't this only work if there are no statements directly under "if   
   > test1:" besides the second conditional?   
      
   Indeed, but that’s not the example Stéphane gave. It’s tricky to debug   
   someone’s problem if they don’t describe it accurately.   
      
   A more general solution would be to force the condition to False, e.g.:   
      
      if test1:   
        if False or test2:   
          stuff...   
        more stuff...   
      
   --   
   https://www.greenend.org.uk/rjk/   
      
   --- 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