Unpickle patch: cannot instantiate 'WindowsPath' on your system
Hello, I hope that I am writing to the right list. Python 3.7.4 on GNU/Linux Parabola 5.3.1-gnu-1 x86_64 AMD Issue: I got a .pickle which had some WindowsPath inside. I was unable to unpickle like this: ┌ │ import pickle as pkl │ from pathlib import Path, PureWindowsPath, PurePath, PurePosixPath, WindowsPath, PosixPath │ fname = "ohw_analysis.pickle" │ # fpath = PureWindowsPath(fname) │ fpath = Path(fname) │ with open(fpath, "rb") as fd: │ # Works in Winbug$ only │ ohw_analysis = pkl.load(fd) └ I tried to create my own class to override =_new= in =Path=, but that did not work, because (I assume that) the pickle data was pointing to =pathlib=. I did not know how to solve this, so I modified the code for pathlib.py Solution: The modification allowed me to unpickle the file, and I think that it would not break =pathlib=. I have seen this issue reported elsewhere, and I thought that it could be useful to others. Extra: I really hope that this is useful. Although I am not asking for help, if there was a better solution, let me know. I don't want a Github account (Micro$oft). Thanks! -- https://mail.python.org/mailman/listinfo/python-list
read serial data from a barcode reader/scanner using python
Hi. is there a way to program python to read serial data from a barcode reader/scanner and then using the parallel port of the PC to activate an electromagnetic door lock. edgar -- http://mail.python.org/mailman/listinfo/python-list
Help on PyQt4 QProcess
Dear friends,
I need execute an external program from a gui using PyQt4, to avoid
that hang the main thread, i must connect the signal "finished(int)"
of a QProcess to work properly.
for example, why this program don't work?
from PyQt4.QtCore import QProcess
pro = QProcess() # create QProcess object
pro.connect(pro, SIGNAL('started()'), lambda
x="started":print(x))# connect
pro.connect(pro, SIGNAL("finished(int)"), lambda
x="finished":print(x))
pro.start('python',['hello.py'])# star hello.py program
(contain print("hello world!"))
timeout = -1
pro.waitForFinished(timeout)
print(pro.readAllStandardOutput().data())
output:
started
0
b'hello world!\n'
see that not emit the signal finished(int)
I'm using Python 3.2 and PyQt 4.8.4 under winxp 32bit.
best regards,
--
http://mail.python.org/mailman/listinfo/python-list
Re: Help on PyQt4 QProcess
On Aug 19, 1:56 pm, Phil Thompson wrote:
> On Fri, 19 Aug 2011 10:15:20 -0700 (PDT), Edgar Fuentes
>
>
>
>
>
>
>
>
>
> wrote:
> > Dear friends,
>
> > I need execute an external program from a gui using PyQt4, to avoid
> > that hang the main thread, i must connect the signal "finished(int)"
> > of a QProcess to work properly.
>
> > for example, why this program don't work?
>
> > from PyQt4.QtCore import QProcess
> > pro = QProcess() # create QProcess object
> > pro.connect(pro, SIGNAL('started()'), lambda
> > x="started":print(x)) # connect
> > pro.connect(pro, SIGNAL("finished(int)"), lambda
> > x="finished":print(x))
> > pro.start('python',['hello.py']) # star hello.py program
> > (contain print("hello world!"))
> > timeout = -1
> > pro.waitForFinished(timeout)
> > print(pro.readAllStandardOutput().data())
>
> > output:
>
> > started
> > 0
> > b'hello world!\n'
>
> > see that not emit the signal finished(int)
>
> Yes it is, and your lambda slot is printing "0" which is the return code
> of the process.
>
> Phil
Ok, but the output should be:
started
b'hello world!\n'
finished
no?.
thanks Phil
--
http://mail.python.org/mailman/listinfo/python-list
Re: Help on PyQt4 QProcess
On Aug 19, 4:21 pm, Carl Banks wrote:
> On Friday, August 19, 2011 12:55:40 PM UTC-7, Edgar Fuentes wrote:
> > On Aug 19, 1:56 pm, Phil Thompson
> > wrote:
> > > On Fri, 19 Aug 2011 10:15:20 -0700 (PDT), Edgar Fuentes
> > > wrote:
> > > > Dear friends,
>
> > > > I need execute an external program from a gui using PyQt4, to avoid
> > > > that hang the main thread, i must connect the signal "finished(int)"
> > > > of a QProcess to work properly.
>
> > > > for example, why this program don't work?
>
> > > > from PyQt4.QtCore import QProcess
> > > > pro = QProcess() # create QProcess object
> > > > pro.connect(pro, SIGNAL('started()'), lambda
> > > > x="started":print(x)) # connect
> > > > pro.connect(pro, SIGNAL("finished(int)"), lambda
> > > > x="finished":print(x))
> > > > pro.start('python',['hello.py']) # star hello.py program
> > > > (contain print("hello world!"))
> > > > timeout = -1
> > > > pro.waitForFinished(timeout)
> > > > print(pro.readAllStandardOutput().data())
>
> > > > output:
>
> > > > started
> > > > 0
> > > > b'hello world!\n'
>
> > > > see that not emit the signal finished(int)
>
> > > Yes it is, and your lambda slot is printing "0" which is the return code
> > > of the process.
>
> > > Phil
>
> > Ok, but the output should be:
>
> > started
> > b'hello world!\n'
> > finished
>
> > no?.
>
> > thanks Phil
>
> Two issues. First of all, your slot for the finished function does not have
> the correct prototype, and it's accidentally not throwing an exception
> because of your unnecessary use of default arguments. Anyway, to fix that,
> try this:
>
> pro.connect(pro, SIGNAL("finished(int)"), lambda v, x="finished":print(x))
>
> Notice that it adds an argument to the lambda (v) that accepts the int
> argument of the signal. If you don't have that argument there, the int
> argument goes into x, which is why Python prints 0 instead of "finished".
>
> Second, processess run asynchrously, and because of line-buffering, IO can
> output asynchronously, and so there's no guarantee what order output occurs.
> You might try calling the python subprocess with the '-u' switch to force
> unbuffered IO, which might be enough to force synchronous output (depending
> on how signal/slot and subprocess semantics are implemented).
>
> Carl Banks
Thanks Carl, your intervention was very helpful for me, this solve my
semantic error. I need to study more about signal/slots and process.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Help on PyQt4 QProcess
On Aug 20, 4:36 am, Phil Thompson wrote:
> On Fri, 19 Aug 2011 14:32:12 -0700 (PDT), Edgar Fuentes
>
>
>
>
>
>
>
>
>
> wrote:
> > On Aug 19, 4:21 pm, Carl Banks wrote:
> >> On Friday, August 19, 2011 12:55:40 PM UTC-7, Edgar Fuentes wrote:
> >> > On Aug 19, 1:56 pm, Phil Thompson
> >> > wrote:
> >> > > On Fri, 19 Aug 2011 10:15:20 -0700 (PDT), Edgar Fuentes
> >> > > wrote:
> >> > > > Dear friends,
>
> >> > > > I need execute an external program from a gui using PyQt4, to
> avoid
> >> > > > that hang the main thread, i must connect the signal
> >> > > > "finished(int)"
> >> > > > of a QProcess to work properly.
>
> >> > > > for example, why this program don't work?
>
> >> > > > from PyQt4.QtCore import QProcess
> >> > > > pro = QProcess() # create QProcess object
> >> > > > pro.connect(pro, SIGNAL('started()'), lambda
> >> > > > x="started":print(x)) # connect
> >> > > > pro.connect(pro, SIGNAL("finished(int)"), lambda
> >> > > > x="finished":print(x))
> >> > > > pro.start('python',['hello.py']) # star hello.py
> program
> >> > > > (contain print("hello world!"))
> >> > > > timeout = -1
> >> > > > pro.waitForFinished(timeout)
> >> > > > print(pro.readAllStandardOutput().data())
>
> >> > > > output:
>
> >> > > > started
> >> > > > 0
> >> > > > b'hello world!\n'
>
> >> > > > see that not emit the signal finished(int)
>
> >> > > Yes it is, and your lambda slot is printing "0" which is the return
> >> > > code
> >> > > of the process.
>
> >> > > Phil
>
> >> > Ok, but the output should be:
>
> >> > started
> >> > b'hello world!\n'
> >> > finished
>
> >> > no?.
>
> >> > thanks Phil
>
> >> Two issues. First of all, your slot for the finished function does not
> >> have the correct prototype, and it's accidentally not throwing an
> >> exception because of your unnecessary use of default arguments.
> Anyway,
> >> to fix that, try this:
>
> >> pro.connect(pro, SIGNAL("finished(int)"), lambda v,
> >> x="finished":print(x))
>
> >> Notice that it adds an argument to the lambda (v) that accepts the int
> >> argument of the signal. If you don't have that argument there, the int
> >> argument goes into x, which is why Python prints 0 instead of
> "finished".
>
> >> Second, processess run asynchrously, and because of line-buffering, IO
> >> can output asynchronously, and so there's no guarantee what order
> output
> >> occurs. You might try calling the python subprocess with the '-u'
> switch
> >> to force unbuffered IO, which might be enough to force synchronous
> output
> >> (depending on how signal/slot and subprocess semantics are
> implemented).
>
> >> Carl Banks
>
> > Thanks Carl, your intervention was very helpful for me, this solve my
> > semantic error. I need to study more about signal/slots and process.
>
> In which case you should look at the modern, Pythonic connection syntax
> rather than the old one...
>
> pro.started.connect(lambda: print("started"))
> pro.finished.connect(lambda: print("finished"))
>
> Phil
Pythonic, great!, more straightforward.
Thanks again Phil and Carl.
best regards,
Edgar Fuentes
--
http://mail.python.org/mailman/listinfo/python-list
Re: making a valid file name...
Hi,
On 10/17/2006 06:22:45 PM, SpreadTooThin wrote:
> valid =
> ':./,^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
>
not specifying the OS platform, these are not all the characters
that may occur in a filename: '[]{}-=", etc. And '/' is NOT valid.
On a unix platform. And it should be easy to scan the filename and
check every character against the 'valid-string'.
HTH, cu l8r, Edgar.
--
\|||/
(o o) Just curious...
ooO-(_)-Ooo-
--
http://mail.python.org/mailman/listinfo/python-list
FW: Re: [Spambayes] How to create a valid RPM?
ls, On 09/12/2006 11:48:10 AM, [EMAIL PROTECTED] wrote: > >> when I download python-spambayes-1.0rc2-2.src.rpm, install it and >> run rpmbuild -ba ../SPECS/python-spambayes.spec, I get a lot of >> error messages. It complains about a lot of installed but >> unpackaged files. How can I create a valid RPM? > > Dunno. Did you try "python setup.py bdist_rpm"? This is a bit more This gives the same errors. In fact it calls rpmbuild... > general than just SpamBayes. You might get some useful help from > comp.lang.python (aka [email protected]). can anyone of you guys help me? It seems that the spec-file does not contain a valid %files section. Thanks, cu l8r, Edgar. -- \|||/ (o o) Just curious... ooO-(_)-Ooo--- -- http://mail.python.org/mailman/listinfo/python-list
Newbie with some doubts.
Hi everybody, Im newbie to Python (I found it three weeks ago) , in fact Im newbie to programming. I'm being reading and training with the language, but I still wondering about what Classes are used to. Could you please give me some examples?? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie with some doubts.
Thanks, I'll do that. -- http://mail.python.org/mailman/listinfo/python-list
