5 ms·
print chevron in python2 is super awesome print 'hello' f = open(file, 'w') print>>f, 'world' It just feels more "powerful" than Py3k's print
by est 9y ago
print chevron in python2 is super awesome
print 'hello'
f = open(file, 'w')
print>>f, 'world'
It just feels more "powerful" than Py3k's
print(somestring, file=someopenfile)
- nhumrich 9y ago> More powerful But less obvious and readable, which is anti pythonic. If you want "power" over readability, there is ruby/perl.
- masklinn 9y ago> print chevron in python2 is super awesome Print chevron is super awful, it's unreadable, hard to remember and difficult to search for. The print function was a welcome improvement: it's not a statement (so can be used in a lambda, no need to fall back to sys.stdout.write), it doesn't use weird-ass syntax to redirect or suppress the final newline and it's more extensible (e.g. "end" or "flush" kwargs would have been… challenging to add to the keyword version)
- RodericDay 9y agoIf you want power you can fprint = lambda string: print(string, file=somefile) and use fprint all over the place that little chevron trick is bad imo
- majewsky 9y agoYou'd like Perl: open my $file, '>', 'hello'; print{$file} "Hello";