__repr__ policy problem: should module be prefixed to output?
Per Kraulis
per at sbc.su.se
Fri Dec 15 10:36:13 EST 2000
More information about the Python-list mailing list
Fri Dec 15 10:36:13 EST 2000
- Previous message (by thread): Accessing serial port on windows
- Next message (by thread): __repr__ policy problem: should module be prefixed to output?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Having just released a Python extension module crng (http://www.sbc.su.se/~per/crng/), I have received some constructive criticism, one issue being save/restore functionality. My plan is to define a __repr__ for each type in the module. However, I have realized that there is a policy problem. Should __repr__ add the module name as prefix to the output string, or not? Or is there some other solution? Alternative 1: >>> from crng import * >>> r=ParkMiller() >>> repr(r) crng.ParkMiller(seed=314159265) Alternative 2: >>> from crng import * >>> r=ParkMiller() >>> repr(r) ParkMiller(seed=314159265) The problem is that Alt 1 is appropriate in the context of "import crng", while Alt 2 is better when having done "from crng import *". A suggestion is that there should be a settable module variable that controls this. Feels like a kludge to me... Any ideas which way to go? -- Per J. Kraulis, Ph.D. per at sbc.su.se Stockholm Bioinformatics Center (SBC) http://www.sbc.su.se/~per Dept. Biochemistry, Stockholm University phone +46 (0)8 - 674 78 17 SE-106 91 Stockholm, SWEDEN fax +46 (0)8 - 15 80 57
- Previous message (by thread): Accessing serial port on windows
- Next message (by thread): __repr__ policy problem: should module be prefixed to output?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list