Re: [Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))

2005-10-14 Thread Greg Ewing
Phillip J. Eby wrote: I meant that just changing its class is a mutation, and since immutables can be shared or cached, that could lead to problems. So I do think it's a reasonable implementation limit to disallow changing the __class__ of an immutable. That's a fair point. Although I

Re: [Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))

2005-10-13 Thread Michael Hudson
Greg Ewing [EMAIL PROTECTED] writes: Phillip J. Eby wrote: At 01:47 PM 10/13/2005 +1300, Greg Ewing wrote: I'm trying to change the __class__ of a newly-imported module to a subclass of types.ModuleType It happened in Python 2.3, actually. Is there a discussion anywhere about the

Re: [Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))

2005-10-13 Thread Phillip J. Eby
At 04:02 PM 10/13/2005 +0100, Michael Hudson wrote: Greg Ewing [EMAIL PROTECTED] writes: Phillip J. Eby wrote: At 01:47 PM 10/13/2005 +1300, Greg Ewing wrote: I'm trying to change the __class__ of a newly-imported module to a subclass of types.ModuleType It happened in Python 2.3,

Re: [Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))

2005-10-13 Thread Eyal Lotem
Why not lazily import modules by importing them when they are needed (i.e inside functions), and not in the top-level module scope? On 10/13/05, Phillip J. Eby [EMAIL PROTECTED] wrote: At 04:02 PM 10/13/2005 +0100, Michael Hudson wrote: Greg Ewing [EMAIL PROTECTED] writes: Phillip J. Eby

Re: [Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))

2005-10-13 Thread Josiah Carlson
Eyal Lotem [EMAIL PROTECTED] wrote: Why not lazily import modules by importing them when they are needed (i.e inside functions), and not in the top-level module scope? Because then it wouldn't be automatic. The earlier portion of this discussion came from... import module #module.foo

Re: [Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))

2005-10-13 Thread Greg Ewing
Josiah Carlson wrote: The earlier portion of this discussion came from... import module #module.foo does not reference a module module.foo #now module.foo references a module Or more generally, module.foo now references *something*, not necessarily a module. (In my use

[Python-Dev] Assignment to __class__ of module? (Autoloading? (Making Queue.Queue easier to use))

2005-10-12 Thread Greg Ewing
I just tried to implement an autoloader using a technique I'm sure I used in an earlier Python version, but it no longer seems to be allowed. I'm trying to change the __class__ of a newly-imported module to a subclass of types.ModuleType, but I'm getting TypeError: __class__ assignment: only