[Python-Dev] Replacement for print in Python 3.0 (original) (raw)
Eli Stevens (WG.c) listsub at wickedgrey.com
Thu Sep 1 23:56:40 CEST 2005
- Previous message: [Python-Dev] Replacement for print in Python 3.0
- Next message: [Python-Dev] Replacement for print in Python 3.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
It seems to me that, as long as write() and writeln() were built-ins taking multiple args, teaching a beginner to use
writeln("The answer is: ", 4+4) is perfectly clear (and might be a gentle introduction to function calls as well).
Hello,
I'm Eli Stevens, and this is my first real post to python-dev (bio below). I've got two ideas relating to formatting that I'd thought I'd air out.
The first is to add a separator argument to write[ln]:
def w(*args, **kwargs): ... nextsep = "" ... sep = kwargs.get("sep","") ... output = "" ... for item in args: ... output += nextsep ... nextsep = sep ... output += str(item) ... print output ... w("foo", "bar") foobar w("foo", "bar", sep=" ") foo bar w("foo", "bar", sep="\n") foo bar w("foo", "bar", sep="\t") foo bar
I'd have found this handy just this week at work. Not a huge deal to work around, obviously, but it would have been handy.
The second is something along the lines of:
f = 3.14159 str(f) '3.14159' str(f, ".2") # calls f.str(".2") which can do whatever it wants '3.14' str(f, "%.2") # the percent is ignored? '3.14'
Thoughts?
Eli Stevens
Bio:
Geek since I saw my first computer in 5th grade at school. Programmed (poorly) from middle school through high school. Graduated from Univ. of Missouri, Columbia with a bachelors in CS. C++ fan at the time. Worked a startup in the valley for 3 years, heavily in Java. Mildly disliked it (from the start), found python, loved it, got acquired by Cisco, but still doing Java. I cashed out. Now at Yahoo doing Python almost full time. Happy. No accepted patches to an open source project (yet). Prefer the MIT license for my code (assuming any of it gets to a point where I can release it :).
Whew. ;)
- Previous message: [Python-Dev] Replacement for print in Python 3.0
- Next message: [Python-Dev] Replacement for print in Python 3.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]