- Python 3.7 released: Standard checklist:
- Run installer
- Delete the old 3.6 folder from /Applications
- Run the certificate command in the new 3.7 folder (the other shits a PATH into my shell profile, don’t need it)
- Run IDLE and verify it’s 3.7.0. Happily, no longer have to fight with updating Tcl/Tk.
- Run “python3” from Terminal and verify it’s 3.7.0
- Run a random Python script to make sure nothing’s broken.
Nanosecond-accurate time functions and switching more ASCII/C Locale into UTF-8 are nice improvements, but those are more patching up legacy annoyances than “must have”.
I’m mostly interested in dataclasses, which makes it much easier to build little struct-type objects instead of random dicts or lists which have all sorts of problems (no equality, hashing, typo-safety).
I greatly dislike the addition of BDSM typing, but it’s mostly optional, EXCEPT you have to use them in dataclasses:
from dataclasses import dataclass @dataclass class Point: x : float = 0.0 y : float = 0.0 >>> p = Point() >>> p Point(x=0.0, y=0.0) >>> q = Point(1.1, 2.2) >>> q Point(x=1.1, y=2.2)
If I define Point without the type annoytations[my new favorite typo!], only the default constructor works, and it doesn’t print the fields as a string.
@dataclass class Pointless: x = 0.0 y = 0.0 >>> f = Pointless() >>> f Pointless() >>> f.x 0.0 >>> f.y 0.0
Real examples might be a lot more complex than a point, and by then the cost of building a proper class with
__init__ and everything yourself isn’t such a big deal, so I can see dataclasses mostly being used for very simple struct-like containers.