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 Newsgroups: comp.lang.python Subject: Re: Is this a good way to work with init and exception Date: Sun, 19 Jul 2015 21:10:24 +0200 Organization: Decebal Computing Lines: 37 Message-ID: <87io9gx8tb.fsf@Equus.decebal.nl> References: <87380kzb8b.fsf@Equus.decebal.nl> <87r3o4xfhx.fsf@Equus.decebal.nl> 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="5904"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18n0x8sjyEnWK91AUeRDyQZtUPkBiiOooc=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:se5JHcFJFH5es+NnZbhUz+OxFgE= sha1:n3DtOiH5+6yhB94HIYKUHavWAUc= X-Homepage: http://www.decebal.nl/ Xref: csiph.com comp.lang.python:94153 On Sunday 19 Jul 2015 20:11 CEST, Chris Angelico wrote: >>> Parameterized imports aren't possible, correct. What I'd look at >>> here is a more explicit instantiation. Something like: >>> >>> import twitterDecebal >>> twitter = twitterDecebal.twitterDecebal(5, 60) >> >> I worked with default values, because I thought that would be a >> good idea. I should remove the default values? > > No no, the default values are good. I just gave an example that > didn't use them, as that's where you actually need the call. If > you're always going to use the defaults, well, there's not a lot of > point having the function. But if you often use the defaults (or one > of them), and occasionally override it, then what you have is good > design. In my case I think the defaults are good. (But I do not know how I will use the function in the future. ;-) ) But I want to share it on GitHub and it would be possible that for someone else my defaults are not correct and then it is nice when they can be overridden. > 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? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof