> Raymond writes: > > I would like change the Context constructor API to [...] > > (list only the flags and traps that you want set). [Jim] > I assume there will still be a reasonable way to say both Yes. > "Keep the context just as it is, but turn *off* flag/trap X" > "Keep the context just as it is, but turn *on* flag/trap X" After simplifying the constructor and altering the representation to match, there was no longer much of a need to try to hide the dictionary with a bunch of methods. Since everyone already knows how to use a dictionary, the API is easier to learn without method access to traps and flags: >>> c = Context(prec=7, traps=[DivisionByZero, Overflow]) >>> c Context(prec=7, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, capitals=1, flags=[], traps=[DivisionByZero, Overflow]) >>> c.traps[Overflow] = 0 >>> c Context(prec=7, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, capitals=1, flags=[], traps=[DivisionByZero]) As a nice side benefit, eval(repr(c)) now works too. Privatizing the dictionary can still be done but I don't think it is worth adding more methods and slowing everything down with an additional layer of indirection. Raymond
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4