[Python-Dev] Replacement for print in Python 3.0

Steven Bethard steven.bethard at gmail.com
Fri Sep 2 17:12:07 CEST 2005


skip at pobox.com wrote:
> the print statement is more convenient.  Maybe a print builtin wouldn't kill
> me.  In that case I'd want both output redirection and newline suppression
> though.  I guess you'd have to use a keyword arg to specify an alternate
> stream.  Perhaps if the last non-keyword argument was exactly one space, the
> newline could be suppressed, e.g.:
> 
>     print("foo", "bar", "baz", " ", stream=sys.stderr)

I think, instead, the stream API should grow a "print" method (or
whatever it ends up getting called).  The example would then look
like:

    sys.stderr.print("foo", "bar", "baz", " ")

It would probably be nice to provide a FileMixin object too. 
(Actually, this would be nice now, so that if I implement read(), I
don't have to implement readline(), readlines(), etc.)  The FileMixin
object would make it easy for user-defined file-like objects to also
support the print() method:

    class FileMixin(object):
        """Adds the file methods.
    
        Requires:
            read()
            write()
    
        Adds:
            __iter__()
            next()
            readline()
            readlines()
            writelines()
            print() # or whatever it gets called
        """
        ...


STeVe
-- 
You can wordify anything if you just verb it.
        --- Bucky Katt, Get Fuzzy


More information about the Python-Dev mailing list