-
-
Save tswicegood/479549 to your computer and use it in GitHub Desktop.
| class QuickOutputter(object): | |
| def __lt__(self, msg): | |
| print msg | |
| return self | |
| o = QuickOutputter() | |
| o < "Some random message" | |
| o < "Some other message" |
if this is in any way better than the regular print statement, your example does not make it obvious. It's more like you're forcing C++ cin/cout onto python, for no good reason. But if that's what you want, why not use __lshift__?
o < "neat"
your way of printing doesn't support redirection the print statement has
print >>sys.stderr, "Some random message"
generally, i think this only makes the code harder to read, rather then making it "more concise"
@superbobry: yup - not trying to mimic the print >>sys.std* syntax. The idea would be that you call log.set_default_output for a printer, then do o.stderr < "something" or log.warn < "omg!".
Agreed - concise doesn't always make more readable - just trying to see what the thoughts where out there on this style.
Playing around with an idea for making generating output quicker/more concise in Python. Thoughts?