4

Preamble: One can import print function in python2.7.

Is there a way to import the above-mentioned @ operator in python3.4?

If not: is there fundamental point why it is impossible, or it is just too much work?

Dima Lituiev
  • 12,544
  • 10
  • 41
  • 58
  • 1
    This is not a dup, common! I am not asking what it does, and it is not answered there how to import it. – Dima Lituiev Feb 11 '16 at 07:36
  • Then you should *really* make it more clear what you mean in your question. It’s totally unclear what you are referring to, especially since you are apparently referring to the matrix multiplication operator which is not available in 3.4, so “import from python 3.4” does not make any sense. – poke Feb 11 '16 at 07:39
  • Well, the question is clear: not "what it does" but how to import it. Analogously, `print` function is also not a function in Python2, but one can import it with a `__future__`. My lay knowledge does not allow me to see what is the root difference. But isn't the scope of this site to ask questions? – Dima Lituiev Feb 11 '16 at 07:41
  • 3
    See it like this: The `@` to me is primarily used for decorators, since you mention in *no way* matrix multiplication or that this is a feature from Python 3.5, I default to assuming that you are referring to the decorator symbol. Your question is unclear. I asked you to fix it, so please do so. – poke Feb 11 '16 at 07:44
  • 2
    Please don't get into the habit of expecting every new feature to be backported to older versions. It's a new version for a reason. Just be happy when they do. – Jeff Mercado Feb 11 '16 at 07:45
  • @ poke : please check that I did label the question as python3.5 and python3.4 – Dima Lituiev Feb 11 '16 at 07:46

1 Answers1

4

As stated in PEP-0465, the matrix multiplication operators (and corresponding magic methods __matmul__, __rmatmul__ and __imatmul__) are introduced into the language at version 3.5. It is not an operator in python3.4 (via __future__ or otherwise), so you're out of luck until you update your python version.

mgilson
  • 300,191
  • 65
  • 633
  • 696
  • Is there a fundamental reason that it cannot be imported with `__future__` like `print` function, or it is just has not been implemented? – Dima Lituiev Feb 11 '16 at 17:47
  • 2
    @DimaLituiev -- The simple answer is that it hasn't been implemented. My feeling is that most of the time `__future__` is used for things that would break when moving the code from a lower version to a higher version. e.g. `unicode_literals`, `print_function`, `division` all could cause working code to break when going from python2.7 to 3.0 if those future imports weren't enabled. It isn't usually meant to make features available sooner than scheduled (that would take magic :-) – mgilson Feb 11 '16 at 19:39