Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94169
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.python |
| Subject | Re: Is this a good way to work with init and exception |
| Date | Mon, 20 Jul 2015 00:19:49 +0200 |
| Organization | Decebal Computing |
| Lines | 36 |
| Message-ID | <87615fyem2.fsf@Equus.decebal.nl> (permalink) |
| References | <87380kzb8b.fsf@Equus.decebal.nl> <mailman.711.1437310769.3674.python-list@python.org> <87r3o4xfhx.fsf@Equus.decebal.nl> <mailman.733.1437329515.3674.python-list@python.org> <87io9gx8tb.fsf@Equus.decebal.nl> <mailman.743.1437340103.3674.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | mx02.eternal-september.org; posting-host="528adfd6ad074c92fdc6a7f8fb9e23d8"; logging-data="18070"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vZ+7saZdtRqQ9a92yAAPqH8aa6IyXwGw=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| Cancel-Lock | sha1:ugBAAZ6BbU9pumzWSNf3lea7n9U= sha1:1L6Jea2bM0MJNi0KnJoZrHGmi6Q= |
| X-Homepage | http://www.decebal.nl/ |
| Xref | csiph.com comp.lang.python:94169 |
Show key headers only | View raw
On Sunday 19 Jul 2015 23:08 CEST, Chris Angelico wrote:
> On Mon, Jul 20, 2015 at 5:10 AM, Cecil Westerhof <Cecil@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is this a good way to work with init and exception Cecil Westerhof <Cecil@decebal.nl> - 2015-07-19 12:35 +0200
Re: Is this a good way to work with init and exception Chris Angelico <rosuav@gmail.com> - 2015-07-19 22:59 +1000
Re: Is this a good way to work with init and exception Cecil Westerhof <Cecil@decebal.nl> - 2015-07-19 18:46 +0200
Re: Is this a good way to work with init and exception Chris Angelico <rosuav@gmail.com> - 2015-07-20 04:11 +1000
Re: Is this a good way to work with init and exception Cecil Westerhof <Cecil@decebal.nl> - 2015-07-19 21:10 +0200
Re: Is this a good way to work with init and exception Chris Angelico <rosuav@gmail.com> - 2015-07-20 07:08 +1000
Re: Is this a good way to work with init and exception Cecil Westerhof <Cecil@decebal.nl> - 2015-07-20 00:19 +0200
Re: Is this a good way to work with init and exception Chris Angelico <rosuav@gmail.com> - 2015-07-20 08:40 +1000
Re: Is this a good way to work with init and exception Cecil Westerhof <Cecil@decebal.nl> - 2015-07-20 01:27 +0200
csiph-web