Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"print" magic does not work in Python 3 #2984

Closed
asmeurer opened this issue Feb 25, 2013 · 8 comments
Closed

"print" magic does not work in Python 3 #2984

asmeurer opened this issue Feb 25, 2013 · 8 comments
Milestone

Comments

@asmeurer
Copy link
Contributor

From the mailing list.

In [10]: @register_line_magic
def print(line):
    __builtin__.print(line)
   ....:

In [11]: %print 1
1

In [12]: print 1
  File "<ipython-input-12-08890221e919>", line 1
    print 1
          ^
SyntaxError: invalid syntax

But you can see that other magics work just fine without the %:

In [13]: timeit 1
100000000 loops, best of 3: 17 ns per loop
@asmeurer
Copy link
Contributor Author

On an unrelated not, when I went to look up the mailing list link, I noticed that "mailing list" on the homepage links to the dev list. Is the user list defunct, or did you just accidentally drop the user list link?

@asmeurer
Copy link
Contributor Author

In case it isn't clear, this is all in Python 3.

@takluyver
Copy link
Member

(To answer the unrelated note: We're downplaying the user mailing list, with the intention that people ask user questions on Stackoverflow or on the new Hipchat room. But it still exists, and we'll still respond there. My filters route -dev and -user to the same folder, so I usually don't even notice which list things are on)

@asmeurer
Copy link
Contributor Author

Oh OK. So would you have preferred it if I had asked that question on StackOverflow?

@takluyver
Copy link
Member

This one falls near the boundary between 'user question' and 'development
discussion'. As it happened, I think this was better suited to a mailing
list (it would have been fine on -dev, too). But it's not easy to judge
where a question belongs until you know the answer.

On 25 February 2013 23:36, Aaron Meurer notifications@github.com wrote:

Oh OK. So would you have preferred it if I had asked that question on
StackOverflow?


Reply to this email directly or view it on GitHubhttps://github.com//issues/2984#issuecomment-14083496
.

@asmeurer
Copy link
Contributor Author

OK. I get the feeling that more of the questions I am likely to ask are like that than not, if anything because I am quite willing to submit a pull request if it turns out something is a bug in IPython (and someone points me in the right direction).

Which leads me to my next question: is this something that you might want to include in IPython itself, perhaps as some option to autocall? I imagine it might be quite common among those of us who don't like autocall to still want print to work in Python 3 like it does in Python 2.

@takluyver
Copy link
Member

Hmmm...maybe. The question is how much of the old syntax we'd want to
allow. The simple version would only work for a single argument. Multiple
arguments is an obvious extension, but I think it would take several lines
more code. Then there's the magic trailing comma to suppress newline, and
the ugly 'print >>target, object' syntax. Plus, of course, it mustn't
interfere with the real print() function.

We might also prefer not to have it on by default, for the same reason that
we turned autocall off: to avoid confusing people about how Python syntax
works. Making print() a normal function means one less piece of syntax to
learn.

I think I'd suggest what we've said about quite a few feature ideas
recently: make a decent implementation, let people know about it, and see
how much popularity it gets.

On 26 February 2013 00:56, Aaron Meurer notifications@github.com wrote:

OK. I get the feeling that more of the questions I am likely to ask are
like that than not, if anything because I am quite willing to submit a pull
request if it turns out something is a bug in IPython (and someone points
me in the right direction).

Which leads me to my next question: is this something that you might want
to include in IPython itself, perhaps as some option to autocall? I imagine
it might be quite common among those of us who don't like autocall to still
want print to work in Python 3 like it does in Python 2.


Reply to this email directly or view it on GitHubhttps://github.com//issues/2984#issuecomment-14086343
.

@takluyver
Copy link
Member

I'm going to close this, as it doesn't look like it's going anywhere. It's working as designed in that automagics are only used when they're not shadowed by a normal function.

@minrk minrk added this to the no action milestone Mar 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants