I've long wanted to make the print statement able to handle alternative output files in a more convenient syntax. Yes you can rebind sys.stdout, but that is often very clumsy to get right in the face of exceptions. All the talk about extra operators has made me giddy (no, not geddy :) so my proposal is to allow `@' after the print keyword using syntax such as: print @ sys.stderr, 'hello' The thing between the @ and the , must be an expression yeilding an object with a write() method, otherwise you'd get a runtime exception (probably TypeError). Thus, these two are equivalent: print @ sys.stdout, 'wassup?' print 'wassup?' It makes it quite convenient to do things like: f = open('log, 'w') print @ f, 'starting' do_something_that_expects_to_print_to_stdout() print @ f, 'ending' etc., etc. I started hacking on the grammar to play with this, but haven't gotten very far, and I'm way too tired to continue tonight. I'd continue though if there's positive feedback. Thoughts? -Barry
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4