4 ms·
I would like to have this as a feature in the language without having to import another "magic" module, something similar to case classes in Scala. Let me drea
by chronid 11y ago
I would like to have this as a feature in the language without having to import another "magic" module, something similar to case classes in Scala.
Let me dream :)
- 0x0dea 11y agoRuby's Struct is pretty nifty. Person = Struct.new :name, :age people = [ Person.new('Alice', 42), Person.new('Bob', 23), Person.new('Carol', 30) ] people.sort_by(&:age).map(&:name) # => ["Bob", "Carol", "Alice"]
- aw3c2 11y agoIt's hardly a magic module, collections is part of the Python standard library. https://docs.python.org/3/library/collections.html https://docs.python.org/3/library/collections.html
- maxerickson 11y agoIt's kind of magical: https://hg.python.org/cpython/file/tip/Lib/collections/__init__.py#l284 https://hg.python.org/cpython/file/tip/Lib/collections/__ini...
- robohamburger 11y agoIf you look at the code for it you will weep. If only python had hygienic macros. I would settle for better namedtuple syntax though.
- rch 11y agoI always thought it was left as-is to further discussions about how it should be, without having to overcome a crowd of people claiming it's good enough already.