On Sunday 19 Jul 2015 23:08 CEST, Chris Angelico wrote: > On Mon, Jul 20, 2015 at 5:10 AM, Cecil Westerhof <ce...@decebal.nl> wrote: >>> I think it's fine, then. As long as it makes absolutely no sense >>> to have two separately-initialized twitter connections, and as >>> long as it's okay for two separate modules to both import this and >>> to then share state, then what you have is fine. >> >> I do not see myself doing this, but I like to know ‘everything’. >> When I have a program with two different modules that both import >> this, they would get in each-others way? How? > > If two modules import the same module, they get two references to > that same module, not two separate module instances. Since your > parameters appear only to affect the initialization itself, this is > not likely to be a problem (it's not like you'll need to > authenticate with two different sets of credentials, for instance), > but it will mean that the second one will import an > already-initialized module. That's why I suggested the try_init > function which would quietly return an immediate success if the > module had already been initialized. But if this isn't going to be > an issue, then your code's fine.
Good to know. I would expect two different instances. I agree that in my case it would not be a problem, but I put the code on GitHub: https://github.com/CecilWesterhof/PythonLibrary/blob/master/twitterDecebal.py I should do my best to circumvent nasty surprises for users of the code. Someone else could use several Twitter accounts at the same time. Is there a way to do this? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list