PEP 259: Omit printing newline after newline

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu Jun 14 03:32:14 EDT 2001


Tue, 12 Jun 2001 15:56:26 +0200, Alex Martelli <aleaxit at yahoo.com> pisze:

> But the differences between your ideas and mine are basically
> syntax-sugar.

Keep print and softspace as is for compatibility. Have a function
similar to this:

    def get_and_del(dict, key, default = None):
        if dict.has_key(key):
            value = dict[key]
            del dict[key]
            return value
        else:
            return default

    def output(*args, **kwargs):
        file = get_and_del(kwargs, 'file', sys.stdout)
        end = get_and_del(kwargs, 'end', '\n')
        sep = get_and_del(kwargs, 'sep', ' ')
        if kwargs: raise TypeError # TODO: build a message
        first = 1
        for arg in args:
            if not first: file.write(sep)
            file.write(str(arg))
            first = 0
        file.write(end)

Yes, I'm throwing away the idea of softspace state preserved across
output calls. Life will be simpler in overall.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list