by dec0dedab0de · 12y ago · 0 comments
Edit: I really just like the statement for the interpreter, and IPython Notebook. To me the statement syntax feels less like programming, and more like using a computer.
print(<SOMETHING I'M TRYING TO DEBUG>) or
into a lambda has been useful on multiple occasions.Edit: now that I thought about it - since you're able to decode the bytes you're using, it means you are operating on text - why not convert it then?
print 'hi', # prints hi (no extra space in the end)
print 'hi',; print 'hi' # prints hi hi
I personally dislike this syntax because I don't find this natural. Wouldn't it make more sense to print an extra space after the print statement with trailing comma instead of before the next print statement?
print 'hi',
do_something()
print 'there'
and print 'hi', 'there'
both yield hi there
(Assuming do_something() doesn't call print itself) pprint = functools.partial(print, end=' ')
pprint('hi')
do_something()
print('there')
print('hi', 'there', sep=' ')
I appreciate the fine grained control, and the ability to do things like `functools.partial` on it. fprint = functools.partial(print, file='/var/log/foo.log')
fprint("I'm writing to a file!")
fprint("So am I")