473,225 Members | 1,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

using reload(module)

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(modolename) 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 2180
bvdet
2,851 Expert Mod 2GB
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
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
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 Expert 4TB
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
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. ...
2
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...
2
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...
4
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...
30
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...
0
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...
3
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...
2
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...
5
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...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.