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] looking for volunteers with testing simple python program

2013-06-25 Thread Alexander
On Tue, Jun 25, 2013 at 2:04 PM, Walter Prins wrote: > Hi Alexander > > > On 23 June 2013 22:46, Alexander wrote: > >> I guess this is for testing, but I have a question. If somebody sends you >> their .pub file (email or otherwise over internet), and a villainous third >> party intercepts that

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] looking for volunteers with testing simple python program

2013-06-25 Thread Walter Prins
Hi Alexander On 23 June 2013 22:46, Alexander wrote: > I guess this is for testing, but I have a question. If somebody sends you > their .pub file (email or otherwise over internet), and a villainous third > party intercepts that .pub file, will they be able to decrypt the data sent > over this

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] mistaken about splitting expressions over lines

2013-06-25 Thread eryksun
On Tue, Jun 25, 2013 at 11:35 AM, Peter Otten <__pete...@web.de> wrote: > eryksun wrote: > >> Constant folding for binary operations has a length limit of 20 for >> sequences: >> >> >>> dis.dis(lambda: '0123456789' + '0123456789' + '0') >> 1 0 LOAD_CONST 3 ('012345

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread Peter Otten
eryksun wrote: > Constant folding for binary operations has a length limit of 20 for > sequences: > > >>> dis.dis(lambda: '0123456789' + '0123456789' + '0') > 1 0 LOAD_CONST 3 ('0123456789 > 0123456789') >

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread eryksun
On Tue, Jun 25, 2013 at 10:11 AM, Peter Otten <__pete...@web.de> wrote: > > In older Pythons for ("alpha" "beta") the compiler would merge the two > strings into one whereas ("alpha" + "beta") would trigger a str.__add__() > call at runtime. Nowadays the peephole optimiser recognizes ("alpha" + > "

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread Peter Otten
Albert-Jan Roskam wrote: > ___ >>From: eryksun >>To: Jim Mooney >>Cc: tutor@python.org >>Sent: Tuesday, June 25, 2013 2:14 PM >>Subject: Re: [Tutor] mistaken about splitting expressions over lines > > > >> > a = ('this' # this way >>... ' string' ' is lon

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread Albert-Jan Roskam
___ >From: eryksun >To: Jim Mooney >Cc: tutor@python.org >Sent: Tuesday, June 25, 2013 2:14 PM >Subject: Re: [Tutor] mistaken about splitting expressions over lines > >    >>> a = ('this'  # this way >    ...      ' string' ' is long') # is more flexible >    >>>

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] mistaken about splitting expressions over lines

2013-06-25 Thread eryksun
On Mon, Jun 24, 2013 at 9:58 PM, Dave Angel wrote: > > Alternatively, you can also use the statement continuation mechanism, > whereby the last character of the line is a backslash. Using that approach > you can break almost anywhere, except within a token or inside a string > literal. Also, the

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