Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 11th, 2001, 11:35 AM
nickname nickname is offline
inexperienced and useless
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Stevenage, uk
Posts: 10 nickname User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old December 12th, 2001, 04:27 AM
Taradino Taradino is offline
Python Prophet
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Amersfoort, The Netherlands
Posts: 45 Taradino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
  #3  
Old December 12th, 2001, 05:46 AM
nickname nickname is offline
inexperienced and useless
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Stevenage, uk
Posts: 10 nickname User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old December 12th, 2001, 06:38 AM
Taradino Taradino is offline
Python Prophet
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Amersfoort, The Netherlands
Posts: 45 Taradino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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.

Reply With Quote
  #5  
Old August 10th, 2004, 03:12 PM
mtb mtb is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 0 mtb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You need quotes

Quote:
Originally Posted by nickname
pickle.dump(conn_table, open(proj/daylight/gwcgi/drh25452/merlin/conn_tab(), 'w')


Try putting quotes around your filename.
--
Michael T. Babcock

Reply With Quote
  #6  
Old August 11th, 2004, 08:21 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 11 m 13 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #7  
Old August 11th, 2004, 06:19 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,254 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 8 h 9 m
Reputation Power: 265
Since the original post was December 2001, I doubt that the poster is still worrying about this problem.

Dave

Reply With Quote
  #8  
Old August 11th, 2004, 11:32 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 11 m 13 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > pickle problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT