[Python-announce] PyEmpaq 0.3 released
I'm happy to announce the release of PyEmpaq 0.3. PyEmpaq is a simple but powerful Python packer to run any project with any virtualenv dependencies anywhwere. With PyEmpaq you can convert any Python project into a single `.pyz` file with all the project's content packed inside. That single file is everything that needs to be distributed. When the final user executes it, the original project will be expanded, its dependencies installed in a virtualenv, and then executed. Note that no special permissions or privileges are required, as everything happens in the user environment. Both the packaging and the execution are fully multiplatorm. This means that you can pack a project in Linux, Windows, Mac or whatever, and it will run ok in Linux, Windows, Mac or whatever. The only requirement is Python to be already installed. What's new in this version? - Added 'include' and 'exclude' configuration options to have full control on what is inside the packed file. - Reuse the existing project directory only if it has a complete previous installation. - Support the declaration of a minimum Python version to run the packed project. - Expose the .pyz path to the project being run. - Now used logging to expose messages to developer and users, with different verbosity levels. - Set up the proper PATH in the end command environment. - Added a -V/--version option to just print the version and exit. - Run tests (unit and integration) in Linux, MacOS and Windows. You can check the whole documentation, including demos and examples, in the docs page: https://pyempaq.readthedocs.io/en/latest/ The project: https://github.com/facundobatista/pyempaq/ Enjoy, -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org.ar/ Twitter: @facundobatista ___ Python-announce-list mailing list -- python-announce-list@python.org To unsubscribe send an email to python-announce-list-le...@python.org https://mail.python.org/mailman3/lists/python-announce-list.python.org/ Member address: arch...@mail-archive.com
Re: Pycharm IDE
On 20/04/2023 08.59, Thomas Passin wrote: On 4/19/2023 4:06 PM, Mark Bourne wrote: print(f'{LIMIT}) ^ I think this one should be: print(f'{LIMIT}') with the closing quote ;o) Yup a typo! Where's pylint when I need it? but (and you designed it this way - right?) an excellent object-lesson for the OP AND great rationale for why linters are so handy! I am bullish on F-strings, but they can stretch the typing fingers and strain the eyes. Remember the days when pythonista used to make deprecating remarks about the superiority of Python's syntax because we didn't have 'all those braces' (and other punctuation-characters) cluttering-up the code??? -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: PyCharm's strict PEP and not so strict?
NB this reply came only to me (so @Alan will have missed your response to his posting). Have replied on-list (only) - please see earlier comment about email-client behaviors... On 20/04/2023 08.11, Kevin M. Wilson wrote: *What kind of problems are you experiencing with quotes?* If we have some specific examples we can give specific answers. /I have an issue with the 'Light Blub', if I wanted suggestions I'd turn on that option... Assuming it's an option!/ The "light bulb" has little to do with "quotes"! This is one of the advantages of utilising a Python-native IDE (cf a more general-purpose alternative, perhaps with some Python add-on). PyCharm attempts to understand the code it is editing, and apply various lessons or experiences to offer intelligent assistance. Thus, the "light bulb" is an icon indicating that PyCharm had spotted one or more "intention actions". These may be faults in the code, or may be anticipating what you're about to do and offering to do it for you. A red light-bulb indicates that there is an error in the Python code. Whereas, the yellow color indicates opportunity, aka "a light-bulb moment". Hah! Yes, there are times when the icon overlays and obstructs the code, and thus irritates. I believe it can be turned-off (but don't recommend such to coders at your level of skill). Please read the manual, specifically that page (https://www.jetbrains.com/help/pycharm/intention-actions.html) - there's even an F-string code-example! In this case, PyCharm undoubtedly was picking-up that the string was opened by a single-quote but never closed. One of the useful options PyCharm suggests in this case, is to presume that the string is longer than will fit on one line, and it will 'break' the string for you/us and ensure that the correct punctuation is placed at the beginning and end of each fragment of the string - something many of us find either slightly confusing or a nuisance of 'boiler-plate'. To see what it has noticed, the alternative actions are to mouse-click on the light-bulb, or to type Alt+Enter. Interestingly, the latter is called "Show Context Actions" (but is still talking about "Intentions". The description reads "Quick-fixes for highlighted errors and warnings, intention actions for improving and optimizing your code." (https://www.jetbrains.com/help/pycharm/mastering-keyboard-shortcuts.html) You may have noticed some indicators/statistics at the top-right of the editing panel. Green ticks/check-marks, and amber/yellow or red caution-triangles. These similarly indicate problems PyCharm has noticed, or wisdom from which you may choose to benefit. These come from a feature called "inspection". There are some controls enabling adjustment of "inspection severity" (https://www.jetbrains.com/help/pycharm/configuring-inspection-severities.html) which may be worth the reading-time. However, and once again, changing any cannot be recommended to someone at an early stage of Python-experience. *Not really. What is the problem. Use of single versus double quotes is straightforward - use one or the other and make sure they match(opening and closing) You can nest one type inside the other if you need literal quotes. And of course the same applies to triple quotes except you can include newlines inside those.* * * Not stupid typing... Thanks! I use Double quotes, the light blub suggestions aren't, in many cases, relevant to my style of coding, nor of 'english'... I'd like to set my options! Sadly this wouldn't help! If you (can) turn-off such warnings in PyCharm, it will simply delay the inevitable - when the code is executed Python will object to the opening of a single-quote and not finding its matching close. ie the issue is NOT with PyCharm (nor with Python) but ... *PyCharm enables a range of Python-linters. Some by add-in. Some by "External tools"* I was not 'up' on "linters", Thanks for the heads up! Attempted finding a "linter" on jetbrains... I take it that finding a 'linter' for Build #PC-222.4554.11, built on March 15, 2023 Is a matter of hit and miss... Any suggestions? Try a web-search for "Python linters". Linters, I've know a few... (hum along with the music...) have long been a part of the Python eco-system. They have usually been designed to run from Python or 'the command-line'. Accordingly, many can be added into PyCharm from 'the outside'. The original purpose was possibly to guide/nudge coders into the practices recommended by PEP-008 (https://peps.python.org/pep-0008/). This, as you will read, is not about syntax, but more about coding "style". There are many to choose from. Some are more strict than others. Recommendation: (for the good of your blood-pressure) stay away from "highly opinionated" alternatives, such as Black. Try the ones which offer options to turn-on/-off particular situations (as described earlier). "stones" for bull, how do I set up the kind of "checking" I
Re: Python-pickle error
On 4/19/2023 12:14 PM, charles wiewiora wrote: Hello, I am experincing problems with the pickle moducle the folowing code was working before, import pickle number=2 my_pickeld_object=pickle.dumps(number) print("this is my pickled object",{my_pickeld_object},) with open('file.pkl', 'rb') as file: number=pickle.load(file) my_unpickeled_object=pickle.loads(my_pickeld_object) print("this is my unpickeled object",{my_unpickeled_object},) but now i get error Traceback (most recent call last): File "C:\Users\lukwi\Desktop\python\tester2.py", line 5, in with open('file.pkl', 'rb') as file: FileNotFoundError: [Errno 2] No such file or directory: 'file.pkl' That's because you haven't saved anything to a file named "file.pkl". If this code seemed to work in the past, it may have been because there was a file named "file.pkl" left over from some previous experiment. But it's not there now, and even if it were it would not contain your current pickled object. Take a look at .load() and .dump() (instead of .loads() and .dumps(). Maybe they will do what you want a little easier. im get this problem after this, a .pkl came into my Python script files i though this could be a spare file made from python becauce i was doing this first, import pickle number=2 my_pickeld_object=pickle.dumps(number) print("this is my pickled object",{my_pickeld_object},) with open('file.pkl', 'rb') as file: number=pickle.load(file) so i stupidly deleted the file do you know how to fix this? i reinstalled it but it didn't work this is on widnows and on version 3.11.3 on python thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: Pycharm IDE
On 4/19/2023 4:06 PM, Mark Bourne wrote: print(f'{LIMIT}) ^ I think this one should be: print(f'{LIMIT}') with the closing quote ;o) Yup a typo! Where's pylint when I need it? -- https://mail.python.org/mailman/listinfo/python-list
Re: Pycharm IDE
Thomas Passin wrote: On 4/19/2023 1:27 AM, Kevin M. Wilson via Python-list wrote: Ok, I got rid of the "print (f'"I am thinking of a number between 1 to {LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"), I think you misunderstand several things at the same time here. 1. These errors originate from syntax errors. They are basically Python errors. It's possible that behind the scenes, PyCharm is running one or another Python program to detect them, but they are errors in your Python code. 2. print() doesn't care whether you give it an f-string or not, because a f-string is a string too. 3. All strings need to be closed with the same kind of quote they started with. If one is not closed, then Python thinks the string is supposed to continue, and - say- the final parenthesis of the print() function looks like it is part of the string. So Python (or PyCharm) notices that the closing parenthesis of the print() expression is missing. 4. in an f-string, the expression in braces is evaluated and replaced by its string value. So if you try to do this print('{LIMIT}') then that will be printed as is with no substitution - because it is not an f-string. So you will see "{LIMIT}" But you thought you were going to see "42" (if LIMIT == 42, that is). OTOH, print(f'{LIMIT}) ^ I think this one should be: print(f'{LIMIT}') with the closing quote ;o) will substitute the string value of LIMIT before printing the string. Both are legitimate but the first is not what you seem to want. 5. As I posted earlier, you almost certainly do not need to add the "\n". So, some suggestions: - If you are having a problem with some piece of code, try to simplify it down to the smallest bit that shows the problem. - If you are having trouble with f-strings, then think about what you want to achieve and look up information about f-strings with that in mind. - If you are having trouble with the print statement, think what you want it to display and look up information about the print function with that in mind. - If your tool - PyCharm in this case - is producing messages but you don't understand why they are being produced, try to look up information about how and when PyCharm produces error messages Do you see a pattern here? Also note that just because you don't see an error message does not mean that the code is correct. It may be correct from the point of view of Python syntax but that doesn't mean that it will perform correctly nor how you expect. and Pycharm stopped complaining about it... WHY?? Perplexed "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze." Isaiah 43:2 On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson via Python-list wrote: print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the impression that the format specifier 'f' was necessary for the print function, but the double quotes are for the string printed to the user, as a prompt!The Pycharm IDE is showing that it expects a single quotation mark or ')'! No error message is displayed. Perplexed "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze." Isaiah 43:2 On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost wrote: On 4/18/23 19:18, Kevin M. Wilson wrote: Why complain about a 'comma', or a ')'??? print (f'"I am thinking of a number between 1 to {LIMIT}\n") my version says it expects ' first (to close the fstring) then on a new line below it, it mentions the comma and ) I believe that is just showing you after ' it expects you to end the print with ) as you have or , to add additional arguments to print -- https://mail.python.org/mailman/listinfo/python-list
Python-pickle error
Hello, I am experincing problems with the pickle moducle the folowing code was working before, import pickle number=2 my_pickeld_object=pickle.dumps(number) print("this is my pickled object",{my_pickeld_object},) with open('file.pkl', 'rb') as file: number=pickle.load(file) my_unpickeled_object=pickle.loads(my_pickeld_object) print("this is my unpickeled object",{my_unpickeled_object},) but now i get error Traceback (most recent call last): File "C:\Users\lukwi\Desktop\python\tester2.py", line 5, in with open('file.pkl', 'rb') as file: FileNotFoundError: [Errno 2] No such file or directory: 'file.pkl' im get this problem after this, a .pkl came into my Python script files i though this could be a spare file made from python becauce i was doing this first, import pickle number=2 my_pickeld_object=pickle.dumps(number) print("this is my pickled object",{my_pickeld_object},) with open('file.pkl', 'rb') as file: number=pickle.load(file) so i stupidly deleted the file do you know how to fix this? i reinstalled it but it didn't work this is on widnows and on version 3.11.3 on python thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: PyCharm's strict PEP and not so strict?
On 20/04/2023 04.25, Alan Gauld wrote: On 19/04/2023 10:51, Kevin M. Wilson via Python-list wrote: I'm in a bit of a quandary, I want some strict syntax errors to be flagged, OK, You might want to use a "linter" in that case because most tools use the interpreter itself to flag syntax errors. but the use of single quotes vs double quotes! NOT what I need from the 'checker', you dig? Not really. What is the problem. Use of single versus double quotes is straightforward - use one or the other and make sure they match(opening and closing) You can nest one type inside the other if you need literal quotes. And of course the same applies to triple quotes except you can include newlines inside those. What kind of problems are you experiencing with quotes? If we have some specific examples we can give specific answers. "stones" for bull, how do I set up the kind of "checking" I want? That's not a phrase with which I'm familiar but my guess is you need to install a linter tool and then, possibly configure it to flag or hide particular error/warning types to your personal taste. Each tool is different so you will need to read the docs on how to configure it (and how to plumb it into your IDE). Personally I've never felt the need for any stricter error checking than the interpreter provides so I can't offer anything beyond the generic suggestion to use a linter. +1 PyCharm enables a range of Python-linters. Some by add-in. Some by "External tools" (https://www.jetbrains.com/help/pycharm/configuring-third-party-tools.html). Once a linter is made-available, some allow one to tune the application or relaxation of certain 'rules', eg whether commas in a comma-separated list are to be followed by a space. Whether any enable the restriction of quotes use is another matter - probably for the reasons @Alan has already covered. PyCharm auto-magically enters both an opening-quote and a closing-quote whenever start typing a string. The 'trick' is not to delete the close whilst editing. After gaining experience, I have a convention of when to use apostrophes and when double-quotes. These old eyes dislike mixing both in a single expression - but sometimes it is the best course to follow. YMMV! -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: PyCharm's strict PEP and not so strict?
On 19/04/2023 10:51, Kevin M. Wilson via Python-list wrote: > I'm in a bit of a quandary, I want some strict syntax errors to be flagged, OK, You might want to use a "linter" in that case because most tools use the interpreter itself to flag syntax errors. > but the use of single quotes vs double quotes! > NOT what I need from the 'checker', you dig? Not really. What is the problem. Use of single versus double quotes is straightforward - use one or the other and make sure they match(opening and closing) You can nest one type inside the other if you need literal quotes. And of course the same applies to triple quotes except you can include newlines inside those. What kind of problems are you experiencing with quotes? If we have some specific examples we can give specific answers. > "stones" for bull, how do I set up the kind of "checking" I want? That's not a phrase with which I'm familiar but my guess is you need to install a linter tool and then, possibly configure it to flag or hide particular error/warning types to your personal taste. Each tool is different so you will need to read the docs on how to configure it (and how to plumb it into your IDE). Personally I've never felt the need for any stricter error checking than the interpreter provides so I can't offer anything beyond the generic suggestion to use a linter. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
PyCharm's strict PEP and not so strict?
Greetings, I'm in a bit of a quandary, I want some strict syntax errors to be flagged, but the use of single quotes vs double quotes! NOT what I need from the 'checker', you dig? As I've recently returned to the IDE, and no longer have the "stones" for bull, how do I set up the kind of "checking" I want? Thank you, Kevin "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze." Isaiah 43:2 | | Virus-free.www.avg.com | -- https://mail.python.org/mailman/listinfo/python-list
Re: Pycharm IDE
On 4/19/2023 1:27 AM, Kevin M. Wilson via Python-list wrote: Ok, I got rid of the "print (f'"I am thinking of a number between 1 to {LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"), I think you misunderstand several things at the same time here. 1. These errors originate from syntax errors. They are basically Python errors. It's possible that behind the scenes, PyCharm is running one or another Python program to detect them, but they are errors in your Python code. 2. print() doesn't care whether you give it an f-string or not, because a f-string is a string too. 3. All strings need to be closed with the same kind of quote they started with. If one is not closed, then Python thinks the string is supposed to continue, and - say- the final parenthesis of the print() function looks like it is part of the string. So Python (or PyCharm) notices that the closing parenthesis of the print() expression is missing. 4. in an f-string, the expression in braces is evaluated and replaced by its string value. So if you try to do this print('{LIMIT}') then that will be printed as is with no substitution - because it is not an f-string. So you will see "{LIMIT}" But you thought you were going to see "42" (if LIMIT == 42, that is). OTOH, print(f'{LIMIT}) will substitute the string value of LIMIT before printing the string. Both are legitimate but the first is not what you seem to want. 5. As I posted earlier, you almost certainly do not need to add the "\n". So, some suggestions: - If you are having a problem with some piece of code, try to simplify it down to the smallest bit that shows the problem. - If you are having trouble with f-strings, then think about what you want to achieve and look up information about f-strings with that in mind. - If you are having trouble with the print statement, think what you want it to display and look up information about the print function with that in mind. - If your tool - PyCharm in this case - is producing messages but you don't understand why they are being produced, try to look up information about how and when PyCharm produces error messages Do you see a pattern here? Also note that just because you don't see an error message does not mean that the code is correct. It may be correct from the point of view of Python syntax but that doesn't mean that it will perform correctly nor how you expect. and Pycharm stopped complaining about it... WHY?? Perplexed "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze." Isaiah 43:2 On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson via Python-list wrote: print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the impression that the format specifier 'f' was necessary for the print function, but the double quotes are for the string printed to the user, as a prompt!The Pycharm IDE is showing that it expects a single quotation mark or ')'! No error message is displayed. Perplexed "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze." Isaiah 43:2 On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost wrote: On 4/18/23 19:18, Kevin M. Wilson wrote: Why complain about a 'comma', or a ')'??? print (f'"I am thinking of a number between 1 to {LIMIT}\n") my version says it expects ' first (to close the fstring) then on a new line below it, it mentions the comma and ) I believe that is just showing you after ' it expects you to end the print with ) as you have or , to add additional arguments to print -- https://mail.python.org/mailman/listinfo/python-list
Re: Pycharm IDE
On 19/04/2023 21.13, Kevin M. Wilson wrote: Sorry the code snippet I sent was what is written in PyCharm. LIMIT is defined and is not causing an error! PyCharm is flagging the Parentheses at the end. It is not seeing the Parentheses as the end of the print function. def play_game(): number= random.randint(1, LIMIT) print (f'"I am thinking of a number between 1 to {LIMIT}\n") Observe... Look at the color of the parenthesis, it's green!!! !!! = WTH Same question! Please explain: why is there a (single) apostrophe? NB some email clients don't notice list communications and ReplyList - you may need to do that manually... -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Pycharm IDE
Kevin, As mentioned in another response, the format of these messages seems very confused. Please copy-paste all of (the pertinent part of) the code, and ensure that the line-endings are in the correct places, tab/indentation looks correct, etc? (this will allow us to copy the same code into our PyCharm software and see what is happening!) There still appears to be both an apostrophe (') and quotation-marks ("). Do you want the user to see one/both? There was mention of this being an input prompt - hence the question-mark. Are you aware that this could be done as part of the input() function? How about creating a string and then printing that, eg prompt = f'"I am thinking of a number between 1 to {LIMIT}" print( prompt ) NB because of the question asked earlier, the above code is NOT syntactically-correct Python! NBB am assuming there's previous code which defines LIMIT On 19/04/2023 17.27, Kevin M. Wilson via Python-list wrote: Ok, I got rid of the "print (f'"I am thinking of a number between 1 to {LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"), and Pycharm stopped complaining about it... WHY?? Perplexed "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze." Isaiah 43:2 On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson via Python-list wrote: print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the impression that the format specifier 'f' was necessary for the print function, but the double quotes are for the string printed to the user, as a prompt!The Pycharm IDE is showing that it expects a single quotation mark or ')'! No error message is displayed. Perplexed "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze." Isaiah 43:2 On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost wrote: On 4/18/23 19:18, Kevin M. Wilson wrote: Why complain about a 'comma', or a ')'??? print (f'"I am thinking of a number between 1 to {LIMIT}\n") my version says it expects ' first (to close the fstring) then on a new line below it, it mentions the comma and ) I believe that is just showing you after ' it expects you to end the print with ) as you have or , to add additional arguments to print -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list