469,945 Members | 1,910 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

any plans to make pprint() a builtin?

Just wondering if this will ever happen, maybe in 3.0 when print becomes
a function too? It would be a nice option to have it available without
importing it every time, but maybe making it a builtin violates some
kind of pythonic ideal?
May 14 '06 #1
9 1322
John Salerno wrote:
Just wondering if this will ever happen, maybe in 3.0 when print becomes
a function too? It would be a nice option to have it available without
importing it every time, but maybe making it a builtin violates some
kind of pythonic ideal?


There are so many things which *could* be builtins, and it really is better
not to pollute the global namespace with more than absolutely necessary.

Personally I'd just like to see 'python' a builtin shorthand for importing
a name you aren't going to use much
e.g.

python.pprint.pprint(x)
May 14 '06 #2

Duncan Booth wrote:
John Salerno wrote:
Just wondering if this will ever happen, maybe in 3.0 when print becomes
a function too? It would be a nice option to have it available without
importing it every time, but maybe making it a builtin violates some
kind of pythonic ideal?


There are so many things which *could* be builtins, and it really is better
not to pollute the global namespace with more than absolutely necessary.

Personally I'd just like to see 'python' a builtin shorthand for importing
a name you aren't going to use much
e.g.

python.pprint.pprint(x)


I think that's what the py.lib people have done with
their py.std module:

http://codespeak.net/py/current/doc/...he-py-std-hook

(At least, it looks like it; I've never used it myself).

TJG

May 14 '06 #3
Duncan Booth wrote:
Personally I'd just like to see 'python' a builtin shorthand for importing
a name you aren't going to use much
e.g.

python.pprint.pprint(x)


Would you settle for
import py
py.std.pprint.pprint(x) ?

http://codespeak.net/py/current/doc/...he-py-std-hook

Kent
May 14 '06 #4
Tim Golden wrote:
Duncan Booth wrote:
Personally I'd just like to see 'python' a builtin shorthand for
importing a name you aren't going to use much
e.g.

python.pprint.pprint(x)


I think that's what the py.lib people have done with
their py.std module:

http://codespeak.net/py/current/doc/...he-py-std-hook

(At least, it looks like it; I've never used it myself).

Yes, I know it is easy enough to implement. I'm just suggesting that it
might be useful as a builtin. After all, if I have to import something to
use it I'd mostly just do the imports I needed instead.
May 14 '06 #5
Kent Johnson wrote:
Duncan Booth wrote:
Personally I'd just like to see 'python' a builtin shorthand for importing
a name you aren't going to use much
e.g.

python.pprint.pprint(x)


Would you settle for
import py
py.std.pprint.pprint(x) ?

http://codespeak.net/py/current/doc/...he-py-std-hook

Kent


Interesting, but that could start to get a little too messy I think. I'd
rather just have the 'authentic' code in my program (i.e. pprint.pprint)
instead of the py.std prefix as well.

It's a good point not to pollute the builtin namespace with too much, so
I think I'd rather just import pprint when needed instead of using the
py.std call.
May 14 '06 #6
pjw
It has been proposed to replace the current print statement with a
print function for python 3.0.
http://www.python.org/dev/peps/pep-3100/
From BDFL state of the python union:

"
print x, y, x becomes print(x, y, z)
print >>f, x, y, z becomes print(x, y, z, file=f)
"

May 14 '06 #7
Ant
Considering that the current:

import pprint
pprint.pprint(x)

is hardly lengthy, I can't see how either of the alternatives proposed
are any better.
python.pprint.pprint(x)
6 characters shorter, but considerably more keystrokes if you are using
pprint more than once. Is it worth adding the 'python' builtin to save
an import statement?
import py
py.std.pprint.pprint(x)


Longer, messy, and what's the actual point? Wouldn't:

import pprint as pp
pp.pprint(x)

be better, standard *and* shorter?

May 15 '06 #8
Ant wrote:
Considering that the current:

import pprint
pprint.pprint(x)

is hardly lengthy, I can't see how either of the alternatives proposed
are any better.
python.pprint.pprint(x)


6 characters shorter, but considerably more keystrokes if you are using
pprint more than once. Is it worth adding the 'python' builtin to save
an import statement?
import py
py.std.pprint.pprint(x)


Longer, messy, and what's the actual point? Wouldn't:

import pprint as pp
pp.pprint(x)

be better, standard *and* shorter?


I guess the idea is that you can use the import py statement to access
many other modules as well, without importing them all separately.
May 15 '06 #9
Ant wrote:
Longer, messy, and what's the actual point? Wouldn't:

import pprint as pp
pp.pprint(x)

be better, standard *and* shorter?


why not just:

from pprint import pprint
pprint (x)

No need to modify the interpreter when you can pollute the global namespace
yourself just as easily.

--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
May 17 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

38 posts views Thread by Anthony Baxter | last post: by
2 posts views Thread by BJörn Lindqvist | last post: by
7 posts views Thread by Lowell Kirsh | last post: by
10 posts views Thread by Thomas R. Hummel | last post: by
6 posts views Thread by Brian L. Troutwine | last post: by
reply views Thread by Paddy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.