Re: How to change '\\' to '\'
Yes, you are right, it's just the way Python display the '\'. Thank you. Gregory Ewing at 2018/9/28 PM 02:02 wrote: Jach Fong wrote: I get a string item, for example path[0], from path = os.get_exec_path() It's something like "\\Borland\\Bcc55\\Include" It doesn't actually have double backslashes in it, that's just a result of how the string is being displayed. No conversion is needed. --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- https://mail.python.org/mailman/listinfo/python-list
cx_Freeze window app path question
[I tried without success to post this question to the cx_Freeze mailing list (which seems to have suddenly died at the beginning of the year).] You freeze an app on Windows producing a 'build' directory. The contents of that build directory get installed in some arbitrary location. When you run the .exe from that arbitrary location, is it guaranteed that it won't try to find/use python modules or libraries from outside that installed build directory tree? -- Grant Edwards grant.b.edwardsYow! As President I have at to go vacuum my coin gmail.comcollection! -- https://mail.python.org/mailman/listinfo/python-list
Re: What's needed for jpegtran in Python 3?
Chris Angelico wrote: > On Fri, Sep 28, 2018 at 3:51 AM Chris Green wrote: > > > > Chris Angelico wrote: > > > On Fri, Sep 28, 2018 at 2:51 AM Chris Green wrote: > > > > > > > > I'm converting an existing Python2 program to Python3, it uses > > > > jpegtran and I can't find what to install to get this in Python3. > > > > > > > > Can anyone advise what I need to install in Python3? > > > > > > > > > > Do you mean this? > > > > > > https://pypi.org/project/jpegtran-cffi/ > > > > > > I can't find anything called just "jpegtran" for either Py2 or Py3, > > > but that one claims to work on 3.3+ as well as 2.6 and 2.7. > > > > > I think that must be what I have already installed, it doesn't make > > the module available in Python 3, it just says this when I try and > > install it:- > > > > root@t470:~# pip install jpegtran-cffi > > Requirement already satisfied: jpegtran-cffi in > > /usr/local/lib/python2.7/dist-packages > > Requirement already satisfied: cffi>=0.8 in > > /usr/lib/python2.7/dist-packages > (from jpegtran-cffi) > > root@t470:~# > > > > Python 3 isn't going to find that is it? > > Ah! Correct. What you need to do is use pip from your Python 3 > installation. The safest way is: > > python3 -m pip install jpegtran-cffi > > but you may be able to abbreviate it to just: > > pip3 install jpegtran-cffi > > ie just change "pip" to "pip3". > OK, yes, after a bit of trouble (I needed python3-cffi as well) I've got it installed now, thank you! -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: JPEGImage() hangs
Brian Oney wrote: > Could you please try another tool like `convert'? E.g. > > $ convert 102_PANA/P1020466.JPG test.png > > > What does that say? Well, after having returned home with the laptop where this was failing and doing exactly the same thing again, it now works. However it did take several seconds before the >>> prompt appeared. The problem seems to be intermittent as I'm calling the function while importing images from a camera SD card and, sometimes, the import hangs but most times it works OK. I'll see if I can see anything common to when it hangs. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: JPEGImage() hangs
Chris Green wrote: > Brian Oney wrote: > > Could you please try another tool like `convert'? E.g. > > > > $ convert 102_PANA/P1020466.JPG test.png > > > > > > What does that say? > > Well, after having returned home with the laptop where this was > failing and doing exactly the same thing again, it now works. However > it did take several seconds before the >>> prompt appeared. > > The problem seems to be intermittent as I'm calling the function while > importing images from a camera SD card and, sometimes, the import > hangs but most times it works OK. > > I'll see if I can see anything common to when it hangs. > ... and the result is that it now hangs several images later in the sequence! It's almost as if some resource is running out. If I try convert on the 'problem' image it too hangs absolutely solidly needing a 'kill -9'. After some experimentation OK, it's some sort of file accessibility problem between the SD card and the computer:- Running 'convert 102_PANA/P1020493.JPG /tmp/xyz.png' hangs So 'kill -9' the convert Run 'cp 102_PANA/P1020493.JPG /tmp/fred' takes several seconds but returns Running 'convert 102_PANA/P1020493.JPG /tmp/xyz.png' now works My python program that uses jpegtran now also works OK Wierd! However it would seem it's not an issue with Python or the jpegtran module. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
EuroPython 2019: RFP for Venues
Dear EuroPython'istas, We are happy to announce that we have started the RFP for venues to host the EuroPython 2019 conference. We have sent out the details to almost 40 venues. For more details about the RFP, please see our blog post: https://www.europython-society.org/post/178541594370/europython-2019-rfp-for-venues Many thanks to everyone who had submitted contact details and venue suggestions after our call. We have tried to include all of them in the list of direct recipients. Feel free to forward the blog post to additional suitable venues. Many thanks, -- EuroPython Society Board https://www.europython-society.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: I am not able to run Python in Powershell
On Friday, 1 September 2017 19:37:41 UTC+1, The Cat Gamer wrote: > fter I installed Python I try to open it in Powershell, by typing > python/python.exe. > It gives me an error: > python : The term 'python' is not recognized as the name of a cmdlet, > function, script file, or operable program. Check the spelling of the name, > or if a path was included, verify that the path is correct and try again. > At line:1 char:1 > + python > + ~~ > + CategoryInfo : ObjectNotFound: (python:String) [], > CommandNotFoundException > + FullyQualifiedErrorId : CommandNotFoundException > This happens with version 3 and version 2. The newest versions and the > older versions none of them makes me able to open Python in Windows > Powershell. Are you guys aware of a fix? > > (I already tried the environment fix and that didnt work as well) -- https://mail.python.org/mailman/listinfo/python-list
Re: JPEGImage() hangs
On Fri, 28 Sep 2018 15:01:41 +0100, Chris Green wrote: > Chris Green wrote: >> Brian Oney wrote: >> > Could you please try another tool like `convert'? E.g. >> > >> > $ convert 102_PANA/P1020466.JPG test.png >> > >> > >> > What does that say? >> >> Well, after having returned home with the laptop where this was >> failing and doing exactly the same thing again, it now works. However >> it did take several seconds before the >>> prompt appeared. >> >> The problem seems to be intermittent as I'm calling the function while >> importing images from a camera SD card and, sometimes, the import >> hangs but most times it works OK. >> >> I'll see if I can see anything common to when it hangs. >> > ... and the result is that it now hangs several images later in the > sequence! It's almost as if some resource is running out. > > If I try convert on the 'problem' image it too hangs absolutely > solidly needing a 'kill -9'. > > After some experimentation OK, it's some sort of file > accessibility problem between the SD card and the computer:- > > Running 'convert 102_PANA/P1020493.JPG /tmp/xyz.png' hangs > > So 'kill -9' the convert > > Run 'cp 102_PANA/P1020493.JPG /tmp/fred' takes several seconds but returns [snip] If copying that particular file takes longer than copying other files, I'd start to suspect that it's stored in a failing spot in memory. Is 102_PANA/P1020493.JPG being read from a camera's flash memory? Does "convert" hang on /tmp/fred? Does 102_PANA/P1020493.JPG have an unusual size? Can you use smartctl to ask the storage device if it's encountering many errors? -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list
Re: JPEGImage() hangs
Peter Pearson wrote: > On Fri, 28 Sep 2018 15:01:41 +0100, Chris Green wrote: > > Chris Green wrote: > >> Brian Oney wrote: > >> > Could you please try another tool like `convert'? E.g. > >> > > >> > $ convert 102_PANA/P1020466.JPG test.png > >> > > >> > > >> > What does that say? > >> > >> Well, after having returned home with the laptop where this was > >> failing and doing exactly the same thing again, it now works. However > >> it did take several seconds before the >>> prompt appeared. > >> > >> The problem seems to be intermittent as I'm calling the function while > >> importing images from a camera SD card and, sometimes, the import > >> hangs but most times it works OK. > >> > >> I'll see if I can see anything common to when it hangs. > >> > > ... and the result is that it now hangs several images later in the > > sequence! It's almost as if some resource is running out. > > > > If I try convert on the 'problem' image it too hangs absolutely > > solidly needing a 'kill -9'. > > > > After some experimentation OK, it's some sort of file > > accessibility problem between the SD card and the computer:- > > > > Running 'convert 102_PANA/P1020493.JPG /tmp/xyz.png' hangs > > > > So 'kill -9' the convert > > > > Run 'cp 102_PANA/P1020493.JPG /tmp/fred' takes several seconds but returns > [snip] > > If copying that particular file takes longer than copying other files, > I'd start to suspect that it's stored in a failing spot in memory. Is > 102_PANA/P1020493.JPG being read from a camera's flash memory? Does > "convert" hang on /tmp/fred? Does 102_PANA/P1020493.JPG have an unusual > size? Can you use smartctl to ask the storage device if it's > encountering many errors? > Thanks, that sounds like a good explanation. The SD card has been in use for quite a while so it might have some problems. I think I'll retire it and see how things go. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: Anaconda with Python 3.7
On Sep 3, 2018, gvim wrote (in article <[email protected]>): > Anyone have any idea when Anaconda might ship a version compatible with > Python 3.7. I sent them 2 emails but no reply. I heard a rumor today that it will be a few more months. They are short on resources and are also dealing with issues with dependency management. In any case miniconda is available for 3.7 so it is worth checking to see if it has the packages that you need. (And if it’s just missing a few you can see if pip will install those). -- Russell -- https://mail.python.org/mailman/listinfo/python-list
Re: JPEGImage() hangs
On 28Sep2018 20:12, Chris Green wrote: Peter Pearson wrote: On Fri, 28 Sep 2018 15:01:41 +0100, Chris Green wrote: > Chris Green wrote: >> Brian Oney wrote: >> > Could you please try another tool like `convert'? E.g. >> > >> > $ convert 102_PANA/P1020466.JPG test.png >> > >> > What does that say? >> >> Well, after having returned home with the laptop where this was >> failing and doing exactly the same thing again, it now works. However >> it did take several seconds before the >>> prompt appeared. >> >> The problem seems to be intermittent as I'm calling the function while >> importing images from a camera SD card and, sometimes, the import >> hangs but most times it works OK. Can you separate the conversion from the copy? Copy the images off, run convert against the copies? That would give you more info as to whether it was the copy (implying an issue with the SD card as Peter suggests) or some pathologial image data (eg spinning out convert). Also, you can strace the hanging process; I'm a big fan of this for diagnostic purposes. A "hanging" process will normally be either spinning (using lots of CPU, or a mix of CPU and OS calls), or blocked (using no CPU at all while it waits for a OS call to complete). If it is blocked doing a read() then you immediately suspect the device from which the read is taking place. WRT to the strace, find the pid with "ps" then: strace -p pid-of-process It is usually astonishingly helpful in telling you about the underlying activity causing the problem. Also, if the SD card is emitting errors these should show in the output of dmesg. (OTOH if the SD cards internals are taking forever, perhaps doing repeated _internal_ access to the data) then this may not be apparent. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
What's an elegant way to test for list index existing?
I have a list created by:- fld = shlex.split(ln) It may contain 3, 4 or 5 entries according to data read into ln. What's the neatest way of setting the fourth and fifth entries to an empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels clumsy somehow. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: What's an elegant way to test for list index existing?
On Friday, September 28, 2018 at 11:03:17 AM UTC-7, Chris Green wrote:
> I have a list created by:-
>
> fld = shlex.split(ln)
>
> It may contain 3, 4 or 5 entries according to data read into ln.
> What's the neatest way of setting the fourth and fifth entries to an
> empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels
> clumsy somehow.
How about this?
from itertools import chain, repeat
temp = shlex.split(ln)
fld = list(chain(temp, repeat("", 5-len(temp
--
https://mail.python.org/mailman/listinfo/python-list
Re: Which class method is being called when we declare below expression?
Ben Finney writes: > Ajay Patel writes: > > > L = [1,2,3] > > That's not an expression; it is an assignment statement. > > The right-hand side is an expression. […] in this case, [the object] a new > instance of 'list' […] is the result of evaluating the right-hand side > of the expression. I goofed there. That should end with "[…] evaluating the expression on the right-hand side". > The statement then assigns the reference 'L' to that object. -- \ “We have clumsy, sputtering, inefficient brains…. It is a | `\ *struggle* to be rational and objective, and failures are not | _o__) evidence for an alternative reality.” —Paul Z. Myers, 2010-10-14 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: What's an elegant way to test for list index existing?
Chris Green writes: > I have a list created by:- > > fld = shlex.split(ln) > > It may contain 3, 4 or 5 entries according to data read into ln. Because of what an index means for the 'list' type, that's equivalent to saying "the result of `len(fld)` may be 3, 4, or 5". > What's the neatest way of setting the fourth and fifth entries to an > empty string if they don't (yet) exist? You have the right idea: testing the length of the object is a correct and expressive way to ask "is there an item at this index in the list". > Using 'if len(fld) < 4:' feels clumsy somehow. One reason I finx that clumsy is that you're testing against a hard-coded value; and you'd have to write a loop to get the value each time. You can use a comprehension, iterating over the full range of index you want:: words = shlex.split(line) padding_length = 5 words_padded = [ (words[index] if index < len(words)) for index in range(padding_length)] That accomplishes the construction of the padded list in a single expression, hopefully expressive, and definitely making use of whatever optimisations the in-built comprehension mechanics provide. -- \ “Pray, v. To ask that the laws of the universe be annulled in | `\ behalf of a single petitioner confessedly unworthy.” —Ambrose | _o__) Bierce, _The Devil's Dictionary_, 1906 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
