Hi,
I've a module report.py having a set of funtions to open/close/write
data to a log file. I invoke these functions from another module
script.py.
Whenever I'm changing something in report.py, I'm running the file
(however, it has not effect). After that I'm running script.py again.
However, the output is not taking effect.
If I shut the IDLE interpreter and all the other files and then reopen
again; and then run script.py, the output is taking effect.
Is there any way to improve it? I'm new to Python.
-Gopal. 2 1678
Gopal wrote: Hi,
I've a module report.py having a set of funtions to open/close/write data to a log file. I invoke these functions from another module script.py.
Whenever I'm changing something in report.py, I'm running the file (however, it has not effect). After that I'm running script.py again. However, the output is not taking effect.
If I shut the IDLE interpreter and all the other files and then reopen again; and then run script.py, the output is taking effect.
Is there any way to improve it? I'm new to Python.
-Gopal.
you could try "reload(module) " instead of "import module" or running the file.
Gopal wrote: I've a module report.py having a set of funtions to open/close/write data to a log file. I invoke these functions from another module script.py.
Whenever I'm changing something in report.py, I'm running the file (however, it has not effect). After that I'm running script.py again. However, the output is not taking effect.
If I shut the IDLE interpreter and all the other files and then reopen again; and then run script.py, the output is taking effect.
Is there any way to improve it? I'm new to Python.
If I understand you correctly, you are importing your module report in
script.py. If so, you need reload.
When in IDLE, you have a python process running, in which you execute
your program. The first time you run script.py after starting IDLE, your
module report is imported from file. The next time you run script.py,
there is already a module named report in memory. Then the corresponding
file will not be executed again. Instead, the one in memory will be used.
What I do when I am developing a module for a program is that I both
import and reload the module in my main file. Once I think I am done
developing, I remove the reload statement. So, in your script.py, I
would write:
import report
reload(report)
HTH
/MiO This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Greg Scharlemann |
last post by:
Given some recent success on a simple form validation (mainly due to
the kind folks in this forum), I've tried to tackle something a bit
more difficult. I'm pulling data down from a database and populating a
simple table. I'd like the table to contain 10 entries per page and
have the option for the user to scroll through the pages of data
without having to go back to refresh the page (I've already pulled all
the info I need from the...
|
by: A_PK |
last post by:
Hi,
I am a VB.net beginner, I do not know what are the major difference between
Module vs Class.
Could someone guide me when is the best situation to use Module or Class.
I have no idea when should I use module or class, because no matter i use
module or class, i always could get the results that are what i want. but
just the declare and calling method is a bit different.
|
by: Jim Frazer |
last post by:
Hi,
I'm working on an application in C# that will allow the user to create
simple CAD drawings on a CEPC system. I would like to be able to change the
cursor shape depending on the drawing mode selected by the user. I started
out by setting up P/Invokes for LoadCursor and SetCursor. Calling
LoadCursor followed by SetCursor does allow me to change to a different
cursor, such as the cross cursor, but as soon as the application leaves...
|
by: mensanator |
last post by:
## Holy Mother of Pearl!
##
## >>> for i in range(10):
## for j in range(10):
## print '%4d' % (gmpy.mpz(i)*gmpy.mpz(j)),
## print
##
##
## 0 0 0 0 0 0 0 0 0 0
## 0 1 2 3 1 5 6 7 2 9
|
by: Tom Plunket |
last post by:
I've got a bunch of code that runs under a bunch of unit tests. It'd
be really handy if when testing I could supply replacement
functionality to verify that the right things get called without those
things actually getting called, since frequently those calls take a
long time to execute and do things that, well, I don't really want to
do.
E.g. imagine you've got a routine which takes a filespec, generates a
list of files, and copies...
| |
by: rahatekarabhijeet |
last post by:
I downloaded the sorce from CPAN(PerlMagick-6.32.tar.gz).
I followed the normal procedure to install perl module on unix platform,
i.e.
1) perl Makefile.PL
during the execution of this command i am getting error as:
Note (probably harmless): No library found for -lgvc
Writing Makefile for Image::Magick
2)make
|
by: blufox |
last post by:
Hi All,
Can i change the execution path of methods in my process at runtime?
e.g
a()->b()->c()->d()->e()
Now, i want execution to be altered at runtime as -
|
by: chigasakigaijin |
last post by:
Hi all! This is my first post in this forum. Looking forward to learning alot! I'm still a beginner at Python, but have grasped all the major concepts in "How to Think Like a Computer Scientist." I'm trying to branch out a bit and get some more control over how my console apps are displayed. I don't want to jump into a full-fledged GUI like TkInter just yet, though, so I wanted to see if I could get more control over the Windows Console.
...
|
by: trihaitran |
last post by:
Hi,
My problem is that I have a large function with hundreds of lines. I want to break it apart into smaller functions. The issue is that if I make a module level function, the scope changes and I have to pass the necessary variables to it. This can be difficult if there are 10 variables that need to be passed. So basically I want to be able to call a function inside another function but keep the scope the same. I found a way to do something...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |