Steven D'Aprano wrote:

<snip>


def SomeClass(object):
    _gridsize = 0.8


The leading underscore tells callers that they change the attribute at their own risk.

An even more Pythonic approach is to write your class that makes no assumptions about gridsize, and thus explicitly supports any reasonable grid size.

The parent class, makes no assumption about grid-size, and I have put
a great deal of functionality there.

The methods of the derived class that depend on a gridsize of 8mm are
mostly concerned with standard LaTeX glyphs (from a specific font)
at standard LaTeX sizes.

I am fitting a small subset of them into my grid by hand, in a
way that I don't think could be easily automated even if I use the metric information. Not impossible, just too much hastle.

The general rationale of the project is 'pen-and-ink' algorithms
for arithmetic, on quadrille paper. It is to create figures that
will be imported into LaTeX later.

(By the way, it is perfectly easy to re-scale the figure after
the digits, carry-figures, and other glyphs are placed. So long
as you don't mind the font-size within the figure to
be out of kilter with the font-size of the main run of
LaTeX text.)

I hope this explains why I have decided on a Read-only attribute, the
first one ever, apart from a quick try-out when I started with Python.
And that was when Guido was still in Amsterdam.


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to