Hi,all.
I see from "http://docs.python.org/tut/node11.html" that "Name
spaces are created at different moments and have different lifetimes.
The namespace containing the built-in names is created when the Python
interpreter starts up, and is never deleted. The global namespace for
a module is created when the module definition is read in; normally,
module namespaces also last until the interpreter quits."
So can I "delete" the namespace of a module that i import?
thanks. 2 3682
On May 9, 9:06*am, "gbin,Zhou" <scutee...@gmai l.comwrote:
Hi,all.
* *I see from "http://docs.python.org/tut/node11.html" that "Name
spaces are created at different moments and have different lifetimes.
The namespace containing the built-in names is created when the Python
interpreter starts up, and is never deleted. The global namespace for
a module is created when the module definition is read in; normally,
module namespaces also last until the interpreter quits."
* *So can I "delete" the namespace of a module that i import?
* *thanks.
I did some searching and haven't found much. The closest I've found so
far is this old thread: http://mail.python.org/pipermail/pyt...ry/022526.html
You might look at IDLE's code to see what it does when you tell it to
"restart" too.
Good luck!
Mike
En Fri, 09 May 2008 11:06:49 -0300, gbin,Zhou <sc*******@gmai l.comescribió:
I see from "http://docs.python.org/tut/node11.html" that "Name
spaces are created at different moments and have different lifetimes.
The namespace containing the built-in names is created when the Python
interpreter starts up, and is never deleted. The global namespace for
a module is created when the module definition is read in; normally,
module namespaces also last until the interpreter quits."
So can I "delete" the namespace of a module that i import?
You can make Python "forget" a module by removing it from sys.modules; that way, next time you import it, Python will load it again from file.
Or you can use the built-in reload() function to get a "fresh" copy from file.
But any references to objects in the old module will still refer to the old objects (that means, by example, that existing instances of classes defined in the module will still refer to the old definition)
--
Gabriel Genellina This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: gary |
last post by:
Hi,
We all know the below codes are dangerous:
{
int *p = new int;
delete p;
delete p;
}
And we also know the compilers do not delete p if p==NULL.
So why compilers do not "p = NULL" automatically after programs do "delete p"?
|
by: John Baker |
last post by:
Hi:
Access 2000 W98!
I have a table with numerous records in it, and am attempting to delete certain records
that have been selected from it. These are selected based on the ID number in a different
table. While I am using the tools in Access for query setup, its easier to show it on here
using the SQL for the query, which is as follows( the table is ):
DELETE .date, .,
|
by: Bob Tinsman |
last post by:
This problem shows up in Firefox 1.5.0.1 and Rhino 1.6R2.
I've found that if I have an XML node expression that ends in a filter,
I can't use it with the delete operator. In the following example, the
delete operation has no effect:
var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
alert(z.foo.(@a == '2'));
delete z.foo.(@a == '2');
|
by: mkaushik |
last post by:
Hi everyone,
Im just starting out with C++, and am curious to know how "delete
<pointer>", knows about the number of memory locations to free.
I read somewhere that delete frees up space assigned to <pointerby
"new". Does "new" create a list of pointer names and the size of the
memory array they point to? I also read that some compilers may store
the number of consec mem locations a pointer points to, just before the
first data...
|
by: Daniel Mark |
last post by:
Hello all:
I am looking the sample code posted on PIL website
http://www.pythonware.com/library/pil/handbook/imagedraw.htm
################################################
<<Draw a Grey Cross Over an Image>>
import Image, ImageDraw
| |
by: eqq2002 |
last post by:
The below is my code and my compiler is vc++:
#include <iostream>
using namespace std;
int main(){
int *pint = new int(1024);
cout << "The initialized value of *pint is " << *pint << "\n";
|
by: MorgyTheMole |
last post by:
I have a base class:
class A {
protected:
static void* operator new (size_t size);
void operator delete (void *p);
public:
void Delete();
}
|
by: Medvedev |
last post by:
i see serveral source codes , and i found they almost only use "new"
and "delete" keywords to make they object.
Why should i do that , and as i know the object is going to be destroy
by itself at the end of the app
for example:
class test
{
public:
int x;
|
by: tvnaidu |
last post by:
I compiled tinyxml files (.cpp files) and when I am linking to create final exe in Linux, I am getting lot of errors saying "undefiend reference" to "operator new" and "delete", any idea?.
Main.cpp:377: undefined reference to `operator delete(void*)'
tinyXML/include/tinystr.h:259: undefined reference to `operator delete(void*)'
../common/tinyXML/include/tinyxml.h:1401: undefined reference to `operator delete(void*)'...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |