> # constants
> 
> EOH  = b'\r'[0]
> CHAR = b'C'[0]
> DATE = b'D'[0]
> FLOAT = b'F'[0]
> INT = b'I'[0]
> LOGICAL = b'L'[0]
> MEMO = b'M'[0]
> NUMBER = b'N'[0]
> 
> This is not beautiful code.

In this case, I think the intent would be better captured with

def ASCII(c):
    return c.encode('ascii')

EOH     = ASCII('\r') # 0D
CHAR    = ASCII('C')  # 43
DATE    = ASCII('D')  # 44
FLOAT   = ASCII('F')  # 46
INT     = ASCII('I')  # 49
LOGICAL = ASCII('L')  # 4C
MEMO    = ASCII('M')  # 4D
NUMBER  = ASCII('N')  # 4E

This expresses the intent that a) these are really byte values,
not characters, and b) the specific choice of byte values was motivated
by ASCII.

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to