On 12 September 2014 12:11, David Crisp <[email protected]> wrote:

> How do I read the configuration opbject from within test7 when it is
> called from test6?    I dont really want to call it from every module that
> needs it as there is meant to be some write back functionality happening to
> a configuration file and if I try and do that from more than one entry
> point I will end up writing a corrupted config back.  So A single entry
> point for configuration would be nice..
> ​​
>
>
​What makes you think it will be corrupted?  Have you tried it?​


​There are no globals in python, really, besides the module system (every
import of module 'x' will give the same object(s)), but you can even work
around that.



> ​​
>
> Or am I doing it wrong?
>
> Whats the best way of doing what I want to do.
>
> Again, if I havent asked the right questions, please guide and I will try
> and provide the information you need.
>
>
>
​Why not:​

test8.py
class ClientConfiguration:
    def __init__(self):
        self.input = "excel"
        self.output = "sql"

configuration = ClientConfiguration()

​then there's one configuration object that everyone can use (or not use,
if they like):

from test8 import configuration​

Current best practice, as documented by
https://glyph.twistedmatrix.com/2007/07/functional-functions-and-python.html
is to have clean places to override the usage of the module, that's the
'best way' really.


-- 
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered under
copyright law.  You absolutely MAY reproduce any part of it in accordance
with the copyright law of the nation you are reading this in.  Any attempt
to DENY YOU THOSE RIGHTS would be illegal without prior contractual
agreement.
_______________________________________________
melbourne-pug mailing list
[email protected]
https://mail.python.org/mailman/listinfo/melbourne-pug

Reply via email to