[Tutor] Little pickle playing up on me
lonetwin at gmail.com
Fri Jul 9 12:09:50 CEST 2004
looking at the error, I noticed:
> File "C:\Python23\lib\pickle.py", line 872, in load
> KeyError: '#'
This suggests that pickle.py is trying to interpret a string that
starts with '#'. The second thing I noticed is that, you mentioned
that when you provide the filename on prompting it seems to work but
when you pass it as a command line argument it seems to fail.
So, I looked at your command line argument handling code and saw
> 465 >---if sys.argv:
> 466 >--->---filepassed = str(sys.argv)
sys.argv is actually the name of your script when you execute it.
The command line arguments passed to the script start from
sys.argv. This is because sometimes it is useful to know how the
script was called (ie: using it's full path name as opposed to
invoking from the current directory).
In any case, if you need a proper full blown command line argument
handling module you may look at the getopt module ...tho' it *is* a
bit of an over kill for what you might want to do.
On Fri, 9 Jul 2004 09:36:10 -0000 (GMT), adam <adam at monkeez.org> wrote:
> I've got two functions (see below) which load pickled objects in to memory
> - one (loadcollection) which worked by querying the user for a string to
> provide a file name and unpickling it. The second function
> (load_existing_function) takes a command line argument, which has been
> tested for and turned into a string.
> I'm getting the error:
More information about the Tutor