Hacker News new | past | comments | ask | show | jobs | submit | narm60's comments login

The single element list is no longer necessary w/ Python 3's nonlocal keyword (along w/ the old global keyword)


These two aren't equivalent, the first example requires the shapename keyword arg, raising a KeyError when it wasn't specified


That's true. The second one might be better written as:

  def __init__(self, shapename, **kwds):
Or, in Python 3:

  def __init__(self, *, shapename, **kwds):
(making shapename a required keyword-only argument)


  def __init__(self, shapename, **kwds):
is not better written; it allows shapename to be passed positionally which makes cooperative inheritance fragile.


The version that I was rewriting:

  def __init__(self, shapename=None, **kwds):
also allows that.


Can you go into specifics about how any of these examples are non-obvious because the language is incredibly complex?

In the context of higher level and or dynamic languages, I'd argue that Python is rather low on the complexity scale


Yes, and some of those `hidden features' are just nice library functions that avoid adding features to the core language. Look at `enumerate' and `zip' for example, which allow Python to get away with one very simple for-loop.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: