• The Errors Of My Fingertips

    From Stefan Ram@21:1/5 to All on Fri Feb 3 19:15:13 2023
    Out of the top of my head, errors I make most often when
    writing Python code:

    WRONG:
    f( x )
    print( x )

    WRONG:
    def f( x )
    print( x )

    WRONG:
    f( x ):
    print( x )

    SHOULD BE:
    def f( x ):
    print( x )

    WRONG:
    else

    SHOULD BE:
    else:

    WRONG:
    x[ 2, 7 ]

    SHOULD BE:
    x[ 2: 7 ]

    WRONG
    print x
    # I never used Python 2!

    SHOULD BE:
    print( x )

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Stefan Ram on Fri Feb 3 19:59:09 2023
    ram@zedat.fu-berlin.de (Stefan Ram) writes:
    SHOULD BE:
    else:

    and another one is:

    WRONG:
    while i in re.finditer( '=[^,]+', example ):

    WRONG:
    for each i in re.finditer( '=[^,]+', example ):

    SHOULD BE:
    for i in re.finditer( '=[^,]+', example ):

    I am talking about "typos" here: I know what's correct,
    but when typing fast, my fingers sometimes get it wrong.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gilmeh Serda@21:1/5 to Stefan Ram on Sat Feb 4 19:23:50 2023
    On 3 Feb 2023 19:59:09 GMT, Stefan Ram wrote:

    I am talking about "typos" here: I know what's correct, but when
    typing fast, my fingers sometimes get it wrong.

    Let me guess, vim user?

    --
    Gilmeh

    Ten persons who speak make more noise than ten thousand who are silent. -- Napoleon I

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Gilmeh Serda on Mon Feb 6 19:06:12 2023
    Gilmeh Serda <gilmeh.serda@nothing.here.invalid> writes:
    On 3 Feb 2023 19:59:09 GMT, Stefan Ram wrote:
    I am talking about "typos" here: I know what's correct, but when
    typing fast, my fingers sometimes get it wrong.
    Let me guess, vim user?

    I sometimes use vim, but I write Python mainly with other editors.

    PS: In the meantime, I have noticed some other types of errors
    I make often:

    - Forgetting "return" at the end of a function
    - using "+=" instead of "append" when adding to a list
    - forgetting "r" in front of strings with regular expressions

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)