Ad
  • Custom User Avatar

    def dude():
    return "Where is your PEP?"

    print(dude())

  • Custom User Avatar

    neater to read "-"

  • Custom User Avatar

    According to PEP 8, Programming Recommendations:

    Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier:

    # Correct:
    def f(x): return 2*x
    
    # Wrong:
    f = lambda x: 2*x
    

    The first form means that the name of the resulting function object is specifically 'f' instead of the generic ''. This is more useful for tracebacks and string representations in general. The use of the assignment statement eliminates the sole benefit a lambda expression can offer over an explicit def statement (i.e. that it can be embedded inside a larger expression)