[Python-Dev] Python 3 design principles

Ron Adam rrr at ronadam.com
Thu Sep 1 23:00:51 CEST 2005

Reinhold Birkenfeld wrote:
> Greg Ewing wrote:
>>Charles Cazabon wrote:
>>>Perhaps py3k could have a py2compat module.  Importing it could have the
>>>effect of (for instance) putting compile, id, and intern into the global
>>>namespace, making print an alias for writeln,
>>There's no way importing a module could add something that
>>works like the old print statement, unless some serious
>>magic is going on...
> You'd have to enclose print arguments in parentheses. Of course, the "trailing
> comma" form would be lost.
> Reinhold

The trailing comma is convenient, but I don't think it's that big of a 
deal to have two methods.

    ui.writeln()   # or ui.print()

I'm +1 on making it a method of a "user interface object".  Not just a 

I want to be able to import an interface, then communicate to it in a 
consistent way even though it may look quite different on the screen. 
Having a set of standard io methods moves in that direction I think.

    import console
    ui = console()
    ui.write("Hello World\n")
    howami = ui.input("How are you today? %s")

    import popup
    ui = popup('YesNo')              # Create a 'YesNo' popup.
    ok = ui.input('Ok to proceed?')  # Open it and wait for it.
    ok2 = ui.input('Are you sure?')  # Reopen it and reuse it.
    if ok == ok2 == 'Yes':

Some possible common methods...

    ui.write(data)    # non blocking print/output, doesn't wait
    ui.send()         # non echo write; passwords, config, etc..
    ui.input(prompt)  # output something and wait for return value
    ui.get()          # non echo wait for value, or io.next()
    ui.read()         # non blocking get

As for functions without '()'s. (Just a thought) You could use '<<' or 
'<<<' (or other symbol) as a way to move data between objects.

    ui.write <<< 'Hello World/n'      #  ui.write('Hello World/n')

    ui.writeln <<< counter            #  ui.writeln(counter.next())

    ok = ui.input <<< 'press a key:'  # ok = ui.input('press a key:')

The requirement could be that the item on the left is a callable, and 
the item on the right is a sequence or generator.


More information about the Python-Dev mailing list