Re: in a pickle

2019-03-06 Thread duncan smith
On 07/03/2019 00:18, Ethan Furman wrote: > On 03/06/2019 10:30 AM, duncan smith wrote: > >>  I've been trying to figure out why one of my classes can be >> pickled but not unpickled. (I realise the problem is probably with the >> pickling, but I get the error when I attempt to unpickle.) >> >> A

Re: in a pickle

2019-03-06 Thread duncan smith
On 06/03/2019 20:24, Peter Otten wrote: > duncan smith wrote: > >> On 06/03/2019 16:14, duncan smith wrote: >>> Hello, >>> I've been trying to figure out why one of my classes can be >>> pickled but not unpickled. (I realise the problem is probably with the >>> pickling, but I get the error

Re: in a pickle

2019-03-06 Thread Ethan Furman
On 03/06/2019 10:30 AM, duncan smith wrote: I've been trying to figure out why one of my classes can be pickled but not unpickled. (I realise the problem is probably with the pickling, but I get the error when I attempt to unpickle.) A relatively minimal example is pasted below. --> import

Re: in a pickle

2019-03-06 Thread Peter Otten
duncan smith wrote: > On 06/03/2019 16:14, duncan smith wrote: >> Hello, >> I've been trying to figure out why one of my classes can be >> pickled but not unpickled. (I realise the problem is probably with the >> pickling, but I get the error when I attempt to unpickle.) >> >> A relatively

Re: in a pickle

2019-03-06 Thread duncan smith
On 06/03/2019 16:14, duncan smith wrote: > Hello, > I've been trying to figure out why one of my classes can be > pickled but not unpickled. (I realise the problem is probably with the > pickling, but I get the error when I attempt to unpickle.) > > A relatively minimal example is pasted

RE: in a pickle

2019-03-06 Thread David Raymond
https://docs.python.org/3.7/library/pickle.html#pickling-class-instances includes 2 notes, which I think are the relevant ones: When a class instance is unpickled, its __init__() method is usually not invoked. The default behaviour first creates an uninitialized instance and then restores the

Re: in a pickle

2019-03-06 Thread duncan smith
[snip] Sorry, this is Python 3.6 on Linux. Duncan -- https://mail.python.org/mailman/listinfo/python-list

Re: dictionary of pickle error when get it in multiprocessing and has name error

2017-02-27 Thread Peter Otten
Ho Yeung Lee wrote: > before cloususerlogin > Unexpected error: > after map pool > > > ... > passwordlist = pickle.load( open( str(currentworkingdirectory) + > "\\decryptedsecret.p", "rb" ) ) According to https://docs.python.org/dev/library/multiprocessing.html#programming-guidelines you

Re: MemoryError and Pickle

2016-11-21 Thread Steve D'Aprano
On Tue, 22 Nov 2016 10:27 am, Fillmore wrote: > > Hi there, Python newbie here. > > I am working with large files. For this reason I figured that I would > capture the large input into a list and serialize it with pickle for > later (faster) usage. > Everything has worked beautifully until

Re: MemoryError and Pickle

2016-11-21 Thread Steve D'Aprano
On Tue, 22 Nov 2016 11:40 am, Peter Otten wrote: > Fillmore wrote: > >> Hi there, Python newbie here. >> >> I am working with large files. For this reason I figured that I would >> capture the large input into a list and serialize it with pickle for >> later (faster) usage. > > But is it

Re: MemoryError and Pickle

2016-11-21 Thread Chris Kaynor
On Mon, Nov 21, 2016 at 3:43 PM, John Gordon wrote: > In Fillmore > writes: > > >> Question for experts: is there a way to refactor this so that data may >> be filled/written/released as the scripts go and avoid

Re: MemoryError and Pickle

2016-11-21 Thread Peter Otten
Fillmore wrote: > Hi there, Python newbie here. > > I am working with large files. For this reason I figured that I would > capture the large input into a list and serialize it with pickle for > later (faster) usage. But is it really faster? If the pickle is, let's say, twice as large as the

Re: MemoryError and Pickle

2016-11-21 Thread John Gordon
In Fillmore writes: > Question for experts: is there a way to refactor this so that data may > be filled/written/released as the scripts go and avoid the problem? > code below. That depends on how the data will be read. Here is

Re: problem using pickle

2016-10-27 Thread Veek M
Ben Finney wrote: > "Veek. M" writes: > >> class Foo(object): >> pass >> >> object is a keyword and you're using it as an identifier > > Python does not have ‘object’ as a keyword. ‘and’ is a keyword. > > Here's the difference:: > > >>> object > > >>>

Re: problem using pickle

2016-10-27 Thread Veek M
Rustom Mody wrote: > On Saturday, July 2, 2016 at 9:17:01 AM UTC+5:30, Veek. M wrote: >> object is a keyword and you're using it as an identifier > > keyword and builtin are different > In this case though the advice remains the same > In general maybe not... > Just sayin' np - feel free to

Re: problem using pickle

2016-07-01 Thread Ben Finney
"Veek. M" writes: > class Foo(object): > pass > > object is a keyword and you're using it as an identifier Python does not have ‘object’ as a keyword. ‘and’ is a keyword. Here's the difference:: >>> object >>> object = "Lorem ipsum" >>> object

Re: problem using pickle

2016-07-01 Thread Rustom Mody
On Saturday, July 2, 2016 at 9:17:01 AM UTC+5:30, Veek. M wrote: > object is a keyword and you're using it as an identifier keyword and builtin are different In this case though the advice remains the same In general maybe not... Just sayin' --

Re: problem using pickle

2016-07-01 Thread Veek. M
Nicky Mac wrote: > Dear Python team, > I have studied the excellent documentation, and attempted to make use > of pickle thus: > > filename = 'my_saved_adventure' > import pickle > class object: > def __init__(self,i,.t) : > self.id = i > . > > class

Re: problem using pickle

2016-03-13 Thread Terry Reedy
On 3/12/2016 10:45 AM, Nicky Mac wrote: class object: def __init__(self,i, This is a syntax error, so this is not the code that ran without error. As Peter Otten said, please write a minimal complete runnable example that shows the error and then copy and paste it as run. -- Terry

Re: problem using pickle

2016-03-13 Thread Peter Otten
Nicky Mac wrote: > Dear Python team, > I have studied the excellent documentation, That is always a laudable endeavour ;) > and attempted to make use of > pickle thus: > > filename = 'my_saved_adventure' > import pickle > class object: 'object' already is the name for a Python built-in; you

Re: Questions on Pickle and Shelve

2015-11-06 Thread Chris Warrick
On 6 November 2015 at 12:53, Virgil Stokes wrote: > Here is snippet of Python (vers. 2.7.10) code that bothers me. > > [snip bad code] > > 1) Which (the pickle or shelve code) takes less total RAM, if dogs and cats > were very large? > 2) When the last shelve.open is given, is

Re: Questions on Pickle and Shelve

2015-11-06 Thread Peter Otten
Virgil Stokes wrote: > Here is snippet of Python (vers. 2.7.10) code that bothers me. > > import cPickle as pickle > > print "Pickle lists:" > dogs = ['Rover','King','Spot','Rufus'] > cats = ['Mimi','Misty','Sasha'] > > with open('pickle.dat', 'wb') as pfile: > pickle.dump(dogs, pfile) >

Re: ImportError with pickle (Python 2.7.9), possibly platform dependent

2015-05-13 Thread Ben Sizer
On Friday, 1 May 2015 13:09:48 UTC+1, Chris Angelico wrote: Cool! That's part way. So, can you simply stuff OMDBMap into sys.modules prior to loading? It might be a bit of a hack, but it should work for testing, at least. Conversely, you could change the dump script to import via the name

Re: ImportError with pickle (Python 2.7.9), possibly platform dependent

2015-05-13 Thread Ben Sizer
On Friday, 1 May 2015 13:34:41 UTC+1, Peter Otten wrote: Ben Sizer wrote: So... I don't know how to fix this, but I do now know why it fails, and I have a satisfactory answer for why it is acting differently on the Linux server (and that is just because that is the only one running under

Re: ImportError with pickle (Python 2.7.9), possibly platform dependent

2015-05-01 Thread Ben Sizer
On Thursday, 30 April 2015 01:45:05 UTC+1, Chris Angelico wrote: On Thu, Apr 30, 2015 at 2:01 AM, Ben Sizer wrote: 1) There clearly is a module named OMDBMap, and it's importable - it's there in the 2nd line of the traceback. Does anybody have any suggestions on how I can go about

Re: ImportError with pickle (Python 2.7.9), possibly platform dependent

2015-05-01 Thread Peter Otten
Ben Sizer wrote: On Thursday, 30 April 2015 01:45:05 UTC+1, Chris Angelico wrote: On Thu, Apr 30, 2015 at 2:01 AM, Ben Sizer wrote: 1) There clearly is a module named OMDBMap, and it's importable - it's there in the 2nd line of the traceback. Does anybody have any suggestions on how I

Re: ImportError with pickle (Python 2.7.9), possibly platform dependent

2015-05-01 Thread Chris Angelico
On Fri, May 1, 2015 at 9:01 PM, Ben Sizer kylo...@gmail.com wrote: Another good question, and this gives us the answer. The module lists are quite different, as I'd expect because the load happens in the context of the full application whereas the dump happens as a standalone script. But

Re: ImportError with pickle (Python 2.7.9), possibly platform dependent

2015-04-29 Thread Chris Angelico
On Thu, Apr 30, 2015 at 2:01 AM, Ben Sizer kylo...@gmail.com wrote: 1) There clearly is a module named OMDBMap, and it's importable - it's there in the 2nd line of the traceback. Does anybody have any suggestions on how I can go about debugging this? Or refactoring it to avoid whatever is

Re: Pyrolite, lightweight pickle and pyro client library, seeking a bit of testing help

2014-09-23 Thread Irmen de Jong
On 22-9-2014 20:28, Chris Angelico wrote: On Tue, Sep 23, 2014 at 4:23 AM, Irmen de Jong irmen.nos...@xs4all.nl wrote: This is why Pyro has been using a different (and safe) serializer by default for a while now. You have to plow through the usual security warnings in the docs and make a

Re: Pyrolite, lightweight pickle and pyro client library, seeking a bit of testing help

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 3:47 AM, Irmen de Jong irmen.nos...@xs4all.nl wrote: I've developed Pyrolite (https://github.com/irmen/Pyrolite), a lightweight client library for Java and .NET to gain access to Python servers running Pyro. As such it also contains a complete pickle and unpickle

Re: Pyrolite, lightweight pickle and pyro client library, seeking a bit of testing help

2014-09-22 Thread Irmen de Jong
On 22-9-2014 19:53, Chris Angelico wrote: On Tue, Sep 23, 2014 at 3:47 AM, Irmen de Jong irmen.nos...@xs4all.nl wrote: I've developed Pyrolite (https://github.com/irmen/Pyrolite), a lightweight client library for Java and .NET to gain access to Python servers running Pyro. As such it also

Re: Pyrolite, lightweight pickle and pyro client library, seeking a bit of testing help

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 4:23 AM, Irmen de Jong irmen.nos...@xs4all.nl wrote: This is why Pyro has been using a different (and safe) serializer by default for a while now. You have to plow through the usual security warnings in the docs and make a conscious effort in your code to enable the

Re: Problem with pickle and restarting a program

2014-03-22 Thread dieter
peace abhishek1...@gmail.com writes: On Thursday, March 20, 2014 1:20:03 AM UTC-7, dieter wrote: ... You may want to use debugging to determine what goes on in detail. ... I tried doing that. I still could not figure out what was wrong. Thank you. Debugging is often not easy. An essential

Re: Problem with pickle and restarting a program

2014-03-20 Thread dieter
Peace abhishek1...@gmail.com writes: ... The serial number field always remains empty even though I enter from the GUI and the receiveSerialNumber function is called and I explicitly initialize it to the variable in the model. I'm trying to save the state of the program so that next time I

Re: Problem with pickle and restarting a program

2014-03-20 Thread peace
On Thursday, March 20, 2014 1:20:03 AM UTC-7, dieter wrote: Peace writes: ... The serial number field always remains empty even though I enter from the GUI and the receiveSerialNumber function is called and I explicitly initialize it to the variable in the model. I'm trying to

Re: Question about pickle

2013-06-26 Thread Phu Sam
f.seek(0) really does the trick. Danke sehr, Phu On Tue, Jun 25, 2013 at 6:47 AM, Peter Otten __pete...@web.de wrote: Phu Sam wrote: I have a method that opens a file, lock it, pickle.load the file into a dictionary. I then modify the status of a record, then pickle.dump the

Re: Question about pickle

2013-06-25 Thread Peter Otten
Phu Sam wrote: I have a method that opens a file, lock it, pickle.load the file into a dictionary. I then modify the status of a record, then pickle.dump the dictionary back to the file. The problem is that the pickle.dump never works. The file never gets updated. def

Re: GUI for pickle read

2012-02-28 Thread Jerry Hill
On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 ssmil...@gmail.com wrote: Can I have some thoughts about - building a GUI to display the results of the pickle read? A prototype code should be fine on Linux. It doesn't seem like it would be all that useful, though I may just be lacking in

Re: GUI for pickle read

2012-02-28 Thread Aaron France
On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321ssmil...@gmail.com wrote: Can I have some thoughts about - building a GUI to display the results of the pickle read? A prototype code should be fine on Linux. What on earth is this post asking? Do you want code? Opinions? --

Re: GUI for pickle read

2012-02-28 Thread Rick Johnson
On Feb 28, 12:13 pm, Jerry Hill malaclyp...@gmail.com wrote: On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 ssmil...@gmail.com wrote: Can I have some thoughts about - building a GUI to display the results of the pickle read? Sure. But first can you show us some code that reads a pickled file

Re: ValueError: insecure pickle string

2011-03-28 Thread Peter Otten
pradeepbpin wrote: I am encountering 'Value Error: insecure string pickle' when trying to execute the script on Ubuntu. The same script and the pickled file works without any problem in Windows. For working in Ubuntu I just copied both the script file and pickled file from Windows. How

Re: ValueError: insecure pickle string

2011-03-28 Thread Steven D'Aprano
On Mon, 28 Mar 2011 08:53:35 -0700, pradeepbpin wrote: I am encountering 'Value Error: insecure string pickle' when trying to execute the script on Ubuntu. The same script and the pickled file works without any problem in Windows. For working in Ubuntu I just copied both the script file and

Re: ValueError: insecure pickle string

2011-03-28 Thread pradeepbpin
For new data: an alternative is to open the file in binary mode for both reading and writing on all platforms. This will also allow you to switch to the more efficient binary pickle protocols. Writing and reading the pickled file in binary mode seems to be working. Thank you. --

Re: Converting a pickle to python3

2010-06-02 Thread Paulo da Silva
Em 02-06-2010 04:48, Paulo da Silva escreveu: Hi! I have a big data structure cpickled into a datafile, by python2. I tried to unpickle it using python3 but got the followin message: File /usr/lib64/python3.1/pickle.py, line 1372, in loads encoding=encoding, errors=errors).load()

Re: Zipped and pickle

2009-09-17 Thread Thomas Lehmann
Briefly: s = cPickle.dumps(obj) z = zipfile.Zipfile(filename.zip,w,zipfile.ZIP_DEFLATED) z.writestr(arcname.pkl,s) Thank you very much. I have not been aware that pickle can also do the job without a file! Here's the complete scenario for writing and reading the data... APPENDIX: import

Re: How to pickle a lambda function?

2009-08-11 Thread Duncan Booth
Terry terry.yin...@gmail.com wrote: I'm trying to implement something like: remote_map(fun, list) to execute the function on a remove machine. But the problem is I cannot pickle a lambda function and send it to the remote machine. Is there any possible way to pickle (or other method)

Re: How to pickle a lambda function?

2009-08-11 Thread Terry
On Aug 11, 3:42 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: Terry terry.yin...@gmail.com wrote: I'm trying to implement something like: remote_map(fun, list) to execute the function on a remove machine. But the problem is I cannot pickle a lambda function and send it to the

Re: Marshal vs pickle...

2009-04-25 Thread Pascal Chambon
Hello I've never run into a discussion on pickle vs marshal, but clearly if the point is to exchange data between different clients, or to store it, pickle is the preferred solution, as masrhal is really too low level and its format too unstable. Indeed, the problem of pickle is that at the

Re: Marshal vs pickle...

2009-04-25 Thread Paul Rubin
Lawson English lengli...@cox.net writes: I read somewhere that Marshalling is version-dependent while pickling is not, but can't find that reference. It is in the python library docs for the marshal module. -- http://mail.python.org/mailman/listinfo/python-list

Re: Marshal vs pickle...

2009-04-25 Thread Benjamin Peterson
Lawson English lenglish5 at cox.net writes: Marshalling is only briefly mentioned in most python books I have, and pickling is declared teh preferred method for serialization. I read somewhere that Marshalling is version-dependent while pickling is not, but can't find that reference.

Re: Marshal vs pickle...

2009-04-25 Thread Erik Max Francis
Lawson English wrote: Marshalling is only briefly mentioned in most python books I have, and pickling is declared teh preferred method for serialization. I read somewhere that Marshalling is version-dependent while pickling is not, but can't find that reference. OTOH, pickling can lead to

Re: Marshal vs pickle...

2009-04-25 Thread Lawson English
Lawson English wrote: Marshalling is only briefly mentioned in most python books I have, and pickling is declared teh preferred method for serialization. I read somewhere that Marshalling is version-dependent while pickling is not, but can't find that reference. OTOH, pickling can lead to

Re: cPickle vs pickle discrepancy

2009-01-08 Thread Zac Burns
Thanks for your patience waiting for me to isolate the problem. | Package --__init__.py -empty --Package.py -empty --Module.py import cPickle class C(object): pass def fail(): return cPickle.dumps(C(), -1) import Package.Module Package.Module.fail() The failure

Re: cPickle vs pickle discrepancy

2009-01-08 Thread Carl Banks
On Jan 8, 12:27 pm, Zac Burns zac...@gmail.com wrote: Thanks for your patience waiting for me to isolate the problem. | Package --__init__.py -empty --Package.py -empty --Module.py      import cPickle      class C(object):         pass      def fail():         return cPickle.dumps(C(),

Re: cPickle vs pickle discrepancy

2009-01-08 Thread Zac Burns
Correct, 2.6.1 does not complain. If only I could upgrade! The workaround is obvious and I'll do that. Thanks for your help. -- Zachary Burns (407)590-4814 Aim - Zac256FL Production Engineer (Digital Overlord) Zindagi Games On Thu, Jan 8, 2009 at 11:34 AM, Carl Banks pavlovevide...@gmail.com

Re: cPickle vs pickle discrepancy

2009-01-06 Thread Gabriel Genellina
En Mon, 05 Jan 2009 23:04:30 -0200, Zac Burns zac...@gmail.com escribió: I have a module that attempts to pickle classes defined in that module. I get an error of the form: PicklingError: Can't pickle class 'Module.SubModule.Class': import of module Module.SubModule failed when using cPickle

Re: TypeError: can't pickle HASH objects?

2008-10-02 Thread est
On Oct 2, 1:51 pm, James Mills [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 3:34 PM, est [EMAIL PROTECTED] wrote: wow. It's giga-size file. I need stream reading it, md5 it. It may break for a while. So use generators and consume the stream ? --JamesMills -- -- -- Problems are

Re: TypeError: can't pickle HASH objects?

2008-10-02 Thread Aaron Castironpi Brady
On Oct 2, 2:44 am, est [EMAIL PROTECTED] wrote: On Oct 2, 1:51 pm, James Mills [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 3:34 PM, est [EMAIL PROTECTED] wrote: wow. It's giga-size file. I need stream reading it, md5 it. It may break for a while. So use generators and consume the

Re: TypeError: can't pickle HASH objects?

2008-10-02 Thread est
On Oct 2, 4:22 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: On Oct 2, 2:44 am, est [EMAIL PROTECTED] wrote: On Oct 2, 1:51 pm, James Mills [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 3:34 PM, est [EMAIL PROTECTED] wrote: wow. It's giga-size file. I need stream reading

Re: TypeError: can't pickle HASH objects?

2008-10-02 Thread Gabriel Genellina
En Wed, 01 Oct 2008 16:50:05 -0300, est [EMAIL PROTECTED] escribió: import md5 a=md5.md5() import pickle pickle.dumps(a) Traceback (most recent call last): File stdin, line 1, in module File C:\Python25\lib\pickle.py, line 1366, in dumps Pickler(file, protocol).dump(obj) File

Re: TypeError: can't pickle HASH objects?

2008-10-02 Thread Aaron Castironpi Brady
On Oct 2, 4:03 am, est [EMAIL PROTECTED] wrote: On Oct 2, 4:22 pm, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: On Oct 2, 2:44 am, est [EMAIL PROTECTED] wrote: On Oct 2, 1:51 pm, James Mills [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 3:34 PM, est [EMAIL PROTECTED] wrote:

Re: TypeError: can't pickle HASH objects?

2008-10-02 Thread est
On Oct 2, 5:07 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Wed, 01 Oct 2008 16:50:05 -0300, est [EMAIL PROTECTED] escribió: import md5 a=md5.md5() import pickle pickle.dumps(a) Traceback (most recent call last):   File stdin, line 1, in module   File

Re: TypeError: can't pickle HASH objects?

2008-10-01 Thread mdsherry
On Oct 1, 3:50 pm, est [EMAIL PROTECTED] wrote: import md5 a=md5.md5() import pickle pickle.dumps(a) Traceback (most recent call last):   File stdin, line 1, in module   File C:\Python25\lib\pickle.py, line 1366, in dumps     Pickler(file, protocol).dump(obj)   File

Re: TypeError: can't pickle HASH objects?

2008-10-01 Thread Aaron Castironpi Brady
On Oct 1, 2:50 pm, est [EMAIL PROTECTED] wrote: import md5 a=md5.md5() import pickle pickle.dumps(a) Traceback (most recent call last):   File stdin, line 1, in module   File C:\Python25\lib\pickle.py, line 1366, in dumps     Pickler(file, protocol).dump(obj)   File

Re: TypeError: can't pickle HASH objects?

2008-10-01 Thread est
On Oct 2, 11:27 am, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: On Oct 1, 2:50 pm, est [EMAIL PROTECTED] wrote: import md5 a=md5.md5() import pickle pickle.dumps(a) Traceback (most recent call last):   File stdin, line 1, in module   File C:\Python25\lib\pickle.py,

Re: TypeError: can't pickle HASH objects?

2008-10-01 Thread James Mills
On Thu, Oct 2, 2008 at 3:34 PM, est [EMAIL PROTECTED] wrote: wow. It's giga-size file. I need stream reading it, md5 it. It may break for a while. So use generators and consume the stream ? --JamesMills -- -- -- Problems are solved by method --

Re: TypeError: can't pickle HASH objects?

2008-10-01 Thread electronixtar
James Mills wrote: On Thu, Oct 2, 2008 at 3:34 PM, est [EMAIL PROTECTED] wrote: wow. It's giga-size file. I need stream reading it, md5 it. It may break for a while. So use generators and consume the stream ? --JamesMills it's not the stream's problem. it the md5 module. --

Re: How to pickle bound methods

2008-07-03 Thread Peter Otten
srinivasan srinivas wrote: Please don't top-post. Could you please explain the code breifly?? I am not getting what it does. import copy_reg import new def make_instancemethod(inst, methodname):     return getattr(inst, methodname) def pickle_instancemethod(method):     return

Re: How to pickle bound methods

2008-07-03 Thread srinivasan srinivas
From: Peter Otten [EMAIL PROTECTED] To: python-list@python.org Sent: Thursday, 3 July, 2008 12:13:45 PM Subject: Re: How to pickle bound methods srinivasan srinivas wrote: Please don't top-post. Could you please explain the code breifly?? I am not getting what it does. import copy_reg import

Re: How to pickle bound methods

2008-07-03 Thread Peter Otten
srinivasan srinivas wrote: Please don't top-post. No. It does not work. That's what I said. Try class A(object): @staticmethod def alpha(): print Hello alpha = A.alpha Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: How to pickle bound methods

2008-07-02 Thread Peter Otten
srinivasan srinivas wrote: I would like to know how to pickle a bound method?? $ cat pickle_method.py import copy_reg import new def make_instancemethod(inst, methodname): return getattr(inst, methodname) def pickle_instancemethod(method): return make_instancemethod, (method.im_self,

Re: How to pickle bound methods

2008-07-02 Thread srinivasan srinivas
Subject: Re: How to pickle bound methods srinivasan srinivas wrote: I would like to know how to pickle a bound method?? $ cat pickle_method.py import copy_reg import new def make_instancemethod(inst, methodname):     return getattr(inst, methodname) def pickle_instancemethod(method

Re: How to pickle bound methods

2008-07-02 Thread Peter Otten
srinivasan srinivas wrote: (Please don't top-post) It works will for instance and class methods. But it doesn't work for static methods. Can you tel me how to pickle static methods as well?? For static methods pickling is not so easy because these don't carry information about the class they

Re: How to pickle bound methods

2008-07-02 Thread srinivasan srinivas
July, 2008 5:15:41 PM Subject: Re: How to pickle bound methods srinivasan srinivas wrote: (Please don't top-post) It works will for instance and class methods. But it doesn't work for static methods. Can you tel me how to pickle static methods as well?? For static methods pickling is not so easy

Re: How to pickle bound methods

2008-07-02 Thread George Sakkis
On Jul 2, 8:26 am, srinivasan srinivas [EMAIL PROTECTED] wrote: I am writing client-server program. The server will send a methodname and its arguments to a client. The client has to execute the method and return back the results. Are you aware of Pyro [1] ? Btw, you use the terminology

Re: How to pickle bound methods

2008-07-02 Thread srinivasan srinivas
Peter, Could you please explain the code breifly?? I am not getting what it does. Thanks, Srini  - Original Message From: Peter Otten [EMAIL PROTECTED] To: python-list@python.org Sent: Wednesday, 2 July, 2008 12:53:19 PM Subject: Re: How to pickle bound methods srinivasan srinivas

Re: KeyError in pickle

2008-05-23 Thread Peter Otten
christof wrote: I am using pickle/unpickle to let my program save its documents to disk. While this it worked stable for a long time, one of my users now complained, that he had a file which can't be loaded. The traceback is: File pickle.pyo, line 1374, in loads File pickle.pyo,

Re: KeyError in pickle

2008-05-23 Thread christof
On 23 Mai, 10:48, Peter Otten [EMAIL PROTECTED] wrote: christof wrote: I am using pickle/unpickle to let my program save its documents to disk. While this it worked stable for a long time, one of my users now complained, that he had a file which can't be loaded. The traceback is:

Re: Shelve or pickle module

2008-05-18 Thread Ville M. Vainio
Gabriel Genellina [EMAIL PROTECTED] writes: A shelve is just a persistent dictionary that uses pickle to store the objects. If you want to store one or a few objects, using pickle directly may be easier. Any problem you may have with pickle (nonpickleable objects, security risks) will

Re: Shelve or pickle module

2008-05-17 Thread Gabriel Genellina
En Sun, 18 May 2008 00:14:19 -0300, Guillaume Bog [EMAIL PROTECTED] escribió: I read and re-read Python in a Nutshell written by Alex Martelli, who knows what he is talking about. I'm a bit new to python and I'm going to start doing persistence side on a project. Martelli's book seems to tell

Re: ValueError in pickle module during unpickling a infinite float (python 2.5.2)

2008-03-12 Thread Mark Dickinson
On Mar 12, 11:22 am, [EMAIL PROTECTED] wrote: Unpickling an infinite float caused a ValueError in the pickle module. I need to pickle and load infinite floats in my project. Do you have any suggestions how to solve the issue? Have you tried this on the recent 2.6 alpha (Python2.6a1)? It's

Re: ValueError in pickle module during unpickling a infinite float (python 2.5.2)

2008-03-12 Thread Peter Otten
[EMAIL PROTECTED] wrote: Unpickling an infinite float caused a ValueError in the pickle module. I need to pickle and load infinite floats in my project. Do you have any suggestions how to solve the issue? You could try another protocol. Does inf = 1e1000 pickle.loads(pickle.dumps(inf,

Re: marshal vs pickle

2007-11-02 Thread Aaron Watters
On Nov 1, 11:42 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: Aaron Watters [EMAIL PROTECTED] writes: marshal.loads('RKp,U\xf7`\xef\xe77\xc1\xea\xd8\xec\xbe\\') Segmentation fault ... I'll grant you the above as a denial of service attack. ... Can you give me an example where

Re: marshal vs pickle

2007-11-02 Thread Aaron Watters
On Nov 1, 10:12 am, Aaron Watters [EMAIL PROTECTED] wrote: On Oct 31, 6:10 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: Alright already. Here is the patched file you want http://nucular.sourceforge.net/kisstree_pickle.py This file has been removed. After consideration, I don't want to

Re: marshal vs pickle

2007-11-01 Thread Aaron Watters
On Nov 1, 12:04 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Raymond Hettinger [EMAIL PROTECTED] writes: ''' This is not a general persistence module. For general persistence and transfer of Python objects through RPC calls, see the modules :mod:`pickle` and :mod:`shelve`. That advice

Re: marshal vs pickle

2007-11-01 Thread Aaron Watters
On Oct 31, 6:10 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: On Oct 31, 12:27 pm, Aaron Watters [EMAIL PROTECTED] wrote: Makes more sense to use cPickle and be done with it. FWIW, I've updated the docs to be absolutely clear on the subject: ''' This is not a general persistence module.

Re: marshal vs pickle

2007-11-01 Thread Raymond Hettinger
On Nov 1, 4:45 am, Aaron Watters [EMAIL PROTECTED] wrote: Marshal is more secure than pickle More or less make little sense in a security context which typically is an all or nothing affair. Neither module is designed for security. From the docs for marshal: ''' Warning: The marshal module is

Re: marshal vs pickle

2007-11-01 Thread Aaron Watters
On Nov 1, 2:15 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: On Nov 1, 4:45 am, Aaron Watters [EMAIL PROTECTED] wrote: Marshal is more secure than pickle More or less make little sense in a security context which typically is an all or nothing affair. Neither module is designed for

Re: marshal vs pickle

2007-11-01 Thread Jean-Paul Calderone
On Thu, 01 Nov 2007 20:35:15 -, Aaron Watters [EMAIL PROTECTED] wrote: On Nov 1, 2:15 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: On Nov 1, 4:45 am, Aaron Watters [EMAIL PROTECTED] wrote: Marshal is more secure than pickle More or less make little sense in a security context which

Re: marshal vs pickle

2007-11-01 Thread Aaron Watters
On Nov 1, 4:59 pm, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Thu, 01 Nov 2007 20:35:15 -, Aaron Watters [EMAIL PROTECTED] wrote: On Nov 1, 2:15 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: On Nov 1, 4:45 am, Aaron Watters [EMAIL PROTECTED] wrote: Marshal is more secure than

Re: marshal vs pickle

2007-11-01 Thread Jean-Paul Calderone
On Thu, 01 Nov 2007 21:15:06 -, Aaron Watters [EMAIL PROTECTED] wrote: On Nov 1, 4:59 pm, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Thu, 01 Nov 2007 20:35:15 -, Aaron Watters [EMAIL PROTECTED] wrote: On Nov 1, 2:15 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: On Nov 1, 4:45 am,

Re: marshal vs pickle

2007-11-01 Thread Paul Rubin
Aaron Watters [EMAIL PROTECTED] writes: marshal.loads('RKp,U\xf7`\xef\xe77\xc1\xea\xd8\xec\xbe\\') Segmentation fault ... I'll grant you the above as a denial of service attack. ... Can you give me an example where someone can erase the filesystem using marshal.load? You should

Re: marshal vs pickle

2007-10-31 Thread Bjoern Schliessmann
Evan Klitzke wrote: Can anyone elaborate more on the difference between marshal and pickle. In what conditions would using marshal be unsafe? If one can guarantee that the marshalled objects would be created and read by the same version of Python, is that enough? Just use pickle. From the

Re: marshal vs pickle

2007-10-31 Thread Aaron Watters
On Oct 31, 3:31 am, Evan Klitzke [EMAIL PROTECTED] wrote: Can anyone elaborate more on the difference between marshal and pickle. In what conditions would using marshal be unsafe? If one can guarantee that the marshalled objects would be created and read by the same version of Python, is that

Re: marshal vs pickle

2007-10-31 Thread Raymond Hettinger
On Oct 31, 6:45 am, Aaron Watters [EMAIL PROTECTED] wrote: I like to use marshal a lot because it's the absolutely fastest way to store and load data to/from Python. Furthermore because marshal is stupid the programmer has complete control. A lot of the overhead you get with the pickles

Re: marshal vs pickle

2007-10-31 Thread Aaron Watters
On Oct 31, 1:37 pm, Raymond Hettinger [EMAIL PROTECTED] wrote: On Oct 31, 6:45 am, Aaron Watters [EMAIL PROTECTED] wrote: I like to use marshal a lot because it's the absolutely fastest way to store and load data to/from Python I believe this FUD is somewhat out-of-date.

Re: marshal vs pickle

2007-10-31 Thread Raymond Hettinger
On Oct 31, 12:27 pm, Aaron Watters [EMAIL PROTECTED] wrote: Anyway since it's easy and makes sense I think the next version of nucular will have a switchable option between marshal and cPickle for persistant storage. Makes more sense to use cPickle and be done with it. FWIW, I've updated the

Re: marshal vs pickle

2007-10-31 Thread Gabriel Genellina
En Wed, 31 Oct 2007 19:10:48 -0300, Raymond Hettinger [EMAIL PROTECTED] escribió: FWIW, I've updated the docs to be absolutely clear on the subject: As you are into it, the list of supported types should be updated too: The following types are supported: ``None``, integers, long integers,

Re: marshal vs pickle

2007-10-31 Thread Paul Rubin
Raymond Hettinger [EMAIL PROTECTED] writes: ''' This is not a general persistence module. For general persistence and transfer of Python objects through RPC calls, see the modules :mod:`pickle` and :mod:`shelve`. That advice should be removed since Python currently does not have a general

Re: problem with pickle

2007-07-07 Thread Lawrence Oluyede
K Gaur [EMAIL PROTECTED] wrote: this is what the python interpreter returns on giving the basic command pickle.dump(x,f) where x is a tuple and f is a file object Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'pickle' is not defined kindly

  1   2   >