On Fri, Oct 07, 2005, Kent Johnson wrote:
>Pierre Barbier de Reuille wrote:
>> (never import
>> a module in a small function likely to be called in an inner-loop !)
>
>That's good advice, but I would say "in a *time-critical* inner-loop". After
>the first import, importing a module is fast, it is
Pierre Barbier de Reuille wrote:
> (never import
> a module in a small function likely to be called in an inner-loop !)
That's good advice, but I would say "in a *time-critical* inner-loop". After
the first import, importing a module is fast, it is just a few dictionary
lookups (looking up the m
Kent Johnson a écrit :
> Daniel Watkins wrote:
>
>[...]
>
>>However, someone (I don't recall who) said that there were occasions
>>when it would be appropriate to import modules the former way. I was
>>just wondering under what circumstances importing should be done this
>>way?
>
>
> That was
That was me using the import within the class. I only did it due to my
ignorance. I am not advanced enough to use it like that and know what I am
doing, so as suggested I just moved all of my imports to the top.
Python Newbie.
On Thursday 06 October 2005 08:21 pm, Kent Johnson wrote:
> Danie
Daniel Watkins wrote:
> Recently, there has been an example of someone importing modules within
> a class definition. eg:
>
> class Exemplar:
> import re
> ...use re...
>
> It seems obvious to me that this is incorrect, though more through
> training than actual observation on my part
Recently, there has been an example of someone importing modules within
a class definition. eg:
class Exemplar:
import re
...use re...
It seems obvious to me that this is incorrect, though more through
training than actual observation on my part, and it should be:
import re
clas