|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
pickle problems
I am wanting to pickle an object so that I can save it in a file, I seem to be having problems getting it to work, here's my code sample:
pickle.dump(conn_table, open(proj/daylight/gwcgi/drh25452/merlin/conn_tab(), 'w') I wondered if anyone could see any problems or suddest anything else that could be causing this to generate errors? |
|
#2
|
|||
|
|||
|
What errors do you get? I can't help you if I don't know the error.
But I'm not sure if you can use proj/bla/conn_tab() as a vaild filename. It is a filename or a function call that would return a filename?
__________________
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems. - Jamie Zawinski, in comp.lang.emacs |
|
#3
|
|||
|
|||
|
the errors
That's the problem, it's not generating any specific errors, it's just causing all of the code after it to fail, generating syntax errors.
I don't know if this will help you at all, I'm a bit confused myself. Thanks |
|
#4
|
|||
|
|||
|
Okay, just try to open the file outside the pickle.dump function, and then pass the file object on to the function. I guess you should be able to see where the syntax error is caused.
But is this a filename: proj/daylight/gwcgi/drh25452/merlin/conn_tab(), or is it a function that's called to get a filename? If it's a filename, just put quotes around it to make it a string. If it's a function, I have no idea how this could be legal syntax for a function. |
|
#5
|
|||
|
|||
|
You need quotes
Quote:
Try putting quotes around your filename. -- Michael T. Babcock |
|
#6
|
||||
|
||||
|
You actually have unbalanced parenthesis too, try rewriting the line to something like this:
Code:
pickle.dump(conn_table, file('proj/daylight/gwcgi/drh25452/merlin/conn_tab', 'w'))
Note: file() was introduced in Python 2.3 as the prefered way to open a file() opject. Mark. |
|
#7
|
|||
|
|||
|
Since the original post was December 2001, I doubt that the poster is still worrying about this problem.
Dave |
|
#8
|
||||
|
||||
|
No, but it was easy enough to clear up. If only for mtb
. So no real loss there. Now, the jetlag has me and its time for bed me thinks. Later Dave, Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > pickle problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|