Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

@ is a binary operator with the same precedence and left-right associativity as * , /, and //. It's hard to think of places where @ could be abused where those other three couldn't equally well be a source of abuse. There hasn't been much abuse of those other three, so there likely won't be much abuse of @.

I think the only real (ab)use of @ is to echo its use in another language. For example, @ means something in XPath, so X@Y could be used as a short-hand for X.attrib[Y] in an ElementTree-like API:

   tree = load_xml_tree(...)
   for node in tree.select("//item[@price > 2*@discount]"):
       print(node @ "price", node @ "discount")


The only other hypothetical I can think of right now is evaluation shorthand. Something like an expression group represented by a class which may be subject to arithmetic using standard operators. @ could be used as shorthand for a .evaluate_at() method but it's probably not that useful anyway.

Maybe passing objects with 'argument @ resource' would be interesting...


In Python 3.4's pathlib, you can concatenate two paths by dividing one path with the other.

I guess you could torture @ for similar purposes in an email library or something.


Just got to say, dirtiness aside, overloading / to be path.join is actually a godsend for readability working with path heavy code.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: