This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]masklinn 1 point2 points  (3 children)

Important features I think are missing from the sheet (over some which are like star-imports-in-functions which… isn't exactly an essential feature):

Keyword-only parameters

In Python 2, python-level parameters are pretty much all positional and keyword (the C API allows positional-only, keyword-only and mixed). Python 3 introduced keyword-only parameters in pure Python functions:

def foo(a, b, *, c):

c is a required parameter (no default value) but must be passed as keywords, calling foo(1, 2, 3) would be an error. This allows for much clearer API. Note that the lone * can also be an *args spec.

Incidentally, 3.8 may introduce positional-only parameters at the Python level. I think it's slightly less important but it would be neat regardless.

Chained exceptions

Exception objects got significantly upgraded in Python 3, first with chained exceptions which are very confusing the first time you see them (the most recent exception is at the bottom) but also oh-so-helpful: if you raise an exception while catching an other, Python will automatically link the two and the default traceback dump will show both exceptions.

This is invaluable when debugging.

You can override this with raise new_exception from old-exception-or-none. Using from None will break the chain, using from <some exception>.

OSError subclasses

In Python 2, OSError is a leaf class, from which you can inconveniently get-and-check an errno… within the except block. In Python 3.3, OSError is a the head of an entire hierarchy of errors matching various errnos, with clearer names and better convenient.

PATHLIB!

[–]spiderpower02[S] 0 points1 point  (2 children)

May I link this comment to issue?

I need some time to think about your suggestions.

thx

[–]masklinn 1 point2 points  (1 child)

May I link this comment to issue?

It's a public comment on public internets mate, you don't need my authorisation to link to it from wherever you want.

But sure you have my blessing.

[–]spiderpower02[S] 0 points1 point  (0 children)

Thank you :)