Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Steven D'Aprano
On 26/06/13 03:03, Matt D wrote: meanwhile can you please take a look at this update() and tell me if you see something wrong because ever sense I tried using the array for logging the values from the TextCtrls the program is not updating meaning when the program receives the c++ map, or the pic

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Marc Tompkins
On Tue, Jun 25, 2013 at 6:12 PM, Steven D'Aprano wrote: > Why do you want to see rubbish like that inside your log file? Surely > something like this is better? > > log.write("data = %r" % data) > > which will give you a line like this: > > data = {'a': None, 'b': 42} > > > in your log, which is

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Steven D'Aprano
On 26/06/13 04:30, Matt D wrote: On 06/25/2013 01:54 PM, Alan Gauld wrote: On 25/06/13 17:32, Matt D wrote: self.data = data with open('mypicklelog.txt','ab') as log: # open in binary mode pickle.dump(self.data, log) # serialize data and write to file And I

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Matt D
> > The real question is why do you want this pickle in a file? I am not sure > it will be easy to pull out and reuse anyway. Given your experience level, > I think this is a lot of work for something that you are unlikely to be able > to easily use. I think it would be more useful to `log.wr

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Alan Gauld
On 25/06/13 19:30, Matt D wrote: Does the file exist? Does it have anything in it? Does self.data exist - what does it look like if you print it? Are there any error messages? Yeh nothing as in an empty file. The file is there but there is nothing written in it. OK, Try deleting the file an

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Matt D
On 06/25/2013 01:54 PM, Alan Gauld wrote: > On 25/06/13 17:32, Matt D wrote: > >> self.data = data >> with open('mypicklelog.txt','ab') as log: # open in binary mode >> pickle.dump(self.data, log) # serialize data and write to >> file >> >> >> And I still get nothing

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Prasad, Ramit
Again, please leave in attributions. Matt D wrote: > [Ramit Prasad wrote] > > > > Well I think self.data is some kind of container with a pickled string, > > given the code to unpickle it is: > > > Exactly! This is what the C++ file 'pickle.h' creates to send to the > Python GUI: Not really. >

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Alan Gauld
On 25/06/13 17:32, Matt D wrote: self.data = data with open('mypicklelog.txt','ab') as log: # open in binary mode pickle.dump(self.data, log) # serialize data and write to file And I still get nothing. Define 'nothing'. Does the file exist? Does it have anythi

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Prasad, Ramit
Please leave attributions in so we know who is saying what. Matt D wrote: > [Ramit Prasad wrote] > > [Peter Otten wrote] > > > > with open('mypicklelog.txt','ab') as log: # open in binary mode > > pickle.dump(self.data, log) # serialize data and write to file > > > > where pickle.dump(obj, fil

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Matt D
> > Well I think self.data is some kind of container with a pickled string, > given the code to unpickle it is: > Exactly! This is what the C++ file 'pickle.h' creates to send to the Python GUI: /** * A pickled Python dictionary. Used to pass stuff to the UI. */ class pickle { public:

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Matt D
> > with open('mypicklelog.txt','ab') as log: # open in binary mode > pickle.dump(self.data, log) # serialize data and write to file > > where pickle.dump(obj, file) converts `obj` to a sequence of bytes before it > is written to `file`. > I put this like this: class DataEvent(wx.PyEven

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Prasad, Ramit
Peter Otten wrote: > Matt D wrote: > > > On 06/24/2013 07:17 PM, Alan Gauld wrote: > >> On 24/06/13 23:05, Matt D wrote: > >>> I have been unable to find a way to write pickled data to text file. > >> > >> Probably because pickled data is not plain text. > >> You need to use binary mode. However..

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread Matt D
On 06/25/2013 07:28 AM, eryksun wrote: > On Mon, Jun 24, 2013 at 6:57 PM, Steven D'Aprano wrote: >> >> You certainly shouldn't be writing pickle data to a log file! Firstly, >> log files are usually opened in text mode, not binary mode, so it >> probably won't work, and secondly even if it did wor

Re: [Tutor] Need help printing a pickled data

2013-06-25 Thread eryksun
On Mon, Jun 24, 2013 at 6:57 PM, Steven D'Aprano wrote: > > You certainly shouldn't be writing pickle data to a log file! Firstly, > log files are usually opened in text mode, not binary mode, so it > probably won't work, and secondly even if it did work, you will be > dumping a load of pickled bi

Re: [Tutor] Need help printing a pickled data

2013-06-24 Thread Peter Otten
Matt D wrote: > On 06/24/2013 07:17 PM, Alan Gauld wrote: >> On 24/06/13 23:05, Matt D wrote: >>> I have been unable to find a way to write pickled data to text file. >> >> Probably because pickled data is not plain text. >> You need to use binary mode. However... >> >> >>> def __init__(se

Re: [Tutor] Need help printing a pickled data

2013-06-24 Thread Matt D
On 06/24/2013 07:17 PM, Alan Gauld wrote: > On 24/06/13 23:05, Matt D wrote: >> I have been unable to find a way to write pickled data to text file. > > Probably because pickled data is not plain text. > You need to use binary mode. However... > > >> def __init__(self, data): >> wx

Re: [Tutor] Need help printing a pickled data

2013-06-24 Thread Marc Tompkins
On Mon, Jun 24, 2013 at 3:48 PM, Matt D wrote: > > def __init__(self, data): > > wx.PyEvent.__init__(self) > > # this line *binds* this class to a certain type of event, > > wxDATA_EVENT > > self.SetEventType (wxDATA_EVENT) > > # and this is the actual data >

Re: [Tutor] Need help printing a pickled data

2013-06-24 Thread Alan Gauld
On 24/06/13 23:05, Matt D wrote: I have been unable to find a way to write pickled data to text file. Probably because pickled data is not plain text. You need to use binary mode. However... def __init__(self, data): wx.PyEvent.__init__(self) self.SetEventType (wxDATA_

Re: [Tutor] Need help printing a pickled data

2013-06-24 Thread Matt D
On 06/24/2013 06:05 PM, Matt D wrote: > I have been unable to find a way to write pickled data to text file. > My last attempt was to add the last two lines: > > # the dataevent class -- stores the data that gets transmitted when the > event occurs. > #it is the data in text fields, stored in sel

Re: [Tutor] Need help printing a pickled data

2013-06-24 Thread Steven D'Aprano
On Mon, Jun 24, 2013 at 06:05:37PM -0400, Matt D wrote: > I have been unable to find a way to write pickled data to text file. Normally you write pickled data to a file like this: import pickle data = {'something': 'goes', 'here': 42} with open("/path/to/file/name.pickle", "rb") as f: pickl

[Tutor] Need help printing a pickled data

2013-06-24 Thread Matt D
I have been unable to find a way to write pickled data to text file. My last attempt was to add the last two lines: # the dataevent class -- stores the data that gets transmitted when the event occurs. #it is the data in text fields, stored in self.data as a dictionary, which is basically a c++ m