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.
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?
But really, I just don't like how http/ftp/similar protocols were designed in the first place. They're mixing binary and text in the same stream. That's ugly and when you have strict rules about text encoding in your language, the implementation also turns out ugly - what a surprise :)
Explicit is better than implicit.
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") def print_wrapper(*args, **kwargs)
outfile = None
print_stmt = "print "
if 'file' in kwargs:
outfile = open(kwargs['file'], 'a')
print_stmt += '>>outfile '
print_stmt += ", ".join(*args)
if 'end' in kwargs and kwargs['end'] == ' ':
print_stmt += ','
eval(print_stmt)
if outfile is not None: outfile.close()
sep and other end values for anything other than ' ' would not be possible.http://docs.python.org/2.6/reference/simple_stmts.html#the-p...