Re: Cashing in PythonWin name space?... seems unexpected to me
On Oct 8, 2:12 pm, Dave Angel wrote: > bsneddon wrote: > > I saw an issue on winXP box not connected to internet yesterday, > > where i was running > > a script in the interactive window on PythonWin . I would modify the > > script save and > > import and was still running the old version. I did that several > > times with same result. > > I even renamed the function and it showed up but ran the old script. > > Very strange. > > > > Caching (not cashing) doesn't come into play here. Objects are kept as > long as there is a reference to them somewhere. So renamed functions > can still exist under their old name, since nobody has reused the name > for something newer. > > I'm not familiar with PythonWin. But if it's like the standard python > interpreter, where you use import at the command line to load a module, > then I can comment on it. > > Doing a second import on the same module will not look at the disk file > at all. To get it to re-read the source code, you need reload(). And > reload() doesn't really do everything you'd expect. In some cases it > cannot (for example, references to external DLL's). So there are > frequently remnants of the earlier version of things lying around. > > If this is really an interpreter environment, I'd exit the environment > and start it again. If it's more like a GUI (like Komodo, which I > use), then the gui will kill the old interpreter and start another one > when you say "exit" and "run". Then you have nothing left of the old > version of the module, and can start from scratch. > > As Simon said, you should read about reload(), and its caveats: > http://docs.python.org/library/functions.html#reload > > DaveA Thanks I have looked at reload now. It seem pythonWin tries to use reload when doing an import. I think I need to do a little more reading on PythonWin. Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: Errors with PyPdf
On Sep 26, 7:10 pm, flebber wrote:
> I was trying to use Pypdf following a recipe from the Activestate
> cookbooks. However I cannot get it too work. Unsure if it is me or it
> is beacuse sets are deprecated.
>
> I have placed a pdf in my C:\ drive. it is called "Components-of-Dot-
> NET.pdf" You could use anything I was just testing with it.
>
> I was using the last script on that page that was most recently
> updated. I am using python 2.6.
>
> http://code.activestate.com/recipes/511465-pure-python-pdf-to-text-co...
>
> import pyPdf
>
> def getPDFContent(path):
> content = "C:\Components-of-Dot-NET.pdf"
> # Load PDF into pyPDF
> pdf = pyPdf.PdfFileReader(file(path, "rb"))
> # Iterate pages
> for i in range(0, pdf.getNumPages()):
> # Extract text from page and add to content
> content += pdf.getPage(i).extractText() + "\n"
> # Collapse whitespace
> content = " ".join(content.replace(u"\xa0", " ").strip().split())
> return content
>
> print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> "ignore")
>
> This is my error.
>
>
>
> Warning (from warnings module):
> File "C:\Documents and Settings\Family\Application Data\Python
> \Python26\site-packages\pyPdf\pdf.py", line 52
> from sets import ImmutableSet
> DeprecationWarning: the sets module is deprecated
>
> Traceback (most recent call last):
> File "C:/Python26/Pdfread", line 15, in
> print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> "ignore")
> File "C:/Python26/Pdfread", line 6, in getPDFContent
> pdf = pyPdf.PdfFileReader(file(path, "rb"))
---> IOError: [Errno 2] No such file or directory: 'Components-of-Dot-
> NET.pdf'
>
>
>
>
Looks like a issue with finding the file.
how do you pass the path?
--
http://mail.python.org/mailman/listinfo/python-list
