Python Release Python 3.5.0b3
Python 3.5 adds support for the '@' operator, designed for use in matrix multiplication. ("A*B" is element-wise multiplication, and "A@B" is matrix multiplication.)
There's nothing in the implementation which restricts is to matrix multiplication. While there are good reasons to be restrained with operator overloading, I have an idea of a domain-specific use in XML.
XML's XPath defines '@abc' as a way to select an attribute from an element tag. Right now if I want to get all elements named "SEGMENT" and display the "title" and "length" attributes, I might do:
What about allowing 'x@"y"' as a shorthand for 'x.attrib["y"]', so the last line becomes:from xml.etree import ElementTree as ET etree = ElementTree.parse("example.xml") for segment in tree.find("SEGMENT"): print(segment.attrib["title"], segment.attrib["length"])
? Is that too much magic in order to get the domain appropriate syntax?print(segment@"title", segment@"length")