From arj.python at gmail.com Wed Jan 1 02:00:08 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 1 Jan 2020 11:00:08 +0400 Subject: Packaging Sqlite DB and Pictures with Executable file Message-ID: Greetings list, Sometimes ago i was asking how to add Sqlite files to zipapp files here , i still haven't figured it out. Finally the solution i used was PyInstaller itself. Kushal Das shared an article of a RAT tool which uses Python. That got me wondering, PyDevs here are sweating on distribution and this one is surfing the internet at lightening speed ... Steve Dower suggested some solutions which got me into the mood of not abandoning native exec file (I was going to ship pure python code files). Another friend encouraged me with retrying Pyinstaller itself. Sure enough after gliding through many internet pipes, i solved the issue. Here is the solution ! Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius From arj.python at gmail.com Wed Jan 1 02:22:18 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 1 Jan 2020 11:22:18 +0400 Subject: Python, Be Bold! Message-ID: Greetings list, I wanted to make some suggestion about the Python interpreter but since it's more high-level, i decided to post it here instead of python-ideas. Well, concerning distributing Python apps, a natural way is to compile to native executables. But, another way is to have a python-specific executable which specifically requires the Python interpreter to be installed on the system. To that end, i propose -- Self-updating Python distributions -- Distributions which notify about new releases -- Easy compilation to python-specific executable (.pyz is a good candidate) -- More robust native Gui facilities Python has evolved quite a lot, it's past the scripting level. It has it's own VM. I suggest Python consider the Java approach. Java distributions are more os-integrated than Python's. Python is like <> Compare to Java, let's say you want to download a Java app, the popular Maltego for example. If you don't have Java installed it will tell: <> Also Python adopts a .jar file approach, making .pyz generation more intelligent. .jar file generation is a breeze. Gui side, i suggest some more powerful tools. In Java using JavaFx, you can really build cool apps, in Python you don't have it natively. You can use stylesheets etc (which PyQt has to some extent). Java's standard library even has splash-screen utilities. It shows that they care for app-making. Well, even while many say that Java is bloated, it still finds it's way in many different hardwares. The idea is not to copy-cat Java but to learn from it. Python is way cooler, but it needs some tuning. Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius From o1bigtenor at gmail.com Wed Jan 1 08:17:27 2020 From: o1bigtenor at gmail.com (o1bigtenor) Date: Wed, 1 Jan 2020 07:17:27 -0600 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Wed, Jan 1, 2020 at 1:24 AM Abdur-Rahmaan Janhangeer wrote: > > Greetings list, > > I wanted to make some suggestion about the Python interpreter but since > it's more high-level, i decided to post it here instead of python-ideas. > > Well, concerning distributing Python apps, a natural way is to compile to > native executables. But, another way is to have a python-specific > executable which specifically requires the Python interpreter to be > installed on the system. To that end, i propose > > -- Self-updating Python distributions > -- Distributions which notify about new releases > -- Easy compilation to python-specific executable (.pyz is a good candidate) > -- More robust native Gui facilities > Speaking as just a very newbie very unskilled computer programmer I can tell you that if Python decided to go to self-updating that that would be the day that I stopped using Python. Why? I spent a considerable amount of time investigating containers and when it became clear that the version that I was looking into had forced me into accepting this self-updating I tried to figure out a way to 'control' that feature. I won't bore you with the whole mess but the end result was that the only way that I could regain control over my computer - - - - I couldn't even delete major parts of that subsystem - - - - well it was a complete reinstall. That, imo a very very M$ solution is something I spent many hours trying NOT to do so anything that wants to take me to such again - - - - it will get dropped. To the powers that be - - - - please do NOT program Python to be self-updating!!!!!! Regards From random832 at fastmail.com Wed Jan 1 16:04:00 2020 From: random832 at fastmail.com (Random832) Date: Wed, 01 Jan 2020 16:04:00 -0500 Subject: Does the argparse generate a wrong help message? In-Reply-To: <63c01a3b-6e47-48e7-9405-d144371b54d6@googlegroups.com> References: <63c01a3b-6e47-48e7-9405-d144371b54d6@googlegroups.com> Message-ID: <75a4aa1c-8546-4548-ac04-9244b160cd56@www.fastmail.com> On Fri, Dec 27, 2019, at 23:08, jfong at ms4.hinet.net wrote: > > > optional arguments: > > > -h, --help show this help message and exit > > > --foo [FOO] foo help > > > --goo GOO goo help > > > > > > D:\Works\Python>py test.py --foo 1 --goo 2 > > > 1 ['2'] > > So the square bracket means optional, not list? My misunderstanding:-( To be clear, the brackets in the print output do mean a list, and it is because nargs=1 produces a list rather than the default (no nargs) which is to produce a single value. This is not normally visible to the end user (it's just a difference in how your program consumes the one mandatory argument), so it's not reflected in the help output. Square brackets in the help output mean an optional argument. From jfong at ms4.hinet.net Wed Jan 1 19:54:40 2020 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Wed, 1 Jan 2020 16:54:40 -0800 (PST) Subject: Does the argparse generate a wrong help message? In-Reply-To: References: <63c01a3b-6e47-48e7-9405-d144371b54d6@googlegroups.com> <75a4aa1c-8546-4548-ac04-9244b160cd56@www.fastmail.com> Message-ID: <8578308e-2d58-4de0-bf71-aa887e1df2d2@googlegroups.com> Random832? 2020?1?2???? UTC+8??5?04?36???? > On Fri, Dec 27, 2019, at 23:08, jfong at ms4.hinet.net wrote: > > > > optional arguments: > > > > -h, --help show this help message and exit > > > > --foo [FOO] foo help > > > > --goo GOO goo help > > > > > > > > D:\Works\Python>py test.py --foo 1 --goo 2 > > > > 1 ['2'] > > > > So the square bracket means optional, not list? My misunderstanding:-( > > To be clear, the brackets in the print output do mean a list, and it is because nargs=1 produces a list rather than the default (no nargs) which is to produce a single value. This is not normally visible to the end user (it's just a difference in how your program consumes the one mandatory argument), so it's not reflected in the help output. Square brackets in the help output mean an optional argument. Yes, I have noticed my misunderstanding. I thought [FOO] in "--foo [FOO]" is a list until Chris had reminded me:-) Thank you for clarifying it in detail. --Jach From jamtlu at gmail.com Wed Jan 1 11:34:41 2020 From: jamtlu at gmail.com (James Lu) Date: Wed, 1 Jan 2020 11:34:41 -0500 Subject: Front end In-Reply-To: References: Message-ID: I would use software like Airtable. You set the columns, Airtable produces a type-checked form. Every spreadsheet also comes with its own API, so you can exfiltrate the data programmatically easily. On Sat, Dec 28, 2019, 10:36 L A Smit wrote: > Hi > > Don't know if this is the correct subject but i want a program like an > invoice, You make an invoice and save it and the next one is ready to > use. I am completely new to programming and want this program for myself. > > > I want to use python to do it. Have already build the program but don't > know how to put it in usable format. I hope you understand what i mean. > > Ex: Input. > > Quote Nr: > > Client: > > Product: > > Then there will be costs and in the end a cost per product. > > In the end a save button to save quote with input from line 1 and 2. > > Then the template is ready for next input. > > I understand that there is probably hundreds of these programs but to > teach myself i want to wright my own program and then i can update it > when needed. > > > > Thx > > > L Smit > > -- > https://mail.python.org/mailman/listinfo/python-list > From PythonList at DancesWithMice.info Thu Jan 2 00:01:55 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 2 Jan 2020 18:01:55 +1300 Subject: Friday Finking: Source code organisation In-Reply-To: <20191229044927.GA50701@cskk.homeip.net> References: <20191229044927.GA50701@cskk.homeip.net> Message-ID: On 29/12/19 5:49 PM, Cameron Simpson wrote: > On 29Dec2019 09:49, Chris Angelico wrote: >> "Define before use" is a broad principle that I try to follow, even >> when the code itself doesn't mandate this. This generally means that >> "if name is main" is the very last thing in the file, and if there's a >> main() function or equivalent, that's usually just before that. Any >> metaprogramming goes right at the top; sometimes this is mandated (if >> I write a decorator function, it has to be above the functions it's >> decorating), but even if it's not, metaprogramming goes before the >> mainline. > > For main, i have the opposite habit. If a module has a main() function > for command line use I usually want that right up the front: > > ?#!/usr/bin/env python3 > ?.... > ?import... > > ?def main(argv=None): > ?? ... main command line ... > > ?classes, functions, etc > > ?if __name__ == '__main__': > ?? sys.exit(main(sys.argv)) > > My reasoning here is that I want the main programme obvious up front. > > But then I loosely follow "define before use" after that. OK, I'll bite: 1 the reader (one assumes) starts at the top, then scrolls all the way to the bottom to find if...__main___, but is then directed to search for the def main... which is all the way back up to the top! 2 if instead of a main(), that code was under if ... __main__ would that be an equally reasonable and "obvious" place to find it? -- Regards =dn From arj.python at gmail.com Thu Jan 2 02:19:01 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Jan 2020 07:19:01 +0000 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: if not self-updating, at least the ability to update Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius From cs at cskk.id.au Thu Jan 2 02:46:37 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Thu, 2 Jan 2020 18:46:37 +1100 Subject: Friday Finking: Source code organisation In-Reply-To: References: Message-ID: <20200102074637.GA27704@cskk.homeip.net> On 02Jan2020 18:01, DL Neil wrote: >On 29/12/19 5:49 PM, Cameron Simpson wrote: >>For main, i have the opposite habit. If a module has a main() function >>for command line use I usually want that right up the front: >> >> ?#!/usr/bin/env python3 >> ?.... >> ?import... >> >> ?def main(argv=None): >> ?? ... main command line ... >> >> ?classes, functions, etc >> >> ?if __name__ == '__main__': >> ?? sys.exit(main(sys.argv)) >> >>My reasoning here is that I want the main programme obvious up front. >> >>But then I loosely follow "define before use" after that. > >OK, I'll bite: > >1 the reader (one assumes) starts at the top, then scrolls all the way >to the bottom to find if...__main___, but is then directed to search >for the def main... which is all the way back up to the top! If they scrolled, they'd have seen the main() function. I consider it akin to the opening comment/docstring: I want the reader to know pretty immediately that this has a meaningful command line mode. >2 if instead of a main(), that code was under if ... __main__ would >that be an equally reasonable and "obvious" place to find it? Well... Inline code under the if...__main__ stuff cannot be called as a function; I usually consider the main() function a reusable component. The boilerplate under if...__main__ at the bottom is just the call to it for when the module is used with "python -m". But main itself is standalone. So it won't be under the if...__main__; the only real discussion is where to put it. Cheers, Cameron Simpson From rosuav at gmail.com Thu Jan 2 03:38:42 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 2 Jan 2020 19:38:42 +1100 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Thu, Jan 2, 2020 at 6:20 PM Abdur-Rahmaan Janhangeer wrote: > > if not self-updating, at least the ability to update > That's a package manager's job. $ sudo apt update $ sudo apt upgrade Job done. The wheel does not need to be reinvented. ChrisA From arj.python at gmail.com Thu Jan 2 04:41:14 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Jan 2020 13:41:14 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: i wonder who uses windows On Thu, 2 Jan 2020, 12:38 Chris Angelico, wrote: > On Thu, Jan 2, 2020 at 6:20 PM Abdur-Rahmaan Janhangeer > wrote: > > > > if not self-updating, at least the ability to update > > > > That's a package manager's job. > > $ sudo apt update > $ sudo apt upgrade > > Job done. The wheel does not need to be reinvented. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From torriem at gmail.com Thu Jan 2 11:02:35 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 2 Jan 2020 09:02:35 -0700 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On 1/2/20 2:41 AM, Abdur-Rahmaan Janhangeer wrote: > i wonder who uses windows If this kind of thing is important to a user , what you propose would probably be the responsibility of the entity that is producing a Python distribution, such as Anaconda. Usually in such cases these distributions are not targeted at developers per se, but scientific users who write small programs to solve particular problems. And it may be appropriate in that case. Python is just a language specification and some tools (including a reference implementation of the interpreter and standard library). It's not an IDE and it's not a software distribution. I know that other languages have turned themselves into such things. Particularly node.js with npm, and that has been a real mess on occasion. I haven't heard anything about Java being like this, though. I guess Visual Studio has added a package manager. However that's separate from the language itself (C#, C++, etc). How would you determine what should be updated? The core libraries are already updated with the interpreter version, and have some dependency on the interpreter version. You seem to be suggesting that third-party libraries from PyPi or other places should automatically update, and that seems like a bad idea to me, as they each operate under their own standards of API compatibility, quality, and so forth. All you have to do is look at the mess that is npm in node.js to see what this idea has some real problems if you were to update everything in one swoop in a semi-automated fashion. Personally if I were working on a large Python project that I wanted to release to clients involving a few third-party packages, I would not be interested in any sort of automatic updating. Without testing, such automatic updates could easily break my program. And the last thing I'd want is a client or customer to be updating dependencies on his own! How would you address these issues? From tjreedy at udel.edu Thu Jan 2 13:36:32 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 2 Jan 2020 13:36:32 -0500 Subject: Friday Finking: Source code organisation In-Reply-To: <20200102074637.GA27704@cskk.homeip.net> References: <20200102074637.GA27704@cskk.homeip.net> Message-ID: On 1/2/2020 2:46 AM, Cameron Simpson wrote: > Inline code under the if...__main__ stuff cannot be called as a > function; Which makes it difficult to test app startup. > I usually consider the main() function a reusable component. Which, if called (at least optionally) with a list of string arguments (sys.argv) as Cameron suggested, makes it easy to test with various lists of strings. -- Terry Jan Reedy From arj.python at gmail.com Thu Jan 2 14:37:57 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Jan 2020 23:37:57 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: Oh auto-3rd party modules is a mess. Suggesting updating only the interpreter. We can have a pre-scan which warns the user that upgrading will make the following packages no longer compatible. But that's one aim of venvs i think, is to confine packages to projects, not to the interpreter. No java does not have such a feature, it's a suggestion that's unrelated to Java. For distributing to clients, you don't rely on the user interpreter for packages. As far as I know, some companies select let's say version 1.0.5 of a library, and ... they keep it internal, they might modify it as desired. It becomes a home pet. They distribute this version with their project. Even if the library is at 2. they use the modified 1. for increased stability. That's one extreme. Having a sort of .jar running with the system interpreter concerns syntax and enforced standards. To further ease dist, much work is required to be done on the project format itself. If i remember well, a PEP proposed to install 3rd party packages in a folder in the project, which might further enhance the process. Having a Python-specific executable allows you to go to whatever length you desire to make project bundling an easy task. The other effort is to get your interpreter/VM running on as many hardwares as possible. This includes the effort to make it lighter, faster etc. It might entails the complete removal of 3rd party packaging interpreter side or not using it when running the specific executable. I believe Python should be able to run on any device. I believe that my Python code should go everywhere. It pains me to see a project not choosing Python as an add-on scripting language due to the size of the interpreter or things of the sort. From arj.python at gmail.com Thu Jan 2 14:49:01 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Jan 2020 23:49:01 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: Coincidentally, one day before i posted this approach, a user posted on Idle-dev: [Idle-dev] Wishlist: Make executables + startup option which proposes the idea of adding an option to generate a single executable from Idle. It reflects the profound desire of the community to distribute their apps professionally. From PythonList at DancesWithMice.info Thu Jan 2 15:09:46 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 3 Jan 2020 09:09:46 +1300 Subject: Friday Finking: Source code organisation In-Reply-To: References: <20200102074637.GA27704@cskk.homeip.net> Message-ID: <78bdad6f-18f2-079f-a905-b62bdebd65f3@DancesWithMice.info> On 3/01/20 7:36 AM, Terry Reedy wrote: > On 1/2/2020 2:46 AM, Cameron Simpson wrote: > >> Inline code under the if...__main__ stuff cannot be called as a function; > > Which makes it difficult to test app startup. > >> I usually consider the main() function a reusable component. > > Which, if called (at least optionally) with a list of string arguments > (sys.argv) as Cameron suggested, makes it easy to test with various > lists of strings. NB I agree with suggestion that 'important stuff' is better placed at 'top' of source-code. Preceding comment assumes that main() is to be a word/name which catches the eye and has 'importance' attached. However, the Python idiom is "if __name__ == '__main__'" and (paradoxically?) that usually goes at the 'bottom'. I think we've previously discussed if __name__ == '__main__' and/vs main(). Continuing the discussion, above:- def start_up( args ): etc def do_it( args ): etc def close_down( args ): etc if __name__ == '__main__': start_up( sys.argv ) do_it( etc ) close_down( etc ) 1. app startup remains test-able 2. each component is reusable 3. sys.argv may be passed with all flexibility 4. separation of concerns, etc, observed NB above for casual illustration only - if start_up() is more than trivial, seems likely that others would be better implemented as context manager, etc, etc... -- Regards =dn From rosuav at gmail.com Thu Jan 2 15:14:05 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Jan 2020 07:14:05 +1100 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Fri, Jan 3, 2020 at 6:39 AM Abdur-Rahmaan Janhangeer wrote: > Having a Python-specific executable allows you to go to whatever length you > desire to make project bundling an easy task. The other effort is to get > your interpreter/VM running on as many hardwares as possible. This includes > the effort to make it lighter, faster etc. It might entails the complete > removal of 3rd party packaging interpreter side or not using it when > running the specific executable. > > I believe Python should be able to run on any device. I believe that my > Python code should go everywhere. It pains me to see a project not choosing > Python as an add-on scripting language due to the size of the interpreter > or things of the sort. What do you mean by "Python-specific executable"? Your Python code can go anywhere if you package it up in, say, a .deb or .rpm, and then just depend on a Python interpreter of appropriate version. You can allow your users to manage their own updates so long as it's within the dependency range you have chosen to support. I don't understand how "run on any device" relates to "automatically update the Python interpreter", but it's still a solved problem: *use a package manager*. ChrisA From arj.python at gmail.com Thu Jan 2 15:22:23 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 00:22:23 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Fri, 3 Jan 2020, 00:14 Chris Angelico, wrote: > > What do you mean by "Python-specific executable"? > a Python equivalent of .jar > Your Python code can go anywhere if you package it up in, say, a .deb > or .rpm, Not everybody uses Linux I > don't understand how "run on any device" relates to "automatically > update the Python interpreter", Two unrelated suggestions but it's still a solved problem: *use > a package manager*. > Single-file executables are slick. End-users want to only use the app. From rosuav at gmail.com Thu Jan 2 15:33:00 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Jan 2020 07:33:00 +1100 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Fri, Jan 3, 2020 at 7:22 AM Abdur-Rahmaan Janhangeer wrote: > > On Fri, 3 Jan 2020, 00:14 Chris Angelico, wrote: >> >> >> What do you mean by "Python-specific executable"? > > > a Python equivalent of .jar A jar is just an archive of Java class files. It's approximately equivalent to a zip file of .pyc files. You can't run a .jar file without a Java interpreter. >> Your Python code can go anywhere if you package it up in, say, a .deb >> or .rpm, > > Not everybody uses Linux No, but there are package managers for Windows and Mac too. (I don't think there's any first-party package manager for Macs, but there are some very popular third-party ones eg Homebrew.) >> I >> don't understand how "run on any device" relates to "automatically >> update the Python interpreter", > > > Two unrelated suggestions > >> but it's still a solved problem: *use >> a package manager*. > > > Single-file executables are slick. End-users want to only use the app. And that's the problem: the single-file executable requires you to bundle everything, update it yourself, and duplicate all the code everywhere. Using a package manager means you have ONE copy of the Python interpreter, and all your scripts depend on it. If you update that interpreter, ALL scripts benefit from the update. This is a solved problem. ChrisA From arj.python at gmail.com Thu Jan 2 15:42:11 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 00:42:11 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Fri, 3 Jan 2020, 00:33 Chris Angelico, wrote: > A jar is just an archive of Java class files. It's approximately > equivalent to a zip file of .pyc files. > Exactly the idea, that's why i said zipapp might be a good candidate No, but there are package managers for Windows and Mac too. (I don't > think there's any first-party package manager for Macs, but there are > some very popular third-party ones eg Homebrew.) > > ... > > And that's the problem: the single-file executable requires you to > bundle everything, update it yourself, and duplicate all the code > everywhere. > > Using a package manager means you have ONE copy of the Python > interpreter, and all your scripts depend on it. If you update that > interpreter, ALL scripts benefit from the update. This is a solved > problem. > I am not proposing native executables, but a .jar like executable. The term executable refers to one click run. From rosuav at gmail.com Thu Jan 2 15:46:15 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Jan 2020 07:46:15 +1100 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Fri, Jan 3, 2020 at 7:42 AM Abdur-Rahmaan Janhangeer wrote: > > > > On Fri, 3 Jan 2020, 00:33 Chris Angelico, wrote: >> >> A jar is just an archive of Java class files. It's approximately >> equivalent to a zip file of .pyc files. > > > Exactly the idea, that's why i said zipapp might be a good candidate > >> No, but there are package managers for Windows and Mac too. (I don't >> think there's any first-party package manager for Macs, but there are >> some very popular third-party ones eg Homebrew.) >> >> ... >> >> And that's the problem: the single-file executable requires you to >> bundle everything, update it yourself, and duplicate all the code >> everywhere. >> >> Using a package manager means you have ONE copy of the Python >> interpreter, and all your scripts depend on it. If you update that >> interpreter, ALL scripts benefit from the update. This is a solved >> problem. > > > I am not proposing native executables, but a .jar like executable. The term executable refers to one click run. > Then we already have this. On Windows, set your file associations appropriately. On Unix-like platforms, have a shebang at the start, and chmod it +x. Example: https://github.com/Rosuav/shed/blob/master/steamguard ChrisA From arj.python at gmail.com Thu Jan 2 15:54:28 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 00:54:28 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: > > Then we already have this. On Windows, set your file associations > appropriately. On Unix-like platforms, have a shebang at the start, > and chmod it +x. > Not proposing only executable but single file executable. > From rosuav at gmail.com Thu Jan 2 15:57:01 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Jan 2020 07:57:01 +1100 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Fri, Jan 3, 2020 at 7:54 AM Abdur-Rahmaan Janhangeer wrote: >> >> Then we already have this. On Windows, set your file associations >> appropriately. On Unix-like platforms, have a shebang at the start, >> and chmod it +x. > > > Not proposing only executable but single file executable. > I linked you to a single file executable of mine. It makes use of... oh hey, the system package manager. See? It works. ChrisA From torriem at gmail.com Thu Jan 2 15:57:14 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 2 Jan 2020 13:57:14 -0700 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> On 1/2/20 1:33 PM, Chris Angelico wrote: > Using a package manager means you have ONE copy of the Python > interpreter, and all your scripts depend on it. If you update that > interpreter, ALL scripts benefit from the update. This is a solved > problem. Except that it's not actually a solved problem. We thought it was but then found the limitations. Linux distros are actually moving away from a pure packager dependency model, especially for applications. System components, yes. Makes a lot of sense. Makes less sense for user-facing things. That's why there's a lot of movement going with regards to solutions like flatpak, snap, and even AppImage. RPMs and debs are never going to go away, but they do have limitations for the kind of thing the OP is talking about. Right now in Fedora land, a very appropriate way to bundle a python application is in a flatpak, bundled with the appropriate versions of Python and the libraries you depend on. More and more apps on Ubuntu are being delivered via snaps too. Especially ones that move fast like Firefox, or even LibreOffice. I use several apps that are flatpaks because my distro is old and stable (CentOS 7) and doesn't have a lot of the dependent shiny libs modern apps require. Flatpak lets me run them while keeping the core system very conservative and stable. From torriem at gmail.com Thu Jan 2 16:01:21 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 2 Jan 2020 14:01:21 -0700 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: <24e2f5d6-f576-7759-5851-404d9907702a@gmail.com> On 1/2/20 1:42 PM, Abdur-Rahmaan Janhangeer wrote: > I am not proposing native executables, but a .jar like executable. The term > executable refers to one click run. But a jar file is not executable on Windows and never has been. You can't go to the cmd.exe window and type "myprogram.jar." Maybe it can be opened with a file association linking it to a Java runtime executable. But it's certainly not a Windows executable. And I've never ever seen anyone launch a java jar file by double clicking on it. Most people provide .bat files to start it, or a lnk file that contains the necessary java flags. As Chris said with file associations you can already double-click on a py file (or pyw without a console window by convention). From rosuav at gmail.com Thu Jan 2 16:04:48 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Jan 2020 08:04:48 +1100 Subject: Python, Be Bold! In-Reply-To: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On Fri, Jan 3, 2020 at 7:58 AM Michael Torrie wrote: > > On 1/2/20 1:33 PM, Chris Angelico wrote: > > Using a package manager means you have ONE copy of the Python > > interpreter, and all your scripts depend on it. If you update that > > interpreter, ALL scripts benefit from the update. This is a solved > > problem. > > Except that it's not actually a solved problem. We thought it was but > then found the limitations. Linux distros are actually moving away from > a pure packager dependency model, especially for applications. System > components, yes. Makes a lot of sense. Makes less sense for user-facing > things. That's why there's a lot of movement going with regards to > solutions like flatpak, snap, and even AppImage. RPMs and debs are > never going to go away, but they do have limitations for the kind of > thing the OP is talking about. They are still FAR better than trying to create a single bloated executable that contains everything and magically knows how and when to update itself. If you're going to use snaps etc, you do so with full control of what you're bundling together, rather than hoping that the publisher of the program will (a) bundle the correct versions, and (b) keep them up-to-date. I'm not seeing any Linux distro moving towards a model where every program author has to include the entire binary and make 32-bit and 64-bit versions available, etc, etc, etc, as is often seen elsewhere. ChrisA From arj.python at gmail.com Thu Jan 2 16:07:54 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 01:07:54 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Fri, 3 Jan 2020, 00:58 Chris Angelico, wrote: > > I linked you to a single file executable of mine. It makes use of... > oh hey, the system package manager. See? It works. > I don't understand this one > From arj.python at gmail.com Thu Jan 2 16:11:47 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 01:11:47 +0400 Subject: Python, Be Bold! In-Reply-To: <24e2f5d6-f576-7759-5851-404d9907702a@gmail.com> References: <24e2f5d6-f576-7759-5851-404d9907702a@gmail.com> Message-ID: On Fri, 3 Jan 2020, 01:01 Michael Torrie, wrote: > > But a jar file is not executable on Windows and never has been. .... Maybe it can > be opened with a file association linking it to a Java runtime > executable. > That's it. See UMLet's distribution mode for example As Chris said with file associations you can already double-click on a > py file (or pyw without a console window by convention). > But single file are better suited for distribution. > From arj.python at gmail.com Thu Jan 2 16:17:19 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 01:17:19 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On Fri, 3 Jan 2020, 01:05 Chris Angelico, wrote: > > They are still FAR better than trying to create a single bloated > executable that contains everything and magically knows how and when > to update itself. > Proposing to freeze things. You distribute a version of the program. The single file (not using the word executable as it seemingly leads to confusions) is given with the assurance that the only thing you need is an interpreter for it to work. From torriem at gmail.com Thu Jan 2 16:43:28 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 2 Jan 2020 14:43:28 -0700 Subject: Python, Be Bold! In-Reply-To: References: <24e2f5d6-f576-7759-5851-404d9907702a@gmail.com> Message-ID: <1775c15b-2311-e81d-5cb1-bcd90ebdb8d5@gmail.com> On 1/2/20 2:11 PM, Abdur-Rahmaan Janhangeer wrote: > But single file are better suited for distribution. Maybe. Most windows applications are distributed with installers. I've made several bundles over the years with Nullsoft's installer builder. That's how commercial companies, including those that use Python, distribute their applications. Here's a popular open source application build on Python, and it's installer (a single msi file): https://calibre-ebook.com/download_windows I haven't seen very many single-exe windows applications ever. Anyway we can argue forever about what ought to be. But until someone does it and proves that it's important, it's not going to happen. From rosuav at gmail.com Thu Jan 2 16:43:29 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Jan 2020 08:43:29 +1100 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On Fri, Jan 3, 2020 at 8:17 AM Abdur-Rahmaan Janhangeer wrote: > > > > On Fri, 3 Jan 2020, 01:05 Chris Angelico, wrote: >> >> >> They are still FAR better than trying to create a single bloated >> executable that contains everything and magically knows how and when >> to update itself. > > > Proposing to freeze things. You distribute a version of the program. The single file (not using the word executable as it seemingly leads to confusions) is given with the assurance that the only thing you need is an interpreter for it to work. > Wait, so as well as the single file, you ALSO need a Python interpreter? Then what's the point? Why not just distribute a .py file? ChrisA From grant.b.edwards at gmail.com Thu Jan 2 17:48:57 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 2 Jan 2020 22:48:57 -0000 (UTC) Subject: Python, Be Bold! References: <24e2f5d6-f576-7759-5851-404d9907702a@gmail.com> <1775c15b-2311-e81d-5cb1-bcd90ebdb8d5@gmail.com> Message-ID: On 2020-01-02, Michael Torrie wrote: > On 1/2/20 2:11 PM, Abdur-Rahmaan Janhangeer wrote: >> But single file are better suited for distribution. > > Maybe. Most windows applications are distributed with installers. Definitely. Single file executables aren't really "a thing" on Windows. > [...] > I haven't seen very many single-exe windows applications ever. Putty is still made available as a single file executable. But, it's the only one I've seen for a couple decades. AFAICT, 99.999% of Windows apps are distributed as an .msi file or as a self-extracting installer (e.g. foobar-1.2.3-setup.exe) file. If that's what you want to do with your python app, then you can use cx_freeze et alia. Packagining something for wide distribution can be a bit a fiddly to get right: you need to know what you're doing, and you need to do a lot of testing. But that's true regardless of OS or language. -- Grant Edwards grant.b.edwards Yow! Are you the at self-frying president? gmail.com From barry at barrys-emacs.org Thu Jan 2 17:50:36 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Thu, 2 Jan 2020 22:50:36 +0000 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: > On 2 Jan 2020, at 21:17, Abdur-Rahmaan Janhangeer wrote: > > On Fri, 3 Jan 2020, 01:05 Chris Angelico, wrote: > >> >> They are still FAR better than trying to create a single bloated >> executable that contains everything and magically knows how and when >> to update itself. >> > > Proposing to freeze things. You distribute a version of the program. The > single file (not using the word executable as it seemingly leads to > confusions) is given with the assurance that the only thing you need is an > interpreter for it to work. Expect for trivial programs you cannot distribute a single file python exe for windows. As you found zipapp is not a solution. Many stdlib modules use DLL's on Windows and you cannot run a DLL from inside a zip file. As soon as you have a GUI interface you have to install lots of DLLs and the C++ runtime. The only easy way to support users is by using a windows installer. I use inno installer for windows which is a very powerful tool, https://www.jrsoftware.org/isinfo.php . And I create the windows app with https://pypi.org/project/win-app-packager/ (I'm the author). The situation for the Mac requires you to create a .app bundle. The way these are distributed is as a compressed .dmg file. I use py2app and dmgbuild to get the job done on macOS. As Chris noted its easier on Linux systems. You can make a package (.deb or .rpm) that uses the already packaged python code and libraries. There are excellent solutions that have existed for many years to package python apps for Windows, macOS and Linux. On Windows and macOS it is necessary to install python, you just bundle it inside the app. I support two apps on Windows, macOS and unix that does exactly this. http://barrys-emacs.org and http://http://scm-workbench.barrys-emacs.org/ For command line tools pip knows how to install a .exe for Windows that runs the tool. On macOS and linux its creates a small boot strap script. As an example see my https://pypi.org/project/colour-text/ project that installs the colour-print command. All the code for the above is open source and you can read the code used to build the install kits. Barry > -- > https://mail.python.org/mailman/listinfo/python-list > From greg.ewing at canterbury.ac.nz Thu Jan 2 18:22:58 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 3 Jan 2020 12:22:58 +1300 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: It looks like what the OP is after already exists: https://docs.python.org/3/library/zipapp.html "This module provides tools to manage the creation of zip files containing Python code, which can be executed directly by the Python interpreter." -- Greg From none at invalid.com Thu Jan 2 18:31:42 2020 From: none at invalid.com (mm0fmf) Date: Thu, 2 Jan 2020 23:31:42 +0000 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On 02/01/2020 09:41, Abdur-Rahmaan Janhangeer wrote: > i wonder who uses windows > I do. The man pays me well to write software for Windows and Linux and I don't care which . It's just an OS, write the code to do what the spec says. Not a difficult concept really. apt-get works fine for me on Linux. On Windows I currently have Python 3.7.3 which comes with a nice installer and uninstalls via the OS apps management. (i.e. it has an uninstaller somewhere). From arj.python at gmail.com Thu Jan 2 21:07:36 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 06:07:36 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On Fri, 3 Jan 2020, 03:25 Greg Ewing, wrote: > It looks like what the OP is after already exists: > > https://docs.python.org/3/library/zipapp.html > > "This module provides tools to manage the creation of zip files > containing Python code, which can be executed directly by the Python > interpreter." > Oh my, you did not read from the begining. Please do so. I would really like to rewrite what i said but it's too long. > From arj.python at gmail.com Thu Jan 2 21:08:40 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 06:08:40 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Fri, 3 Jan 2020, 03:35 mm0fmf, wrote: > On 02/01/2020 09:41, Abdur-Rahmaan Janhangeer wrote: > > i wonder who uses windows > > > > I do. The man pays me well to write software for Windows and Linux and I > don't care which . It's just an OS, write the code to do what the spec > says. Not a difficult concept really. > Was a pointing out that people use windows also. > From arj.python at gmail.com Thu Jan 2 21:10:10 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 06:10:10 +0400 Subject: Python, Be Bold! In-Reply-To: <1775c15b-2311-e81d-5cb1-bcd90ebdb8d5@gmail.com> References: <24e2f5d6-f576-7759-5851-404d9907702a@gmail.com> <1775c15b-2311-e81d-5cb1-bcd90ebdb8d5@gmail.com> Message-ID: On Fri, 3 Jan 2020, 01:43 Michael Torrie, wrote: > On 1/2/20 2:11 PM, Abdur-Rahmaan Janhangeer wrote: > > But single file are better suited for distribution. > > Maybe. Most windows applications are distributed with installers. I've > made several bundles over the years with Nullsoft's installer builder. > That's how commercial companies, including those that use Python, > distribute their applications. Here's a popular open source application > build on Python, and it's installer (a single msi file): > https://calibre-ebook.com/download_windows > > I haven't seen very many single-exe windows applications ever. > This proposal is not about native executables > From arj.python at gmail.com Thu Jan 2 21:11:40 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 06:11:40 +0400 Subject: Python, Be Bold! In-Reply-To: References: <24e2f5d6-f576-7759-5851-404d9907702a@gmail.com> <1775c15b-2311-e81d-5cb1-bcd90ebdb8d5@gmail.com> Message-ID: On Fri, 3 Jan 2020, 02:49 Grant Edwards, wrote: > > Definitely. > > Single file executables aren't really "a thing" on Windows. > This proposal is about a .jar like file executable, not native executables > From arj.python at gmail.com Thu Jan 2 21:14:44 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 06:14:44 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On Fri, 3 Jan 2020, 01:43 Chris Angelico, wrote: > > Wait, so as well as the single file, you ALSO need a Python > interpreter? Then what's the point? Why not just distribute a .py > file? > Well let's say a Flask, Django or PyQt app, a single file is not really feasible. > From arj.python at gmail.com Thu Jan 2 21:22:26 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 06:22:26 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: One of the advantages of single "executable"s is the abstraction of details. You don't want users to see what you included. It's an attempt at hiding away details for aesthetic purposes. The second reason is compression. You get a lighter program. The third reason is to be as reverse-engineer resistant as possible. From arj.python at gmail.com Thu Jan 2 21:31:33 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 06:31:33 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On Fri, 3 Jan 2020, 02:50 Barry Scott, wrote: > Expect for trivial programs you cannot distribute a single file python exe > for windows. > You can, PyInstaller does it. You can have folder-based or single file apps As you found zipapp is not a solution. > Zipapp is a good candidate. Proposing to improve it > Many stdlib modules use DLL's on Windows and you cannot run a DLL from > inside a zip file. > PyInstaller's -F mode does it well But, this proposal is not about native executables. It's about a .jar like executable. As a python-specific 'executable', os is not a problem unless of course you are using like curses on windows From bob at mellowood.ca Thu Jan 2 21:32:56 2020 From: bob at mellowood.ca (Bob van der Poel) Date: Thu, 2 Jan 2020 19:32:56 -0700 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: Oh, now we get the rational. No thank you! Enough of the world is hidden away as it is. On Thu, Jan 2, 2020 at 7:22 PM Abdur-Rahmaan Janhangeer < arj.python at gmail.com> wrote: > One of the advantages of single "executable"s is the abstraction of > details. You don't want users to see what you included. It's an attempt at > hiding away details for aesthetic purposes. The second reason is > compression. You get a lighter program. The third reason is to be as > reverse-engineer resistant as possible. > -- > https://mail.python.org/mailman/listinfo/python-list > -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca From arj.python at gmail.com Thu Jan 2 22:32:32 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 3 Jan 2020 07:32:32 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On Fri, 3 Jan 2020, 06:33 Bob van der Poel, wrote: > Oh, now we get the rational. No thank you! Enough of the world is hidden > away as it is. > Zipapp was introduced for a reason, .jar for a reason. This proposal also adds in the ability of the interpreter to notify of new Python releases. > From alan at csail.mit.edu Fri Jan 3 11:41:38 2020 From: alan at csail.mit.edu (Alan Bawden) Date: 03 Jan 2020 11:41:38 -0500 Subject: A small quiz References: Message-ID: <86d0c0ijb1.fsf@richard.bawden.org> ram at zedat.fu-berlin.de (Stefan Ram) writes: ... > So I was looking for a predefined object from the standard > library that already /is/ an iterator (with no need to use > ?iter?). > > I found exactly one such object (which can be used after a > ?from ... import ...? statement). Can you guess what it is? Well, there's sys.stdin. But I would expect beginning students to find the effect of typing "next(sys.stdin)" to the commnd prompt to be a bit confusing... -- Alan Bawden From __peter__ at web.de Fri Jan 3 13:01:32 2020 From: __peter__ at web.de (Peter Otten) Date: Fri, 03 Jan 2020 19:01:32 +0100 Subject: A small quiz References: <86d0c0ijb1.fsf@richard.bawden.org> Message-ID: Alan Bawden wrote: > ram at zedat.fu-berlin.de (Stefan Ram) writes: > ... >> So I was looking for a predefined object from the standard >> library that already /is/ an iterator (with no need to use >> ?iter?). >> >> I found exactly one such object (which can be used after a >> ?from ... import ...? statement). Can you guess what it is? > > Well, there's sys.stdin. > > But I would expect beginning students to find the effect of typing > "next(sys.stdin)" to the commnd prompt to be a bit confusing... > There are a lot of itertools.count() objects, e. g. >>> from multiprocessing.pool import job_counter >>> next(job_counter) 0 >>> next(job_counter) 1 From barry at barrys-emacs.org Fri Jan 3 14:03:15 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Fri, 3 Jan 2020 19:03:15 +0000 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: <374FC11C-DA20-429C-A0EF-497D31F36AC1@barrys-emacs.org> > On 3 Jan 2020, at 02:31, Abdur-Rahmaan Janhangeer wrote: > > > > On Fri, 3 Jan 2020, 02:50 Barry Scott, > wrote: > Expect for trivial programs you cannot distribute a single file python exe for windows. > > You can, PyInstaller does it. You can have folder-based or single file apps > > As you found zipapp is not a solution. > > Zipapp is a good candidate. Proposing to improve it I'm at a lose to understand what the problem is that zipapp is the solution to that is not better served with pip or PyInstall etc. > > > Many stdlib modules use DLL's on Windows and you cannot run a DLL from > inside a zip file. > > PyInstaller's -F mode does it well Then use that are be happy. > > But, this proposal is not about native executables. It's about a .jar like executable. As a python-specific 'executable', os is not a problem unless of course you are using like curses on windows Barry From greg.ewing at canterbury.ac.nz Fri Jan 3 17:04:36 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 4 Jan 2020 11:04:36 +1300 Subject: A small quiz In-Reply-To: <86d0c0ijb1.fsf@richard.bawden.org> References: <86d0c0ijb1.fsf@richard.bawden.org> Message-ID: On 4/01/20 5:41 am, Alan Bawden wrote: >> So I was looking for a predefined object from the standard >> library that already /is/ an iterator (with no need to use >> ?iter?). Why are you so intent on introducing either next() or iter() to beginning students? I'd have thought they were somewhat advanced topics, to be tackled after your students are familiar with the basics. -- Greg From greg.ewing at canterbury.ac.nz Fri Jan 3 17:50:06 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 4 Jan 2020 11:50:06 +1300 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On 3/01/20 3:31 pm, Abdur-Rahmaan Janhangeer wrote: > But, this proposal is not about native executables. It's about a .jar like > executable. You can pass a zip file with a .pyz extension to the python interpreter and it will look for a __main__.py file and run it. That seems to give you all the functionality of a jar -- including the limitations (e.g. you can't bundle extension modules or native libraries that way). Py2exe comes with zipextimporter, which purports to be able to load .pyd files from zip archives, but I'm not aware of an equivalent for other platforms. Perhaps getting zipextimporter into the standard library, and developing versions of it for Linux and MacOS, would be a useful improvement? -- Greg From arj.python at gmail.com Fri Jan 3 19:44:16 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sat, 4 Jan 2020 04:44:16 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: On Sat, 4 Jan 2020, 02:55 Greg Ewing, wrote: > On 3/01/20 3:31 pm, Abdur-Rahmaan Janhangeer wrote: > > You can pass a zip file with a .pyz extension to the python > interpreter and it will look for a __main__.py file and run > it. > > That seems to give you all the functionality of a jar -- > including the limitations (e.g. you can't bundle extension > modules or native libraries that way). > .jar provides more than just compression. It provides app info and has signing ability > From arj.python at gmail.com Fri Jan 3 20:10:26 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sat, 4 Jan 2020 05:10:26 +0400 Subject: Python, Be Bold! In-Reply-To: <374FC11C-DA20-429C-A0EF-497D31F36AC1@barrys-emacs.org> References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> <374FC11C-DA20-429C-A0EF-497D31F36AC1@barrys-emacs.org> Message-ID: On Fri, 3 Jan 2020, 23:49 Barry Scott, wrote: > > I'm at a lose to understand what the problem is that zipapp is the > solution to that is not better served > with pip or PyInstall etc. > Well proposing to enhance zipapp, by adding app metadata and signing. By pip i understand you mean pure python distribution. Well, an enhanced zipapp's advantage would be smaller codebase and easy injection detection among others + the improving the ability to prevent reverse engineering for those who want it. Comparing to native executable well, one thing is program size. You must have the interpreter on the machine but your program is lighter. 10 python programs does not mean inclung 10? the interpreter. The proposal also proposes enhancement to the interpreter to make it more non-programmer friendly. Also, you must have a dist for every different Os. Python, Be Bold captures the spirit of it should not be a shame to have the interpreter/VM installed on end-users machines. It also facilitates the work of other python devs. You installed it because of one Python program, other programs benefit from it. It also proposes enhancements to the VM to better facilitate that. > From jezkator at gmail.com Fri Jan 3 20:13:12 2020 From: jezkator at gmail.com (rontoto) Date: Fri, 3 Jan 2020 17:13:12 -0800 (PST) Subject: heap enhancements Message-ID: Hi guys, the code is working, but I want know, what I can improve on this code. It is like implementation of the simulation of shipment clearance in the depot according to priority and available deliveries. How can I do it better? Can u show me? Thnx for your time. Input: 24 K 13 H 25 R 1 M -4 T0 15 G 4 C -1 T1 -3 T2 12 Y Code: import sys class MaxHeap: def __init__(self): self.heap =[] def bubble_up(self, i): while i > 0: j = (i - 1) // 2 if self.heap[i] <= self.heap[j]: break self.heap[j], self.heap[i] = self.heap[i], self.heap[j] i = j def insert(self, k): self.heap += [k] self.bubble_up(len(self.heap) - 1) def peek(self): return self.heap[0] def size(self): return len(self.heap) def is_empty(self): return self.size() == 0 def bubble_down(self, i): n = self.size() while 2 * i + 1 < n: j = 2 * i + 1 if j + 1 < n and self.heap[j] < self.heap[j + 1]: j += 1 if self.heap[i] < self.heap[j]: self.heap[i], self.heap[j] = self.heap[j], self.heap[i] i = j def pop(self): element = self.heap[0] self.heap[0] = self.heap[-1] self.heap.pop() self.bubble_down(0) return element y = sys.stdin.read().splitlines() z = list() for line in y: row=list(map(str, line.split())) z.append(row) def checking(a): for char in a: if char not in "0123456789-": return False return True for i in range (len(z)): for j in range (len(z[i])): d=z[i][j] if d.isdigit() is True: z[i][j]=int(z[i][j]) q=checking(d) if q is True: z[i][j]=int(z[i][j]) H=MaxHeap() for t in range (len(z)): if z[t][0]>0: H.insert(z[t]) if z[t][0] < 0: print(z[t][1],sep="",end="") print(": ",end="") e=z[t][0] while e<0 and (H.is_empty()) is False: u=H.pop() print(u[1],end=" ") e=e+1 print("") print("Depo: ",end="") while (H.is_empty()) is not True: u_1=H.pop() print(u_1[1],end=" ") Output: T0: R K H M T1: G T2: C Depo: Y From arj.python at gmail.com Fri Jan 3 20:15:12 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sat, 4 Jan 2020 05:15:12 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> <374FC11C-DA20-429C-A0EF-497D31F36AC1@barrys-emacs.org> Message-ID: On Sat, 4 Jan 2020, 05:10 Abdur-Rahmaan Janhangeer, wrote: > > Also, you must have a dist for every different Os. > *for native execs > From rosuav at gmail.com Fri Jan 3 20:22:48 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 4 Jan 2020 12:22:48 +1100 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> <374FC11C-DA20-429C-A0EF-497D31F36AC1@barrys-emacs.org> Message-ID: On Sat, Jan 4, 2020 at 12:12 PM Abdur-Rahmaan Janhangeer wrote: > > On Fri, 3 Jan 2020, 23:49 Barry Scott, wrote: > > > > > I'm at a lose to understand what the problem is that zipapp is the > > solution to that is not better served > > with pip or PyInstall etc. > > > > Well proposing to enhance zipapp, by adding app metadata and signing. By > pip i understand you mean pure python distribution. Well, an enhanced > zipapp's advantage would be smaller codebase and easy injection detection > among others + the improving the ability to prevent reverse engineering for > those who want it. Why do you assume pure Python? pip is fully capable of locating and installing binary packages based on the architecture it's running on. > Comparing to native executable well, one thing is program size. You must > have the interpreter on the machine but your program is lighter. 10 python > programs does not mean inclung 10? the interpreter. The proposal also > proposes enhancement to the interpreter to make it more non-programmer > friendly. Also, you must have a dist for every different Os. I'm not sure what your proposal is here. Are you trying to make a single-file executable, or are you trying to make an archive of Python source code (like a jar), or are you trying something different again? > Python, Be Bold captures the spirit of it should not be a shame to have the > interpreter/VM installed on end-users machines. It also facilitates the > work of other python devs. You installed it because of one Python program, > other programs benefit from it. It also proposes enhancements to the VM to > better facilitate that. Uhhhh...... so.... go install Python and then you can install some Python app? Isn't that how things already are? ChrisA From PythonList at DancesWithMice.info Fri Jan 3 20:30:27 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Sat, 4 Jan 2020 14:30:27 +1300 Subject: heap enhancements In-Reply-To: References: Message-ID: <29e50f05-7ad9-ebe6-39ed-3f4968869b10@DancesWithMice.info> On 4/01/20 2:13 PM, rontoto wrote: > Hi guys, the code is working, but I want know, what I can improve on this code. It is like implementation of the simulation of shipment clearance in the depot according to priority and available deliveries. How can I do it better? Can u show me? Thnx for your time. 1 add comments which document the code, explaining what each method accomplishes, etc 2 choose meaningful names - it is not like you're sending a telegram (and if you don't know what on earth I'm talking about, then this applies double!) and being charged by the letter. Have you run any time-trials to establish whether the code is 'fast' or 'slow'? Recommended reading: 1 supporting the above, including PEP-8 2 supporting the above 3 writing program(me)s so that others can read them 4 search for "Python heap" 5 download and inspect heapq from the PSL (Python Standard Library) There are algorithm-mavens on-list who might weigh-in at that level... -- Regards =dn From arj.python at gmail.com Fri Jan 3 20:39:37 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sat, 4 Jan 2020 05:39:37 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> <374FC11C-DA20-429C-A0EF-497D31F36AC1@barrys-emacs.org> Message-ID: On Sat, 4 Jan 2020, 05:23 Chris Angelico, wrote: > > I'm not sure what your proposal is here. Are you trying to make a > single-file executable, or are you trying to make an archive of Python > source code (like a jar), or are you trying something different again? > a .jar but it can be defined for greater security Uhhhh...... so.... go install Python and then you can install some > Python app? Isn't that how things already are? > Not for the archive-based exec. It does not currently exist. > From torriem at gmail.com Fri Jan 3 21:49:42 2020 From: torriem at gmail.com (Michael Torrie) Date: Fri, 3 Jan 2020 19:49:42 -0700 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: <751a892c-4541-20bd-7c60-d2da20d2fcbd@gmail.com> On 2020-01-03 5:44 p.m., Abdur-Rahmaan Janhangeer wrote: > .jar provides more than just compression. It provides app info and has > signing ability This is the first time you've mentioned signing ability in this very long thread. At this point I have no idea what point you are even making anymore. It's all over the place! If you coded up something concrete to share with the list, and described it in the form of a PEP, and then it could be debated on its merits rather than some ever-changing feature wish list. Your ideas may well be good. But they will need an implementation behind them. Python core developers have a lot on their hands; pie in the sky wishes are unlikely to get on their radar. Several people have suggested utilities to look at. I suggest you start there and see if you can modify them to suit your needs. From arj.python at gmail.com Fri Jan 3 21:51:15 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sat, 4 Jan 2020 06:51:15 +0400 Subject: Python, Be Bold! In-Reply-To: <751a892c-4541-20bd-7c60-d2da20d2fcbd@gmail.com> References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> <751a892c-4541-20bd-7c60-d2da20d2fcbd@gmail.com> Message-ID: On Sat, 4 Jan 2020, 06:49 Michael Torrie, wrote: > On 2020-01-03 5:44 p.m., Abdur-Rahmaan Janhangeer wrote: > > .jar provides more than just compression. It provides app info and has > > signing ability > > This is the first time you've mentioned signing ability in this very > long thread. At this point I have no idea what point you are even > making anymore. It's all over the place! > True. Currently writing a draft. > From arj.python at gmail.com Fri Jan 3 21:53:15 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sat, 4 Jan 2020 06:53:15 +0400 Subject: Python, Be Bold! In-Reply-To: <751a892c-4541-20bd-7c60-d2da20d2fcbd@gmail.com> References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> <751a892c-4541-20bd-7c60-d2da20d2fcbd@gmail.com> Message-ID: << than some ever-changing feature wish list. >> ^^_ since the beginning it was .jar From jezkator at gmail.com Fri Jan 3 22:06:47 2020 From: jezkator at gmail.com (jezkator at gmail.com) Date: Fri, 3 Jan 2020 19:06:47 -0800 (PST) Subject: heap enhancements In-Reply-To: References: <29e50f05-7ad9-ebe6-39ed-3f4968869b10@DancesWithMice.info> Message-ID: <95a5fb70-0696-467a-a7aa-9bf4b890b43a@googlegroups.com> ok, so it could be like this? import sys chain = sys.stdin.read().splitlines() array_z = list() for line in chain: row=list(map(str, line.split())) array_z.append(row) #every line in input changes into 2D array def checking(chain): "checking if characters are numbers or not" for char in chain: if char not in "0123456789-": return False return True class MaxHeap: def __init__(self): """heap __init__ constructor""" self.heap =[] def bubble_up(self, i): """"bubble the element up if condition is ok """ while i > 0: j = (i - 1) // 2 if self.heap[i] <= self.heap[j]: break self.heap[j], self.heap[i] = self.heap[i], self.heap[j] i = j def insert(self, k): """insert element in heap""" self.heap += [k] self.bubble_up(len(self.heap) - 1) def peek(self): """return the biggest element""" return self.heap[0] def size(self): """return quantity of elements in heap""" return len(self.heap) def is_empty(self): """is heap empty?""" return self.size() == 0 def bubble_down(self, i): """bubble down the element""" n = self.size() while 2 * i + 1 < n: j = 2 * i + 1 if j + 1 < n and self.heap[j] < self.heap[j + 1]: j += 1 if self.heap[i] < self.heap[j]: self.heap[i], self.heap[j] = self.heap[j], self.heap[i] i = j def pop(self): """delete the biggest element and change the heap""" element = self.heap[0] self.heap[0] = self.heap[-1] self.heap.pop() self.bubble_down(0) return element for i in range (len( array_z)): for j in range (len( array_z[i])): digit_z= array_z[i][j] if digit_z.isdigit() is True: array_z[i][j]=int( array_z[i][j]) check =checking(digit_z) if check is True: array_z[i][j]=int( array_z[i][j]) Heap=MaxHeap() for a in range (len( array_z)): if array_z[a][0]>0: Heap.insert( array_z[a]) if array_z[a][0] < 0: print( array_z[a][1]+": ",end="") #print name of delivery index_of_package= array_z[a][0] while index_of_package<0 and (Heap.is_empty()) is False: delivery_package=Heap.pop() print(delivery_package[1],end=" ") #print name of package in delivery index_of_package+= 1 print("") print("Depo: ",end="") while (Heap.is_empty()) is False: depo_package=Heap.pop() print(depo_package[1],end=" ") #print name of package in depo From __peter__ at web.de Sat Jan 4 10:04:13 2020 From: __peter__ at web.de (Peter Otten) Date: Sat, 04 Jan 2020 16:04:13 +0100 Subject: heap enhancements References: <29e50f05-7ad9-ebe6-39ed-3f4968869b10@DancesWithMice.info> <95a5fb70-0696-467a-a7aa-9bf4b890b43a@googlegroups.com> Message-ID: jezkator at gmail.com wrote: > ok, so it could be like this? Easy things to improve: (1) Avoid iterating over indices. Wrong: for i in range(len(stuff)): item = stuff[i] ... Better: for item in stuff: ... (1a) If you need the index use enumerate(): for i, value in enumerate(stuff) if value < 0: stuff[i] = -value (1b) Instead of modifiying a container it is often more convenient to build a new one stuff = [abs(v) for v in stuff] # common way stuff = list(map(abs, stuff)) # also possible (2) Test for "truthiness" rather than object identity Wrong: if x is True: ... Better: if x: ... (3) Avoid toplevel code, or at least move it to the end of the script and guard it with if __name__ == "__main__": ... Wrong: do stuff def foo(): ... do more stuff class Bar: ... do even more stuff Better def foo(): ... class Bar: ... def main(): do stuff do more stuff do even more stuff if __name__ == "__main__": main() (4) Choose names carefully. > def checking(chain): The function name should tell what is checked, e. g. def is_valid_int(text): (5) Parameterize your code to simplify tests and refactoring. Wrong: > chain = sys.stdin.read().splitlines() > array_z = list() > for line in chain: > row=list(map(str, line.split())) > array_z.append(row) > #every line in input changes into 2D array Better: def read_2d_array(instream): """Read whitespace-separated pairs from `instream`. Returns a list of 2-tuples. pairs = [] for line in instream: pair = line.split() if len(pair) != 2: raise ValueError pairs.append(pair) return pairs array_z = read_2d_array(sys.stdin) If you later decide to support files the change is obvious: filename = ... if filename == "-": array_z = read_2d_array(sys.stdin) else: with open(filename) as instream array_z = read_2d_array(instream) (Somewhat advanced: read_2d_array() could also be a generator yielding pairs.) > def checking(chain): > "checking if characters are numbers or not" > for char in chain: > if char not in "0123456789-": > return False > return True This check is tedious and incomplete as it allows "-" in arbitrary positions. Instead of testing the string for correctness before you convert it it is often more convenient to try the conversion and cope with the exception that may be raised. Instead of # this is called "look before you leap", or LBYL if is_valid_int_string(some_string): intval = int(some_string) else: handle error # "it's easier to ask for forgiveness than permission", or EAFP try: intval = int(s) except ValueError: handle error - > class MaxHeap: > def __init__(self): > """heap __init__ constructor""" > self.heap =[] > def bubble_up(self, i): > """"bubble the element up if condition is ok """ > while i > 0: > j = (i - 1) // 2 > if self.heap[i] <= self.heap[j]: > break > self.heap[j], self.heap[i] = self.heap[i], self.heap[j] > i = j > def insert(self, k): > """insert element in heap""" > self.heap += [k] > self.bubble_up(len(self.heap) - 1) > def peek(self): > """return the biggest element""" > return self.heap[0] > def size(self): > """return quantity of elements in heap""" > return len(self.heap) > def is_empty(self): > """is heap empty?""" > return self.size() == 0 The pythonic replacement for size() and is_empty() is def __len__(self): return len(self.heap) You can then replace myheap = MaxHeap() print(myheap.size()) if myheap.is_empty(): print("myheap is empty") with print(len(myheap)) if not myheap: print("myheap is empty") > def bubble_down(self, i): > """bubble down the element""" > n = self.size() > while 2 * i + 1 < n: > j = 2 * i + 1 > if j + 1 < n and self.heap[j] < self.heap[j + 1]: > j += 1 > if self.heap[i] < self.heap[j]: > self.heap[i], self.heap[j] = self.heap[j], self.heap[i] > i = j > def pop(self): > """delete the biggest element and change the heap""" > element = self.heap[0] > self.heap[0] = self.heap[-1] > self.heap.pop() > self.bubble_down(0) > return element > > for i in range (len( array_z)): > for j in range (len( array_z[i])): > digit_z= array_z[i][j] > if digit_z.isdigit() is True: > array_z[i][j]=int( array_z[i][j]) > check =checking(digit_z) > if check is True: > array_z[i][j]=int( array_z[i][j]) > > Heap=MaxHeap() > for a in range (len( array_z)): > if array_z[a][0]>0: > Heap.insert( array_z[a]) > if array_z[a][0] < 0: > print( array_z[a][1]+": ",end="") #print name of delivery > index_of_package= array_z[a][0] > while index_of_package<0 and (Heap.is_empty()) is False: > delivery_package=Heap.pop() > print(delivery_package[1],end=" ") #print name of package in > delivery index_of_package+= 1 > print("") > print("Depo: ",end="") > while (Heap.is_empty()) is False: > depo_package=Heap.pop() > print(depo_package[1],end=" ") #print name of package in depo From marko at pacujo.net Sat Jan 4 16:19:51 2020 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 04 Jan 2020 23:19:51 +0200 Subject: Python, Be Bold! References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> Message-ID: <87sgkuor60.fsf@elektro.pacujo.net> Greg Ewing : > You can pass a zip file with a .pyz extension to the python > interpreter and it will look for a __main__.py file and run > it. This discussion has been interesting, and I've now learned about zipapp. This is really nice and will likely be a favorite distribution format for Python applications. My initial instinct would be to use zipapp as follows: * The starting point is a directory containing the Python source files, possibly with subdirectories. (A simple, two-file example: "myapp.py", "auxmod.py".) Be sure that "myapp.py" contains the boilerplate footer: if __name__ == '__main__': main() * Test that the program works: $ ./myapp.py hello * Generate the zipapp: $ python3 -m zipapp . -o ../myapp.pyz --main myapp:main \ -p "/usr/bin/env python3" * Try it out: $ ../myapp.pyz hello Marko From soyeomul at doraji.xyz Sat Jan 4 20:57:04 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Sun, 05 Jan 2020 10:57:04 +0900 Subject: A small quiz References: <86d0c0ijb1.fsf@richard.bawden.org> Message-ID: Greg Ewing writes: > On 4/01/20 5:41 am, Alan Bawden wrote: >>> So I was looking for a predefined object from the standard >>> library that already /is/ an iterator (with no need to use >>> ?iter?). > > Why are you so intent on introducing either next() or iter() to > beginning students? I'd have thought they were somewhat advanced > topics, to be tackled after your students are familiar with the > basics. Also i think that topic is somewhat difficult. Anyway thanks for introducing, Stefan(OP)^^^ Sincerely, -- ^????? _????_ ?????_^))// From wille.vincent at hotmail.com Sat Jan 4 17:29:26 2020 From: wille.vincent at hotmail.com (William Johnsson) Date: Sat, 4 Jan 2020 22:29:26 +0000 Subject: No subject Message-ID: Hello! My name is William and im 14 years old and live in sweden. Im pretty new to programing in python and i need some help with code, (That?s why i?m here). But i couldn?t really find what i was searching for on the internet. I?m trying to write code that can check only the first line in a .txt file and check if it?s the same as the int 1000. I preferably want it to be an if satement but anything works, i just don?t know how i should write it. I?ve been browsing the internet for a solution but sadly can?t seem to find a solution to it. I don?t really know if this is the right way to get help or even if this email is for something else. Hopefully i will get some kind of response. Best regards, William From torriem at gmail.com Sun Jan 5 00:04:10 2020 From: torriem at gmail.com (Michael Torrie) Date: Sat, 4 Jan 2020 22:04:10 -0700 Subject: No subject In-Reply-To: References: Message-ID: <003f8a7b-1810-4ea9-6812-ba82728431e6@gmail.com> On 1/4/20 3:29 PM, William Johnsson wrote: > Hello! My name is William and im 14 years old and live in sweden. Im > pretty new to programing in python and i need some help with code, > (That?s why i?m here). But i couldn?t really find what i was > searching for on the internet. I?m trying to write code that can > check only the first line in a .txt file and check if it?s the same > as the int 1000. I preferably want it to be an if satement but > anything works, i just don?t know how i should write it. I?ve been > browsing the internet for a solution but sadly can?t seem to find a > solution to it. > > I don?t really know if this is the right way to get help or even if > this email is for something else. Hopefully i will get some kind of > response. > > Best regards, William Welcome, William. Another mailing list you might want to post to is the Python Tutor list (https://mail.python.org/mailman/listinfo/tutor) which is focused on people learning Python. Seems like your problem can be broken down into a few steps: 1. Open a file 2. Read the first line 3. look for "1000" in that line. Learning how to read from a text file would probably be the first thing to look into. See in particular chapter 7.2 in this section of official tutorial. https://docs.python.org/3/tutorial/inputoutput.html You may also google for other examples of opening and reading lines from a text file in Python. Once you've been able to read in a line, you can do a simple search in that line using the "in" keyword (mentioned part way down the page https://docs.python.org/3/library/stdtypes.html in the section called "Common Sequence Operations"). Hopefully you'll find this useful rather than just giving you a complete little program (where's the fun in that!). From rosuav at gmail.com Sun Jan 5 03:57:14 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 5 Jan 2020 19:57:14 +1100 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Sun, Jan 5, 2020 at 7:51 PM Andrea D'Amore wrote: > > On Thu, 2 Jan 2020 at 09:38, Chris Angelico wrote: > > > The wheel does not need to be reinvented. > > I see what you did there. > If you're talking about the pip-installable "wheel" format, then I *think* that it's a reference to that expression, but I'm not positive. More info can be found here: https://www.python.org/dev/peps/pep-0427/ ChrisA From a at d-amo.re Sun Jan 5 03:51:14 2020 From: a at d-amo.re (Andrea D'Amore) Date: Sun, 5 Jan 2020 09:51:14 +0100 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Thu, 2 Jan 2020 at 09:38, Chris Angelico wrote: > The wheel does not need to be reinvented. I see what you did there. -- Andrea From arj.python at gmail.com Sun Jan 5 08:00:51 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sun, 5 Jan 2020 17:00:51 +0400 Subject: Python, Be Bold! In-Reply-To: References: <1105de23-861c-fdc6-ebba-32c48f75f2bd@gmail.com> <751a892c-4541-20bd-7c60-d2da20d2fcbd@gmail.com> Message-ID: On Sun, 5 Jan 2020, 14:38 Marco Sulla, < mail.python.org at marco.sulla.e4ward.com> wrote: > > Sorry, I do not understand. > Probably do you mean: I install all the wheels in a machine identical > to the target I want (maybe using a VM, I don't know if Python support > cross-compiling). Then I copy the folders of the modules inside my > app? > > The problem is: who will maintain the pre-compiled versions of the > modules for every OSes? As a programmer, I can assure you I'm not > really slightly interested to do this work at all :D > Nor me, a bad idea, this part is open for discussion. IMHO the most simple solution is that Python ships, together the > installer of the interpreter, a C compiler for systems, like Windows, > where such compiler is not pre-installed. Maybe gcc or Clang. If the > user wants to use its installer, no problem, (s)he can customize it. > > This way you can create a sort of python installer that is nothing > more that a zip file with the source code of the app, the wheels of > the dependencies and a setup.py. Where the zip is opened by python, it > should execute the setup.py, that will create the venv, install the > app and the wheels. And since Python ships a beautiful C compiler, the > wheels will be installed without problems (in the best of the > worlds...) > This part is open to discussions. It should be under: Proposed changes to the interpreter part > Do you have the link of the PEP you cited? > Must look for it, will be a long hunt apparently The end user it's not interested to have the most updated Python in > the world. As you said down below, programs do. The adoption of 3.7 was amazing, i've seen libs use f strings as though it was an old buddy. People are interested to build programs using new features available but that's according to me is bad practise as you always have people lagging behind. But on the other hand security fixes interpreter side might be a good upgrade inventive. The end user probably does not even _know_ what is Python. > That's what the Python, Be Bold approach suggests, to make end-users more and more aware of what a Python distribution is. It should not be a shame for devs to introduce end-users to a Python installation on their system. For example, what happens if an user tries to use an executable jar > than needs a more updated version of java than the one that is > installed on the user machine? Well, if it's well written, it's the > program itself that gives him / her an alert: "You need Java version > Z". That's a nice idea, but if on interpreter side, might be easier unless in-built alert mechanism when executing the archive. The user will snort, and finally will search on Google the Java > version (s)he needs.No auto update. No ... auto-update is a bad idea, third time saying that on this thread ^^_ Proposing instead the ability to update not auto-update From torriem at gmail.com Sun Jan 5 17:50:41 2020 From: torriem at gmail.com (Michael Torrie) Date: Sun, 5 Jan 2020 15:50:41 -0700 Subject: Error in python installation - was Re: Python, Be Bold! In-Reply-To: <1928171622.4535748.1578236377909@mail.yahoo.com> References: <59256794.4317944.1578122984185@mail.yahoo.com> <1928171622.4535748.1578236377909@mail.yahoo.com> Message-ID: On 1/5/20 7:59 AM, Kishor Soni wrote: > After proceeding installation, few minutes later such error appears "0x80072f7d - unspecified error" > A log file is generated and attached herewith I prefer to keep communication on the list. Where did you download the installer from? Python.org or some other distribution like Anaconda? Are you installing for all users, or just for your current user? What has google found about this error message and python? Does google tell you whether anyone else has seen this error message while installing Python before? I don't have Windows, so I can only speculate, and do the same google searches you can do. Finally, have you tried installing Python through the Microsoft Store on Windows 10? It's officially released by python.org core devs and should always be free. From hanan.lamaazi at gmail.com Sun Jan 5 07:56:16 2020 From: hanan.lamaazi at gmail.com (hanan lamaazi) Date: Sun, 5 Jan 2020 16:56:16 +0400 Subject: Dataset training using Kmeans Message-ID: Dear all, I'm actually using the K-means algorithm for clustering, and scikit-learn machine learning in python. when I want to print my "score_accuarcy" using this command >print(metrics.accuracy_score(y_test, y_pred)) I get the following error : "Classification metrics can't handle a mix of continuous-multioutput and binary targets" I use Python version 3.7 and Jupyter notebook Thank you in advance From arj.python at gmail.com Mon Jan 6 05:21:14 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 6 Jan 2020 14:21:14 +0400 Subject: Python, Be Bold! - The Draft Message-ID: Note: Prepared a draft on the previous discussion, motivated by the vision of an era where the world swarms in Python apps. This draft is not a PEP, at least not yet. It's structure approaches a PEP but takes liberties as necessary. It includes info deemed as essential. Thanking list members for their input. Abstract ====== This original proposal outlines 3 points to enhance app making in Python, namely: -- The formulation of a Python-specific single-file executable (Archive) -- Better integration of the VM with the OS -- Features to be supported by the native Gui library This proposal aims at working to boost the dissemination of Python apps and help further promote Python as the language of choice for developing apps. It explores beyond performance, what can be improved? But since the previous thread focused on the archive, we'll focus on it in this draft. Aim Expansion ============ One area where there remains some difficulty in Python is packaging for end-user consumption. To that effect either the code is distributed in pure Python form with installers or native executables are built for each target Os. Currently by default, Python does not provide such utilities. This pro- posal aims at finalising a Python-specific archive as the default VM exec- utable. To further support the above, the proposals explores the impacts on the interpreter: how should it be modified. Modifications explored don't touch the parser in any way. Instead of discussing how to better integrate the official dist with the System, this will discuss only archive-specific mod- ifications. A push to choose Python might be providing better GUI options, so that apps become more powerful, more beautiful and with even faster develop- ment time. The proposal aimed to show the limitations of the current GUI option (tkinter) and what features can make app-making using default uti- lities a class above. But, it is bulky enough to be discussed in a different draft. In the light of the above, this draft's topic will be: Python-specific Executable Archive. Python-specific Executable Archive =========================== Inspiration -------------- Java has a file format called .jar which allows bundled programs to be run with a simple click. Defining Executable --------------------------- Before we begin, we'd like to define the term executable used in the context of this draft. It means an archive that is run by double-clicking. This is made possible by file association. The closest example existent is the .pyz file format. Although for example .jar files are not native executables, they are nonetheless referred to in common language as executable as in question like these: How to create an executable jar in java . Closest Python Implementation ----------------------------------------- Python already has an archive bundling module called zipapp which allow a project to be bundled as a zip archive which has __main__.py as an point. Advantages of zip-executables ----------------------------------------- PEP441 states one of the advantage as: "These archives provide a great way to publish software that needs to be distributed as a single file script but is complex enough to need to be written as a collection of modules." Oracle Docs state the advantage of archive executables in the following term: "JAR files are packaged with the ZIP file format, so you can use them for tasks such as lossless data compression, archiving, decompression, and archive unpacking. These tasks are among the most common uses of JAR files, and you can realize many JAR file benefits using only these basic features. Even if you want to take advantage of advanced functionality provided by the JAR file format such as electronic signing ..." Other advantages include - Portability - Security - Versioning - Dependency freezing which will be discussed when discussing specific examples. How a .jar can help? ---------------------------- Both Java and Python share similarities in having a VM, bytecodes and being labelled as cross-platform languages. Java has a .jar format for distribution. The .jar file gave rise to many formats such as the .apk Brief ==== This proposal proposes to alter zipapp with enhanced security and versioning among others. It can have a .pyz extention or choose another extention. Existing solutions ============== In this section we give an overview of existing file formats. 1) .Jar --------- An official intro runs like this: "JAR file is a file format based on the popular ZIP file format and is used for aggregating many files into one. A JAR file is essentially a zip file that contains an optional META-INF directory. A JAR file can be created by the command-line jar tool, or by using the java.util.jar API in the Java platform. There is no restriction on the name of a JAR file, it can be any legal file name on a particular platform. In many cases, JAR files are not just simple archives of java classes files and/or resources. They are used as building blocks for applications and extensions. The META-INF directory, if it exists, is used to store package and extension configuration data, including security, versioning, extension and services." Which follows that .jar is not only used for program bundling but also for packaging modules. - META-INF/MANIFEST.MF The manifest file is a file containing meta information. A simple one generated might look like this: ``` Manifest-Version: 1.0 Created-By: 11.0.3 (AdoptOpenJDK) ``` An advanced one add in many things such as author name, corporation name, build tool name etc etc. The idea of a manifest file was further exploited by the .apk format - Digital Signature Modified from here , signing a Jar file means: "When the JAR file is signed, you also have the option of time stamping the signature. Similar to putting a date on a paper document, time stamping the signature identifies when the JAR file was signed. The time stamp can be used to verify that the certificate used to sign the JAR file was valid at the time of signing. ... If you have downloaded some code that's signed by a trusted entity, you can use that fact as a criterion in deciding which security permissions to assign to the code. ... The Java platform enables signing and verification by using special numbers called public and private keys. Public keys and private keys come in pairs, and they play complementary roles. The private key is the electronic "pen" with which you can sign a file. As its name implies, your private key is known only to you so that no one else can "forge" your signature. A file signed with your private key can be verified only by the corresponding public key. ... One more element, therefore, is required to make signing and verification work. That additional element is the certificate that the signer includes in a signed JAR file. A certificate is a digitally signed statement from a recognized certification authority that indicates who owns a particular public key. Certification authorities are entities (typically firms specializing in digital security) that are trusted throughout the industry to sign and issue certificates for keys and their owners. In the case of signed JAR files, the certificate indicates who owns the public key contained in the JAR file. When you sign a JAR file your public key is placed inside the archive along with an associated certificate so that it's easily available for use by anyone wanting to verify your signature. To summarize digital signing: -The signer signs the JAR file using a private key. -The corresponding public key is placed in the JAR file, together with its certificate, so that it is available for use by anyone who wants to verify the signature." - Signature Files When you sign a JAR file, each file in the archive is given a digest entry in the archive's manifest. Here's an example of what such an entry might look like: Name: test/classes/ClassOne.class SHA1-Digest: TD1GZt8G11dXY2p4olSZPc5Rj64= The digest values are hashes or encoded representations of the contents of the files as they were at the time of signing. A file's digest will change if and only if the file itself changes. When a JAR file is signed, a signature file is automatically generated and placed in the JAR file's META-INF directory, the same directory that contains the archive's manifest. Signature files have filenames with an .SF extension. Here is an example of the contents of a signature file: Signature-Version: 1.0 SHA1-Digest-Manifest: h1yS+K9T7DyHtZrtI+LxvgqaMYM= Created-By: 1.7.0_06 (Oracle Corporation) Name: test/classes/ClassOne.class SHA1-Digest: fcav7ShIG6i86xPepmitOVo4vWY= Name: test/classes/ClassTwo.class SHA1-Digest: xrQem9snnPhLySDiZyclMlsFdtM= Name: test/images/ImageOne.gif SHA1-Digest: kdHbE7kL9ZHLgK7akHttYV4XIa0= Name: test/images/ImageTwo.gif SHA1-Digest: mF0D5zpk68R4oaxEqoS9Q7nhm60= - Signature Block File In addition to the signature file, a signature block file is automatically placed in the META-INF directory when a JAR file is signed. Unlike the manifest file or the signature file, signature block files are not human-readable. The signature block file contains two elements essential for verification: The digital signature for the JAR file that was generated with the signer's private key The certificate containing the signer's public key, to be used by anyone wanting to verify the signed JAR file Signature block filenames typically will have a .DSA extension indicating that they were created by the default Digital Signature Algorithm. Other filename extensions are possible if keys associated with some other standard algorithm are used for signing. 2) Android -------------- The .apk is much like ,jar, it's whole content can be found here . It's manifest file includes the interesting concept of permissions. Android has .apk for apps and .arr for modules. The developer's website states: "An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that you can use as a dependency for an Android app module. Unlike JAR files, AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods. A library module is useful in the following situations: -When you're building multiple apps that use some of the same components, such as activities, services, or UI layouts. -When you're building an app that exists in multiple APK variations, such as a free and paid version and you need the same core components in both." - Signing Since we already included .jar signing in this mail, we'll include only relevent links. Android has 3 signing schemes, one based on.jar , scheme v2 , and v3 3rd Party Packages =============== Before we go on to discuss recommended specifications for our solution, we'll discuss a bit about including 3rd party modules in the folder itself. One of the strengths of Python is the extensive 3rd party modules available and, the swift addition of libraries. A normal python distribution includes 3rd party packages under Lib/site-packages/ Virtual environments include 3rd party packages under env-name/Lib/site-packages/ For the archive also, proposing to include 3rd party packages under a site-packages folder It can be created on bundling with packages included. Dealing with 3rd party C-based packages ================================ The above 3rd party package dealing should have sufficed if Python always executed pure-python codes. However Python provides an effective way of speeding up apps by writing C-codes. It poses the problem of OS-specific files. Instead of including the libs themselves, we can include wheels project/ wheels/ # included upon building of archive site-packages/ # included when running app Those are only ideas Zipapp as a practical solution for 3rd party bundling ======================================== Here user lukassup provided the way of bundling and running a flask app via zipapp. He did not install packages in a venv but rather in a separate folder, which for our purposes can be named as site-packages. The final structure looks like this: ??? app/ ? ??? click/ ? ??? flask/ ? ??? gunicorn/ ? ??? jinja2/ ? ??? markupsafe/ ? ??? werkzeug/ ? ??? itsdangerous.py ? ??? requirements.txt ??? flaskr/ ? ??? flaskr/ ? ??? flaskr.egg-info/ ? ??? venv/ ? ??? LICENSE ? ??? MANIFEST.in ? ??? README.rst ? ??? requirements.txt ? ??? setup.py ??? venv/ ??? bin/ ??? include/ ??? lib/ ??? pip-selfcheck.json Entry points ========= An entry point is important to know what file to launch on archive execution for .jar it can be specified at the command line or in the manifest Main-Class: MyPackage.MyClass PyInstaller generates a .spec file based on your entry point file Zipapp has a __main__.py file or you can set your entry point via command line $ python3 -m zipapp APP_DIR -m ENTRYPOINT_MODULE:ENTRYPOINT_FUNCTION -p PYTHON_INTERPRETER pynsist lets you specify an entry point in your installer.cfg file Now after going through .jar, Android and zipapp, we can formulate some specifications Specifications for a Python-specific executable ==================================== - Manifest A user manifest where the user includes relevent archiving info A generated manifest with info to be included while archiving like signing info - Sigining To check whether file contents are the same as at the time of archiving - Entry point Which file to launch - Bundling 3rd party packages wheels inclusion seems to be the answer. - Exec mode Does temporary files offer advantages over in-memory execution? Can it be an advantage for 3rd party packages? This draft does not propose a fixed solution but expects proposals from the community (like hash, which hash to use etc) or point point wrong assumptions. Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius From o1bigtenor at gmail.com Mon Jan 6 09:36:25 2020 From: o1bigtenor at gmail.com (o1bigtenor) Date: Mon, 6 Jan 2020 08:36:25 -0600 Subject: Python, Be Bold! - The Draft In-Reply-To: References: Message-ID: On Mon, Jan 6, 2020 at 4:23 AM Abdur-Rahmaan Janhangeer wrote: > > Note: Prepared a draft on the previous discussion, motivated by the vision > of > an era where the world swarms in Python apps. This draft is not a PEP, at > least > not yet. It's structure approaches a PEP but takes liberties as necessary. > It > includes info deemed as essential. Thanking list members for their input. > Maybe I'm just slow but it really seems like what you are trying to achieve is a java like system. Wouldn't you find it easier to just use java rather than trying to remake Python into Java? (It would be easier imo.) From rhodri at kynesim.co.uk Mon Jan 6 11:22:19 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 6 Jan 2020 16:22:19 +0000 Subject: Dataset training using Kmeans In-Reply-To: References: Message-ID: <73d02255-904f-47d3-2e7b-e7d991d0a04f@kynesim.co.uk> On 05/01/2020 12:56, hanan lamaazi wrote: > Dear all, > > I'm actually using the K-means algorithm for clustering, and scikit-learn > machine learning in python. > > when I want to print my "score_accuarcy" using this command > >> print(metrics.accuracy_score(y_test, y_pred)) > > I get the following error : > > "Classification metrics can't handle a mix of continuous-multioutput and > binary targets" This is probably an exception from metrics.accuracy_score() (you've shorn off too much context for me to be certain). Googling the text gives me no shortage of links; you are far more likely than me to recognise which of them are relevant to your circumstances. -- Rhodri James *-* Kynesim Ltd From rhodri at kynesim.co.uk Mon Jan 6 11:44:50 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 6 Jan 2020 16:44:50 +0000 Subject: Python, Be Bold! - The Draft In-Reply-To: References: Message-ID: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> On 06/01/2020 10:21, Abdur-Rahmaan Janhangeer wrote: > Before we begin, we'd like to define the term executable used in the context > of this draft. It means an archive that is run by double-clicking. I'm an embedded systems programmer. Congratulations, you have just rendered your draft utterly irrelevant to me and those like me. -- Rhodri James *-* Kynesim Ltd From rhodri at kynesim.co.uk Mon Jan 6 11:49:58 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 6 Jan 2020 16:49:58 +0000 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On 01/01/2020 07:22, Abdur-Rahmaan Janhangeer wrote: > -- Self-updating Python distributions Microsoft have proved time and again that this is a really good thing if you want to piss off your customer base. Let's not. > -- Distributions which notify about new releases Surely this is the OS's package management system's job? > -- Easy compilation to python-specific executable (.pyz is a good candidate) Don't we already have .pyc files? > -- More robust native Gui facilities Why is this a core Python issue? GUIs are inherently OS-specific (including those OSes -- or lack of OSes -- which have no graphical interface). -- Rhodri James *-* Kynesim Ltd From rosuav at gmail.com Mon Jan 6 12:00:16 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 7 Jan 2020 04:00:16 +1100 Subject: Python, Be Bold! - The Draft In-Reply-To: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> References: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> Message-ID: On Tue, Jan 7, 2020 at 3:47 AM Rhodri James wrote: > > On 06/01/2020 10:21, Abdur-Rahmaan Janhangeer wrote: > > Before we begin, we'd like to define the term executable used in the context > > of this draft. It means an archive that is run by double-clicking. > > I'm an embedded systems programmer. Congratulations, you have just > rendered your draft utterly irrelevant to me and those like me. > Don't worry. It's trying to solve a problem that doesn't exist, in a platform-specific way, imitating a completely different execution model, and ultimately is just reinventing what pip already does. You can safely ignore it for plenty of reasons besides the misuse of "executable". ChrisA From arj.python at gmail.com Mon Jan 6 12:04:03 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 6 Jan 2020 21:04:03 +0400 Subject: Python, Be Bold! - The Draft In-Reply-To: References: Message-ID: On Mon, 6 Jan 2020, 18:37 o1bigtenor, wrote: > > Maybe I'm just slow but it really seems like what you are trying to > achieve is > a java like system. > > Wouldn't you find it easier to just use java rather than trying to remake > Python into Java? (It would be easier imo.) > It proposes to enhance zipapp but included relevent info to pull in ideas > From arj.python at gmail.com Mon Jan 6 12:05:27 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 6 Jan 2020 21:05:27 +0400 Subject: Python, Be Bold! - The Draft In-Reply-To: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> References: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> Message-ID: On Mon, 6 Jan 2020, 20:46 Rhodri James, wrote: > > I'm an embedded systems programmer. Congratulations, you have just > rendered your draft utterly irrelevant to me and those like me. > If you followed the previous thread there was some misunderstanding as to what do i mean by executable, sorry. > From arj.python at gmail.com Mon Jan 6 12:06:55 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 6 Jan 2020 21:06:55 +0400 Subject: Python, Be Bold! - The Draft In-Reply-To: References: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> Message-ID: On Mon, 6 Jan 2020, 21:01 Chris Angelico, wrote: > > Don't worry. It's trying to solve a problem that doesn't exist, in a > platform-specific way, imitating a completely different execution > model, and ultimately is just reinventing what pip already does. You > can safely ignore it for plenty of reasons besides the misuse of > "executable". > Hum it proposes to enhance zipapp, well, pip has it's use and i don't think package managers are a replacement for zip archives. > From arj.python at gmail.com Mon Jan 6 12:10:01 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 6 Jan 2020 21:10:01 +0400 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: On Mon, 6 Jan 2020, 20:50 Rhodri James, wrote: > On 01/01/2020 07:22, Abdur-Rahmaan Janhangeer wrote: > > -- Self-updating Python distributions > > Microsoft have proved time and again that this is a really good thing if > you want to piss off your customer base. Let's not. > Nooooo if you read the thread (please do it), that's the 4th time i'm saying it's a bad idea > > -- Distributions which notify about new releases > > Surely this is the OS's package management system's job? > In windows for example, the interpreter/VM and package manager is referred to as a dustribution > -- Easy compilation to python-specific executable (.pyz is a good > candidate) > > Don't we already have .pyc files? > See the draft thread where pep441 enounces archives' advantages > -- More robust native Gui facilities > > Why is this a core Python issue? GUIs are inherently OS-specific > (including those OSes -- or lack of OSes -- which have no graphical > interface). > This is an issue which requires it's own thread. > From arj.python at gmail.com Mon Jan 6 12:24:37 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 6 Jan 2020 21:24:37 +0400 Subject: Python, Be Bold! - The Draft In-Reply-To: References: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> Message-ID: ---------- Forwarded message --------- From: AAKASH JANA Date: Mon, 6 Jan 2020, 21:15 Subject: Re: Python, Be Bold! - The Draft To: Abdur-Rahmaan Janhangeer Maybe but if you know or have heard of Julia the language. You will realise its going to take over what python gives us. So i think there is urgent need for upgrades to newer versions of python to make basic tasks on python way quicker. On Mon, 6 Jan 2020, 10:39 pm Abdur-Rahmaan Janhangeer On Mon, 6 Jan 2020, 20:46 Rhodri James, wrote: > > > > > I'm an embedded systems programmer. Congratulations, you have just > > rendered your draft utterly irrelevant to me and those like me. > > > > If you followed the previous thread there was some misunderstanding as to > what do i mean by executable, sorry. > > > > -- > https://mail.python.org/mailman/listinfo/python-list > From PythonList at DancesWithMice.info Mon Jan 6 12:43:49 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 7 Jan 2020 06:43:49 +1300 Subject: Python, Be Bold! In-Reply-To: References: Message-ID: <419f380f-ac55-d287-86c6-417f261ea673@DancesWithMice.info> On 7/01/20 6:10 AM, Abdur-Rahmaan Janhangeer wrote: > On Mon, 6 Jan 2020, 20:50 Rhodri James, wrote: > Nooooo if you read the thread (please do it), that's the 4th time i'm > saying it's a bad idea I have not (been following the thread) - with all due apologies. Podcast of possible interest: Episode #245: Python packaging landscape in 2020 https://talkpython.fm/episodes/show/245/python-packaging-landscape-in-2020 -- Regards =dn From rgaddi at highlandtechnology.invalid Mon Jan 6 13:15:12 2020 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Mon, 6 Jan 2020 10:15:12 -0800 Subject: (no subject) In-Reply-To: References: Message-ID: On 1/4/20 2:29 PM, William Johnsson wrote: > Hello! My name is William and im 14 years old and live in sweden. Im pretty new to programing in python and i need some help with code, (That?s why i?m here). But i couldn?t really find what i was searching for on the internet. I?m trying to write code that can check only the first line in a .txt file and check if it?s the same as the int 1000. I preferably want it to be an if satement but anything works, i just don?t know how i should write it. I?ve been browsing the internet for a solution but sadly can?t seem to find a solution to it. > > I don?t really know if this is the right way to get help or even if this email is for something else. Hopefully i will get some kind of response. > > Best regards, William > It won't be; it can't be. A text file contains only text. The line you read from it might be the string '1000' (or more likely '1000\n', which is 4 digits followed by a newline character), but it cannot be the int 1000 because data has types. str(1000) gives you '1000', because ints can be converted to strings. int('1000') gives you 1000 because and strings consisting only of digits can be converted to ints. So the two types are convertible into one another. But that's a thing you need to do explicitly. If x is a thing you just read from a text file then if x == 1000: can never be true. From rgaddi at highlandtechnology.invalid Mon Jan 6 13:17:38 2020 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Mon, 6 Jan 2020 10:17:38 -0800 Subject: Hi!! im searching for a ready app of python for pdf combiner In-Reply-To: References: Message-ID: On 1/6/20 8:13 AM, alon.najman at gmail.com wrote: > Hi!! im searching for a ready app of python for pdf combiner > what I need exactly is a pdf combiner for 20 + pdfs to combine them as one, do a merge > Why does this need to be in Python? Just download a copy of pdftk (which I think is written in Java?) and move on with your life. From arj.python at gmail.com Mon Jan 6 14:17:25 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 6 Jan 2020 23:17:25 +0400 Subject: Python, Be Bold! In-Reply-To: <419f380f-ac55-d287-86c6-417f261ea673@DancesWithMice.info> References: <419f380f-ac55-d287-86c6-417f261ea673@DancesWithMice.info> Message-ID: Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius On Mon, Jan 6, 2020 at 9:44 PM DL Neil via Python-list < python-list at python.org> wrote: > > I have not (been following the thread) - with all due apologies. > > Podcast of possible interest: > Episode #245: Python packaging landscape in 2020 > https://talkpython.fm/episodes/show/245/python-packaging-landscape-in-2020 For interested people listen the podcast from time 32:00 From aakashjana2002 at gmail.com Mon Jan 6 12:06:42 2020 From: aakashjana2002 at gmail.com (AAKASH JANA) Date: Mon, 6 Jan 2020 22:36:42 +0530 Subject: No subject Message-ID: Julia is a rapidly progressing language directly attacking python's sweet spot in a.i , m.l and other computational areas. I love python and want it to remain undefeated . I think its time we create a compiler for python . So that python can be compiled and interpreted at will . Its time we make our snake go faster than the world.(and most importantly Julia) From arj.python at gmail.com Mon Jan 6 14:34:39 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 6 Jan 2020 23:34:39 +0400 Subject: Enhancing Zipapp Message-ID: Note: draft simplified Abstract ====== This extracts aims at proposing enhancements to the generated zipapp executable Rationale ======= One area where there remains some difficulty in Python is packaging for end-user consumption. To that effect either the code is distributed in pure Python form with installers [1] or native executables are built for each target Os [2]. Currently by default, Python does not provide such utilities. This pro- posal aims at finalising a Python-specific archive as the default VM exec- utable built on zipapp. In simple terms, it proposes to enhance zipapp from plain archive to app-level archive. Advantages of archives ================== Archives provide a great way to publish software that needs to be distributed as a single file script but is complex enough to need to be written as a collection of modules [3] You can use archives for tasks such as lossless data compression, archiving, decompression, and archive unpacking. [4] Adding capabilities like digital signing is used to verify integrity and authenticity. Zip archives as apps ================ If we are to treat zip archives as app, here are some recommended features - [x] Main entry point A main entry point specifies which file to launch. Zipapp already solves this problem by either having a __main__.py [5] or specifying the entry point at the commandline ENTRYPOINT_MODULE:ENTRYPOINT_FUNCTION [6] - [ ] App info file An info file can have info such as author name, archiving date, company name etc. - [ ] Signing mechanism Mechanisms can be added to detect the integrity of the app. App hash can be used to check if the app has been modified and per-file hash can be used to detect what part has been modified. This can be further enhanced if needed. - [ ] Protecting meta data Metadata are not protected by basic signing. There existing ways to protect metadata and beyond [7] - [x] Pure-Python 3rd party package bundling In Python, as long as the 3rd party packages are pure-python packages, we can bundle and use them [6]. The user can maybe just include a requirements.txt - [ ] C-based 3rd party packages Zipapp by default was not meant to include packages at all. << The executable zip format is specifically designed for standalone use, without needing to be installed. They are in effect a multi-file version of a standalone Python script >> Though the previous point shows that this can be done. Now remains the issue of C-based packages. Distributing wheels might be the answer [8]. A zip archive is supposed to be standalone. A possible solution might be to include wheels and the wheels are installed in a site-packages folder. When running such an app, the interpreter will check first if the app-specific site-packages folder is empty, if not, install the wheels. This provides package- freezing ability. The only downside is longer first-run time. Only specifying packages to be installed is not an option as if you really want stand-alone apps, using the internet etc defeats the purpose. FAQ ==== Why not a package manager? --------------------------------------- The zipapp pep was introduced for a reason, for easing the running of archives. Maybe the package manager idea came from listening to people talking about packaging and pex and comparing it with package-managers like homebrew and concluded that pex and hence zipapp is not worth it and people would better off not complicate their lives with some zip utility. This proposal is not solving any problem at all -------------------------------------------------------------- This proposal aims at enhancing zipapp. Zipapp solved the problem. Zipapp had an aim. This proposal aims at helping zipapp better accompplish it's aim. References [1] https://pynsist.readthedocs.io/en/latest/ [2] https://www.pyinstaller.org [3] https://www.python.org/dev/peps/pep-0441/ [4] https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html [5] https://docs.python.org/3/library/zipapp.html [6] https://gist.github.com/lukassup/cf289fdd39124d5394513a169206631c [7] https://source.android.com/security/apksigning [8] https://pythonwheels.com Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius From alon.najman at gmail.com Mon Jan 6 11:13:13 2020 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Mon, 6 Jan 2020 08:13:13 -0800 (PST) Subject: Hi!! im searching for a ready app of python for pdf combiner Message-ID: Hi!! im searching for a ready app of python for pdf combiner what I need exactly is a pdf combiner for 20 + pdfs to combine them as one, do a merge From rosuav at gmail.com Mon Jan 6 14:50:30 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 7 Jan 2020 06:50:30 +1100 Subject: No subject In-Reply-To: References: Message-ID: On Tue, Jan 7, 2020 at 6:35 AM AAKASH JANA wrote: > > Julia is a rapidly progressing language directly attacking python's sweet > spot in a.i , m.l and other computational areas. I love python and want it > to remain undefeated . I think its time we create a compiler for python . > So that python can be compiled and interpreted at will . Its time we make > our snake go faster than the world.(and most importantly Julia) If you're that green with envy, go and create one. See whether it improves things. You'll learn a lot in the process. ChrisA From rosuav at gmail.com Mon Jan 6 14:53:15 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 7 Jan 2020 06:53:15 +1100 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: References: Message-ID: On Tue, Jan 7, 2020 at 6:37 AM Abdur-Rahmaan Janhangeer wrote: > When running such an app, the interpreter will check first if the app-specific > site-packages folder is empty, if not, install the wheels. This provides package- > freezing ability. The only downside is longer first-run time. Where is this directory? What if it already contains content? Are you proposing that *any* zipapp archive is capable of downloading arbitrary code from the internet and then running it, without any prompting from the user? ChrisA From arj.python at gmail.com Mon Jan 6 15:15:27 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 7 Jan 2020 00:15:27 +0400 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: References: Message-ID: Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius On Mon, Jan 6, 2020 at 11:53 PM Chris Angelico wrote: > On Tue, Jan 7, 2020 at 6:37 AM Abdur-Rahmaan Janhangeer > wrote: > Where is this directory? What if it already contains content? > It's sometimes typical for extracted zips to be in temporary folders. If we are including wheels maybe we can have a permanent folder for extracting the wheels and the interpreter looks for those in it Are you proposing that *any* zipapp archive is capable of downloading > arbitrary code from the internet and then running it, without any > prompting from the user? > Exactly the opposite, the archive bundler includes all that have to be included so that the app runner does not have to do it. Proposing to include pa If we are talking about the scenario where a malware already lying in wait in the packages folder then it's the same as malware entering the interpreter's site-packages If we are talking about malicious code in a package that gets called when running the zipapp without prompt, then that's the same issue with all executables (like apps built with pyinstaller). If ever we want to mitigate that risk, it depends if we trust the sender. That's also where the proposed security features come into play. From arj.python at gmail.com Mon Jan 6 15:16:48 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 7 Jan 2020 00:16:48 +0400 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: References: Message-ID: On Tue, Jan 7, 2020 at 12:15 AM Abdur-Rahmaan Janhangeer < arj.python at gmail.com> wrote: > Proposing to include pa > please ignore that part From post at tinita.de Mon Jan 6 15:33:22 2020 From: post at tinita.de (=?ISO-8859-15?Q?Tina_M=FCller?=) Date: Mon, 6 Jan 2020 21:33:22 +0100 (CET) Subject: [ANN] PyYAML-5.3: YAML parser and emitter for Python Message-ID: ======================= Announcing PyYAML-5.3 ======================= A new release of PyYAML is now available: https://pypi.org/project/PyYAML/ This release contains some bugfixes (handling of slots, enable unicode for maxunicode < 0xffff, enable large files), enhancements (create timezone aware datetimes) and some other small enhancements. Changes ======= * https://github.com/yaml/pyyaml/pull/290 -- Use `is` instead of equality for comparing with `None` * https://github.com/yaml/pyyaml/pull/270 -- fix typos and stylistic nit * https://github.com/yaml/pyyaml/pull/309 -- Fix up small typo * https://github.com/yaml/pyyaml/pull/161 -- Fix handling of __slots__ * https://github.com/yaml/pyyaml/pull/358 -- Allow calling add_multi_constructor with None * https://github.com/yaml/pyyaml/pull/285 -- Add use of safe_load() function in README * https://github.com/yaml/pyyaml/pull/351 -- Fix reader for Unicode code points over 0xFFFF * https://github.com/yaml/pyyaml/pull/360 -- Enable certain unicode tests when maxunicode not > 0xffff * https://github.com/yaml/pyyaml/pull/359 -- Use full_load in yaml-highlight example * https://github.com/yaml/pyyaml/pull/244 -- Document that PyYAML is implemented with Cython * https://github.com/yaml/pyyaml/pull/329 -- Fix for Python 3.10 * https://github.com/yaml/pyyaml/pull/310 -- increase size of index, line, and column fields * https://github.com/yaml/pyyaml/pull/260 -- remove some unused imports * https://github.com/yaml/pyyaml/pull/163 -- Create timezone-aware datetimes when parsed as such * https://github.com/yaml/pyyaml/pull/363 -- Add tests for timezone Resources ========= PyYAML IRC Channel: #pyyaml on irc.freenode.net PyYAML homepage: https://github.com/yaml/pyyaml PyYAML documentation: http://pyyaml.org/wiki/PyYAMLDocumentation Source and binary installers: https://pypi.org/project/PyYAML/ GitHub repository: https://github.com/yaml/pyyaml/ Bug tracking: https://github.com/yaml/pyyaml/issues YAML homepage: http://yaml.org/ YAML-core mailing list: http://lists.sourceforge.net/lists/listinfo/yaml-core About PyYAML ============ YAML is a data serialization format designed for human readability and interaction with scripting languages. PyYAML is a YAML parser and emitter for Python. PyYAML features a complete YAML 1.1 parser, Unicode support, pickle support, capable extension API, and sensible error messages. PyYAML supports standard YAML tags and provides Python-specific tags that allow to represent an arbitrary Python object. PyYAML is applicable for a broad range of tasks from complex configuration files to object serialization and persistence. Example ======= >>> import yaml >>> yaml.full_load(""" ... name: PyYAML ... description: YAML parser and emitter for Python ... homepage: https://github.com/yaml/pyyaml ... keywords: [YAML, serialization, configuration, persistence, pickle] ... """) {'keywords': ['YAML', 'serialization', 'configuration', 'persistence', 'pickle'], 'homepage': 'https://github.com/yaml/pyyaml', 'description': 'YAML parser and emitter for Python', 'name': 'PyYAML'} >>> print(yaml.dump(_)) name: PyYAML homepage: https://github.com/yaml/pyyaml description: YAML parser and emitter for Python keywords: [YAML, serialization, configuration, persistence, pickle] Maintainers =========== The following people are currently responsible for maintaining PyYAML: * Ingy d?t Net * Tina Mueller * Matt Davis and many thanks to all who have contribributed! See: https://github.com/yaml/pyyaml/pulls Copyright ========= Copyright (c) 2017-2019 Ingy d?t Net Copyright (c) 2006-2016 Kirill Simonov The PyYAML module was written by Kirill Simonov . It is currently maintained by the YAML and Python communities. PyYAML is released under the MIT license. See the file LICENSE for more details. From torriem at gmail.com Mon Jan 6 16:21:38 2020 From: torriem at gmail.com (Michael Torrie) Date: Mon, 6 Jan 2020 14:21:38 -0700 Subject: Python, Be Bold! - The Draft In-Reply-To: References: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> Message-ID: <1349bdf5-0b56-0edf-d71f-e6b851bad24c@gmail.com> On 1/6/20 10:24 AM, Abdur-Rahmaan Janhangeer wrote: > Maybe but if you know or have heard of Julia the language. You will realise > its going to take over what python gives us. So i think there is urgent > need for upgrades to newer versions of python to make basic tasks on python > way quicker. No it sure won't. You can't possibly make such a blanket statement. Julia might replace python for some users, perhaps those involved in data science, but Python stands on its own merits. And currently that standing is pretty good. If that changes in the future, oh well. Languages come and go. Besides all that, if some users find Julia fits their need better, why is that a bad thing? You talk like it's a zero sum game. It's not. I don't see where this urgency is coming from. Put in another way, Python fills the needs of many users at present. This isn't going to magically change because you see something that is deficient in your opinion. From torriem at gmail.com Mon Jan 6 16:37:36 2020 From: torriem at gmail.com (Michael Torrie) Date: Mon, 6 Jan 2020 14:37:36 -0700 Subject: No subject In-Reply-To: References: Message-ID: <6f490a68-2666-0297-b2ed-78c0ee5276e3@gmail.com> On 1/6/20 10:06 AM, AAKASH JANA wrote: > Julia is a rapidly progressing language directly attacking python's sweet > spot in a.i , m.l and other computational areas. I love python and want it > to remain undefeated . I think its time we create a compiler for python . > So that python can be compiled and interpreted at will . Its time we make > our snake go faster than the world.(and most importantly Julia) Why is it so important for "python to remain undefeated?" Furthermore what do you suppose Python is "undefeated" at? If Julia is better suited to certain computational areas, then more power to it. As I posted just a few minutes ago, languages come and go, and specialize in certain things. Python certainly is popular right now and good at lots of things, but something else might come along and relegate it to a fond memory. Besides, for obvious reasons, Python doesn't lend itself to compiling. It's too dynamic. Either you get slow executables where some code can be compiled and other bits are interpreted (nuitka), or you get a language that is a subset of python that compiles to a very fast executable or library (Cython). Honestly, for what most people use Python for, compiling is of little value. Even math people who use Python, rely on numpy or similar high-speed libraries which are written in a compiled language and used from Python. This is, in my opininon, what Python excels at. It's an easy-to-use glue for connecting parts. From barry at barrys-emacs.org Mon Jan 6 16:57:54 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Mon, 6 Jan 2020 21:57:54 +0000 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: References: Message-ID: <91BB8419-AA86-4128-A3E3-0DF5163F4C72@barrys-emacs.org> > On 6 Jan 2020, at 19:34, Abdur-Rahmaan Janhangeer wrote: > > Note: draft simplified Please cover the pro's and con's of the alernatives that have been raised as comments on this idea, as is usually done for a PEP style document. Also beware that zip file format does not include the encoding of the files that are in the zip file. This means that for practical purposes only ASCII filenames are portable across systems. Is this limitation a problem for this proposal? Barry From arj.python at gmail.com Mon Jan 6 20:33:48 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 7 Jan 2020 05:33:48 +0400 Subject: Python, Be Bold! - The Draft In-Reply-To: <1349bdf5-0b56-0edf-d71f-e6b851bad24c@gmail.com> References: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> <1349bdf5-0b56-0edf-d71f-e6b851bad24c@gmail.com> Message-ID: No, i did not write that, it's not Abdur-Rahmaan Janhangeer wrote rather ---------- Forwarded message --------- From: *AAKASH JANA* Date: Mon, 6 Jan 2020, 21:15 Subject: Re: Python, Be Bold! - The Draft To: Abdur-Rahmaan Janhangeer Please forward it to aakashjana2002 at gmail.com On Tue, 7 Jan 2020, 01:21 Michael Torrie, wrote: > On 1/6/20 10:24 AM, Abdur-Rahmaan Janhangeer wrote: > > Maybe but if you know or have heard of Julia the language. You will > realise > > its going to take over what python gives us. So i think there is urgent > > need for upgrades to newer versions of python to make basic tasks on > python > > way quicker. > > No it sure won't. You can't possibly make such a blanket statement. > Julia might replace python for some users, perhaps those involved in > data science, but Python stands on its own merits. And currently that > standing is pretty good. If that changes in the future, oh well. > Languages come and go. Besides all that, if some users find Julia fits > their need better, why is that a bad thing? You talk like it's a zero > sum game. It's not. I don't see where this urgency is coming from. > > Put in another way, Python fills the needs of many users at present. > This isn't going to magically change because you see something that is > deficient in your opinion. > > > -- > https://mail.python.org/mailman/listinfo/python-list > From arj.python at gmail.com Mon Jan 6 20:48:24 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 7 Jan 2020 05:48:24 +0400 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: <91BB8419-AA86-4128-A3E3-0DF5163F4C72@barrys-emacs.org> References: <91BB8419-AA86-4128-A3E3-0DF5163F4C72@barrys-emacs.org> Message-ID: On Tue, 7 Jan 2020, 01:57 Barry Scott, wrote: > > > Please cover the pro's and con's of the alernatives that have been raised > as comments > on this idea, as is usually done for a PEP style document. > Thanks, i don't have much experience writing peps and if i don't bug you may i ask what "alternatives" refer to? Also beware that zip file format does not include the encoding of the files > that are in the > zip file. For the encoding of the contents, well since we are packaging python code files, it's handling will be the same as handling outside the zip file. It's handling is the same as how zipapp handles things. This means that for practical purposes only ASCII filenames are portable > across > systems. Is this limitation a problem for this proposal? > If we are talking about filenames, then i guess ascii filenames are the way to go as you'd unnecessarily break things otherwise. > From torriem at gmail.com Mon Jan 6 20:56:08 2020 From: torriem at gmail.com (Michael Torrie) Date: Mon, 6 Jan 2020 18:56:08 -0700 Subject: Python, Be Bold! - The Draft In-Reply-To: References: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> <1349bdf5-0b56-0edf-d71f-e6b851bad24c@gmail.com> Message-ID: On 1/6/20 6:33 PM, Abdur-Rahmaan Janhangeer wrote: > No, i did not write that, it's not Abdur-Rahmaan Janhangeer wrote rather My mistake. I see now that it was something you forwarded to the list from someone else. Doesn't change my reply, though. Whoever said it, it's not very relevant. Who's "us" and what is it the Python gives them that Julia will soon take over? Python is lots of things to lots of different people. I'm not surprised it fits some people's needs more than others. Julia is a fine language and I encourage the original poster to explore it if it fits his or her needs. From arj.python at gmail.com Mon Jan 6 21:08:33 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 7 Jan 2020 06:08:33 +0400 Subject: Python, Be Bold! - The Draft In-Reply-To: References: <4251ffb1-f731-f105-4027-760ff35ea643@kynesim.co.uk> <1349bdf5-0b56-0edf-d71f-e6b851bad24c@gmail.com> Message-ID: On Tue, 7 Jan 2020, 05:56 Michael Torrie, wrote: > > My mistake. I see now that it was something you forwarded to the list > from someone else. > > Doesn't change my reply, though. Whoever said it, it's not very > relevant. Who's "us" and what is it the Python gives them that Julia > will soon take over? > Don't worry about it, that's how Python lists are. There's an unwritten law that tells whatever thread you start, folks around have the ability to teleport the conversion to higher realms. Here is a Julia ending, another one ended with running Python in the browser. That got me scratching my head as to what i started and what folks end up talking about. > From pythonchb at gmail.com Mon Jan 6 21:39:52 2020 From: pythonchb at gmail.com (Christopher Barker) Date: Mon, 6 Jan 2020 18:39:52 -0800 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: <91BB8419-AA86-4128-A3E3-0DF5163F4C72@barrys-emacs.org> Message-ID: I?m a bit unclear on how far this goes: is it just a bit more specific with more meta-data standards? Or are you aiming for something that will run without a Python install? Other issues: Are you aiming for a bundle that can run on multiple platforms? If so, then it?ll have to have a way to bundle multiple compiled extensions and select the right ones at runtime. If this Is essentially just zipapp with the ability to bundle dependencies, then you could probably just do some sys.path hackery. In any case, thus seems like something you could implement, and then see if people find it useful. BTW- I?m pretty sure we could simply specify that filenames are utf-8 and we?d be good to go. -CHB On Mon, Jan 6, 2020 at 5:50 PM Abdur-Rahmaan Janhangeer < arj.python at gmail.com> wrote: > > > On Tue, 7 Jan 2020, 01:57 Barry Scott, wrote: > >> >> >> Please cover the pro's and con's of the alernatives that have been raised >> as comments >> on this idea, as is usually done for a PEP style document. >> > > Thanks, i don't have much experience writing peps and > if i don't bug you may i ask what "alternatives" refer to? > > Also beware that zip file format does not include the encoding of the >> files that are in the >> zip file. > > > For the encoding of the contents, well since we are > packaging python code files, it's handling will be the same > as handling outside the zip file. It's handling is the > same as how zipapp handles things. > > This means that for practical purposes only ASCII filenames are portable >> across >> systems. Is this limitation a problem for this proposal? >> > > If we are talking about filenames, then i guess > ascii filenames are the way to go as you'd > unnecessarily break things otherwise. > >> _______________________________________________ > Python-ideas mailing list -- python-ideas at python.org > To unsubscribe send an email to python-ideas-leave at python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas at python.org/message/RVGFMDP3PG6TXFQGH7ISRLYM4FS5CO64/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython From nerdynelsons at gmail.com Tue Jan 7 00:19:34 2020 From: nerdynelsons at gmail.com (nerdynelsons at gmail.com) Date: Mon, 6 Jan 2020 21:19:34 -0800 (PST) Subject: Python ABI typeslots for buffer protocol Message-ID: <1e09d60a-ee19-4bf9-a5bb-190ff654c336@googlegroups.com> Hello, I am trying to implement the buffer API for the JPype Python module. Unfortunately the required type slots (Py_bf_getbuffer, Py_bf_releasebuffer) are currently disabled due to the long since closed issue #10181. JPype is a bridge module between Java and Python and as such it is required to create a many dynamic types. Thus I am forced to use the ABI interface. I read through all of Issue #10181 in which the developers were discussing various problems with the implementation of the buffer interface for Python 3.3. At some point they decided to disable that part of the ABI, but then they closed the issue leaving the ABI interface disabled with a reference to the closed issue. I have read through the CPython code and do not see anyway short of hacking the tables to implement the buffer interface for dynamically created types. Is there an alternative way to use the buffer feature? Is the PyBuffer protocol actually usable or is it intended to be disabled? --Karl Nelson From adam.preble at gmail.com Tue Jan 7 00:58:55 2020 From: adam.preble at gmail.com (adam.preble at gmail.com) Date: Mon, 6 Jan 2020 21:58:55 -0800 (PST) Subject: Understanding bytecode arguments: 1 byte versus 2 bytes Message-ID: <4f3e9753-e1a6-43b3-8a67-b6949de67304@googlegroups.com> I'm trying to understand the difference in disassemblies with 3.6+ versus older versions of CPython. It looks like the basic opcodes like LOAD_FAST are 3 bytes in pre-3.6 versions, but 2 bytes in 3.6+. I read online somewhere that there was a change to the argument sizes in 3.6: it became 2 bytes when it used to be just one. I wanted to verify that. For 3.6, if an opcode takes an argument, can I always assume that argument is just one byte? I can think of some situations where that doesn't sounds right. For example, JUMP_ABSOLUTE would be a problem, although I have yet to see that opcode in the wild. Actually, I'd be worried about more involved jumps because it sounds like with just a single-byte offset that I'd have to sometimes make trampolines to jump to where I ultimately need to be. Again, I haven't really hit that, but I'm also use 2-byte opcodes. What I have works, but it looks ... fairly simple for me to reduce the opcode size so I wanted to understand some of the decisions that were made go to a single-byte argument size in 3.6. From rosuav at gmail.com Tue Jan 7 01:05:49 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 7 Jan 2020 17:05:49 +1100 Subject: Understanding bytecode arguments: 1 byte versus 2 bytes In-Reply-To: <4f3e9753-e1a6-43b3-8a67-b6949de67304@googlegroups.com> References: <4f3e9753-e1a6-43b3-8a67-b6949de67304@googlegroups.com> Message-ID: On Tue, Jan 7, 2020 at 5:01 PM wrote: > > I'm trying to understand the difference in disassemblies with 3.6+ versus older versions of CPython. It looks like the basic opcodes like LOAD_FAST are 3 bytes in pre-3.6 versions, but 2 bytes in 3.6+. I read online somewhere that there was a change to the argument sizes in 3.6: it became 2 bytes when it used to be just one. I wanted to verify that. For 3.6, if an opcode takes an argument, can I always assume that argument is just one byte? > > I can think of some situations where that doesn't sounds right. For example, JUMP_ABSOLUTE would be a problem, although I have yet to see that opcode in the wild. Actually, I'd be worried about more involved jumps because it sounds like with just a single-byte offset that I'd have to sometimes make trampolines to jump to where I ultimately need to be. Again, I haven't really hit that, but I'm also use 2-byte opcodes. > > What I have works, but it looks ... fairly simple for me to reduce the opcode size so I wanted to understand some of the decisions that were made go to a single-byte argument size in 3.6. > There was an extensive discussion about it. If you want to go poking around, the keyword to search for is "wordcode". It's quite an interesting read.... if you are in no hurry to go anywhere else. :) ChrisA From arj.python at gmail.com Tue Jan 7 01:49:51 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 7 Jan 2020 10:49:51 +0400 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: <91BB8419-AA86-4128-A3E3-0DF5163F4C72@barrys-emacs.org> Message-ID: Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius On Tue, Jan 7, 2020 at 6:40 AM Christopher Barker wrote: > I?m a bit unclear on how far this goes: is it just a bit more specific > with more meta-data standards? > - More metadata - Integrity check with hashing - Protecting the meta data - Bundling 3rd party packages Or are you aiming for something that will run without a Python install? > Aie aie Mr. Christopher, zipapp requires a Python install Other issues: > > Are you aiming for a bundle that can run on multiple platforms? If so, > then it?ll have to have a way to bundle multiple compiled extensions and > select the right ones at runtime. > According to the discussion on the Python, Be Bold thread, it became clear that it will be a pain to generate and will have an unnecessary size but sure this a most stable idea Suggesting instead to include wheels. The wheels are installed. The interpreter looks for packages in that app-specific folder If this Is essentially just zipapp with the ability to bundle dependencies, > then you could probably just do some sys.path hackery. > Could you please explain more. Thanks? In any case, thus seems like something you could implement, and then see if > people find it useful. > That's a nice idea to have a working demo. I'm not a security expert but i'll try! Anyone interested in this thread can view this tool built by LinkedIn which attempts dependencies bundling. > From h.goebel at goebel-consult.de Tue Jan 7 09:09:27 2020 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Tue, 7 Jan 2020 15:09:27 +0100 Subject: PyInstaller needs Funding by your Company Message-ID: <56aa0352-e69f-4b3c-791c-fa957e2d5905@goebel-consult.de> Hi, as some of you might already know: PyInstaller is in urgent need of funding. If you are working for a company using PyInstaller, please make them pay their share. For details see *If reasonable funding is not achieved until end of January 2020, @htgoebel will retire as an maintainer.* This basically means: Unless somebody else steps in, there will be nobody reviewing any pull-request, there will be not improvement and sooner or later you will not be able to use PyInstaller any more. P.S.: Many thanks for those who donated from their personal money. We really appreciate this! What is "sustainable funding"? Maintianing PyInstaller at a proper level requires about 4 to 5 days per month. Which means about 4,000 to 5,000 ? per month and about 50,000 to 60,000 ? per year. -- Sch?nen Gru? Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: https://www.goe-con.de/blog/bin-offiziell-entdecker-einer-sicherheitslucke Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2012-01-in-die-cloud-in-die-cloud-aber-wo-soll-die-sein From auriocus at gmx.de Tue Jan 7 11:19:11 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Tue, 7 Jan 2020 17:19:11 +0100 Subject: PyInstaller needs Funding by your Company In-Reply-To: References: <56aa0352-e69f-4b3c-791c-fa957e2d5905@goebel-consult.de> Message-ID: Am 07.01.20 um 15:09 schrieb Hartmut Goebel: > Maintianing PyInstaller at a proper level requires about 4 to 5 days per > month. Which means about 4,000 to 5,000 ? per month and about 50,000 to > 60,000 ? per year. these numbers sound odd to me. 4000? - 5000? per month or equivalently 60,000? per year is the level of academic full-time jobs in Germany, i.e. that would be 4-5 days per week, not per month. Christian From h.goebel at goebel-consult.de Tue Jan 7 13:05:52 2020 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Tue, 7 Jan 2020 19:05:52 +0100 Subject: PyInstaller needs Funding by your Company In-Reply-To: References: <56aa0352-e69f-4b3c-791c-fa957e2d5905@goebel-consult.de> Message-ID: Am 07.01.20 um 17:19 schrieb Christian Gollwitzer: > Am 07.01.20 um 15:09 schrieb Hartmut Goebel: >> Maintianing PyInstaller at a proper level requires about 4 to 5 days per >> month. Which means about 4,000 to 5,000 ? per month and about 50,000 to >> 60,000 ? per year. > > these numbers sound odd to me. 4000? - 5000? per month or equivalently > 60,000? per year is the level of academic full-time jobs in Germany, > i.e. that would be 4-5 days per week, not per month. > Based on the hourly rate calculator at gulp.de, the average rate for software developers is 85 ?. This is a very specialized job, and I'm senior, thus my rate should be a bit higher. Also this has to compete with the offerings I get as a InfoSec consultant, which are above. Please also keep in mind: PyInstaller is used by eg. Google, Docker, CarbonBlack, Siemens, and quite some other really big ones. There is no reason for me to spend my spare-time to make them earn money. (Also your figure seems to not take into account the "Lohnnebenkosten" - health insurance, pension fond, etc.) -- Sch?nen Gru? Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: https://www.goe-con.de/blog/openstreetmaps-hat-google-maps-weit-ueberholt Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-08-horrorszenario-bring-your-own-device From arj.python at gmail.com Tue Jan 7 14:53:04 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 7 Jan 2020 23:53:04 +0400 Subject: Removing reference to local installed package Message-ID: Greetings everybody, I installed a local package using python -m pip install Now if you install the same package from pypi, it says requirements already satisfied pointing to the location of the local package folder instead of site -package pip uninstall does not work as the package is not in site-package in the first place importing the package does not work as the package is not in site-package it won't install and won't delete Q: How do i remove the reference of a local package? Thanks Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius From PythonList at DancesWithMice.info Tue Jan 7 16:37:20 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Wed, 8 Jan 2020 10:37:20 +1300 Subject: Removing reference to local installed package In-Reply-To: References: Message-ID: On 8/01/20 8:53 AM, Abdur-Rahmaan Janhangeer wrote: > Greetings everybody, Salaam, > I installed a local package using > python -m pip install > > Now if you install the same package from pypi, it says requirements already > satisfied pointing to the location of the local package folder instead of > site -package > > pip uninstall does not work as the package is not in site-package in the > first > place > importing the package does not work as the package is not in site-package > it won't install and won't delete > Q: How do i remove the reference of a local package? Possibly relevant: https://stackoverflow.com/questions/33412974/how-to-uninstall-a-package-installed-with-pip-install-user NB this problem avoided by using virtual environments/machines which are tailored to the individual application; thereby evincing no differences between 'system-wide' and 'lesser' installations. Related?OT: Is there a tool which will identify?estimate how packages were installed? eg pip[2] cf pip3, pip --user, pip system-wide, Linux apt/rpm installer, ... ...and thus how to uninstall! Also, because something installed one-way may (as described above) 'prevent' its installation in an alternate mode. (experienced an issue where the version of pytest installed with/by/for the VS-Codium(?) add-on package differed from the one which I thought I'd just updated using (Linux Fedora's) DNF - the newer version requiring more recent dependencies that the IDE claimed 'weren't there'. It took quite a bit of circling around to determine the problem, and yet more to be sure of fixing it without causing 'collateral damage'!) -- Regards =dn From brett at python.org Tue Jan 7 16:32:33 2020 From: brett at python.org (Brett Cannon) Date: Tue, 7 Jan 2020 13:32:33 -0800 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: References: Message-ID: Thanks for the ideas, Abdur-Rahmaan! Some feedback below. On Mon, Jan 6, 2020 at 11:35 AM Abdur-Rahmaan Janhangeer < arj.python at gmail.com> wrote: > Note: draft simplified > > Abstract > ====== > > This extracts aims at proposing enhancements to the generated zipapp > executable > > Rationale > ======= > > One area where there remains some difficulty in Python is packaging for > end-user consumption. To that effect either the code is distributed in pure > Python form with installers [1] or native executables are built for each > target > Os [2]. Currently by default, Python does not provide such utilities. This > pro- > posal aims at finalising a Python-specific archive as the default VM exec- > utable built on zipapp. > > In simple terms, it proposes to enhance zipapp from plain archive to > app-level > archive. > > Advantages of archives > ================== > > Archives provide a great way to publish software that needs to be > distributed as > a single file script but is complex enough to need to be written as a > collection of > modules [3] > > You can use archives for tasks such as lossless data compression, > archiving, > decompression, and archive unpacking. [4] Adding capabilities like digital > signing is used to verify integrity and authenticity. > > Zip archives as apps > ================ > > If we are to treat zip archives as app, here are some recommended features > > - [x] Main entry point > > A main entry point specifies which file to launch. Zipapp already solves > this > problem by either having a __main__.py [5] or specifying the entry point > at the > commandline ENTRYPOINT_MODULE:ENTRYPOINT_FUNCTION [6] > > - [ ] App info file > > An info file can have info such as author name, archiving date, company > name > etc. > This would be a packaging detail so not something to be specified in the stdlib. > > - [ ] Signing mechanism > > Mechanisms can be added to detect the integrity of the app. App hash can > be > used to check if the app has been modified and per-file hash can be used > to > detect what part has been modified. This can be further enhanced if needed. > > - [ ] Protecting meta data > > Metadata are not protected by basic signing. There existing ways to protect > metadata and beyond [7] > This can be tricky because people want signing in specific ways that vary from OS to OS, case by case. So unless there's a built-in signing mechanism the flexibility required here is huge. > > - [x] Pure-Python 3rd party package bundling > > In Python, as long as the 3rd party packages are pure-python packages, we > can bundle and use them [6]. The user can maybe just include a > requirements.txt > > - [ ] C-based 3rd party packages > > Zipapp by default was not meant to include packages at all. > > << The executable zip format is specifically designed for standalone use, > without needing to be installed. They are in effect a multi-file version > of a > standalone Python script >> > > Though the previous point shows that this can be done. Now remains the > issue of C-based packages. Distributing wheels might be the answer [8]. > A zip archive is supposed to be standalone. A possible solution might be > to > include wheels and the wheels are installed in a site-packages folder. > > When running such an app, the interpreter will check first if the > app-specific > site-packages folder is empty, if not, install the wheels. This provides > package- > freezing ability. The only downside is longer first-run time. > Install the wheels where? You can't do that globally. And you also have to worry about the security of doing the install implicitly. And now the user suddenly has stuff on their file system they may not have asked for as a side-effect which may upset some people who are tight on disk space (remember that Python runs on some low-powered machines). -Brett > > Only specifying packages to be installed is not an option as if you really > want > stand-alone apps, using the internet etc defeats the purpose. > > FAQ > ==== > > Why not a package manager? > --------------------------------------- > The zipapp pep was introduced for a reason, for easing the running of > archives. > Maybe the package manager idea came from listening to people talking about > packaging and pex and comparing it with package-managers like homebrew > and concluded that pex and hence zipapp is not worth it and people would > better off not complicate their lives with some zip utility. > > This proposal is not solving any problem at all > -------------------------------------------------------------- > This proposal aims at enhancing zipapp. Zipapp solved the problem. Zipapp > had an aim. This proposal aims at helping zipapp better accompplish it's > aim. > > > References > > [1] https://pynsist.readthedocs.io/en/latest/ > > [2] https://www.pyinstaller.org > > [3] https://www.python.org/dev/peps/pep-0441/ > > [4] > https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html > > [5] https://docs.python.org/3/library/zipapp.html > > [6] https://gist.github.com/lukassup/cf289fdd39124d5394513a169206631c > > [7] https://source.android.com/security/apksigning > > [8] https://pythonwheels.com > > > > Yours, > > Abdur-Rahmaan Janhangeer > pythonmembers.club | github > > Mauritius > _______________________________________________ > Python-ideas mailing list -- python-ideas at python.org > To unsubscribe send an email to python-ideas-leave at python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas at python.org/message/EMP4PMT7AHUJPLYD2DN4MXKCMGDK3QSO/ > Code of Conduct: http://python.org/psf/codeofconduct/ > From barry at barrys-emacs.org Tue Jan 7 17:15:38 2020 From: barry at barrys-emacs.org (Barry) Date: Tue, 7 Jan 2020 22:15:38 +0000 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: > On 7 Jan 2020, at 02:40, Christopher Barker wrote: > > ? > I?m a bit unclear on how far this goes: is it just a bit more specific with more meta-data standards? > > Or are you aiming for something that will run without a Python install? > > Other issues: > > Are you aiming for a bundle that can run on multiple platforms? If so, then it?ll have to have a way to bundle multiple compiled extensions and select the right ones at runtime. > > If this Is essentially just zipapp with the ability to bundle dependencies, then you could probably just do some sys.path hackery. > > In any case, thus seems like something you could implement, and then see if people find it useful. > > BTW- I?m pretty sure we could simply specify that filenames are utf-8 and we?d be good to go. Have a look at this write up about the horror that is zip file name handling. https://marcosc.com/2008/12/zip-files-and-encoding-i-hate-you/ This has been a pain point at work. Barry > > -CHB > > > > > >> On Mon, Jan 6, 2020 at 5:50 PM Abdur-Rahmaan Janhangeer wrote: >> >> >>> On Tue, 7 Jan 2020, 01:57 Barry Scott, wrote: >>> >>> >>> Please cover the pro's and con's of the alernatives that have been raised as comments >>> on this idea, as is usually done for a PEP style document. >> >> >> Thanks, i don't have much experience writing peps and >> if i don't bug you may i ask what "alternatives" refer to? >> >>> Also beware that zip file format does not include the encoding of the files that are in the >>> zip file. >> >> >> For the encoding of the contents, well since we are >> packaging python code files, it's handling will be the same >> as handling outside the zip file. It's handling is the >> same as how zipapp handles things. >> >>> This means that for practical purposes only ASCII filenames are portable across >>> systems. Is this limitation a problem for this proposal? >> >> >> If we are talking about filenames, then i guess >> ascii filenames are the way to go as you'd >> unnecessarily break things otherwise. >> _______________________________________________ >> Python-ideas mailing list -- python-ideas at python.org >> To unsubscribe send an email to python-ideas-leave at python.org >> https://mail.python.org/mailman3/lists/python-ideas.python.org/ >> Message archived at https://mail.python.org/archives/list/python-ideas at python.org/message/RVGFMDP3PG6TXFQGH7ISRLYM4FS5CO64/ >> Code of Conduct: http://python.org/psf/codeofconduct/ > -- > Christopher Barker, PhD > > Python Language Consulting > - Teaching > - Scientific Software Development > - Desktop GUI and Web Development > - wxPython, numpy, scipy, Cython From barry at barrys-emacs.org Tue Jan 7 17:20:08 2020 From: barry at barrys-emacs.org (Barry) Date: Tue, 7 Jan 2020 22:20:08 +0000 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: References: Message-ID: > On 7 Jan 2020, at 01:48, Abdur-Rahmaan Janhangeer wrote: > > ? > > >> On Tue, 7 Jan 2020, 01:57 Barry Scott, wrote: >> >> >> Please cover the pro's and con's of the alernatives that have been raised as comments >> on this idea, as is usually done for a PEP style document. > > > Thanks, i don't have much experience writing peps and > if i don't bug you may i ask what "alternatives" refer to? You are offing up a competitor against python wheels, Py2app, py2exe etc packagers. Explain the benefits and weaknesses compared to the existing alternatives. You might want to look at pex that is mentioned in the pep you refer to. The other mentioned app has seen no update sine 2013. > >> Also beware that zip file format does not include the encoding of the files that are in the >> zip file. > > > For the encoding of the contents, well since we are > packaging python code files, it's handling will be the same > as handling outside the zip file. It's handling is the > same as how zipapp handles things. I replies seperaly about this problem. > >> This means that for practical purposes only ASCII filenames are portable across >> systems. Is this limitation a problem for this proposal? > > > If we are talking about filenames, then i guess > ascii filenames are the way to go as you'd > unnecessarily break things otherwise. Barry From shanky.tiwari at gmail.com Tue Jan 7 18:47:37 2020 From: shanky.tiwari at gmail.com (Shashank Tiwari) Date: Tue, 7 Jan 2020 15:47:37 -0800 Subject: Floating point overflow and underflow Message-ID: In Python3 an operation as follows: >>> 10135.1941 * (10**8) gives the result: 1013519410000.0001 Similarly, using the pow function also gives the same overflow/underflow error. >>> 10135.1941 * pow(10,8) 1013519410000.0001 Like multiplication, division of large or very small floating point numbers gives similar overflow/underflow errors. Usage of Decimal doesn't seem to fix it either. >>> from decimal import * >>> Decimal(10135.1941 * pow(10,8)) Decimal('1013519410000.0001220703125') >>> Decimal(10135.1941)*pow(10,8) Decimal('1013519410000.000061700120568') >>> Decimal(10135.1941) * Decimal(pow(10,8)) Decimal('1013519410000.000061700120568') >>> Decimal(10135.1941 * (10**8)) Decimal('1013519410000.0001220703125') How could one do high precision multiplication and division of floating points numbers (decimals) in Python3 without any overflow/underflow errors? Thanks, Shanky From rgaddi at highlandtechnology.invalid Tue Jan 7 20:23:30 2020 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Tue, 7 Jan 2020 17:23:30 -0800 Subject: Floating point overflow and underflow In-Reply-To: References: Message-ID: On 1/7/20 3:47 PM, Shashank Tiwari wrote: > In Python3 an operation as follows: >>>> 10135.1941 * (10**8) > gives the result: 1013519410000.0001 > > Similarly, using the pow function also gives the same overflow/underflow > error. >>>> 10135.1941 * pow(10,8) > 1013519410000.0001 > > Like multiplication, division of large or very small floating point numbers > gives similar overflow/underflow errors. > > Usage of Decimal doesn't seem to fix it either. >>>> from decimal import * >>>> Decimal(10135.1941 * pow(10,8)) > Decimal('1013519410000.0001220703125') >>>> Decimal(10135.1941)*pow(10,8) > Decimal('1013519410000.000061700120568') >>>> Decimal(10135.1941) * Decimal(pow(10,8)) > Decimal('1013519410000.000061700120568') >>>> Decimal(10135.1941 * (10**8)) > Decimal('1013519410000.0001220703125') > > How could one do high precision multiplication and division of floating > points numbers (decimals) in Python3 without any overflow/underflow errors? > > Thanks, Shanky > You've already polluted your Decimal with floating-point roundoff error before you even multiply it in any of your examples. >>> Decimal(10135.1941) Decimal('10135.1941000000006170012056827545166015625') Initialize your Decimal from a string instead. >>> Decimal('10135.1941') Decimal('10135.1941') >>> Decimal('10135.1941') * Decimal('1e8') Decimal('1.01351941E+12') >>> float(_) 1013519410000.0 From shanky.tiwari at gmail.com Tue Jan 7 21:36:06 2020 From: shanky.tiwari at gmail.com (Shashank Tiwari) Date: Tue, 7 Jan 2020 18:36:06 -0800 Subject: Floating point overflow and underflow In-Reply-To: References: Message-ID: Thanks Rob. How would one initialize a Decimal with something like pow(2,256)? On Tue, Jan 7, 2020 at 5:25 PM Rob Gaddi wrote: > On 1/7/20 3:47 PM, Shashank Tiwari wrote: > > In Python3 an operation as follows: > >>>> 10135.1941 * (10**8) > > gives the result: 1013519410000.0001 > > > > Similarly, using the pow function also gives the same overflow/underflow > > error. > >>>> 10135.1941 * pow(10,8) > > 1013519410000.0001 > > > > Like multiplication, division of large or very small floating point > numbers > > gives similar overflow/underflow errors. > > > > Usage of Decimal doesn't seem to fix it either. > >>>> from decimal import * > >>>> Decimal(10135.1941 * pow(10,8)) > > Decimal('1013519410000.0001220703125') > >>>> Decimal(10135.1941)*pow(10,8) > > Decimal('1013519410000.000061700120568') > >>>> Decimal(10135.1941) * Decimal(pow(10,8)) > > Decimal('1013519410000.000061700120568') > >>>> Decimal(10135.1941 * (10**8)) > > Decimal('1013519410000.0001220703125') > > > > How could one do high precision multiplication and division of floating > > points numbers (decimals) in Python3 without any overflow/underflow > errors? > > > > Thanks, Shanky > > > > You've already polluted your Decimal with floating-point roundoff error > before > you even multiply it in any of your examples. > > >>> Decimal(10135.1941) > Decimal('10135.1941000000006170012056827545166015625') > > Initialize your Decimal from a string instead. > > >>> Decimal('10135.1941') > Decimal('10135.1941') > >>> Decimal('10135.1941') * Decimal('1e8') > Decimal('1.01351941E+12') > >>> float(_) > 1013519410000.0 > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Tue Jan 7 21:39:20 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 Jan 2020 13:39:20 +1100 Subject: Floating point overflow and underflow In-Reply-To: References: Message-ID: On Wed, Jan 8, 2020 at 1:37 PM Shashank Tiwari wrote: > > Thanks Rob. > > How would one initialize a Decimal with something like pow(2,256)? > Easy, just initialize it with an integer: >>> Decimal(2**256) Decimal('115792089237316195423570985008687907853269984665640564039457584007913129639936') ChrisA From shanky.tiwari at gmail.com Tue Jan 7 22:18:39 2020 From: shanky.tiwari at gmail.com (Shashank Tiwari) Date: Tue, 7 Jan 2020 19:18:39 -0800 Subject: Floating point overflow and underflow In-Reply-To: References: Message-ID: Thanks Chris. What if it's pow(2.2,0.45)? On Tue, Jan 7, 2020, 6:40 PM Chris Angelico wrote: > On Wed, Jan 8, 2020 at 1:37 PM Shashank Tiwari > wrote: > > > > Thanks Rob. > > > > How would one initialize a Decimal with something like pow(2,256)? > > > > Easy, just initialize it with an integer: > > >>> Decimal(2**256) > > Decimal('115792089237316195423570985008687907853269984665640564039457584007913129639936') > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Tue Jan 7 22:38:20 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 Jan 2020 14:38:20 +1100 Subject: Floating point overflow and underflow In-Reply-To: References: Message-ID: On Wed, Jan 8, 2020 at 2:18 PM Shashank Tiwari wrote: > > Thanks Chris. What if it's pow(2.2,0.45)? > Initialize your Decimals from strings, as you were already advised, and do the calculation in Decimals. Or just use floats, since it's likely to be at least as accurate. ChrisA From torriem at gmail.com Tue Jan 7 22:40:55 2020 From: torriem at gmail.com (Michael Torrie) Date: Tue, 7 Jan 2020 20:40:55 -0700 Subject: Floating point overflow and underflow In-Reply-To: References: Message-ID: <04ce0e16-ae77-b7dc-8ab1-fc10d72e113a@gmail.com> On 1/7/20 8:18 PM, Shashank Tiwari wrote: > Thanks Chris. What if it's pow(2.2,0.45)? Why not do some more experimentation: >>> import decimal >>> a = decimal.Decimal('2.2') >>> b = decimal.Decimal('0.45') >>> a ** b Decimal('1.425903734234490793207619170') Is this what you mean? I'm sure there are other ways as well. From shanky.tiwari at gmail.com Tue Jan 7 22:46:32 2020 From: shanky.tiwari at gmail.com (Shashank Tiwari) Date: Tue, 7 Jan 2020 19:46:32 -0800 Subject: Floating point overflow and underflow In-Reply-To: <04ce0e16-ae77-b7dc-8ab1-fc10d72e113a@gmail.com> References: <04ce0e16-ae77-b7dc-8ab1-fc10d72e113a@gmail.com> Message-ID: Yes, I tried this and it worked. I was wondering if I could use the output of pow (or math.pow). On Tue, Jan 7, 2020, 7:41 PM Michael Torrie wrote: > On 1/7/20 8:18 PM, Shashank Tiwari wrote: > > Thanks Chris. What if it's pow(2.2,0.45)? > > Why not do some more experimentation: > > >>> import decimal > >>> a = decimal.Decimal('2.2') > >>> b = decimal.Decimal('0.45') > >>> a ** b > Decimal('1.425903734234490793207619170') > > Is this what you mean? I'm sure there are other ways as well. > -- > https://mail.python.org/mailman/listinfo/python-list > From shanky.tiwari at gmail.com Tue Jan 7 22:48:45 2020 From: shanky.tiwari at gmail.com (Shashank Tiwari) Date: Tue, 7 Jan 2020 19:48:45 -0800 Subject: Floating point overflow and underflow In-Reply-To: References: <04ce0e16-ae77-b7dc-8ab1-fc10d72e113a@gmail.com> Message-ID: Thanks everyone. Much appreciated. On Tue, Jan 7, 2020, 7:46 PM Shashank Tiwari wrote: > Yes, I tried this and it worked. I was wondering if I could use the output > of pow (or math.pow). > > On Tue, Jan 7, 2020, 7:41 PM Michael Torrie wrote: > >> On 1/7/20 8:18 PM, Shashank Tiwari wrote: >> > Thanks Chris. What if it's pow(2.2,0.45)? >> >> Why not do some more experimentation: >> >> >>> import decimal >> >>> a = decimal.Decimal('2.2') >> >>> b = decimal.Decimal('0.45') >> >>> a ** b >> Decimal('1.425903734234490793207619170') >> >> Is this what you mean? I'm sure there are other ways as well. >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From torriem at gmail.com Tue Jan 7 22:53:04 2020 From: torriem at gmail.com (Michael Torrie) Date: Tue, 7 Jan 2020 20:53:04 -0700 Subject: Floating point overflow and underflow In-Reply-To: References: <04ce0e16-ae77-b7dc-8ab1-fc10d72e113a@gmail.com> Message-ID: <0c1de8ff-6bb8-899d-d5f8-4bf367ea5fd1@gmail.com> On 1/7/20 8:46 PM, Shashank Tiwari wrote: > Yes, I tried this and it worked. I was wondering if I could use the output > of pow (or math.pow). Sure: pow(Decimal('2.2'), Decimal('0.45')) From shanky.tiwari at gmail.com Tue Jan 7 23:01:14 2020 From: shanky.tiwari at gmail.com (Shashank Tiwari) Date: Tue, 7 Jan 2020 20:01:14 -0800 Subject: Floating point overflow and underflow In-Reply-To: <0c1de8ff-6bb8-899d-d5f8-4bf367ea5fd1@gmail.com> References: <04ce0e16-ae77-b7dc-8ab1-fc10d72e113a@gmail.com> <0c1de8ff-6bb8-899d-d5f8-4bf367ea5fd1@gmail.com> Message-ID: Oh, thanks. Didn't think of that. On Tue, Jan 7, 2020, 7:53 PM Michael Torrie wrote: > On 1/7/20 8:46 PM, Shashank Tiwari wrote: > > Yes, I tried this and it worked. I was wondering if I could use the > output > > of pow (or math.pow). > > Sure: > > pow(Decimal('2.2'), Decimal('0.45')) > > -- > https://mail.python.org/mailman/listinfo/python-list > From pythonchb at gmail.com Wed Jan 8 02:09:14 2020 From: pythonchb at gmail.com (Christopher Barker) Date: Tue, 7 Jan 2020 23:09:14 -0800 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: <91BB8419-AA86-4128-A3E3-0DF5163F4C72@barrys-emacs.org> Message-ID: On Mon, Jan 6, 2020 at 10:50 PM Abdur-Rahmaan Janhangeer < arj.python at gmail.com> wrote: > - More metadata > good idea, and simple. > - Integrity check with hashing > - Protecting the meta data > This could be a big challenge -- and I'm not expert, so have no idea what the issues are. > - Bundling 3rd party packages > Well, as you state below, that could make it big. but it also could make it useful -- folks want to use environments of various sorts to keep dependencies separate, so bundling them all up in an app would be nice. But a thought on that -- you may be able to accomplish something similar with conda, "conda constructor", and "conda run". -- or a new tool built from those. The idea is that the first time you ran your "app", it would install its dependencies, and then use them in an isolated environment. But if the multiple apps had the same dependencies, they would share them, so you wouldn't get major bloat on the host machine. > Are you aiming for a bundle that can run on multiple platforms? If so, >> then it?ll have to have a way to bundle multiple compiled extensions and >> select the right ones at runtime. >> > > According to the discussion on the Python, Be Bold thread, it became > clear that it will be a pain to generate and will have an unnecessary > size but sure this a most stable idea > > Suggesting instead to include wheels. The wheels are installed. The > interpreter looks for packages in that app-specific folder > but a wheel is just as big as the installed package (at least a zipped version) -- it's essentially the package compressed into a tarball. If this Is essentially just zipapp with the ability to bundle dependencies, >> then you could probably just do some sys.path hackery. >> > > Could you please explain more. Thanks? > sure -- in your zip file, you have a "dependencies" directory. the dependencies get installed there. Then that dir gets added to sys.path at startup. I'm not so sure o=how to do that inside a zipfile, but it could be done *somehow* In any case, thus seems like something you could implement, and then see if >> people find it useful. >> > > That's a nice idea to have a working demo. I'm not a security > expert but i'll try! > well, you'll need a consult on the security issues -- which you would want well reviewed anyway ;-) > Anyone interested in this thread can view this tool > built by LinkedIn which > attempts dependencies bundling. > There you go -- you've got half the job done already :-) But: "Unlike ?conventional? zipapps, shiv packs a site-packages style directory of your tool?s dependencies into the resulting binary, and then at bootstrap time extracts it into a ~/.shiv cache directory." which is how they get around the "how to add a dir in a zip file to sys.path" -- but I'll bet someone could hack that to no be neccesary.... -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython From arj.python at gmail.com Wed Jan 8 02:40:25 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 8 Jan 2020 11:40:25 +0400 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: References: Message-ID: Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius On Wed, Jan 8, 2020 at 2:20 AM Barry wrote: > > You are offing up a competitor against python wheels > This proposal proposes to inlcude python wheels in the archive > Py2app, py2exe etc packagers. > Native executables are off the plate. This one deals with archive files. But i get the idea, thanks! Maybe you wanted to allude to projects like Shiv by LinkedIn > Explain the benefits and weaknesses compared to the existing alternatives. > There are some projects similar to Shiv, will write a comparison. From arj.python at gmail.com Wed Jan 8 04:09:03 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 8 Jan 2020 13:09:03 +0400 Subject: [Python-ideas] Enhancing Zipapp In-Reply-To: References: Message-ID: Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius On Wed, Jan 8, 2020 at 1:32 AM Brett Cannon wrote: > > > This would be a packaging detail so not something to be specified in the stdlib. Yes, the module opening the zip will look for it >> - [ ] Signing mechanism >> >> Mechanisms can be added to detect the integrity of the app. App hash can be >> used to check if the app has been modified and per-file hash can be used to >> detect what part has been modified. This can be further enhanced if needed. >> >> - [ ] Protecting meta data >> >> Metadata are not protected by basic signing. There existing ways to protect >> metadata and beyond [7] > > > This can be tricky because people want signing in specific ways that vary from OS to OS, case by case. So unless there's a built-in signing mechanism the flexibility required here is huge. Let's say we have a simple project folder/ file.py __main__.py The first step is to include in the info file the file name and hashes file.py: 5f22669f6f0ea1cc7e5af7c59712115bcf312e1ceaf7b2b005af259b610cf2da __main__.py: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Then by reading the info file and hashing the actual file and comparing, we can see which file was modified if any. But now, a malicious program might try to modify the info file and modify the hash. One way to protect even the metadata is to hash the entire content folder/ file.py # we can add those in a folder if needed __main__.py infofile Then after zipping it, we hash the zipfile then append the hash to the zip binary [zipfile binary][hash value] We can have a zip file and yet another file stating the hash value but to maintain a single file structure, the one described above is best. Then when opening the zip file, we start reading upto the hash value. The hash value becomes the checking signature of the zipfile. This forms a base on which more sigining mechanism can be added like author keys Since zipfiles are the same across OSes, this kind of approach supposedly don't pose a problem > Install the wheels where? You can't do that globally. And you also have to worry about the security of doing the install implicitly. And now the user suddenly has stuff on their file system they may not have asked for as a side-effect which may upset some people who are tight on disk space (remember that Python runs on some low-powered machines). Yes, global folders also defeat the spirit. Using the wheel-included zip (A), we can generate another zip file (B) with the packages installed. That generated zip file is then executed. Zip format A solves the problem of cross-platforming. Normal solutions upto now like use solution B where you can't share your zips across OSes. As for space, it's a bit the same as with venvs. Zip format B is the equivalent of packages installed in venv. Venv usage can be a hint as to when to use. From arj.python at gmail.com Wed Jan 8 04:23:46 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 8 Jan 2020 13:23:46 +0400 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: <91BB8419-AA86-4128-A3E3-0DF5163F4C72@barrys-emacs.org> Message-ID: On Wed, 8 Jan 2020, 11:09 Christopher Barker, wrote: > > But a thought on that -- you may be able to accomplish something similar > with conda, "conda constructor", and "conda run". -- or a new tool built > from those. The idea is that the first time you ran your "app", it would > install its dependencies, and then use them in an isolated environment. But > if the multiple apps had the same dependencies, they would share them, so > you wouldn't get major bloat on the host machine. > I guess it's time to dig more into anaconda, been putting it off, will do. but a wheel is just as big as the installed package (at least a zipped > version) -- it's essentially the package compressed into a tarball. > I really hope C extentions would become redundent someday in Python, which would make Python development real Python dev. The proposal at hand is maybe the best solution to a hard nut case that most if not all solutions preferred to avoid But: "Unlike ?conventional? zipapps, shiv packs a site-packages style > directory of your tool?s dependencies into the resulting binary, and then > at bootstrap time extracts it into a ~/.shiv cache directory." > Maybe we can have a PYZ directory where the packages for each app are extracted then it's not a global dump but more specific Why not that route? It would be nice to comment on what is wrong with Shiv's mode of execution > From arj.python at gmail.com Wed Jan 8 04:47:30 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 8 Jan 2020 13:47:30 +0400 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: On Wed, 8 Jan 2020, 02:15 Barry, wrote: > > Have a look at this write up about the horror that is zip file name > handling. > > https://marcosc.com/2008/12/zip-files-and-encoding-i-hate-you/ > > This has been a pain point at work. > Since zipapp did not touch the subject, i won't either unless well, we can clearly come up with a solution. If you can work out a solution for Python that would be great! From alon.najman at gmail.com Wed Jan 8 05:53:12 2020 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Wed, 8 Jan 2020 02:53:12 -0800 (PST) Subject: looking for git with a solution - merge many pdfs to 1 pdf (no matter what language) Message-ID: hi looking for git with a solution - merge many pdfs to 1 pdf (no matter what language) From pieter-l at vanoostrum.org Wed Jan 8 08:24:49 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Wed, 08 Jan 2020 14:24:49 +0100 Subject: looking for git with a solution - merge many pdfs to 1 pdf (no matter what language) References: Message-ID: alon.najman at gmail.com writes: > hi > looking for git with a solution - merge many pdfs to 1 pdf (no matter what language) There is a clone of pdftk on github: https://github.com/ericmason/pdftk Another possibility is mupdf: http://git.ghostscript.com/?p=mupdf.git -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From pythonchb at gmail.com Wed Jan 8 11:02:32 2020 From: pythonchb at gmail.com (Christopher Barker) Date: Wed, 8 Jan 2020 08:02:32 -0800 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: On Wed, Jan 8, 2020 at 1:49 AM Abdur-Rahmaan Janhangeer < arj.python at gmail.com> wrote: > Have a look at this write up about the horror that is zip file name >> handling. >> >> https://marcosc.com/2008/12/zip-files-and-encoding-i-hate-you/ >> >> This has been a pain point at work. >> > I'm pretty sure this is a non-issue for this use-case. If you need to open sip files created by arbitrary other systems, or create zip files that can be opened by arbitrary other systems, then it's a big mess. But that isn't the case here. -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython From pythonchb at gmail.com Wed Jan 8 11:08:15 2020 From: pythonchb at gmail.com (Christopher Barker) Date: Wed, 8 Jan 2020 08:08:15 -0800 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: <91BB8419-AA86-4128-A3E3-0DF5163F4C72@barrys-emacs.org> Message-ID: On Wed, Jan 8, 2020 at 1:24 AM Abdur-Rahmaan Janhangeer < arj.python at gmail.com> wrote: > But a thought on that -- you may be able to accomplish something similar >> with conda, "conda constructor", and "conda run". -- or a new tool built >> from those. The idea is that the first time you ran your "app", it would >> install its dependencies, and then use them in an isolated environment. But >> if the multiple apps had the same dependencies, they would share them, so >> you wouldn't get major bloat on the host machine. >> > > I guess it's time to dig more into anaconda, been > putting it off, will do. > to be clear -- you want to look at "conda", not "Anaconda" -- conda is a package manager, Anaconda is a distribution created with the conda package manager. > but a wheel is just as big as the installed package (at least a zipped >> version) -- it's essentially the package compressed into a tarball. >> > > I really hope C extentions would become redundent someday > in Python, which would make Python development real > Python dev. > That's not going to completely happen. Which does not mean that a solution that doesn't support them isn't still useful for a lot. But it would be interesting to see how many commonly used packages on PyPi rely on C extensions (other than the SciPy Stack). > But: "Unlike ?conventional? zipapps, shiv packs a site-packages style >> directory of your tool?s dependencies into the resulting binary, and then >> at bootstrap time extracts it into a ~/.shiv cache directory." >> > > Maybe we can have a PYZ directory where the > packages for each app are extracted then it's not > a global dump but more specific > I'm not sure how that differs from a .shiv directory, which is not global. But a way to share packages in the "central place for packages" would be nice. -- maybe how conda does it with hard links? -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython From abarnert at yahoo.com Wed Jan 8 12:29:51 2020 From: abarnert at yahoo.com (Andrew Barnert) Date: Wed, 8 Jan 2020 09:29:51 -0800 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: <75079226-6CB6-4DDC-884C-E0271A06DECA@yahoo.com> On Jan 8, 2020, at 01:09, Abdur-Rahmaan Janhangeer wrote: > > But now, a malicious program might try to modify the info file > and modify the hash. One way to protect even the metadata is > to hash the entire content > > folder/ > file.py # we can add those in a folder if needed > __main__.py > infofile > > Then after zipping it, we hash the zipfile then append the hash to the zip binary > > [zipfile binary][hash value] How does this solve the problem? A malicious program that could modify the hash inside the info file could even more easily modify the hash at the end of the zip. Existing systems deal with this by recognizing that you can?t prevent anyone from hashing anything they want, so you either have to store the hashes in a trusted central repo, or (more commonly?there are multiple advantages) sign them with a trustable key. If a malicious app modified the program and modified the hash, it?s going to be a valid hash; there?s nothing you can do about that. But it won?t be the hash in the repo, or it?ll be signed by the untrusted author of the malicious program rather than the trusted author of the app, and that?s why you don?t let it run. And this works just as well for hashes embedded inside an info file inside the zip as for hashes appended to the zip. And there are advantages to putting the hash inside. For example, if you want to allow downstream packagers or automated systems to add distribution info (this is important if you want to be able to pass a second code signing requirement, e.g., Apple?s, as well as the zipapp one), you just have a list of escape patterns that say which files are allowed to be unhashed. Anything that appears in the info file must match its hash or the archive is invalid. Anything that doesn?t appear in the info file but does match the escape patterns is fine, but if it doesn?t match the escape patterns, the archive is invalid. So now downstream distributors can add extra files that match the escape patterns. (The escape patterns can be configurable?you just need them to be specified by something inside the hash. But you definitely want a default that works 99% of the time, because if developers and packagers have to think it through in every case instead of only in exceptional cases, they?re going to get it wrong, and nobody will have any idea who to trust to get it right.) From abarnert at yahoo.com Wed Jan 8 12:29:51 2020 From: abarnert at yahoo.com (Andrew Barnert) Date: Wed, 8 Jan 2020 09:29:51 -0800 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: <75079226-6CB6-4DDC-884C-E0271A06DECA@yahoo.com> On Jan 8, 2020, at 01:09, Abdur-Rahmaan Janhangeer wrote: > > But now, a malicious program might try to modify the info file > and modify the hash. One way to protect even the metadata is > to hash the entire content > > folder/ > file.py # we can add those in a folder if needed > __main__.py > infofile > > Then after zipping it, we hash the zipfile then append the hash to the zip binary > > [zipfile binary][hash value] How does this solve the problem? A malicious program that could modify the hash inside the info file could even more easily modify the hash at the end of the zip. Existing systems deal with this by recognizing that you can?t prevent anyone from hashing anything they want, so you either have to store the hashes in a trusted central repo, or (more commonly?there are multiple advantages) sign them with a trustable key. If a malicious app modified the program and modified the hash, it?s going to be a valid hash; there?s nothing you can do about that. But it won?t be the hash in the repo, or it?ll be signed by the untrusted author of the malicious program rather than the trusted author of the app, and that?s why you don?t let it run. And this works just as well for hashes embedded inside an info file inside the zip as for hashes appended to the zip. And there are advantages to putting the hash inside. For example, if you want to allow downstream packagers or automated systems to add distribution info (this is important if you want to be able to pass a second code signing requirement, e.g., Apple?s, as well as the zipapp one), you just have a list of escape patterns that say which files are allowed to be unhashed. Anything that appears in the info file must match its hash or the archive is invalid. Anything that doesn?t appear in the info file but does match the escape patterns is fine, but if it doesn?t match the escape patterns, the archive is invalid. So now downstream distributors can add extra files that match the escape patterns. (The escape patterns can be configurable?you just need them to be specified by something inside the hash. But you definitely want a default that works 99% of the time, because if developers and packagers have to think it through in every case instead of only in exceptional cases, they?re going to get it wrong, and nobody will have any idea who to trust to get it right.) From songbird at anthive.com Wed Jan 8 11:23:26 2020 From: songbird at anthive.com (songbird) Date: Wed, 8 Jan 2020 11:23:26 -0500 Subject: PyInstaller needs Funding by your Company References: <56aa0352-e69f-4b3c-791c-fa957e2d5905@goebel-consult.de> Message-ID: Christian Gollwitzer wrote: > Am 07.01.20 um 15:09 schrieb Hartmut Goebel: >> Maintianing PyInstaller at a proper level requires about 4 to 5 days per >> month. Which means about 4,000 to 5,000 ? per month and about 50,000 to >> 60,000 ? per year. > > these numbers sound odd to me. 4000? - 5000? per month or equivalently > 60,000? per year is the level of academic full-time jobs in Germany, > i.e. that would be 4-5 days per week, not per month. it is the demand of a volunteer to be paid. if people want to pay him that's their business, but i think a larger company may just instead fork their own copy or fund an internal developer to track this project IF it is that important to them. he may resign or limit his participation in the future as with any other volunteer effort. it is GPL code. songbird From abarnert at yahoo.com Wed Jan 8 13:08:42 2020 From: abarnert at yahoo.com (Andrew Barnert) Date: Wed, 8 Jan 2020 10:08:42 -0800 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: On Jan 8, 2020, at 01:09, Abdur-Rahmaan Janhangeer wrote: > > Using the wheel-included zip (A), we can generate another zip file (B) with > the packages installed. That generated zip file is then executed. But that generated zip B doesn?t have a trustable hash on it, so how can you execute it? If you keep this all hidden inside the zipapp system, where malicious programs can?t find and modify the generated zips, then I suppose that?s fine. But at that point, why not just install the wheels inside zip A into an auto-generated only-for-zip-A venv cache directory or something, and then just run zip A as-is against that venv? > Zip format A solves the problem of cross-platforming. > Normal solutions upto now like use solution B where you can't share > your zips across OSes. You can still only share zips across OSs if you bundle in a wheel for each extension library for every possible platform. For in-house deployments where you only care about two platforms (your dev boxes and your deployment cluster boxes), that?s fine, but for a publicly released app that?s supposed to work ?everywhere?, you pretty much have to download and redistribute every wheel on PyPI for every dependency, which could make your app pretty big, and require pretty frequent updates, and it still only lets you run on systems that have wheels for all your dependencies. If you?re already doing an effective ?install? step in building zip B out of zip A, why not make that step just use a requirements file and download the dependencies from PyPI? You could still run zip B without being online, just not zip A. Maybe you could optionally include wheels and they?d serve as a micro-repo sitting in front of PyPI, so when you?re dependencies are small you can distribute a version that works for 95% of your potential users without needing to do anything fancy but it still works for the other 5% if they can reach PyPI. (But maybe it would be simpler to just use the zip B as a cache in the first place. If I download Spam.zipapp for Win64 3.9, that?s a popular enough platform that you probably have a zip B version ready to go and just ship me that, so it works immediately. Now, if I copy that file to my Mac instead of downloading it fresh, oops, wrong wheels, so it downloads the right ones off PyPI and builds a new zipapp for my platform?and it still runs, it just takes a bit longer the first time. I?m not sure this is a good idea, but I?m not sure trying to include every wheel for every platform is a good idea either?) But there?s a bigger problem than just distribution. Some extension modules are only extension modules for speed, like numpy. But many are there to interface with C libraries. If my app depends on PortAudio, distributing the extension module as wheels is easy, but it doesn?t do any good unless you have the C library installed and configured on your system. Which you probably don?t if you?re on Windows or Mac. A package manager like Homebrew or Choco can take care of that by just making my app?s package depend on the PortAudio package (and maybe even conda can?), but I don?t see how zipapps with wheels in, or anything else self-contained, can. And if most such packages eventually migrate to binding from Python (using cffi or ctypes) rather than from C (using an extension module), that actually makes your problem harder rather than easier, because now you can?t even tell from outside the code that there are external dependencies; you can distribute a single zipapp that works everywhere, but only in the sense that it starts running and quickly fails with an exception for most users. From abarnert at yahoo.com Wed Jan 8 13:08:42 2020 From: abarnert at yahoo.com (Andrew Barnert) Date: Wed, 8 Jan 2020 10:08:42 -0800 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: On Jan 8, 2020, at 01:09, Abdur-Rahmaan Janhangeer wrote: > > Using the wheel-included zip (A), we can generate another zip file (B) with > the packages installed. That generated zip file is then executed. But that generated zip B doesn?t have a trustable hash on it, so how can you execute it? If you keep this all hidden inside the zipapp system, where malicious programs can?t find and modify the generated zips, then I suppose that?s fine. But at that point, why not just install the wheels inside zip A into an auto-generated only-for-zip-A venv cache directory or something, and then just run zip A as-is against that venv? > Zip format A solves the problem of cross-platforming. > Normal solutions upto now like use solution B where you can't share > your zips across OSes. You can still only share zips across OSs if you bundle in a wheel for each extension library for every possible platform. For in-house deployments where you only care about two platforms (your dev boxes and your deployment cluster boxes), that?s fine, but for a publicly released app that?s supposed to work ?everywhere?, you pretty much have to download and redistribute every wheel on PyPI for every dependency, which could make your app pretty big, and require pretty frequent updates, and it still only lets you run on systems that have wheels for all your dependencies. If you?re already doing an effective ?install? step in building zip B out of zip A, why not make that step just use a requirements file and download the dependencies from PyPI? You could still run zip B without being online, just not zip A. Maybe you could optionally include wheels and they?d serve as a micro-repo sitting in front of PyPI, so when you?re dependencies are small you can distribute a version that works for 95% of your potential users without needing to do anything fancy but it still works for the other 5% if they can reach PyPI. (But maybe it would be simpler to just use the zip B as a cache in the first place. If I download Spam.zipapp for Win64 3.9, that?s a popular enough platform that you probably have a zip B version ready to go and just ship me that, so it works immediately. Now, if I copy that file to my Mac instead of downloading it fresh, oops, wrong wheels, so it downloads the right ones off PyPI and builds a new zipapp for my platform?and it still runs, it just takes a bit longer the first time. I?m not sure this is a good idea, but I?m not sure trying to include every wheel for every platform is a good idea either?) But there?s a bigger problem than just distribution. Some extension modules are only extension modules for speed, like numpy. But many are there to interface with C libraries. If my app depends on PortAudio, distributing the extension module as wheels is easy, but it doesn?t do any good unless you have the C library installed and configured on your system. Which you probably don?t if you?re on Windows or Mac. A package manager like Homebrew or Choco can take care of that by just making my app?s package depend on the PortAudio package (and maybe even conda can?), but I don?t see how zipapps with wheels in, or anything else self-contained, can. And if most such packages eventually migrate to binding from Python (using cffi or ctypes) rather than from C (using an extension module), that actually makes your problem harder rather than easier, because now you can?t even tell from outside the code that there are external dependencies; you can distribute a single zipapp that works everywhere, but only in the sense that it starts running and quickly fails with an exception for most users. From rhodri at kynesim.co.uk Wed Jan 8 13:14:08 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 8 Jan 2020 18:14:08 +0000 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: <82b7f830-e8c1-d5b4-1b4c-abb7347908de@kynesim.co.uk> On 08/01/2020 18:08, many people wrote lots of stuff... Folks, could we pick one list and have the discussion there, rather than on both python-list and python-ideas? Getting *four* copies of Andrew's emails is a tad distracting :-) -- Rhodri James *-* Kynesim Ltd From barry at barrys-emacs.org Wed Jan 8 16:26:08 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Wed, 8 Jan 2020 21:26:08 +0000 Subject: [Python-ideas] Re: Enhancing Zipapp In-Reply-To: References: Message-ID: <0F9E7D02-1241-41E1-BACE-9037473EFE77@barrys-emacs.org> > On 8 Jan 2020, at 16:02, Christopher Barker wrote: > > On Wed, Jan 8, 2020 at 1:49 AM Abdur-Rahmaan Janhangeer > wrote: > Have a look at this write up about the horror that is zip file name handling. > > https://marcosc.com/2008/12/zip-files-and-encoding-i-hate-you/ > > This has been a pain point at work. > > I'm pretty sure this is a non-issue for this use-case. If you need to open sip files created by arbitrary other systems, or create zip files that can be opened by arbitrary other systems, then it's a big mess. But that isn't the case here. One claim is that because its zip you can use any of the existing tools. But this encoding issue means that its likely that you have to use zipapp aware tools. Also can we stop cross posting to 2 lists please. Pick one and keep the thread on it please. Barry > > -CHB > > > -- > Christopher Barker, PhD > > Python Language Consulting > - Teaching > - Scientific Software Development > - Desktop GUI and Web Development > - wxPython, numpy, scipy, Cython From PythonList at DancesWithMice.info Wed Jan 8 16:40:02 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 9 Jan 2020 10:40:02 +1300 Subject: Coding technique: distinguish using type or abc? Message-ID: <1835657b-8a22-da59-dad2-90e5b2432e71@etelligence.info> Do you prefer to use isinstance() with type() or to refer to collections.abc? This team producing bases statistical analyses for (lesser capable) user-coders to utilise with their own experimental 'control code'; faces situations where a list-parameter is often only one element long. As is so often the way, amongst the 'clients' there are a couple of strong-minded (am not allowed to call them "awkward", or otherwise!) user-coder-analysts, who demand that entry of a single-element not require them to surround it with "unnecessary" square-brackets. Despite complaining, we realise that this is actually quite a good practice, and likely save us (as well as 'them') from interface mistakes. Such single elements appear in both string and numeric formats, but for simplicity (here) let's ignore numerics... The problem rearing its ugly head, is when the string single-element becomes input to a for-loop. If we loop around a list, then each element is handled individually (as desired). Whereas if the element is a string, then each character is treated as if it were a list-element (not)! In Code Review, I noticed that two 'solutions' have been coded. 1 using type()s to distinguish: def format_as_list( parameter:Union[ str, list ] )->list: if isinstance( parameter, str ): parameter_list = [ parameter ] elif isinstance( parameter, list ): parameter_list = parameter else: raise NotImplementedError return parameter_list 2 using abstract base classes from PSL.collections to distinguish: import collections.abc as abc def is_list_not_string( parameter:Union[ str, list ] ) -> bool: return isinstance( parameter, abc.MutableSequence ) def format_as_list( parameter:str )->list: if is_list_not_string( parameter ): return parameter else: return [ parameter, ] (ignoring implicit assumption/error!) NB I've simplified the code and attempted to harmonise the varNMs between snippets. With our preference for EAFP, I went looking for a way to utilise an exception by way of distinguishing between the input-types - but couldn't see how, without major artifice (false/purposeless construct which would confuse the next reader of the code). That said, I'm wondering if using (or appearing to use) tuples and *args might solve the problem - but will have to dig back through the code-base... Meantime, faced with such a challenge, would you recommend utilising one of these ideas over the other, or perhaps some other solution? Are there perhaps circumstances where you would use one solution, and others the other? -- Regards, =dn From rgaddi at highlandtechnology.invalid Wed Jan 8 17:33:17 2020 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Wed, 8 Jan 2020 14:33:17 -0800 Subject: Coding technique: distinguish using type or abc? In-Reply-To: References: <1835657b-8a22-da59-dad2-90e5b2432e71@etelligence.info> Message-ID: On 1/8/20 1:40 PM, DL Neil wrote: > Do you prefer to use isinstance() with type() or to refer to collections.abc? > > > This team producing bases statistical analyses for (lesser capable) user-coders > to utilise with their own experimental 'control code'; faces situations where a > list-parameter is often only one element long. As is so often the way, amongst > the 'clients' there are a couple of strong-minded (am not allowed to call them > "awkward", or otherwise!) user-coder-analysts, who demand that entry of a > single-element not require them to surround it with "unnecessary" > square-brackets. Despite complaining, we realise that this is actually quite a > good practice, and likely save us (as well as 'them') from interface mistakes. > > Such single elements appear in both string and numeric formats, but for > simplicity (here) let's ignore numerics... > > The problem rearing its ugly head, is when the string single-element becomes > input to a for-loop. If we loop around a list, then each element is handled > individually (as desired). Whereas if the element is a string, then each > character is treated as if it were a list-element (not)! > > > In Code Review, I noticed that two 'solutions' have been coded. > > 1 using type()s to distinguish: > > ????def format_as_list( parameter:Union[ str, list ] )->list: > ??????? if isinstance( parameter, str ): > ??????????? parameter_list = [ parameter ] > ??????? elif isinstance( parameter, list ): > ??????????? parameter_list = parameter > ??????? else: > ??????????? raise NotImplementedError > ??????? return parameter_list > > 2 using abstract base classes from PSL.collections to distinguish: > > ????import collections.abc as abc > ????def is_list_not_string( parameter:Union[ str, list ] ) -> bool: > ??????? return isinstance( parameter, abc.MutableSequence ) > > ????def format_as_list( parameter:str )->list: > ??????? if is_list_not_string( parameter ): > ??????????? return parameter > ??????? else: > ??????????? return [ parameter, ] > > (ignoring implicit assumption/error!) > NB I've simplified the code and attempted to harmonise the varNMs between snippets. > > With our preference for EAFP, I went looking for a way to utilise an exception > by way of distinguishing between the input-types - but couldn't see how, without > major artifice (false/purposeless construct which would confuse the next reader > of the code). That said, I'm wondering if using (or appearing to use) tuples and > *args might solve the problem - but will have to dig back through the code-base... > > > Meantime, faced with such a challenge, would you recommend utilising one of > these ideas over the other, or perhaps some other solution? > > Are there perhaps circumstances where you would use one solution, and others the > other? > I try to avoid making assumptions, so I wind up with a lot of if isinstance(parameter, str): plist = [parameter] else: try: plist = list(parameter) except TypeError: plist = [parameter] Any iterable gets listified unless it's a string, which gets treated the same way a non-iterable does. EAFP. From jfong at ms4.hinet.net Thu Jan 9 03:20:48 2020 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Thu, 9 Jan 2020 00:20:48 -0800 (PST) Subject: How to decide which module is in charge of this error? cx-Freeze or pynput or six? Message-ID: <15b9e467-b190-40ec-bc3d-3a5e65b4f3de@googlegroups.com> Takes the simple\hello.py file in the cx_Freeze\samples directory as an example, I insert this line into hello.py: from pynput.keyboard import Key, Controller then build the executable using "py setup.py build" command, the on-screen message shows this missing module warning: ... Missing modules: ... ? six.moves imported from pynput._util ... Run the created hello.exe will cause this error: ... from pynput._util import Events File "C:\Users\jfong\AppData\Local\Programs\Python\Python36-32\lib\site- packages\pynput\_util\__init__.py", line 33, in from six.moves import queue File "C:\Users\jfong\AppData\Local\Programs\Python\Python36-32\lib\site-packages\six.py", line 92, in __get__ result = self._resolve() File "C:\Users\jfong\AppData\Local\Programs\Python\Python36-32\lib\site-packages\six.py", line 115, in _resolve return _import_module(self.mod) File "C:\Users\jfong\AppData\Local\Programs\Python\Python36-32\lib\site-packages\six.py", line 82, in _import_module __import__(name) ModuleNotFoundError: No module named 'queue' If I change line 33 in file pynput\_util\__init__.py from six.moves import queue to import queue and re-build, then that missing warning is gone and hello.exe excutes correctly. My question is how to decide which module causes this problem? PS. My environment is Windows 8.1, Python 3.6.8, cx-Freeze 5.1.1, pynput 1.6.5, six 1.13.0. I had try to upgrade the cx-Freeze to the latest v6.1 but result is the same. --Jach From marko at pacujo.net Thu Jan 9 10:04:56 2020 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 09 Jan 2020 17:04:56 +0200 Subject: Coding technique: distinguish using type or abc? References: Message-ID: <87a76wy8kn.fsf@elektro.pacujo.net> ram at zedat.fu-berlin.de (Stefan Ram): > if type( object ) is list: I would recommend isinstance() because: >>> isinstance(True, int) True >>> type(True) is int False Marko From h.goebel at goebel-consult.de Thu Jan 9 13:33:21 2020 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Thu, 9 Jan 2020 19:33:21 +0100 Subject: [ANN] PyInstaller 3.6 Message-ID: Hello, on behalf of the PyInstaller development team I'm happy to announce PyInstaller 3.6. This version fixes a Local Privilege Escalation vulnerability effecting all Windows software frozen by PyInstaller in "onefile" mode - no matter which version of PyInstaller was used. http://www.pyinstaller.org Thanks for all those who contributed questions, bug-reports or pull-requests. PyInstaller is in urgent need of funding to make future security fixes happen, see for details. === What it is === PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules. PyInstaller reads a Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files ? including the active Python interpreter! ? and puts them with your script in a single folder, or optionally in a single executable file. PyInstaller is tested against Windows, Mac OS X, and Linux. However, it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows; to make a Linux app you run it in Linux, etc. PyInstaller has been used successfully with AIX, Solaris, and FreeBSD, but is not tested against them. === Help keeping PyInstaller alive === Maintaining PyInstaller is a huge amount of work. PyInstaller development can only continue if users and companies provide sustainable funding. Please consider recurring donations. See http://www.pyinstaller.org/funding.html for how to support PyInstaller. === Installation === PyInstaller can be installed from PyPi using pip install pyinstaller === Important Changes === * Fixes a Local Privilege Escalation vulnerability effecting all Windows software frozen vy PyInstaller in "onefile" mode. * More then 20 hooks added, more then 15 hooks fixed or improved. * More then 20 bugs fixed. * Python 3.4 is no longer tested, since this version is end-of-life already. The full changelog for this release can be found at: https://pyinstaller.readthedocs.io/en/v3.6/CHANGES.html === Feedback === We're eager to listen to your feedback on using PyInstaller: Bug tracker: https://github.com/pyinstaller/pyinstaller/issues Mailing list: http://groups.google.com/group/PyInstaller -- Sch?nen Gru? Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: http://www.goebel-consult.de/blog/warum-sie-nicht-perl-programmiern-sollten Kolumne: http://www.cissp-gefluester.de/2012-02-bring-your-own-life-glosse From h.goebel at goebel-consult.de Thu Jan 9 13:47:16 2020 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Thu, 9 Jan 2020 19:47:16 +0100 Subject: [ANN][SECURITY] Local Privilege Escalation in all Windows software frozen by PyInstaller in "onefile" mode Message-ID: <77f3166f-a1e9-7dc2-91ae-d0ace1a71633@goebel-consult.de> Severity: high: CVSSv3 score: 7.0 Packages: PyInstaller (Windows) Affected versions:? <= 3.5 Patched versions: 3.6, available at https://pypi.org/project/PyInstaller/ CVE identifier: CVE-2019-16784 Impact *Local Privilege Escalation *in all *Windows software frozen by PyInstaller* in "onefile" mode, caused by insecure directory permissions of sys._MEIPATH. While PyInstaller itself was not vulnerable, *all Windows software frozen by PyInstaller in ?onefile? mode is vulnerable.* The vulnerability is present only on Windows and in this particular case: If a /software frozen by PyInstaller in "onefile" mode/**is launched by a (privileged) user who has /his/her "TempPath" resolving to a world writable directory/. This is the case e.g. if the software is launched as a service or as a scheduled task using a system account (in which case TempPath will default to C:\Windows\Temp). In order to be exploitable the software has to be (re)started after the attacker has launched the exploit program. So for a service launched at startup, a service restart is needed (e.g. after a crash or an upgrade). While PyInstaller itself was not vulnerable, all Windows software frozen by PyInstaller in "onefile" mode is vulnerable. CVSSv3 score: 7.0 (High) CVSSv3 vector: CVSS:3.0/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H Patches The problem is patched in commits 42a67148b3bdf9 (fixed code) and be948cf09547 (recompiled bootloaders) . Users should upgrade to PyInstaller version 3.6 and rebuild their software. The new version is available at https://pypi.org/project/PyInstaller/ Workarounds There is no known workaround: Users using PyInstaller to freeze their Windows software using "onefile" mode should upgrade PyInstaller and rebuild their software. The new version is available at https://pypi.org/project/PyInstaller/ Credits This vulnerability was discovered and reported by Farid AYOUJIL (@faridtsl), David HA, Florent LE NIGER and Yann GASCUEL (@lnv42) from Alter Solutions (@AlterSolutions) and fixed in collaboration with Hartmut Goebel (@htgoebel, maintainer of PyInstaller). Funding Development PyInstaller is in urgent need of funding to make future security fixes happen, see for details. -- Sch?nen Gru? Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: https://www.goe-con.de/blog/e-mails-weiterhin-verschlusseln Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2010-11-it-sicherheit-im-unternehmen-eine-interne-oder-externe-angelegenheit From fabiofz at gmail.com Fri Jan 10 12:43:45 2020 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 10 Jan 2020 14:43:45 -0300 Subject: PyDev 7.5.0 Released Message-ID: PyDev 7.5.0 Release Highlights - Fixed support for Python 3.8 (which wasn't properly added to 7.4.0). - Improved Cython support: - Cython itself is used to generate the AST for Cython files. - Cython needs to be available in the default interpreter. - Cython does not currently support generating the AST for files with errors, so, syntax errors must be fixed for the code-completion to work properly. - Debugger improvements (updated to pydevd 1.9.0). - Improved stepping into coroutines - Attach to process no longer needs to match the bitness of the target program with the interpreter. - File with a relative path is searched in sys.path folders (i.e.: so, cython builds can find the source). About PyDev PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and IronPython development, now also available for Python on Visual Studio Code. It comes with goodies such as code completion, syntax highlighting, syntax analysis, code analysis, refactor, debug, interactive console, etc. It is also available as a standalone through LiClipse with goodies such as multiple cursors, theming and support for many other languages, such as Django Templates, Jinja2, Html, JavaScript, etc. Links: PyDev: http://pydev.org PyDev Blog: http://pydev.blogspot.com PyDev on VSCode: http://pydev.org/vscode LiClipse: http://www.liclipse.com PyVmMonitor - Python Profiler: http://www.pyvmmonitor.com/ Cheers, Fabio Zadrozny From garimakapoor490 at gmail.com Fri Jan 10 08:41:00 2020 From: garimakapoor490 at gmail.com (garimakapoor490 at gmail.com) Date: Fri, 10 Jan 2020 05:41:00 -0800 Subject: to continue python Message-ID: <5e187ee9.1c69fb81.9bb1c.73c2@mx.google.com> Sent from Mail for Windows 10 From Karsten.Hilbert at gmx.net Fri Jan 10 16:41:04 2020 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Fri, 10 Jan 2020 22:41:04 +0100 Subject: to continue python In-Reply-To: <5e187ee9.1c69fb81.9bb1c.73c2@mx.google.com> References: <5e187ee9.1c69fb81.9bb1c.73c2@mx.google.com> Message-ID: <20200110214103.GA1969@hermes.hilbert.loc> Sure, by all means ! -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From bluebox03 at gmail.com Fri Jan 10 18:16:39 2020 From: bluebox03 at gmail.com (tommy yama) Date: Sat, 11 Jan 2020 08:16:39 +0900 Subject: Saying bye bye to Python 2 Message-ID: As many know, python 2 was retired. ? This means imminent migration to 3 will be a must ? I thought that upgrading is not that simple. thanks ! From skip.montanaro at gmail.com Fri Jan 10 19:55:24 2020 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Fri, 10 Jan 2020 18:55:24 -0600 Subject: Saying bye bye to Python 2 In-Reply-To: References: Message-ID: > > As many know, python 2 was retired. ? > This means imminent migration to 3 will be a must ? > Not if you don't change anything (update software or hardware). If it ain't broke, there's no need to fix it. OTOH, if your software, Python itself, or your operating system have security or other bugs, you may well have to update something. Even so, that may well not force a switch to Python 3. > I thought that upgrading is not that simple. > That depends. In my experience, str/bytes were the only frustrating bits. Other than that, the 2to3 tool does a pretty good job. Also, assuming you have a decent suite of unit tests, porting from 2 to 3 will be much more straightforward. Skip From marko at pacujo.net Sat Jan 11 06:43:54 2020 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 11 Jan 2020 13:43:54 +0200 Subject: Saying bye bye to Python 2 References: Message-ID: <87o8vai5fp.fsf@elektro.pacujo.net> tommy yama : > As many know, python 2 was retired. ? > This means imminent migration to 3 will be a must ? Python 2 will have a lively retirement. It won't be dead before RHEL 7 is dead. According to https://access.redhat.com/support/policy/updates/errata the support dates for RHEL 7 are: End of Full Support: Aug 6, 2019 End of Maintenance Support 1: Aug 6, 2020. End of Maintenance Support 2: June 30, 2024. End of Extended Life-cycle Support: TBD End of Extended Life Phase: ongoing Last Minor Release: TBD Marko From random832 at fastmail.com Sat Jan 11 09:45:22 2020 From: random832 at fastmail.com (Random832) Date: Sat, 11 Jan 2020 09:45:22 -0500 Subject: =?UTF-8?Q?Re:_Why_isn't_"-std=3Dc99"_(and_others)_not_part_of_python3-co?= =?UTF-8?Q?nfig's_output=3F?= In-Reply-To: <06becbd43ba88f1923f56f9c118bfb4e@posteo.de> References: <06becbd43ba88f1923f56f9c118bfb4e@posteo.de> Message-ID: <74ff5626-4da9-45dd-9a1c-0047bf17b644@www.fastmail.com> On Mon, Nov 25, 2019, at 15:13, Musbur wrote: > 2) How does one activate the necessary CFLAGs for extension building? the standard level required for building some extension is a property of the extension's source code, isn't it? I don't know if including the python headers requires -std=c99 or not, but almost certainly they'll work with -std=c11 and an extension may well require it. From tjol at tjol.eu Sat Jan 11 07:22:44 2020 From: tjol at tjol.eu (Thomas Jollans) Date: Sat, 11 Jan 2020 13:22:44 +0100 Subject: Saying bye bye to Python 2 In-Reply-To: References: Message-ID: On 11/01/2020 00:16, tommy yama wrote: > As many know, python 2 was retired. ? > This means imminent migration to 3 will be a must ? Upgrading to Python 3 has been a "bloody well should" for many, many years now. Though in a shock announcement a few weeks ago the end of Python 2 was delayed AGAIN (this time only by a few months, but still) https://pyfound.blogspot.com/2019/12/python-2-sunset.html > > I thought that upgrading is not that simple. > > > thanks ! From anthra.norell at bluewin.ch Sat Jan 11 08:39:38 2020 From: anthra.norell at bluewin.ch (Friedrich Rentsch) Date: Sat, 11 Jan 2020 14:39:38 +0100 Subject: How to get dynamic data in html (javascript?) Message-ID: Hi all, I'm pretty good at hacking html text. But I have no clue how to get dynamic data like this : "At close: {date} {time}". I would appreciate a starting push to narrow my focus, currently awfully unfocused. Thanks. Frederic From gunnar at magnusson.io Sat Jan 11 12:48:43 2020 From: gunnar at magnusson.io (=?UTF-8?Q?Gunnar_=C3=9E=C3=B3r_Magn=C3=BAsson?=) Date: Sat, 11 Jan 2020 18:48:43 +0100 Subject: Saying bye bye to Python 2 In-Reply-To: References: Message-ID: <013e4634-3919-4d68-b191-67ac25ab2f15@www.fastmail.com> > I thought that upgrading is not that simple. It depends. If you have Python 2 code that deals with a lot of text in byte form, and it's kind of vague where you convert from bytes to strings, you may have a bad time. Otherwise, it may not be that bad. I ported around 500k lines of Python 2 to 3 this year, and it went smoothly. The most valuable resource I found was eevee's post on the subject: https://eev.ee/blog/2016/07/31/python-faq-how-do-i-port-to-python-3/ It talks about the most common tools and pitfalls. In particular, I found the future project to be very valuable. Best, G On Sat, Jan 11, 2020, at 00:16, tommy yama wrote: > As many know, python 2 was retired. ? > This means imminent migration to 3 will be a must ? > > I thought that upgrading is not that simple. > > > thanks ! > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Sat Jan 11 13:33:12 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Jan 2020 05:33:12 +1100 Subject: Saying bye bye to Python 2 In-Reply-To: <013e4634-3919-4d68-b191-67ac25ab2f15@www.fastmail.com> References: <013e4634-3919-4d68-b191-67ac25ab2f15@www.fastmail.com> Message-ID: On Sun, Jan 12, 2020 at 4:50 AM Gunnar ??r Magn?sson wrote: > > > I thought that upgrading is not that simple. > > It depends. > > If you have Python 2 code that deals with a lot of text in byte form, and it's kind of vague where you convert from bytes to strings, you may have a bad time. > It's always hard to port buggy code or underspecified code. If you have code written in some hypothetical language that doesn't distinguish properly between 16-bit ints and 64-bit floats, and has sloppy conversions between them and different semantics, then it would be a pain to port that to any other language. Ultimately, the cure is to figure out the programmer's original intention and implement that. > Otherwise, it may not be that bad. I ported around 500k lines of Python 2 to 3 this year, and it went smoothly. The most valuable resource I found was eevee's post on the subject: > Python Indeed. Especially if you're porting to a fairly recent Py3, chances are that most of the code will work just fine. There'll be just a few places where you have to manually figure things out, and for the rest, automated conversions like 2to3 will cover it. (And a lot of it doesn't even need automated conversion. There aren't actually THAT many things to change.) ChrisA From patrickkidd at gmail.com Sun Jan 12 00:24:50 2020 From: patrickkidd at gmail.com (Patrick Stinson) Date: Sun, 12 Jan 2020 00:24:50 -0500 Subject: Relative import cannot find .so submodule? Message-ID: <1ACAAE32-39FE-4F8D-BC6C-378239793258@gmail.com> I have a module named rtmidi, and its C submodule named rtmidi/_rtmidi. The distills script builds successfully and successfully creates a build/lib dir with a rtmidi dir in it and the submodule file rtmidi/_rtmidi.cpython-36dm-darwin.so. I have set PYTHONPATH to this lib dir, but rtmidi/__init__.py gives the following error: Traceback (most recent call last): File "main.py", line 6, in from pkmidicron import MainWindow, util, ports File "/Users/patrick/dev/pkmidicron/pkmidicron/__init__.py", line 1, in from .mainwindow import * File "/Users/patrick/dev/pkmidicron/pkmidicron/mainwindow.py", line 2, in import rtmidi File "/Users/patrick/dev/pkmidicron/pyrtmidi/build/lib/rtmidi/__init__.py", line 1, in from ._rtmidi import * ModuleNotFoundError: No module named 'rtmidi._rtmidi? How does the module finder work in the import system? I assume ti automatically resolves the name _rtmidi.cpython-36dm-darwin.so to _rtmidi? I didn?t have any luck reading the docs on the import system. Thanks! -Patrick From tjreedy at udel.edu Sun Jan 12 04:18:18 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Jan 2020 04:18:18 -0500 Subject: Saying bye bye to Python 2 In-Reply-To: References: Message-ID: On 1/11/2020 7:22 AM, Thomas Jollans wrote: > Though in a shock announcement a few weeks ago the end of Python 2 was > delayed AGAIN (this time only by a few months, but still) > > https://pyfound.blogspot.com/2019/12/python-2-sunset.html Not really. The only thing delayed was the final release,2.7.18, so it could be done during PyCon. The end of core developer maintenance occurred on schedule. "Effective January 1, 2020, no new bug reports, fixes, or changes will be made to Python 2." Any further changes should be cleanup patches by or with the approval of the release manager, preparing for the release candidate and then the final release. -- Terry Jan Reedy From musbur at posteo.org Sun Jan 12 12:10:06 2020 From: musbur at posteo.org (musbur at posteo.org) Date: Sun, 12 Jan 2020 18:10:06 +0100 Subject: How to get dynamic data in html (javascript?) In-Reply-To: References: Message-ID: <20200112181006.22bf8711@nxp10225> On Sat, 11 Jan 2020 14:39:38 +0100 Friedrich Rentsch wrote: > I'm pretty good at hacking html text. But I have no clue how to get > dynamic data like this : "At close: {date} {time}". I would > appreciate a starting push to narrow my focus, currently awfully > unfocused. Thanks. Focus on the str.format() function. From chrisrehm100 at gmail.com Sun Jan 12 13:04:53 2020 From: chrisrehm100 at gmail.com (christopher rehm) Date: Sun, 12 Jan 2020 10:04:53 -0800 (PST) Subject: I need to create .odt or .rtf documents in Python3. what is the best tool to do this.... Message-ID: hi all im new here. i need to create .odt or rtf documents from a python 3 program. i need a package or library that actually has real documentation and examples, using python3 and the tool ( sorry PyRTF3 is a major failure here) does anyone have any suggestions? chris From pieter-l at vanoostrum.org Sun Jan 12 14:31:22 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Sun, 12 Jan 2020 20:31:22 +0100 Subject: I need to create .odt or .rtf documents in Python3. what is the best tool to do this.... References: Message-ID: christopher rehm writes: > hi all im new here. i need to create .odt or rtf documents from a python > 3 program. i need a package or library that actually has real > documentation and examples, using python3 and the tool ( sorry PyRTF3 is > a major failure here) > does anyone have any suggestions? > > chris https://github.com/eea/odfpy -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From barry at barrys-emacs.org Mon Jan 13 04:10:22 2020 From: barry at barrys-emacs.org (Barry) Date: Mon, 13 Jan 2020 09:10:22 +0000 Subject: Relative import cannot find .so submodule? In-Reply-To: <1ACAAE32-39FE-4F8D-BC6C-378239793258@gmail.com> References: <1ACAAE32-39FE-4F8D-BC6C-378239793258@gmail.com> Message-ID: <3475446B-26C5-4D8B-82F2-0C040BDFB211@barrys-emacs.org> > On 12 Jan 2020, at 05:27, Patrick Stinson wrote: > > ?I have a module named rtmidi, and its C submodule named rtmidi/_rtmidi. The distills script builds successfully and successfully creates a build/lib dir with a rtmidi dir in it and the submodule file rtmidi/_rtmidi.cpython-36dm-darwin.so. I have set PYTHONPATH to this lib dir, but rtmidi/__init__.py gives the following error: > > Traceback (most recent call last): > File "main.py", line 6, in > from pkmidicron import MainWindow, util, ports > File "/Users/patrick/dev/pkmidicron/pkmidicron/__init__.py", line 1, in > from .mainwindow import * > File "/Users/patrick/dev/pkmidicron/pkmidicron/mainwindow.py", line 2, in > import rtmidi > File "/Users/patrick/dev/pkmidicron/pyrtmidi/build/lib/rtmidi/__init__.py", line 1, in > from ._rtmidi import * > ModuleNotFoundError: No module named 'rtmidi._rtmidi? > > How does the module finder work in the import system? I assume ti automatically resolves the name _rtmidi.cpython-36dm-darwin.so to _rtmidi? I didn?t have any luck reading the docs on the import system. Use python -vv then import you module. Python will print debug messages showing where it looks for the modules. Usually that helps find the problem with the PYTHONPATH. Barry > > Thanks! > -Patrick > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Sat Jan 11 13:34:54 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Jan 2020 05:34:54 +1100 Subject: How to get dynamic data in html (javascript?) In-Reply-To: References: Message-ID: On Sun, Jan 12, 2020 at 4:41 AM Friedrich Rentsch wrote: > > Hi all, > > I'm pretty good at hacking html text. But I have no clue how to get > dynamic data like this : "At close: {date} {time}". I would appreciate a > starting push to narrow my focus, currently awfully unfocused. Thanks. > > Frederic > You're asking this on a Python mailing list. Are you using Flask? Django? AIOHTTP? Do you have a templating engine like Jinja? ChrisA From ofomimatthew7 at gmail.com Sun Jan 12 09:21:52 2020 From: ofomimatthew7 at gmail.com (ofomi matthew) Date: Sun, 12 Jan 2020 15:21:52 +0100 Subject: Complaints on installing packages Message-ID: Good day Python Team, I'm Matt by name and I have been having difficulties in installing packages on my pycharm.it keeps telling me "error installing package". Please how do I rectify this issues step by step. Looking forward to get a response as soon as possible. Thank you From kiranksc55 at gmail.com Sun Jan 12 11:53:58 2020 From: kiranksc55 at gmail.com (kiran chawan) Date: Sun, 12 Jan 2020 22:23:58 +0530 Subject: Help Message-ID: Whenever Iam trying to run this 'New latest version python software 3.8.4 python ' but it doesn't show any install option tell me how to run this software and install new latest version of python plz reply sir thank you From outloook60 at outlook.com Mon Jan 13 00:00:55 2020 From: outloook60 at outlook.com (Helal Uddin) Date: Mon, 13 Jan 2020 05:00:55 +0000 Subject: Problem with pip Message-ID: When I first installed python, I didn?t have Pip. But when I installed python a few days ago, it?s showing this problem. Sent from Mail for Windows 10 From baris.avci at mazsan.com Mon Jan 13 00:52:08 2020 From: baris.avci at mazsan.com (=?iso-8859-9?Q?Bar=FD=FE_AVCI?=) Date: Mon, 13 Jan 2020 05:52:08 +0000 Subject: error Message-ID: <8C9D1471E3D872469C363C3CA2FDEA1002C4191E@EXCHANGE-MB03.limonhost.local> Kivy does not support python3.8 Sayg?lar?mla, Bar?? AVCI Bak?m Sorumlusu [A??klama: A??klama: A??klama: logo] MAZSAN Makina ?malat San.ve Tic.Ltd.?ti. ?stanbul Anadolu Yakas? Org. San. B?l. 2.Sanayi Cad.No:1 Tepe?ren-Tuzla ?STANBUL T?RK?YE-34953 Tel : +90(216) 593 00 40 Fax : +90(216) 593 00 39 From dieter at handshake.de Mon Jan 13 02:51:02 2020 From: dieter at handshake.de (dieter) Date: Mon, 13 Jan 2020 08:51:02 +0100 Subject: Relative import cannot find .so submodule? References: <1ACAAE32-39FE-4F8D-BC6C-378239793258@gmail.com> Message-ID: <875zhf7q1l.fsf@handshake.de> Patrick Stinson writes: > I have a module named rtmidi, and its C submodule named rtmidi/_rtmidi. The distills script builds successfully and successfully creates a build/lib dir with a rtmidi dir in it and the submodule file rtmidi/_rtmidi.cpython-36dm-darwin.so. I have set PYTHONPATH to this lib dir, but rtmidi/__init__.py gives the following error: > > Traceback (most recent call last): > File "main.py", line 6, in > from pkmidicron import MainWindow, util, ports > File "/Users/patrick/dev/pkmidicron/pkmidicron/__init__.py", line 1, in > from .mainwindow import * > File "/Users/patrick/dev/pkmidicron/pkmidicron/mainwindow.py", line 2, in > import rtmidi > File "/Users/patrick/dev/pkmidicron/pyrtmidi/build/lib/rtmidi/__init__.py", line 1, in > from ._rtmidi import * > ModuleNotFoundError: No module named 'rtmidi._rtmidi? > > How does the module finder work in the import system? I assume ti automatically resolves the name _rtmidi.cpython-36dm-darwin.so to _rtmidi? I didn?t have any luck reading the docs on the import system. I think the extension module should be found. However, an extension module must satify further conditions (apart from being found), e.g. it must contain a public initialization function with a name derived from the module name (and dependent on the major Python version). Maybe, your so does not fulfill one of those conditions? From muazzamshaikh20 at gmail.com Mon Jan 13 05:30:11 2020 From: muazzamshaikh20 at gmail.com (muazzam shaikh) Date: Mon, 13 Jan 2020 16:00:11 +0530 Subject: i am using python Message-ID: From gautamigaikwad1999 at gmail.com Mon Jan 13 06:50:55 2020 From: gautamigaikwad1999 at gmail.com (Gautami Gaikwad) Date: Mon, 13 Jan 2020 17:20:55 +0530 Subject: to solve the issues Message-ID: please solve the issues and make me essential use of this software. thank you. From miweaver at gmail.com Mon Jan 13 08:53:19 2020 From: miweaver at gmail.com (Mike Weaver) Date: Mon, 13 Jan 2020 21:53:19 +0800 Subject: Problems with Python install on Windows 10 Message-ID: Hello I am having great problems installing Python 3.8.1 on my Windows 10 64 bit system. I have tried using chocolatey as referenced at https://docs.python-guide.org/starting/install3/win/#install3-windows - it says it is installed but it isn't! I've tried downloading from https://www.python.org/downloads/windows/ (the Windows x86-64 executable installer ) and running that. Again says it is installed - but it clearly isn't. If I open a command prompt and type 'python', I get TCC: (Sys) The file cannot be accessed by the system "C:\Users\Mike\AppData\Local\Microsoft\WindowsApps\python.exe" If I search in that directory, I find a to python.exe. I have added that directory to my Path. I can see Python 3.8.1 in the Control Panel. I've rebooted. Reinstalled. Tried just about everything - but cannot get past either the crazy Microsoft Store app request or 'the file cannot be accessed' message. HELP!! Any advice is REALLY welcome! Thanks Mike From ikorot01 at gmail.com Mon Jan 13 10:11:37 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Mon, 13 Jan 2020 09:11:37 -0600 Subject: to solve the issues In-Reply-To: References: Message-ID: Hi, On Mon, Jan 13, 2020 at 8:29 AM Gautami Gaikwad wrote: > > please solve the issues and make me essential use of this software. > thank you. Errr, what kid of issue? Can you be a little more specific? Thank you. > -- > https://mail.python.org/mailman/listinfo/python-list From pieter-l at vanoostrum.org Mon Jan 13 10:55:53 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Mon, 13 Jan 2020 16:55:53 +0100 Subject: Relative import cannot find .so submodule? References: <1ACAAE32-39FE-4F8D-BC6C-378239793258@gmail.com> Message-ID: Patrick Stinson writes: > I have a module named rtmidi, and its C submodule named rtmidi/_rtmidi. The distills script builds successfully and successfully creates a build/lib dir with a rtmidi dir in it and the submodule file rtmidi/_rtmidi.cpython-36dm-darwin.so. I have set PYTHONPATH to this lib dir, but rtmidi/__init__.py gives the following error: > > Traceback (most recent call last): > File "main.py", line 6, in > from pkmidicron import MainWindow, util, ports > File "/Users/patrick/dev/pkmidicron/pkmidicron/__init__.py", line 1, in > from .mainwindow import * > File "/Users/patrick/dev/pkmidicron/pkmidicron/mainwindow.py", line 2, in > import rtmidi > File "/Users/patrick/dev/pkmidicron/pyrtmidi/build/lib/rtmidi/__init__.py", line 1, in > from ._rtmidi import * > ModuleNotFoundError: No module named 'rtmidi._rtmidi? > > How does the module finder work in the import system? I assume ti automatically resolves the name _rtmidi.cpython-36dm-darwin.so to _rtmidi? I didn?t have any luck reading the docs on the import system. Are you running python 3.6? I tried this on python 3.7 and it worked, but the file is called _rtmidi.cpython-37m-darwin.so there (37 for python3.7, and the d is missing, I don't know what that indicates). -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From p.f.moore at gmail.com Mon Jan 13 11:10:47 2020 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 13 Jan 2020 16:10:47 +0000 Subject: Relative import cannot find .so submodule? In-Reply-To: References: <1ACAAE32-39FE-4F8D-BC6C-378239793258@gmail.com> Message-ID: Did you build the extension as a debug build, but you're trying to use it in a release build Python? That may not work (it may depend on the OS, I don't know the compatibility details on MacOS)... On Mon, 13 Jan 2020 at 16:02, Pieter van Oostrum wrote: > > Patrick Stinson writes: > > > I have a module named rtmidi, and its C submodule named rtmidi/_rtmidi. The distills script builds successfully and successfully creates a build/lib dir with a rtmidi dir in it and the submodule file rtmidi/_rtmidi.cpython-36dm-darwin.so. I have set PYTHONPATH to this lib dir, but rtmidi/__init__.py gives the following error: > > > > Traceback (most recent call last): > > File "main.py", line 6, in > > from pkmidicron import MainWindow, util, ports > > File "/Users/patrick/dev/pkmidicron/pkmidicron/__init__.py", line 1, in > > from .mainwindow import * > > File "/Users/patrick/dev/pkmidicron/pkmidicron/mainwindow.py", line 2, in > > import rtmidi > > File "/Users/patrick/dev/pkmidicron/pyrtmidi/build/lib/rtmidi/__init__.py", line 1, in > > from ._rtmidi import * > > ModuleNotFoundError: No module named 'rtmidi._rtmidi? > > > > How does the module finder work in the import system? I assume ti automatically resolves the name _rtmidi.cpython-36dm-darwin.so to _rtmidi? I didn?t have any luck reading the docs on the import system. > > Are you running python 3.6? > > I tried this on python 3.7 and it worked, but the file is called _rtmidi.cpython-37m-darwin.so there (37 for python3.7, and the d is missing, I don't know what that indicates). > -- > Pieter van Oostrum > www: http://pieter.vanoostrum.org/ > PGP key: [8DAE142BE17999C4] > -- > https://mail.python.org/mailman/listinfo/python-list From eryksun at gmail.com Mon Jan 13 11:23:27 2020 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 13 Jan 2020 10:23:27 -0600 Subject: Problems with Python install on Windows 10 In-Reply-To: References: Message-ID: On 1/13/20, Mike Weaver wrote: > > I've tried downloading from https://www.python.org/downloads/windows/ > (the Windows x86-64 executable installer > ) > and running that. Again says it is installed - but it clearly isn't. Maybe you didn't enable the option to add the installation directory to PATH. Modifying the system and per-user PATH value is easy enough -- especially in Windows 10, which provides an exploded view of the semicolon-delimited list of directories, with individual entries that you can edit or move up and down in the list. > If I open a command prompt and type 'python', I get > > TCC: (Sys) The file cannot be accessed by the system > "C:\Users\Mike\AppData\Local\Microsoft\WindowsApps\python.exe" > > If I search in that directory, I find a to python.exe. I have That's the app-exec link for the store version of Python, which, if it's not installed, actually targets a stub app that opens the Microsoft Store to install Python. The directory of the standard installation needs to precede "%LocalAppData%\Microsoft\WindowsApps" in PATH in order to avoid this app-exec link. The default installation directory for x64 3.8 would be "%ProgramFiles%\Python38" for a system install and "%LocalAppData%\Programs\Python\Python38" for a per-user install. Note that an app-exec link is a type of filesystem reparse point, like a symlink or mount point in that narrow aspect, but it is most definitely not a symlink. Your shell is wrong to report that it's a "". There's no kernel handler for this type of reparse point, so any attempt to open it normally, with reparsing enabled, will fail as an unhandled reparse point. As far as I know, no Cygwin-derived environment (e.g. MSYS2) has been updated to support app-exec links. The onus is on these frameworks to stay up to date with significant changes in Windows. CreateProcess handles app-exec links in user mode. It directly opens the reparse point to read the target executable path. It also reads a set of security attributes, which it adds to a custom access token for the child process (i.e it's like a CreateProcessAsUser call). The security attributes in the access token allow the child process to access the app's files in "%ProgramFiles%WindowsApps\", which are protected by a conditional access-control entry. From pkpearson at nowhere.invalid Mon Jan 13 12:02:42 2020 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 13 Jan 2020 17:02:42 GMT Subject: Complaints on installing packages References: Message-ID: On Sun, 12 Jan 2020 15:21:52 +0100, ofomi matthew wrote: > Good day Python Team, > I'm Matt by name and I have been having difficulties in installing packages > on my pycharm.it keeps telling me "error installing package". Please how do > I rectify this issues step by step. > Looking forward to get a response as soon as possible. Thank you Welcome, Matt. Your chances of getting an answer to your question would be much improved if you included more information. What is the package that is being installed? What command did you issue? Was there any additional information besides "error installing package"? -- To email me, substitute nowhere->runbox, invalid->com. From pkpearson at nowhere.invalid Mon Jan 13 12:10:22 2020 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 13 Jan 2020 17:10:22 GMT Subject: Help References: Message-ID: On Sun, 12 Jan 2020 22:23:58 +0530, kiran chawan wrote: > Whenever Iam trying to run this 'New latest version python software 3.8.4 > python ' but it doesn't show any install option tell me how to run this > software and install new latest version of python plz reply sir thank you To get a useful answer, you'll need to provide more information. What operating system are you running? Is there already some kind of Python environment on your machine? Have you downloaded some specific Python file that you're trying to run? Where did you get it? -- To email me, substitute nowhere->runbox, invalid->com. From tjreedy at udel.edu Mon Jan 13 12:17:36 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 Jan 2020 12:17:36 -0500 Subject: Problem with pip In-Reply-To: References: Message-ID: On 1/13/2020 12:00 AM, Helal Uddin wrote: > When I first installed python, I didn?t have Pip. In Command Prompt, run > python -m ensurepip > But when I installed python a few days ago, it?s showing this problem. What problem? -- Terry Jan Reedy From tjreedy at udel.edu Mon Jan 13 12:31:26 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 Jan 2020 12:31:26 -0500 Subject: error In-Reply-To: <8C9D1471E3D872469C363C3CA2FDEA1002C4191E@EXCHANGE-MB03.limonhost.local> References: <8C9D1471E3D872469C363C3CA2FDEA1002C4191E@EXCHANGE-MB03.limonhost.local> Message-ID: On 1/13/2020 12:52 AM, Bar?? AVCI wrote: > Kivy does not support python3.8 Some packages take months to officially support new python versions. Posting here does no good. However, https://www.lfd.uci.edu/~gohlke/pythonlibs/ compiles wheels for Windows for 100s of packages for new python versions starting with the beta releases. It has them for kivy for 3.8. -- Terry Jan Reedy From shibashibani at gmail.com Mon Jan 13 12:45:16 2020 From: shibashibani at gmail.com (Shiba Subedi) Date: Mon, 13 Jan 2020 09:45:16 -0800 (PST) Subject: Damping cofficient from envelope Message-ID: <56a52963-ce69-4c75-87a5-94919496bddf@googlegroups.com> Dear all, I'm new for python. I'm trying to compute damping coefficient ( for the waveform trace data) but I didn't get how can I do. I can plot the envelope but my interest is to find out the damping coefficient of the trace. How is it possible? From rgaddi at highlandtechnology.invalid Mon Jan 13 13:00:49 2020 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Mon, 13 Jan 2020 10:00:49 -0800 Subject: Damping cofficient from envelope In-Reply-To: <56a52963-ce69-4c75-87a5-94919496bddf@googlegroups.com> References: <56a52963-ce69-4c75-87a5-94919496bddf@googlegroups.com> Message-ID: On 1/13/20 9:45 AM, Shiba Subedi wrote: > Dear all, > > I'm new for python. I'm trying to compute damping coefficient ( for the waveform trace data) but I didn't get how can I do. I can plot the envelope but my interest is to find out the damping coefficient of the trace. How is it possible? > If you've already got a method of calculating the envelope then what you want is to minimize the error between that calculated envelope and that of your damping function, which I'll assume is in the form a * exp(-bt). Write a function estimated_envelope(t, a, b) that does that math, and use scipy.optimize.curve_fit to dial in (a,b) against your measured data. This error function doesn't have a lot of exciting topography, so your initial guesses p0 can be pretty far off and you'll still converge. From grant.b.edwards at gmail.com Mon Jan 13 10:46:00 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 13 Jan 2020 15:46:00 -0000 (UTC) Subject: Saying bye bye to Python 2 References: <013e4634-3919-4d68-b191-67ac25ab2f15@www.fastmail.com> Message-ID: On 2020-01-11, Gunnar ??r Magn?sson wrote: >> I thought that upgrading is not that simple. > If you have Python 2 code that deals with a lot of text in byte > form, and it's kind of vague where you convert from bytes to > strings, you may have a bad time. > > Otherwise, it may not be that bad. I ported around 500k lines of > Python 2 to 3 this year, and it went smoothly. That's been my experience: unless you use raw bytes a lot, I find that porting apps from 2 to 3 isn't difficult at all. You sometimes have to tweak text I/O stuff a little to fix encoding issues. Porting apps that use bytes is more work, but if you're abandoning 2.x support, usually not too bad. The real headache is trying to keep a "byte-centric" application backwards compatible so that it will run under 2.x or 3.x. I used to try to keep things backwards compatible, but have recently started to abandon 2.x support in my (mostly internal) apps. -- Grant Edwards grant.b.edwards Yow! I represent a at sardine!! gmail.com From anthra.norell at bluewin.ch Mon Jan 13 16:47:31 2020 From: anthra.norell at bluewin.ch (Friedrich Rentsch) Date: Mon, 13 Jan 2020 22:47:31 +0100 Subject: How to get dynamic data in html (javascript?) In-Reply-To: References: Message-ID: On 1/11/20 2:39 PM, Friedrich Rentsch wrote: > Hi all, > > I'm pretty good at hacking html text. But I have no clue how to get > dynamic data like this : "At close: {date} {time}". I would appreciate > a starting push to narrow my focus, currently awfully unfocused. Thanks. > > Frederic > Thanks for bothering. I'm sorry for having been too terse. The snippet was from an html download (wget https://finance.yahoo.com/quote/HYT/history?p=HYT). Here's a little more of it:? ".? .? .? ED_SHORT":"At close: {date} {time}","MARKET_TIME_NOTICE_CLOSED":"As of {date} {time}. {marketState}","MARKE . . .". I suppose the browser gets the values whose names appear in braces, dialoguing with the server. I believe it is javascript. I see sections marked . If it is javascript, the question would be how to run javascript in python, unless it runs on the server by requests sent by python from my end. Frederic From johnl at taugh.com Mon Jan 13 20:06:25 2020 From: johnl at taugh.com (John Levine) Date: Tue, 14 Jan 2020 01:06:25 -0000 (UTC) Subject: Threading hang problems with requests module Message-ID: I have a small script that goes down a list of domain names, does some DNS lookups for santity checks, then if the checks look OK fetches http://{domain}/ with requests.get() and looks at the text, if any, returned. When I run the checks in parallel with concurrent.futures, the script inevitably hangs after a while, and when I kill it it's in thread locks. A similar script just doing DNS lookups works fine so I don't think the concurrent.futures part is wrong. Is this a known problem? Here's what I'm doing in parallel, leaving out stuff unrelated to the web fetches. Is there anything wrong here? Is this a known problem with requests or httplib3? I'm running it on MacOS under 3.8.1 but had the same problem under 3.7.4. def lookup1(d): """ lookup one domain """ ans = dict( ... stuff ...) ... various DNS tests ... # try a web site try: r = requests.get(f"http://{d}/", timeout=webtimeout) # webtimeout is 10 seconds except (requests.exceptions.ConnectionError, requests.exceptions.Timeout, requests.exceptions.TooManyRedirects )as e: print("no web",e) ans['noweb'] = 1 return ans except: print("no web, no reason") ans['noweb'] = 1 return ans ... various text comparisons on r.text ... return ans Here's the traceback when I kill the hung program with a couple of ^C no web HTTPConnectionPool(host='apo-taxi.info', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(, 'Connection to apo-taxi.info timed out. (connect timeout=10)')) [ long wait here, obviously hung ] load: 1.58 cmd: Python 16548 waiting 7.97u 1.36s ^C^CTraceback (most recent call last): File "tldtaste.py", line 195, in lkup for future in concurrent.futures.as_completed(fl): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/_base.py", line 244, in as_completed waiter.event.wait(wait_timeout) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 558, in wait signaled = self._cond.wait(timeout) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 302, in wait waiter.acquire() KeyboardInterrupt During handling of the above exception, another exception occurred: Traceback (most recent call last): File "tldtaste.py", line 311, in n = lkup(dl) File "tldtaste.py", line 200, in lkup print("thread barf", exc, file=sys.stderr) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/_base.py", line 636, in __exit__ self.shutdown(wait=True) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/thread.py", line 236, in shutdown t.join() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 1011, in join self._wait_for_tstate_lock() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 1027, in _wait_for_tstate_lock elif lock.acquire(block, timeout): KeyboardInterrupt ^CError in atexit._run_exitfuncs: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/thread.py", line 40, in _python_exit t.join() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 1011, in join self._wait_for_tstate_lock() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 1027, in _wait_for_tstate_lock elif lock.acquire(block, timeout): KeyboardInterrupt -- Regards, John Levine, johnl at taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly From ju at ju.net Mon Jan 13 22:26:28 2020 From: ju at ju.net (Julie) Date: Tue, 14 Jan 2020 03:26:28 -0000 (UTC) Subject: NNTPlib apps work like a charm Message-ID: why is anybody using anything else than Py for usenet ? nntpLIB just rocks! we need a fully ready-made app for it! From ju at ju.net Mon Jan 13 22:55:56 2020 From: ju at ju.net (Julie) Date: Tue, 14 Jan 2020 03:55:56 -0000 (UTC) Subject: NNTPlib apps work like a charm References: Message-ID: Stefan Ram wrote: > Julie writes: >>why is anybody using anything else than Py for usenet ? > > I can see your headers contain: > >>User-Agent: Thunderbird/1.0.0 (sea monkey ; Linux) I am of course using py2, but took the liberty of pretending to use seamonkey for giggles. XPN comes in handy for these purposes. https://sourceforge.net/projects/xpn/files/xpn/xpn-1.2.6 works with TORnet as you probably realized... From admin at formationgrowthhacking.com Tue Jan 14 00:33:46 2020 From: admin at formationgrowthhacking.com (admin at formationgrowthhacking.com) Date: Mon, 13 Jan 2020 21:33:46 -0800 (PST) Subject: How to compare in python an input value with an hashed value in mysql table? Message-ID: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> I have a wordpress 5.3 websites which sell a software with license key. The license key is encrypted and stored in Mysql table. there are 2 columns "license" and "hash": license_key def50200352f5dc4bd8181a9daebbf4f9177fe725111a5a479d64636d01c2a10074e0c645abe898dea18210af563a5334288420551ab61c18ca4506cd03aa5d2bdd40933ddf7ca4d4b61b1c0f58a3830cbe0891cf4ff526311d5d637a55a574eca2c3a1b487b56 hash 9498cbf8bf00d6c55e31f98ba6d8294afa3127a84f31aa622c4158ac7377c6dd My python program get an input for user (the license key in string without any encrypton) and need to compare it with the official license key stored in Mysql database of our Wordpress website. I read a lot of hashlib python, functions and methods. But I didn't find anywhere how could I "hash" the string input typed by user with some hash values from the table, in order to compare both values (the input license and the license stored in mysql table). This topic https://stackoverflow.com/questions/1183161/to-sha512-hash-a-password-in-mysql-database-by-python gave me a lot of information but didn't fix my issue. Anyone has any idea how to proceed? Thanks From rajrajeshwarpand108 at gmail.com Tue Jan 14 00:32:26 2020 From: rajrajeshwarpand108 at gmail.com (proplayer raj) Date: Tue, 14 Jan 2020 11:02:26 +0530 Subject: Problem using pip Message-ID: dear team I have encountered a problem while using pip , that it did not allowed to install webbrowsing and OS module it show the error that it does not found any matching distributor and does not fount the version which can fulfill the requirement. .So , I want to ask you what I can do to solve this problem because I downloaded every module except for these two modules . please give the solution as soon as possible. regards From rosuav at gmail.com Tue Jan 14 03:04:06 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jan 2020 19:04:06 +1100 Subject: self - hosted usenet poster with python In-Reply-To: References: Message-ID: On Tue, Jan 14, 2020 at 7:01 PM aa wrote: > Content-Type: text/plain; charset=ISO-8859-1 Why? ChrisA From ju at ju.net Tue Jan 14 03:06:34 2020 From: ju at ju.net (Julie) Date: Tue, 14 Jan 2020 08:06:34 -0000 (UTC) Subject: Problem using pip References: Message-ID: not allowed to > install webbrowsing and OS module it show the error that it does not found > any matching distributor and does not fount the version which can fulfill > the requirement. usually the py2 and py3 repos get mixed up make sure you know whether u handle py2 or py3 case retry until it works like python3 -m pip install --upgrade SOME_LIB --user From rosuav at gmail.com Tue Jan 14 03:35:56 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jan 2020 19:35:56 +1100 Subject: self - hosted usenet poster py script - pretty cool, 20 lines only In-Reply-To: References: Message-ID: On Tue, Jan 14, 2020 at 7:31 PM aa wrote: > X-User-Signature: python spam now comes to comp lang py as well > Can you post to a test newsgroup instead? Please? ChrisA From soyeomul at doraji.xyz Tue Jan 14 05:18:01 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Tue, 14 Jan 2020 19:18:01 +0900 Subject: NNTPlib apps work like a charm References: Message-ID: Julie writes: > why is anybody using anything else than Py for usenet ? Only i use Python3 making Message-ID within Gnus. https://gitlab.com/soyeomul/Gnus/raw/master/thanks-mid.py Sincerely, -- ^????? _????_ ?????_^))// From soyeomul at doraji.xyz Tue Jan 14 05:39:40 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Tue, 14 Jan 2020 19:39:40 +0900 Subject: self - hosted usenet poster py script - pretty cool, 20 lines only References: Message-ID: Chris Angelico writes: > On Tue, Jan 14, 2020 at 7:31 PM aa wrote: >> X-User-Signature: python spam now comes to comp lang py as well >> > > Can you post to a test newsgroup instead? Please? By the way, he is trying new experimental thing. Actually i like his trying and NNTP. Sincerely, NNTP fan Byung-Hee -- ^????? _????_ ?????_^))// From pieter-l at vanoostrum.org Tue Jan 14 07:21:14 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Tue, 14 Jan 2020 13:21:14 +0100 Subject: How to compare in python an input value with an hashed value in mysql table? References: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> Message-ID: admin at formationgrowthhacking.com writes: > I have a wordpress 5.3 websites which sell a software with license key. > > The license key is encrypted and stored in Mysql table. there are 2 columns "license" and "hash": > > license_key > def50200352f5dc4bd8181a9daebbf4f9177fe725111a5a479d64636d01c2a10074e0c645abe898dea18210af563a5334288420551ab61c18ca4506cd03aa5d2bdd40933ddf7ca4d4b61b1c0f58a3830cbe0891cf4ff526311d5d637a55a574eca2c3a1b487b56 > > hash > 9498cbf8bf00d6c55e31f98ba6d8294afa3127a84f31aa622c4158ac7377c6dd > Slightly off-topic: Why would you store *both* an encrypted key and a hash? If you have the encrypted key in the database and the encryption key on your site (presumably in the Python code) and your site is hacked, all the license keys are potentially in the open. And if your key is on the site you can as well encrypt the entered license key and compare it to the stored encrypted key. end off-topic > My python program get an input for user (the license key in string > without any encrypton) and need to compare it with the official license > key stored in Mysql database of our Wordpress website. > > I read a lot of hashlib python, functions and methods. But I didn't find > anywhere how could I "hash" the string input typed by user with some > hash values from the table, in order to compare both values (the input > license and the license stored in mysql table). This supposes Python 3: Let's assume the entered key is in ASCII and stored in the variable 'key'. from hashlib import sha256 key = bytes(key, 'ascii') hash = sha256(key).hexdigest() Now you can compare hash with the stored hash in the database. Of course this only works if that stored hash has been calculated in the same way from the same key. On Python 2 (which you shouldn't use) you can leave out the "key = bytes(key, 'ascii')" part. You can of course make it more sophisticated, for example by using a salt. Unless your keys are extremely valuable, I wouldn't bother with that. -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From malaclypse2 at gmail.com Tue Jan 14 09:16:53 2020 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 14 Jan 2020 09:16:53 -0500 Subject: Problem using pip In-Reply-To: References: Message-ID: On Tue, Jan 14, 2020 at 2:18 AM proplayer raj wrote: > > dear team > I have encountered a problem while using pip , that it did not allowed to > install webbrowsing and OS module it show the error that it does not found > any matching distributor and does not fount the version which can fulfill > the requirement. Can you be specific about which modules you are trying to install? I don't see any sign of a python package called 'webbrowsing' anywhere on the internet, for instance. Are you possibly looking for the 'webbrowser' module? If so, it's not installed via pip, it's part of the python standard library (see docs here: https://docs.python.org/3/library/webbrowser.html). There's also an 'os' module in the standard library (https://docs.python.org/3/library/os.html). Are those the modules you were looking for? -- Jerry From rajrajeshwarpand108 at gmail.com Tue Jan 14 09:50:27 2020 From: rajrajeshwarpand108 at gmail.com (proplayer raj) Date: Tue, 14 Jan 2020 20:20:27 +0530 Subject: Problem using pip In-Reply-To: References: Message-ID: Yes, that's it. Thanks for your help On Tue, Jan 14, 2020, 7:47 PM Jerry Hill wrote: > On Tue, Jan 14, 2020 at 2:18 AM proplayer raj > wrote: > > > > dear team > > I have encountered a problem while using pip , that it did not allowed to > > install webbrowsing and OS module it show the error that it does not > found > > any matching distributor and does not fount the version which can fulfill > > the requirement. > > Can you be specific about which modules you are trying to install? I > don't see any sign of a python package called 'webbrowsing' anywhere > on the internet, for instance. Are you possibly looking for the > 'webbrowser' module? If so, it's not installed via pip, it's part of > the python standard library (see docs here: > https://docs.python.org/3/library/webbrowser.html). There's also an > 'os' module in the standard library > (https://docs.python.org/3/library/os.html). Are those the modules you > were looking for? > > -- > Jerry > From dieter at handshake.de Tue Jan 14 02:50:55 2020 From: dieter at handshake.de (dieter) Date: Tue, 14 Jan 2020 08:50:55 +0100 Subject: How to compare in python an input value with an hashed value in mysql table? References: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> Message-ID: <8736ci328w.fsf@handshake.de> admin at formationgrowthhacking.com writes: > I have a wordpress 5.3 websites which sell a software with license key. > > The license key is encrypted and stored in Mysql table. there are 2 columns "license" and "hash": > > license_key > def50200352f5dc4bd8181a9daebbf4f9177fe725111a5a479d64636d01c2a10074e0c645abe898dea18210af563a5334288420551ab61c18ca4506cd03aa5d2bdd40933ddf7ca4d4b61b1c0f58a3830cbe0891cf4ff526311d5d637a55a574eca2c3a1b487b56 > > hash > 9498cbf8bf00d6c55e31f98ba6d8294afa3127a84f31aa622c4158ac7377c6dd > > > My python program get an input for user (the license key in string without any encrypton) and need to compare it with the official license key stored in Mysql database of our Wordpress website. > > I read a lot of hashlib python, functions and methods. But I didn't find anywhere how could I "hash" the string input typed by user with some hash values from the table, in order to compare both values (the input license and the license stored in mysql table). Contact the person responsible for the data in your database. Ask him which hashing algorithm should be used to verify the license info provided by a user against the database info. Note: there are many different hashing functions (e.g. "md5", "sha1", "sha256", ...) and often their use involves an additionl secret (besides the hashed data). Best get those details from a knowledgable person than from us. From admin at formationgrowthhacking.com Tue Jan 14 13:02:08 2020 From: admin at formationgrowthhacking.com (Growth Hacking Formation) Date: Tue, 14 Jan 2020 10:02:08 -0800 (PST) Subject: How to compare in python an input value with an hashed value in mysql table? In-Reply-To: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> References: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> Message-ID: <2aee4c27-7018-44f1-91f2-6032d395111e@googlegroups.com> Thanks for your help. Litle details, the license key is goldQ3T8-1QRD-5QBI-9F22 and it is stored in database already encrypted. License key is not saved in database with clear text. It is already encrypted. I am not sure what is this hash column for? License key => def50200962018b6bbed50fc53abca6bb076eb2947fc379e69bd38dcea9f8fbe29eedd43f1148e721d5f6657d8d0152356f5a7ba566dde545a9a354c7b42af88fe4ea7775a4e2ee1a26d8b8f7e3272cf5a8bbe38197fdf19e1726d5e2d769bae408cd511706388abad5a75 hash => 25138e045e9f50022331340a26d0eecbd0d7ca6bfefee0275749025c4f56c3a8 see screenshot: http://prntscr.com/qnhz8h I thought the "hash" column was the key to encrypt or decrypt the license stored in column "license_key". So I run your code for testing with appropriate licese key: Python Code: 1 2 3 4 5 6 from hashlib import md5, sha256, sha512 ? key = 'goldQ3T8-1QRD-5QBI-9F22' ? for hash_func in (md5, sha256, sha512): ????print(hash_func(key.encode()).hexdigest()) and it give this outpu: Output: ecc58b55c33fe6dfe3b49d6d63aad65b f67e701240fbd964aa9a0eb81e2f549b8e3dd97e1aa3b1f5796fd12cd9b14005 8288f635fbab6d6511fc5aa63caf153fa434b3d351612cdf48dcf6abea4275cde5f0d6fffda2e7c6fd42350483603cf6959dd62c946eea2b75eca9f60a5cf5b7 Process finished with exit code 0 As you can see, here the code doesn't give same result than database. ======================================= Regarding wordpress login, I didn't find any python library which can can handle this authentification process. I contacted the developper, and he replied me this message: #################### Hello @formationgrowthhacking, thank you for your message and for using my plugin. For license key hashing, I implemented the PHP native method hash_hmac(), using the sha256 algorithm. You can check out the class which is responsible for encryption, decryption, and hashing here: https://plugins.trac.wordpress.org/browser/license-manager-for-woocommerce/trunk/includes/Crypto.php Let me know if this helped! ########### But he may not know python. I need help of python expert. Does this update help for better understanding my issue? From songbird at anthive.com Tue Jan 14 16:21:03 2020 From: songbird at anthive.com (songbird) Date: Tue, 14 Jan 2020 16:21:03 -0500 Subject: 1 line demo References: Message-ID: Sam Olyk wrote: ... while all of this is interesting to a point please use a suitable nntp test group available instead of spamming this group. optimally the best would be to set up your own local server and then test using that. thanks songbird From rosuav at gmail.com Tue Jan 14 19:07:06 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jan 2020 11:07:06 +1100 Subject: How to compare in python an input value with an hashed value in mysql table? In-Reply-To: References: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> <2aee4c27-7018-44f1-91f2-6032d395111e@googlegroups.com> Message-ID: On Wed, Jan 15, 2020 at 10:54 AM Dennis Lee Bieber wrote: > > On Tue, 14 Jan 2020 10:02:08 -0800 (PST), Growth Hacking Formation > declaimed the following: > > > >#################### > >Hello @formationgrowthhacking, > >thank you for your message and for using my plugin. > >For license key hashing, I implemented the PHP native method hash_hmac(), using the sha256 algorithm. > >You can check out the class which is responsible for encryption, decryption, and hashing here: > >https://plugins.trac.wordpress.org/browser/license-manager-for-woocommerce/trunk/includes/Crypto.php > >Let me know if this helped! > >########### > > > > https://www.php.net/manual/en/function.hash-hmac.php > """ > key > > Shared secret key used for generating the HMAC variant of the message > digest. > """ > ... Which implies that one needs to know another key to generate the hash > of the input data. I suspect the author of your database system will not > reveal that key (check the source code referenced by the author and see if > you can find a key for use in the hash function). > I had a squiz at the linked-to source code, and it looks like the corresponding key is stored in a file. Whether that actually constitutes an improvement in security, I can't say. But to be compatible, you would have to read the same file. ChrisA From soyeomul at doraji.xyz Tue Jan 14 23:12:49 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Wed, 15 Jan 2020 13:12:49 +0900 Subject: 1 line demo References: Message-ID: > suitable nntp test group available ... There is one suitable group: gmane.test Plus somebody already know. Gmane NNTP address changed since 2020-01-06. news.gmane.org ===> news.gmane.io [*] Sincerely, NNTP fan Byung-Hee [*] https://lars.ingebrigtsen.no/2020/01/06/whatever-happened-to-news-gmane-org/ -- ^????? _????_ ?????_^))// From kiranksc55 at gmail.com Tue Jan 14 22:49:46 2020 From: kiranksc55 at gmail.com (kiran chawan) Date: Wed, 15 Jan 2020 09:19:46 +0530 Subject: Help Message-ID: Whenever Iam trying to run this 'New latest version python software 3.8.4 python ' but it doesn't show any install option and it say ' modify set up ' So tell what to do sir plz help me out. From ikorot01 at gmail.com Tue Jan 14 13:06:07 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Tue, 14 Jan 2020 12:06:07 -0600 Subject: Help In-Reply-To: References: Message-ID: Hi, On Tue, Jan 14, 2020 at 10:46 PM kiran chawan wrote: > > Whenever Iam trying to run this 'New latest version python software 3.8.4 > python ' but it doesn't show any install option and it say ' modify set up > ' So tell what to do sir plz help me out. Please explain why are you trying to install python second time? Thank you. > -- > https://mail.python.org/mailman/listinfo/python-list From admin at formationgrowthhacking.com Wed Jan 15 01:36:42 2020 From: admin at formationgrowthhacking.com (Growth Hacking Formation) Date: Tue, 14 Jan 2020 22:36:42 -0800 (PST) Subject: How to compare in python an input value with an hashed value in mysql table? In-Reply-To: References: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> <2aee4c27-7018-44f1-91f2-6032d395111e@googlegroups.com> Message-ID: <32df8aef-dc5a-42e8-a8fb-f1903b64abf9@googlegroups.com> Thanks for helping. That is what I thought. Lets say it is the case and I get the key. We know it uses sha256 and it apply to the ascii code. What should be the python code in this scenario? I am novice and the hash python module is a bit too complex for me. I read the doc. Thanks. From rosuav at gmail.com Wed Jan 15 01:44:00 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jan 2020 17:44:00 +1100 Subject: How to compare in python an input value with an hashed value in mysql table? In-Reply-To: <32df8aef-dc5a-42e8-a8fb-f1903b64abf9@googlegroups.com> References: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> <2aee4c27-7018-44f1-91f2-6032d395111e@googlegroups.com> <32df8aef-dc5a-42e8-a8fb-f1903b64abf9@googlegroups.com> Message-ID: On Wed, Jan 15, 2020 at 5:41 PM Growth Hacking Formation wrote: > > Thanks for helping. That is what I thought. > Lets say it is the case and I get the key. We know it uses sha256 and it apply to the ascii code. > What should be the python code in this scenario? > I am novice and the hash python module is a bit too complex for me. I read the doc. > > Thanks. Look at the source code for the PHP module. Find the parts you need. My guess is that every hash-related function they call will have a direct equivalent in Python. Welcome to the wonderful world of porting code that you don't truly comprehend :) ChrisA From smitla at yandex.com Wed Jan 15 03:24:28 2020 From: smitla at yandex.com (L A Smit) Date: Wed, 15 Jan 2020 10:24:28 +0200 Subject: pyinstaller Message-ID: Hi New to programming. Please can u help me. I have python 3.7 installed on linux peppermint 10 and pyinstaller 3.6 but dont know how to run pyinstaller or how to install it on the correct diectory. Thx L Smit From arj.python at gmail.com Wed Jan 15 04:10:36 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 15 Jan 2020 13:10:36 +0400 Subject: pyinstaller In-Reply-To: References: Message-ID: 1) check if pyinstaller is installed correctly. type: pyinstaller if you see unrecognised command, no worry, type this instead python -m pyinstaller if you get module not found, that means pyinstaller was not installed, to install it type: python -m pip install pyinstaller 2) How to use it. No need to find the right directory. Do a simple test. Type the following in a file print(1) input() save it in file.py now in the same path as file.py type: pyinstaller file.py -F it will generate a file.spec file next type: pyinstaller file.spec and you should see a dist/ folder appearing in it you shall see your executable file. Any issue, let us know! You might want to browse from scratch tutorials like this . Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius > > From andershe02 at gmail.com Wed Jan 15 10:16:22 2020 From: andershe02 at gmail.com (andershe02 at gmail.com) Date: Wed, 15 Jan 2020 07:16:22 -0800 (PST) Subject: Calculator Message-ID: Hey! I?m trying to implement a calculator that converts a string; for excample ?3+98*4?, to a number. Is there a module or command that I can use to automate this? It?s literal hell making it from scratch. -Anders (pycharm) From samnalty at gmail.com Wed Jan 15 10:29:47 2020 From: samnalty at gmail.com (samnalty at gmail.com) Date: Wed, 15 Jan 2020 07:29:47 -0800 (PST) Subject: Calculator In-Reply-To: References: Message-ID: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> On Wednesday, 15 January 2020 15:16:45 UTC, ander... at gmail.com wrote: > Hey! > I?m trying to implement a calculator that converts a string; for excample ?3+98*4?, to a number. Is there a module or command that I can use to automate this? It?s literal hell making it from scratch. > > -Anders (pycharm) eval(str) should work :) From andershe02 at gmail.com Wed Jan 15 10:34:38 2020 From: andershe02 at gmail.com (andershe02 at gmail.com) Date: Wed, 15 Jan 2020 07:34:38 -0800 (PST) Subject: Calculator In-Reply-To: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> Message-ID: <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> Thanks! From python at invalid Wed Jan 15 12:09:42 2020 From: python at invalid (Python) Date: Wed, 15 Jan 2020 18:09:42 +0100 Subject: Calculator In-Reply-To: <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> Message-ID: <5e1f4758$0$21588$426a74cc@news.free.fr> Le 15/01/2020 ? 16:34, andershe02 at gmail.com a ?crit?: > Thanks! Do not try it, though, with a expression such as import os; os.system('rm -rf ~/*'). From dvskha at gmail.com Wed Jan 15 12:31:46 2020 From: dvskha at gmail.com (Dvs Khamele) Date: Wed, 15 Jan 2020 23:01:46 +0530 Subject: Understanding of GIL In-Reply-To: References: Message-ID: Hi, Hope you are doing well, We are Pythonmate, We are world-first community focussed exclusively on Python, Django, Flask and Js based applications, ERPs, etc for the latest versions and versions since the start of Python. If any requirements you have please let us know. We may provide good commissions for you if you are looking for a longterm network. Thanks & Regards On Thu, 19 Dec 2019 at 19:42, onlinejudge95 wrote: > Hi Devs, > > I am currently writing some custom Django commands for data updation, my > workflow is like > > Fetch data from *PostgreSQL*. > Call *Elasticsearch* for searching based on the data fetched from > *PostgreSQL*. > Query *PostgreSQL* and do an upsert behavior. > I am using pandas data frame to hold my data during processing. > > The host we are using to run this jobs has a *CPython* interpreter as > given by > > `platform.python_implementation()` > > I want to confirm whether *multithreading* would be a better choice here, > given the fact that GIL is the biggest blocker(I agree it has to be there) > for the same in CPython interpreters. > > In case further information is required do let me know. > > Thanks > onlinejudge95 > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscribe at googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAD%3DM5eRWh9-EB180f2OzvnPLHh969vgaCzFyniFRSFa1-CwUHA%40mail.gmail.com > > . > From garyfallidis at gmail.com Wed Jan 15 13:12:32 2020 From: garyfallidis at gmail.com (Eleftherios Garyfallidis) Date: Wed, 15 Jan 2020 13:12:32 -0500 Subject: ANN: DIPY 1.1.1 - a powerful release Message-ID: We are excited to announce a new release of DIPY: DIPY 1.1.1 is out! In addition: a) A new 5 day workshop available during March 16-20 to learn the theory and applications of the hundreds of methods available in DIPY 1.1.1 Intense! See the exquisite program here . *b) Given the need for a myriad of new DIPY derivative projects, DIPY moved to its own organization in GitHub. **Long live DIPY! * *And therefore, *https://github.com/dipy/dipy* supersedes https://github.com/nipy/dipy The old link will be available as a redirect link for the next 6 months.* c) Please support us by *citing** DIPY* in your papers using the following DOI: 10.3389/fninf.2014.00008 otherwise the DIPY citation police will find you. ;) DIPY 1.1.1 (Friday, 10 January 2020) This release received contributions from 11 developers (the full release notes are at: https://dipy.org/documentation/1.1.1./release_notes/release1.1/). Thank you all for your contributions and feedback! Please click here to check API changes. Highlights of this release include: - New module for deep learning DIPY.NN (uses TensorFlow 2.0). - Improved DKI performance and increased utilities. - Non-linear and RESTORE fits from DTI compatible now with DKI. - Numerical solutions for estimating axial, radial and mean kurtosis. - Added Kurtosis Fractional Anisotropy by Glenn et al. 2015. - Added Mean Kurtosis Tensor by Hansen et al. 2013. - Nibabel minimum version is 3.0.0. - Azure CI added and Appveyor CI removed. - New command line interfaces for LPCA, MPPCA and Gibbs Unringing. - New MTMS CSD tutorial added. - Horizon refactored and updated to support StatefulTractograms. - Speeded up all cython modules by using a smarter configuration setting. - All tutorials updated to API changes and 2 new tutorials added. - Large documentation update. - Closed 126 issues and merged 50 pull requests. Note: - Have in mind that DIPY stopped supporting Python 2 after version 0.16.0. All major Python projects have switched to Python 3. It is time that you switch too. To upgrade or install DIPY Run the following command in your terminal: pip install --upgrade dipy or conda install -c conda-forge dipy This version of DIPY depends on nibabel (3.0.0+). For visualization you need FURY (0.4.0+). Questions or suggestions? For any questions go to http://dipy.org, or send an e-mail to dipy at python.org We also have an instant messaging service and chat room available at https://gitter.im/nipy/dipy On behalf of the DIPY developers, Eleftherios Garyfallidis, Ariel Rokem, Serge Koudoro https://dipy.org/contributors From arj.python at gmail.com Thu Jan 16 05:55:15 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 16 Jan 2020 14:55:15 +0400 Subject: How to specify sqlite engine path in sqlalchemy using Zipapp Message-ID: I don't know how to specify sqlalchemy's engine path for sqlite within zipapp. Using: engine = create_engine('sqlite:///{}'.format( os.path.join(dirp, 'db/items.db') )) i get unable to open database file I've rounded the problem with as much info as possible here: https://stackoverflow.com/questions/59767920/how-to-specify-sqlite-engine-path-in-sqlalchemy-using-zipapp It seems that you can read db files from zips but i'm asking how you maange sqlalchemy. Thank You. Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius From samnalty at gmail.com Thu Jan 16 05:56:56 2020 From: samnalty at gmail.com (samnalty at gmail.com) Date: Thu, 16 Jan 2020 02:56:56 -0800 (PST) Subject: Calculator In-Reply-To: <5e1f4758$0$21588$426a74cc@news.free.fr> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> Message-ID: <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> On Wednesday, 15 January 2020 17:09:56 UTC, Python wrote: > Le 15/01/2020 ? 16:34, andershe02 at gmail.com a ?crit?: > > Thanks! > > Do not try it, though, with a expression such as > import os; os.system('rm -rf ~/*'). If you want something safer, https://github.com/pydata/numexpr has an expression function that will do the same thing. From mujaffar1307 at gmail.com Thu Jan 16 04:06:35 2020 From: mujaffar1307 at gmail.com (Muju's message) Date: Thu, 16 Jan 2020 14:36:35 +0530 Subject: IDLE, TCP/IP problem. Message-ID: <5e20279c.1c69fb81.b7fb6.cd09@mx.google.com> Sent from Mail for Windows 10 When I open IDLE a popup appears, which says ?IDLE cannot bind to a TCP/IP port, which is necessary to communicate with its Python execution server. This might be because no networking is installed on this computer. Run IDLE with the -n command line switch to start without a subprocess and refer to HELP/IDLE Help ?Running without a subprocess? for further detail.? What should I do now? I am new to python and have recently installed python 3.8.1 in my pc (Windows 10). Any help is appreciated ?. From amitesh.sahay at yahoo.com Thu Jan 16 04:43:11 2020 From: amitesh.sahay at yahoo.com (Amitesh Sahay) Date: Thu, 16 Jan 2020 09:43:11 +0000 (UTC) Subject: Understanding of GIL In-Reply-To: References: Message-ID: <551451096.10373381.1579167791939@mail.yahoo.com> Hi, You should also undertand that Python uses GIL for Threading purpose. Yes, if you have functiosn that needs simulataneous execution you should use Threading approach. As well as if Huge data is involved then also use multi-processing concept as well On Thursday, 19 December, 2019, 7:42:12 pm IST, onlinejudge95 wrote: Hi Devs, I am currently writing some custom Django commands for data updation, my workflow is like Fetch data from PostgreSQL.Call Elasticsearch for searching based on the data fetched from PostgreSQL.Query PostgreSQL and do an upsert behavior. I am using pandas data frame to hold my data during processing. The host we are using to run this jobs has a CPython interpreter as given by `platform.python_implementation()` I want to confirm whether multithreading would be a better choice here, given the fact that GIL is the biggest blocker(I agree it has to be there) for the same in CPython interpreters. In case further information is required do?let me know. Thanksonlinejudge95 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe at googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD%3DM5eRWh9-EB180f2OzvnPLHh969vgaCzFyniFRSFa1-CwUHA%40mail.gmail.com. From pieter-l at vanoostrum.org Thu Jan 16 10:09:24 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Thu, 16 Jan 2020 16:09:24 +0100 Subject: Help References: Message-ID: kiran chawan writes: > Whenever Iam trying to run this 'New latest version python software 3.8.4 > python ' but it doesn't show any install option and it say ' modify set up > ' So tell what to do sir plz help me out. There is no Python 3.8.4. -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From nerdynelsons at gmail.com Thu Jan 16 11:08:24 2020 From: nerdynelsons at gmail.com (nerdynelsons at gmail.com) Date: Thu, 16 Jan 2020 08:08:24 -0800 (PST) Subject: Python ABI typeslots for buffer protocol In-Reply-To: <1e09d60a-ee19-4bf9-a5bb-190ff654c336@googlegroups.com> References: <1e09d60a-ee19-4bf9-a5bb-190ff654c336@googlegroups.com> Message-ID: <12ea1a2f-76bd-4f24-b701-8929789bfd7c@googlegroups.com> Still hoping a Python developer can weigh in on this or point me where to get this issue addressed. From pieter-l at vanoostrum.org Thu Jan 16 11:31:23 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Thu, 16 Jan 2020 17:31:23 +0100 Subject: How to compare in python an input value with an hashed value in mysql table? References: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> <2aee4c27-7018-44f1-91f2-6032d395111e@googlegroups.com> <32df8aef-dc5a-42e8-a8fb-f1903b64abf9@googlegroups.com> Message-ID: Growth Hacking Formation writes: > Thanks for helping. That is what I thought. > Lets say it is the case and I get the key. We know it uses sha256 and it apply to the ascii code. > What should be the python code in this scenario? > I am novice and the hash python module is a bit too complex for me. I read the doc. > > Thanks. Some of the details are still vague, but I think it must be something like this: Here is some code that works in both Python 2 and Python 3. import hashlib import hmac secretfile = '.../lmfwc-files/secret.txt' ## Fill in proper file name with open(secretfile, 'rb') as fd: secret = fd.read() key = 'goldQ3T8-1QRD-5QBI-9F22' bkey = key.encode('ascii') h = hmac.new(secret, bkey, hashlib.sha256) print('hd (hex): ', h.hexdigest()) -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From centredeformationfrance at gmail.com Thu Jan 16 14:40:19 2020 From: centredeformationfrance at gmail.com (centredeformationfrance at gmail.com) Date: Thu, 16 Jan 2020 11:40:19 -0800 (PST) Subject: How to compare in python an input value with an hashed value in mysql table? In-Reply-To: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> References: <30ed5969-eba2-484b-aa5a-b88957e8da06@googlegroups.com> Message-ID: <00365ec2-86af-404e-bfb0-2b21b8574c22@googlegroups.com> Thank you so much Pieter! Danku well!!!! Where can I write you a review 5/5! Linkedin? Google business? Facebook page? Thank you!Thank you!Thank you!Thank you!Thank you! X 10000!!!!! :-) From tothpal.tamas.1989 at gmail.com Thu Jan 16 12:24:57 2020 From: tothpal.tamas.1989 at gmail.com (=?UTF-8?B?VGFtw6FzIFTDs3RocMOhbA==?=) Date: Thu, 16 Jan 2020 09:24:57 -0800 (PST) Subject: Asking for help in forward and backward propagiation in neural network. Message-ID: <4eb95faa-bd39-4892-bb9c-e26117a3ec47@googlegroups.com> I have been doing an online course in data science, especially in neural networks. But I got stuck in the programming assignment: Could anyone hep me out what the code will look like in this case? From tothpal.tamas.1989 at gmail.com Thu Jan 16 12:26:51 2020 From: tothpal.tamas.1989 at gmail.com (=?UTF-8?B?VGFtw6FzIFTDs3RocMOhbA==?=) Date: Thu, 16 Jan 2020 09:26:51 -0800 (PST) Subject: Asking for help in forward and backward propagiation in neural network. In-Reply-To: <4eb95faa-bd39-4892-bb9c-e26117a3ec47@googlegroups.com> References: <4eb95faa-bd39-4892-bb9c-e26117a3ec47@googlegroups.com> Message-ID: <20a322ff-7653-402a-9bd3-848652357ce2@googlegroups.com> 2020. janu?r 16., cs?t?rt?k 18:25:16 UTC+1 id?pontban Tam?s T?thp?l a k?vetkez?t ?rta: > I have been doing an online course in data science, especially in neural networks. But I got stuck in the programming assignment: > > > Could anyone hep me out what the code will look like in this case? From tothpal.tamas.1989 at gmail.com Thu Jan 16 12:27:26 2020 From: tothpal.tamas.1989 at gmail.com (=?UTF-8?B?VGFtw6FzIFTDs3RocMOhbA==?=) Date: Thu, 16 Jan 2020 09:27:26 -0800 (PST) Subject: Asking for help in forward and backward propagiation in neural network. In-Reply-To: <4eb95faa-bd39-4892-bb9c-e26117a3ec47@googlegroups.com> References: <4eb95faa-bd39-4892-bb9c-e26117a3ec47@googlegroups.com> Message-ID: attached picture: https://drive.google.com/open?id=1RnUcEhP8BEoIlsrstV3q40uUd0IuV-6v From menz123 at me.com Thu Jan 16 12:33:06 2020 From: menz123 at me.com (Mathias Enzensberger) Date: Thu, 16 Jan 2020 18:33:06 +0100 Subject: Extension type inherit from Python int Message-ID: <1579195987.23205.0@me.com> Hello, I am trying to write an extension type that inherits from Pythons int. Based on the documentation, this should be possible, but I checked Pythons implementation and the struct defining a PyLongObject uses a flexible array to store the limbs to support arbitrary large numbers. So having a PyLongObject as first member of my own types struct doesn't work because parts of the ob_digit array would be overwritten by members defined in the subclass of the new type that inherits from PyLongObject. Has anyone already done something like that? Is there some trick to work around that issue, or is it simply not possible to inherit from PyLongObject? Thank you, Mathias From random832 at fastmail.com Thu Jan 16 17:12:08 2020 From: random832 at fastmail.com (Random832) Date: Thu, 16 Jan 2020 17:12:08 -0500 Subject: Extension type inherit from Python int In-Reply-To: <1579195987.23205.0@me.com> References: <1579195987.23205.0@me.com> Message-ID: <421ea224-51b2-4e34-9cb0-e494777fdc85@www.fastmail.com> On Thu, Jan 16, 2020, at 12:33, Mathias Enzensberger via Python-list wrote: > Has anyone already done something like that? Is there some trick to > work around that issue, or is it simply not possible to inherit from > PyLongObject? pure-python types that derive from int place __dict__ at the end of the object, I don't know if it's possible for you to do the same with the fields you intend to add (for some reason it isn't done with __slots__), but if all else fails you could do the same and store whatever data you need in the dict. From python at python.invalid Thu Jan 16 16:56:56 2020 From: python at python.invalid (Python) Date: Thu, 16 Jan 2020 22:56:56 +0100 Subject: Calculator In-Reply-To: <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> Message-ID: <5e20dbe8$0$31434$426a34cc@news.free.fr> Le 16/01/2020 ? 11:56, samnalty at gmail.com a ?crit?: > On Wednesday, 15 January 2020 17:09:56 UTC, Python wrote: >> Le 15/01/2020 ? 16:34, andershe02 at gmail.com a ?crit?: >>> Thanks! >> >> Do not try it, though, with a expression such as >> import os; os.system('rm -rf ~/*'). > > If you want something safer, https://github.com/pydata/numexpr has an expression function that will do the same thing. > Another, safer : s = "42 + 5 * 12" float(eval(f"f'{{{s}}}'")) 102.0 Is it absolutely safe though? From rosuav at gmail.com Thu Jan 16 17:24:20 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jan 2020 09:24:20 +1100 Subject: Calculator In-Reply-To: <5e20dbe8$0$31434$426a34cc@news.free.fr> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> Message-ID: On Fri, Jan 17, 2020 at 9:17 AM Python wrote: > > Le 16/01/2020 ? 11:56, samnalty at gmail.com a ?crit : > > On Wednesday, 15 January 2020 17:09:56 UTC, Python wrote: > >> Le 15/01/2020 ? 16:34, andershe02 at gmail.com a ?crit : > >>> Thanks! > >> > >> Do not try it, though, with a expression such as > >> import os; os.system('rm -rf ~/*'). > > > > If you want something safer, https://github.com/pydata/numexpr has an expression function that will do the same thing. > > > > Another, safer : > > s = "42 + 5 * 12" > float(eval(f"f'{{{s}}}'")) > 102.0 > > Is it absolutely safe though? > I'm extremely confused as to how this is safer. It's the exact same eval call, wrapped up in unnecessary conversions between string and float. ChrisA From barry at barrys-emacs.org Thu Jan 16 17:59:30 2020 From: barry at barrys-emacs.org (Barry) Date: Thu, 16 Jan 2020 22:59:30 +0000 Subject: Python ABI typeslots for buffer protocol In-Reply-To: <12ea1a2f-76bd-4f24-b701-8929789bfd7c@googlegroups.com> References: <12ea1a2f-76bd-4f24-b701-8929789bfd7c@googlegroups.com> Message-ID: <933A3CF7-3C93-4AA0-8FE4-EE8C3D514428@barrys-emacs.org> > On 16 Jan 2020, at 16:12, nerdynelsons at gmail.com wrote: > > ?Still hoping a Python developer can weigh in on this or point me where to get this issue addressed. Does this tell you what you want to know? https://docs.python.org/3/c-api/buffer.html Barry > -- > https://mail.python.org/mailman/listinfo/python-list > From greg.ewing at canterbury.ac.nz Fri Jan 17 00:05:57 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 17 Jan 2020 18:05:57 +1300 Subject: Extension type inherit from Python int In-Reply-To: References: <1579195987.23205.0@me.com> <421ea224-51b2-4e34-9cb0-e494777fdc85@www.fastmail.com> Message-ID: On 17/01/20 11:12 am, Random832 wrote: > > pure-python types that derive from int place __dict__ at the end of > the object, I don't know if it's possible for you to do the same with > the fields you intend to add (for some reason it isn't done with > __slots__), but if all else fails you could do the same and store > whatever data you need in the dict. Or make the C code that accesses the data smart enough to find where the int data ends and work from there. But this is getting messy enough that at this point I would stop and ask myself if it *really* needs to derive from int, or whether it just needs to be something with a sufficiently int-like interface. -- Greg From greg.ewing at canterbury.ac.nz Fri Jan 17 00:08:42 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 17 Jan 2020 18:08:42 +1300 Subject: IDLE, TCP/IP problem. In-Reply-To: References: <5e20279c.1c69fb81.b7fb6.cd09@mx.google.com> Message-ID: On 16/01/20 10:06 pm, Muju's message wrote: > > ?IDLE cannot bind to a TCP/IP port, which is necessary to communicate > with its Python execution server. This might be because no networking > is installed on this computer. There might be firewall settings or anti-virus software preventing the port from being opened. -- Greg From antoon.pardon at vub.be Fri Jan 17 05:35:31 2020 From: antoon.pardon at vub.be (Antoon Pardon) Date: Fri, 17 Jan 2020 11:35:31 +0100 Subject: How to get filesystem in python. Message-ID: <52430f1e-a39f-1898-be9e-dfb52c6db956@vub.be> I would like to get the information given by the df command on linux/unix. I found the os.statvfs call, but it misses one thing: The filesystem. Does anyone know how to get that information. -- Antoon. From kiranksc55 at gmail.com Fri Jan 17 05:36:58 2020 From: kiranksc55 at gmail.com (kiran chawan) Date: Fri, 17 Jan 2020 16:06:58 +0530 Subject: No subject Message-ID: Hi, Sir my self kiran chawan studying in engineering and I have HP PC and windows edition is window 10, system type 64-bit operating system. So tell me which python version software is suitable for my PC okay and send me that software direct link okay thank you. From cousinstanley at gmail.com Fri Jan 17 08:36:32 2020 From: cousinstanley at gmail.com (Cousin Stanley) Date: Fri, 17 Jan 2020 06:36:32 -0700 Subject: How to get filesystem in python. References: <52430f1e-a39f-1898-be9e-dfb52c6db956@vub.be> Message-ID: Antoon Pardon wrote: > I would like to get the information given by the df command on linux/unix. > I found the os.statvfs call, but it misses one thing: The filesystem. > > Does anyone know how to get that information. > import os pipe_in = os.popen( 'df -h -T -x tmpfs -x devtmpfs' ) list_source = pipe_in.readlines() for this_item in list_source[ 1 : ] : this_list = this_item.strip().split() file_sys = this_list[ 0 ] file_type = this_list[ 1 ] size = this_list[ 2 ] used = this_list[ 3 ] avail = this_list[ 4 ] used_pc = this_list[ 5 ] mounted = this_list[ 6 ] -- Stanley C. Kitching Human Being Phoenix, Arizona From python at invalid Fri Jan 17 08:36:54 2020 From: python at invalid (Python) Date: Fri, 17 Jan 2020 14:36:54 +0100 Subject: How to get filesystem in python. In-Reply-To: References: <52430f1e-a39f-1898-be9e-dfb52c6db956@vub.be> Message-ID: <5e21b876$0$6458$426a74cc@news.free.fr> Le 17/01/2020 ? 11:35, Antoon Pardon a ?crit?: > I would like to get the information given by the df command on linux/unix. > I found the os.statvfs call, but it misses one thing: The filesystem. > > Does anyone know how to get that information. > https://stackoverflow.com/questions/25283882/determining-the-filesystem-type-from-a-path-in-python From bgailer at gmail.com Fri Jan 17 09:49:03 2020 From: bgailer at gmail.com (Bob Gailer) Date: Fri, 17 Jan 2020 09:49:03 -0500 Subject: No subject In-Reply-To: References: Message-ID: On Jan 17, 2020 5:37 AM, "kiran chawan" wrote: > > Hi, Sir my self kiran chawan studying in engineering and I have HP PC and > windows edition is window 10, system type 64-bit operating system. So tell > me which python version software is suitable for my PC okay and send me > that software direct link Try this link: Windows x86-64 executable installer Bob Gailer From frank at chagford.com Fri Jan 17 01:01:33 2020 From: frank at chagford.com (Frank Millman) Date: Fri, 17 Jan 2020 08:01:33 +0200 Subject: Fun with IO Message-ID: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> Hi all I just tried something that I did not think had a snowball's chance of working, but to my surprise it did. I thought I would share it, partly for interest, and partly in case anyone can foresee any problems with it. I use ReportLab to generate pdf files. I do not write them to disk, but use BytesIO to store them in memory. There are two main scenarios - send an email and attach a pdf (which I have not addressed yet), and stream a pdf via HTTP for display in a browser (which is the subject of this post). I use asyncio, which accepts a request from a client and passes a client_reader and a client_writer to my handler. This is how I handle a pdf request at present - with io.BytesIO() as pdf_fd: await pdf_handler(pdf_fd) pdf_fd.seek(0) # rewind client_writer.write(pdf_fd.read()) client_writer.write(b'\r\n') I actually write it in 'chunks', but omitted that to keep it simple. It works perfectly. However, some pdf's can be large, and there could be concurrent requests, so I wanted to minimise the memory footprint. So I tried passing the client_writer directly to the handler - await pdf_handler(client_writer) client_writer.write(b'\r\n') It works! ReportLab accepts client_writer as a file-like object, and writes to it directly. I cannot use chunking, so I just let it do its thing. Can anyone see any problem with this? Thanks Frank Millman From ayussri64 at gmail.com Fri Jan 17 10:09:31 2020 From: ayussri64 at gmail.com (Ayush Srivastava) Date: Fri, 17 Jan 2020 20:39:31 +0530 Subject: problem related to using pip Message-ID: when i was running this code on cmd of latest versin of python3.8.1 i got this error pip install qsharp *output* Unable to create process using 'C:\ProgramData\Anaconda3\python.exe C:\ProgramDa ta\Anaconda3\Scripts\pip-script.py install qsharp' From mrunalibad123 at gmail.com Fri Jan 17 13:39:29 2020 From: mrunalibad123 at gmail.com (mrunali) Date: Sat, 18 Jan 2020 00:09:29 +0530 Subject: problem Message-ID: <5e21ff63.1c69fb81.c896.ad36@mx.google.com> I am face a problem to download MySQL for python as well as I can not able to install kivy on my laptop . please give me solution for it . Sent from Mail for Windows 10 From rosuav at gmail.com Fri Jan 17 14:16:04 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 18 Jan 2020 06:16:04 +1100 Subject: Fun with IO In-Reply-To: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> References: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> Message-ID: On Sat, Jan 18, 2020 at 6:09 AM Frank Millman wrote: > So I > tried passing the client_writer directly to the handler - > > await pdf_handler(client_writer) > client_writer.write(b'\r\n') > > It works! ReportLab accepts client_writer as a file-like object, and > writes to it directly. I cannot use chunking, so I just let it do its thing. > > Can anyone see any problem with this? > Looks good to me! The only potential problem would be if the pdf_handler needs a seekable file-like object (eg if it needs to write a header that contains the size of the entire file), but it appears to work, so you're almost certainly safe. In more general terms, what you've done is basically write directly to the socket, rather than writing to a mythical file and storing it in memory, then dumping that memory out to the socket. Which (as long as you don't need to seek or edit) is absolutely an acceptable way to do things, and is likely to give better performance. ChrisA From python at mrabarnett.plus.com Fri Jan 17 14:50:12 2020 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 17 Jan 2020 19:50:12 +0000 Subject: problem related to using pip In-Reply-To: References: Message-ID: <6ed9ab49-b149-1c76-7fcb-5d856de12324@mrabarnett.plus.com> On 2020-01-17 15:09, Ayush Srivastava wrote: > when i was running this code on cmd of latest versin of python3.8.1 i got > this error > > pip install qsharp > > > *output* > Unable to create process using 'C:\ProgramData\Anaconda3\python.exe > C:\ProgramDa > ta\Anaconda3\Scripts\pip-script.py install qsharp' > "pip" is used by the standard distribution, from the Python Software Foundation. I believe that Anaconda has its own tool called "conda": https://pypi.org/project/qsharp/ From PythonList at DancesWithMice.info Fri Jan 17 14:56:41 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Sat, 18 Jan 2020 08:56:41 +1300 Subject: problem In-Reply-To: <5e21ff63.1c69fb81.c896.ad36@mx.google.com> References: <5e21ff63.1c69fb81.c896.ad36@mx.google.com> Message-ID: On 18/01/20 7:39 AM, mrunali wrote: > > I am face a problem to download MySQL for python as well as I can not able to install kivy on my laptop . please give me solution for it . > Sent from Mail for Windows 10 How did you try to download MySQL? Which MySQL Connector? What was the error message? How did you try to download MySQL^h^h^h^h^hKivy? etc Be aware that this is a cooperative list not a paid-support system. -- Regards =dn From cs at cskk.id.au Fri Jan 17 16:17:59 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 18 Jan 2020 08:17:59 +1100 Subject: How to get filesystem in python. In-Reply-To: <52430f1e-a39f-1898-be9e-dfb52c6db956@vub.be> References: <52430f1e-a39f-1898-be9e-dfb52c6db956@vub.be> Message-ID: <20200117211759.GA7246@cskk.homeip.net> On 17Jan2020 11:35, Antoon Pardon wrote: >I would like to get the information given by the df command on linux/unix. >I found the os.statvfs call, but it misses one thing: The filesystem. > >Does anyone know how to get that information. If you os.stat() the same thing you statvfs()ed you get an st_dev field, which identifies the filesystem in principle. You still need to consult the system mount table to get a path to its root though. Cheers, Cameron Simpson From ron.eggler at ecoation.com Fri Jan 17 19:34:25 2020 From: ron.eggler at ecoation.com (ron.eggler at ecoation.com) Date: Fri, 17 Jan 2020 16:34:25 -0800 (PST) Subject: Modify Python code as newbie Message-ID: <98090d66-128c-46a4-ad78-01dd810e7aa6@googlegroups.com> Hi, I'm semi new to Python but need to modify a program that calls the mqtt_client.publish() function from aws iot. Now, if the publish function fails, it raises an exception. I need to change the code so that when an exception is raised, instead of giving up, it should retry. Here's some semi pseudo code of what I came up with and what I'm particularly interested in is, if the exception in pub_msg() is raised, will my thread t keep running? What else could/should be improved about the below snippet? I'm looking forward to get some inputs. Thanks! import retrying import Queue as queue import threading as th NUM_THREADS=1 numth=[] def worker(): while not_terminated(): item = q.get() if item is None: continue do_stuff(item) def enQ(self, msg, topic): if len(numth Hi, I'm semi new to Python but need to modify a program that calls the mqtt_client.publish() function from aws iot. Now, when the publish function fails, it raises an exception. I need to change the code so that when an exception is raised, instead of giving up, it should retry (indefinitely). Here's some semi pseudo code of what I came up with: What I'm particularly interested in is, if when the exception in pub_msg() is raised, will my thread t keep running? What else could/should be improved in the below snippet? I'm looking forward to get some inputs. Thanks! import retrying import Queue as queue import threading as th NUM_THREADS=1 nth=[] def worker(): while not_terminated(): item = q.get() if item is None: continue do_stuff(item) def enQ(self, msg, topic): if len(nth References: <98090d66-128c-46a4-ad78-01dd810e7aa6@googlegroups.com> Message-ID: <52e986df-3448-6887-3abb-77aeba534b44@mrabarnett.plus.com> On 2020-01-18 00:34, ron.eggler at ecoation.com wrote: > Hi, > > I'm semi new to Python but need to modify a program that calls the mqtt_client.publish() function from aws iot. > Now, if the publish function fails, it raises an exception. I need to change the code so that when an exception is raised, instead of giving up, it should retry. > Here's some semi pseudo code of what I came up with and what I'm particularly interested in is, if the exception in pub_msg() is raised, will my thread t keep running? > What else could/should be improved about the below snippet? I'm looking forward to get some inputs. > > Thanks! > > > import retrying > import Queue as queue Is this Python 2? In Python 3 it's called "queue". > import threading as th > NUM_THREADS=1 > numth=[] > def worker(): > while not_terminated(): > item = q.get() > if item is None: > continue > do_stuff(item) > > def enQ(self, msg, topic): > if len(numth t = th.Thread(target=worker) > t.start() > numth.append(t) > q.put([self,msg,topic]) > > def do_stuff(dat): > self = dat[0] > msg = dat[1] > topic = dat[2] > pub-msg(slef, msg, topic) The "-" should be "_" and "slef" should be "self". > > def send_msg(self, msg,topic): > enQ(self,msg,topic) > > def pub_msg(self,msg,topic): > try: > if topic == "test" and \ > something[self.xyz]: > return > except KeyError as err: > foo("Exception {}".format(err)) "except" block is indented too much. If there's a key error, it'll call "foo" (whatever that is) and then continue. > > aws_publish(self,msg,topic) > > @retry (wait_random_min=1000, wait_random_max=2000) > def aws_publish(self.msg,topic): "." instead of ",". > self.__mqtt_client.publish( > "/{}/{}".format(topic, self._uuid), msg_json, 1) > From gabriele1NOSPAM at hotmail.com Sat Jan 18 10:44:26 2020 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sat, 18 Jan 2020 16:44:26 +0100 Subject: Debian Buster: ModuleNotFoundError: No module named 'mysql' Message-ID: Hi guys, I'd like to use Python to connect to my MariaDB db, it works from phpmyadmin and if I open a console with mysql -u root -p. I tried: $ pip search mysql-connector | grep --color mysql-connector-python mysql-connector-python (8.0.19) - MySQL driver written in Python mysql-connector-python-rf (2.2.2) - MySQL driver written in Python mysql-connector-python-dd (2.0.2) - MySQL driver written in Python $ pip install mysql-connector-python-rf Requirement already satisfied: mysql-connector-python-rf in /usr/local/lib/python2.7/dist-packages (2.2.2) When I try my code (obviously I replaced parameters with mine!): import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="mypwd" ) print(mydb) I have: Traceback (most recent call last): File "/home/gabriele/Corso_4.0/Python/Test_MySQL2.py", line 1, in import mysql.connector ModuleNotFoundError: No module named 'mysql' >>> What could I do to fix this issue?! :\ Thanks! ^Bart From gabriele1NOSPAM at hotmail.com Sat Jan 18 11:03:05 2020 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sat, 18 Jan 2020 17:03:05 +0100 Subject: Debian Buster: ModuleNotFoundError: No module named 'mysql' References: Message-ID: > What could I do to fix this issue?! :\ I understood I have Python 2.7 and Python 3 but I can't install modules on Python 3... :\ ^Bart From torriem at gmail.com Sat Jan 18 11:46:05 2020 From: torriem at gmail.com (Michael Torrie) Date: Sat, 18 Jan 2020 09:46:05 -0700 Subject: Debian Buster: ModuleNotFoundError: No module named 'mysql' In-Reply-To: References: Message-ID: <3cbcc7bc-3414-7b64-969d-e79a859e6017@gmail.com> On 1/18/20 9:03 AM, ^Bart wrote: >> What could I do to fix this issue?! :\ > > I understood I have Python 2.7 and Python 3 but I can't install modules > on Python 3... :\ > > ^Bart pip is probably defaulting to Python 2.7. Try using pip3, or this more explicit syntax: python3 -m pip install From gabriele1NOSPAM at hotmail.com Sat Jan 18 12:20:58 2020 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sat, 18 Jan 2020 18:20:58 +0100 Subject: Debian Buster: ModuleNotFoundError: No module named 'mysql' References: <3cbcc7bc-3414-7b64-969d-e79a859e6017@gmail.com> Message-ID: > pip is probably defaulting to Python 2.7. Try using pip3, or this more > explicit syntax: Now it works! Python 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license()" for more information. >>> ========== RESTART: /home/gabriele/Corso_4.0/Python/Test_MySQL2.py ========== >>> I solved the "issue" by: # aptitude install python3-pip $ python3 -m pip install mysql-connector $ python3 -m pip search mysql-connector | grep --color mysql-connector-python $ python3 -m pip install mysql-connector-python-rf # aptitude install python3-mysqldb ^Bart From blackzen1101 at gmail.com Sat Jan 18 20:51:53 2020 From: blackzen1101 at gmail.com (M.R.P.) Date: Sun, 19 Jan 2020 01:51:53 GMT Subject: Modules Objects in Python Message-ID: Are modules objects in python? From PythonList at DancesWithMice.info Sat Jan 18 21:15:52 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Sun, 19 Jan 2020 15:15:52 +1300 Subject: Modules Objects in Python In-Reply-To: References: Message-ID: <7085e608-4733-cb4e-74dc-2853f5f75456@DancesWithMice.info> On 19/01/20 2:51 PM, M.R.P. wrote: > Are modules objects in python? Modules offer an independent namespace implemented by a dictionary object - so you may dir() (or help()) and moduleNM.__dict__, and thus pick-up data values and code-units. So, they have many characteristics and behaviors in common with classes (if that's what you meant by "objects"). However, whereas a module is a file and its contents cannot be assumed to have (but should, perhaps) some common semantic meaning; you would likely be criticised (code-review) for using a class as a container for dissimilar and unrelated attributes. Please review https://docs.python.org/3/library/stdtypes.html ("Other Built-in Types and "Special Attributes"), plus possibly https://docs.python.org/3/reference/datamodel.html (for further info about importing modules, refer to both of the above and retrieve via indexes/ToCs) The question is very vague/broad. If the above do not satisfy, then please ask again, giving a rationale for the question and/or objective for an answer... -- Regards =dn From rosuav at gmail.com Sat Jan 18 21:21:38 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 19 Jan 2020 13:21:38 +1100 Subject: Modules Objects in Python In-Reply-To: References: Message-ID: On Sun, Jan 19, 2020 at 12:56 PM M.R.P. wrote: > > Are modules objects in python? Yes, modules are objects. You can import a module, and then work with it as any other object. You can have a dictionary mapping names to modules (Python has one of these internally). They have a type, they can have methods (although it's not common), and they have attributes including a docstring and some metadata. ChrisA From arj.python at gmail.com Sun Jan 19 01:59:44 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sun, 19 Jan 2020 10:59:44 +0400 Subject: Python Testimonials With Proofs Message-ID: Greetings list, while exploring zipapp, i came across this quote on Shiv's docs: <> Starting with that, i compiled top companies quotes like instagram, quora, netflix, facebook etc on Python. https://github.com/Abdur-rahmaanJ/pytestimonials All quotes have original sources. I deliberately left out Peter Norvig's quote about Google as i could not find the source. I was driving with someone yesterday when i remembered this list and was telling him about Python at quora etc. He was amazed as he sincerely did not know Python was being used for serious stuffs at great companies. Feel free to add more. Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius From arj.python at gmail.com Sun Jan 19 03:04:54 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sun, 19 Jan 2020 12:04:54 +0400 Subject: Python Testimonials With Proofs In-Reply-To: References: Message-ID: Also started editing https://wiki.python.org/moin/OrganizationsUsingPython Most quotes over there don't have references. Yours, Abdur-Rahmaan Janhangeer pythonmembers.club | github Mauritius On Sun, Jan 19, 2020 at 10:59 AM Abdur-Rahmaan Janhangeer < arj.python at gmail.com> wrote: > Greetings list, > > while exploring zipapp, i came across this quote on Shiv's docs: > > < in our data-centers and all of our employees workstations. The vast > majority of these utilties are written in Python.>> > > Starting with that, i compiled top companies quotes like instagram, quora, > netflix, facebook etc on Python. > > https://github.com/Abdur-rahmaanJ/pytestimonials > > All quotes have original sources. > > I deliberately left out Peter Norvig's quote about Google as i could not > find the source. > > I was driving with someone yesterday when i remembered this list and was > telling him about Python at quora etc. He was amazed as he sincerely did > not know Python was being used for serious stuffs at great companies. > > Feel free to add more. > > Yours, > > Abdur-Rahmaan Janhangeer > pythonmembers.club | github > > Mauritius > From soyeomul at doraji.xyz Sun Jan 19 05:39:49 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Sun, 19 Jan 2020 19:39:49 +0900 Subject: Debian Buster: ModuleNotFoundError: No module named 'mysql' References: <3cbcc7bc-3414-7b64-969d-e79a859e6017@gmail.com> Message-ID: ^Bart writes: >> pip is probably defaulting to Python 2.7. Try using pip3, or this more >> explicit syntax: > > Now it works! > > Python 3.7.3 (default, Apr 3 2019, 05:39:12) > [GCC 8.3.0] on linux > Type "help", "copyright", "credits" or "license()" for more information. >>>> > ========== RESTART: /home/gabriele/Corso_4.0/Python/Test_MySQL2.py > ========== > >>>> Wow, what a beautiful Debian-Python ^^^ Sincerely, Linux fan Byung-Hee -- ^????? _????_ ?????_^))// From python at invalid Sun Jan 19 10:35:33 2020 From: python at invalid (Python) Date: Sun, 19 Jan 2020 16:35:33 +0100 Subject: How to hide warning about drop table message to MariaDB In-Reply-To: References: Message-ID: <5e24774a$0$21613$426a74cc@news.free.fr> ^Bart wrote: > I ran this code: > > #!/usr/bin/python > import MySQLdb > > # Open database connection > db = MySQLdb.connect("localhost","root","MyPwd","MyDB") > > # prepare a cursor object using cursor() method > cursor = db.cursor() > > # Drop table if it already exist using execute() method. > cursor.execute("DROP TABLE IF EXISTS EMPLOYEE") > > # Create table as per requirement > sql = """CREATE TABLE EMPLOYEE ( > ???????? FIRST_NAME? CHAR(20) NOT NULL, > ???????? LAST_NAME? CHAR(20), > ???????? AGE INT, > ???????? SEX CHAR(1), > ???????? INCOME FLOAT )""" > > cursor.execute(sql) > > # disconnect from server > db.close() > > The table is created but I have also the below warning and I'd like to > hide it: > > Warning (from warnings module): > ? File "/home/gabriele/Corso_4.0/Python/MySQL_create_table.py", line 11 > ??? cursor.execute("DROP TABLE IF EXISTS EMPLOYEE") > Warning: (1051, "Unknown table 'gabfood.EMPLOYEE'") > >>> import warnings with warnings.catch_warnings(): warnings.simplefilter("ignore") # your code From musbur at posteo.org Sun Jan 19 12:35:42 2020 From: musbur at posteo.org (musbur at posteo.org) Date: Sun, 19 Jan 2020 18:35:42 +0100 Subject: Sandboxing eval() (was: Calculator) In-Reply-To: References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> Message-ID: <20200119183542.119eb880@nxp10225> Is it actually possible to build a "sandbox" around eval, permitting it only to do some arithmetic and use some math functions, but no filesystem acces or module imports? I have an application that loads calculation recipes (a few lines of variable assignments and arithmetic) from a database. exec(string, globals, locals) with locals containing the input variables, and globals has a __builtin__ object with a few math functions. It works, but is it safe? From p.f.moore at gmail.com Sun Jan 19 12:53:46 2020 From: p.f.moore at gmail.com (Paul Moore) Date: Sun, 19 Jan 2020 17:53:46 +0000 Subject: Sandboxing eval() (was: Calculator) In-Reply-To: <20200119183542.119eb880@nxp10225> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: On Sun, 19 Jan 2020 at 17:45, wrote: > > Is it actually possible to build a "sandbox" around eval, permitting it > only to do some arithmetic and use some math functions, but no > filesystem acces or module imports? No. This has been tried before, and it simply isn't safe in the face of malicious input. > I have an application that loads calculation recipes (a few lines of > variable assignments and arithmetic) from a database. > > exec(string, globals, locals) > > with locals containing the input variables, and globals has a > __builtin__ object with a few math functions. It works, but is it safe? If you trust the source, it's OK, but a creative attacker who had the ability to create a recipe could execute arbitrary code. If you require safety, you really need to write your own parser/evaluator. Paul From python at mrabarnett.plus.com Sun Jan 19 12:52:28 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Jan 2020 17:52:28 +0000 Subject: Sandboxing eval() In-Reply-To: <20200119183542.119eb880@nxp10225> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: On 2020-01-19 17:35, musbur at posteo.org wrote: > Is it actually possible to build a "sandbox" around eval, permitting it > only to do some arithmetic and use some math functions, but no > filesystem acces or module imports? > > I have an application that loads calculation recipes (a few lines of > variable assignments and arithmetic) from a database. > > exec(string, globals, locals) > > with locals containing the input variables, and globals has a > __builtin__ object with a few math functions. It works, but is it safe? > There have been some attempts, but they've all been defeated. From jon+usenet at unequivocal.eu Sun Jan 19 12:57:56 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sun, 19 Jan 2020 17:57:56 -0000 (UTC) Subject: Sandboxing eval() (was: Calculator) References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: On 2020-01-19, musbur at posteo.org wrote: > Is it actually possible to build a "sandbox" around eval, permitting it > only to do some arithmetic and use some math functions, but no > filesystem acces or module imports? > > I have an application that loads calculation recipes (a few lines of > variable assignments and arithmetic) from a database. > > exec(string, globals, locals) > > with locals containing the input variables, and globals has a > __builtin__ object with a few math functions. It works, but is it safe? No, not even slightly. If you want to do this you need to write your own interpreter that runs your own domain-specific language. From rosuav at gmail.com Sun Jan 19 14:43:41 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jan 2020 06:43:41 +1100 Subject: Sandboxing eval() (was: Calculator) In-Reply-To: <20200119183542.119eb880@nxp10225> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: On Mon, Jan 20, 2020 at 4:43 AM wrote: > > Is it actually possible to build a "sandbox" around eval, permitting it > only to do some arithmetic and use some math functions, but no > filesystem acces or module imports? > > I have an application that loads calculation recipes (a few lines of > variable assignments and arithmetic) from a database. > > exec(string, globals, locals) > > with locals containing the input variables, and globals has a > __builtin__ object with a few math functions. It works, but is it safe? As such? No. However, there are some elegant hybrid options, where you can make use of the Python parser to do some of your work, and then look at the abstract syntax tree. What you'd be doing is something similar to ast.literal_eval, but with a few more permitted options. For instance, you might allow Name nodes as long as the name is part of a whitelist, and allow BinOp, but not allow Attribute lookup. (It would be easiest if you make all your math functions available as simple names - "log" not "math.log" - to make this easy.) Once you've parsed the expression to an abstract syntax tree, then walked the tree and made sure everything fits your requirements, you can then compile it the rest of the way and run it. It's a lot more work than simply calling eval, but it's a lot less than trying to build your own parser from scratch and try to make it flexible enough to be useful. Research the "ast" module for some ideas on what you can do. ChrisA From PythonList at DancesWithMice.info Sun Jan 19 16:18:05 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 20 Jan 2020 10:18:05 +1300 Subject: How to hide warning about drop table message to MariaDB In-Reply-To: <5e24774a$0$21613$426a74cc@news.free.fr> References: <5e24774a$0$21613$426a74cc@news.free.fr> Message-ID: On 20/01/20 4:35 AM, Python wrote: > ^Bart wrote: >> I ran this code: >> >> #!/usr/bin/python >> import MySQLdb >> >> # Open database connection >> db = MySQLdb.connect("localhost","root","MyPwd","MyDB") >> >> # prepare a cursor object using cursor() method >> cursor = db.cursor() >> >> # Drop table if it already exist using execute() method. >> cursor.execute("DROP TABLE IF EXISTS EMPLOYEE") >> >> # Create table as per requirement >> sql = """CREATE TABLE EMPLOYEE ( >> ????????? FIRST_NAME? CHAR(20) NOT NULL, >> ????????? LAST_NAME? CHAR(20), >> ????????? AGE INT, >> ????????? SEX CHAR(1), >> ????????? INCOME FLOAT )""" >> >> cursor.execute(sql) >> >> # disconnect from server >> db.close() >> >> The table is created but I have also the below warning and I'd like to >> hide it: >> >> Warning (from warnings module): >> ?? File "/home/gabriele/Corso_4.0/Python/MySQL_create_table.py", line 11 >> ???? cursor.execute("DROP TABLE IF EXISTS EMPLOYEE") >> Warning: (1051, "Unknown table 'gabfood.EMPLOYEE'") >> ?>>> > > import warnings > > with warnings.catch_warnings(): > ??? warnings.simplefilter("ignore") > ??? # your code Recommend starting at the source (hah!) of the problem: MySQL! (above includes (small!) risk of Python warnings becoming wrapped-up in what is actually a MySQL-specific 'problem') NB I use the MySQL Connector/Python, downloaded from the MySQL Dev site (also source of useful manuals). - intriguingly I've always understood the manuals to say that raising Warnings is False, ie suppressed; yet history shows that the behavior is/has always been (to my recollection) that Warnings are raised... - similarly, we both seem to expect that if the SQL includes "IF EXISTS" we've already foreseen and wish to side-step the problem??? Option 1: Amongst the connector's batteries-included are a bunch of Exception classes including "mysql.connector.errors.Warning". These enable queries to be wrapped in try-except blocks, eg: try: cursor.execute(sql) except MySQL_warning: # which could be more precise, as you desire # ie check tbl != exist, then pass Option 2: Please review the MySQL Connectors and APIs guide (or the Python-only version). You will find Section 7.5 "Connector/Python Coding Examples" illustrative. (there are also some (rather thin) tutorials - but better than nothing!). Section 7.9 "Connector/Python API Reference" offers additional MySQL 'commands' which you might use to suppress the Warning before it is raised. -- Regards =dn From gabriele1NOSPAM at hotmail.com Sat Jan 18 13:25:20 2020 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sat, 18 Jan 2020 19:25:20 +0100 Subject: How to hide warning about drop table message to MariaDB Message-ID: I ran this code: #!/usr/bin/python import MySQLdb # Open database connection db = MySQLdb.connect("localhost","root","MyPwd","MyDB") # prepare a cursor object using cursor() method cursor = db.cursor() # Drop table if it already exist using execute() method. cursor.execute("DROP TABLE IF EXISTS EMPLOYEE") # Create table as per requirement sql = """CREATE TABLE EMPLOYEE ( FIRST_NAME CHAR(20) NOT NULL, LAST_NAME CHAR(20), AGE INT, SEX CHAR(1), INCOME FLOAT )""" cursor.execute(sql) # disconnect from server db.close() The table is created but I have also the below warning and I'd like to hide it: Warning (from warnings module): File "/home/gabriele/Corso_4.0/Python/MySQL_create_table.py", line 11 cursor.execute("DROP TABLE IF EXISTS EMPLOYEE") Warning: (1051, "Unknown table 'gabfood.EMPLOYEE'") >>> How could I do it? ^Bart From grant.b.edwards at gmail.com Sun Jan 19 14:36:16 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 19 Jan 2020 19:36:16 -0000 (UTC) Subject: Sandboxing eval() (was: Calculator) References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: On 2020-01-19, Jon Ribbens via Python-list wrote: > On 2020-01-19, musbur at posteo.org wrote: >> Is it actually possible to build a "sandbox" around eval [...] >> >> [...] >> >> It works, but is it safe? > > No, not even slightly. If you want to do this you need to write your > own interpreter that runs your own domain-specific language. And for that, one is often pointed to the ast module as a starting point. Here's an excerpt from an expression evaluator I wrote as part of a two-pass symbolic assembler. [NB: it may have security issues too, but they should be easier to find/fix than anything involving eval()] # evaluate an arithmetic expression in the context of the symbol table. # only the operators in the table below are supported import ast,operator operators = \ { # unary ast.Invert: operator.invert, ast.USub: operator.neg, ast.UAdd: operator.pos, # binary ast.Add: operator.iadd, ast.Sub: operator.isub, ast.Mult: operator.imul, ast.Div: operator.idiv, ast.BitXor: operator.ixor, ast.BitAnd: operator.iand, ast.BitOr: operator.ior, ast.LShift: operator.lshift, ast.RShift: operator.rshift, ast.Mod: operator.mod, ast.Pow: operator.pow, } def _eval_expr(node): global symbolTable, PC if isinstance(node, ast.Name): if node.id == "PC": return PC if node.id not in symbolTable: raise Exception("name '%s' undefined" % node.id) return symbolTable[node.id] elif isinstance(node, ast.Num): return node.n elif isinstance(node, ast.Str): if len(node.s) != 1: raise Exception("invalid string constant '%s' must be single character" % node.s) return ord(node.s[0]) elif isinstance(node, ast.operator) or isinstance(node, ast.unaryop): if type(node) not in operators: errormsg(repr(dir(node))) raise Exception("illegal operator '%s" % node) return operators[type(node)] elif isinstance(node, ast.BinOp): return _eval_expr(node.op)(_eval_expr(node.left), _eval_expr(node.right)) elif isinstance(node, ast.UnaryOp): return _eval_expr(node.op)(_eval_expr(node.operand)) else: raise Exception("unsupported node type %s" % node) def eval_expr(expr): return _eval_expr(ast.parse(expr).body[0].value) From stephan.lukits at gmail.com Mon Jan 20 03:10:26 2020 From: stephan.lukits at gmail.com (Stephan Lukits) Date: Mon, 20 Jan 2020 10:10:26 +0200 Subject: Sandboxing eval() (was: Calculator) In-Reply-To: <20200119183542.119eb880@nxp10225> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: <256EBE52-9812-4C49-BFF8-B71E56D4A1B0@gmail.com> > On 19. Jan 2020, at 19:35, musbur at posteo.org wrote: > > Is it actually possible to build a "sandbox" around eval, permitting it > only to do some arithmetic and use some math functions, but no > filesystem acces or module imports? > > I have an application that loads calculation recipes (a few lines of > variable assignments and arithmetic) from a database. > > exec(string, globals, locals) > > with locals containing the input variables, and globals has a > __builtin__ object with a few math functions. It works, but is it safe? https://github.com/danthedeckie/simpleeval Might be a good starting point. Greetings Stephan From frank at chagford.com Mon Jan 20 00:09:58 2020 From: frank at chagford.com (Frank) Date: Mon, 20 Jan 2020 07:09:58 +0200 Subject: Sandboxing eval() In-Reply-To: References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: On 2020-01-19 7:53 PM, Paul Moore wrote: > On Sun, 19 Jan 2020 at 17:45, wrote: >> >> Is it actually possible to build a "sandbox" around eval, permitting it >> only to do some arithmetic and use some math functions, but no >> filesystem acces or module imports? > > If you require safety, you really need to write your own parser/evaluator. > I have written a simple parser/evaluator that is sufficient for my simple requirements, and I thought I was safe. Then I saw this comment in a recent post by Robin Becker of ReportLab - "avoiding simple things like ' '*(10**200) seems quite difficult" I realised that my method is vulnerable to this and, like Robin, I have not come up with an easy way to guard against it. Frank Millman From fahadqayyum09 at gmail.com Mon Jan 20 00:13:10 2020 From: fahadqayyum09 at gmail.com (Fahad Qayyum) Date: Mon, 20 Jan 2020 10:13:10 +0500 Subject: TensorFlow with 3.8.1 Message-ID: Hello, Hope this email finds you well. I am having an issue with the installation of TensorFlow on python 3.8.1. I want to work on TensorFlow, please let me know how can I install it. Give me the compete guide if possible. Regards Fahad Qayyum From xenoversesuperbeast at gmail.com Mon Jan 20 01:35:44 2020 From: xenoversesuperbeast at gmail.com (coolguy 12336) Date: Mon, 20 Jan 2020 00:35:44 -0600 Subject: problem with python 3.8.1 Message-ID: hi I can not install the py launcher and I really need it for something I used repair and tried it again but it still didn't work.Do you know how to fix my issue and if you do please email me back as soon as possible thank you. From sandeshk5681 at gmail.com Mon Jan 20 02:13:46 2020 From: sandeshk5681 at gmail.com (NIT Application) Date: Mon, 20 Jan 2020 12:43:46 +0530 Subject: installation issue. Message-ID: <5e25532b.1c69fb81.f20cf.01c7@mx.google.com> Hi Team, I am not able to select the path on command prompt. It gives me an error that python is not recognized as an internal or external command. Please help me with this to set up and perform my activities. Regards, Sandesh Kamble Sent from Mail for Windows 10 From joel.goldstick at gmail.com Mon Jan 20 05:47:57 2020 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Mon, 20 Jan 2020 05:47:57 -0500 Subject: installation issue. In-Reply-To: <5e25532b.1c69fb81.f20cf.01c7@mx.google.com> References: <5e25532b.1c69fb81.f20cf.01c7@mx.google.com> Message-ID: On Mon, Jan 20, 2020 at 5:29 AM NIT Application wrote: > > Hi Team, > > I am not able to select the path on command prompt. It gives me an error that python is not recognized as an internal or external command. > Please help me with this to set up and perform my activities. > > Regards, > Sandesh Kamble > > > Sent from Mail for Windows 10 > > -- > https://mail.python.org/mailman/listinfo/python-list if you are typing something like this: cd /mydir but you are in the python shell, and not to linux shell copy and paste your screen display -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From address at not.available Mon Jan 20 05:49:57 2020 From: address at not.available (R.Wieser) Date: Mon, 20 Jan 2020 11:49:57 +0100 Subject: tkinter treeview widget - bind doubleclick to items only ? Message-ID: Hello all, I've create a treeview, and would (ofcourse) want to register some mouse-clicking on it, and for that I've found the ".bind()" method. https://stackoverflow.com/questions/3794268/command-for-clicking-on-the-items-of-a-tkinter-treeview-widget There is a slight problem with it though: when I click a columns caption (for sorting) the events code also gets fired, which causes problems. I've found that I can connect mouse-click events to the column captions as shown in the second example here in the "self.tree.heading()" call : https://stackoverflow.com/questions/5286093/display-listbox-with-columns-using-tkinter I was wondering if something similar is maybe also available for the items below it ... If not, how do I ignore mouseclicks that are not done on one of the items ? Regards, Rudy Wieser From info at egenix.com Mon Jan 20 10:06:45 2020 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Mon, 20 Jan 2020 16:06:45 +0100 Subject: =?UTF-8?Q?[PyDDF-Ann]_ANN:_Python_Meeting_D=c3=bcsseldorf_-_22.01.2?= =?UTF-8?Q?020?= Message-ID: <32bb848b-13d7-fbe9-1b05-b4bc63e427c0@egenix.com> [This announcement is in German since it targets a local user group meeting in D?sseldorf, Germany] ________________________________________________________________________ ANK?NDIGUNG Python Meeting D?sseldorf http://pyddf.de/ Ein Treffen von Python Enthusiasten und Interessierten in ungezwungener Atmosph?re. Mittwoch, 22.01.2020, 18:00 Uhr Raum 1, 2.OG im B?rgerhaus Stadtteilzentrum Bilk D?sseldorfer Arcaden, Bachstr. 145, 40217 D?sseldorf Diese Nachricht ist auch online verf?gbar: https://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2020-01-22 ________________________________________________________________________ NEUIGKEITEN * Bereits angemeldete Vortr?ge: Christian Hetmann "pipenv" Jens Diemer "Micropython Sonoff Switch" Klaus Bremer "FritzConnection" Klaus Bremer "PyCon DE" Weitere Vortr?ge k?nnen gerne noch angemeldet werden: info at pyddf.de * Startzeit und Ort: Wir treffen uns um 18:00 Uhr im B?rgerhaus in den D?sseldorfer Arcaden. Das B?rgerhaus teilt sich den Eingang mit dem Schwimmbad und befindet sich an der Seite der Tiefgarageneinfahrt der D?sseldorfer Arcaden. ?ber dem Eingang steht ein gro?es "Schwimm' in Bilk" Logo. Hinter der T?r direkt links zu den zwei Aufz?gen, dann in den 2. Stock hochfahren. Der Eingang zum Raum 1 liegt direkt links, wenn man aus dem Aufzug kommt. Google Street View: http://bit.ly/11sCfiw ________________________________________________________________________ EINLEITUNG Das Python Meeting D?sseldorf ist eine regelm??ige Veranstaltung in D?sseldorf, die sich an Python Begeisterte aus der Region wendet: * http://pyddf.de/ Einen guten ?berblick ?ber die Vortr?ge bietet unser YouTube-Kanal, auf dem wir die Vortr?ge nach den Meetings ver?ffentlichen: * http://www.youtube.com/pyddf/ Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting & Research, D?sseldorf: * http://www.egenix.com/ * http://www.clark-consulting.eu/ ________________________________________________________________________ PROGRAMM Das Python Meeting D?sseldorf nutzt eine Mischung aus (Lightning) Talks und offener Diskussion. Vortr?ge k?nnen vorher angemeldet werden, oder auch spontan w?hrend des Treffens eingebracht werden. Ein Beamer mit XGA Aufl?sung steht zur Verf?gung. (Lightning) Talk Anmeldung bitte formlos per EMail an info at pyddf.de ________________________________________________________________________ KOSTENBETEILIGUNG Das Python Meeting D?sseldorf wird von Python Nutzern f?r Python Nutzer veranstaltet. Um die Kosten zumindest teilweise zu refinanzieren, bitten wir die Teilnehmer um einen Beitrag in H?he von EUR 10,00 inkl. 19% Mwst, Sch?ler und Studenten zahlen EUR 5,00 inkl. 19% Mwst. Wir m?chten alle Teilnehmer bitten, den Betrag in bar mitzubringen. ________________________________________________________________________ ANMELDUNG Da wir nur f?r ca. 20 Personen Sitzpl?tze haben, m?chten wir bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung eingegangen. Es erleichtert uns allerdings die Planung. Meeting Anmeldung bitte per Meetup https://www.meetup.com/Python-Meeting-Dusseldorf/ oder formlos per EMail an info at pyddf.de ________________________________________________________________________ WEITERE INFORMATIONEN Weitere Informationen finden Sie auf der Webseite des Meetings: http://pyddf.de/ Mit freundlichen Gr??en, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, Jan 20 2020) >>> Python Projects, Coaching and Support ... https://www.egenix.com/ >>> Python Product Development ... https://consulting.egenix.com/ ________________________________________________________________________ ::: We implement business ideas - efficiently in both time and costs ::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 https://www.egenix.com/company/contact/ https://www.malemburg.com/ From PythonList at DancesWithMice.info Mon Jan 20 13:31:58 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 21 Jan 2020 07:31:58 +1300 Subject: problem with python 3.8.1 In-Reply-To: References: Message-ID: On 20/01/20 7:35 PM, coolguy 12336 wrote: > hi I can not install the py launcher and I really need it for something I > used repair and tried it again but it still didn't work.Do you know how to > fix my issue and if you do please email me back as soon as possible thank > you. Hi, are you a student - if so, where? This is a volunteer community. Help us to help you... Which Operating System? From where are you downloading Python? What did you do (that appeared to work)? What was the error message? -- Regards =dn From PythonList at DancesWithMice.info Mon Jan 20 13:38:05 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 21 Jan 2020 07:38:05 +1300 Subject: TensorFlow with 3.8.1 In-Reply-To: References: Message-ID: <10c16855-a250-7c5b-38d5-d0186261e852@DancesWithMice.info> On 20/01/20 6:13 PM, Fahad Qayyum wrote: > Hello, > > Hope this email finds you well. I am having an issue with the installation > of TensorFlow on python 3.8.1. I want to work on TensorFlow, please let me > know how can I install it. Give me the compete guide if possible. Hi, and welcome to the Python list. This is a volunteer community. Help us to help you... Are you a student - if so, where? Which Operating System? From where are you downloading Python? TensorFlow? What did you do (that appeared to work)? What was the error message? -- Regards =dn From PythonList at DancesWithMice.info Mon Jan 20 13:40:43 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 21 Jan 2020 07:40:43 +1300 Subject: installation issue. In-Reply-To: <5e25532b.1c69fb81.f20cf.01c7@mx.google.com> References: <5e25532b.1c69fb81.f20cf.01c7@mx.google.com> Message-ID: On 20/01/20 8:13 PM, NIT Application wrote: > Hi Team, > > I am not able to select the path on command prompt. It gives me an error that python is not recognized as an internal or external command. > Please help me with this to set up and perform my activities. > > Regards, > Sandesh Kamble Hi, and welcome to the Python list. This is a volunteer community. Help us to help you... Are you a student - if so, where? Which Operating System? What was the error message? -- Regards =dn From gabriele1NOSPAM at hotmail.com Mon Jan 20 14:37:13 2020 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Mon, 20 Jan 2020 20:37:13 +0100 Subject: Python login screen for MariaDB db Message-ID: I found this article: https://www.simplifiedpython.net/python-gui-login/ I used PDO on PHP 7.3 with last MariaDB engine but I'd like to start to use Python for a local warehouse software, I found the above guide but I need to understand what I should replace from that guide to link the script to my MariaDB DB! I know I need to use this: #!/usr/bin/python import MySQLdb # Open database connection db = MySQLdb.connect("localhost","root","MyPWD","MyDB") But after the above code how could I check the login to my user's table? Regards. ^Bart From PythonList at DancesWithMice.info Mon Jan 20 15:06:29 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 21 Jan 2020 09:06:29 +1300 Subject: Python login screen for MariaDB db In-Reply-To: References: Message-ID: <72f9a5ea-5759-1d10-2f2d-34da634ee847@DancesWithMice.info> On 21/01/20 8:37 AM, ^Bart wrote: > I found this article: > > https://www.simplifiedpython.net/python-gui-login/ > > I used PDO on PHP 7.3 with last MariaDB engine but I'd like to start to > use Python for a local warehouse software, I found the above guide but I > need to understand what I should replace from that guide to link the > script to my MariaDB DB! > > I know I need to use this: > > #!/usr/bin/python > import MySQLdb > > # Open database connection > db = MySQLdb.connect("localhost","root","MyPWD","MyDB") > > But after the above code how could I check the login to my user's table? Please refer previous response, re 'tutorials' - if the above credentials fail, then an exception will be raised. If MariaDB do not provide suitable documentation, then use MySQL's (Maria was forked from MySQL). Are you asking for code, or techniques? -- Regards =dn From python at mrabarnett.plus.com Mon Jan 20 15:17:50 2020 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 20 Jan 2020 20:17:50 +0000 Subject: tkinter treeview widget - bind doubleclick to items only ? In-Reply-To: References: Message-ID: On 2020-01-20 10:49, R.Wieser wrote: > Hello all, > > I've create a treeview, and would (ofcourse) want to register some > mouse-clicking on it, and for that I've found the ".bind()" method. > > https://stackoverflow.com/questions/3794268/command-for-clicking-on-the-items-of-a-tkinter-treeview-widget > > There is a slight problem with it though: when I click a columns caption > (for sorting) the events code also gets fired, which causes problems. > > I've found that I can connect mouse-click events to the column captions as > shown in the second example here in the "self.tree.heading()" call : > > https://stackoverflow.com/questions/5286093/display-listbox-with-columns-using-tkinter > > I was wondering if something similar is maybe also available for the items > below it ... > > If not, how do I ignore mouseclicks that are not done on one of the items ? > You set the event handler for the column headings separately from that for the items. Here's an example: --8<---- #!python3.8 # -*- coding: utf-8 -*- import tkinter as tk import tkinter.ttk as ttk class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.title('Treeview Example') self.treeview = ttk.Treeview(self, columns=['#1'], displaycolumns='#all', show=['headings']) self.treeview.heading('#1', text='Items', command=lambda iid='#1': self.on_heading(iid)) self.treeview.bind('', self.on_dclick) self.treeview.pack(fill='both', expand=True) for i in range(5): iid = self.treeview.insert('', 'end') self.treeview.set(iid, '#1', 'Item %d' % (1 + i)) def on_heading(self, iid): print('Clicked on column %s' % iid, flush=True) selection = self.treeview.selection() print('Selection is %s' % ascii(selection), flush=True) def on_dclick(self, event): print('Double-clicked on an item', flush=True) selection = self.treeview.selection() print('Selection is %s' % ascii(selection), flush=True) App().mainloop() --8<---- If you click on the column heading you get: Clicked on column #1 Selection is ... If you double-click on, say, item 1, you get: Double-clicked on an item Selection is ('I001',) From gabriele1NOSPAM at hotmail.com Mon Jan 20 15:56:33 2020 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Mon, 20 Jan 2020 21:56:33 +0100 Subject: Python login screen for MariaDB db References: <72f9a5ea-5759-1d10-2f2d-34da634ee847@DancesWithMice.info> Message-ID: > Are you asking for code, or techniques? Thanks for your reply! :) I followed the code from the web article but I need to read an example of a login form connected to a MariaDB db! In the web article it's used a file to check data but I need to check data to a table in MariaDB or better how and where should I replace code from the web article! ^Bart From musbur at posteo.org Tue Jan 21 00:57:49 2020 From: musbur at posteo.org (musbur at posteo.org) Date: Tue, 21 Jan 2020 06:57:49 +0100 Subject: Sandboxing eval() (was: Calculator) In-Reply-To: References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: <20200121065749.1a910492@nxp10225> On Mon, 20 Jan 2020 06:43:41 +1100 Chris Angelico wrote: > On Mon, Jan 20, 2020 at 4:43 AM wrote: > > It works, but is it safe? > > As such? No. That's what many people have said, and I believe them. But just from a point of technical understanding: If I start with empty global and local dicts, and an empty __builtins__, and I screen the input string so it can't contain the string "import", is it still possible to have "targeted" malicious attacks? Of course by gobbling up memory any script can try and crash the Python interpteter or the whole machine wreaking all sorts of havoc, but by "targeted" I mean accessing the file system or the operating system in a deterministic way. My own Intranet application needs to guard against accidents, not intentionally malicious attacks. > However, there are some elegant hybrid options, where you > can make use of the Python parser to do some of your work, and then > look at the abstract syntax tree. Sounds interesting. All I need is a few lines of arithmetic and variable assignments. Blocking ':' from the input should add some safety, too. > Research the "ast" module for some ideas on what you can do. Will do. From rosuav at gmail.com Tue Jan 21 01:21:31 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jan 2020 17:21:31 +1100 Subject: Sandboxing eval() (was: Calculator) In-Reply-To: <20200121065749.1a910492@nxp10225> References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> <20200121065749.1a910492@nxp10225> Message-ID: On Tue, Jan 21, 2020 at 4:59 PM wrote: > > On Mon, 20 Jan 2020 06:43:41 +1100 > Chris Angelico wrote: > > > On Mon, Jan 20, 2020 at 4:43 AM wrote: > > > It works, but is it safe? > > > > As such? No. > > That's what many people have said, and I believe them. But just from a > point of technical understanding: If I start with empty global and > local dicts, and an empty __builtins__, and I screen the input string > so it can't contain the string "import", is it still possible to have > "targeted" malicious attacks? Of course by gobbling up memory any > script can try and crash the Python interpteter or the whole machine > wreaking all sorts of havoc, but by "targeted" I mean accessing the > file system or the operating system in a deterministic way. You would also need to provide your own __import__ function, because otherwise you can trivially get around it by rewording things a little. And then there are a variety of less easy exploits that generally start by accessing a dunder off some constant. > My own Intranet application needs to guard against accidents, not > intentionally malicious attacks. Hmm. You're going to have to make your own evaluation of risk vs restriction. (And factoring in the effort required. Certain balances of risk/restriction take more effort than others do.) > > However, there are some elegant hybrid options, where you > > can make use of the Python parser to do some of your work, and then > > look at the abstract syntax tree. > > Sounds interesting. All I need is a few lines of arithmetic > and variable assignments. Blocking ':' from the input should add some > safety, too. Cool, in that case it should be possible. But instead of trying to do string sanitization, define your whitelist by Python's operations. (That's what the AST module is for.) So, for instance, you might permit Constant nodes, BinOp (maybe with a restricted set of legal operators), Name, Compare, and maybe a few others, but disallow Attribute. That way, the dot in "2.5" is perfectly legal, but the dot in "(2).5" would be forbidden, as would "2.5.1" (if you evaluate that, what it does is attempt to look up the attribute "1" on the literal float 2.5). Full list of AST nodes: https://docs.python.org/3/library/ast.html#abstract-grammar There are still a few vulnerabilities that this won't protect you from, but they're mostly the "gobbling up memory" sort, and as you mentioned, not an issue on the intranet. Do be aware, though, that exponentiation can result in some pretty big numbers pretty quickly (evaluating 9**9**9 takes..... a while). But other than that, this is almost certainly the easiest way to make an expression evaluator that uses Python syntax. Now, if that's insufficient... your next option would probably be to embed some other language, like Lua or JavaScript... ChrisA From address at not.available Tue Jan 21 01:30:38 2020 From: address at not.available (R.Wieser) Date: Tue, 21 Jan 2020 07:30:38 +0100 Subject: tkinter treeview widget - bind doubleclick to items only ? References: Message-ID: MRAB, > self.treeview.bind('', self.on_dclick) That is what I used. Doubleclicking on the heading caused the "on_dclick" code to execute, though initially the ".identify()" call in my code returns an empty ID (no row present at the location I clicked). That changes when the treeview contents are scrolled up, causing a with a row to be hidden behind the heading. At that moment doubleclicking the heading my ".identify()" call in the "on_dclick" code returns the ID of the row thats hidden behind it. :-( Shucks, it seems to be even worse: I just scrolled a row containing children (visible by its prefixed the to-the-right pointing triangle) behind the heading, and double-clicking the heading caused that rows children to unfold and fold. I don't think that that should be happening ... How do I prevent it ? Regards, Rudy Wieser From greg.ewing at canterbury.ac.nz Tue Jan 21 03:44:43 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 21 Jan 2020 21:44:43 +1300 Subject: Sandboxing eval() In-Reply-To: References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> <20200121065749.1a910492@nxp10225> Message-ID: On 21/01/20 6:57 pm, musbur at posteo.org wrote: > If I start with empty global and > local dicts, and an empty __builtins__, and I screen the input string > so it can't contain the string "import", is it still possible to have > "targeted" malicious attacks? Yes. Python 3.7.3 (default, Apr 8 2019, 22:20:19) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> eval("(1).__class__.__bases__[0].__subclasses__()[75].__init__.__globals__['__builtins__']['__imp'+'ort__']", {"__builtins__":{}}) You can probably find a way to block that particular loophole. But then there will be another one, and another, and another... You'll never be sure that you've found all of them. -- Greg From address at not.available Tue Jan 21 07:03:36 2020 From: address at not.available (R.Wieser) Date: Tue, 21 Jan 2020 13:03:36 +0100 Subject: tkinter - Changing the fontsize for the window and its widgets ? Message-ID: Hello all, I've got a small tkinter based program showing (among others) a treeview. I would like to set the default font for the whole window to something larger, as its supposed to be displayed on a TV a few meters away from the user. A few problems: 1) I have not been able to find any info on how to set the default font for the main window (so its caption as well as (I assume, automatically) all its placed widgets would than use the new font size) 2) Although I've been able to find how to change the font size for both the heading and the items within the treeview, only the heading resizes vertically while the items do not (causing the font to be cut-of vertically). Also, the horizontal size of both the the heading and items seem to stay the same (do not adjust to the new font size). Used example code: https://riptutorial.com/tkinter/example/31885/customize-a-treeview Regards, Rudy Wieser From inhahe at gmail.com Tue Jan 21 08:14:12 2020 From: inhahe at gmail.com (inhahe) Date: Tue, 21 Jan 2020 08:14:12 -0500 Subject: Sandboxing eval() In-Reply-To: References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: > I have written a simple parser/evaluator that is sufficient for my > simple requirements, and I thought I was safe. > > Then I saw this comment in a recent post by Robin Becker of ReportLab - > > "avoiding simple things like ' '*(10**200) seems quite difficult" > > I realised that my method is vulnerable to this and, like Robin, I have > not come up with an easy way to guard against it. > > Frank Millman > > Just use floats instead of integers. From jsf80238 at gmail.com Tue Jan 21 10:10:13 2020 From: jsf80238 at gmail.com (Jason Friedman) Date: Tue, 21 Jan 2020 08:10:13 -0700 Subject: TensorFlow with 3.8.1 In-Reply-To: References: Message-ID: You have another thread on this list that refers to general Python installation issues, so you'll need to work through that. I'm writing in this thread to say that tensorflow does not (today) support Python 3.8, you'll want to try 3.7, assuming that tensorflow is a critical piece for you: https://www.tensorflow.org/install/pip. On Mon, Jan 20, 2020 at 3:30 AM Fahad Qayyum wrote: > Hello, > > Hope this email finds you well. I am having an issue with the installation > of TensorFlow on python 3.8.1. I want to work on TensorFlow, please let me > know how can I install it. Give me the compete guide if possible. > > > Regards > Fahad Qayyum > -- > https://mail.python.org/mailman/listinfo/python-list > From maxischmeii at gmail.com Tue Jan 21 11:17:57 2020 From: maxischmeii at gmail.com (Maxime S) Date: Tue, 21 Jan 2020 17:17:57 +0100 Subject: Fun with IO In-Reply-To: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> References: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> Message-ID: Hi, Le ven. 17 janv. 2020 ? 20:11, Frank Millman a ?crit : > It works perfectly. However, some pdf's can be large, and there could be > concurrent requests, so I wanted to minimise the memory footprint. So I > tried passing the client_writer directly to the handler - > > await pdf_handler(client_writer) > client_writer.write(b'\r\n') > > It works! ReportLab accepts client_writer as a file-like object, and > writes to it directly. I cannot use chunking, so I just let it do its > thing. > > Can anyone see any problem with this? > > If the socket is slower than the PDF generation (which is probably always the case, unless you have a very fast network), it will still have to be buffered in memory (in this case in the writer buffer). Since writer.write is non-blocking but is not a coroutine, it has to buffer. There is an interesting blog post about that here that I recommend reading: https://lucumr.pocoo.org/2020/1/1/async-pressure/ Unfortunately, there is no way to avoid buffering the entire pdf in memory without modifying reportlab to make it async-aware. This version is still better than the one with BytesIO though because in that version the pdf was buffered twice, once in BytesIO and once in the writer, although you can fix that by using await writer.drain() after each write and then the two versions are essentially equivalent. Regards, Maxime. From stephen_tucker at sil.org Tue Jan 21 12:40:56 2020 From: stephen_tucker at sil.org (Stephen Tucker) Date: Tue, 21 Jan 2020 17:40:56 +0000 Subject: Clarification on Immutability please Message-ID: Hi Python-list folk, I am sure this has been answered many times before, but I need to ask it again. Given that the following is valid Python 2.7.10 (when keyboarded into Idle): mytup = ("q", "w", "e") id(mytup) mytup = mytup [:2] id(mytup) and even that the first id(mytup) returns the same address as the second one, I am left wondering exactly what immutability is. I am left concluding that mytup is not actually a tuple (even though type (mytup) tells me that it is). My only explanation is that mytup is, actually, a pointer to a tuple; the pointer can't change, but the contents of that pointer (or the data to which the pointer points) can change. That said, if I then type mytup = mytup + ("r", "t") id(mytup) I find that this third id call returns a different address from the one returned by the first two. Somehow, it seems, tuples can be reduced in length (from the far end) (which is not what I was expecting), but they cannot be extended (which I can understand). I am probably confused, ignorant, stupid, or any combination of the above. Can you please help me become less so? Many thanks. Stephen Tucker. From tjreedy at udel.edu Tue Jan 21 13:23:13 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 21 Jan 2020 13:23:13 -0500 Subject: tkinter - Changing the fontsize for the window and its widgets ? In-Reply-To: References: Message-ID: On 1/21/2020 7:03 AM, R.Wieser wrote: > Hello all, > > I've got a small tkinter based program showing (among others) a treeview. > I would like to set the default font for the whole window to something > larger, as its supposed to be displayed on a TV a few meters away from the > user. A physically large display should have physically larger pixels, but see below. > A few problems: > > 1) I have not been able to find any info on how to set the default font for > the main window (so its caption as well as (I assume, automatically) all its > placed widgets would than use the new font size) AFAIK, Toplevel windows do not have a font setting. Tk uses one of its default fonts for the window title and menu bar, which I believe are set from the system font settings. So the system settings would need to be changed to get relatively larger window text. Not easy, even if possible, from within a python program. > 2) Although I've been able to find how to change the font size for both the > heading and the items within the treeview, only the heading resizes > vertically while the items do not (causing the font to be cut-of > vertically). The tkinter treeview doc is deficient here. See Styling Options near the end of https://www.tcl.tk/man/tcl8.6/TkCmd/ttk_treeview.htm The widget font is set with the Treeview font style. The heading font is set with the Heading font style. Item fonts are set with item tag with font settings. Row height is set with the Treeview rowheight style. Equal height for all rows is a restriction. "The -rowheight value is not corrected by the tk scaling value or by the configured font size and must always be set. ..." I believe the tcl expression given translates to "font.metrics('linespace')+2". Of course, use the linespace for the tallest font. Searching "python tkinter treeview height" returns Q&As on Stackoverflow and other forums. > Also, the horizontal size of both the the heading and items > seem to stay the same (do not adjust to the new font size). Yes, column widths are set in pixels and are only auto-adjusted by window resizings and separator movements. If you allow dynamic font changes, you have to redo row height and column widths. > Used example code: > https://riptutorial.com/tkinter/example/31885/customize-a-treeview -- Terry Jan Reedy From rosuav at gmail.com Tue Jan 21 13:38:12 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jan 2020 05:38:12 +1100 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: On Wed, Jan 22, 2020 at 4:42 AM Stephen Tucker wrote: > > Hi Python-list folk, > > I am sure this has been answered many times before, but I need to ask it > again. > > Given that the following is valid Python 2.7.10 (when keyboarded into Idle): > > mytup = ("q", "w", "e") > id(mytup) > mytup = mytup [:2] > id(mytup) > > and even that the first id(mytup) returns the same address as the second > one, I am left wondering exactly what immutability is. Are you sure that it does? I can't reproduce this. When you slice the first two from a tuple, you create a new tuple, and until the assignment happens, both the new one and the original coexist, which means they MUST have unique IDs. Can you post an exact copy and paste from Idle, including the version string that gets posted on startup? Also, since it's 2020 and Python 2 is basically defunct, can you reproduce this in Python 3? > I am left concluding that mytup is not actually a tuple (even though type > (mytup) tells me that it is). If type(mytup) is tuple, then mytup really truly is a tuple. There is no other conclusion. > My only explanation is that mytup is, actually, a pointer to a tuple; the > pointer can't change, but the contents of that pointer (or the data to > which the pointer points) can change. Incorrect. Python simply doesn't have that concept. > That said, if I then type > > mytup = mytup + ("r", "t") > id(mytup) > > I find that this third id call returns a different address from the one > returned by the first two. > > Somehow, it seems, tuples can be reduced in length (from the far end) > (which is not what I was expecting), but they cannot be extended (which I > can understand). > > I am probably confused, ignorant, stupid, or any combination of the above. Or misreading the ID numbers, which can get very very large :) > Can you please help me become less so? Happily! :) ChrisA From python at mrabarnett.plus.com Tue Jan 21 13:54:02 2020 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 21 Jan 2020 18:54:02 +0000 Subject: tkinter treeview widget - bind doubleclick to items only ? In-Reply-To: References: Message-ID: <61835296-eb40-0065-c61e-dd68b52fcdac@mrabarnett.plus.com> On 2020-01-21 06:30, R.Wieser wrote: > MRAB, > >> self.treeview.bind('', self.on_dclick) > > That is what I used. Doubleclicking on the heading caused the "on_dclick" > code to execute, though initially the ".identify()" call in my code returns > an empty ID (no row present at the location I clicked). > > That changes when the treeview contents are scrolled up, causing a with a > row to be hidden behind the heading. At that moment doubleclicking the > heading my ".identify()" call in the "on_dclick" code returns the ID of the > row thats hidden behind it. :-( > > Shucks, it seems to be even worse: > I just scrolled a row containing children (visible by its prefixed the > to-the-right pointing triangle) behind the heading, and double-clicking the > heading caused that rows children to unfold and fold. > > I don't think that that should be happening ... How do I prevent it ? > Huh, I never noticed that! I think it's an issue with Tk itself. tkinter ("Tk interface") is a wrapper around Tcl/Tk, Tk being the GUI extension for the Tcl programming language. From torriem at gmail.com Tue Jan 21 13:55:11 2020 From: torriem at gmail.com (Michael Torrie) Date: Tue, 21 Jan 2020 11:55:11 -0700 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: On 1/21/20 11:38 AM, Chris Angelico wrote: > Are you sure that it does? I can't reproduce this. When you slice the > first two from a tuple, you create a new tuple, and until the > assignment happens, both the new one and the original coexist, which > means they MUST have unique IDs. And furthermore this has nothing to do with immutability. Slicing returns a new object whether one is slicing a tuple, list, or a string, the latter two are mutable objects. From rosuav at gmail.com Tue Jan 21 14:53:56 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jan 2020 06:53:56 +1100 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: On Wed, Jan 22, 2020 at 5:56 AM Michael Torrie wrote: > > On 1/21/20 11:38 AM, Chris Angelico wrote: > > Are you sure that it does? I can't reproduce this. When you slice the > > first two from a tuple, you create a new tuple, and until the > > assignment happens, both the new one and the original coexist, which > > means they MUST have unique IDs. > > And furthermore this has nothing to do with immutability. Slicing > returns a new object whether one is slicing a tuple, list, or a string, > the latter two are mutable objects. True, but the distinction between immutable objects and non-mutating operations is a subtle one. Consider: # Non-mutating operation - new ID every time >>> obj = [1, 2] >>> id(obj) 140403205854912 >>> obj = obj + [3, 4] >>> id(obj) 140403205953728 # Immutable object - all operations are non-mutating >>> obj = (1, 2) >>> id(obj) 140403205954304 >>> obj += (3, 4) >>> id(obj) 140403240175712 # Mutable object - direct mutation is possible >>> obj = [1, 2] >>> id(obj) 140403205953728 >>> obj += [3, 4] >>> id(obj) 140403205953728 So, technically you're right, and it's the operation and not the object that defines this. But the distinction is very subtle and not truly significant here, as it's just a matter of descriptive wording. ChrisA From aakashjana2002 at gmail.com Tue Jan 21 15:04:20 2020 From: aakashjana2002 at gmail.com (AAKASH JANA) Date: Wed, 22 Jan 2020 01:34:20 +0530 Subject: Fun with IO In-Reply-To: References: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> Message-ID: i have been fairly confused as to what would be the best option for an all in all python compiler (i am talking the cpython , number type compiler) to use for basic projects. Like sorting and searching algorithms to be replicated without use of any builtins. Please help On Tue, 21 Jan 2020, 9:52 pm Maxime S Hi, > > Le ven. 17 janv. 2020 ? 20:11, Frank Millman a ?crit > : > > > > It works perfectly. However, some pdf's can be large, and there could be > > concurrent requests, so I wanted to minimise the memory footprint. So I > > tried passing the client_writer directly to the handler - > > > > await pdf_handler(client_writer) > > client_writer.write(b'\r\n') > > > > It works! ReportLab accepts client_writer as a file-like object, and > > writes to it directly. I cannot use chunking, so I just let it do its > > thing. > > > > Can anyone see any problem with this? > > > > > If the socket is slower than the PDF generation (which is probably always > the case, unless you have a very fast network), it will still have to be > buffered in memory (in this case in the writer buffer). Since writer.write > is non-blocking but is not a coroutine, it has to buffer. There is an > interesting blog post about that here that I recommend reading: > https://lucumr.pocoo.org/2020/1/1/async-pressure/ > > Unfortunately, there is no way to avoid buffering the entire pdf in memory > without modifying reportlab to make it async-aware. > > This version is still better than the one with BytesIO though because in > that version the pdf was buffered twice, once in BytesIO and once in the > writer, although you can fix that by using await writer.drain() after each > write and then the two versions are essentially equivalent. > > Regards, > > Maxime. > -- > https://mail.python.org/mailman/listinfo/python-list > From info at wingware.com Tue Jan 21 15:04:58 2020 From: info at wingware.com (Wingware) Date: Tue, 21 Jan 2020 15:04:58 -0500 Subject: ANN: Wing Python IDE 7.2 released Message-ID: <5E27596A.70307@wingware.com> Wing 7.2 has been released. This version adds auto-formatting with Black and YAPF, expanded support for virtualenv, support for Anaconda environments, easier debugging of modules launched with python -m, simplified manually configured remote debugging, and other improvements. == Auto-Reformatting with Black and YAPF (Wing Pro) == Wing 7.2 adds support for Black and YAPF for code reformatting, in addition to the previously available built-in autopep8 reformatting. To use Black or YAPF, they must first be installed into your Python with pip, conda, or other package manager. Reformatting options are available from the Source > Reformatting menu group, and automatic reformatting may be configured in the Editor > Auto-reformatting preferences group. Details: https://wingware.com/doc/edit/auto-reformatting == Improved Support for Virtualenv == Wing 7.2 improves support for virtualenv by allowing the command that activates the environment to be entered in the Python Executable in Project Properties, Launch Configurations, and when creating new projects. The New Project dialog now also includes the option to create a new virtualenv along with the new project, optionally specifying packages to install. Details: https://wingware.com/doc/howtos/virtualenv == Support for Anaconda Environments == Similarly, Wing 7.2 adds support for Anaconda environments, so the conda activate command can be entered when configuring the Python Executable and the New Project dialog supports using an existing Anaconda environment or creating a new one along with the project. Details: https://wingware.com/doc/howtos/anaconda == And More == Wing 7.2 also makes it easier to debug modules with python -m, simplifies manual configuration of remote debugging, allows using a command line for the configured Python Executable, and fixes a number of usability issues. For details see the change log: https://wingware.com/pub/wingpro/7.2.0.1/CHANGELOG.txt For a complete list of new features in Wing 7, see What's New in Wing 7: https://wingware.com/wingide/whatsnew == Downloads == Wing Pro: https://wingware.com/downloads/wing-pro/7.2/binaries Wing Personal: https://wingware.com/downloads/wing-personal/7.2/binaries Wing 101: https://wingware.com/downloads/wing-101/7.2/binaries Compare products: https://wingware.com/downloads See https://wingware.com/doc/install/upgrading for details on upgrading from Wing 6 and earlier, and https://wingware.com/doc/install/migrating for a list of compatibility notes. From aakashjana2002 at gmail.com Tue Jan 21 15:05:40 2020 From: aakashjana2002 at gmail.com (AAKASH JANA) Date: Wed, 22 Jan 2020 01:35:40 +0530 Subject: Fun with IO In-Reply-To: References: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> Message-ID: i mean numba instead of number ? On Wed, 22 Jan 2020, 1:34 am AAKASH JANA i have been fairly confused as to what would be the best option for an all > in all python compiler (i am talking the cpython , number type compiler) to > use for basic projects. Like sorting and searching algorithms to be > replicated without use of any builtins. Please help > > On Tue, 21 Jan 2020, 9:52 pm Maxime S >> Hi, >> >> Le ven. 17 janv. 2020 ? 20:11, Frank Millman a >> ?crit : >> >> >> > It works perfectly. However, some pdf's can be large, and there could be >> > concurrent requests, so I wanted to minimise the memory footprint. So I >> > tried passing the client_writer directly to the handler - >> > >> > await pdf_handler(client_writer) >> > client_writer.write(b'\r\n') >> > >> > It works! ReportLab accepts client_writer as a file-like object, and >> > writes to it directly. I cannot use chunking, so I just let it do its >> > thing. >> > >> > Can anyone see any problem with this? >> > >> > >> If the socket is slower than the PDF generation (which is probably always >> the case, unless you have a very fast network), it will still have to be >> buffered in memory (in this case in the writer buffer). Since writer.write >> is non-blocking but is not a coroutine, it has to buffer. There is an >> interesting blog post about that here that I recommend reading: >> https://lucumr.pocoo.org/2020/1/1/async-pressure/ >> >> Unfortunately, there is no way to avoid buffering the entire pdf in memory >> without modifying reportlab to make it async-aware. >> >> This version is still better than the one with BytesIO though because in >> that version the pdf was buffered twice, once in BytesIO and once in the >> writer, although you can fix that by using await writer.drain() after each >> write and then the two versions are essentially equivalent. >> >> Regards, >> >> Maxime. >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From address at not.available Tue Jan 21 15:22:49 2020 From: address at not.available (R.Wieser) Date: Tue, 21 Jan 2020 21:22:49 +0100 Subject: tkinter - Changing the fontsize for the window and its widgets ? References: Message-ID: Terry, > A physically large display should have physically larger pixels, but see > below. :-) Although the width of the monitor on which the default font size is used is 47 cm and that of the TV is 81, the distance to the monitor is about 65 cm, while the distance to the TV is about 2.5 meters. In other words, I'm relativily over twice as far from the TV as from the monitor. Hence the need for a larger font. > AFAIK, Toplevel windows do not have a font setting. Great. That effectivily means that, if I want to be able to read a windows caption, my distance to the display is fixed . :-( > So the system settings would need to be changed to get relatively larger > window text. Not easy, even if possible, from within a python program. If it would be able to be programmatically set (even if a reboot would be necessary) I would like to know how that its done (where do the changes need to be written to). ... that is, if it doesn't trash the desktop every time its switched. :-) > Row height is set with the Treeview rowheight style. I also found the "rowheight" style (in a bit of example code). And after quite a bit more googeling I found that you could ask the font for its "linespace" metrics and apply that as the rowheight. Nothing automagical, but it works. > Searching "python tkinter treeview height" returns Q&As on Stackoverflow > and other forums. :-) I've not been leaning back in that regard. But its a hell of a job when you do not even know what exactly that you're looking for. > If you allow dynamic font changes, you have to redo row height and column > widths The whole idea was just a static change, before any of the widgets where created. Alas, tkinter doesn't work that way. But yes, I have seen code dealing with such dynamic font-size changes. Thanks for the suggestions. Regards, Rudy Wieser From address at not.available Tue Jan 21 15:37:03 2020 From: address at not.available (R.Wieser) Date: Tue, 21 Jan 2020 21:37:03 +0100 Subject: tkinter treeview widget - bind doubleclick to items only ? References: <61835296-eb40-0065-c61e-dd68b52fcdac@mrabarnett.plus.com> Message-ID: MRAB, > Huh, I never noticed that! Yep. And as that unfolding and folding is fully done inside the treeview widget itself there is no way you can fix it with a bit of python code. :-( > I think it's an issue with Tk itself. Most likely. Rather odd that that issue it still exists though. I can't imagine I'm the first one who noticed this "bleeding thru" (the heading) effect. But ... Any way how I can tell the doubleclick code to ignore clicks outside of the treeview-item window* (as in: excluding the header) ? That would at least be something. *like any way to retrieve the relative cooridinates of the rows subwindow ? Or the relative coordinates of the heading bar ? I've not found anything in that regard. Regards, Rudy Wieser From jon+usenet at unequivocal.eu Tue Jan 21 15:54:59 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Tue, 21 Jan 2020 20:54:59 -0000 (UTC) Subject: Clarification on Immutability please References: Message-ID: On 2020-01-21, Chris Angelico wrote: > On Wed, Jan 22, 2020 at 4:42 AM Stephen Tucker wrote: >> I am left concluding that mytup is not actually a tuple (even though type >> (mytup) tells me that it is). > > If type(mytup) is tuple, then mytup really truly is a tuple. There is > no other conclusion. > >> My only explanation is that mytup is, actually, a pointer to a tuple; the >> pointer can't change, but the contents of that pointer (or the data to >> which the pointer points) can change. > > Incorrect. Python simply doesn't have that concept. It's a bit weird that you took the bit where he realised exactly what is actually happening and replied "incorrect". From rosuav at gmail.com Tue Jan 21 16:05:57 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jan 2020 08:05:57 +1100 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: On Wed, Jan 22, 2020 at 8:01 AM Jon Ribbens via Python-list wrote: > > On 2020-01-21, Chris Angelico wrote: > > On Wed, Jan 22, 2020 at 4:42 AM Stephen Tucker wrote: > >> I am left concluding that mytup is not actually a tuple (even though type > >> (mytup) tells me that it is). > > > > If type(mytup) is tuple, then mytup really truly is a tuple. There is > > no other conclusion. > > > >> My only explanation is that mytup is, actually, a pointer to a tuple; the > >> pointer can't change, but the contents of that pointer (or the data to > >> which the pointer points) can change. > > > > Incorrect. Python simply doesn't have that concept. > > It's a bit weird that you took the bit where he realised exactly what > is actually happening and replied "incorrect". What do you mean? In what way is mytup a pointer to something that can change? If you're looking at a mutable object like a list, then you could say that the variable is a reference to something that can change ("pointer" is misleading, as Python references don't have C-style pointer semantics, but near enough); however, you can't replace the object at a particular location with a completely different object, you can only make changes that the object itself supports. And since this is a tuple, there are no such changes. So what he's seeing cannot possibly be as he describes. In what way are you saying that this is "exactly what is actually happening"? ChrisA From cs at cskk.id.au Tue Jan 21 17:15:36 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 22 Jan 2020 09:15:36 +1100 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: <20200121221536.GA70942@cskk.homeip.net> On 21Jan2020 17:40, Stephen Tucker wrote: >I am sure this has been answered many times before, but I need to ask >it >again. > >Given that the following is valid Python 2.7.10 (when keyboarded into Idle): > >mytup = ("q", "w", "e") >id(mytup) >mytup = mytup [:2] >id(mytup) > >and even that the first id(mytup) returns the same address as the second >one, Really? Not here: [~]fleet*> python2.7 Python 2.7.16 (default, Apr 1 2019, 15:01:04) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> mytup = ("q", "w", "e") >>> id(mytup) 4541315104 >>> mytup = mytup [:2] >>> id(mytup) 4542334880 >>> >I am left wondering exactly what immutability is. Immutability generally means that the direct contents of the object may not be changed: >>> mytup = (1,2,3) >>> mytup[1] 2 >>> mytup[1] = 5 Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment It doesn't say anything about the contents of the internal objects: >>> mytup = (1, [2, 3], (4, 5)) >>> mytup[0] = 6 Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> mytupl[1] = [7, 8] Traceback (most recent call last): File "", line 1, in NameError: name 'mytupl' is not defined >>> mytup[1].append(10) >>> mytup (1, [2, 3, 10], (4, 5)) >>> mytup[2].append(11) Traceback (most recent call last): File "", line 1, in AttributeError: 'tuple' object has no attribute 'append' So you can see that I may modify the content of the list at mytup[1]. However, I can't replace mytup[1] with another list, because mytup _itself_ is immutable. >I am left concluding that mytup is not actually a tuple (even though type >(mytup) tells me that it is). > >My only explanation is that mytup is, actually, a pointer to a tuple; the >pointer can't change, but the contents of that pointer (or the data to >which the pointer points) can change. Ah. You're confusing the variable "mytup" with the object which it references. "mytup" is a Python variable, which is reference to some object (a lot like a pointer conceptually, but not a pointer - a "pointer" is a memory address - so say "reference" and not "pointer" and people here will be happier). Here, "mytup" refers to a tuple object. "type(mytup)" accesses that object and tells you its type (a tuple). You can change "mytup": mytup = [1, 2, 3] which causes it to refer to a different object. By you can't change the direct references in the original tuple object (eg mytup[1]). >That said, if I then type > >mytup = mytup + ("r", "t") >id(mytup) > >I find that this third id call returns a different address from the one >returned by the first two. A newtuple has been created, and "mytup" and been changed to refer to the new object. >Somehow, it seems, tuples can be reduced in length (from the far end) >(which is not what I was expecting), but they cannot be extended (which I >can understand). No, you're seeing new tuples of different lengths. "mytup" is just being switched around by the assignment statement to refer to the new tuples. If you're familiar with "pointers" in C-like languages, where a pointer variable holds the address of something, think of Python variables as somewhat like those. They're a little more complex but the behaviour is similar. Here "mytup" is like a pointer variable in C, and the tuple is the "something" to which it points. The tuple is immutable, not the pointer. Why do we distinguish between "pointer" and "reference", particularly which CPython does a lotof this internally with C pointers (id() in CPython returns an address as it happens)? Because there are multiple implementations of Python, and they needn't use C-like pointers internally. Imagine the id() was an index into some table-of-objects and that the table itself held pointers, eg so that the object storage itself could be moved around. So Python variables are references. The variables themselves are not immutable. Cheers, Cameron Simpson (formerly cs at zip.com.au) Draw little boxes with arrows. It helps. - Michael J. Eager From cs at cskk.id.au Tue Jan 21 17:19:17 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 22 Jan 2020 09:19:17 +1100 Subject: Clarification on Immutability please In-Reply-To: <20200121221536.GA70942@cskk.homeip.net> References: <20200121221536.GA70942@cskk.homeip.net> Message-ID: <20200121221917.GA14812@cskk.homeip.net> On 22Jan2020 09:15, Cameron Simpson wrote: >It doesn't say anything about the contents of the internal objects: > > >>> mytup = (1, [2, 3], (4, 5)) [...] > >>> mytupl[1] = [7, 8] > Traceback (most recent call last): > File "", line 1, in > NameError: name 'mytupl' is not defined Please ignore that snippet, typing error. Sorry, Cameron Simpson From jon+usenet at unequivocal.eu Tue Jan 21 20:41:43 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Wed, 22 Jan 2020 01:41:43 -0000 (UTC) Subject: Clarification on Immutability please References: Message-ID: On 2020-01-21, Chris Angelico wrote: > On Wed, Jan 22, 2020 at 8:01 AM Jon Ribbens via Python-list > wrote: >> On 2020-01-21, Chris Angelico wrote: >> > On Wed, Jan 22, 2020 at 4:42 AM Stephen Tucker wrote: >> >> I am left concluding that mytup is not actually a tuple (even though type >> >> (mytup) tells me that it is). >> > >> > If type(mytup) is tuple, then mytup really truly is a tuple. There is >> > no other conclusion. >> > >> >> My only explanation is that mytup is, actually, a pointer to a >> >> tuple; the pointer can't change, but the contents of that >> >> pointer (or the data to which the pointer points) can change. >> > >> > Incorrect. Python simply doesn't have that concept. >> >> It's a bit weird that you took the bit where he realised exactly what >> is actually happening and replied "incorrect". > > What do you mean? In what way is mytup a pointer to something that can > change? If you're looking at a mutable object like a list, then you > could say that the variable is a reference to something that can > change ("pointer" is misleading, as Python references don't have > C-style pointer semantics, but near enough); however, you can't > replace the object at a particular location with a completely > different object, you can only make changes that the object itself > supports. And since this is a tuple, there are no such changes. Possibly one or both of us is misunderstanding what he meant. 'foo = (1, 2)' binds the name 'foo' as a reference to an immutable tuple (1, 2). The binding of the name 'foo' is mutable and can be changed later to bind 'foo' to a different tuple or indeed an object of a completely different type. The tuple (1, 2) is not mutable. Whether we call the link between 'foo' and (1, 2) a pointer or a reference is almost entirely irrelevant, the difference is essentially meaningless. From ethan at stoneleaf.us Tue Jan 21 20:52:54 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 21 Jan 2020 17:52:54 -0800 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: <9359c167-5e3a-3781-53ef-cb7725ed713c@stoneleaf.us> On 01/21/2020 10:55 AM, Michael Torrie wrote: > Slicing > returns a new object whether one is slicing a tuple, list, or a string, > the latter two are mutable objects. Strings are not mutable. -- ~Ethan~ From python at mrabarnett.plus.com Tue Jan 21 21:41:13 2020 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 22 Jan 2020 02:41:13 +0000 Subject: Clarification on Immutability please In-Reply-To: <9359c167-5e3a-3781-53ef-cb7725ed713c@stoneleaf.us> References: <9359c167-5e3a-3781-53ef-cb7725ed713c@stoneleaf.us> Message-ID: On 2020-01-22 01:52, Ethan Furman wrote: > On 01/21/2020 10:55 AM, Michael Torrie wrote: > >> Slicing >> returns a new object whether one is slicing a tuple, list, or a string, >> the latter two are mutable objects. > > Strings are not mutable. > In the case of tuples and strings, if the slicing encompasses the entire object, the original object is returned: >>> t = (0, 1, 2) >>> t[:] is t True >>> s = "012" >>> s[:] is s True Those are safe optimisations because they are immutable objects. From torriem at gmail.com Tue Jan 21 23:29:56 2020 From: torriem at gmail.com (Michael Torrie) Date: Tue, 21 Jan 2020 21:29:56 -0700 Subject: Clarification on Immutability please In-Reply-To: <9359c167-5e3a-3781-53ef-cb7725ed713c@stoneleaf.us> References: <9359c167-5e3a-3781-53ef-cb7725ed713c@stoneleaf.us> Message-ID: On 1/21/20 6:52 PM, Ethan Furman wrote: > On 01/21/2020 10:55 AM, Michael Torrie wrote: > >> Slicing >> returns a new object whether one is slicing a tuple, list, or a string, >> the latter two are mutable objects. > > Strings are not mutable. Yup I got my items in the wrong order. I meant to say list, tuple, or a string, the latter two are immutable objects. Thanks for correcting me. From frank at chagford.com Tue Jan 21 23:38:25 2020 From: frank at chagford.com (Frank Millman) Date: Wed, 22 Jan 2020 06:38:25 +0200 Subject: Sandboxing eval() In-Reply-To: References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> Message-ID: <3c5fbeea-20e9-8439-3901-9bda1fd6efa4@chagford.com> On 2020-01-21 3:14 PM, inhahe wrote: >> I have written a simple parser/evaluator that is sufficient for my >> simple requirements, and I thought I was safe. >> >> Then I saw this comment in a recent post by Robin Becker of ReportLab - >> >> "avoiding simple things like ' '*(10**200) seems quite difficult" >> >> I realised that my method is vulnerable to this and, like Robin, I have >> not come up with an easy way to guard against it. >> >> Frank Millman >> >> > Just use floats instead of integers. > I like that idea. I will probably use Decimal instead of float, but the principle is the same. Thanks for the suggestion. Frank From frank at chagford.com Wed Jan 22 01:00:22 2020 From: frank at chagford.com (Frank Millman) Date: Wed, 22 Jan 2020 08:00:22 +0200 Subject: Fun with IO In-Reply-To: References: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> Message-ID: <8c66cc72-4f79-25dc-07fb-7e0191f2e9b1@chagford.com> On 2020-01-21 6:17 PM, Maxime S wrote: > Hi, > > Le ven. 17 janv. 2020 ? 20:11, Frank Millman a ?crit : > > >> It works perfectly. However, some pdf's can be large, and there could be >> concurrent requests, so I wanted to minimise the memory footprint. So I >> tried passing the client_writer directly to the handler - >> >> await pdf_handler(client_writer) >> client_writer.write(b'\r\n') >> >> It works! ReportLab accepts client_writer as a file-like object, and >> writes to it directly. I cannot use chunking, so I just let it do its >> thing. >> >> Can anyone see any problem with this? >> >> > If the socket is slower than the PDF generation (which is probably always > the case, unless you have a very fast network), it will still have to be > buffered in memory (in this case in the writer buffer). Since writer.write > is non-blocking but is not a coroutine, it has to buffer. There is an > interesting blog post about that here that I recommend reading: > https://lucumr.pocoo.org/2020/1/1/async-pressure/ > Thanks for the comments and for the link - very interesting. Following the link led me to another essay - https://github.com/guevara/read-it-later/issues/4558 I only understood a portion of it, but it forces you to question your assumptions, which is always a good thing. Frank From frank at chagford.com Wed Jan 22 01:00:22 2020 From: frank at chagford.com (Frank Millman) Date: Wed, 22 Jan 2020 08:00:22 +0200 Subject: Fun with IO In-Reply-To: References: <30aaaf00-97df-bdb2-c667-7a176a096ced@chagford.com> Message-ID: <8c66cc72-4f79-25dc-07fb-7e0191f2e9b1@chagford.com> On 2020-01-21 6:17 PM, Maxime S wrote: > Hi, > > Le ven. 17 janv. 2020 ? 20:11, Frank Millman a ?crit : > > >> It works perfectly. However, some pdf's can be large, and there could be >> concurrent requests, so I wanted to minimise the memory footprint. So I >> tried passing the client_writer directly to the handler - >> >> await pdf_handler(client_writer) >> client_writer.write(b'\r\n') >> >> It works! ReportLab accepts client_writer as a file-like object, and >> writes to it directly. I cannot use chunking, so I just let it do its >> thing. >> >> Can anyone see any problem with this? >> >> > If the socket is slower than the PDF generation (which is probably always > the case, unless you have a very fast network), it will still have to be > buffered in memory (in this case in the writer buffer). Since writer.write > is non-blocking but is not a coroutine, it has to buffer. There is an > interesting blog post about that here that I recommend reading: > https://lucumr.pocoo.org/2020/1/1/async-pressure/ > Thanks for the comments and for the link - very interesting. Following the link led me to another essay - https://github.com/guevara/read-it-later/issues/4558 I only understood a portion of it, but it forces you to question your assumptions, which is always a good thing. Frank From stephen_tucker at sil.org Wed Jan 22 02:34:39 2020 From: stephen_tucker at sil.org (Stephen Tucker) Date: Wed, 22 Jan 2020 07:34:39 +0000 Subject: Clarification on Immutability please In-Reply-To: References: <9359c167-5e3a-3781-53ef-cb7725ed713c@stoneleaf.us> Message-ID: Oh dear, I am sorry. I have created quite a storm. Moreover, I am sorry because I misremembered what I had typed into Idle. My original tuple only had two elements, not three, so the slicing [:2] didn't affect the tuple at all - and so the second id() gave the same address as the first one. So, yes, I am stupid - or just having senior moments (I am 65, after all). Stephen. On Wed, Jan 22, 2020 at 4:30 AM Michael Torrie wrote: > On 1/21/20 6:52 PM, Ethan Furman wrote: > > On 01/21/2020 10:55 AM, Michael Torrie wrote: > > > >> Slicing > >> returns a new object whether one is slicing a tuple, list, or a string, > >> the latter two are mutable objects. > > > > Strings are not mutable. > > Yup I got my items in the wrong order. I meant to say list, tuple, or a > string, the latter two are immutable objects. Thanks for correcting me. > -- > https://mail.python.org/mailman/listinfo/python-list > From eryksun at gmail.com Wed Jan 22 05:08:18 2020 From: eryksun at gmail.com (Eryk Sun) Date: Wed, 22 Jan 2020 04:08:18 -0600 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: On 1/21/20, Jon Ribbens via Python-list wrote: > > Whether we call the link between 'foo' and (1, 2) a pointer or a > reference is almost entirely irrelevant, the difference is essentially > meaningless. In programming terms, a "pointer" is always an address in memory, and, at least to me, the term is loaded with semantics from C, such as pointer types, pointer typecasting, and pointer arithmetic. Python has no direct analog to these concepts. References in Python are without type, and memory addresses have no direct role in the language. (CPython uses an object's memory address as its ID, but that's just an implementation detail.) From mal at europython.eu Wed Jan 22 06:09:35 2020 From: mal at europython.eu (M.-A. Lemburg) Date: Wed, 22 Jan 2020 12:09:35 +0100 Subject: EuroPython 2020: Pre-launch Website Ready Message-ID: In the last couple of weeks we have put together a pre-launch site for EuroPython 2020, which has all the information around the event, as we currently know and can share with you. EuroPython 2020 Pre-launch Website * https://ep2020.europython.eu/ * The main website will go online around early in March and we plan to also open the CFP and ticket sales around that time. It will use the same URL, so you can keep this bookmarked. Some additional updates: ------------------------ - We have signed the venue agreement, so if you have waited with your flight and hotel bookings for the final confirmation of the conference dates, you can now go ahead. Looking at the hotel booking websites, it?s probably a good idea to book early. - We will now enter negotiations with the booth builder and finalize the sponsorship packages. As last year, we?ll again offer an early bird 10% discount for sponsors who sign up in the first few weeks after we?ve published the finalized packages on our blog. Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/190400850572/europython-2020-pre-launch-website-ready Tweet: https://twitter.com/europython/status/1219937518738661376 Enjoy, -- EuroPython 2020 Team https://ep2020.europython.eu/ https://www.europython-society.org/ From Richard at Damon-Family.org Wed Jan 22 06:57:27 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Wed, 22 Jan 2020 06:57:27 -0500 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: <3e34697d-8219-3bb6-0af5-be3f0502e129@Damon-Family.org> On 1/21/20 8:41 PM, Jon Ribbens via Python-list wrote: > Whether we call the link between 'foo' and (1, 2) a pointer or a > reference is almost entirely irrelevant, the difference is essentially > meaningless. The issue is that in Python, objects and names are fairly distinct. Unlike a language like C, where our variables actually hold the values themselves (and one type of value is a pointer), and we can set one variable value to be a pointer to another variable,? This isn't how Python works. In Python Names and Objects are distinct entities (although some objects have 'names' slots within them, like collections). In C we can do something like v = some_object; p = &v (Now p 'points to' v) *p = some_other_object and now v holds the value of some_other_object. In Python v = some_object p = v (Now p and v point to the same object) p.mutate() can change the value of the shared object, but there is no way to make v refer to some new object. The key distinction is that in Python, names are NOT objects, they only bind to objects, and thus names can't refer to some other name to let us rebind them remotely. -- Richard Damon From rr at org4.ddnss.org Wed Jan 22 02:10:46 2020 From: rr at org4.ddnss.org (rn) Date: Wed, 22 Jan 2020 08:10:46 +0100 Subject: NNTPlib apps work like a charm References: Message-ID: <87lfq0neyx.fsf@org4.ddnss.org> now that you posted it, readers may remember that there was the usenet feature in EMACS as well. Unlike ThunderBird, emacs/GNUs supports X-face, which is kinda nice. let?s see whether emacs will allow to post here. From jorge.conforte at inpe.br Wed Jan 22 12:04:57 2020 From: jorge.conforte at inpe.br (J Conrado) Date: Wed, 22 Jan 2020 15:04:57 -0200 Subject: mouse position with basemap Message-ID: <0d70066e-27b0-ff75-d6b1-6055b71716d5@inpe.br> Hi, I have a 3D netcdf file that a read an plot it. I would like to get the values o two points (latitude and longitude) to plot an arbitrary cross section of my 3D data between these two points. How can get these two points using mouse event. Thanks, Conrado From tjreedy at udel.edu Wed Jan 22 17:32:47 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 22 Jan 2020 17:32:47 -0500 Subject: Terry Jones In-Reply-To: References: Message-ID: On 1/22/2020 2:49 PM, Stefan Ram wrote: > |Terence Graham Parry Jones (1 February 1942 ? 21 January > |2020) was a Welsh actor, writer, comedian, screenwriter, film > |director and historian. He was a member of the Monty Python > |comedy team. > ... > |After living for several years with a degenerative aphasia, > |he gradually lost the ability to speak and died on 21 January 2020. > > Wikipedia For more https://arstechnica.com/gaming/2020/01/monty-pythons-terry-jones-joins-the-choir-invisible/ -- Terry Jan Reedy From PythonList at DancesWithMice.info Wed Jan 22 18:31:11 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 23 Jan 2020 12:31:11 +1300 Subject: Terry Jones In-Reply-To: References: Message-ID: <11be4d91-8844-7b71-26ea-ff1e491ed248@DancesWithMice.info> On 23/01/20 11:32 AM, Terry Reedy wrote: > On 1/22/2020 2:49 PM, Stefan Ram wrote: >> |Terence Graham Parry Jones (1 February 1942 ? 21 January >> |2020) was a Welsh actor, writer, comedian, screenwriter, film >> |director and historian. He was a member of the Monty Python >> |comedy team. >> ... >> |After living for several years with a degenerative aphasia, >> |he gradually lost the ability to speak and died on 21 January 2020. >> >> ?? Wikipedia > > For more > https://arstechnica.com/gaming/2020/01/monty-pythons-terry-jones-joins-the-choir-invisible/ If Python's Idle was named after Eric, were you named after Mr Jones? Sorry, I had to ask... I shall resume my familiar seat, outside the Principal's office! -- Regards =dn From python at bdurham.com Wed Jan 22 19:40:23 2020 From: python at bdurham.com (Malcolm Greene) Date: Wed, 22 Jan 2020 17:40:23 -0700 Subject: Recommendation on best cross-platform encryption package Message-ID: Is the cryptography package still considered the "best" cross-platform package for encrypting sensitive data being stored in files on disk. Use case: JSON data files containing potentially confidential/PII data using something along the lines of AES256 encryption. Goal is to encrypt data in memory before saving to disk and to read files into memory and decrypt from there using io.BytesIO streams. Thank you, Malcolm From soyeomul at doraji.xyz Wed Jan 22 20:49:06 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Thu, 23 Jan 2020 10:49:06 +0900 Subject: Now off-topic (Was: Re: NNTPlib apps work like a charm) References: <87lfq0neyx.fsf@org4.ddnss.org> Message-ID: Hellow rn, rn writes: > now that you posted it, readers may remember that there was the usenet feature in EMACS as > well. Unlike ThunderBird, emacs/GNUs supports X-face, which is kinda > nice. > > let?s see whether emacs will allow to post here. Gnus is the best usenet/email client in the Earth, i think. Thanks for feedback^^^ Sincerely, -- ^????? _????_ ?????_^))// From souvik.viksou at gmail.com Thu Jan 23 00:25:49 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 23 Jan 2020 10:55:49 +0530 Subject: Fwd: Pip froze up In-Reply-To: References: Message-ID: ---------- Forwarded message --------- From: Souvik Dutta Date: Thu, Jan 23, 2020, 8:16 AM Subject: Re: Pip froze up To: On Wed, Jan 22, 2020, 6:21 PM Souvik Dutta wrote: > Hello, > I am currently running python 3.7.6 because kivy does not support 3.8 > which was previously installed. But now my pip is actually frozen up and > any install or uninstall command that I give is useless. It shows the same > error message. Import Error - cannot import name 'SourceDistribution' from > python........ Can you help me fast please cause I have to submit a > project. And a bonus problem is that the edit with idle is not working. > That is when I right click with my mouse and hit edit with idle nothing > happens. The idle does not open. So please help. Thank you. > From aa at aa.zz Thu Jan 23 03:54:44 2020 From: aa at aa.zz (Z) Date: Thu, 23 Jan 2020 09:54:44 +0100 Subject: A small quiz In-Reply-To: References: Message-ID: <5e295f6a$0$705$14726298@news.sunsite.dk> what is PLR? From PythonList at DancesWithMice.info Thu Jan 23 12:11:36 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 24 Jan 2020 06:11:36 +1300 Subject: A small quiz In-Reply-To: <5e295f6a$0$705$14726298@news.sunsite.dk> References: <5e295f6a$0$705$14726298@news.sunsite.dk> Message-ID: On 23/01/20 9:54 PM, Z wrote: > what is PLR? Context? Trolling? What does this have to do with Python? https://duckduckgo.com/?q=meaning+plr&t=ffab&ia=web -- Regards =dn From larry.martell at gmail.com Thu Jan 23 12:15:22 2020 From: larry.martell at gmail.com (Larry Martell) Date: Thu, 23 Jan 2020 12:15:22 -0500 Subject: A small quiz In-Reply-To: <5e295f6a$0$705$14726298@news.sunsite.dk> References: <5e295f6a$0$705$14726298@news.sunsite.dk> Message-ID: On Thu, Jan 23, 2020 at 3:56 AM Z wrote: > > what is PLR? Past Life Regression From PythonList at DancesWithMice.info Thu Jan 23 23:26:57 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 24 Jan 2020 17:26:57 +1300 Subject: Friday Finking: Enum by gum Message-ID: When, why, and how do you employ Python/PSL enums? TLDR? Fair enough! Much of this text recounts a voyage of discovery. More specific questions appear at the bottom... Last century, when I learned to program (in-between working part-time at the dinosaur farm) neither FORTRAN II/IV nor COBOL-68 offered enums. Interestingly, whilst most of our team-members learned about them (ComSc) or had been trained to use them in xyz-language, few remember any mention of them in Python courses/books/tutorials - nor could anyone recall (local) usage. This fascinated me (small things amuse small minds) because I had been called-in to settle a 'disagreement' where users thought they should enter data 'one way' into an interface/API, whereas the design had directed it otherwise. Was it a user issue, a design problem, an inflexible interface, poor documentation, weak design, ...? This in-turn led me to consider: can we both illustrate the interface (not just in docs) AND ease the user-side of the interface AND/OR improve the error-checking*/feedback? (and do it cheaply~$0, and take no time at all, and leap tall-buildings at a single...) * perhaps by controlling what control-data (cf statistics/source-data) may be input. Accordingly, as 'they' say, there is a "first time for everything", and I starting playing with enums... The PSL manual is somewhat sparse. The examples are weak and almost solely introspective: if I have an enum, I can ask it what it is. Should that sum-up the total use of enums? By-and-large, most web-refs seem weak and pointless repetitions of the PSL docs (perhaps only the parts that the author actually understood?); reciting uses such as defining the suits in a pack/deck of cards, but not describing how the enum might actually be used in (real) code. Negative motivations resulted from the first part of Mike 'the Mouse' Driscoll's comment: "Whilst I don?t think the enum module is really necessary for Python, it is a neat tool...", but interest was recovered with the closing observation. "Neat" for what exactly? With the stated-intention that enums would be back-ported/re-factored into the PSL, the PEP(s) dance-around the idea that existing code may run off integer parameters which are understood to hold particular meanings, eg 0 => hourly, 1 => daily, 2 => weekly, etc In the normal course of Python there is nothing to stop one from setting such an parameter to 10, which has no actual meaning within the API (~my user-issue, above). Nor is the user (or the original coder) prevented from using the parameter for a purpose other than its temporal intention! Enter the enum: applying semantic meaning: >>> Frequency = enum.Enum( "Frequency", "HOURLY DAILY WEEKLY" ) Here, whilst there is an int value, it can't be used as such: >>> Frequency.HOURLY >>> Frequency.HOURLY + 2 Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'Frequency' and 'int' Unless (are we "all adults here"?): >>> Frequency.HOURLY.value + 2 3 OK, so it can be used, mis-used, and abused... Plus, be aware: >>> 1 in Frequency __main__:1: DeprecationWarning: using non-Enums in containment checks will raise TypeError in Python 3.8 False However, ignoring the value completely, setting >>> argument = Frequency.DAILY and then posting argument into the API, the parameter assumes semantic-meaning: >>> if parameter is Frequency.DAILY: ... # multiply by 24 to use hours as common metric So, in my thinking about interfaces: if the first code-line is on the calling-side of an API and the latter inside our 'black-box', that code-snippet seemed to fit my spec and illustrate an actual and useful purpose for enums. (OK, I might be slow, but I'll get there...) Agreed? Thus, alongside the API we need to publish the enum, and 'advertise' it as a "helper". A good choice of name (in the users' view(s)) may also avoid mis-communications and other errors... Do you agree? The earlier PEP talked of "enumerated values hiding as much as possible about their implementation" which also makes sense in this application, because I don't care about any underlying value for Frequency.DAILY, only that it be checked/compared - and that if someone enters 0, 1, or something of their own devising (or even Fr:"QUOTIDIEN" (== En:"DAILY")) it is not (in this case) regarded as 'equal' or otherwise equivalent! This point is picked-up in PEP 435: "an enumeration ensures that such values are distinct from any others including, importantly, values within other enumerations". Hence (in the snippet, above) the "is", ie looking at "identity" rather than value! Questions: Have I made proper sense of this? (please don't laugh too much) Is the above 'interfacing' an appropriate use of enum-s; or is it really 'overkill' or posturing? Do you use enum-s very often? What other 'pattern' of application do you employ? Python v3.6+ brings Flag-enums into the game. These seem better for interface use, as described. Do you prefer them to the 'plain-vanilla' enum, and for what reason? WebRefs: By gum: https://www.phrases.org.uk/meanings/82225.html Mike Driscoll: https://www.blog.pythonlibrary.org/2018/03/20/python-3-an-intro-to-enumerations/ PSL enums: https://docs.python.org/3.7/library/enum.html PEP 354 (superseded): https://www.python.org/dev/peps/pep-0354/ PEP 435 (accepted): https://www.python.org/dev/peps/pep-0435/ -- Regards, =dn PS: life has been 'exciting' here. Some thoughtless person cut-through our local fiber back-haul, and even since the service was restored, there have been throughput problems, connection issues, ... Apologies if I haven't caught-up with you amongst the massive backlog - it's not you, it's me! From nimbiotics at gmail.com Fri Jan 24 08:57:55 2020 From: nimbiotics at gmail.com (Mario R. Osorio) Date: Fri, 24 Jan 2020 05:57:55 -0800 (PST) Subject: A small quiz In-Reply-To: <5e295f6a$0$705$14726298@news.sunsite.dk> References: <5e295f6a$0$705$14726298@news.sunsite.dk> Message-ID: <646101c3-4113-4b2b-abb8-b7f158681165@googlegroups.com> On Thursday, January 23, 2020 at 3:54:56 AM UTC-5, Z wrote: > what is PLR? PLR: Private Label Rights (https://en.wikipedia.org/wiki/Private_label_rights) From rhodri at kynesim.co.uk Fri Jan 24 08:40:25 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Fri, 24 Jan 2020 13:40:25 +0000 Subject: Friday Finking: Enum by gum In-Reply-To: References: Message-ID: <2297e42b-3f7d-2214-56e3-b44348de764c@kynesim.co.uk> On 24/01/2020 04:26, DL Neil via Python-list wrote: > Questions: > > Have I made proper sense of this? (please don't laugh too much) Um. My basic take on enums is that they provide a convenient namespace to collect together related constants. API flags and opcodes are an obvious example of related constants you would want to keep together, but Python enums can be more complex than that both as structured data and associated functions. > Is the above 'interfacing' an appropriate use of enum-s; or is it really > 'overkill' or posturing? I think it's an entirely appropriate use of enums. In fact it's pretty much my only use of them. One caveat: when you care about the value of a constant, set it explicitly. Don't rely on auto() to come up with the right number for you, because the documentation really gives you no guarantees. > Python v3.6+ brings Flag-enums into the game. These seem better for > interface use, as described. Do you prefer them to the 'plain-vanilla' > enum, and for what reason? I prefer them when the interface calls for flags, because they behave like flags. I use plain enums when I don't require that behaviour. It's horses for courses, as ever. -- Rhodri James *-* Kynesim Ltd From matt.mailinglists at gmail.com Fri Jan 24 15:33:46 2020 From: matt.mailinglists at gmail.com (Matt) Date: Fri, 24 Jan 2020 14:33:46 -0600 Subject: Threading Message-ID: I am using this example for threading in Python: from threading import Thread def start_test( address, port ): print address, port sleep(1) for line in big_list: t = Thread(target=start_test, args=(line, 80)) t.start() But say big_list has thousands of items and I only want to have a maximum of 10 threads open. How do work my way through the big_list with only 10 threads for example? From rosuav at gmail.com Fri Jan 24 15:43:49 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Jan 2020 07:43:49 +1100 Subject: Threading In-Reply-To: References: Message-ID: On Sat, Jan 25, 2020 at 7:35 AM Matt wrote: > > I am using this example for threading in Python: > > from threading import Thread > > def start_test( address, port ): > print address, port > sleep(1) > > for line in big_list: > t = Thread(target=start_test, args=(line, 80)) > t.start() > > But say big_list has thousands of items and I only want to have a > maximum of 10 threads open. How do work my way through the big_list > with only 10 threads for example? First off, it is high time you move to Python 3, as the older versions of Python have reached end-of-life. The best way is to create your ten threads, and have each one request "jobs" (for whatever definition of job you have) from a queue. Once the queue is exhausted, the threads terminate cleanly, and then you can join() each thread to wait for the entire queue to be completed. ChrisA From 2QdxY4RzWzUUiLuE at potatochowder.com Fri Jan 24 16:15:05 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Fri, 24 Jan 2020 16:15:05 -0500 Subject: Threading In-Reply-To: References: Message-ID: <20200124161505.b4d149ca6ae28e58d660bccc@potatochowder.com> On Sat, 25 Jan 2020 07:43:49 +1100 Chris Angelico wrote: > On Sat, Jan 25, 2020 at 7:35 AM Matt wrote: > > > > I am using this example for threading in Python: > > > > from threading import Thread > > > > def start_test( address, port ): > > print address, port > > sleep(1) > > > > for line in big_list: > > t = Thread(target=start_test, args=(line, 80)) > > t.start() > > > > But say big_list has thousands of items and I only want to have a > > maximum of 10 threads open. How do work my way through the big_list > > with only 10 threads for example? > > First off, it is high time you move to Python 3, as the older versions > of Python have reached end-of-life. > > The best way is to create your ten threads, and have each one request > "jobs" (for whatever definition of job you have) from a queue. Once > the queue is exhausted, the threads terminate cleanly, and then you > can join() each thread to wait for the entire queue to be completed. Or use a thread pool: https://docs.python.org/3/library/concurrent.futures.html Dan -- ?Atoms are not things.? ? Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan From matt.mailinglists at gmail.com Fri Jan 24 16:33:33 2020 From: matt.mailinglists at gmail.com (Matt) Date: Fri, 24 Jan 2020 15:33:33 -0600 Subject: Threading In-Reply-To: References: Message-ID: So I would create 10 threads. And each would pop items off list like so? def start_test(): while big_list: list_item = big_list.pop() print list_item, port sleep(1) port = 80 for i = 1 to 10 t = Thread(target=start_test) t.start() t.join() Would that be thread safe? On Fri, Jan 24, 2020 at 2:44 PM Chris Angelico wrote: > > On Sat, Jan 25, 2020 at 7:35 AM Matt wrote: > > > > I am using this example for threading in Python: > > > > from threading import Thread > > > > def start_test( address, port ): > > print address, port > > sleep(1) > > > > for line in big_list: > > t = Thread(target=start_test, args=(line, 80)) > > t.start() > > > > But say big_list has thousands of items and I only want to have a > > maximum of 10 threads open. How do work my way through the big_list > > with only 10 threads for example? > > First off, it is high time you move to Python 3, as the older versions > of Python have reached end-of-life. > > The best way is to create your ten threads, and have each one request > "jobs" (for whatever definition of job you have) from a queue. Once > the queue is exhausted, the threads terminate cleanly, and then you > can join() each thread to wait for the entire queue to be completed. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From python at mrabarnett.plus.com Fri Jan 24 16:59:45 2020 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 24 Jan 2020 21:59:45 +0000 Subject: Threading In-Reply-To: References: Message-ID: On 2020-01-24 21:33, Matt wrote: > So I would create 10 threads. And each would pop items off list like so? > > > def start_test(): > while big_list: > list_item = big_list.pop() > print list_item, port > sleep(1) > > port = 80 > for i = 1 to 10 > t = Thread(target=start_test) > t.start() > > t.join() > Not quite. 1. Create a list of threads. 2. Put the items into a _queue_, not a list. 3. Start the threads. 4. Iterate over the list of threads, using .join() on each. If you're going to start the threads before you've put all of the items into the queue, you can also put a sentinel such as None into the queue after you've finished putting the items into it. When a thread sees the sentinel, it knows there are no more items to come. You could have one sentinel for each thread, or have only one and have each thread put it back when it sees it, for the other threads to see. > > > Would that be thread safe? > > On Fri, Jan 24, 2020 at 2:44 PM Chris Angelico wrote: >> >> On Sat, Jan 25, 2020 at 7:35 AM Matt wrote: >> > >> > I am using this example for threading in Python: >> > >> > from threading import Thread >> > >> > def start_test( address, port ): >> > print address, port >> > sleep(1) >> > >> > for line in big_list: >> > t = Thread(target=start_test, args=(line, 80)) >> > t.start() >> > >> > But say big_list has thousands of items and I only want to have a >> > maximum of 10 threads open. How do work my way through the big_list >> > with only 10 threads for example? >> >> First off, it is high time you move to Python 3, as the older versions >> of Python have reached end-of-life. >> >> The best way is to create your ten threads, and have each one request >> "jobs" (for whatever definition of job you have) from a queue. Once >> the queue is exhausted, the threads terminate cleanly, and then you >> can join() each thread to wait for the entire queue to be completed. >> >> ChrisA >> -- >> https://mail.python.org/mailman/listinfo/python-list > From matt.mailinglists at gmail.com Fri Jan 24 17:03:50 2020 From: matt.mailinglists at gmail.com (Matt) Date: Fri, 24 Jan 2020 16:03:50 -0600 Subject: Threading In-Reply-To: References: Message-ID: Created this example and it runs. import time import threading big_list = [] for i in range(1, 200): big_list.append(i) def start_test(): while big_list: #is this???? list_item = big_list.pop() #and this thread safe???? print list_item, port time.sleep(1) print "Creating Threads..." port = 80 for i in range(1, 10): t = threading.Thread(target=start_test) t.start() print "Waiting on Threads..." t.join() print "Finished..." On Fri, Jan 24, 2020 at 2:44 PM Chris Angelico wrote: > > On Sat, Jan 25, 2020 at 7:35 AM Matt wrote: > > > > I am using this example for threading in Python: > > > > from threading import Thread > > > > def start_test( address, port ): > > print address, port > > sleep(1) > > > > for line in big_list: > > t = Thread(target=start_test, args=(line, 80)) > > t.start() > > > > But say big_list has thousands of items and I only want to have a > > maximum of 10 threads open. How do work my way through the big_list > > with only 10 threads for example? > > First off, it is high time you move to Python 3, as the older versions > of Python have reached end-of-life. > > The best way is to create your ten threads, and have each one request > "jobs" (for whatever definition of job you have) from a queue. Once > the queue is exhausted, the threads terminate cleanly, and then you > can join() each thread to wait for the entire queue to be completed. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Fri Jan 24 17:06:53 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Jan 2020 09:06:53 +1100 Subject: Threading In-Reply-To: References: Message-ID: On Sat, Jan 25, 2020 at 9:05 AM Matt wrote: > > Created this example and it runs. > > import time > import threading > > big_list = [] > > for i in range(1, 200): > big_list.append(i) > > def start_test(): > while big_list: #is this???? > list_item = big_list.pop() #and this thread safe???? > print list_item, port > time.sleep(1) > > print "Creating Threads..." > > port = 80 > for i in range(1, 10): > t = threading.Thread(target=start_test) > t.start() > > print "Waiting on Threads..." > > t.join() > > print "Finished..." > Please don't top-post. Also, switch to a Python 3 interpreter before you end up filling your code with Py2isms and make your job harder later. ChrisA From cs at cskk.id.au Fri Jan 24 17:19:27 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 25 Jan 2020 09:19:27 +1100 Subject: Threading In-Reply-To: References: Message-ID: <20200124221927.GA62565@cskk.homeip.net> First come remarks, then a different suggestion about your capacity problem (no more than 10). Details below. On 24Jan2020 16:03, Matt wrote: >Created this example and it runs. [...] >big_list = [] >for i in range(1, 200): > big_list.append(i) You can just go: big_list.extend(range(1,200)) >def start_test(): > while big_list: #is this???? This tests if big_list is nonempty. In Python, most "containers" (lists, tuples, dicts, sets etc) are "falsey" if empty and "true" if nonempty. > list_item = big_list.pop() #and this thread safe???? Don't think so. > print list_item, port Please use Python 3; Python 2 is end of life. So: print(list_item, port) > time.sleep(1) > >print "Creating Threads..." > >port = 80 >for i in range(1, 10): > t = threading.Thread(target=start_test) > t.start() This starts only 10 Threads. >print "Waiting on Threads..." >t.join() This waits for only the last Thread. My suggestion for your capacity thing: use a Semaphore, which is a special thread safe counter which cannot go below zero. from threading import Semaphore def start_test(sem, args...): sem.acquire() ... do stuff with args ... sem.release() sem = Semaphore(10) threads = [] for item in big_list: t = Thread(target=start_test, args=(sem, item)) t.start() threads.append(t) ... wait for all the threads here ... This version starts many threads, but only 10 at a time will do "work" because they stall until they can acquire the Semaphore. The first 10 acquire it immediately, then the later only stall until an earlier Thread releases the Semaphore. Cheers, Cameron Simpson From matt.mailinglists at gmail.com Fri Jan 24 19:12:12 2020 From: matt.mailinglists at gmail.com (Matt) Date: Fri, 24 Jan 2020 18:12:12 -0600 Subject: Threading In-Reply-To: References: Message-ID: > Not quite. > > 1. Create a list of threads. > > 2. Put the items into a _queue_, not a list. > > 3. Start the threads. > > 4. Iterate over the list of threads, using .join() on each. > > If you're going to start the threads before you've put all of the items > into the queue, you can also put a sentinel such as None into the queue > after you've finished putting the items into it. When a thread sees the > sentinel, it knows there are no more items to come. You could have one > sentinel for each thread, or have only one and have each thread put it > back when it sees it, for the other threads to see. > Is the list not thread safe and I need to use Queue instead or is it just that using a Queue is more efficient? I think I have everything else you mentioned changed. Even in python3 now though I still need to work in python2 in places for time being. Thanks. import time import datetime import threading import random big_list = [] def date_stamp(): return "[" + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S:%f')[:-3] + "] " for i in range(1, 5000): big_list.append(i) def start_test(id): while big_list: list_item = big_list.pop() print(date_stamp(), "Thread", id, ":", list_item, port) time.sleep(random.random()) print(date_stamp(), "Thread", id, "done...") print(date_stamp(), "Creating Threads...") port = 80 threads = [] for i in range(1, 10): t = threading.Thread(target=start_test, args=(i,)) print(date_stamp(), "Starting Thread:", i) t.start() threads.append(t) print(date_stamp(), "Waiting on Threads...") for t in threads: t.join() print(date_stamp(), "Finished...") From robertvstepp at gmail.com Fri Jan 24 21:45:43 2020 From: robertvstepp at gmail.com (boB Stepp) Date: Fri, 24 Jan 2020 20:45:43 -0600 Subject: A small quiz In-Reply-To: <5e295f6a$0$705$14726298@news.sunsite.dk> References: <5e295f6a$0$705$14726298@news.sunsite.dk> Message-ID: On Thu, Jan 23, 2020 at 2:57 AM Z wrote: > > what is PLR? Python Language Reference? https://docs.python.org/3/reference/index.html Or, perhaps, Python Library Reference? https://docs.python.org/3/library/index.html -- boB From gabriele1NOSPAM at hotmail.com Sat Jan 25 07:08:15 2020 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sat, 25 Jan 2020 13:08:15 +0100 Subject: How to read/write a field in MariaDB already managed/encrypted by PHP script. Message-ID: Hy guys, I'm doing a software with a login/register area by Python 3 and PHP 7.3, i followed this guide https://www.9lessons.info/2016/04/php-login-system-with-pdo-connection.html and it store the password in encrypted mode but now I need to understand how to set the same cypher in Python! :\ ^Bart From me at use.net Sat Jan 25 07:57:20 2020 From: me at use.net (I) Date: Sat, 25 Jan 2020 12:57:20 +0000 Subject: How to read/write a field in MariaDB already managed/encrypted by PHP script. In-Reply-To: References: Message-ID: on 2020-01-25 at 12:08 user ^Bart wrote: > Hy guys, > > I'm doing a software with a login/register area by Python 3 and PHP > 7.3, i followed this guide > https://www.9lessons.info/2016/04/php-login-system-with-pdo-connection.html > and it store the password in encrypted mode but now I need to > understand how to set the same cypher in Python! :\ > > ^Bart everyone and his son uses oasswords, truth is, passwords totally suck. do not ver use shitty passwords, mate From lukasz at langa.pl Sat Jan 25 10:40:05 2020 From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=) Date: Sat, 25 Jan 2020 16:40:05 +0100 Subject: [RELEASE] Python 3.9.0a3 available for testing Message-ID: <580C1A11-CD56-4814-BACE-4244A09CBA98@langa.pl> Go get it here: https://www.python.org/downloads/release/python-390a3/ This is an early developer preview of Python 3.9 Python 3.9 is still in development. This releasee, 3.9.0a3 is the third of six planned alpha releases. Alpha releases are intended to make it easier to test the current state of new features and bug fixes and to test the release process. During the alpha phase, features may be added up until the start of the beta phase (2020-05-18) and, if necessary, may be modified or deleted up until the release candidate phase (2020-08-10). Please keep in mind that this is a preview release and its use is not recommended for production environments. Major new features of the 3.9 series, compared to 3.8 Many new features for Python 3.9 are still being planned and written. Among the new major new features and changes so far: PEP 602 , Python adopts a stable annual release cadence BPO 38379 , garbage collection does not block on resurrected objects; BPO 38692 , os.pidfd_open added that allows process management without races and signals; A number of standard library modules (audioop, ast, grp, _hashlib, pwd, _posixsubprocess, random, select, struct, termios, zlib) are now using the stable ABI defined by PEP 384 . (Hey, fellow core developer, if a feature you find important is missing from this list, let ?ukasz know .) The next pre-release of Python 3.9 will be 3.9.0a4, currently scheduled for 2020-02-17. - ? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: Message signed with OpenPGP URL: From address at not.available Sat Jan 25 12:28:42 2020 From: address at not.available (R.Wieser) Date: Sat, 25 Jan 2020 18:28:42 +0100 Subject: tkinter treeview widget - bind doubleclick to items only ? Anyone ? References: Message-ID: "R.Wieser"
wrote in message news:r040ls$fje$1 at gioia.aioe.org... > Hello all, > > I've create a treeview, and would (ofcourse) want to register some > mouse-clicking on it, and for that I've found the ".bind()" method. > > https://stackoverflow.com/questions/3794268/command-for-clicking-on-the-items-of-a-tkinter-treeview-widget > > There is a slight problem with it though: when I click a columns caption > (for sorting) the events code also gets fired, which causes problems. > > I've found that I can connect mouse-click events to the column captions > as shown in the second example here in the "self.tree.heading()" call : > > https://stackoverflow.com/questions/5286093/display-listbox-with-columns-using-tkinter > > I was wondering if something similar is maybe also available for the items > below it ... > > If not, how do I ignore mouseclicks that are not done on one of the items > ? > > Regards, > Rudy Wieser From mehrabrarlak at gmail.com Sat Jan 25 14:21:29 2020 From: mehrabrarlak at gmail.com (Mehr Abrar Lak) Date: Sun, 26 Jan 2020 00:21:29 +0500 Subject: pyttsx3 installation error Message-ID: When I try to import pyytsx3 on python 3.7.3 having latest pip version then I get error like exit code 1. I couldn't make it to install it I try using pip install pyttsx3 but it doesn't work for me then I tried it's .whl wheel file to install but instead fixing the issue am still facing the same one. It tries to load and download some files but at some point it shows error the exit status code 1 it is just because of the environment error2 From cs at cskk.id.au Sat Jan 25 16:50:56 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Sun, 26 Jan 2020 08:50:56 +1100 Subject: Threading In-Reply-To: <076n2ftjljaj5alektjtcu1lk43md09i25@4ax.com> References: <076n2ftjljaj5alektjtcu1lk43md09i25@4ax.com> Message-ID: <20200125215056.GA97286@cskk.homeip.net> On 24Jan2020 21:08, Dennis Lee Bieber wrote: >>My suggestion for your capacity thing: use a Semaphore, which is a >>special thread safe counter which cannot go below zero. >> >> from threading import Semaphore >> >> def start_test(sem, args...): >> sem.acquire() >> ... do stuff with args ... >> sem.release() >> >> sem = Semaphore(10) >> >> threads = [] >> for item in big_list: >> t = Thread(target=start_test, args=(sem, item)) >> t.start() >> threads.append(t) >> ... wait for all the threads here ... >> >>This version starts many threads, but only 10 at a time will do "work" >>because they stall until they can acquire the Semaphore. The first 10 >>acquire it immediately, then the later only stall until an earlier >>Thread releases the Semaphore. > > You are actually proposing to create {200} threads, with related stack >and thread overhead -- and then block all but 10, releasing a blocked >thread only when a previous unblocked thread exits? Well, yeah, but largely because semaphores are averlooked as a resource constraint tool, and because the expression is simple and clear. I'd much prefer to create only 10 threads with the semaphore control in the thread dispatcher, but it was harder to write and be clear in its intent. Basic concepts first, superior complication later. I also was wanting a scheme where the "set it all up" phase could be fast (== start alll the threads, wait later) versus process a capacity limited queue (takes a long time, stalling the "main" programme). Of course one might dispatch a thread to run the queue... I'm aware this makes a lot of threads and they're not free, that's a very valid criticism. Cheers, Cameron Simpson From cs at cskk.id.au Sat Jan 25 23:03:14 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Sun, 26 Jan 2020 15:03:14 +1100 Subject: pyttsx3 installation error In-Reply-To: References: Message-ID: <20200126040314.GA71193@cskk.homeip.net> On 26Jan2020 00:21, Mehr Abrar Lak wrote: >When I try to import pyytsx3 on python 3.7.3 having latest pip version then >I get error like exit code 1. I couldn't make it to install it I try using >pip install pyttsx3 but it doesn't work for me then I tried it's .whl wheel >file to install but instead fixing the issue am still facing the same one. >It tries to load and download some files but at some point it shows error >the exit status code 1 it is just because of the environment error2 Please post the full output of running: pip install pyttsx3 so that we can see the error messages. Likewise, if the "import pyytsx3" statement causes python to emit an error, please post the _full_ transcript of the failure. "error like exit code 1" is not sufficiently precise. Note that this is a text only list, so do not attach screenshots; insert the error text straight into the message body. If pip is working but an import fails, make sure the "pip" command you're running installs for the python you're using. It is common for systems to have both a python2 and python3 installed presently, so there is some scope for pip installing into the wrong python. Cheers, Cameron Simpson From ferzans97 at gmail.com Sun Jan 26 10:15:28 2020 From: ferzans97 at gmail.com (ferzan saglam) Date: Sun, 26 Jan 2020 07:15:28 -0800 (PST) Subject: Nested Loop Code Help Message-ID: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> Hello people, I have written the code below which works fine, but it has one small problem. Instead of printing one (x) on the first line, it prints two. I have tried everything in my knowledge, but cannot fix the problem. Thanks for any help in advance. for x in range ( 0, 10): stars = 'x' count = 0 while count < x: stars = stars + 'x' count = count + 1 print (stars) Output I am trying to get Output I am getting x xx xx xxx xxx xxxx xxxx xxxxx xxxxx xxxxxx xxxxxx xxxxxxx xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxxx xxxxxxxxxx From dan at djph.net Sun Jan 26 10:26:20 2020 From: dan at djph.net (Dan Purgert) Date: Sun, 26 Jan 2020 15:26:20 -0000 (UTC) Subject: Nested Loop Code Help References: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ferzan saglam wrote: > Hello people, I have written the code below which works fine, but it > has one small problem. Instead of printing one (x) on the first line, > it prints two. > I have tried everything in my knowledge, but cannot fix the problem. > Thanks for any help in advance. either take the initial "stars = x" out, or increment stars after you print it. Either approach should give you the result you want. -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEBcqaUD8uEzVNxUrujhHd8xJ5ooEFAl4tr5sACgkQjhHd8xJ5 ooGt+AgArjEk3CIPLvX36SBhZjnjOCdpTXpvzjZDePgMcAJT3WZTweIVmF+JyV6w xS7kSI/pjmReP/BTH6XGdcJiqsyKeOh5C1D5HgCYFNsuXcegCd1j7PvKlQ/3tVFz MZUhT46PtWK04Er/Hj4IHUdvP+IRu5HNeUozcWHPlSV9VJmfOd5e94s/cV7Mx5HA d1p+GHrhS3VDIqY0MBxm3r9A6ciKjys328YpiUpIRfTIX8uUEYWPhNRr3UcIHLBC ilgZUV5evyr5CXFIET5UKEw4QD0eMLy3T6o2VqR5HsrgAgFW95RTWXNA+qWw+spV t/grPnMpZ8Cjw5TTbmFYYIrvEyJ+WQ== =ern6 -----END PGP SIGNATURE----- -- |_|O|_| |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From ferzans97 at gmail.com Sun Jan 26 10:33:47 2020 From: ferzans97 at gmail.com (ferzan saglam) Date: Sun, 26 Jan 2020 07:33:47 -0800 (PST) Subject: Nested Loop Code Help In-Reply-To: References: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> Message-ID: On Sunday, January 26, 2020 at 3:26:40 PM UTC, Dan Purgert wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > ferzan saglam wrote: > > Hello people, I have written the code below which works fine, but it > > has one small problem. Instead of printing one (x) on the first line, > > it prints two. > > I have tried everything in my knowledge, but cannot fix the problem. > > Thanks for any help in advance. > > either take the initial "stars = x" out, or increment stars after you > print it. Either approach should give you the result you want. > > -----BEGIN PGP SIGNATURE----- > > iQEzBAEBCAAdFiEEBcqaUD8uEzVNxUrujhHd8xJ5ooEFAl4tr5sACgkQjhHd8xJ5 > ooGt+AgArjEk3CIPLvX36SBhZjnjOCdpTXpvzjZDePgMcAJT3WZTweIVmF+JyV6w > xS7kSI/pjmReP/BTH6XGdcJiqsyKeOh5C1D5HgCYFNsuXcegCd1j7PvKlQ/3tVFz > MZUhT46PtWK04Er/Hj4IHUdvP+IRu5HNeUozcWHPlSV9VJmfOd5e94s/cV7Mx5HA > d1p+GHrhS3VDIqY0MBxm3r9A6ciKjys328YpiUpIRfTIX8uUEYWPhNRr3UcIHLBC > ilgZUV5evyr5CXFIET5UKEw4QD0eMLy3T6o2VqR5HsrgAgFW95RTWXNA+qWw+spV > t/grPnMpZ8Cjw5TTbmFYYIrvEyJ+WQ== > =ern6 > -----END PGP SIGNATURE----- > > -- > |_|O|_| > |_|_|O| Github: https://github.com/dpurgert > |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 Thanks for the help Dan, your suggestion worked. From souvik.viksou at gmail.com Sun Jan 26 12:38:46 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sun, 26 Jan 2020 23:08:46 +0530 Subject: PyQt5 help. Message-ID: I am making a birthday reminder app. I want to show tha label (" Today is Tom's birthday.") Assuming Tom has a birthday. But I want this label to be visible only when someone has a birthday today. I am using datetime module to check the date. How can I do this?? Any help is appreciated. From arj.python at gmail.com Sun Jan 26 12:42:47 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sun, 26 Jan 2020 21:42:47 +0400 Subject: PyQt5 help. In-Reply-To: References: Message-ID: suggest a scrollable widget which on loads appends labels with members birthdays in it. If 3 members have birthdays today, it will append 3 labels On Sun, 26 Jan 2020, 21:39 Souvik Dutta, wrote: > I am making a birthday reminder app. I want to show tha label (" Today is > Tom's birthday.") Assuming Tom has a birthday. > But I want this label to be visible only when someone has a birthday today. > I am using datetime module to check the date. How can I do this?? Any help > is appreciated. > -- > https://mail.python.org/mailman/listinfo/python-list > From Richard at Damon-Family.org Sun Jan 26 12:51:36 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Sun, 26 Jan 2020 12:51:36 -0500 Subject: Nested Loop Code Help In-Reply-To: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> References: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> Message-ID: <262f8d4d-4b12-240a-9d12-4a27940af0bd@Damon-Family.org> On 1/26/20 10:15 AM, ferzan saglam wrote: > Hello people, I have written the code below which works fine, but it has one small problem. Instead of printing one (x) on the first line, it prints two. > I have tried everything in my knowledge, but cannot fix the problem. > Thanks for any help in advance. > > > for x in range ( 0, 10): > stars = 'x' > count = 0 > > while count < x: > stars = stars + 'x' > count = count + 1 > print (stars) > > > > Output I am trying to get Output I am getting > x xx > xx xxx > xxx xxxx > xxxx xxxxx > xxxxx xxxxxx > xxxxxx xxxxxxx > xxxxxxx xxxxxxxx > xxxxxxxx xxxxxxxxx > xxxxxxxxx xxxxxxxxxx > xxxxxxxxxx First skill is to learn to act like an interpreter, and execute the instructions one by one. First we execute the for x in range (0, 10): statement which will set x to 0 Then we set stars to 'x' Then we set count to 0, since the while outdents, that ends the loop and we repeat it with x having values 1, 2, 3, and up to 9 THEN we go to the bottom loop. Count is 0, x is 9 so the while is satisfied, so we do a loop stars = stars + 'x' which is 'xx' count = count + 1 which is 1 print(stars) prints 'xx' that ends one pass thru the while loop, so we do the test again Count is 1, x is 9, so the while is satisfied, so we do a loop, stars = stars + 'x', which is 'xxx' count = count + 1, which is 2 print(stars) prints 'xxx' this continues until count reaches 9 (the value left in x) at which it stops. Thus the loop ran 9 times (for starting values of count = 0, 1, 2, 3, 4, 5, 6, 7, 8 Think about what you wanted to do and what the code actually did. The first for x in range (0, 10) doesn't really do what I think you wanted, did you mean for the second loop to be nested in it? If you do nest the second loop, you probably don't want the print at the end part of the second loop. -- Richard Damon From admin at formationgrowthhacking.com Sun Jan 26 15:36:05 2020 From: admin at formationgrowthhacking.com (Growth Hacking Formation) Date: Sun, 26 Jan 2020 12:36:05 -0800 (PST) Subject: I need help for multidimensional loop Message-ID: Hi guys, I need your help please to sold a complicate problem. It is difficult for me to find the solution but in fact, I am sure it is just a few lines of code. The problem is about some kind of multidimensional loop with some test IF. I worked hours on it, but I am a newbie and it is too difficult. I was wondering if a super expert in python could give me a hand. In order to give a maximum of info (explanations + code + screenshot), I prepared a google doc for better understanding. Here in a Facebook post would be too hard to read. https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing Thanks for help. Have a great evening. From python at invalid Sun Jan 26 16:14:33 2020 From: python at invalid (Python) Date: Sun, 26 Jan 2020 22:14:33 +0100 Subject: I need help for multidimensional loop In-Reply-To: References: Message-ID: <5e2e013b$0$6463$426a34cc@news.free.fr> Le 26/01/2020 ? 21:36, Growth Hacking Formation a ?crit?: > Hi guys, > > I need your help please to sold a complicate problem. > > It is difficult for me to find the solution but in fact, I am sure it is just a few lines of code. > > The problem is about some kind of multidimensional loop with some test IF. > > I worked hours on it, but I am a newbie and it is too difficult. > > I was wondering if a super expert in python could give me a hand. > > In order to give a maximum of info (explanations + code + screenshot), I prepared a google doc for better understanding. Here in a Facebook post would be too hard to read. > > https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing > > Thanks for help. > > Have a great evening. > You are a joke, aren't you? From phamp at mindspring.com Sun Jan 26 18:08:08 2020 From: phamp at mindspring.com (pyotr filipivich) Date: Sun, 26 Jan 2020 15:08:08 -0800 Subject: I need help for multidimensional loop References: Message-ID: <7o6s2fd98o0ilrsef7fp1b2gc8ab4k8jdq@4ax.com> Growth Hacking Formation on Sun, 26 Jan 2020 12:36:05 -0800 (PST) typed in comp.lang.python the following: >Hi guys, > >I need your help please to sold a complicate problem. > >It is difficult for me to find the solution but in fact, I am sure it is just a few lines of code. > >The problem is about some kind of multidimensional loop with some test IF. > >I worked hours on it, but I am a newbie and it is too difficult. > >I was wondering if a super expert in python could give me a hand. > >In order to give a maximum of info (explanations + code + screenshot), I prepared a google doc for better understanding. Here in a Facebook post would be too hard to read. > >https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing > >Thanks for help. > >Have a great evening. I realize that if you could explain it well enough for someone else to realize what your problem is, you should be able to see the solution yourself. It would be better if you could provide a short "elevator itch" on what you're trying to do. Cause "multidimensional arrays" can get hairy really fast. I mean, try building a sieve of erostothenses using arrays in integers [0..maxint] in size. -- pyotr filipivich Next month's Panel: Graft - Boon or blessing? From greg.ewing at canterbury.ac.nz Sun Jan 26 18:11:41 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 27 Jan 2020 12:11:41 +1300 Subject: Nested Loop Code Help In-Reply-To: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> References: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> Message-ID: On 27/01/20 4:15 am, ferzan saglam wrote: > for x in range ( 0, 10): > stars = 'x' > count = 0 By the way, this 'for' loop is unnecessary. The end result is just to give initial values to three names. You don't need a loop at all for that, just three assignment statements. -- Greg From Richard at Damon-Family.org Sun Jan 26 18:37:37 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Sun, 26 Jan 2020 18:37:37 -0500 Subject: Nested Loop Code Help In-Reply-To: References: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> Message-ID: <944ab917-b44f-e019-e9d0-05fba3d93a33@Damon-Family.org> On 1/26/20 6:11 PM, Greg Ewing wrote: > On 27/01/20 4:15 am, ferzan saglam wrote: >> for x in range ( 0, 10): >> ?? stars = 'x' >> ?? count = 0 > By the way, this 'for' loop is unnecessary. The end result is just to > give initial values to three names. You don't need a loop at all for > that, just three assignment statements. > His thinking MIGHT have been that this for loop be the main loop that prints the 10 lines (i.e the following loop be within this loop). In that case, the assignment statements in the loop make sense. In that case, the print call wouldn't be in the while loop, which would add x 'x's to the string. -- Richard Damon From PythonList at DancesWithMice.info Sun Jan 26 18:44:30 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 27 Jan 2020 12:44:30 +1300 Subject: I need help for multidimensional loop In-Reply-To: <7o6s2fd98o0ilrsef7fp1b2gc8ab4k8jdq@4ax.com> References: <7o6s2fd98o0ilrsef7fp1b2gc8ab4k8jdq@4ax.com> Message-ID: <2bdedfd3-9cb3-0e19-3e48-c0ee1c09fc2f@DancesWithMice.info> On 27/01/20 12:08 PM, pyotr filipivich wrote: > Growth Hacking Formation on Sun, 26 > Jan 2020 12:36:05 -0800 (PST) typed in comp.lang.python the > following: >> Hi guys, >> >> I need your help please to sold a complicate problem. >> >> It is difficult for me to find the solution but in fact, I am sure it is just a few lines of code. >> >> The problem is about some kind of multidimensional loop with some test IF. ... >> https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing > > I realize that if you could explain it well enough for someone > else to realize what your problem is, you should be able to see the > solution yourself. > > It would be better if you could provide a short "elevator itch" on > what you're trying to do. > > Cause "multidimensional arrays" can get hairy really fast. I > mean, try building a sieve of erostothenses using arrays in integers > [0..maxint] in size. +1 Unfortunately, (given that this is a Python list) I would suggest that (full-fat) SQL already offers solutions to such 'relationship issues'. (hah!) I'm not sufficiently familiar with SQL-Lite to know if/how well it manages multi-table "joins". So, back to Python... Are you aware that it is possible to have one for-loop inside another? ("nested") In this case, use one for-loop to one of the tables, another loop for another table... Start with (almost) empty loops which print only the key or identifier of 'that' particular table. You should then be able to assure yourself that every single combination of account and phone is covered. Thereafter, complicate things by adding if-statements which cause appropriate action, or "pass"/do nothing. Let us know how you get on... -- Regards =dn From PythonList at DancesWithMice.info Sun Jan 26 18:52:09 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 27 Jan 2020 12:52:09 +1300 Subject: Nested Loop Code Help In-Reply-To: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> References: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> Message-ID: On 27/01/20 4:15 AM, ferzan saglam wrote: > Hello people, I have written the code below which works fine, but it has one small problem. Instead of printing one (x) on the first line, it prints two. > I have tried everything in my knowledge, but cannot fix the problem. > Thanks for any help in advance. > for x in range ( 0, 10): > stars = 'x' > count = 0 > while count < x: > stars = stars + 'x' > count = count + 1 > print (stars) These loops are serial, ie one after the other, and not "nested" (one 'inside' the other) - or the email messed-up the indentation. However, why "nest" or have more than one loop, in any case? >>> for i in range( 0, 10 ): ... print( "*"*i ) ... * ** *** **** ***** ****** ******* ******** ********* -- Regards =dn From PythonList at DancesWithMice.info Sun Jan 26 19:02:03 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 27 Jan 2020 13:02:03 +1300 Subject: PEP-Dilbert Message-ID: <72d13b55-25b4-f02c-7663-fbe534384d15@etelligence.info> Looks as if Dilbert is about to draft a PEP to change Python's world-view: https://dilbert.com/strip/2020-01-24 Curiously, "canard" whilst a French word for "duck", in English describes a rumor or false-story! -- Regards, =dn From hjp-python at hjp.at Sun Jan 26 19:16:52 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 27 Jan 2020 01:16:52 +0100 Subject: PEP-Dilbert In-Reply-To: <72d13b55-25b4-f02c-7663-fbe534384d15@etelligence.info> References: <72d13b55-25b4-f02c-7663-fbe534384d15@etelligence.info> Message-ID: <20200127001652.GA864@hjp.at> On 2020-01-27 13:02:03 +1300, DL Neil via Python-list wrote: > Looks as if Dilbert is about to draft a PEP to change Python's world-view: > https://dilbert.com/strip/2020-01-24 > > Curiously, "canard" whilst a French word for "duck", in English describes a > rumor or false-story! Interesting: In German, "Ente" (duck) also means a false story. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From Richard at Damon-Family.org Sun Jan 26 19:53:37 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Sun, 26 Jan 2020 19:53:37 -0500 Subject: Nested Loop Code Help In-Reply-To: References: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> Message-ID: <599ebcbc-998c-8c6c-62bf-89fe567e9068@Damon-Family.org> On 1/26/20 6:52 PM, DL Neil via Python-list wrote: > On 27/01/20 4:15 AM, ferzan saglam wrote: >> Hello people, I have written the code below which works fine, but it >> has one small problem. Instead of printing one (x) on the first line, >> it prints two. >> I have tried everything in my knowledge, but cannot fix the problem. >> Thanks for any help in advance. >> for x in range ( 0, 10): >> ?? stars = 'x' >> ?? count = 0 >> while count < x: >> ?? stars = stars + 'x' >> ?? count = count + 1 >> ?? print (stars) > > These loops are serial, ie one after the other, and not "nested" (one > 'inside' the other) - or the email messed-up the indentation. > > However, why "nest" or have more than one loop, in any case? > > >>> for i in range( 0, 10 ): > ...???? print( "*"*i ) > ... > > * > ** > *** > **** > ***** > ****** > ******* > ******** > ********* First, your answer doesn't solve his problem, as his expected was lines of 1 to 10 stars, not 0 to 9. Second, this smells a bit like homework, and if they haven't learned the results of string times integer, then using that operation wouldn't be in their tool kit, so having a loop to build that operator makes sense. -- Richard Damon From PythonList at DancesWithMice.info Sun Jan 26 21:36:06 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 27 Jan 2020 15:36:06 +1300 Subject: Nested Loop Code Help In-Reply-To: <599ebcbc-998c-8c6c-62bf-89fe567e9068@Damon-Family.org> References: <73177627-c92b-401e-999e-8de5baec4fb7@googlegroups.com> <599ebcbc-998c-8c6c-62bf-89fe567e9068@Damon-Family.org> Message-ID: On 27/01/20 1:53 PM, Richard Damon wrote: > On 1/26/20 6:52 PM, DL Neil via Python-list wrote: >> On 27/01/20 4:15 AM, ferzan saglam wrote: >>> Hello people, I have written the code below which works fine, but it >>> has one small problem. Instead of printing one (x) on the first line, >>> it prints two. >>> I have tried everything in my knowledge, but cannot fix the problem. >>> Thanks for any help in advance. >>> for x in range ( 0, 10): >>> ?? stars = 'x' >>> ?? count = 0 >>> while count < x: >>> ?? stars = stars + 'x' >>> ?? count = count + 1 >>> ?? print (stars) >> >> These loops are serial, ie one after the other, and not "nested" (one >> 'inside' the other) - or the email messed-up the indentation. >> >> However, why "nest" or have more than one loop, in any case? >> >> >>> for i in range( 0, 10 ): >> ...???? print( "*"*i ) >> ... >> >> * >> ** >> *** >> **** >> ***** >> ****** >> ******* >> ******** >> ********* > > First, your answer doesn't solve his problem, as his expected was lines > of 1 to 10 stars, not 0 to 9. > > Second, this smells a bit like homework, and if they haven't learned the > results of string times integer, then using that operation wouldn't be > in their tool kit, so having a loop to build that operator makes sense. The reply to the first criticism is answered in the second - it only looks like the answer. Notice also, that the character used, whilst a "star", is not what the OP wanted either. Also, please recall that the OP has already accepted one answer (whether the 'right' one, or not, is another matter). If it was 'homework', what are the chances that (s)he will go back and 'change everything' after saying "done"? Would you? Would I? A while back we had a rash of folk asking beginner questions. Not one to whom I posed the 'is this homework?' question, responded. Also, there is the Python Tutor list... That said, there is no telling in which order people learn particular aspects of a topic [Python in this case]. A quick check of the reference I use, shows a listing of string functions (and other objects) before reaching looping constructs. Learning that there are different ways of approaching the same problem/solution is valuable learning. How about taking a string of ten 'stars' and printing progressively longer slices thereof, on successive lines? (that book has slices (of strings and lists) before loops too!) Did anyone suggest that it seemed a little odd to use both a for-loop and a while-loop? Why not both for-loops (there are finite starting and finishing points (and increments) after-all)? BTW your earlier response extremely constructive. Have you seen Philip Guo's http://pythontutor.com/ ? It illustrates what we learned as 'paper computers', with all the advantages of dynamism! The site now makes it possible for learners to 'go' as far as they are able, and then to call for help; and for someone to peer-review, comment, and/or pair-program(me) right there with them! -- Regards =dn From FvLieshout at outlook.com Mon Jan 27 01:10:12 2020 From: FvLieshout at outlook.com (Francois van Lieshout) Date: Mon, 27 Jan 2020 06:10:12 +0000 Subject: Python-list Digest, Vol 196, Issue 26 In-Reply-To: References: Message-ID: for x in range( 0,10 ): stars = "" count = 0 while count < x: stars += "x" count += 1 print( stars ) x xx xxx xxxx xxxxx xxxxxx xxxxxxx xxxxxxxx xxxxxxxxx You've got already an "x" placed in your variable stars that's why. -----Oorspronkelijk bericht----- Van: Python-list Namens python-list-request at python.org Verzonden: zondag 26 januari 2020 18:00 Aan: python-list at python.org Onderwerp: Python-list Digest, Vol 196, Issue 26 Send Python-list mailing list submissions to python-list at python.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to python-list-request at python.org You can reach the person managing the list at python-list-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." From uri at speedy.net Mon Jan 27 02:03:24 2020 From: uri at speedy.net (=?UTF-8?B?15DXldeo15k=?=) Date: Mon, 27 Jan 2020 09:03:24 +0200 Subject: Python-list Digest, Vol 196, Issue 26 In-Reply-To: References: Message-ID: Please don't reply to digest. ???? uri at speedy.net On Mon, Jan 27, 2020 at 8:11 AM Francois van Lieshout < FvLieshout at outlook.com> wrote: > for x in range( 0,10 ): > stars = "" > count = 0 > > while count < x: > stars += "x" > count += 1 > print( stars ) > > x > xx > xxx > xxxx > xxxxx > xxxxxx > xxxxxxx > xxxxxxxx > xxxxxxxxx > > You've got already an "x" placed in your variable stars that's why. > > > -----Oorspronkelijk bericht----- > Van: Python-list > Namens python-list-request at python.org > Verzonden: zondag 26 januari 2020 18:00 > Aan: python-list at python.org > Onderwerp: Python-list Digest, Vol 196, Issue 26 > > Send Python-list mailing list submissions to > python-list at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > python-list-request at python.org > > You can reach the person managing the list at > python-list-owner at python.org > > When replying, please edit your Subject line so it is more specific than > "Re: Contents of Python-list digest..." > -- > https://mail.python.org/mailman/listinfo/python-list > From musbur at posteo.org Mon Jan 27 09:05:37 2020 From: musbur at posteo.org (Musbur) Date: Mon, 27 Jan 2020 15:05:37 +0100 Subject: Clarification on Immutability please In-Reply-To: References: Message-ID: <5846c1dd93671a998c96449c0ceb8b10@posteo.de> Am 21.01.2020 19:38 schrieb Chris Angelico: > On Wed, Jan 22, 2020 at 4:42 AM Stephen Tucker > wrote: >> and even that the first id(mytup) returns the same address as the >> second >> one, I am left wondering exactly what immutability is. Let's look at id()'s documentation: id(object) Return the ?identity? of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value. > Are you sure that it does? I can't reproduce this. When you slice the > first two from a tuple, you create a new tuple, and until the > assignment happens, both the new one and the original coexist, which > means they MUST have unique IDs. I'd expect that, too, but an "atomic" reassignment would not contradict the documentation. >> Somehow, it seems, tuples can be reduced in length (from the far end) >> (which is not what I was expecting), but they cannot be extended >> (which I >> can understand). Different ID means different object, but identical ID doesn't mean identical object. The Python implementation allows re-use of an object's ID after the object has been destroyed, and the documentation mentions this explicitly. From musbur at posteo.org Mon Jan 27 09:16:39 2020 From: musbur at posteo.org (Musbur) Date: Mon, 27 Jan 2020 15:16:39 +0100 Subject: Sandboxing eval() (was: Calculator) In-Reply-To: References: <055c4593-5542-4ac5-b603-6b6104855a90@googlegroups.com> <49bf3a3b-8840-47c9-ba4c-e96cc8e5c40e@googlegroups.com> <5e1f4758$0$21588$426a74cc@news.free.fr> <0e593f87-40a8-4850-91cc-2debbf81e154@googlegroups.com> <5e20dbe8$0$31434$426a34cc@news.free.fr> <20200119183542.119eb880@nxp10225> <20200121065749.1a910492@nxp10225> Message-ID: Thanks, Chris (and others), for the comprehensive answer (as usual). I got interesting insights into Python's inner workings. Of course, when everything is an object, everything has parents and other relatives, so by traversing that tree in the right way one can make one's way all the way to the core. Thanks. From rosuav at gmail.com Mon Jan 27 09:23:24 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 28 Jan 2020 01:23:24 +1100 Subject: Clarification on Immutability please In-Reply-To: <5846c1dd93671a998c96449c0ceb8b10@posteo.de> References: <5846c1dd93671a998c96449c0ceb8b10@posteo.de> Message-ID: On Tue, Jan 28, 2020 at 1:13 AM Musbur wrote: > > Am 21.01.2020 19:38 schrieb Chris Angelico: > > Are you sure that it does? I can't reproduce this. When you slice the > > first two from a tuple, you create a new tuple, and until the > > assignment happens, both the new one and the original coexist, which > > means they MUST have unique IDs. > > I'd expect that, too, but an "atomic" reassignment would not contradict > the documentation. The way execution works in Python, you first evaluate the object, then assign it to the target. The new object HAS to exist before the old one is replaced. There's no such thing as "atomic reassignment" that simultaneously destroys the old object and assigns a new one. The slicing will always happen first, and then the assignment. ChrisA From rosuav at gmail.com Mon Jan 27 10:54:22 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 28 Jan 2020 02:54:22 +1100 Subject: Clarification on Immutability please In-Reply-To: References: <5846c1dd93671a998c96449c0ceb8b10@posteo.de> Message-ID: On Tue, Jan 28, 2020 at 2:44 AM Souvik Dutta wrote: > > If the two objects have the same value that means that when called all of them will point to the same object rather than creating the same value - object pairs twice. Immutability is the characteristics that does not let you change the value once set. Example - a = 5 > b = 5 > Then when a and b are called rather than saving two different objects with the same value python just creates one value and then let's two or more objects to point to the same value. > (I'm going to assume you meant that for the list rather than a personal email.) If you have two independent constants that happen to have the same value, the compiler is free to share them, but it's not required to. Current versions of CPython do share small integers and some strings, but not all - if you used, say, 5000000 instead of 5, they would quite possibly be distinct objects. Other Python interpreters are free to have different optimization rules. For instance, it's absolutely legit to intern every string on creation, thus guaranteeing that any two equal strings will be the same object; I don't know of any interpreter that does this, but it's completely legal according to the specification. ChrisA From torriem at gmail.com Mon Jan 27 11:17:17 2020 From: torriem at gmail.com (Michael Torrie) Date: Mon, 27 Jan 2020 09:17:17 -0700 Subject: Python-list Digest, Vol 196, Issue 26 In-Reply-To: References: Message-ID: On 1/27/20 12:03 AM, ???? wrote: > Please don't reply to digest. Replying to a digest is just fine. Just make sure to change the subject line in the future so people know what it's referring to. From PythonList at DancesWithMice.info Mon Jan 27 15:13:21 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 28 Jan 2020 09:13:21 +1300 Subject: Python-list Digest, Vol 196, Issue 26 In-Reply-To: References: Message-ID: On 28/01/20 5:17 AM, Michael Torrie wrote: > On 1/27/20 12:03 AM, ???? wrote: >> Please don't reply to digest. > > Replying to a digest is just fine. Just make sure to change the subject > line in the future so people know what it's referring to. Excepting that whilst this practice (subject to faithful reproduction) eases 'visual indexing', it still breaks the "threading" of email conversations (for those of us wot use it on our local machines AND in the archives). -- Regards =dn From smitla at yandex.com Tue Jan 28 05:14:09 2020 From: smitla at yandex.com (L A Smit) Date: Tue, 28 Jan 2020 12:14:09 +0200 Subject: Print statement Message-ID: <950343ab-6739-9672-5434-cd7d0ec7718c@yandex.com> Please help me with this. squares =input("\nSquares: ") print(float((squares) *float(.15)) *(1.3)) Cant print answer. print(float((squares) * float(.15)) *(1.3)) TypeError: can't multiply sequence by non-int of type 'float' Thx L Smit From dhaude at posteo.de Tue Jan 28 05:33:24 2020 From: dhaude at posteo.de (Daniel Haude) Date: Tue, 28 Jan 2020 11:33:24 +0100 Subject: Clarification on Immutability please In-Reply-To: References: <5846c1dd93671a998c96449c0ceb8b10@posteo.de> Message-ID: <51022a026ff59152d1100d63240ae1e2@posteo.de> Am 27.01.2020 15:23 schrieb Chris Angelico: > The way execution works in Python, you first evaluate the object, then > assign it to the target. The new object HAS to exist before the old > one is replaced. There's no such thing as "atomic reassignment" that > simultaneously destroys the old object and assigns a new one. The > slicing will always happen first, and then the assignment. Hi Chris, I agree that that is how it's done because it makes sense. My completely academic question is this: If the Python compiler sees that the operation effectively just chops a few items off the end of a tuple which will be immediately discarded I can't see an issue with an implementation simply shortening the length of the tuple. In C this would be an ultra cheap operation, and the pointer to the tuple object (CPython's object ID) would indeed not change. A possible drawback would be waste of memory because the unused tuple items are still around in allocated memory. The introductory comment in tupleobject.h is clear on this subject: "[...] C code can change the tuple items (but not their number) [...]", so this is not how it's done in CPython 3.8.0, but IMO an implementation could legally do this. All this is beside the point of the OP's question. There is no connection between an object's mutability and its ID. From frank at chagford.com Tue Jan 28 05:52:00 2020 From: frank at chagford.com (Frank Millman) Date: Tue, 28 Jan 2020 12:52:00 +0200 Subject: Print statement In-Reply-To: <950343ab-6739-9672-5434-cd7d0ec7718c@yandex.com> References: <950343ab-6739-9672-5434-cd7d0ec7718c@yandex.com> Message-ID: <5edd80f5-0a39-0f76-67ee-89668701b862@chagford.com> On 2020-01-28 12:14 PM, L A Smit wrote: > Please help me with this. > > squares =input("\nSquares: ") > > print(float((squares) *float(.15)) *(1.3)) > > Cant print answer. > > ? print(float((squares) * float(.15)) *(1.3)) > TypeError: can't multiply sequence by non-int of type 'float' > You have some superfluous brackets around 'squares' and '1.3', which hinder readability. Remove them and you get - float(squares * float(.15)) * 1.3 Now you can see that you have the brackets in the wrong place - you are trying to multiply 'squares', which at this stage is still a string, by float(.15). You can multiply a string by an integer, but not by a float - >>> 'abc' * 3 'abcabcabc' >>> >>> 'abc' * 1.5 Traceback (most recent call last): File "", line 1, in TypeError: can't multiply sequence by non-int of type 'float' >>> You probably meant float(squares) * float(.15) or more simply float(squares) * .15 HTH Frank Millman From frank at chagford.com Tue Jan 28 05:52:00 2020 From: frank at chagford.com (Frank Millman) Date: Tue, 28 Jan 2020 12:52:00 +0200 Subject: Print statement In-Reply-To: <950343ab-6739-9672-5434-cd7d0ec7718c@yandex.com> References: <950343ab-6739-9672-5434-cd7d0ec7718c@yandex.com> Message-ID: <5edd80f5-0a39-0f76-67ee-89668701b862@chagford.com> On 2020-01-28 12:14 PM, L A Smit wrote: > Please help me with this. > > squares =input("\nSquares: ") > > print(float((squares) *float(.15)) *(1.3)) > > Cant print answer. > > ? print(float((squares) * float(.15)) *(1.3)) > TypeError: can't multiply sequence by non-int of type 'float' > You have some superfluous brackets around 'squares' and '1.3', which hinder readability. Remove them and you get - float(squares * float(.15)) * 1.3 Now you can see that you have the brackets in the wrong place - you are trying to multiply 'squares', which at this stage is still a string, by float(.15). You can multiply a string by an integer, but not by a float - >>> 'abc' * 3 'abcabcabc' >>> >>> 'abc' * 1.5 Traceback (most recent call last): File "", line 1, in TypeError: can't multiply sequence by non-int of type 'float' >>> You probably meant float(squares) * float(.15) or more simply float(squares) * .15 HTH Frank Millman From rosuav at gmail.com Tue Jan 28 06:12:07 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 28 Jan 2020 22:12:07 +1100 Subject: Clarification on Immutability please In-Reply-To: <51022a026ff59152d1100d63240ae1e2@posteo.de> References: <5846c1dd93671a998c96449c0ceb8b10@posteo.de> <51022a026ff59152d1100d63240ae1e2@posteo.de> Message-ID: On Tue, Jan 28, 2020 at 9:33 PM Daniel Haude wrote: > > Am 27.01.2020 15:23 schrieb Chris Angelico: > > > The way execution works in Python, you first evaluate the object, then > > assign it to the target. The new object HAS to exist before the old > > one is replaced. There's no such thing as "atomic reassignment" that > > simultaneously destroys the old object and assigns a new one. The > > slicing will always happen first, and then the assignment. > > Hi Chris, > > I agree that that is how it's done because it makes sense. My completely > academic question is this: If the Python compiler sees that the > operation effectively just chops a few items off the end of a tuple > which will be immediately discarded I can't see an issue with an > implementation simply shortening the length of the tuple. In C this > would be an ultra cheap operation, and the pointer to the tuple object > (CPython's object ID) would indeed not change. A possible drawback would > be waste of memory because the unused tuple items are still around in > allocated memory. This would be an optimization that would be highly vulnerable, as it would depend on a LOT of knowledge of what's going on. For instance, you would have to know for certain that the surrounding namespace wasn't doing any sort of extra management (eg logging before-and-after on any assignment), and you'd need to be 100% certain that there's no way an exception could occur between the truncation and the reassignment, etc, etc, etc. This is the sort of thing that PyPy might do, but it's not something the language definition supports. > The introductory comment in tupleobject.h is clear on this subject: > "[...] C code can change the tuple items (but not their number) [...]", > so this is not how it's done in CPython 3.8.0, but IMO an implementation > could legally do this. That's more a matter of "C code can violate the rules" than anything else. Nothing to do with language specification. Generally, once a tuple has been "released" into Python code, its members won't be changed. > All this is beside the point of the OP's question. There is no > connection between an object's mutability and its ID. Correct, beyond the fact that immutable objects are open to certain optimizations that are invalid for mutables (for instance, every "[]" in a program will create a new and unique list, but "()" will reference the same empty tuple). ChrisA From random832 at fastmail.com Tue Jan 28 09:47:40 2020 From: random832 at fastmail.com (Random832) Date: Tue, 28 Jan 2020 09:47:40 -0500 Subject: Clarification on Immutability please In-Reply-To: References: <9359c167-5e3a-3781-53ef-cb7725ed713c@stoneleaf.us> Message-ID: <58b1d6f8-93ec-4ad9-97a7-0638b073dd7c@www.fastmail.com> On Wed, Jan 22, 2020, at 02:34, Stephen Tucker wrote: > Oh dear, I am sorry. I have created quite a storm. > > Moreover, I am sorry because I misremembered what I had typed into Idle. My > original tuple only had two elements, not three, so the slicing [:2] didn't > affect the tuple at all - and so the second id() gave the same address as > the first one. > > So, yes, I am stupid - or just having senior moments (I am 65, after all). > > Stephen. Regardless, this is interesting because, even though it is not in fact the case, this would be a valid optimization for an interpreter to perform, and while it's not done, something similar is done when concatenating strings. >>> s = 'asdfghjklmnop' >>> id(s); s += 'x'; id(s) 20405128 27766160 >>> id(s); s += 'x'; id(s) 27766160 27766160 # if this is done repeatedly, the two ids will not always be the same, but they will be quite a bit more often than not. The two tuples, if there are do not exist at the same time, therefore it does not violate any constraint if their ids are the same - ids are only required to be unique for simultaneously existing objects, not across the lifetime of the program. From rosuav at gmail.com Tue Jan 28 10:17:59 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 29 Jan 2020 02:17:59 +1100 Subject: Clarification on Immutability please In-Reply-To: <58b1d6f8-93ec-4ad9-97a7-0638b073dd7c@www.fastmail.com> References: <9359c167-5e3a-3781-53ef-cb7725ed713c@stoneleaf.us> <58b1d6f8-93ec-4ad9-97a7-0638b073dd7c@www.fastmail.com> Message-ID: On Wed, Jan 29, 2020 at 1:50 AM Random832 wrote: > > On Wed, Jan 22, 2020, at 02:34, Stephen Tucker wrote: > > Oh dear, I am sorry. I have created quite a storm. > > > > Moreover, I am sorry because I misremembered what I had typed into Idle. My > > original tuple only had two elements, not three, so the slicing [:2] didn't > > affect the tuple at all - and so the second id() gave the same address as > > the first one. > > > > So, yes, I am stupid - or just having senior moments (I am 65, after all). > > > > Stephen. > > Regardless, this is interesting because, even though it is not in fact the case, this would be a valid optimization for an interpreter to perform, and while it's not done, something similar is done when concatenating strings. > > >>> s = 'asdfghjklmnop' > >>> id(s); s += 'x'; id(s) > 20405128 > 27766160 > >>> id(s); s += 'x'; id(s) > 27766160 > 27766160 > # if this is done repeatedly, the two ids will not always be the same, but they will be quite a bit more often than not. > > The two tuples, if there are do not exist at the same time, therefore it does not violate any constraint if their ids are the same - ids are only required to be unique for simultaneously existing objects, not across the lifetime of the program. > What you've demonstrated isn't actually the same, though. When you use augmented assignment, it actually CAN be an atomic operation (or, more commonly, a mutating operation - see eg lists); but the original question was about slicing, which can't be done in an augmented assignment statement. ChrisA From python at bdurham.com Tue Jan 28 11:36:02 2020 From: python at bdurham.com (Malcolm Greene) Date: Tue, 28 Jan 2020 09:36:02 -0700 Subject: Simple Python github library to push/pull files? Message-ID: Any recommendations on a library providing a simple interface to Github for basic push/pull type of actions? I know there's a native GitHub RESTful API but wondering if anyone has placed a friendly Python wrapper on top of that interface? PyGithub supports a rich set of actions, but doesn't appear to provide support to push/pull files to/from a repo. Thank you, Malcolm From rosuav at gmail.com Tue Jan 28 11:40:53 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 29 Jan 2020 03:40:53 +1100 Subject: Simple Python github library to push/pull files? In-Reply-To: References: Message-ID: On Wed, Jan 29, 2020 at 3:38 AM Malcolm Greene wrote: > > Any recommendations on a library providing a simple interface to Github for basic push/pull type of actions? I know there's a native GitHub RESTful API but wondering if anyone has placed a friendly Python wrapper on top of that interface? PyGithub supports a rich set of actions, but doesn't appear to provide support to push/pull files to/from a repo. > Possibly because pulling and pushing aren't GitHub operations, they're simple git operations. You might be able to find a Python Git library, but it'd probably be just as easy to subprocess it out directly. ChrisA From sush0907 at gmail.com Tue Jan 28 07:03:00 2020 From: sush0907 at gmail.com (sushma ms) Date: Tue, 28 Jan 2020 17:33:00 +0530 Subject: Dynamic Data type assignment Message-ID: Hi Please find below example and the compiler error, when i'm assigning value dynamically and when we comparing in "if" loop it is throwing compiler error. It should not throw error it should assign and act as int why it is thinking as string. *Code Snippet:* print("Hello World") num = input("Enter number ") print(num) if(num%3 == 0): num+=num print(num) *Output in Console:* Hello World Enter number 15 15 Traceback (most recent call last): File "main.py", line 15, in if(num%3 == 0): TypeError: not all arguments converted during string formatting Created the issue: msg 360865 created issue 39476 created -- Thanks & Regards, --------------------------------- Sushma Mob:9740055884 From mariatta at python.org Tue Jan 28 11:24:31 2020 From: mariatta at python.org (Mariatta) Date: Tue, 28 Jan 2020 08:24:31 -0800 Subject: [docs] Dynamic Data type assignment In-Reply-To: References: Message-ID: input() returns a string. If you want it to be treated as an int you need to cast it, example: num =int(input ("Enter number")) On Tue, Jan 28, 2020, 5:13 AM sushma ms wrote: > Hi > > Please find below example and the compiler error, > > when i'm assigning value dynamically and when we comparing in "if" loop it > is throwing compiler error. It should not throw error it should assign and > act as int why it is thinking as string. > > *Code Snippet:* > print("Hello World") > > num = input("Enter number ") > > print(num) > > if(num%3 == 0): > num+=num > print(num) > > *Output in Console:* > Hello World > Enter number 15 > 15 > Traceback (most recent call last): > File "main.py", line 15, in > if(num%3 == 0): > TypeError: not all arguments converted during string formatting > Created the issue: > msg 360865 created > issue 39476 created > -- > Thanks & Regards, > --------------------------------- > Sushma > Mob:9740055884 > _______________________________________________ > docs mailing list -- docs at python.org > To unsubscribe send an email to docs-leave at python.org > https://mail.python.org/mailman3/lists/docs.python.org/ > From rhodri at kynesim.co.uk Tue Jan 28 12:16:28 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Tue, 28 Jan 2020 17:16:28 +0000 Subject: Dynamic Data type assignment In-Reply-To: References: Message-ID: <0dbb5a9e-5b71-73aa-5b82-1d8b87495305@kynesim.co.uk> On 28/01/2020 12:03, sushma ms wrote: > Hi > > Please find below example and the compiler error, > > when i'm assigning value dynamically and when we comparing in "if" loop it > is throwing compiler error. It should not throw error It absolutely should throw an error. > it should assign and > act as int why it is thinking as string. Because it is a string. The documentation of "input" is quite explicit about this: input([prompt]) If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, EOFError is raised. -- Rhodri James *-* Kynesim Ltd From barry at barrys-emacs.org Tue Jan 28 16:06:21 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Tue, 28 Jan 2020 21:06:21 +0000 Subject: Simple Python github library to push/pull files? In-Reply-To: References: Message-ID: > On 28 Jan 2020, at 16:40, Chris Angelico wrote: > > On Wed, Jan 29, 2020 at 3:38 AM Malcolm Greene wrote: >> >> Any recommendations on a library providing a simple interface to Github > for basic push/pull type of actions? I know there's a native GitHub RESTful > API but wondering if anyone has placed a friendly Python wrapper on top of > that interface? PyGithub supports a rich set of actions, but doesn't appear > to provide support to push/pull files to/from a repo. >> > > Possibly because pulling and pushing aren't GitHub operations, they're > simple git operations. You might be able to find a Python Git library, but > it'd probably be just as easy to subprocess it out directly. Agreed if you only want to push and pull then running git in a subprocess is what you should do. If you'r needing get more complex have a look at GitPython that's on PyPi. I found it was the best git python library when I did the research my SCM workbench app. Barry > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From rmlibre at riseup.net Tue Jan 28 19:14:30 2020 From: rmlibre at riseup.net (rmlibre at riseup.net) Date: Tue, 28 Jan 2020 16:14:30 -0800 Subject: Is asyncio.sleep() necessary when yielding? Message-ID: I'm trying to figure out how the event loop handles switching tasks inside of an async generator, and consequently, the constraints on its calling code. For example: > async def > > > > > > From rmlibre at riseup.net Tue Jan 28 19:27:58 2020 From: rmlibre at riseup.net (rmlibre at riseup.net) Date: Tue, 28 Jan 2020 16:27:58 -0800 Subject: Is asyncio.sleep() necessary when yielding? Message-ID: <9690de2d49b5c05c7861fa1ccd6481e5@riseup.net> (Sorry about the double submission) I'm trying to figure out how the event loop handles switching tasks inside of an async generator, and consequently, the constraints on its calling code. For example: > async def gen(): > for number in range(10 ** 7): > yield number > > > async def consumer(): > numbers = [] > async for number in gen(): > numbers.append(number) > return numbers > The gist of my question is: will consumer block the event loop if iterating over an async generator like the example gen()? In so requiring an await asyncio.sleep(0) call? Or, does the yield statement in an async generator cause the event loop to continue doing the rounds across its scheduled tasks without awaiting asyncio.sleep(0)? From kent.tong.mo at gmail.com Tue Jan 28 22:43:02 2020 From: kent.tong.mo at gmail.com (Kent Tong) Date: Tue, 28 Jan 2020 19:43:02 -0800 (PST) Subject: Interactively online Python learning environment freely available Message-ID: Hi, I've made an online python learning environment available at https://p4kweb.appspot.com Please take a look and let me know what you think :-) From tony.flury at btinternet.com Tue Jan 28 22:30:28 2020 From: tony.flury at btinternet.com (Tony Flury) Date: Wed, 29 Jan 2020 03:30:28 -0000 Subject: on sorting things In-Reply-To: References: Message-ID: <3b1f06aa-4665-9911-045d-a34920818eec@btinternet.com> On 20/12/2019 18:59, Peter Otten wrote: > Chris Angelico wrote: > >> On Sat, Dec 21, 2019 at 5:03 AM Peter Otten <__peter__ at web.de> wrote: >>> PS: If you are sorting files by size and checksum as part of a >>> deduplication effort consider using dict-s instead: >> Yeah, I'd agree if that's the purpose. But let's say the point is to >> have a guaranteed-stable ordering of files that are primarily to be >> sorted by file size - in order to ensure that two files are in the >> same order every time you refresh the view, they get sorted by their >> checksums. > One thing that struck me about Eli's example is that it features two key > functions rather than a complex comparison. > > If sort() would accept a sequence of key functions each function could be > used to sort slices that compare equal when using the previous key. You don't need a sequence of key functions : the sort algorithm used in Python (tim-sort) is stable - which means if two items (A &B) are in a given order in the sequence before the sort starts, and A & B compare equal during the sort, then after the sort A & B retain their ordering. So if you want to sort by file size as the primary and then by checksum if file sizes are equal - you sort by checksum first, and then by file size: this guarantees that the items will always be in file size order - and if file sizes are equal then they will be ordered by checksum. The rule to remember - is sort in the reverse order of criteria. > >> There ARE good reasons to do weird things with sorting, and a custom >> key object (either with cmp_to_key or directly implemented) can do >> that. > Indeed. > From sush0907 at gmail.com Tue Jan 28 22:51:05 2020 From: sush0907 at gmail.com (sushma ms) Date: Wed, 29 Jan 2020 09:21:05 +0530 Subject: [docs] Dynamic Data type assignment In-Reply-To: References: Message-ID: Thanks a lot. But why can't we make output of input also dynamic data assignment. Thanks & Regards, Sushma MS On Tue, Jan 28, 2020, 9:54 PM Mariatta wrote: > input() returns a string. If you want it to be treated as an int you need > to cast it, example: > > num =int(input ("Enter number")) > > On Tue, Jan 28, 2020, 5:13 AM sushma ms wrote: > >> Hi >> >> Please find below example and the compiler error, >> >> when i'm assigning value dynamically and when we comparing in "if" loop >> it is throwing compiler error. It should not throw error it should assign >> and act as int why it is thinking as string. >> >> *Code Snippet:* >> print("Hello World") >> >> num = input("Enter number ") >> >> print(num) >> >> if(num%3 == 0): >> num+=num >> print(num) >> >> *Output in Console:* >> Hello World >> Enter number 15 >> 15 >> Traceback (most recent call last): >> File "main.py", line 15, in >> if(num%3 == 0): >> TypeError: not all arguments converted during string formatting >> Created the issue: >> msg 360865 created >> issue 39476 created >> -- >> Thanks & Regards, >> --------------------------------- >> Sushma >> Mob:9740055884 >> _______________________________________________ >> docs mailing list -- docs at python.org >> To unsubscribe send an email to docs-leave at python.org >> https://mail.python.org/mailman3/lists/docs.python.org/ >> > From PythonList at DancesWithMice.info Tue Jan 28 23:26:20 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Wed, 29 Jan 2020 17:26:20 +1300 Subject: [docs] Dynamic Data type assignment In-Reply-To: References: Message-ID: <1a212fd0-281c-c7d3-fce6-46db8f055606@DancesWithMice.info> On 29/01/20 4:51 PM, sushma ms wrote: > Thanks a lot. > > But why can't we make output of input also dynamic data assignment. 1 please don't 'top post': the normal sequence of a conversation is question THEN answer! 2 ambiguity! It is not possible for the input() mechanism to tell whether you later intend to use the number as int(15) or as "15", ie str(15). Thinking about it, what if the user entered "abc" (there's nothing to stop him/her!); how could that translate to a number? Hence, all input (one assumes, from the keyboard) is taken to be a string. If you want to use it otherwise, then programmatically convert the string into a number (and take care of any errors which may arise). WebRef: https://docs.python.org/3/library/functions.html#input > Thanks & Regards, > Sushma MS > > On Tue, Jan 28, 2020, 9:54 PM Mariatta wrote: > >> input() returns a string. If you want it to be treated as an int you need >> to cast it, example: >> >> num =int(input ("Enter number")) >> >> On Tue, Jan 28, 2020, 5:13 AM sushma ms wrote: >> >>> Hi >>> >>> Please find below example and the compiler error, >>> >>> when i'm assigning value dynamically and when we comparing in "if" loop >>> it is throwing compiler error. It should not throw error it should assign >>> and act as int why it is thinking as string. >>> >>> *Code Snippet:* >>> print("Hello World") >>> >>> num = input("Enter number ") >>> >>> print(num) >>> >>> if(num%3 == 0): >>> num+=num >>> print(num) >>> >>> *Output in Console:* >>> Hello World >>> Enter number 15 >>> 15 >>> Traceback (most recent call last): >>> File "main.py", line 15, in >>> if(num%3 == 0): >>> TypeError: not all arguments converted during string formatting >>> Created the issue: >>> msg 360865 created >>> issue 39476 created >>> -- >>> Thanks & Regards, >>> --------------------------------- >>> Sushma >>> Mob:9740055884 >>> _______________________________________________ >>> docs mailing list -- docs at python.org >>> To unsubscribe send an email to docs-leave at python.org >>> https://mail.python.org/mailman3/lists/docs.python.org/ >>> >> -- Regards =dn From pengyu.ut at gmail.com Wed Jan 29 00:09:59 2020 From: pengyu.ut at gmail.com (Peng Yu) Date: Tue, 28 Jan 2020 23:09:59 -0600 Subject: Is there a character that never appears in the output of zlib.compress? Message-ID: Hi, I'd like to tell what part is zlib.compress data in an input stream. One way is to use some characters that never appear in zlib.compress output to denote the boundary. Are there such characters? Thanks. -- Regards, Peng From pengyu.ut at gmail.com Wed Jan 29 00:27:11 2020 From: pengyu.ut at gmail.com (Peng Yu) Date: Tue, 28 Jan 2020 23:27:11 -0600 Subject: How to read the original data line by line from stdin in python 3 just like python 2? Message-ID: Suppose that I use this to read from stdin. But `line` contains decoded data in python 3. In python 2, it contains the original data. What is the best way to get the original data in python 3? Thanks. ``` for line in sys.stdin: ... ``` -- Regards, Peng From greg.ewing at canterbury.ac.nz Wed Jan 29 00:55:59 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Wed, 29 Jan 2020 18:55:59 +1300 Subject: How to read the original data line by line from stdin in python 3 just like python 2? In-Reply-To: References: Message-ID: On 29/01/20 6:27 pm, Peng Yu wrote: > Suppose that I use this to read from stdin. But `line` contains > decoded data in python 3. In python 2, it contains the original data. > What is the best way to get the original data in python 3? Read from stdin.buffer, which is a stream of bytes. -- Greg From cs at cskk.id.au Wed Jan 29 05:25:37 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 29 Jan 2020 21:25:37 +1100 Subject: Is there a character that never appears in the output of zlib.compress? In-Reply-To: References: Message-ID: <20200129102537.GA14288@cskk.homeip.net> On 28Jan2020 23:09, Peng Yu wrote: >I'd like to tell what part is zlib.compress data in an input stream. >One way is to use some characters that never appear in zlib.compress >output to denote the boundary. Are there such characters? Thanks. If you mean: is there a byte which never appears, then apparently not: [~]fleet*1> python3 testzlib.py ........ where testzlib.py contains this code: from random import randint import sys from zlib import compress unseen = set(range(256)) while unseen: sys.stdout.write('.') sys.stdout.flush() block = bytes(randint(0,255) for _ in range(256)) cdata = compress(block) for c in cdata: unseen.discard(c) sys.stdout.write('\n') From Richard at Damon-Family.org Wed Jan 29 07:31:17 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Wed, 29 Jan 2020 07:31:17 -0500 Subject: Is there a character that never appears in the output of zlib.compress? In-Reply-To: References: Message-ID: <45ccc3b3-7bad-e6c7-19c8-a3dd0b0429a6@Damon-Family.org> On 1/29/20 12:09 AM, Peng Yu wrote: > Hi, > > I'd like to tell what part is zlib.compress data in an input stream. > One way is to use some characters that never appear in zlib.compress > output to denote the boundary. Are there such characters? Thanks. > A compression routine that avoid one byte value would be less efficient at compression then one that uses all the values. An alternative might be to precede the compressed data with a byte count of how much data will follow (as well as whatever file code you use to indicate that the next data IS compressed data. A second method would be to take some byte value, (like FF) and where ever it occurs in the compressed data, replace it with a doubled value FF FF, and then add a single FF to the end. -- Richard Damon From jorge.conforte at inpe.br Wed Jan 29 08:13:29 2020 From: jorge.conforte at inpe.br (J Conrado) Date: Wed, 29 Jan 2020 11:13:29 -0200 Subject: Python 3.8.1 Message-ID: Hi, I installed the Python3.8.1 in my computer. I have other versions 2.6 and? 3.7. When I use 2.6 and 3.7 I didn't have problem with: python2 Python 2.6.6 (r266:84292, Jun 20 2019, 14:14:55) [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> python3.7 Python 3.7.3 | packaged by conda-forge | (default, Jul ?1 2019, 21:52:21) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> import numpy as np But if I type: python3.8 I had the error messages: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import BasemapTraceback (most recent call last): ? File "", line 1, in ModuleNotFoundError: No module named 'numpy' >>> Traceback (most recent call last): ? File "", line 1, in ModuleNotFoundError: No module named 'matplotlib' Please what can I do to solve this erros. Thanks, Conrado From tjreedy at udel.edu Wed Jan 29 09:27:09 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Jan 2020 09:27:09 -0500 Subject: Python 3.8.1 In-Reply-To: References: Message-ID: On 1/29/2020 8:13 AM, J Conrado wrote: > I installed the Python3.8.1 in my computer. I have other versions 2.6 > and? 3.7. When I use 2.6 and 3.7 I didn't have problem with: > > > python2 > Python 2.6.6 (r266:84292, Jun 20 2019, 14:14:55) > [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import numpy as np No matplotlib import here. > python3.7 > Python 3.7.3 | packaged by conda-forge | (default, Jul ?1 2019, 21:52:21) > [GCC 7.3.0] :: Anaconda, Inc. on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import numpy > >>> import numpy as np No matplotlib import here, though Anaconda may include it. > But if I type: > > python3.8 I had the error messages: > > > import numpy as np > import matplotlib.pyplot as plt > from mpl_toolkits.basemap import BasemapTraceback (most recent call last): > ? File "", line 1, in > ModuleNotFoundError: No module named 'numpy' > >>> Traceback (most recent call last): > ? File "", line 1, in > ModuleNotFoundError: No module named 'matplotlib' > > > Please what can I do to solve this erros. Install matplotlib into your 3.8 install. Possibly $ python3.8 -m pip install matplotlib -- Terry Jan Reedy From __peter__ at web.de Wed Jan 29 11:32:40 2020 From: __peter__ at web.de (Peter Otten) Date: Wed, 29 Jan 2020 17:32:40 +0100 Subject: on sorting things References: <3b1f06aa-4665-9911-045d-a34920818eec@btinternet.com> Message-ID: Tony Flury via Python-list wrote: > > On 20/12/2019 18:59, Peter Otten wrote: >> Chris Angelico wrote: >> >>> On Sat, Dec 21, 2019 at 5:03 AM Peter Otten <__peter__ at web.de> wrote: >>>> PS: If you are sorting files by size and checksum as part of a >>>> deduplication effort consider using dict-s instead: >>> Yeah, I'd agree if that's the purpose. But let's say the point is to >>> have a guaranteed-stable ordering of files that are primarily to be >>> sorted by file size - in order to ensure that two files are in the >>> same order every time you refresh the view, they get sorted by their >>> checksums. >> One thing that struck me about Eli's example is that it features two key >> functions rather than a complex comparison. >> >> If sort() would accept a sequence of key functions each function could be >> used to sort slices that compare equal when using the previous key. > > You don't need a sequence of key functions : the sort algorithm used in > Python (tim-sort) is stable - which means if two items (A &B) are in a > given order in the sequence before the sort starts, and A & B compare > equal during the sort, then after the sort A & B retain their ordering. Thank you for explaining that ;) > > So if you want to sort by file size as the primary and then by checksum > if file sizes are equal - you sort by checksum first, and then by file > size: this guarantees that the items will always be in file size order - > and if file sizes are equal then they will be ordered by checksum. > > The rule to remember - is sort in the reverse order of criteria. The idea behind the "sequence of key functions" suggestion is that you only calculate keys[n] where keys[:n] all compared equal. Example: you have 1000 files and among those there are five pairs with equal size. Let's assume calculating the size is instantaneous whereas calculating the checksum takes one second. Then you spend 10 seconds on calculating the keys with my proposal versus 1000 seconds with a naive reliance on stable sorting. From jkn_gg at nicorp.f9.co.uk Wed Jan 29 15:00:50 2020 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Wed, 29 Jan 2020 12:00:50 -0800 (PST) Subject: Suggestions on mechanism or existing code - maintain persistence of file download history Message-ID: Hi all I'm almost embarrassed to ask this as it's "so simple", but thought I'd give it a go... I want to be a able to use a simple 'download manager' which I was going to write (in Python), but then wondered if there was something suitable already out there. I haven't found it, but thought people here might have some ideas for existing work, or approaches. The situation is this - I have a long list of file URLs and want to download these as a 'background task'. I want this to process to be 'crudely persistent' - you can CTRL-C out, and next time you run things it will pick up where it left off. The download part is not difficult. Is is the persistence bit I am thinking about. It is not easy to tell the name of the downloaded file from the URL. I could have a file with all the URLs listed and work through each line in turn. But then I would have to rewrite the file (say, with the previously-successful lines commented out) as I go. I also thought of having the actual URLs as filenames (of zero length) in a 'source' directory. The process would then look at each filename in turn, and download the appropriate URL. Then the 'filename file' would either be moved to a 'done' directory, or perhaps renamed to something that the process wouldn't subsequently pick up. But I would have thought that some utility to do this kind of this exists already. Any pointers? Or any comments on the above suggested methods? Thanks J^n From rosuav at gmail.com Wed Jan 29 15:26:36 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 30 Jan 2020 07:26:36 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Thu, Jan 30, 2020 at 7:06 AM jkn wrote: > > Hi all > I'm almost embarrassed to ask this as it's "so simple", but thought I'd give > it a go... Hey, nothing wrong with that! > I want to be a able to use a simple 'download manager' which I was going to write > (in Python), but then wondered if there was something suitable already out there. > I haven't found it, but thought people here might have some ideas for existing work, or approaches. > > The situation is this - I have a long list of file URLs and want to download these > as a 'background task'. I want this to process to be 'crudely persistent' - you > can CTRL-C out, and next time you run things it will pick up where it left off. A decent project. I've done this before but in restricted ways. > The download part is not difficult. Is is the persistence bit I am thinking about. > It is not easy to tell the name of the downloaded file from the URL. > > I could have a file with all the URLs listed and work through each line in turn. > But then I would have to rewrite the file (say, with the previously-successful > lines commented out) as I go. > Hmm. The easiest way would be to have something from the URL in the file name. For instance, you could hash the URL and put the first few digits of the hash in the file name, so http://some.domain.example/some/path/filename.html might get saved into "a39321604c - filename.html". That way, if you want to know if it's been downloaded already, you just hash the URL and see if any file begins with those digits. Would that kind of idea work? ChrisA From python at mrabarnett.plus.com Wed Jan 29 15:48:01 2020 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 29 Jan 2020 20:48:01 +0000 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On 2020-01-29 20:00, jkn wrote: > Hi all > I'm almost embarrassed to ask this as it's "so simple", but thought I'd give > it a go... > > I want to be a able to use a simple 'download manager' which I was going to write > (in Python), but then wondered if there was something suitable already out there. > I haven't found it, but thought people here might have some ideas for existing work, or approaches. > > The situation is this - I have a long list of file URLs and want to download these > as a 'background task'. I want this to process to be 'crudely persistent' - you > can CTRL-C out, and next time you run things it will pick up where it left off. > > The download part is not difficult. Is is the persistence bit I am thinking about. > It is not easy to tell the name of the downloaded file from the URL. > > I could have a file with all the URLs listed and work through each line in turn. > But then I would have to rewrite the file (say, with the previously-successful > lines commented out) as I go. > Why comment out the lines yourself when the download manager could do it for you? Load the list from disk. For each uncommented line: Download the file. Comment out the line. Write the list back to disk. > I also thought of having the actual URLs as filenames (of zero length) in a > 'source' directory. The process would then look at each filename in turn, and > download the appropriate URL. Then the 'filename file' would either be moved to > a 'done' directory, or perhaps renamed to something that the process wouldn't > subsequently pick up. > > But I would have thought that some utility to do this kind of this exists already. Any pointers? Or any comments on the above suggested methods? > From rosuav at gmail.com Wed Jan 29 15:56:30 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 30 Jan 2020 07:56:30 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Thu, Jan 30, 2020 at 7:49 AM MRAB wrote: > > On 2020-01-29 20:00, jkn wrote: > > I could have a file with all the URLs listed and work through each line in turn. > > But then I would have to rewrite the file (say, with the previously-successful > > lines commented out) as I go. > > > Why comment out the lines yourself when the download manager could do it > for you? > > Load the list from disk. > > For each uncommented line: > > Download the file. > > Comment out the line. > > Write the list back to disk. > Isn't that exactly what the OP was talking about? It involves rewriting the file at every step, with the consequent risks of trampling on other changes, corruption on error, etc, etc, etc. ChrisA From 2QdxY4RzWzUUiLuE at potatochowder.com Wed Jan 29 15:57:27 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Wed, 29 Jan 2020 15:57:27 -0500 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: <20200129155727.65cc6ad793faac6f8b7979c2@potatochowder.com> On Thu, 30 Jan 2020 07:26:36 +1100 Chris Angelico wrote: > On Thu, Jan 30, 2020 at 7:06 AM jkn wrote: > > The situation is this - I have a long list of file URLs and want to > > download these as a 'background task'. I want this to process to be > > 'crudely persistent' - you can CTRL-C out, and next time you run > > things it will pick up where it left off. > A decent project. I've done this before but in restricted ways. > > The download part is not difficult. Is is the persistence bit I am > > thinking about. It is not easy to tell the name of the downloaded > > file from the URL. Where do the names of the downloaded files come from now, and why can't that same algorithm be used later to determine the existence of the file? How much control do you have over this algorithm (which leads to what ChrisA suggested)? > > I could have a file with all the URLs listed and work through each > > line in turn. But then I would have to rewrite the file (say, with > > the previously-successful lines commented out) as I go. Files have that problem. Other solutions, e.g., a sqlite3 database, don't. Also, a database might give you a place to store other information about the URL, such as the name of the associated file. > Hmm. The easiest way would be to have something from the URL in the > file name. For instance, you could hash the URL and put the first few > digits of the hash in the file name, so > http://some.domain.example/some/path/filename.html might get saved > into "a39321604c - filename.html". That way, if you want to know if > it's been downloaded already, you just hash the URL and see if any > file begins with those digits. > Would that kind of idea work? Dan -- ?Atoms are not things.? ? Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan From jkn_gg at nicorp.f9.co.uk Wed Jan 29 16:38:49 2020 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Wed, 29 Jan 2020 13:38:49 -0800 (PST) Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Wednesday, January 29, 2020 at 8:27:03 PM UTC, Chris Angelico wrote: > On Thu, Jan 30, 2020 at 7:06 AM jkn wrote: > > > > Hi all > > I'm almost embarrassed to ask this as it's "so simple", but thought I'd give > > it a go... > > Hey, nothing wrong with that! > > > I want to be a able to use a simple 'download manager' which I was going to write > > (in Python), but then wondered if there was something suitable already out there. > > I haven't found it, but thought people here might have some ideas for existing work, or approaches. > > > > The situation is this - I have a long list of file URLs and want to download these > > as a 'background task'. I want this to process to be 'crudely persistent' - you > > can CTRL-C out, and next time you run things it will pick up where it left off. > > A decent project. I've done this before but in restricted ways. > > > The download part is not difficult. Is is the persistence bit I am thinking about. > > It is not easy to tell the name of the downloaded file from the URL. > > > > I could have a file with all the URLs listed and work through each line in turn. > > But then I would have to rewrite the file (say, with the previously-successful > > lines commented out) as I go. > > > > Hmm. The easiest way would be to have something from the URL in the > file name. For instance, you could hash the URL and put the first few > digits of the hash in the file name, so > http://some.domain.example/some/path/filename.html might get saved > into "a39321604c - filename.html". That way, if you want to know if > it's been downloaded already, you just hash the URL and see if any > file begins with those digits. > > Would that kind of idea work? > > ChrisA Hi Chris Thanks for the idea. I should perhaps have said more clearly that it is not easy (though perhaps not impossible) to infer the name of the downloaded data from the URL - it is not a 'simple' file URL, more of a tag. However I guess your scheme would work if I just hashed the URL and created a marker file - "a39321604c.downloaded" once downloaded. The downloaded content would be separately (and somewhat opaquely) named, but that doesn't matter. MRAB's scheme does have the disadvantages to me that Chris has pointed out. Jon N From PythonList at DancesWithMice.info Wed Jan 29 16:57:23 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 30 Jan 2020 10:57:23 +1300 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: <6e031d06-7ab4-265d-0ae0-ed950b78153f@DancesWithMice.info> On 30/01/20 10:38 AM, jkn wrote: > On Wednesday, January 29, 2020 at 8:27:03 PM UTC, Chris Angelico wrote: >> On Thu, Jan 30, 2020 at 7:06 AM jkn wrote: >>> I want to be a able to use a simple 'download manager' which I was going to write >>> (in Python), but then wondered if there was something suitable already out there. >>> I haven't found it, but thought people here might have some ideas for existing work, or approaches. >>> >>> The situation is this - I have a long list of file URLs and want to download these >>> as a 'background task'. I want this to process to be 'crudely persistent' - you >>> can CTRL-C out, and next time you run things it will pick up where it left off. >> >> A decent project. I've done this before but in restricted ways. >> >>> The download part is not difficult. Is is the persistence bit I am thinking about. >>> It is not easy to tell the name of the downloaded file from the URL. >>> >>> I could have a file with all the URLs listed and work through each line in turn. >>> But then I would have to rewrite the file (say, with the previously-successful >>> lines commented out) as I go. ... > Thanks for the idea. I should perhaps have said more clearly that it is not > easy (though perhaps not impossible) to infer the name of the downloaded data > from the URL - it is not a 'simple' file URL, more of a tag. > > However I guess your scheme would work if I just hashed the URL and created > a marker file - "a39321604c.downloaded" once downloaded. The downloaded content > would be separately (and somewhat opaquely) named, but that doesn't matter. > > MRAB's scheme does have the disadvantages to me that Chris has pointed out. Accordingly, +1 to @Dan's suggestion of a database*: - it can be structured to act as a queue, for URLs yet to be downloaded - when downloading starts, the pertinent row can be updated to include the fileNM in use (a separate field from the URL) - when the download is complete, further update the row with a suitable 'flag' - as long as each write/update is commit-ed, the system will be interrupt-able (^c). Upon resumption, query the DB looking for entries without completion-flags, and re-start/resume the download process. If a downloaded file is (later) found to be corrupt, either add the details to the queue again, or remove the 'flag' from the original entry. This method could also be extended/complicated to work if you (are smart about) implement multiple retrieval threads... * NB I don't use SQLite (in favor of going 'full-fat') and thus cannot vouch for its behavior under load/queuing mechanism/concurrent accesses... but I'm biased and probably think/write SQL more readily than Python - oops! -- Regards =dn From rosuav at gmail.com Wed Jan 29 17:06:06 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 30 Jan 2020 09:06:06 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: <6e031d06-7ab4-265d-0ae0-ed950b78153f@DancesWithMice.info> References: <6e031d06-7ab4-265d-0ae0-ed950b78153f@DancesWithMice.info> Message-ID: On Thu, Jan 30, 2020 at 8:59 AM DL Neil via Python-list wrote: > * NB I don't use SQLite (in favor of going 'full-fat') and thus cannot > vouch for its behavior under load/queuing mechanism/concurrent > accesses... but I'm biased and probably think/write SQL more readily > than Python - oops! I don't use SQLite either, and I always have a PostgreSQL database around that I can use. That said, though, I believe SQLite is fine in terms of reliability; the reason it's a bad choice for concurrency is that it uses large-scale locks to ensure safety, which means that multiple writers will block against each other. But that's fine for this use-case. So my recommendations would be: 1) Something stateless, or where the state is intrinsic to the downloaded files 2) Or failing that, use a database rather than a flat file for your state. ChrisA From souvik.viksou at gmail.com Wed Jan 29 20:11:49 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 30 Jan 2020 06:41:49 +0530 Subject: PyQt5 QLineEditor help!!! Message-ID: Hi guys I just started to learn PyQt5 and was wondering if like kivy we can delete the text in a textbox after taking the input. That is I want to make the textbox blank after the text is read. Also can you suggest a way to connect a cancel button with a function so that when the cancel button is clicked it exists a window. Tank you in advance. From souvik.viksou at gmail.com Wed Jan 29 20:14:58 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 30 Jan 2020 06:44:58 +0530 Subject: Help on dictionaries... Message-ID: Hey I was thinking how I can save a dictionary in python(obviously) so that the script is rerun it automatically loads the dictionary. From torriem at gmail.com Wed Jan 29 20:51:50 2020 From: torriem at gmail.com (Michael Torrie) Date: Wed, 29 Jan 2020 18:51:50 -0700 Subject: Help on dictionaries... In-Reply-To: References: Message-ID: <257457bb-71aa-1c1e-60ef-7b200aa98a10@gmail.com> On 1/29/20 6:14 PM, Souvik Dutta wrote: > Hey I was thinking how I can save a dictionary in python(obviously) so that > the script is rerun it automatically loads the dictionary. You could use the pickle module for that. See the python.org documentation on pickle. Alternatively you could use a json library to write the dict to disk. I think this might be preferable to pickle in many situations. Or serialize the data yourself to a file. From PythonList at DancesWithMice.info Wed Jan 29 20:54:37 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 30 Jan 2020 14:54:37 +1300 Subject: Help on dictionaries... In-Reply-To: References: Message-ID: <27321de1-e0c3-d4f3-fd7b-95d76a9be506@DancesWithMice.info> On 30/01/20 2:14 PM, Souvik Dutta wrote: > Hey I was thinking how I can save a dictionary in python(obviously) so that > the script is rerun it automatically loads the dictionary. Perhaps a YAML or JSON file (which follow a very similar format and structure to Python dicts), or a 'NoSQL' database such as MongoDB. -- Regards =dn From python.list at tim.thechases.com Wed Jan 29 20:33:40 2020 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 29 Jan 2020 19:33:40 -0600 Subject: Help on dictionaries... In-Reply-To: References: Message-ID: <20200129193340.4fc49b25@bigbox.attlocal.net> On 2020-01-30 06:44, Souvik Dutta wrote: > Hey I was thinking how I can save a dictionary in python(obviously) > so that the script is rerun it automatically loads the dictionary. This is almost exactly what the "dbm" (nee "anydbm") module does, but persisting the dictionary out to the disk: import dbm from sys import argv with dbm.open("my_cache", "c") as db: if len(argv) > 1: key = argv[1] if key in db: print("Found it:", db[key]) else: print("Not found. Adding") if len(argv) > 2: value = argv[2] else: value = key db[key] = value else: print("There are %i items in the cache" % len(db)) The resulting "db" acts like a dictionary, but persists. If you really must have the results as a "real" dict, you can do the conversion: real_dict = dict(db) -tkc From torriem at gmail.com Wed Jan 29 20:59:07 2020 From: torriem at gmail.com (Michael Torrie) Date: Wed, 29 Jan 2020 18:59:07 -0700 Subject: PyQt5 QLineEditor help!!! In-Reply-To: References: Message-ID: <2c21c432-3626-af60-4407-df6064230ff5@gmail.com> On 1/29/20 6:11 PM, Souvik Dutta wrote: > Hi guys I just started to learn PyQt5 and was wondering if like kivy we can > delete the text in a textbox after taking the input. That is I want to make > the textbox blank after the text is read. Also can you suggest a way to > connect a cancel button with a function so that when the cancel button is > clicked it exists a window. Tank you in advance. How do you know when the input is done (taken)? If it's from pressing Enter, then you'll probably have to capture that keystroke somehow (is there a signal defined in QWidget that might do that?). If it's from a button press that activates something, then from the button click callback handler you would call clear() on the QLineEditor instance. You can definitely close a window on a cancel button click. If you just want to hide the window for displaying in the future, call setVisible(false) on the window object. If you want to destroy the window object, you would probably call the "destroy()" method of the window, and then delete the python reference to it (either let it go out of scope, or use del on it). From souvik.viksou at gmail.com Wed Jan 29 21:30:37 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 30 Jan 2020 08:00:37 +0530 Subject: Help on dictionaries... In-Reply-To: <27321de1-e0c3-d4f3-fd7b-95d76a9be506@DancesWithMice.info> References: <27321de1-e0c3-d4f3-fd7b-95d76a9be506@DancesWithMice.info> Message-ID: Thank you all. On Thu, Jan 30, 2020, 7:25 AM DL Neil via Python-list < python-list at python.org> wrote: > On 30/01/20 2:14 PM, Souvik Dutta wrote: > > Hey I was thinking how I can save a dictionary in python(obviously) so > that > > the script is rerun it automatically loads the dictionary. > > > Perhaps a YAML or JSON file (which follow a very similar format and > structure to Python dicts), or a 'NoSQL' database such as MongoDB. > > -- > Regards =dn > -- > https://mail.python.org/mailman/listinfo/python-list > From cs at cskk.id.au Wed Jan 29 22:05:48 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Thu, 30 Jan 2020 14:05:48 +1100 Subject: on sorting things In-Reply-To: References: Message-ID: <20200130030548.GA36765@cskk.homeip.net> On 20Dec2019 08:23, Chris Angelico wrote: >On Fri, Dec 20, 2019 at 8:06 AM Eli the Bearded <*@eli.users.panix.com> wrote: >> Consider a sort that first compares file size and if the same number >> of >> bytes, then compares file checksum. Any decently scaled real world >> implementation would memoize the checksum for speed, but only work it out >> for files that do not have a unique file size. The key method requires >> it worked out in advance for everything. >> >> But I see the key method handles the memoization under the hood for you, >> so those simpler, more common sorts of sort get an easy to see benefit. > >I guess that's a strange situation that might actually need this kind >of optimization, but if you really do have that situation, you can >make a magical key that behaves the way you want. [... example implementation ...] The classic situation matching Eli's criteria is comparing file trees for equivalent files, for backup or synchronisation or hard linking purposes; I've a script which does exactly what he describes in terms of comparison (size, then checksum, but I checksum a short prefix before doing a full file checksum, so even more fiddly). However, my example above isn't very amenable to sorts, because you never bother looking at checksums at all for files of different sizes. OTOH, I do sort the files by size before processing the checksum phases, letting one sync/reclaim the big files first for example - a policy choice. Cheers, Cameron Simpson From python at mrabarnett.plus.com Wed Jan 29 22:13:26 2020 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 30 Jan 2020 03:13:26 +0000 Subject: Help on dictionaries... In-Reply-To: <257457bb-71aa-1c1e-60ef-7b200aa98a10@gmail.com> References: <257457bb-71aa-1c1e-60ef-7b200aa98a10@gmail.com> Message-ID: On 2020-01-30 01:51, Michael Torrie wrote: > On 1/29/20 6:14 PM, Souvik Dutta wrote: >> Hey I was thinking how I can save a dictionary in python(obviously) so that >> the script is rerun it automatically loads the dictionary. > > You could use the pickle module for that. See the python.org > documentation on pickle. > > Alternatively you could use a json library to write the dict to disk. I > think this might be preferable to pickle in many situations. > > Or serialize the data yourself to a file. > JSON itself supports only a limited range of types, so additional work is needed, especially when loading, if the dict contains any other types beyond those. From souvik.viksou at gmail.com Thu Jan 30 01:56:23 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 30 Jan 2020 12:26:23 +0530 Subject: Help on dictionaries... In-Reply-To: <20200129193340.4fc49b25@bigbox.attlocal.net> References: <20200129193340.4fc49b25@bigbox.attlocal.net> Message-ID: How do I connect it with my dictionary On Thu, Jan 30, 2020, 7:03 AM Tim Chase wrote: > On 2020-01-30 06:44, Souvik Dutta wrote: > > Hey I was thinking how I can save a dictionary in python(obviously) > > so that the script is rerun it automatically loads the dictionary. > > This is almost exactly what the "dbm" (nee "anydbm") module does, but > persisting the dictionary out to the disk: > > import dbm > from sys import argv > with dbm.open("my_cache", "c") as db: > if len(argv) > 1: > key = argv[1] > if key in db: > print("Found it:", db[key]) > else: > print("Not found. Adding") > if len(argv) > 2: > value = argv[2] > else: > value = key > db[key] = value > else: > print("There are %i items in the cache" % len(db)) > > The resulting "db" acts like a dictionary, but persists. > > If you really must have the results as a "real" dict, you can do the > conversion: > > real_dict = dict(db) > > -tkc > > > > From PythonList at DancesWithMice.info Thu Jan 30 02:40:50 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 30 Jan 2020 20:40:50 +1300 Subject: Was: Dynamic Data type assignment In-Reply-To: <1a212fd0-281c-c7d3-fce6-46db8f055606@DancesWithMice.info> References: <1a212fd0-281c-c7d3-fce6-46db8f055606@DancesWithMice.info> Message-ID: <874b5dc1-3362-7ef2-0e16-a91e53ea61ee@DancesWithMice.info> Further thoughts on the OP's point:- > On 29/01/20 4:51 PM, sushma ms wrote: ... >> But why can't we make output of input also dynamic data assignment. ... >>>> when i'm assigning value dynamically and when we comparing in "if" loop >>>> it is throwing compiler error. It should not throw error it should >>>> assign >>>> and act as int why it is thinking as string. NB am not disputing the facts: > WebRef: https://docs.python.org/3/library/functions.html#input Coincidentally, not long after this list-conversation, I was asked to take a look at a command-line program(me) which was not accepting arguments per spec. First, I dived into the PSL to refresh my memory. There we find all manner of 'goodies' for formatting the cmdLN I/P, selecting its type, defaults, etc, etc. Why do we have this at the cmdLN and yet not have something similar for input? Perhaps there is a small library available (that I've never gone looking to find) which wraps input() and facilitates the input of int[egers], for example? What the OP asks is not really 'out there', we used FORMAT to type INPUT data in FORTRAN, back in the ?good old days! (don't over-excite me or I'll threaten you with my walking-stick...) -- Regards =dn From address at not.available Thu Jan 30 03:35:07 2020 From: address at not.available (R.Wieser) Date: Thu, 30 Jan 2020 09:35:07 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: Message-ID: jkn, > MRAB's scheme does have the disadvantages to me that Chris has pointed > out. Nothing that can't be countered by keeping copies of the last X number of to-be-dowloaded-URLs files. As for rewriting every time, you will /have/ to write something for every action (and flush the file!), if you think you should be able to ctrl-c (or worse) out of the program. But, you could opt to write this sessions successfully downloaded URLs to a seperate file, and only merge that with the origional one program start. That together with an integrity check of the seperate file (eventually on a line-by-line (URL) basis) should make the origional files corruption rather unlikely. A database /sounds/ good, but what happens when you ctrl-c outof a non-atomic operation ? How do you fix that ? IOW: Databases can be corrupted for pretty-much the same reason as for a simple datafile (but with much worse consequences). Also think of the old adagio: "I had a problem, and than I thought I could use X. Now I have two problems..." - with X traditionally being "regular expressions". In other words: do KISS (keep it ....) By the way: The "just write the URLs in a folder" method is not at all a bad one. /Very/ easy to maintain, resilent (especially when you consider the self-repairing capabilities of some filesystems) and the polar opposite of a "customer lock-in". :-) Regards, Rudy Wieser From rosuav at gmail.com Thu Jan 30 03:46:42 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 30 Jan 2020 19:46:42 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Thu, Jan 30, 2020 at 7:41 PM R.Wieser
wrote: > A database /sounds/ good, but what happens when you ctrl-c outof a > non-atomic operation ? How do you fix that ? IOW: Databases can be > corrupted for pretty-much the same reason as for a simple datafile (but with > much worse consequences). Uhh.... Proper databases don't HAVE non-atomic operations. That's kinda their job. Unless you mean that there's a non-atomic operation that consists of placing some kind of "claim" on a URL and then going and downloading it, and finally reporting completion, but that's easily enough handled by simply ensuring that there are no downloader processes running, and then clear any incomplete claims. But that's still not corrupting the database. Maybe you've only ever worked with half-baked apologies for database systems? ChrisA From rosuav at gmail.com Thu Jan 30 03:47:52 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 30 Jan 2020 19:47:52 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Thu, Jan 30, 2020 at 7:41 PM R.Wieser
wrote: > Also think of the old adagio: BTW, the word you want here is "adage", unless you mean that it's a piece of music being played slowly :) ChrisA From address at not.available Thu Jan 30 04:34:18 2020 From: address at not.available (R.Wieser) Date: Thu, 30 Jan 2020 10:34:18 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: Message-ID: Chris, > Uhh.... > > Proper databases don't HAVE non-atomic operations. That's kinda their job. Uhh... yes, /singular/ operations are considered to be atomic. A series of operations /ment/ to be executed as a single one on the other hand aren't. > Unless you mean that there's a non-atomic operation that consists of [snip] >> Also think of the old adagio: "I had a problem, I guess that that went right over your head. :-) /You/ might know exactly what should and shouldn't be done, what makes you think the OP currently does ? > But that's still not corrupting the database. Depending on your definition of corruption. An unreadable file is often described as being corrupt, though the same can be said of a database in an inconsistent state. Regards, Rudy Wieser >> Also think of the old adagio: > > BTW, the word you want here is "adage", unless you mean that > it's a piece of music being played slowly :) Thanks. From rosuav at gmail.com Thu Jan 30 06:37:53 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 30 Jan 2020 22:37:53 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Thu, Jan 30, 2020 at 8:36 PM R.Wieser
wrote: > > Chris, > > > Uhh.... > > > > Proper databases don't HAVE non-atomic operations. That's kinda their job. > > Uhh... yes, /singular/ operations are considered to be atomic. A series of > operations /ment/ to be executed as a single one on the other hand aren't. That's what transactions are for. If you have a series of operations meant to be executed as an atomic operation, you begin a transaction, do the operations, and then commit. Again, that is the *job* of the database. > >> Also think of the old adagio: "I had a problem, > > I guess that that went right over your head. :-) /You/ might know exactly > what should and shouldn't be done, what makes you think the OP currently > does ? > > > But that's still not corrupting the database. > > Depending on your definition of corruption. An unreadable file is often > described as being corrupt, though the same can be said of a database in an > inconsistent state. > If the OP doesn't know how to use a database, that doesn't change my recommendations regarding the use of a database. I don't understand why you're denigrating databases, when basically the only way to mess up transactional integrity is to fail to use them properly, which is something easily learned. The downside of a database is that it might be overkill, but it's safe against corruption. ChrisA From souvik.viksou at gmail.com Thu Jan 30 06:38:29 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 30 Jan 2020 17:08:29 +0530 Subject: Help on PyQt5 !! Message-ID: Hey guys. I might be asking the most childish question. I have a window in pyqt5 (a file in python). Let's call it win1. I have another pyqt5 (another file in python). Let's call it win2. Now win2 is called when add button in win1 is clicked. So far no problem. But win2 has another button called save. When this is called I want a label to appear in win1. How can I do this?? And how can I have a number of labels like this when a certain condition is fulfilled?? Thank you in advance for your help. From address at not.available Thu Jan 30 07:07:40 2020 From: address at not.available (R.Wieser) Date: Thu, 30 Jan 2020 13:07:40 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: Message-ID: Chris, > That's what transactions are for. Again, >> I guess that that went right over your head. :-) /You/ might know >> exactly >> what should and shouldn't be done, what makes you think the OP currently >> does ? > I don't understand why you're denigrating databases, Am I denigrating a nut-and-bolt when glue would be an easier solution ? The problem with most people (programmers included) that they often over-think (and thus over-complicate) stuff. I think that a database is /definitily/ overcomplicating stuff, especially when looking at the OP who's supposed to write and maintain it. Y personal MMV. Regards, Rudy Wieser From rosuav at gmail.com Thu Jan 30 07:34:59 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 30 Jan 2020 23:34:59 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Thu, Jan 30, 2020 at 11:11 PM R.Wieser
wrote: > > Chris, > > > That's what transactions are for. > > Again, > > >> I guess that that went right over your head. :-) /You/ might know > >> exactly > >> what should and shouldn't be done, what makes you think the OP currently > >> does ? > > > I don't understand why you're denigrating databases, > > Am I denigrating a nut-and-bolt when glue would be an easier solution ? > > The problem with most people (programmers included) that they often > over-think (and thus over-complicate) stuff. I think that a database is > /definitily/ overcomplicating stuff, especially when looking at the OP who's > supposed to write and maintain it. Y personal MMV. > Okay, sure... but you didn't say that. You said that a database could become corrupted. If you read back in this thread, you'll see that the first recommendations were NOT about databases, and then databases were offered as an alternative. You then said that they could become corrupted just as files can. This is outright false, and is also not helpful to the discussion. So I responded. But I wasn't advocating for the use of a database; my first and strongest recommendation was, and still is, a stateless system wherein the files themselves are the entire indication of which documents have been downloaded. So what IS your line of argument? ChrisA From 2QdxY4RzWzUUiLuE at potatochowder.com Thu Jan 30 07:44:32 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Thu, 30 Jan 2020 07:44:32 -0500 Subject: Was: Dynamic Data type assignment In-Reply-To: <874b5dc1-3362-7ef2-0e16-a91e53ea61ee@DancesWithMice.info> References: <1a212fd0-281c-c7d3-fce6-46db8f055606@DancesWithMice.info> <874b5dc1-3362-7ef2-0e16-a91e53ea61ee@DancesWithMice.info> Message-ID: <20200130074432.1ed74b8cc5146ca831392038@potatochowder.com> On Thu, 30 Jan 2020 20:40:50 +1300 DL Neil via Python-list wrote: > Why do we have [argparse] at the cmdLN and yet not have something > similar for input? Because argparse works on input, too? Many examples on https://docs.python.org/3/library/argparse.html? explicitly pass a list of strings to parser.parse_args instead of letting that function default to the list of command line arguments. ? e.g., https://docs.python.org/3/library/argparse.html#parents Dan -- ?Atoms are not things.? ? Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan From 2QdxY4RzWzUUiLuE at potatochowder.com Thu Jan 30 08:11:01 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Thu, 30 Jan 2020 08:11:01 -0500 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: <20200130081101.070ba651cad50458badc553b@potatochowder.com> On Thu, 30 Jan 2020 23:34:59 +1100 Chris Angelico wrote: > ... I wasn't advocating for the use of a database; my first and > strongest recommendation was, and still is, a stateless system wherein > the files themselves are the entire indication of which documents have > been downloaded. Yes, I like stateless systems, too, but that system isn't stateless. As I understand the problem of a "crudely persistem download manager," there's a collection of to-be-downloaded URLs (which may be empty) and some data that's been downloaded (which may also be empty). You can certainly encode a lot of that directly in the file system, but it's still state. Using a database instead solves a lot of the tricky bits that the bare file system doesn't (which is what ChrisA said in what I snipped). It's just Greenspun's Tenth Rule with the words C, Fortran, and Common Lisp crossed out and Python and ACID Database written in crayon. Dan -- ?Atoms are not things.? ? Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan From info at wingware.com Thu Jan 30 09:43:37 2020 From: info at wingware.com (Wingware) Date: Thu, 30 Jan 2020 09:43:37 -0500 Subject: ANN: Wing Python IDE 7.2.1.0 released Message-ID: <5E32EB99.1010707@wingware.com> Wing 7.2.1 has been released. This update fixes debug process group termination, avoids failures seen when pasting some Python code, prevents crashing in vi browse mode when the first line of the file is blank, and fixes some other usability issues. For details see the change log: https://wingware.com/pub/wingpro/7.2.1.0/CHANGELOG.txt == Auto-Reformatting with Black and YAPF (Wing Pro) == Wing 7.2 adds support for Black and YAPF for code reformatting, in addition to the previously available built-in autopep8 reformatting. To use Black or YAPF, they must first be installed into your Python with pip, conda, or other package manager. Reformatting options are available from the Source > Reformatting menu group, and automatic reformatting may be configured in the Editor > Auto-reformatting preferences group. Details: https://wingware.com/doc/edit/auto-reformatting == Improved Support for Virtualenv == Wing 7.2 improves support for virtualenv by allowing the command that activates the environment to be entered in the Python Executable in Project Properties, Launch Configurations, and when creating new projects. The New Project dialog now also includes the option to create a new virtualenv along with the new project, optionally specifying packages to install. Details: https://wingware.com/doc/howtos/virtualenv == Support for Anaconda Environments == Similarly, Wing 7.2 adds support for Anaconda environments, so the conda activate command can be entered when configuring the Python Executable and the New Project dialog supports using an existing Anaconda environment or creating a new one along with the project. Details: https://wingware.com/doc/howtos/anaconda == And More == Wing 7.2 also makes it easier to debug modules with python -m, simplifies manual configuration of remote debugging, allows using a command line for the configured Python Executable, and fixes a number of usability issues. For a complete list of new features in Wing 7, see What's New in Wing 7: https://wingware.com/wingide/whatsnew == Downloads == Wing Pro: https://wingware.com/downloads/wing-pro/7.2/binaries Wing Personal: https://wingware.com/downloads/wing-personal/7.2/binaries Wing 101: https://wingware.com/downloads/wing-101/7.2/binaries Compare products: https://wingware.com/downloads See https://wingware.com/doc/install/upgrading for details on upgrading from Wing 6 and earlier, and https://wingware.com/doc/install/migrating for a list of compatibility notes. From address at not.available Thu Jan 30 09:55:42 2020 From: address at not.available (R.Wieser) Date: Thu, 30 Jan 2020 15:55:42 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: Message-ID: Chris, >> I think that a database is /definitily/ overcomplicating stuff, > > Okay, sure... but you didn't say that. I'm sorry ? In my first reply I described a file-based approach and mentioned that the folder approach is a rather good one. What do you think I ment there ? > You said that a database could become corrupted. Yes, I did. Here: [Quote] IOW: Databases can be corrupted for pretty-much the same reason as for a simple datafile (but with much worse consequences). [/quote] Please do notice the part between the brackets. > So what IS your line of argument? To be frank, the fact that you think you should still ask baffles me. I hope that the above clears it up though. Regards, Rudy Wieser From rosuav at gmail.com Thu Jan 30 10:13:15 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 31 Jan 2020 02:13:15 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Fri, Jan 31, 2020 at 2:01 AM R.Wieser
wrote: > > Chris, > > >> I think that a database is /definitily/ overcomplicating stuff, > > > > Okay, sure... but you didn't say that. > > I'm sorry ? In my first reply I described a file-based approach and > mentioned that the folder approach is a rather good one. What do you think > I ment there ? > > > You said that a database could become corrupted. > > Yes, I did. Here: > > [Quote] > IOW: Databases can be corrupted for pretty-much the same reason as for a > simple datafile (but with much worse consequences). > [/quote] > > Please do notice the part between the brackets. Yes, and then you backpedalled furiously when I showed that proper transactions prevent this. After which... I lost track of what you were actually trying to say. So either justify this position, showing that a database can become corrupted the same way a flat file can, in normal use; or explain to me what you're actually arguing here. ChrisA From torriem at gmail.com Thu Jan 30 10:44:10 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 30 Jan 2020 08:44:10 -0700 Subject: Help on PyQt5 !! In-Reply-To: References: Message-ID: <7543e004-a015-8a76-b733-66d65c8f9f4c@gmail.com> On 1/30/20 4:38 AM, Souvik Dutta wrote: > Hey guys. I might be asking the most childish question. I have a window in > pyqt5 (a file in python). Let's call it win1. > I have another pyqt5 (another file in python). Let's call it win2. Now win2 > is called when add button in win1 is clicked. So far no problem. But win2 > has another button called save. When this is called I want a label to > appear in win1. How can I do this?? And how can I have a number of labels > like this when a certain condition is fulfilled?? Thank you in advance for > your help. There are some additional resources you might consider using, and will likely get faster responses with regards to Qt questions. First is the PyQt5 mailing list. https://www.riverbankcomputing.com/mailman/listinfo/pyqt . Also there are the normal Qt forums: https://forum.qt.io/ As to your question, you can add a label to a window the same way you would add the label in the first place. Likely you'll want a QBoxLayout widget to place the label(s) into, with the addWidget() method. Take a look at the Qt docs for signal, methods, etc. https://doc.qt.io/qt-5/qboxlayout.html . For the most part, PyQt5's method calls, signals, and slots, are the same in Python as they are in C++. From address at not.available Thu Jan 30 12:08:57 2020 From: address at not.available (R.Wieser) Date: Thu, 30 Jan 2020 18:08:57 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: Message-ID: Chris, > Yes, and then you backpedalled furiously when I showed that > proper transactions prevent this. You're a fool, out for a fight. /You/ might know exactly how to handle a database to make sure its /transactions/ will not leave the database in a corrupt state, but as I mentioned a few posts back: [quote] I think that a database is /definitily/ overcomplicating stuff, especially when looking at the OP who's supposed to write and maintain it. [/quote] Mind the part after the comma. Also, you happily ignored the part in my second post where I mentioned that corruption can be of a different kind - one that you have absolutily /no/ control over: [quote] An unreadable file is often described as being corrupt [/quote] > I lost track of what you were actually trying to say. Well, all that I wanted to say - to the OP - is in my first reply. You could always try to re-read it. The other posts where just responses to your "that can't be!" challenges to me. > So either justify this position, showing that a database can > become corrupted the same way a flat file can, :-) In the /same/ way ? Thats rather multi-interpretable, don't you think ? Are you trying to set me up ? My point was that the /effect/ of a same corruption is different for both: A flat file is /much/ easier to rescue. But, do you remember what the OP said ? [quote] want to download these as a 'background task'. ... you can CTRL-C out, [/quote] Why now do I think that, when such a backgroud process is forgotten and the 'puter switched off, the file, database or otherwise, could easily get damaged ? And that a ctrl-c at the wrong moment could cause the same if the cleanup (of the database, which could easily still be, in its own thread, busy housekeeping) isn't done correctly. Also, have you /never/ encountered a corrupted file, database or otherwise ? You must not have done much with 'puters at all ... Though I think I'm going to end our conversation here, as you're way more agressive than the subject calls for. Goodbye chris. Have a good life. Regards, Rudy Wieser From rosuav at gmail.com Thu Jan 30 12:14:41 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 31 Jan 2020 04:14:41 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Fri, Jan 31, 2020 at 4:11 AM R.Wieser
wrote: > But, do you remember what the OP said ? > [quote] > want to download these as a 'background task'. ... you can CTRL-C out, > [/quote] > > Why now do I think that, when such a backgroud process is forgotten and the > 'puter switched off, the file, database or otherwise, could easily get > damaged ? And that a ctrl-c at the wrong moment could cause the same if the > cleanup (of the database, which could easily still be, in its own thread, > busy housekeeping) isn't done correctly. > > Also, have you /never/ encountered a corrupted file, database or otherwise ? > You must not have done much with 'puters at all ... > On the contrary, I grew up with IBM DB2 and then PostgreSQL, both of which are actually resilient against power failures. I've also recovered data from crashed hard drives. So, yeah, I think I know what I'm talking about. Sorry. Have a nice day. Enjoy dealing with corruption in places where ordinary best-practices and basic tutorials can prevent it from ever happening. ChrisA From gratefuldeadbertha at gmail.com Thu Jan 30 14:01:05 2020 From: gratefuldeadbertha at gmail.com (gratefuldeadbertha at gmail.com) Date: Thu, 30 Jan 2020 11:01:05 -0800 (PST) Subject: Using Python and scikitlearn, is there a way to return the "feature dependency" percentage? Message-ID: <14e80422-668b-4e3a-934d-9499e3fa81c7@googlegroups.com> Hello, I am relatively new to Python and Machine Learning. I have a basic dataset for insurance fraud and a script that generates the model and runs the predictions. I am able to output the accuracy percentages, but I would like to also output the feature dependencies: For example, what role did each attribute play in the prediction? The policy_number would be 0.0% where as the claim_amount would likely be 56.2%, does this make sense? Is there a scikit function for this? Also, is "feature dependency" even the correct term? Thank you for your help! -Matt From jkn_gg at nicorp.f9.co.uk Thu Jan 30 15:30:20 2020 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Thu, 30 Jan 2020 12:30:20 -0800 (PST) Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: Err, well, thanks for that discussion gents... As it happens I do know how to use a database, but I regard it as overkill for what I am trying to do here. I think a combination of hashing the URL, and using a suffix to indicate the result of previous downloaded attempts, will work adequately for my needs. Thanks again Jon N From PythonList at DancesWithMice.info Thu Jan 30 19:01:28 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 31 Jan 2020 13:01:28 +1300 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: <9d1c662e-c63e-3400-b068-d1834e7f169c@DancesWithMice.info> On 30/01/20 9:35 PM, R.Wieser wrote: >> MRAB's scheme does have the disadvantages to me that Chris has pointed >> out. > Nothing that can't be countered by keeping copies of the last X number of > to-be-dowloaded-URLs files. That's a good idea, but how would the automated system 'know' to give-up on the current file and utilise generation n-1? Unable to open the file or ??? > As for rewriting every time, you will /have/ to write something for every > action (and flush the file!), if you think you should be able to ctrl-c (or > worse) out of the program. Which is the nub of the problem! Using ctrl+c is a VERY BAD idea. Depending upon the sophistication of the solution/existing code, surely there is another way... Even closing/pulling-out the networking connection to cause an exception within Python, would enable management of a more 'clean' and 'data safe' shutdown! (see also 'sledgehammer to crack a nut') Why do you need to abandon the process mid-way? > But, you could opt to write this sessions successfully downloaded URLs to a > seperate file, and only merge that with the origional one program start. > That together with an integrity check of the seperate file (eventually on a > line-by-line (URL) basis) should make the origional files corruption rather > unlikely. What is the OP's definition of "unlikely" or "acceptable risk"? If RDBMS == "unnecessary complexity", then (presumably) 'concern' will be commensurately low, and much of the discussion to-date, moot? I've not worked on 'downloads' (which I take to mean data files, eg forms from the tax office - guess what task I'm procrastinating over?) but have automated the downloading of web page content/headers. There are so many reasons why such won't work first-time, when they should every time; that it may be quite difficult to detect 'corruption' (as distinct from so many of these other issues that may arise)... > A database /sounds/ good, but what happens when you ctrl-c outof a > non-atomic operation ? How do you fix that ? IOW: Databases can be > corrupted for pretty-much the same reason as for a simple datafile (but with > much worse consequences). [apologies for personal comment] I, (with my skill-set, tool-set, collection of utilities, ... - see earlier mention of "bias") reach for an RDBMS more quickly than many*. Mea culpa or 'more power to [my] right arm'? The DB suggestion (posted earlier) involved only a single table, to which fields would be added/populated during processing as a record of progress/status. Thus, replacing the single file that the OP (originally) outlined as fitting his/her needs, with a single DB-table. Accordingly, there is no non-atomic transaction in the proposal - UPDATE is atomic in most (competent) RDBMS. (again, in my ignorance of that project, please don't (anyone) think I'm including/excluding SQLite) Contrarily, if the 'single table idea' is hardly a "database" by most definitions, why bother? The answer lies in the very mechanisms to combat corruptions and interruptions being discussed! As a fundamentally-lazy person, I'd rather leave the RDBMS-coders to wrestle with such complexities 'for me'. Then, I can 'stand on the shoulders' of such 'giants', by driving their (competently working) 'black box'... (YMMV!) Now, it transpires, the OP possesses DB skills. So, (s)he is in a position to make the go/no decision which suits the actual spec. Yahoo! (not TM) > Also think of the old adagio: "I had a problem, and than I thought I could > use X. Now I have two problems..." - with X traditionally being "regular > expressions". In other words: do KISS (keep it ....) Good point! (I'm not a great fan of RegEx-es either) - reduce/avoid complexity, "simple is better than complex"! (Python: import this) Surely though, it is only appropriate to dive into the concerns and complexities of DB accuracy and "consistency", if we do likewise with file systems? The rationale of my 'laziness' argument 'for' using an RDBMS, also applies to plain-vanilla file systems. Do I want to deal with the complexities of managing files and corruptions, in that arena? (you could easily guess the answer to that!) Do you? (the answer may be quite different - but no matter, I'm not going to say you are "wrong", as long as in making such a decision (files?DB) we compare 'like with like' - in fact, before that: as long as the client's spec says that we need to be worrying about such detail! (otherwise YAGNI applies!) > By the way: The "just write the URLs in a folder" method is not at all a bad > one. /Very/ easy to maintain, resilent (especially when you consider the > self-repairing capabilities of some filesystems) and the polar opposite of a > "customer lock-in". :-) +1 Be aware that formation rules for URLs are not congruent with OS FS rules! (such concerns don't apply if the URLs are data within a file/table) * was astonished to discover (a show-of-hands poll at some conference or other) that 'the average applications programmer' dislikes SQL/RDBMS and would rather have 'someone else' handle that side of things. Most of those ascribed their attitude to not having been able to 'get [their] heads around SQL' - which left me baffled because I 'just see it'. However, my mental processes have been queried (more than once)! Upon reflection, this 'discovery' made me happy - found me another niche to occupy... -- Regards =dn From souvik.viksou at gmail.com Thu Jan 30 22:34:48 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 31 Jan 2020 09:04:48 +0530 Subject: QTableWidget help!! Message-ID: Hi, I want to add a QTableWidget to an existing window with other labels and button. How can I add the QTableWidget without having to set it as centralwidget and be able to move it and set geometry. Because I am not being able to move the central widget by using self.centralwidget.setGeometry . The error is cannot find reference. Please advise. From address at not.available Fri Jan 31 02:47:54 2020 From: address at not.available (R.Wieser) Date: Fri, 31 Jan 2020 08:47:54 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: <9a263fd9psfie239ilpfcjjoo9rlb92jjk@4ax.com> Message-ID: Dennis, > A full client/server RDBM should never be affected by an abort > of a client program. What you describe is on the single query level. What I was thinking of was having several queries that /should/ work as a single unit, but could get interrupted (because of the OPs ctrl-c). Yes, Chris was probably right about using a transaction to fix that, but that has to be learned - knowledge I do not take for granted with a hobbyist. > So... (And I know many despise it, but it IS easy to set up) that > leaves running ...some ... server process. I think that would make the matter even worse. It could be silently doing some housekeeping work, and a hard shutdown of the 'puter (for whatever reason) could easily trash the whole database. And yes, I'm playing the advocate of the devil there. :-) Regards, Rudy Wieser From address at not.available Fri Jan 31 03:53:09 2020 From: address at not.available (R.Wieser) Date: Fri, 31 Jan 2020 09:53:09 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: <9d1c662e-c63e-3400-b068-d1834e7f169c@DancesWithMice.info> Message-ID: DL, >> Nothing that can't be countered by keeping copies of the last X number of >> to-be-dowloaded-URLs files. > > That's a good idea, but how would the automated system 'know' to give-up > on the current file and utilise generation n-1? Unable to open the file or > ??? Well, that would be one reason for it. But there was also talk about integrity checking, both on the file and URL-entry level. Failing any of that could trigger it. But to be honest, I would not even automate it. Such a situation should not occur often, if at all. So having it is cause for concern, and should be investigated. Instead I would give the user an error message, and offer him the list of older files to choose one from to continue with (or have him specify the file on the commandline). > Using ctrl+c is a VERY BAD idea. To have it just exit the program ? Yes, indeed. Though you /could/ keep track of what needs to be finished and have the ctrl-c handler do that for you (barf). Another posibility is to capture the ctrl-c and set a flag, which than instructs the program to terminate loops wherever possible - and thus have the program finish as if there was no more to do. > (see also 'sledgehammer to crack a nut') While I agree with you there, I've been searching for other ways to detect a keypress (in a console-based script) and have found none. IOW, you do not (seem to) have another option. > Why do you need to abandon the process mid-way? Take your pick. Mostly because of "I need to leave *now*". Or perhaps because of an "you have X seconds before the device shuts down because of the battery being low" situation. > What is the OP's definition of "unlikely" or "acceptable risk"? Good question, but one I had no wish for to try to ascertain. I just gave some "worst case" secenario based replies (aka, the "did you think of situation" kind). > There are so many reasons why such won't work first-time, when they should > every time; that it may be quite difficult to detect 'corruption' :-) That was not even considered. Just the "what do I still need to download" datafile. > Accordingly, there is no non-atomic transaction in the proposal The problem there is that you are second-guessing to what the OP will be writing, and that it will be good. I didn't and I don't assume that. I've seen too much "it works, so its good" noobie code. :-) > Do I want to deal with the complexities of managing files and corruptions, > in that arena? ... > Do you? :-) Its was-and-is not my choice to make. I gave the OP some stuff to think about, and left making the choice upto him. All three of the presented options are viable. > Be aware that formation rules for URLs are not congruent with OS FS rules! Yup. Though I seldom see that happen. Though I guess I should have mentioned that ... :-| Regards, Rudy Wieser From rosuav at gmail.com Fri Jan 31 04:04:57 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 31 Jan 2020 20:04:57 +1100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: <9a263fd9psfie239ilpfcjjoo9rlb92jjk@4ax.com> Message-ID: On Fri, Jan 31, 2020 at 7:56 PM R.Wieser
wrote: > > Dennis, > > > A full client/server RDBM should never be affected by an abort > > of a client program. > > What you describe is on the single query level. What I was thinking of was > having several queries that /should/ work as a single unit, but could get > interrupted (because of the OPs ctrl-c). > > Yes, Chris was probably right about using a transaction to fix that, but > that has to be learned - knowledge I do not take for granted with a > hobbyist. > Do you also permit people to drive cars without knowing about the handbrake? When you start using a database, you have to learn how to speak its language (usually SQL). Transactions are part of that. What is so hard about this? They're not some esoteric thing that only a few people use. EVERY request to a PostgreSQL database (and many other DBMSes) is part of a transaction, whether implicit or explicit. I Googled "postgres python tutorial". The first hit was https://www.postgresqltutorial.com/postgresql-python/ and it mentions transactions in the very first section, on connecting to the database. Second hit: https://pynative.com/python-postgresql-tutorial/ - the word "transaction" comes up on the landing page, albeit part way down; but the first example that does any mutation does use an explicit commit. I didn't check for SQLAlchemy but it's likely the same. Use transactions. Learn them. ChrisA From address at not.available Fri Jan 31 04:40:55 2020 From: address at not.available (R.Wieser) Date: Fri, 31 Jan 2020 10:40:55 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: Message-ID: jkn, > I think a combination of hashing the URL, I hope you're not thinking of saving the hash (into the "done" list) instead if the URL itself. While hash collisions do not happen often (especially not in a small list), you cannot rule them out. And when that happens that would mean you would be skipping downloads ... Regards, Rudy Wieser From jorge.conforte at inpe.br Fri Jan 31 07:15:07 2020 From: jorge.conforte at inpe.br (J Conrado) Date: Fri, 31 Jan 2020 10:15:07 -0200 Subject: Python3.8.1 basemap Message-ID: <44e7ca9b-0d5f-5ee6-5271-b267d4532d0b@inpe.br> Hi, I installed the Python3.8.1 and I run the example of basemap gallery: https://matplotlib.org/basemap/users/examples.html plotgreatcircle.py for Python3.8 plotgreatcircle.py I had: Traceback (most recent call last): ? File "plotgreatcircle.py", line 1, in ? ? from mpl_toolkits.basemap import Basemap ModuleNotFoundError: No module named 'mpl_toolkits' for Python3.7 plotgreatcircle.py It is ok. Please, what what can I do to solve this error for Python3.8. Thanks, From jkn_gg at nicorp.f9.co.uk Fri Jan 31 09:18:12 2020 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Fri, 31 Jan 2020 06:18:12 -0800 (PST) Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: <28e4d65c-e7fb-4019-b488-bb2c9659fc76@googlegroups.com> On Friday, January 31, 2020 at 9:41:32 AM UTC, R.Wieser wrote: > jkn, > > > I think a combination of hashing the URL, > > I hope you're not thinking of saving the hash (into the "done" list) instead > if the URL itself. While hash collisions do not happen often (especially > not in a small list), you cannot rule them out. And when that happens that > would mean you would be skipping downloads ... > > Regards, > Rudy Wieser Hi Rudy From jkn_gg at nicorp.f9.co.uk Fri Jan 31 09:19:24 2020 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Fri, 31 Jan 2020 06:19:24 -0800 (PST) Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On Friday, January 31, 2020 at 9:41:32 AM UTC, R.Wieser wrote: > jkn, > > > I think a combination of hashing the URL, > > I hope you're not thinking of saving the hash (into the "done" list) instead > if the URL itself. While hash collisions do not happen often (especially > not in a small list), you cannot rule them out. And when that happens that > would mean you would be skipping downloads ... > > Regards, > Rudy Wieser I'm happy to consider the risk and choose (eg.) the hash function accordingly, thanks. Jon N From address at not.available Fri Jan 31 09:51:18 2020 From: address at not.available (R.Wieser) Date: Fri, 31 Jan 2020 15:51:18 +0100 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history References: Message-ID: jkn, > I'm happy to consider the risk and choose (eg.) the hash function > accordingly, thanks. No problem, just wanted you to be aware and (thus) able to choose. Regards, Rudy Wieser From souvik.viksou at gmail.com Fri Jan 31 07:05:52 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 31 Jan 2020 17:35:52 +0530 Subject: Please answer fast..... Message-ID: Hi, This is problem from pyqt5. Actually I want to have about 40 labels added into a window when a button is clicked. The text are not the same so the label is not the same. I cannot just add 40 labels before hand and then change its text to something from a qlineedit. Please say me something that is more efficient and less idiot like. Thank you. From arj.python at gmail.com Fri Jan 31 14:06:25 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 31 Jan 2020 23:06:25 +0400 Subject: QTableWidget help!! In-Reply-To: References: Message-ID: QTableView is recommended, what pyqt version are you using? On Fri, 31 Jan 2020, 07:35 Souvik Dutta, wrote: > Hi, > I want to add a QTableWidget to an existing window with other labels and > button. How can I add the QTableWidget without having to set it as > centralwidget and be able to move it and set geometry. Because I am not > being able to move the central widget by using > self.centralwidget.setGeometry . The error is cannot find reference. Please > advise. > -- > https://mail.python.org/mailman/listinfo/python-list > From barry at barrys-emacs.org Fri Jan 31 15:44:19 2020 From: barry at barrys-emacs.org (Barry) Date: Fri, 31 Jan 2020 20:44:19 +0000 Subject: QTableWidget help!! In-Reply-To: References: Message-ID: <9260CB27-3176-4574-A5E9-1968A9D76085@barrys-emacs.org> > On 31 Jan 2020, at 03:38, Souvik Dutta wrote: > > ?Hi, > I want to add a QTableWidget to an existing window with other labels and > button. How can I add the QTableWidget without having to set it as > centralwidget and be able to move it and set geometry. Because I am not > being able to move the central widget by using > self.centralwidget.setGeometry . The error is cannot find reference. Please > advise. Sounds like you have discover layouts yet. Have read about them: https://doc.qt.io/qt-5/examples-layouts.html Barry > -- > https://mail.python.org/mailman/listinfo/python-list > From PythonList at DancesWithMice.info Fri Jan 31 23:11:35 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Sat, 1 Feb 2020 17:11:35 +1300 Subject: Suggestions on mechanism or existing code - maintain persistence of file download history In-Reply-To: References: Message-ID: On 31/01/20 9:30 AM, jkn wrote: > Err, well, thanks for that discussion gents... > > As it happens I do know how to use a database, but I regard it as overkill for > what I am trying to do here. I think a combination of hashing the URL, > and using a suffix to indicate the result of previous downloaded attempts, will > work adequately for my needs. > > Thanks again > Jon N Don't let the, um, robust discussion concern you. Certainly you bear no responsibility. As elsewhere, your understanding of 'the problem' is more complete than any of us can claim. Accordingly, your 'answer' is the correct one! Should you 'fail fast, and fail often', then you have other courses that may be worth considering... Speaking personally, I find a lot to be learned from reading what different folk have to say, and taking benefit from their experiences and different ways of looking at the same thing. It's worth remembering that not everyone comes across in email as a mild-mannered, absent-minded, over-stereotyped, British boffin. There is/was a London PUG Discussion List, just as there likely are for other British groups/localities. I don't recall a recent posting - or maybe they've ex-communicated me for requiring them to shout very (very) loudly to reach me... Thanks for the challenge! -- Regards =dn