Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #92878

Re: instance as module

From Robin Becker <robin@reportlab.com>
Subject Re: instance as module
Date 2015-06-19 12:07 +0100
References <5583E0EA.2090309@chamonix.reportlab.co.uk> <mm0qig$a4d$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.631.1434712068.13271.python-list@python.org> (permalink)

Show all headers | View raw


On 19/06/2015 11:23, Peter Otten wrote:
> Robin Becker wrote:
.........
>
> Do I understand this correctly? You got bitten by a complex setup and now
> you are hoping to improve the situation by making it even more complex?
>
> How about reordering initialisation in such a way that the user defaults are
> the last thing being set?
>

I don't think re-ordering is feasible or desirable.

For the specific case of the canvas_basefontname I don't actually need to do 
anything specific since it is just a string, however, before it can be used in 
action support has to be provided ie I must register the font used. I could just 
make the few usages of this value check for callability at use time, but that 
would scatter the problem; if one default is special why not all.

Effectively the defaults setup is not complex enough to allow use of itself; 
that must be a fairly common problem.

Probably the correct thing to do was always to use an object to hold the 
defaults. For a long time a module satisfied, then people wanted long running 
processes, reset etc etc now they want to define things ahead of time (probably 
for good reason).

I could just move the rl_config module into reportlab's __init__ as an object, 
but I'm almost sure that would break someone's

    from reportlab.rl_config import *

which although deprecated is still allowed. Defining a module like object seems 
a reasonable way out if I really need it.
--
Robin Becker

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: instance as module Robin Becker <robin@reportlab.com> - 2015-06-19 12:07 +0100

csiph-web