473,804 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using reload(module)

54 New Member
Someone suggested I use reload when trying to reopen a script i've written (the suggestion was made in response to the problem ive reposted below)

however when i do reload(modolena me) i only get this...

Expand|Select|Wrap|Line Numbers
  1. >>> reload(eps)
  2. <module 'eps' from 'eps.pyc'>
i know this is incredibly amateur to say, but the person who suggested it had their reload bolded and in color, as if it was recognized function such as import. Reload didn't do that for me. should it?

either way when i try to get a variable out of eps, that is from eps import stuff

stuff is the same (when it should be different) from when i originally imported eps, not what it would be after i reloaded it. In between the import and the reload i changed the text file that data is drawn from (see below).

any help would be much appreciated.

-pc

original problem:

When I'm testing a script in PythonWin after I import it once, it won't recognize some changes i've made sometimes. Like if its a script to do a web scrape...
the 1st time i try import testscript, it'll take the couple of seconds that is needed to do the scrape. thats good.

Then lets say i change a part of the scrape. For example one thing i often do is have a text file where i have names. My script will take a name out of the text file hten use it in a web address in order to do a scrape. for example
i'll have this pageroot "http://finance.google. com/finance?fstype= ii&q="
then i'll take a name "ge" from a text file and use it to find this web page to go to ... "http://finance.google. com/finance?fstype= ii&q=ge".

if i just import testscript again, then it won't recognize that i've changed the web address that i'm going to.

Does that make sense, should that happen? if so, how cna i get around it w/o closing and reopening PythonWin.

thanks
Oct 11 '07 #1
4 2208
bvdet
2,851 Recognized Expert Moderator Specialist
reload() works like this:
Expand|Select|Wrap|Line Numbers
  1. >>> import xtest
  2. >>> xtest.a
  3. 'This is the original assignment'
  4. >>> import xtest
  5. >>> xtest.a
  6. 'This is the original assignment'
  7. >>> reload(xtest)
  8. <module 'xtest' from 'C:\Python23\lib\xtest.py'>
  9. >>> xtest.a
  10. 'This is the revised assignment'
  11. >>> 
Oct 11 '07 #2
Patrick C
54 New Member
reload() works like this:
Expand|Select|Wrap|Line Numbers
  1. >>> import xtest
  2. >>> xtest.a
  3. 'This is the original assignment'
  4. >>> import xtest
  5. >>> xtest.a
  6. 'This is the original assignment'
  7. >>> reload(xtest)
  8. <module 'xtest' from 'C:\Python23\lib\xtest.py'>
  9. >>> xtest.a
  10. 'This is the revised assignment'
  11. >>> 

So is reload not actually equivalent to closing somethign like PythonWin then reopening and importing again?

Because if i do the long process it notices changes made in the text file that my script draws from. If i do a reload it doesn't....

any ideas how i can get it to recognize changes i' ve made in the text file that a script reads from w/o close and reopening PythonWin?

thanks
Oct 11 '07 #3
Patrick C
54 New Member
So is reload not actually equivalent to closing somethign like PythonWin then reopening and importing again?

Because if i do the long process it notices changes made in the text file that my script draws from. If i do a reload it doesn't....

any ideas how i can get it to recognize changes i' ve made in the text file that a script reads from w/o close and reopening PythonWin?

thanks
so i broke it down and did a small test and it worked, meaning there must be something funny w/ my script/logic....we'll be revisiting this subject soon, hopefully someone will be willing to help if i need it later
Oct 11 '07 #4
bartonc
6,596 Recognized Expert Expert
so i broke it down and did a small test and it worked
Atta way, Patrick! That's the way to resolved issues.
we'll be revisiting this subject soon, hopefully someone will be willing to help if i need it later
Always!
Oct 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

66
3920
by: Ellinghaus, Lance | last post by:
> > Other surprises: Deprecating reload() >Reload doesn't work the way most people think >it does: if you've got any references to the old module, >they stay around. They aren't replaced. >It was a good idea, but the implementation simply >doesn't do what the idea promises. I agree that it does not really work as most people think it does, but how
2
2588
by: Robert Rothenberg | last post by:
I am working on a module that when given a CPAN distribution, will return which modules the distribtion requires (by parsing the Makefile.PL using Module::MakefilePL::Parse if the META.yml file is not available). A companion module will actually try to fetch the distribution information from CPAN (since it can query a .meta file if it exists before downloading an entire distribution). Because it is more closely tied to CPAN and works...
2
1677
by: Gopal | last post by:
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.
4
4670
by: Lonnie Princehouse | last post by:
So, it turns out that reload() fails if the module being reloaded isn't in sys.path. Maybe it could fall back to module.__file__ if the module isn't found in sys.path?? .... or reload could just take an optional path parameter... Or perhaps I'm the only one who thinks this is silly: >>> my_module = imp.load_module(module_name, *imp.find_module(module_name,path))
30
2080
by: Franck PEREZ | last post by:
Hello, I'm developing a small XML marshaller and I'm facing an annoying issue. Here's some sample code: ########### My test application ############ class Foo(object): #The class I'd like to serialize pass
0
1709
by: Marek | last post by:
Hi I need to call various functions in a native C++ DLL (FORTRAN eventually too) - passing integers, doubles, (pointers and arrays to both of these as well) and ultimately structures too. I was quite happily proceeding using ModuleBuilder.DefinePInvokeMethod until I started implementing calls to pointer (byref) parameters. The switch to TypeBuilder.DefinePInvokeMethod (the one with the required custom modifiers) has resulted in the...
3
2009
by: =?ISO-8859-1?Q?Gregory_Pi=F1ero?= | last post by:
Hi Python Experts, I hope I can explain this right. I'll try. Background: I have a module that I leave running in a server role. It has a module which has data in it that can change. So every nth time a function in the server gets called, I want to reload the module so it has the freshest data. But there's a lot of data so it takes 5-10 seconds to do a reload.
2
1696
by: WestAussie | last post by:
Hello This is my first attempt at using VB .NET, and I'm having some trouble identifying the correct means by which to access a form using a procedure stored within a module. I've been using VBA in Excel (self taught) where for example I could access a forms textbox using the statement 'frmInput.txtAge.Text'. In my .NET project I have created a form with a textbox but have been unable to access it from a module using the same process....
5
1861
by: jamesnkk | last post by:
I have many forms, in every form, I need to validate a Process, so instead of coding to every forms, I could think of using module, but not sure how to do it. (1). In each form how do I call the module to check the Process and (2) return me the result. The result return would allow me to fire up the next form. For example if result return is "Frmcust" I would then code frmcust.show In the module I use to check the process,...
0
9715
marktang
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...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10353
jinu1996
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...
0
10099
tracyyun
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...
0
6869
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();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
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
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.