Re: Duplicating Modules
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Duplicating Modules

From: Steven D'Aprano <steve@REMOVETHIScyber.com.au>
Date: Sat Oct 01 2005 - 05:57:34 CEST

On Fri, 30 Sep 2005 19:52:56 +0200, Misto . wrote:

> There is a way to dumplicate a module ?

[snip]

> P.S: I know that there is some design Issue here, but my boss says no :)

It depends on what you are expecting to do with the duplicated module. If
all you need is to access the same module from two different names, you
can do this:

py> import sys
py> my_boss_is_an_idiot = sys # *grins*
py> my_boss_is_an_idiot.version
'2.3.3 (#1, May 7 2004, 10:31:40) \n[GCC 3.3.3 20040412 (Red Hat Linux
3.3.3-7)]'

But keep in mind that using this method, sys and my_boss_is_an_idiot are
merely different names for the same underlying module. Change one and you
change the other.

I'm curious... I don't expect you to comment on your boss' mental state,
but how/why do you need to duplicate the module?

-- 
Steven.
Received on Sat Oct 15 04:01:47 2005