Oops, never mind: "It is not possible to create truly immutable Python objects. However, by passing frozen=True to the dataclass() decorator you can emulate immutability. In that case, dataclasses will add __setattr__() and __delattr__() methods to the class. These methods will raise a FrozenInstanceError when invoked."
Python 3.7 released
41–50 of 56 posts
Re: Python 3.7 released
#42Earlier quoted context omitted.
I don't understand the inconvenience. Isn't it just adding `attrs` to requirements.txt once for the whole project, and then you get more features ever after?
That assumes you have a project. Some people write scripts in Python to use in the shell.
Re: Python 3.7 released
#43Earlier quoted context omitted.
Is the breakpoint builtin analogous to binding.pry in Ruby? If so...that is amazing!
Yes, it's quite similar. It's not THAT amazing though since it's just a convenience function over pdb.set_trace() which has been in the Python standard library for a very long time (2 decades or more).
Re: Python 3.7 released
#44Hey, does anyone know where to find information about how python's releases are structured? For example, 3.6 exists and 3.7 is released. Without looking at the release details, should I be upgrading? Should I assume that it will break stuff, or assume that it won't, or should I make no assumptions? Etc...
Re: Python 3.7 released
#45Earlier quoted context omitted.
I'm not a python dev, but isn't less dependencies generally better? Or is attrs in Python natively already?
Attrs isn't in python natively. Not sure why less dependencies would be better though.
There are some exceptions. Like I really don't want form building to be in the standard library, and I don't want to write it myself.
It is nice when your package manager only takes a short manage to fetch and build though, and you can have more confidence that any mistakes will be your own (under your control) rather than someone else's.
Re: Python 3.7 released
#46Earlier quoted context omitted.
Data classes look cool. Maybe replacing named tuples in my future code? They always felt awkward to work with. Will data classes save a ton of memory since you’re specifying the types?
Data classes are just regular classes with some methods generated for you. For now you still have to specify __slots__ manually to save memory.
Re: Python 3.7 released
#47Earlier quoted context omitted.
That assumes you have a project. Some people write scripts in Python to use in the shell.
venvs work fine in the shell. See pipsi for automatic creation/management of the necessary venvs.
If the simple program depends only on core Python, then they don't also have to say "oh, and also install ...".
Re: Python 3.7 released
#48Earlier quoted context omitted.
Data classes are just regular classes with some methods generated for you. For now you still have to specify __slots__ manually to save memory.
So what’s the point of specifying the types?
These are called "type hints" because they are not enforced by the Python runtime.
Re: Python 3.7 released
#49Hey, does anyone know where to find information about how python's releases are structured? For example, 3.6 exists and 3.7 is released. Without looking at the release details, should I be upgrading? Should I assume that it will break stuff, or assume that it won't, or should I make no assumptions? Etc...
3.6 to 3.7 is a minor release, only supposed to have new features, and not break existing code. Obviously, the probability of bugs is higher than in a micro release (e.g. 3.6.2 to 3.6.3), which only contains bugfixes. But I can't remember code from 2.6 breaking on 2.7, nor code from 3.5 breaking on 3.6.
Minor release may break code, though it should be rare. Python 3.7 reserves 'async' and 'await' as keywords so assignments like "async = 3", which worked in 3.6, will now fail.
Python has a deprecation warning system which can detect cases like this, but it must be enabled:
% python -Wall
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> async = 3
:1: DeprecationWarning: 'async' and 'await' will become
reserved keywords in Python 3.7Re: Python 3.7 released
#50Notable parts of this release (IMO): * Data classes ( https://docs.python.org/3.7/library/dataclasses.html ) * New breakpoint() builtin ( https://docs.python.org/3.7/library/functions.html#breakpoin... ) * Dictionaries preserve insertion order. (Implemented in 3.6, but now is part of the official spec.)