From antoon.pardon at vub.be Thu Oct 1 02:59:37 2020 From: antoon.pardon at vub.be (Antoon Pardon) Date: Thu, 1 Oct 2020 08:59:37 +0200 Subject: Faking stdlib Message-ID: <8710103e-2190-e21f-fd21-0009bb59c3fe@vub.be> I'm playing with the following idea. Have the main program do some kind of preparations so that all further modules can import the standard modules via stdlib. So instead of import sys from itertools import chain I could do import stdlib.sys from stdlib.itertools import chain -- Antoon Pardon From pierre.bonville49 at gmail.com Thu Oct 1 03:05:17 2020 From: pierre.bonville49 at gmail.com (Pierre Bonville) Date: Thu, 1 Oct 2020 09:05:17 +0200 Subject: Interference tkinter and plot from matplotlib In-Reply-To: References: Message-ID: Thank you, Mr. Gollwitzer. I understand the problem. I'll see what I can do. Regards, P.Bonville Le mer. 30 sept. 2020 ? 17:02, Christian Gollwitzer a ?crit : > Am 30.09.20 um 15:46 schrieb Pierre Bonville: > > Hi everybody, > > > Interference tkinter and plot from matplotlib > > > You are mixing different ways of control flow. In a GUI program, don't > call input(). Use the mainloop() as the very last of your calls, and > only work in the callbacks. That means you would integrate a "Next" > button in your GUI which switches the plots - or even show them side by > side. > > Concerning matplotlib, you'll need to tell it to integrate with Tk > properly. > > https://matplotlib.org/3.3.1/gallery/user_interfaces/embedding_in_tk_sgskip.html > > > If you want a simple solution instead of full-blown GUI programming, use > IPython https://ipython.readthedocs.io/en/stable/config/eventloops.html > or jupyter notebooks. > > > Christian > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Thu Oct 1 03:17:07 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 1 Oct 2020 17:17:07 +1000 Subject: Faking stdlib In-Reply-To: <8710103e-2190-e21f-fd21-0009bb59c3fe@vub.be> References: <8710103e-2190-e21f-fd21-0009bb59c3fe@vub.be> Message-ID: On Thu, Oct 1, 2020 at 5:02 PM Antoon Pardon wrote: > > I'm playing with the following idea. > > Have the main program do some kind of preparations so that all further > modules can import the standard modules via stdlib. So instead of > > import sys > from itertools import chain > > I could do > > import stdlib.sys > from stdlib.itertools import chain > My first thought was __getattr__ on a package, but that doesn't seem to work: # stdlib/__init__.py def __getattr__(name): return __import__(name) >>> import stdlib.math Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'stdlib.math' >>> from stdlib import math >>> math It may be necessary to use an import hook. ChrisA From arj.python at gmail.com Thu Oct 1 03:59:08 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 1 Oct 2020 11:59:08 +0400 Subject: Faking stdlib In-Reply-To: <8710103e-2190-e21f-fd21-0009bb59c3fe@vub.be> References: <8710103e-2190-e21f-fd21-0009bb59c3fe@vub.be> Message-ID: The last time this was raised, it seemed that folks in here don't have a clear idea of what the standard library is ^^ https://mail.python.org/archives/list/python-ideas at python.org/thread/XSYEVRPJQUX7VBTPNIJMUFZQIZ7WLOQU/ A summary: https://lwn.net/Articles/794458/ Kind Regards, Abdur-Rahmaan Janhangeer https://www.github.com/Abdur-RahmaanJ Mauritius sent from gmail client on Android, that's why the signature is so ugly. From sh at changeset.nyc Thu Oct 1 06:29:56 2020 From: sh at changeset.nyc (Sumana Harihareswara) Date: Thu, 1 Oct 2020 06:29:56 -0400 Subject: Pip users: big change coming this month In-Reply-To: <3dc20496-47de-436f-9328-4699bfcdeaca@changeset.nyc> References: <3dc20496-47de-436f-9328-4699bfcdeaca@changeset.nyc> Message-ID: <28686f1c-eeef-8026-aa99-68d13c4007be@changeset.nyc> Changes are coming to pip, Python's package installation tool, in October 2020. Please read and share this migration guide: https://pip.pypa.io/en/latest/user_guide/#changes-to-the-pip-dependency-resolver-in-20-2-2020 . We're working on improving the Python packaging toolchain, foundational work that will (in the long run) make the whole Python package installation experience way less confusing. The pip team made a 2-minute video to explain what's up: https://youtu.be/B4GQCBBsuNU We are also doing user experience studies, and want you to sign up if you ever do anything with Python (whatever your level of skill/experience): http://www.ei8fdb.org/thoughts/2020/03/pip-ux-study-recruitment/ https://mastodon.social/@brainwane/104950044427849411 is a good toot to boost, and https://twitter.com/ThePSF/status/1311038036013199363 is a good tweet to retweet, if you want to help us get the word out. MORE DETAILS: at the migration guide at https://pip.pypa.io/en/latest/user_guide/#changes-to-the-pip-dependency-resolver-in-20-2-2020 . On 7/30/20 10:58 AM, Sumana Harihareswara wrote: > On behalf of the Python Packaging Authority, I am pleased to announce > that we have just released pip 20.2, a new version of pip. You can > install it by running python -m pip install --upgrade pip. -- Sumana Harihareswara Changeset Consulting https://changeset.nyc From sjeik_appie at hotmail.com Thu Oct 1 09:33:16 2020 From: sjeik_appie at hotmail.com (sjeik_appie at hotmail.com) Date: Thu, 01 Oct 2020 15:33:16 +0200 Subject: Hot reload Flask app? Message-ID: Hi, I would like to create a "/reload" view in my Flask app, so I could easily and safely reload it when code, templates etc change. Similar to what happens when running the app with the debug server. I am using Nginx and Gevent on a recent Ubuntu system with Python 3.6. My strategy would be to gracefully stop Gevent [1], then do os.kill(os.getpid(), signal.SIGHUP). I have not yet tried this (not working today!). Just wondering if there are best practices. Thanks! Albert-Jan [1] http://www.gevent.org/api/gevent.baseserver.html#gevent.baseserver.BaseServer.stop From saishubhamray at gmail.com Thu Oct 1 07:29:05 2020 From: saishubhamray at gmail.com (Sai Shubham Ray) Date: Thu, 1 Oct 2020 16:59:05 +0530 Subject: Why is Python deleting every time Message-ID: Sometimes when I try to run python program it says that python is not installed and I have to repair it. Thank god there is a repair option in python but still do something to get rid of this problem Regards Sai Shubham Ray From phd at phdru.name Thu Oct 1 11:29:17 2020 From: phd at phdru.name (Oleg Broytman) Date: Thu, 1 Oct 2020 17:29:17 +0200 Subject: SQLObject 3.8.1 Message-ID: <20201001152917.GA24396@phdru.name> Hello! I'm pleased to announce version 3.8.1, the first bugfix release of branch 3.8 of SQLObject. What's new in SQLObject ======================= The contributor for this release is Neil Muller. Documentation ------------- * Use conf.py options to exclude sqlmeta options. Tests ----- * Fix ``PyGreSQL`` version for Python 3.4. CI -- * Run tests with Python 3.8 at AppVeyor. For a more complete list, please see the news: http://sqlobject.org/News.html What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Python 2.7 or 3.4+ is required. Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Download: https://pypi.org/project/SQLObject/3.8.1a0.dev20191208/ News and changes: http://sqlobject.org/News.html StackOverflow: https://stackoverflow.com/questions/tagged/sqlobject Example ======= Create a simple class that wraps a table:: >>> from sqlobject import * >>> >>> sqlhub.processConnection = connectionForURI('sqlite:/:memory:') >>> >>> class Person(SQLObject): ... fname = StringCol() ... mi = StringCol(length=1, default=None) ... lname = StringCol() ... >>> Person.createTable() Use the object:: >>> p = Person(fname="John", lname="Doe") >>> p >>> p.fname 'John' >>> p.mi = 'Q' >>> p2 = Person.get(1) >>> p2 >>> p is p2 True Queries:: >>> p3 = Person.selectBy(lname="Doe")[0] >>> p3 >>> pc = Person.select(Person.q.lname=="Doe").count() >>> pc 1 Oleg. -- Oleg Broytman https://phdru.name/ phd at phdru.name Programmers don't die, they just GOSUB without RETURN. From roland.em0001 at googlemail.com Thu Oct 1 11:58:20 2020 From: roland.em0001 at googlemail.com (=?UTF-8?Q?Roland_M=c3=bcller?=) Date: Thu, 1 Oct 2020 18:58:20 +0300 Subject: Hot reload Flask app? In-Reply-To: References: Message-ID: On 2020-10-01 16:33, sjeik_appie at hotmail.com wrote: > Hi, > I would like to create a "/reload" view in my Flask app, so I could easily > and safely reload it when code, templates etc change. Similar to what > happens when running the app with the debug server. I am using Nginx and > Gevent on a recent Ubuntu system with Python 3.6. > My strategy would be to gracefully stop Gevent [1], then do > os.kill(os.getpid(), signal.SIGHUP). I have not yet tried this (not > working today!). Just wondering if there are best practices. > Thanks! > Albert-Jan > [1] > http://www.gevent.org/api/gevent.baseserver.html#gevent.baseserver.BaseServer.stop Running flask app.run(debug=True) will make the Flask server watching the filesystem for source code changes and re-deploy your app. https://pythonhosted.org/Flask-Debug/ -Roland From dieter at handshake.de Thu Oct 1 13:06:29 2020 From: dieter at handshake.de (Dieter Maurer) Date: Thu, 1 Oct 2020 19:06:29 +0200 Subject: A library that converts a type-annotated function into a webpage with HTML forms? In-Reply-To: References: Message-ID: <24438.3221.319653.538648@ixdm.fritz.box> James Lu wrote at 2020-9-30 16:45 -0400: >Is there a python library available that converts a type-annotated Python >function into a webpage with HTML forms? > >Something like: > > >def foo(name: str, times: int): > return f"Hello {name}!" * times > >serve_from(foo, host="0.0.0.0", port=3000) > >Turning into a server that serves something like this: > >
> > > >
> >And hitting the submit button executes the function. You could have a look at "pydoc" ("the Python documentation tool"). As the name indicates, it is for documentation not for the execution of funtions (which may be **VERY** dangerous). But it can show you how to integrate an HTTP server and how to use Python's `inpect` module to determine function signatures. You would need to create the forms yourself and the function execution actions (and again: executing arbitrary functions is really dangerous -- do not do it!). From tjreedy at udel.edu Thu Oct 1 12:42:03 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 1 Oct 2020 12:42:03 -0400 Subject: Why is Python deleting every time In-Reply-To: References: Message-ID: On 10/1/2020 7:29 AM, Sai Shubham Ray wrote: > Sometimes when I try to run python program it says that python is not > installed and I have to repair it. Because you are running the Python installer instead of Python itself after having it installed. > Thank god there is a repair option in > python but still do something to get rid of this problem Delete the Python installer and you cannot run it. If you ever do need to repair, you can redownload. Or rename the installation program (if you can) to something like 'Install Python x.y'. -- Terry Jan Reedy From luisaraujo.ifba at gmail.com Thu Oct 1 15:06:51 2020 From: luisaraujo.ifba at gmail.com (Luis Gustavo Araujo) Date: Thu, 1 Oct 2020 16:06:51 -0300 Subject: List of All Error Menssages In-Reply-To: References: Message-ID: Hi, Is it possible to get the list of all error messages that display in Python? I want the full message -> type error: additional message. Examples: NameError: name 'x' is not defined IndentationError: unindent does not match any outer indentation level In this webpage (ttps://docs.python.org/3/library/exceptions.html) I only can check the type error. []s Em qui., 1 de out. de 2020 ?s 15:59, Luis Gustavo Araujo < luisaraujo.ifba at gmail.com> escreveu: > Hi, > Is it possible to get the list of all error messages that display in > Python? I want the full message -> type error: additional message. > > Examples: > NameError: name 'x' is not defined > IndentationError: unindent does not match any outer indentation level > > In this webpage (ttps://docs.python.org/3/library/exceptions.html) I only > can check the type error. > > []s > > > -- > > [image: Prefeitura Municipal de Am?lia Rodrigues] > > > LUIS GUSTAVO ARAUJO > *Am?lia Rodrigues Prefecture - Brazil (* > > *Teacher of Computer Science) UNIFACS - Laureate International > Universities (Professor Assistant I)* > > Degree in Computer Science (IFBA) - 2015 > Master Degrees in Computer Applied (UEFS) - 2018 > PhD Student in Computer Science (UFBA) > *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634 > * > > [image: Twitter] [image: Facebook] > [image: Github] > > > > > > Livre > de v?rus. www.avast.com > . > <#m_-2814426795322638799_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > -- [image: Prefeitura Municipal de Am?lia Rodrigues] LUIS GUSTAVO ARAUJO *Am?lia Rodrigues Prefecture - Brazil (* *Teacher of Computer Science) UNIFACS - Laureate International Universities (Professor Assistant I)* Degree in Computer Science (IFBA) - 2015 Master Degrees in Computer Applied (UEFS) - 2018 PhD Student in Computer Science (UFBA) *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634 * [image: Twitter] [image: Facebook] [image: Github] From ch.nagaraju008 at gmail.com Thu Oct 1 15:41:25 2020 From: ch.nagaraju008 at gmail.com (Raju) Date: Thu, 1 Oct 2020 12:41:25 -0700 (PDT) Subject: Regex Group case change Message-ID: Hello Everyone, I want to change the case on input string i was able to match using python regex but couldn't find the way to change the case. For example string: Input: 7Section Hello Jim output: 7Section hello Jim I was doing if statment with regex if re.match("(\d+\w* )(Hello)( \w+)",string)): print(r"(\d+\w* )(Hello)( \w+)","\1\2.lower()\3",string) Output was 7Section \2.lower() Jim Above one is one of the regex i have in function, i have total 6 regex patterns and i want to keep all in this if elif else statment. It is matching, but can someone advise how to replace Hello to hello? Thanks From mirkok.lists at googlemail.com Thu Oct 1 16:09:49 2020 From: mirkok.lists at googlemail.com (Mirko) Date: Thu, 1 Oct 2020 22:09:49 +0200 Subject: Problem In-Reply-To: References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> Message-ID: <5F76378D.4080107@googlemail.com> Am 30.09.2020 um 23:44 schrieb Chris Angelico: > On Thu, Oct 1, 2020 at 7:33 AM Mirko via Python-list >> We are seeing these troubles from newcomers on Windows all of the >> time -- and that for years. Isn't it time to ask if the way Python >> installs itself on Windows-Systems is appropriate? >> > > The problem is that there isn't "the way". Did the person: > > 1) Download an MSI file from python.org? > 2) Install ActiveState? > 3) Install Enthought? > 4) Install Anaconda? > 5) Get Python from the Microsoft Store? > 6) Something else? > > They're all different, they all behave differently, they all have > different defaults. And then there's the question of "did you install > it for everyone or just you?", and so on. > > The core Python devs have control of the first option, and some > control over the fifth, but none of the others. Yes, but usability improvements for the one from python.org could be later adopted by the other distributors. I think, that you are jumping from "How to improve the current situation?" to "How to make it absolutely perfect?" That's a sure path into the incapacity to act. I'm not talking about solving all the problems that newcomers have, but reducing them. Eryk Sun suggested to rename the installer to a more explicit filename. Will that solve all the problems? No. But it reduces the troubles by solving one particular case. Renaming "IDLE" to "Python IDE" (or similar) might also. Adding desktop icons for it or have a "Start the Python Editor (IDLE) now" button/checkbox at the end of the installation also. > So, go ahead, ask if it's appropriate.... good luck getting a useful response :| Well, I am not the one who needs to answer those beginner questions time and time again. ;-) From rosuav at gmail.com Thu Oct 1 16:17:10 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 2 Oct 2020 06:17:10 +1000 Subject: Problem In-Reply-To: <5F76378D.4080107@googlemail.com> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> <5F76378D.4080107@googlemail.com> Message-ID: On Fri, Oct 2, 2020 at 6:11 AM Mirko via Python-list wrote: > > Am 30.09.2020 um 23:44 schrieb Chris Angelico: > > On Thu, Oct 1, 2020 at 7:33 AM Mirko via Python-list > > >> We are seeing these troubles from newcomers on Windows all of the > >> time -- and that for years. Isn't it time to ask if the way Python > >> installs itself on Windows-Systems is appropriate? > >> > > > > The problem is that there isn't "the way". Did the person: > > > > 1) Download an MSI file from python.org? > > 2) Install ActiveState? > > 3) Install Enthought? > > 4) Install Anaconda? > > 5) Get Python from the Microsoft Store? > > 6) Something else? > > > > They're all different, they all behave differently, they all have > > different defaults. And then there's the question of "did you install > > it for everyone or just you?", and so on. > > > > The core Python devs have control of the first option, and some > > control over the fifth, but none of the others. > > Yes, but usability improvements for the one from python.org could be > later adopted by the other distributors. Maybe those usability improvements have already been done. I know that both the python.org downloads and the MS store download have been significantly improved over the past few years. But frequently, when these kinds of questions come up, it turns out that someone's installed *multiple* Pythons. There's not a lot we can do about that. > I think, that you are jumping from "How to improve the current > situation?" to "How to make it absolutely perfect?" > > That's a sure path into the incapacity to act. I'm not talking about > solving all the problems that newcomers have, but reducing them. No, I never said anything of the sort. > Eryk Sun suggested to rename the installer to a more explicit > filename. Will that solve all the problems? No. But it reduces the > troubles by solving one particular case. Renaming "IDLE" to "Python > IDE" (or similar) might also. Adding desktop icons for it or have a > "Start the Python Editor (IDLE) now" button/checkbox at the end of > the installation also. Renaming Idle to "Python IDE" would be a very bad idea, since there are many other Python IDEs. Starting something immediately after installation completes might help, but would probably just defer the issue to the *second* time someone wants something. Last I checked, the Start menu entries DO have the name Python in them (I think they were in a submenu called "Python X.Y"), so anything involving changing names in the Start menu is unlikely to help further. There is no simple foolproof solution. That's why people still get confused. ChrisA From sjeik_appie at hotmail.com Thu Oct 1 16:52:22 2020 From: sjeik_appie at hotmail.com (sjeik_appie at hotmail.com) Date: Thu, 01 Oct 2020 22:52:22 +0200 Subject: Hot reload Flask app? In-Reply-To: Message-ID: On 1 Oct 2020 17:58, Roland M?ller via Python-list wrote: On 2020-10-01 16:33, sjeik_appie at hotmail.com wrote: >???? Hi, >???? I would like to create a "/reload" view in my Flask app, so I could easily >???? and safely reload it when code, templates etc change. Similar to what >???? happens when running the app with the debug server. I am using Nginx and >???? Gevent on a recent Ubuntu system with Python 3.6. >???? My strategy would be to gracefully stop Gevent [1], then do >???? os.kill(os.getpid(), signal.SIGHUP). I have not yet tried this (not >???? working today!). Just wondering if there are best practices. >???? Thanks! >???? Albert-Jan >???? [1] >???? http://www.gevent.org/api/gevent.baseserver.html#gevent.baseserver.BaseServer.stop Running flask app.run(debug=True) will make the Flask server watching the filesystem for source code changes and re-deploy your app. https://pythonhosted.org/Flask-Debug/? ==? Hi, Thanks. I was aware of running it in debug mode, but I was looking for domething to use in production. I checked how werkzeug does it, see line 160:?https://github.com/pallets/werkzeug/blob/master/src/werkzeug/_reloader.py I'll study this in more detail tomorrow. Best wishes, Albert-Jan From hexamorph at gmx.net Thu Oct 1 17:04:59 2020 From: hexamorph at gmx.net (Hexamorph) Date: Thu, 1 Oct 2020 23:04:59 +0200 Subject: Problem In-Reply-To: References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> <5F76378D.4080107@googlemail.com> Message-ID: <5F76447B.70609@gmx.net> Am 01.10.2020 um 22:17 schrieb Chris Angelico: > Maybe those usability improvements have already been done. Haven't doubted that. Maybe they are just not enough yet. > Renaming Idle to "Python IDE" would be a very bad idea, since there > are many other Python IDEs. You missed the "(or similar)" addition. ;-) Call it "IDLE - Python IDE" or "Python Editor (IDLE)" or whatever. Something that gives the newcomer a better clue than "IDLE". > Starting something immediately after installation completes might > help, but would probably just defer the issue to the *second* time > someone wants something. Probably not if they once have seen that there is some GUI editor and can barely recall it was something like "IDE", "Python Editor" or so. Again, will it help in *all* cases? No, but in some. > There is no simple foolproof solution. That's why people still get confused. That's what I mean. You dismiss suggestions on the grounds of "no simple foolproof solution" ie. a perfect solution. I'm not talking about solutions that will work in every case and solve all possible problems. I'm talking about incremental improvements which reduce some -- not remove all -- those troubles, But again, I'm not the one who has to deal with all this. :-) From mirkok.lists at googlemail.com Thu Oct 1 17:10:43 2020 From: mirkok.lists at googlemail.com (Mirko) Date: Thu, 1 Oct 2020 23:10:43 +0200 Subject: Problem In-Reply-To: References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> <5F76378D.4080107@googlemail.com> Message-ID: <5F7645D3.1090806@googlemail.com> Am 01.10.2020 um 22:17 schrieb Chris Angelico: > Maybe those usability improvements have already been done. Haven't doubted that. Maybe they are just not enough yet. > Renaming Idle to "Python IDE" would be a very bad idea, since there > are many other Python IDEs. You missed the "(or similar)" addition. Call it "IDLE - Python IDE" or "Python Editor (IDLE)" or whatever. Something that gives the newcomer a better clue than "IDLE". > Starting something immediately after installation completes might > help, but would probably just defer the issue to the *second* time > someone wants something. Probably not if they once have seen that there is some GUI editor and can barely recall it was something like "IDE", "Python Editor" or so. Again, will it help in *all* cases? No, but in some. > There is no simple foolproof solution. That's why people still get confused. That's what I mean. You dismiss suggestions on the grounds of "no simple foolproof solution" ie. a perfect solution. I'm not talking about solutions that will work in every case and solve all possible problems. I'm talking about incremental improvements which reduce some -- not remove all -- those troubles, But again, I'm not the one who has to deal with all this. From rosuav at gmail.com Thu Oct 1 17:17:13 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 2 Oct 2020 07:17:13 +1000 Subject: Problem In-Reply-To: <5F76447B.70609@gmx.net> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> <5F76378D.4080107@googlemail.com> <5F76447B.70609@gmx.net> Message-ID: On Fri, Oct 2, 2020 at 7:06 AM Hexamorph wrote: > > Am 01.10.2020 um 22:17 schrieb Chris Angelico: > > > Maybe those usability improvements have already been done. > > Haven't doubted that. Maybe they are just not enough yet. > > > Renaming Idle to "Python IDE" would be a very bad idea, since there > > are many other Python IDEs. > > You missed the "(or similar)" addition. ;-) > > Call it "IDLE - Python IDE" or "Python Editor (IDLE)" or whatever. > Something that gives the newcomer a better clue than "IDLE". How about "IDLE (Python 3.8 32-bit)" in a submenu called "Python 3.8"? Seems pretty good to me. Calling something "Python IDE" or "Python Editor" isn't any better. People will still be confused, and it's now become *less* clear what it actually is. (Or more verbose, if you put all the different words in. And that has its own problems.) > > There is no simple foolproof solution. That's why people still get confused. > > That's what I mean. You dismiss suggestions on the grounds of "no > simple foolproof solution" ie. a perfect solution. I'm not talking > about solutions that will work in every case and solve all possible > problems. I'm talking about incremental improvements which reduce > some -- not remove all -- those troubles, > On the contrary, I'm not dismissing the solutions because they're not perfect - I'm dismissing them because they're already done, and we have proof that they don't solve the problem. You're suggesting virtually the same things that are already the case. If they were to offer any benefit, we already have it. ChrisA From cs at cskk.id.au Thu Oct 1 17:52:35 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 2 Oct 2020 07:52:35 +1000 Subject: Regex Group case change In-Reply-To: References: Message-ID: <20201001215235.GA68439@cskk.homeip.net> On 01Oct2020 12:41, Raju wrote: >I want to change the case on input string i was able to match using >python regex but couldn't find the way to change the case. > >For example string: >Input: 7Section Hello Jim >output: 7Section hello Jim > >I was doing if statment with regex > >if re.match("(\d+\w* )(Hello)( \w+)",string)): > print(r"(\d+\w* )(Hello)( \w+)","\1\2.lower()\3",string) > >Output was >7Section \2.lower() Jim >Above one is one of the regex i have in function, i have total 6 regex >patterns and i want to keep all in this if elif else statment. It is >matching, but can someone advise how to replace Hello to hello? Please paste the _exact_ code you're using to produce the problem. I do not believe the code above generates the output you show. I imagine there's som kind of regexp replacement call in the real code. There's a few things going on in the code above which will cause trouble: Be consistent using "raw strings", which look like r".......". Normal Python string recognise a variety of backslash escaped things, like \n for a newline character. The purpose of a raw string is to disable that, which is important with regular expressions because they also use backslash escapes such as \d for a digit. Try to _always_ use raw strings when working with regular expressions. Your print() call _looks_ like it should be printing the result of a regexp substitute() function call, based on the "\1\2.lower()\3" in the second field. The substitute() syntax does not support embedding str methods in the result, so the .lower() will just be written out directly. To do more complicated things you need to pull out the matched groups and work with them separately, then assemble your desired result. You do not keep the result of the re.match call here: if re.match("(\d+\w* )(Hello)( \w+)",string)): Traditionally one would write: m = re.match("(\d+\w* )(Hello)( \w+)",string)) if m: and in recent Python (3.8+) you can write: if m := re.match("(\d+\w* )(Hello)( \w+)",string)): This preserves the result fo the match in the variable "m", which you will require if you want to do any work with the result, such as lowercasing something. The matches components of the regexp are available via the .group() method of the match result. So: m.group(1) == "7Section" m.group(2) == "Hello" and to print "Hello" lowercased you might write: m.group(2).lower() Since this looks much like homework we will leave it to you to apply this approach to your existing code. Cheers, Cameron Simpson From ch.nagaraju008 at gmail.com Thu Oct 1 18:15:32 2020 From: ch.nagaraju008 at gmail.com (Raju) Date: Thu, 1 Oct 2020 15:15:32 -0700 (PDT) Subject: Regex Group case change In-Reply-To: References: <20201001215235.GA68439@cskk.homeip.net> Message-ID: <37600291-e6f2-44b2-931f-44f3448d7028n@googlegroups.com> import re import os import sys #word = "7 the world" # 7 The world #word = "Brian'S" # Brian's #word = "O'biran"# O'Brian #word = "Stoke-On-Trent" # Stoke-on-Trent; here i need to lower the case of middle word(i.e -On-) def wordpattern(word): output = '' if re.match("^\d+|w*$",word): output = word.upper() elif re.match("\w+\'\w{1}$",word): output = word.capitalize() elif re.match("(\d+\w* )(Hello)( \w+)",word)) group(1)group(2).title()group(3) else: output.title() On Thursday, October 1, 2020 at 10:53:16 PM UTC+1, cameron... at gmail.com wrote: > On 01Oct2020 12:41, Raju wrote: > >I want to change the case on input string i was able to match using > >python regex but couldn't find the way to change the case. > > > >For example string: > >Input: 7Section Hello Jim > >output: 7Section hello Jim > > > >I was doing if statment with regex > > > >if re.match("(\d+\w* )(Hello)( \w+)",string)): > > print(r"(\d+\w* )(Hello)( \w+)","\1\2.lower()\3",string) > > > >Output was > >7Section \2.lower() Jim > >Above one is one of the regex i have in function, i have total 6 regex > >patterns and i want to keep all in this if elif else statment. It is > >matching, but can someone advise how to replace Hello to hello? > Please paste the _exact_ code you're using to produce the problem. I do > not believe the code above generates the output you show. I imagine > there's som kind of regexp replacement call in the real code. > > There's a few things going on in the code above which will cause > trouble: > > Be consistent using "raw strings", which look like r".......". Normal > Python string recognise a variety of backslash escaped things, like \n > for a newline character. The purpose of a raw string is to disable that, > which is important with regular expressions because they also use > backslash escapes such as \d for a digit. Try to _always_ use raw > strings when working with regular expressions. > > Your print() call _looks_ like it should be printing the result of a > regexp substitute() function call, based on the "\1\2.lower()\3" in the > second field. The substitute() syntax does not support embedding str > methods in the result, so the .lower() will just be written out > directly. To do more complicated things you need to pull out the matched > groups and work with them separately, then assemble your desired result. > > You do not keep the result of the re.match call here: > if re.match("(\d+\w* )(Hello)( \w+)",string)): > Traditionally one would write: > > m = re.match("(\d+\w* )(Hello)( \w+)",string)) > if m: > > and in recent Python (3.8+) you can write: > > if m := re.match("(\d+\w* )(Hello)( \w+)",string)): > > This preserves the result fo the match in the variable "m", which you > will require if you want to do any work with the result, such as > lowercasing something. > > The matches components of the regexp are available via the .group() > method of the match result. So: > > m.group(1) == "7Section" > m.group(2) == "Hello" > > and to print "Hello" lowercased you might write: > > m.group(2).lower() > > Since this looks much like homework we will leave it to you to apply > this approach to your existing code. > > Cheers, > Cameron Simpson From cs at cskk.id.au Thu Oct 1 21:24:08 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 2 Oct 2020 11:24:08 +1000 Subject: Regex Group case change In-Reply-To: <37600291-e6f2-44b2-931f-44f3448d7028n@googlegroups.com> References: <37600291-e6f2-44b2-931f-44f3448d7028n@googlegroups.com> Message-ID: <20201002012408.GA19466@cskk.homeip.net> It is good to see a nice small piece of code which we can run. Thank you. So there are a number of things to comment about in the code below; comments inline under the relevant piece of code (we prefer the "inline reply" style here, it reads like a conversation): On 01Oct2020 15:15, Raju wrote: >import re >import os >import sys > >#word = "7 the world" # 7 The world >#word = "Brian'S" # Brian's >#word = "O'biran"# O'Brian >#word = "Stoke-On-Trent" # Stoke-on-Trent; here i need to lower the case of middle word(i.e -On-) There is an opinion often held that regexp are overused. To lowercase the "on" I would reach for str.split, for example: left, middle, right = word.split('-', 2) middle = middle.lower() modified_word = '-'.join([left, middle, right]) I have broken that out for readability, and it is hardwired for a 3 part word. See the docs for str.split and str.join: https://docs.python.org/3/library/stdtypes.html#str.join https://docs.python.org/3/library/stdtypes.html#str.split So: no regexps, which I'm sure you now realise can be tricky to get correct, and are hard to read. >def wordpattern(word): > output = '' > if re.match("^\d+|w*$",word): > output = word.upper() > elif re.match("\w+\'\w{1}$",word): > output = word.capitalize() > elif re.match("(\d+\w* )(Hello)( \w+)",word)) > group(1)group(2).title()group(3) > else: > output.title() First off, please try to use raw strings for regular expressions, it avoids many potential accidents to do with backslash treatment by Python and regexps. So rewritten: >def wordpattern(word): > output = '' > if re.match(r"^\d+|w*$",word): > output = word.upper() > elif re.match(r"\w+\'\w{1}$",word): > output = word.capitalize() > elif re.match(r"(\d+\w* )(Hello)( \w+)",word)) > group(1)group(2).title()group(3) > else: > output.title() First up, this function does not return a value - it has no return statement. You probably want: return output at the end. Also, your default output seems to be ''; would it not be better to return word unchanged? So I'd start with: output = word up the front. Then there's a bunch of small issues in the main code: > if re.match(r"^\d+|w*$",word): > output = word.upper() You probably want "\w", not "w" (missing backslash). A plain "w" matches the letter "w". Also, you probabloy want "\w+", not "\w*" - meaning "at least one" instead of "zero or more" aka "at least 0". With the "*" it can match zero character (the empty string). > elif re.match(r"\w+\'\w{1}$",word): The "\w{1}" can just be written "\w" - the default repetition for a subpattern is "exactly once", which is what "{1}" means. So not incorrect, just more complicated than required. > output = word.capitalize() > elif re.match(r"(\d+\w* )(Hello)( \w+)",word)) Typically people put the whitepsace outside the group, because they usually want the word and not the spaces around it. Of course, the cost of that s that you would need to put the spaces back in later. So in fact this works for your use case. > group(1)group(2).title()group(3) You need to join these together, and assign the result to output: output = group(1) + group(2).title() + group(3) > else: > output.title() You need to assign the result to output: output = output.title() Cheers, Cameron Simpson From robertvstepp at gmail.com Thu Oct 1 21:37:51 2020 From: robertvstepp at gmail.com (boB Stepp) Date: Thu, 1 Oct 2020 20:37:51 -0500 Subject: Problem In-Reply-To: References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> Message-ID: <20201002013751.GB1147245@Dream-Machine1> On Thu, Oct 01, 2020 at 01:34:35AM -0400, Dennis Lee Bieber wrote: > I'm pretty certain the Python.org downloads for Windows also put IDLE >on the start menu. I believe these newcomers aren't even looking at the >start menu for things -- if it isn't cluttering up the desktop they >probably don't know it exists. And the only thing they know about is the >file they downloaded. Maybe this suggests the "incremental improvement" needed: Have the installer, by default, add a shortcut icon for IDLE to the user's desktop. Perhaps this will get noticed. If it does it would put the new user into a program where they might actually start doing something useful. The person who does not want such a desktop shortcut can uncheck that default option. -- Wishing you only the best, boB Stepp From gklein at xs4all.nl Fri Oct 2 05:45:37 2020 From: gklein at xs4all.nl (Gertjan Klein) Date: Fri, 2 Oct 2020 11:45:37 +0200 Subject: Python 3.8.5 Not Launching In-Reply-To: References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> Message-ID: <5f76f6be$0$306$e4fe514c@news.xs4all.nl> Eryk Sun wrote: > If .py files are associated with py.exe or python.exe, then running a > .py script either inherits or allocates a console and attaches to it. Is it possible to determine, from within Python, whether Python allocated or inherited the console? This could be useful to know in a (global) error trap: to be able to see a traceback, the console must remain open, which won't happen if Python allocated the console itself. Regards, Gertjan. From rosuav at gmail.com Fri Oct 2 05:57:18 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 2 Oct 2020 19:57:18 +1000 Subject: Python 3.8.5 Not Launching In-Reply-To: <5f76f6be$0$306$e4fe514c@news.xs4all.nl> References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> <5f76f6be$0$306$e4fe514c@news.xs4all.nl> Message-ID: On Fri, Oct 2, 2020 at 7:51 PM Gertjan Klein wrote: > > Eryk Sun wrote: > > > If .py files are associated with py.exe or python.exe, then running a > > .py script either inherits or allocates a console and attaches to it. > > Is it possible to determine, from within Python, whether Python > allocated or inherited the console? This could be useful to know in a > (global) error trap: to be able to see a traceback, the console must > remain open, which won't happen if Python allocated the console itself. > It might be possible, but then there'd have to be lots of magic and the result would be a different set of complaints ("sometimes I get a black window, other times it just disappears"). Instead of trying to detect and such, maybe there needs to be a standard recommendation for an atexit or something - advise people to "stick this line at the top of your program so the black window stays around". No magic, and completely consistent. ChrisA From eryksun at gmail.com Fri Oct 2 09:45:52 2020 From: eryksun at gmail.com (Eryk Sun) Date: Fri, 2 Oct 2020 08:45:52 -0500 Subject: Python 3.8.5 Not Launching In-Reply-To: <5f76f6be$0$306$e4fe514c@news.xs4all.nl> References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> <5f76f6be$0$306$e4fe514c@news.xs4all.nl> Message-ID: On 10/2/20, Gertjan Klein wrote: > Eryk Sun wrote: > >> If .py files are associated with py.exe or python.exe, then running a >> .py script either inherits or allocates a console and attaches to it. > > Is it possible to determine, from within Python, whether Python > allocated or inherited the console? If a console session isn't headless (i.e. it's not a pseudoconsole) and has a window (i.e. not allocated with CREATE_NO_WINDOW), then the effective owner of the window is initially the process that allocated the console session, as long as it's still running and attached. For example, with "python.exe" (not a launcher) executed from Explorer: >>> hwnd = win32console.GetConsoleWindow() >>> tid, pid = win32process.GetWindowThreadProcessId(hwnd) >>> pid == os.getpid() True A problem is the case of a launcher such as "py.exe", or the "python.exe" launcher used by venv virtual environments. A venv launcher can be detected by comparing sys.executable with sys._base_executable. For example, with a venv launcher executed from Explorer: >>> hwnd = win32console.GetConsoleWindow() >>> tid, pid = win32process.GetWindowThreadProcessId(hwnd) The current process doesn't own the console, but the parent does: >>> pid == os.getpid() False >>> pid == os.getppid() True Check whether the parent is a venv launcher: >>> print(sys.executable) C:\Temp\env\test38\Scripts\python.exe >>> print(sys._base_executable) C:\Program Files\Python38\python.exe Double check that the parent is the venv launcher: >>> access = win32con.PROCESS_QUERY_LIMITED_INFORMATION >>> hproc = win32api.OpenProcess(access, False, pid) >>> executable = win32process.GetModuleFileNameEx(hproc, None) >>> os.path.samefile(executable, sys.executable) True From tjreedy at udel.edu Fri Oct 2 05:58:57 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 2 Oct 2020 05:58:57 -0400 Subject: Problem In-Reply-To: <5F76378D.4080107@googlemail.com> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> <5F76378D.4080107@googlemail.com> Message-ID: On 10/1/2020 4:09 PM, Mirko via Python-list wrote: > Renaming "IDLE" to "Python IDE" (or similar) might also. "IDLE" intentionally echoes 'Idle', as in Eric Idle of Monty Python. It stands for "Integrated Development and Learning Environment". It is *a* Python IDE aimed especially at beginners (the 'Learning' part). (I should probably revised the doc a bit.) Changing a name in use around the world, in books and web sites and discussion posts and a Stackoverflow tag ('python-idle') is a bad idea. And, as Chris said, implying that it is *the* Python IDE is not a good idea either. I think changing the start menu entry "IDLE (Python 3.9 64 bit)" to something more descriptive, as suggested by Mirko, *is* a good idea. The current longest entry under "Python 3.9" is "Python 3.9 Module Docs (64-bit)" So "IDLE Shell/Editor (3.9 64-bit)" would fit. I opened a bpo issue with more discussion. https://bugs.python.org/issue41908 Bpo users with an opinion should express it there. Terry Jan Reedy From nipurbedazzled at gmail.com Fri Oct 2 06:15:20 2020 From: nipurbedazzled at gmail.com (Nipur Gupta) Date: Fri, 2 Oct 2020 15:45:20 +0530 Subject: Error 0xc000007b on opening python Message-ID: I've downloaded python 3.6.0 64 bits but whenever I try to open idle, it doesn't open and displays error 0xc000007b. I've tried everything from reinstalling to updating windows and visual c++ but it's still the same. I downloaded python earlier also it worked that time but opening after few days it showed this error, since then it's not working. I'm using windows 8.1 64 bit...Please help me in this regard From shishaozhong at gmail.com Fri Oct 2 08:34:46 2020 From: shishaozhong at gmail.com (Shaozhong SHI) Date: Fri, 2 Oct 2020 13:34:46 +0100 Subject: ValueError: arrays must all be same length In-Reply-To: References: Message-ID: Hello, I got a json response from an API and tried to use pandas to put data into a dataframe. However, I kept getting this ValueError: arrays must all be same length. Can anyone help? The following is the json text. Regards, Shao { "locationId": "1-1004508435", "providerId": "1-101641521", "organisationType": "Location", "type": "Social Care Org", "name": "Meadow Rose Nursing Home", "brandId": "BD510", "brandName": "BRAND MACC Care", "onspdCcgCode": "E38000220", "onspdCcgName": "NHS Birmingham and Solihull CCG", "odsCode": "VM4G9", "uprn": "100070537642", "registrationStatus": "Registered", "registrationDate": "2013-12-16", "dormancy": "N", "numberOfBeds": 56, "postalAddressLine1": "96 The Roundabout", "postalAddressTownCity": "Birmingham", "postalAddressCounty": "West Midlands", "region": "West Midlands", "postalCode": "B31 2TX", "onspdLatitude": 52.399843, "onspdLongitude": -1.989241, "careHome": "Y", "inspectionDirectorate": "Adult social care", "mainPhoneNumber": "01214769808", "constituency": "Birmingham, Northfield", "localAuthority": "Birmingham", "lastInspection": { "date": "2020-06-24" }, "lastReport": { "publicationDate": "2020-10-01" }, "relationships": [ ], "locationTypes": [ ], "regulatedActivities": [ { "name": "Accommodation for persons who require nursing or personal care", "code": "RA2", "contacts": [ { "personTitle": "Mr", "personGivenName": "Steven", "personFamilyName": "Kazembe", "personRoles": [ "Registered Manager" ] } ] }, { "name": "Treatment of disease, disorder or injury", "code": "RA5", "contacts": [ { "personTitle": "Mr", "personGivenName": "Steven", "personFamilyName": "Kazembe", "personRoles": [ "Registered Manager" ] } ] } ], "gacServiceTypes": [ { "name": "Nursing homes", "description": "Care home service with nursing" } ], "inspectionCategories": [ { "code": "S1", "primary": "true", "name": "Residential social care" } ], "specialisms": [ { "name": "Caring for adults over 65 yrs" }, { "name": "Caring for adults under 65 yrs" }, { "name": "Dementia" }, { "name": "Physical disabilities" } ], "inspectionAreas": [ ], "currentRatings": { "overall": { "rating": "Requires improvement", "reportDate": "2020-10-01", "reportLinkId": "1157c975-c2f1-423e-a2b4-66901779e014", "useOfResources": { }, "keyQuestionRatings": [ { "name": "Safe", "rating": "Requires improvement", "reportDate": "2020-10-01", "reportLinkId": "1157c975-c2f1-423e-a2b4-66901779e014" }, { "name": "Well-led", "rating": "Requires improvement", "reportDate": "2020-10-01", "reportLinkId": "1157c975-c2f1-423e-a2b4-66901779e014" }, { "name": "Caring", "rating": "Good", "reportDate": "2019-10-04", "reportLinkId": "63ff05ec-4d31-406e-83de-49a271cfdc43" }, { "name": "Responsive", "rating": "Good", "reportDate": "2019-10-04", "reportLinkId": "63ff05ec-4d31-406e-83de-49a271cfdc43" }, { "name": "Effective", "rating": "Requires improvement", "reportDate": "2019-10-04", "reportLinkId": "63ff05ec-4d31-406e-83de-49a271cfdc43" } ] }, "reportDate": "2020-10-01" }, "historicRatings": [ { "reportLinkId": "63ff05ec-4d31-406e-83de-49a271cfdc43", "reportDate": "2019-10-04", "overall": { "rating": "Requires improvement", "keyQuestionRatings": [ { "name": "Safe", "rating": "Requires improvement" }, { "name": "Well-led", "rating": "Requires improvement" } ] } }, { "reportLinkId": "4f20da40-89a4-4c45-a7f9-bfd52b48f286", "reportDate": "2017-09-08", "overall": { "rating": "Good", "keyQuestionRatings": [ { "name": "Safe", "rating": "Good" }, { "name": "Well-led", "rating": "Good" }, { "name": "Caring", "rating": "Good" }, { "name": "Responsive", "rating": "Good" }, { "name": "Effective", "rating": "Requires improvement" } ] } }, { "reportLinkId": "0cc4226b-401e-4f0f-ba35-062cbadffa8f", "reportDate": "2016-06-11", "overall": { "rating": "Requires improvement", "keyQuestionRatings": [ { "name": "Safe", "rating": "Requires improvement" }, { "name": "Well-led", "rating": "Requires improvement" }, { "name": "Caring", "rating": "Requires improvement" }, { "name": "Responsive", "rating": "Requires improvement" }, { "name": "Effective", "rating": "Good" } ] } }, { "reportLinkId": "a11c1e52-ddfd-4cd8-8b56-1b96ac287c96", "reportDate": "2015-01-12", "overall": { "rating": "Good", "keyQuestionRatings": [ { "name": "Safe", "rating": "Good" }, { "name": "Well-led", "rating": "Good" }, { "name": "Caring", "rating": "Good" }, { "name": "Responsive", "rating": "Requires improvement" }, { "name": "Effective", "rating": "Good" } ] } } ], "reports": [ { "linkId": "1157c975-c2f1-423e-a2b4-66901779e014", "reportDate": "2020-10-01", "reportUri": "/reports/1157c975-c2f1-423e-a2b4-66901779e014", "firstVisitDate": "2020-06-23", "reportType": "Location" }, { "linkId": "63ff05ec-4d31-406e-83de-49a271cfdc43", "reportDate": "2019-10-04", "reportUri": "/reports/63ff05ec-4d31-406e-83de-49a271cfdc43", "firstVisitDate": "2019-08-28", "reportType": "Location" }, { "linkId": "4f20da40-89a4-4c45-a7f9-bfd52b48f286", "reportDate": "2017-09-08", "reportUri": "/reports/4f20da40-89a4-4c45-a7f9-bfd52b48f286", "firstVisitDate": "2017-07-19", "reportType": "Location" }, { "linkId": "0cc4226b-401e-4f0f-ba35-062cbadffa8f", "reportDate": "2016-06-11", "reportUri": "/reports/0cc4226b-401e-4f0f-ba35-062cbadffa8f", "firstVisitDate": "2016-03-15", "reportType": "Location" }, { "linkId": "a11c1e52-ddfd-4cd8-8b56-1b96ac287c96", "reportDate": "2015-01-12", "reportUri": "/reports/a11c1e52-ddfd-4cd8-8b56-1b96ac287c96", "firstVisitDate": "2014-08-12", "reportType": "Location" } ] } In [ ]: In [25]: j import pandas as pd import json j = json.JSONDecoder().decode(req.text) ###req.json df = pd.DataFrame.from_dict(j) From user at example.net Fri Oct 2 11:34:29 2020 From: user at example.net (J.O. Aho) Date: Fri, 2 Oct 2020 17:34:29 +0200 Subject: Error 0xc000007b on opening python In-Reply-To: References: Message-ID: On 02/10/2020 12:15, Nipur Gupta wrote: > I've downloaded python 3.6.0 64 bits but whenever I try to open idle, it > doesn't open and displays error 0xc000007b. I've tried everything from > reinstalling to updating windows and visual c++ but it's still the same. There seems to be quite many things that can cause this, you can try to reinstall driectx and .net frameworks, just see to install the right version, don't use a 32bit version of the packages on your 64bit microsoft windows installation. > I'm using windows 8.1 64 bit...Please help me in this regard There is always the option of upgrading, go and visit https://distrowatch.com and install the flavor you thinks fit your best. -- //Aho From mats at python.org Fri Oct 2 12:23:44 2020 From: mats at python.org (Mats Wichmann) Date: Fri, 2 Oct 2020 10:23:44 -0600 Subject: Error 0xc000007b on opening python In-Reply-To: References: Message-ID: <962ee060-c8ce-cce7-722a-e2370b0a06cf@python.org> On 10/2/20 4:15 AM, Nipur Gupta wrote: > I've downloaded python 3.6.0 64 bits but whenever I try to open idle, it > doesn't open and displays error 0xc000007b. I've tried everything from > reinstalling to updating windows and visual c++ but it's still the same. I > downloaded python earlier also it worked that time but opening after few > days it showed this error, since then it's not working. I'm using windows > 8.1 64 bit...Please help me in this regard > Something like this, when a program worked, and then stops working, usually indicates some kind of corruption - or some change you made. Did you install another version of Python later? Try using Microsoft's tools for validating and repairing the system and the image that backs it up. Beyond the scope of this list to describe that, but you can look for articles that describe that. For example: https://support.microsoft.com/en-us/help/929833/use-the-system-file-checker-tool-to-repair-missing-or-corrupted-system Are you able to open Python itself, or does it show the same issue? You should not be using Python 3.6.0. If you have something that tells you you must use 3.6.0 (which probably is not a real requirement anyway), then at the very least select the latest installer in the 3.6 series, which has all the released bugfixes - I believe that is 3.6.8. That's unlikely to have an effect on your problem, but don't continue trying to use 3.6.0. From dieter at handshake.de Fri Oct 2 12:30:37 2020 From: dieter at handshake.de (Dieter Maurer) Date: Fri, 2 Oct 2020 18:30:37 +0200 Subject: List of All Error Menssages In-Reply-To: References: Message-ID: <24439.21933.992965.622926@ixdm.fritz.box> Luis Gustavo Araujo wrote at 2020-10-1 16:06 -0300: >Is it possible to get the list of all error messages that display in >Python? I want the full message -> type error: additional message. > >Examples: >NameError: name 'x' is not defined >IndentationError: unindent does not match any outer indentation level Some systems indicates errors with an error code (often a number). If they in addition do not include an error description, you need a list mapping codes to description. Python indicates errors via exceptions, documented in the Python documentation (as far as used by Python; applications may define/derive further exceptions). In addition, error reports are usually made descriptive. An example is `NameError: name 'x' is not defined`: it informs you about a problem with the name `x`. In addition, you usually get a traceback - which tells you where in the code the problem was detected and the (function call) context that led to the problem. This wealth of direct information removes the need to have an error list. In addition: the additional information (beside the exception type) depends on the concrete situation: it is impossible to list it beforehand. >In this webpage (https://docs.python.org/3/library/exceptions.html) I only >can check the type error. `exceptions.html` describes Python's exception type hierarchy (note: Python is object oriented and exceptions are organized into a class hierarchy) and the exception types used by Python itself. As you have found out, this describes only the exception types. When an exception occurs, the type is usally enhanced by a speaking error description, often including information about your application entities involved in the exception, e.g. >>> open("abc") Traceback (most recent call last): File "", line 1, in FileNotFoundError: [Errno 2] No such file or directory: 'abc' ``` It tells you clearly (and without the need for any list): the problem was that a file could not have been opened and that this file was named 'abc'. Read error messages carefully -- they are usually "speaking". Should you get a message you do not understand, ask here. Otherwise, forget about lists of error messages. From hexamorph at gmx.net Fri Oct 2 15:47:38 2020 From: hexamorph at gmx.net (Hexamorph) Date: Fri, 2 Oct 2020 21:47:38 +0200 Subject: Problem In-Reply-To: References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> <5F76378D.4080107@googlemail.com> Message-ID: <5F7783DA.9070102@gmx.net> Am 02.10.2020 um 11:58 schrieb Terry Reedy: > On 10/1/2020 4:09 PM, Mirko via Python-list wrote: > >> Renaming "IDLE" to "Python IDE" (or similar) might also. > "IDLE" intentionally echoes 'Idle', as in Eric Idle of Monty > Python. It stands for "Integrated Development and Learning > Environment". It is *a* Python IDE aimed especially at beginners > (the 'Learning' part). (I should probably revised the doc a bit.) > > Changing a name in use around the world, in books and web sites and > discussion posts and a Stackoverflow tag ('python-idle') is a bad > idea. And, as Chris said, implying that it is *the* Python IDE is > not a good idea either. > > I think changing the start menu entry > "IDLE (Python 3.9 64 bit)" > to something more descriptive, as suggested by Mirko, *is* a good idea. > > The current longest entry under "Python 3.9" is > "Python 3.9 Module Docs (64-bit)" > So > "IDLE Shell/Editor (3.9 64-bit)" > would fit. I opened a bpo issue with more discussion. > https://bugs.python.org/issue41908 > Bpo users with an opinion should express it there. > > Terry Jan Reedy > Thanks! Sorry, I have been a bit unclear in my second post. I never meant to rename IDLE itself. Only the entries in the Startmenu, the possible desktop icons and such. If I had a say in all this, I would do: - Rename the MSI as suggested by Eryk Sun. - Add a folder named "Python.org " (or similar) to the desktop with shortcuts to Python, IDLE and the CHM. - Add a checkbox (default enabled) like "Start the IDLE Python Editor/Shell" at the end of the installation procedure. - Add a button like "Start the IDLE Python Editor/Shell" to the Repair/Modify/Remove Dialog. For all I know, the points 2 and 3 are very common with installation procedures on Windows (and therefore likely expected by the users). And no, this will not solve all problems. There will always be some people who just don't get it. But I would be very surprised, if that doesn't cut down the number of these beginner troubles by one or two orders of magnitude. From mirkok.lists at googlemail.com Fri Oct 2 15:49:47 2020 From: mirkok.lists at googlemail.com (Mirko) Date: Fri, 2 Oct 2020 21:49:47 +0200 Subject: Problem In-Reply-To: References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> <5F76378D.4080107@googlemail.com> Message-ID: <5F77845B.2060502@googlemail.com> Am 02.10.2020 um 11:58 schrieb Terry Reedy: > On 10/1/2020 4:09 PM, Mirko via Python-list wrote: > >> Renaming "IDLE" to "Python IDE" (or similar) might also. > "IDLE" intentionally echoes 'Idle', as in Eric Idle of Monty > Python. It stands for "Integrated Development and Learning > Environment". It is *a* Python IDE aimed especially at beginners > (the 'Learning' part). (I should probably revised the doc a bit.) > > Changing a name in use around the world, in books and web sites and > discussion posts and a Stackoverflow tag ('python-idle') is a bad > idea. And, as Chris said, implying that it is *the* Python IDE is > not a good idea either. > > I think changing the start menu entry > "IDLE (Python 3.9 64 bit)" > to something more descriptive, as suggested by Mirko, *is* a good idea. > > The current longest entry under "Python 3.9" is > "Python 3.9 Module Docs (64-bit)" > So > "IDLE Shell/Editor (3.9 64-bit)" > would fit. I opened a bpo issue with more discussion. > https://bugs.python.org/issue41908 > Bpo users with an opinion should express it there. > > Terry Jan Reedy > (Sorry for the mail from the other wrong account again, need to change that) Thanks! Sorry, I have been a bit unclear in my second post. I never meant to rename IDLE itself. Only the entries in the Startmenu, the possible desktop icons and such. If I had a say in all this, I would do: - Rename the MSI as suggested by Eryk Sun. - Add a folder named "Python.org " (or similar) to the desktop with shortcuts to Python, IDLE and the CHM. - Add a checkbox (default enabled) like "Start the IDLE Python Editor/Shell" at the end of the installation procedure. - Add a button like "Start the IDLE Python Editor/Shell" to the Repair/Modify/Remove Dialog. For all I know, the points 2 and 3 are very common with installation procedures on Windows (and therefore likely expected by the users). And no, this will not solve all problems. There will always be some people who just don't get it. But I would be very surprised, if that doesn't cut down the number of these beginner troubles by one or two orders of magnitude. From shishaozhong at gmail.com Fri Oct 2 16:25:58 2020 From: shishaozhong at gmail.com (Shaozhong SHI) Date: Fri, 2 Oct 2020 21:25:58 +0100 Subject: How to handle a dictionary value that is a list Message-ID: Hi, All, I was trying to handle the value of "personRoles" in a part of json dictionary. Can anyone tell me various ways to handle this? Regards, Shao "regulatedActivities": [ { "name": "Accommodation for persons who require nursing or personal care", "code": "RA2", "contacts": [ { "personTitle": "Mr", "personGivenName": "Steven", "personFamilyName": "Great", "personRoles": [ "Registered Manager" ] e,f = [],[] for result in d['regulatedActivities']: e.append(result['name']) #### for s in result['contacts']['personRoles']: #### t = (list) #### print s ###f.append(s) f = d['regulatedActivities']['contacts']['personRoles'] df1 = pd.DataFrame([e,f]).T From aeros167 at gmail.com Fri Oct 2 17:03:42 2020 From: aeros167 at gmail.com (Kyle Stanley) Date: Fri, 2 Oct 2020 17:03:42 -0400 Subject: List of All Error Menssages In-Reply-To: References: Message-ID: Hi Luis, There is not a maintained list of every possible combination of exception type and message because they're continuously being added within the Python standard library, and exception messages are considered an implementation detail that are subject to change. While there are many that have remained the same for many years and likely will continue to, we do periodically adjust some to add additional information, make formatting fixes, and/or improve grammar. Documenting exception messages formally would essentially remove them from being implementation details (meaning that they can't as easily be adjusted); not to mention the long term cost of continuously updating that list each time a new exception message is written somewhere within the standard library. It would not be very sustainable, even more so if you consider that CPython development is mostly volunteer-driven efforts. Regards, Kyle Stanley On Thu, Oct 1, 2020 at 3:18 PM Luis Gustavo Araujo < luisaraujo.ifba at gmail.com> wrote: > Hi, > Is it possible to get the list of all error messages that display in > Python? I want the full message -> type error: additional message. > > Examples: > NameError: name 'x' is not defined > IndentationError: unindent does not match any outer indentation level > > In this webpage (ttps://docs.python.org/3/library/exceptions.html) I only > can check the type error. > > []s > > > Em qui., 1 de out. de 2020 ?s 15:59, Luis Gustavo Araujo < > luisaraujo.ifba at gmail.com> escreveu: > > > Hi, > > Is it possible to get the list of all error messages that display in > > Python? I want the full message -> type error: additional message. > > > > Examples: > > NameError: name 'x' is not defined > > IndentationError: unindent does not match any outer indentation level > > > > In this webpage (ttps://docs.python.org/3/library/exceptions.html) I > only > > can check the type error. > > > > []s > > > > > > -- > > > > [image: Prefeitura Municipal de Am?lia Rodrigues] > > > > > > LUIS GUSTAVO ARAUJO > > *Am?lia Rodrigues Prefecture - Brazil (* > > > > *Teacher of Computer Science) UNIFACS - Laureate International > > Universities (Professor Assistant I)* > > > > Degree in Computer Science (IFBA) - 2015 > > Master Degrees in Computer Applied (UEFS) - 2018 > > PhD Student in Computer Science (UFBA) > > *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634 > > * > > > > [image: Twitter] [image: Facebook] > > [image: Github] > > > > > > > > > > > > < > https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Livre > > de v?rus. www.avast.com > > < > https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail > >. > > <#m_-2814426795322638799_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > > > > -- > > [image: Prefeitura Municipal de Am?lia Rodrigues] > > > LUIS GUSTAVO ARAUJO > *Am?lia Rodrigues Prefecture - Brazil (* > > *Teacher of Computer Science) UNIFACS - Laureate International Universities > (Professor Assistant I)* > > Degree in Computer Science (IFBA) - 2015 > Master Degrees in Computer Applied (UEFS) - 2018 > PhD Student in Computer Science (UFBA) > *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634 > * > > [image: Twitter] [image: Facebook] > [image: Github] > > -- > https://mail.python.org/mailman/listinfo/python-list > From luisaraujo.ifba at gmail.com Fri Oct 2 17:27:35 2020 From: luisaraujo.ifba at gmail.com (Luis Gustavo Araujo) Date: Fri, 2 Oct 2020 18:27:35 -0300 Subject: List of All Error Menssages In-Reply-To: References: Message-ID: Hi Kyle, Thanks! Att, Livre de v?rus. www.avast.com . <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> Em sex., 2 de out. de 2020 ?s 18:03, Kyle Stanley escreveu: > Hi Luis, > > There is not a maintained list of every possible combination of exception > type and message because they're continuously being added within the Python > standard library, and exception messages are considered an implementation > detail that are subject to change. While there are many that have remained > the same for many years and likely will continue to, we do periodically > adjust some to add additional information, make formatting fixes, and/or > improve grammar. Documenting exception messages formally would essentially > remove them from being implementation details (meaning that they can't as > easily be adjusted); not to mention the long term cost of continuously > updating that list each time a new exception message is written somewhere > within the standard library. It would not be very sustainable, even more so > if you consider that CPython development is mostly volunteer-driven efforts. > > Regards, > Kyle Stanley > > On Thu, Oct 1, 2020 at 3:18 PM Luis Gustavo Araujo < > luisaraujo.ifba at gmail.com> wrote: > >> Hi, >> Is it possible to get the list of all error messages that display in >> Python? I want the full message -> type error: additional message. >> >> Examples: >> NameError: name 'x' is not defined >> IndentationError: unindent does not match any outer indentation level >> >> In this webpage (ttps://docs.python.org/3/library/exceptions.html) I only >> can check the type error. >> >> []s >> >> >> Em qui., 1 de out. de 2020 ?s 15:59, Luis Gustavo Araujo < >> luisaraujo.ifba at gmail.com> escreveu: >> >> > Hi, >> > Is it possible to get the list of all error messages that display in >> > Python? I want the full message -> type error: additional message. >> > >> > Examples: >> > NameError: name 'x' is not defined >> > IndentationError: unindent does not match any outer indentation level >> > >> > In this webpage (ttps://docs.python.org/3/library/exceptions.html) I >> only >> > can check the type error. >> > >> > []s >> > >> > >> > -- >> > >> > [image: Prefeitura Municipal de Am?lia Rodrigues] >> > >> > >> > LUIS GUSTAVO ARAUJO >> > *Am?lia Rodrigues Prefecture - Brazil (* >> > >> > *Teacher of Computer Science) UNIFACS - Laureate International >> > Universities (Professor Assistant I)* >> > >> > Degree in Computer Science (IFBA) - 2015 >> > Master Degrees in Computer Applied (UEFS) - 2018 >> > PhD Student in Computer Science (UFBA) >> > *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634 >> > * >> > >> > [image: Twitter] [image: >> Facebook] >> > [image: Github] >> > >> > >> > >> > >> > >> > < >> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> >> Livre >> > de v?rus. www.avast.com >> > < >> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail >> >. >> > <#m_-2814426795322638799_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >> > >> >> >> -- >> >> [image: Prefeitura Municipal de Am?lia Rodrigues] >> >> >> LUIS GUSTAVO ARAUJO >> *Am?lia Rodrigues Prefecture - Brazil (* >> >> *Teacher of Computer Science) UNIFACS - Laureate International >> Universities >> (Professor Assistant I)* >> >> Degree in Computer Science (IFBA) - 2015 >> Master Degrees in Computer Applied (UEFS) - 2018 >> PhD Student in Computer Science (UFBA) >> *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634 >> * >> >> [image: Twitter] [image: Facebook] >> [image: Github] >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > -- [image: Prefeitura Municipal de Am?lia Rodrigues] LUIS GUSTAVO ARAUJO *Am?lia Rodrigues Prefecture - Brazil (* *Teacher of Computer Science) UNIFACS - Laureate International Universities (Professor Assistant I)* Degree in Computer Science (IFBA) - 2015 Master Degrees in Computer Applied (UEFS) - 2018 PhD Student in Computer Science (UFBA) *http://dgp.cnpq.br/dgp/espelhorh/8431672735528634 * [image: Twitter] [image: Facebook] [image: Github] Livre de v?rus. www.avast.com . <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> From eryksun at gmail.com Fri Oct 2 18:33:05 2020 From: eryksun at gmail.com (Eryk Sun) Date: Fri, 2 Oct 2020 17:33:05 -0500 Subject: Error 0xc000007b on opening python In-Reply-To: References: Message-ID: On 10/2/20, Nipur Gupta wrote: > I've downloaded python 3.6.0 64 bits but whenever I try to open idle, it Python 3.8 supports Windows 8.1, so, unless otherwise required, you should install the latest release of 64-bit Python 3.8, which is currently 3.8.6: https://www.python.org/ftp/python/3.8.6/python-3.8.6-amd64.exe The 3.6 branch is no longer maintained. If 3.6 is required, you should install 3.6.8, the last build that was released for Windows about two years ago: https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe > doesn't open and displays error 0xc000007b. STATUS_INVALID_IMAGE_FORMAT (0xC000007B or -1073741701) is an NTSTATUS code from the native NT system beneath the Windows (Win32) API. Low-level status codes are observed for critical failures such as failing to initialize a process or an unhandled OS exception. STATUS_INVALID_IMAGE_FORMAT is from the system loader during process initialization. The executable file or a dependent DLL could be corrupt. Or the loader might be trying to load a 32-bit DLL in a 64-bit process, or vice versa. If the error persists after removing 3.6.0 and installing a newer release, then I would resolve the problem by running python.exe under a debugger with "loader snaps" enabled, which will show detailed debug messages from the loader. From python at bladeshadow.org Fri Oct 2 18:39:43 2020 From: python at bladeshadow.org (Python) Date: Fri, 2 Oct 2020 17:39:43 -0500 Subject: How to handle a dictionary value that is a list In-Reply-To: References: Message-ID: <20201002223943.GI30895@bladeshadow.org> On Fri, Oct 02, 2020 at 09:25:58PM +0100, Shaozhong SHI wrote: > Hi, All, > > I was trying to handle the value of "personRoles" in a part of json > dictionary. > > Can anyone tell me various ways to handle this? I'm not sure if I understand what you're asking, but if I do, then... you handle it just as you would handle any other list. The only difference is that instead of something like "my_list", the name of the list is d['regulatedActivities']['contacts']['personRoles']. https://docs.python.org/3/tutorial/datastructures.html Then: > f = d['regulatedActivities']['contacts']['personRoles'] After this executes, you have an alias for that list called "f" that refers to the same list object instance... So you can do all the things you can do to a list, and refer to it either as f or as d['regulatedActivities']['contacts']['personRoles'] when you do so. It is an alias, not a copy, so if you change one, you change the other. HTH. From frank at chagford.com Sat Oct 3 02:51:31 2020 From: frank at chagford.com (Frank Millman) Date: Sat, 3 Oct 2020 08:51:31 +0200 Subject: Debugging technique Message-ID: Hi all When debugging, I sometimes add a 'breakpoint()' to my code to examine various objects. However, I often want to know how I got there, so I replace the 'breakpoint()' with a '1/0', to force a traceback at that point. Then I can rerun the previous step using the extra info from the traceback. Is there a way to combine these into one step, so that, while in the debugger, I can find out how I got there? Frank Millman From rosuav at gmail.com Sat Oct 3 02:58:03 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 3 Oct 2020 16:58:03 +1000 Subject: Debugging technique In-Reply-To: References: Message-ID: On Sat, Oct 3, 2020 at 4:53 PM Frank Millman wrote: > > Hi all > > When debugging, I sometimes add a 'breakpoint()' to my code to examine > various objects. > > However, I often want to know how I got there, so I replace the > 'breakpoint()' with a '1/0', to force a traceback at that point. Then I > can rerun the previous step using the extra info from the traceback. > > Is there a way to combine these into one step, so that, while in the > debugger, I can find out how I got there? > Not sure if it's what you're looking for, but in the debugger, you can type "bt" to show a backtrace. ChrisA From frank at chagford.com Sat Oct 3 03:08:24 2020 From: frank at chagford.com (Frank Millman) Date: Sat, 3 Oct 2020 09:08:24 +0200 Subject: Debugging technique In-Reply-To: References: Message-ID: <744611f5-9d00-bf64-bb73-77357dd96e37@chagford.com> On 2020-10-03 8:58 AM, Chris Angelico wrote: > On Sat, Oct 3, 2020 at 4:53 PM Frank Millman wrote: >> >> Hi all >> >> When debugging, I sometimes add a 'breakpoint()' to my code to examine >> various objects. >> >> However, I often want to know how I got there, so I replace the >> 'breakpoint()' with a '1/0', to force a traceback at that point. Then I >> can rerun the previous step using the extra info from the traceback. >> >> Is there a way to combine these into one step, so that, while in the >> debugger, I can find out how I got there? >> > > Not sure if it's what you're looking for, but in the debugger, you can > type "bt" to show a backtrace. > That is exactly what I was looking for :-) Thanks very much. Frank From frank at chagford.com Sat Oct 3 03:08:24 2020 From: frank at chagford.com (Frank Millman) Date: Sat, 3 Oct 2020 09:08:24 +0200 Subject: Debugging technique In-Reply-To: References: Message-ID: <744611f5-9d00-bf64-bb73-77357dd96e37@chagford.com> On 2020-10-03 8:58 AM, Chris Angelico wrote: > On Sat, Oct 3, 2020 at 4:53 PM Frank Millman wrote: >> >> Hi all >> >> When debugging, I sometimes add a 'breakpoint()' to my code to examine >> various objects. >> >> However, I often want to know how I got there, so I replace the >> 'breakpoint()' with a '1/0', to force a traceback at that point. Then I >> can rerun the previous step using the extra info from the traceback. >> >> Is there a way to combine these into one step, so that, while in the >> debugger, I can find out how I got there? >> > > Not sure if it's what you're looking for, but in the debugger, you can > type "bt" to show a backtrace. > That is exactly what I was looking for :-) Thanks very much. Frank From gklein at xs4all.nl Sat Oct 3 05:52:00 2020 From: gklein at xs4all.nl (Gertjan Klein) Date: Sat, 3 Oct 2020 11:52:00 +0200 Subject: Python 3.8.5 Not Launching In-Reply-To: References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> <5f76f6be$0$306$e4fe514c@news.xs4all.nl> Message-ID: <5f7849bc$0$277$e4fe514c@news.xs4all.nl> Eryk Sun schreef: > On 10/2/20, Gertjan Klein wrote: >> Is it possible to determine, from within Python, whether Python >> allocated or inherited the console? > > If a console session isn't headless (i.e. it's not a pseudoconsole) > and has a window (i.e. not allocated with CREATE_NO_WINDOW), then the > effective owner of the window is initially the process that allocated > the console session, as long as it's still running and attached. For > example, with "python.exe" (not a launcher) executed from Explorer: > > >>> hwnd = win32console.GetConsoleWindow() > >>> tid, pid = win32process.GetWindowThreadProcessId(hwnd) > >>> pid == os.getpid() > True I can't replicate this. I installed pywin32 in a Python 3.8 virtual environment, and double-clicked on the venv\Scripts\python.exe in explorer: Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os, win32console, win32process >>> hwnd = win32console.GetConsoleWindow() >>> tid, pid = win32process.GetWindowThreadProcessId(hwnd) >>> pid == os.getpid() False I tried to find out what happens, using your other code: >>> import win32con, win32api >>> access = win32con.PROCESS_QUERY_LIMITED_INFORMATION >>> hproc = win32api.OpenProcess(access, False, pid) >>> executable = win32process.GetModuleFileNameEx(hproc, None) >>> print(executable) C:\Temp\Python\Console\venv\Scripts\python.exe >>> hproc = win32api.OpenProcess(access, False, os.getpid()) >>> win32process.GetModuleFileNameEx(hproc, None) 'C:\\dev\\Python\\Python38\\python.exe' So, if I understand this correctly, the console is owned by the venv Python, but the running process is the installed Python executable. I'm lost! How did that latter one get involved? Regards, Gertjan. From gklein at xs4all.nl Sat Oct 3 06:01:30 2020 From: gklein at xs4all.nl (Gertjan Klein) Date: Sat, 3 Oct 2020 12:01:30 +0200 Subject: Python 3.8.5 Not Launching In-Reply-To: References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> <5f76f6be$0$306$e4fe514c@news.xs4all.nl> Message-ID: <5f784bf6$0$295$e4fe514c@news.xs4all.nl> Chris Angelico schreef: > On Fri, Oct 2, 2020 at 7:51 PM Gertjan Klein wrote: >> >> Is it possible to determine, from within Python, whether Python >> allocated or inherited the console? This could be useful to know in a >> (global) error trap: to be able to see a traceback, the console must >> remain open, which won't happen if Python allocated the console itself. > > It might be possible, but then there'd have to be lots of magic and > the result would be a different set of complaints ("sometimes I get a > black window, other times it just disappears"). That sounds a bit dismissive. Who would do that complaining? I would like to be able to do this for scripts I write for myself. If these scripts have something to tell me, they should make sure I get to see that. If they don't, the console can disappear (if started from explorer). I can do this with "input('Press enter when done')" easily; however, if I start the script from a console window I get to press enter too, needlessly. > Instead of trying to > detect and such, maybe there needs to be a standard recommendation for > an atexit or something - advise people to "stick this line at the top > of your program so the black window stays around". No magic, and > completely consistent. I specifically asked for the opposite of consistency. Regards, Gertjan. From eryksun at gmail.com Sat Oct 3 06:40:39 2020 From: eryksun at gmail.com (Eryk Sun) Date: Sat, 3 Oct 2020 05:40:39 -0500 Subject: Python 3.8.5 Not Launching In-Reply-To: <5f7849bc$0$277$e4fe514c@news.xs4all.nl> References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> <5f76f6be$0$306$e4fe514c@news.xs4all.nl> <5f7849bc$0$277$e4fe514c@news.xs4all.nl> Message-ID: On 10/3/20, Gertjan Klein wrote: > > I tried to find out what happens, using your other code: > > >>> import win32con, win32api > >>> access = win32con.PROCESS_QUERY_LIMITED_INFORMATION > >>> hproc = win32api.OpenProcess(access, False, pid) > >>> executable = win32process.GetModuleFileNameEx(hproc, None) > >>> print(executable) > C:\Temp\Python\Console\venv\Scripts\python.exe > >>> hproc = win32api.OpenProcess(access, False, os.getpid()) > >>> win32process.GetModuleFileNameEx(hproc, None) > 'C:\\dev\\Python\\Python38\\python.exe' > > So, if I understand this correctly, the console is owned by the venv > Python, but the running process is the installed Python executable. I'm > lost! How did that latter one get involved? In Windows, venv defaults to copying binaries instead of creating symlinks. Starting with 3.7.2, venv copies a python.exe launcher (a custom build of the py.exe launcher) instead of copying the base executable and DLLs [1]. The launcher finds and spawns the base python.exe, and waits for it to exit. If you run the launcher from Explorer, it's the launcher that allocates and owns the console session. The base python.exe inherits the console session. The primary benefit of copying a launcher is that existing virtual environments don't have to be updated or recreated when the base installation is updated. The primary downside is that the parent process has a handle for and PID of the launcher process instead of the base Python process. This causes problems if the parent tries to manually duplicate a handle to the child, or vice versa, since it's actually duplicating the handle to the launcher process. This is particularly a problem for the multiprocessing module. It has to detect whether it's in a launcher-based virtual environment by comparing sys.executable with sys._base_executable. If they're different files, it executes sys._base_executable and sets the child's "__PYVENV_LAUNCHER__" environment variable to sys.executable (the venv launcher) in order to make it use the virtual environment. [1] https://docs.python.org/3.7/whatsnew/3.7.html#notable-changes-in-python-3-7-2 From pkpearson at nowhere.invalid Sat Oct 3 11:07:49 2020 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 3 Oct 2020 15:07:49 GMT Subject: ValueError: arrays must all be same length References: Message-ID: On Fri, 2 Oct 2020 13:34:46 +0100, Shaozhong SHI wrote: > Hello, > > I got a json response from an API and tried to use pandas to put data into > a dataframe. > > However, I kept getting this ValueError: arrays must all be same length. > > Can anyone help? > > The following is the json text. Regards, Shao > > { > "locationId": "1-1004508435", > "providerId": "1-101641521", ... [huge block removed] ... > "reportType": "Location" > } > ] > } > > In [ ]: > > > In [25]: > j > > > import pandas as pd > > import json > > j = json.JSONDecoder().decode(req.text) ###req.json > > df = pd.DataFrame.from_dict(j) An important programming skill is paring back failing code to create the smallest example that exhibits the failure. Often, the paring process reveals the problem; and if it doesn't, the shorter code is more likely to attract help. -- To email me, substitute nowhere->runbox, invalid->com. From Irv at furrypants.com Sat Oct 3 13:22:49 2020 From: Irv at furrypants.com (Irv Kalb) Date: Sat, 3 Oct 2020 10:22:49 -0700 Subject: Debugging technique In-Reply-To: References: Message-ID: This probably is not for you. But PyCharm has a panel that shows a stack trace. I created a video about debugging using the PyCharm debugger. Here is a YouTube link: https://www.youtube.com/watch?v=cxAOSQQwDJ4 Irv > On Oct 2, 2020, at 11:51 PM, Frank Millman wrote: > > Hi all > > When debugging, I sometimes add a 'breakpoint()' to my code to examine various objects. > > However, I often want to know how I got there, so I replace the 'breakpoint()' with a '1/0', to force a traceback at that point. Then I can rerun the previous step using the extra info from the traceback. > > Is there a way to combine these into one step, so that, while in the debugger, I can find out how I got there? > > Frank Millman > > -- > https://mail.python.org/mailman/listinfo/python-list > From auriocus at gmx.de Sun Oct 4 05:05:30 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sun, 4 Oct 2020 11:05:30 +0200 Subject: ValueError: arrays must all be same length In-Reply-To: References: Message-ID: Am 02.10.20 um 14:34 schrieb Shaozhong SHI: > Hello, > > I got a json response from an API and tried to use pandas to put data into > a dataframe. > > However, I kept getting this ValueError: arrays must all be same length. > > Can anyone help? > > The following is the json text. What do you expect the dataframe to look like? dataframes are 2D tables, JSON is a tree. Christian From barpasc at yahoo.com Sun Oct 4 05:35:17 2020 From: barpasc at yahoo.com (pascal z) Date: Sun, 4 Oct 2020 02:35:17 -0700 (PDT) Subject: python if and same instruction line not working In-Reply-To: References: Message-ID: <21f6c65a-cb94-4826-920f-36e49f090a04o@googlegroups.com> On Tuesday, September 29, 2020 at 5:28:22 PM UTC+2, MRAB wrote: > On 2020-09-29 15:42, pascal z via Python-list wrote: > > I need to change the script commented out to the one not commented out. Why? > > > > # for x in sorted (fr, key=str.lower): > > # tmpstr = x.rpartition(';')[2] > > # if x != csv_contents and tmpstr == "folder\n": > > # csv_contentsB += x > > # elif x != csv_contents and tmpstr == "files\n": > > # csv_contentsC += x > > > > for x in sorted (fr, key=str.lower): > > if x != csv_contents: > > tmpstr = x.rpartition(';')[2] > > if tmpstr == "folder\n": > > csv_contentsB += x > > elif tmpstr == "file\n": > > csv_contentsC += x > > > You haven't defined what you mean by "not working" for any test values > to try, but I notice that the commented code has "files\n" whereas the > uncommented code has "file\n". Very good point, it should what caused the issue By the way, it seems it's ok to check \n as end of line, it will work on windows linux and mac platforms even if windows use \r\n From barpasc at yahoo.com Sun Oct 4 05:56:06 2020 From: barpasc at yahoo.com (pascal z) Date: Sun, 4 Oct 2020 02:56:06 -0700 (PDT) Subject: python show folder files and not subfolder files In-Reply-To: References: <20200923210545.GA5917@cskk.homeip.net> <90128d85-b46a-474c-80f6-9d705dcf2fd3n@googlegroups.com> Message-ID: On Thursday, September 24, 2020 at 4:37:07 PM UTC+2, Terry Reedy wrote: > On 9/23/2020 7:24 PM, pascal z via Python-list wrote: > > Please advise if the following is ok (i don't think it is) > > > > #!/usr/bin/env python3 > > # -*- coding: utf-8 -*- > > > > import os > > > > csv_contents = "" > > output_file = '/home/user/Documents/csv/output3csv.csv' > > Lpath = '/home/user/Documents/' > > > > csv_contents = "FOLDER PATH;Size in Byte;Size in Kb;Size in Mb;Size in Gb\n" > > > > d_size = 0 > > for root, dirs, files in os.walk(Lpath, topdown=False): > > for i in files: > > d_size += os.path.getsize(root + os.sep + i) > > csv_contents += "%s ;%.2f ;%.2f ;%.2f ;%.2f \n" % (root, d_size, d_size/1024, d_size/1048576, d_size/1073741824) > > > > counter = Lpath.count(os.path.sep) > > if counter < 5: > > for f in os.listdir(Lpath): > > path = os.path.join(Lpath, f) > > f_size = 0 > > f_size = os.path.getsize(path) > > csv_contents += "%s ;%.2f ;%.2f ;%.2f ;%.2f \n" % (path, f_size, f_size/1024, f_size/1048576, f_size/1073741824) > > > > fp = open(output_file, "w") > > fp.write(csv_contents) > > fp.close() > > > Read > https://docs.python.org/3/faq/programming.html#what-is-the-most-efficient-way-to-concatenate-many-strings-together > -- > Terry Jan Reedy Thanks for this tip. I do think it's better to use lists than concatenate into string variable. However, writing a list to a csv file is not something easy. If strings stored into the list have commas and single quotes (like song title's), it messes up the whole csv when it first meets this. Example with arr as list: import csv import io (...) csv_contents = "%s;%s;%s;%.2f;%.2f;%.2f;%.2f;%s" % (vfolder_path, vfile_name, vfolder_path_full, 0.00, 0.00, 0.00,0.00, "folder") arr.append([csv_contents]) b = io.BytesIO() with open(CSV_FILE,'w', newline ='\n') as f: #write = csv.writer(f,delimiter=';') #write = csv.writer(f,quotechar='\'', quoting=csv.QUOTE_NONNUMERIC,delimiter=',') write = csv.writer(f,b) for row in arr: write.writerows(row) (...) string samples: ;'Forgotten Dreams' Mix.mp3;'Awakening of a Dream' Ambient Mix.mp3;Best of Trip-Hop & Downtempo & Hip-Hop Instrumental.mp3;2-Hour _ Space Trance.mp3 for the titles above, the easiest thing to write csv for me is (...) csv_contents += "%s;%s;%s;%.2f;%.2f;%.2f;%.2f;%s" % (vfolder_path, vfile_name, vfolder_path_full, 0.00, 0.00, 0.00,0.00, "folder" with open(CSV_FILE,'w') as f: f.write(csv_contents) csv_contents can be very large and it seems to work. It can concatenate 30k items and it's ok. Also with the above, I have the expected result into each of the 8 rows having the corresponding data. This is not always the case with csv writerows. If it meets a character it can't process, from there everything go into a single cell row. The split on semi colon from doesnt work anymore. I am not allowed to change the name of the files (it could be used later somewhere else, making side effects...). From tjandacw at gmail.com Sun Oct 4 08:39:16 2020 From: tjandacw at gmail.com (Tim Williams) Date: Sun, 4 Oct 2020 08:39:16 -0400 Subject: ValueError: arrays must all be same length In-Reply-To: References: Message-ID: On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI wrote: > Hello, > > I got a json response from an API and tried to use pandas to put data into > a dataframe. > > However, I kept getting this ValueError: arrays must all be same length. > > Can anyone help? > > The following is the json text. Regards, Shao > > (snip json_text) > import pandas as pd > > import json > > j = json.JSONDecoder().decode(req.text) ###req.json > > df = pd.DataFrame.from_dict(j) > I copied json_text into a Jupyter notebook and got the same error trying to convert this into a pandas DataFrame:When I tried to copy this into a string, I got an error,, but without enclosing the paste in quotes, I got the dictionary. dir(json_text) ['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values'] pd.DataFrame(json_text) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) in ----> 1 pd.DataFrame(json_text) D:\anaconda3\lib\site-packages\pandas\core\frame.py in __init__(self, data, index, columns, dtype, copy) 433 ) 434 elif isinstance(data, dict): --> 435 mgr = init_dict(data, index, columns, dtype=dtype) 436 elif isinstance(data, ma.MaskedArray): 437 import numpy.ma.mrecords as mrecords D:\anaconda3\lib\site-packages\pandas\core\internals\construction.py in init_dict(data, index, columns, dtype) 252 arr if not is_datetime64tz_dtype(arr) else arr.copy() for arr in arrays 253 ] --> 254 return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype) 255 256 D:\anaconda3\lib\site-packages\pandas\core\internals\construction.py in arrays_to_mgr(arrays, arr_names, index, columns, dtype) 62 # figure out the index, if necessary 63 if index is None: ---> 64 index = extract_index(arrays) 65 else: 66 index = ensure_index(index) D:\anaconda3\lib\site-packages\pandas\core\internals\construction.py in extract_index(data) 363 lengths = list(set(raw_lengths)) 364 if len(lengths) > 1: --> 365 raise ValueError("arrays must all be same length") 366 367 if have_dicts: ValueError: arrays must all be same length I got a different error trying json.loads(str(json_text)), --------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call last) in ----> 1 json.loads(str(json_text)) D:\anaconda3\lib\json\__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 355 parse_int is None and parse_float is None and 356 parse_constant is None and object_pairs_hook is None and not kw): --> 357 return _default_decoder.decode(s) 358 if cls is None: 359 cls = JSONDecoder D:\anaconda3\lib\json\decoder.py in decode(self, s, _w) 335 336 """ --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end() 339 if end != len(s): D:\anaconda3\lib\json\decoder.py in raw_decode(self, s, idx) 351 """ 352 try: --> 353 obj, end = self.scan_once(s, idx) 354 except StopIteration as err: 355 raise JSONDecodeError("Expecting value", s, err.value) from None JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) I think the solution is to fix the arrays so that the lengths match. for k in json_text.keys(): if isinstance(json_text[k], list): print(k, len(json_text[k])) relationships 0 locationTypes 0 regulatedActivities 2 gacServiceTypes 1 inspectionCategories 1 specialisms 4 inspectionAreas 0 historicRatings 4 reports 5 HTH,. -- > https://mail.python.org/mailman/listinfo/python-list > From tjandacw at gmail.com Sun Oct 4 08:53:17 2020 From: tjandacw at gmail.com (Tim Williams) Date: Sun, 4 Oct 2020 08:53:17 -0400 Subject: ValueError: arrays must all be same length In-Reply-To: References: Message-ID: On Sun, Oct 4, 2020 at 8:39 AM Tim Williams wrote: > > > On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI > wrote: > >> Hello, >> >> I got a json response from an API and tried to use pandas to put data into >> a dataframe. >> >> However, I kept getting this ValueError: arrays must all be same length. >> >> Can anyone help? >> >> The following is the json text. Regards, Shao >> >> (snip json_text) > > >> import pandas as pd >> >> import json >> >> j = json.JSONDecoder().decode(req.text) ###req.json >> >> df = pd.DataFrame.from_dict(j) >> > > I copied json_text into a Jupyter notebook and got the same error trying > to convert this into a pandas DataFrame:When I tried to copy this into a > string, I got an error,, but without enclosing the paste in quotes, I got > the dictionary. > > (delete long response output) > for k in json_text.keys(): > if isinstance(json_text[k], list): > print(k, len(json_text[k])) > > relationships 0 > locationTypes 0 > regulatedActivities 2 > gacServiceTypes 1 > inspectionCategories 1 > specialisms 4 > inspectionAreas 0 > historicRatings 4 > reports 5 > > HTH,. > > This may also be more of a pandas issue. json.loads(json.dumps(json_text)) has a successful round-trip > -- >> https://mail.python.org/mailman/listinfo/python-list >> > From python at mrabarnett.plus.com Sun Oct 4 12:39:32 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 4 Oct 2020 17:39:32 +0100 Subject: python if and same instruction line not working In-Reply-To: <21f6c65a-cb94-4826-920f-36e49f090a04o@googlegroups.com> References: <21f6c65a-cb94-4826-920f-36e49f090a04o@googlegroups.com> Message-ID: On 2020-10-04 10:35, pascal z via Python-list wrote: > On Tuesday, September 29, 2020 at 5:28:22 PM UTC+2, MRAB wrote: >> On 2020-09-29 15:42, pascal z via Python-list wrote: >> > I need to change the script commented out to the one not commented out. Why? >> > >> > # for x in sorted (fr, key=str.lower): >> > # tmpstr = x.rpartition(';')[2] >> > # if x != csv_contents and tmpstr == "folder\n": >> > # csv_contentsB += x >> > # elif x != csv_contents and tmpstr == "files\n": >> > # csv_contentsC += x >> > >> > for x in sorted (fr, key=str.lower): >> > if x != csv_contents: >> > tmpstr = x.rpartition(';')[2] >> > if tmpstr == "folder\n": >> > csv_contentsB += x >> > elif tmpstr == "file\n": >> > csv_contentsC += x >> > >> You haven't defined what you mean by "not working" for any test values >> to try, but I notice that the commented code has "files\n" whereas the >> uncommented code has "file\n". > > Very good point, it should what caused the issue > > By the way, it seems it's ok to check \n as end of line, it will work on windows linux and mac platforms even if windows use \r\n > By default, when the 'open' function opens a file in text mode, it uses "universal newlines mode", so the rest of the program doesn't have to worry about the differences in line endings. It's explained in the documentation about the 'open' function. From cs at cskk.id.au Sun Oct 4 17:19:12 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 5 Oct 2020 08:19:12 +1100 Subject: python show folder files and not subfolder files In-Reply-To: References: Message-ID: <20201004211912.GA27471@cskk.homeip.net> On 04Oct2020 02:56, pascal z wrote: >On Thursday, September 24, 2020 at 4:37:07 PM UTC+2, Terry Reedy wrote: >> Read >> https://docs.python.org/3/faq/programming.html#what-is-the-most-efficient-way-to-concatenate-many-strings-together > >Thanks for this tip. I do think it's better to use lists than >concatenate into string variable. However, writing a list to a csv file >is not something easy. If strings stored into the list have commas and >single quotes (like song title's), it messes up the whole csv when it >first meets this. [...] >[...] >csv_contents = "%s;%s;%s;%.2f;%.2f;%.2f;%.2f;%s" % (vfolder_path, >vfile_name, vfolder_path_full, 0.00, 0.00, 0.00,0.00, "folder") >arr.append([csv_contents]) >[...] Is there a reaon you're not using the csv module to write and read CSV files. It knows how to correctly escape values in a number of common dialects (the default dialect works well). By composing CSV files with %-formatting (or with any crude string cormatting) you the exact syntax issue you're describing. Faced with user supplied data, these issues become "injection attacks", as exemplified by this XKCD comics: https://xkcd.com/327/ https://www.explainxkcd.com/wiki/index.php/Little_Bobby_Tables The correct approach here is to have a general and _correct_ formatter for the values, and to not assemble things with simplistic approaches like %-formatting. With databases the standard approach for assembling SQL is to provide template SQL with the values as arguments, and have the db-specific driver construct SQL for you. And with CSV files the same applies: import the csv module and use csv.writer() to general the CSV data; you just hand the writer an array of values (strings, floats, whatever) and it takes care of using the correct syntax in the file. Cheers, Cameron Simpson From taleinat at gmail.com Sun Oct 4 13:27:42 2020 From: taleinat at gmail.com (Tal Einat) Date: Sun, 4 Oct 2020 20:27:42 +0300 Subject: Collecting more feedback about contributing to Python Message-ID: Have you tried contributing to the development of Python itself, or have considered doing so? I'd like to hear your thoughts and experiences! I'm collecting such information to guide work during the upcoming core-dev sprint on making contribution easier and friendlier. You can reach out publicly or privately. I'll keep private stories to myself, only mentioning specific relevant points from them without mentioning who sent them. Public stories will be added to the dedicated repo, which already includes many such stories which I have previously collected. https://github.com/taleinat/python-contribution-feedback For more info on the core dev sprint: https://python-core-sprint-2020.readthedocs.io/index.html - Tal Einat From mirkok.lists at googlemail.com Mon Oct 5 00:52:56 2020 From: mirkok.lists at googlemail.com (Mirko) Date: Mon, 5 Oct 2020 06:52:56 +0200 Subject: Problem In-Reply-To: <9g5hnftik3ntiadljt3dt7kihk3dik7ef0@4ax.com> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> <5F76378D.4080107@googlemail.com> <5F7783DA.9070102@gmx.net> <9g5hnftik3ntiadljt3dt7kihk3dik7ef0@4ax.com> Message-ID: <5F7AA6A8.8060301@googlemail.com> Am 03.10.2020 um 17:25 schrieb Dennis Lee Bieber: > On Fri, 2 Oct 2020 21:47:38 +0200, Hexamorph declaimed > the following: > > >> >> - Add a folder named "Python.org " (or similar) to the >> desktop with shortcuts to Python, IDLE and the CHM. >> >> - Add a checkbox (default enabled) like "Start the IDLE Python >> Editor/Shell" at the end of the installation procedure. >> > > Which may only result in reinforcing the idea that one runs the > installer to run Python. Perhaps not if the installer says, that Python is already installed and accessible per Startmenu and desktop icons. At some point they will probably notice this hint. There are multiple reasons, why beginners don't find out how to start Python. Some expect a GUI-Application like an Editor in the Startmenu, some expect desktop icons, some don't realize, that the installer is just that. They all need a different change. However, I'm out of this discussion now. With the exception of Terry changing IDLE's menu entry, this has been a very unproductive discussion. People where only highlighting possible drawbacks and remaining problems (including the usual nitpicking on edge-cases) without coming up with own ideas. If you want to lessen the amount of those initial newcomer questions, reconsider what was proposed: - Rename the MSI as suggested by Eryk Sun. - Add a folder named "Python.org " (or similar) to the desktop with shortcuts to Python, IDLE and the CHM. - Add a checkbox (default enabled) like "Start the IDLE Python Editor/Shell" at the end of the installation procedure. - Perhaps, if possible, add a button like "Start the IDLE Python Editor/Shell" to the Repair/Modify/Remove Dialog. So long and happy hacking! :-) From jpic at yourlabs.org Mon Oct 5 03:19:00 2020 From: jpic at yourlabs.org (J. Pic) Date: Mon, 5 Oct 2020 09:19:00 +0200 Subject: Debugging technique In-Reply-To: References: Message-ID: Another nice debugger feature is to step up with "u", this will take you to the parent frame where you can again inspect the variables. I use this when I want to reverse engineer how the interpreter got to a specific line. Maybe worth mentioning that Werkzeug provides in-browser interactive debuggers at each frame of a traceback, that's very nice. From shishaozhong at gmail.com Mon Oct 5 06:47:33 2020 From: shishaozhong at gmail.com (Shaozhong SHI) Date: Mon, 5 Oct 2020 11:47:33 +0100 Subject: ValueError: arrays must all be same length In-Reply-To: References: Message-ID: Hi, I managed to flatten it with json_normalize first. from pandas.io.json import json_normalize atable = json_normalize(d) atable Then, I got this table. brandId brandName careHome constituency currentRatings.overall.keyQuestionRatings currentRatings.overall.rating currentRatings.overall.reportDate currentRatings.overall.reportLinkId currentRatings.reportDate dormancy ... providerId region registrationDate registrationStatus regulatedActivities relationships reports specialisms type uprn 0 BD510 BRAND MACC Care Y Birmingham, Northfield [{u'reportDate': u'2020-10-01', u'rating': u'R... Requires improvement 2020-10-01 1157c975-c2f1-423e-a2b4-66901779e014 2020-10-01 N ... 1-101641521 West Midlands 2013-12-16 Registered [{u'code': u'RA2', u'name': u'Accommodation Then, I tried to expand the column of currentRatings.overall.keyQuestionRatings, with mydf = pd.DataFrame.from_dict(atable['currentRatings.overall.keyQuestionRatings'][0]) mydf Then, I got another table. name rating reportDate reportLinkId 0 Safe Requires improvement 2020-10-01 1157c975-c2f1-423e-a2b4-66901779e014 1 Well-led Requires improvement 2020-10-01 1157c975-c2f1-423e-a2b4-66901779e014 2 Caring Good 2019-10-04 63ff05ec-4d31-406e-83de-49a271cfdc43 3 Responsive Good 2019-10-04 63ff05ec-4d31-406e-83de-49a271cfdc43 4 Effective Requires improvement 2019-10-04 63ff05ec-4d31-406e-83de-49a271cfdc43 How can I re-arrange to get a flatten table? Apparently, the nested data is another table. Regards, Shao On Sun, 4 Oct 2020 at 13:55, Tim Williams wrote: > On Sun, Oct 4, 2020 at 8:39 AM Tim Williams wrote: > > > > > > > On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI > > wrote: > > > >> Hello, > >> > >> I got a json response from an API and tried to use pandas to put data > into > >> a dataframe. > >> > >> However, I kept getting this ValueError: arrays must all be same length. > >> > >> Can anyone help? > >> > >> The following is the json text. Regards, Shao > >> > >> (snip json_text) > > > > > >> import pandas as pd > >> > >> import json > >> > >> j = json.JSONDecoder().decode(req.text) ###req.json > >> > >> df = pd.DataFrame.from_dict(j) > >> > > > > I copied json_text into a Jupyter notebook and got the same error trying > > to convert this into a pandas DataFrame:When I tried to copy this into a > > string, I got an error,, but without enclosing the paste in quotes, I got > > the dictionary. > > > > > (delete long response output) > > > > for k in json_text.keys(): > > if isinstance(json_text[k], list): > > print(k, len(json_text[k])) > > > > relationships 0 > > locationTypes 0 > > regulatedActivities 2 > > gacServiceTypes 1 > > inspectionCategories 1 > > specialisms 4 > > inspectionAreas 0 > > historicRatings 4 > > reports 5 > > > > HTH,. > > > > > This may also be more of a pandas issue. > > json.loads(json.dumps(json_text)) > > has a successful round-trip > > > > -- > >> https://mail.python.org/mailman/listinfo/python-list > >> > > > -- > https://mail.python.org/mailman/listinfo/python-list > From tjandacw at gmail.com Mon Oct 5 12:21:30 2020 From: tjandacw at gmail.com (Tim Williams) Date: Mon, 5 Oct 2020 12:21:30 -0400 Subject: ValueError: arrays must all be same length In-Reply-To: References: Message-ID: On Mon, Oct 5, 2020 at 6:47 AM Shaozhong SHI wrote: > > Hi, I managed to flatten it with json_normalize first. > > from pandas.io.json import json_normalize > atable = json_normalize(d) > atable > > Then, I got this table. > > brandId brandName careHome constituency > currentRatings.overall.keyQuestionRatings currentRatings.overall.rating > currentRatings.overall.reportDate currentRatings.overall.reportLinkId > currentRatings.reportDate dormancy ... providerId region registrationDate > registrationStatus regulatedActivities relationships reports specialisms > type uprn > 0 BD510 BRAND MACC Care Y Birmingham, Northfield [{u'reportDate': > u'2020-10-01', u'rating': u'R... Requires improvement 2020-10-01 > 1157c975-c2f1-423e-a2b4-66901779e014 2020-10-01 N ... 1-101641521 West > Midlands 2013-12-16 Registered [{u'code': u'RA2', u'name': > u'Accommodation > > Then, I tried to expand the column > of currentRatings.overall.keyQuestionRatings, with > > mydf = > pd.DataFrame.from_dict(atable['currentRatings.overall.keyQuestionRatings'][0]) > mydf > > Then, I got another table. > > name rating reportDate reportLinkId > 0 Safe Requires improvement 2020-10-01 > 1157c975-c2f1-423e-a2b4-66901779e014 > 1 Well-led Requires improvement 2020-10-01 > 1157c975-c2f1-423e-a2b4-66901779e014 > 2 Caring Good 2019-10-04 63ff05ec-4d31-406e-83de-49a271cfdc43 > 3 Responsive Good 2019-10-04 63ff05ec-4d31-406e-83de-49a271cfdc43 > 4 Effective Requires improvement 2019-10-04 > 63ff05ec-4d31-406e-83de-49a271cfdc43 > > > How can I re-arrange to get a flatten table? > > Apparently, the nested data is another table. > > Regards, > > Shao > > > I'm fairly new to pandas myself. Can't help there. You may want to post this on Stackoverflow, or look for a similar issue on github. https://stackoverflow.com/questions/tagged/pandas+json https://github.com/pandas-dev/pandas/issues > > On Sun, 4 Oct 2020 at 13:55, Tim Williams wrote: > >> On Sun, Oct 4, 2020 at 8:39 AM Tim Williams wrote: >> >> > >> > >> > On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI >> > wrote: >> > >> >> Hello, >> >> >> >> I got a json response from an API and tried to use pandas to put data >> into >> >> a dataframe. >> >> >> >> However, I kept getting this ValueError: arrays must all be same >> length. >> >> >> >> Can anyone help? >> >> >> >> The following is the json text. Regards, Shao >> >> >> >> (snip json_text) >> > >> > >> >> import pandas as pd >> >> >> >> import json >> >> >> >> j = json.JSONDecoder().decode(req.text) ###req.json >> >> >> >> df = pd.DataFrame.from_dict(j) >> >> >> > >> > I copied json_text into a Jupyter notebook and got the same error trying >> > to convert this into a pandas DataFrame:When I tried to copy this into a >> > string, I got an error,, but without enclosing the paste in quotes, I >> got >> > the dictionary. >> > >> > >> (delete long response output) >> >> >> > for k in json_text.keys(): >> > if isinstance(json_text[k], list): >> > print(k, len(json_text[k])) >> > >> > relationships 0 >> > locationTypes 0 >> > regulatedActivities 2 >> > gacServiceTypes 1 >> > inspectionCategories 1 >> > specialisms 4 >> > inspectionAreas 0 >> > historicRatings 4 >> > reports 5 >> > >> > HTH,. >> > >> > >> This may also be more of a pandas issue. >> >> json.loads(json.dumps(json_text)) >> >> has a successful round-trip >> >> >> > -- >> >> https://mail.python.org/mailman/listinfo/python-list >> >> >> > >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From barry at python.org Mon Oct 5 14:38:58 2020 From: barry at python.org (Barry Warsaw) Date: Mon, 5 Oct 2020 11:38:58 -0700 Subject: Thank you Larry Hastings! Message-ID: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> They say being a Python Release Manager is a thankless job, so the Python Secret Underground (PSU), which emphatically does not exist, hereby officially doesn?t thank Larry for his years of diligent service as the Python 3.4 and 3.5 release manager. On the other hand, the Python Steering Council, Python Software Foundation, and worldwide Python community, all of which emphatically *do* exist, all extend our heartfelt thanks to Larry for his excellent stewardship of Python 3.4 and 3.5! Python 3.4 and 3.5 were both pivotal releases. While the features of these two releases are too numerous to mention here, they introduced such staples as: * asyncio * enum * pathlib * async and await keywords * matrix multiplication operators * typing and zipapp modules and so much more. For details, see: * https://docs.python.org/3/whatsnew/3.4.html * https://docs.python.org/3/whatsnew/3.5.html Larry?s first official release of 3.4.0a1 was on 2013-08-03 and his last Python 3.5.10 release was 2020-09-05. That?s 7 years of exemplary release managing! Larry, from all of us, and from me personally, thank you so much for your invaluable contributions to Python. Enjoy your retirement! Cheers, -Barry (on behalf of the PSC and PSF) -------------- 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 guido at python.org Mon Oct 5 14:53:55 2020 From: guido at python.org (Guido van Rossum) Date: Mon, 5 Oct 2020 11:53:55 -0700 Subject: [python-committers] Thank you Larry Hastings! In-Reply-To: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> References: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> Message-ID: Thank you Larry! On Mon, Oct 5, 2020 at 11:39 AM Barry Warsaw wrote: > They say being a Python Release Manager is a thankless job, so the Python > Secret Underground (PSU), which emphatically does not exist, hereby > officially doesn?t thank Larry for his years of diligent service as the > Python 3.4 and 3.5 release manager. > > On the other hand, the Python Steering Council, Python Software > Foundation, and worldwide Python community, all of which emphatically *do* > exist, all extend our heartfelt thanks to Larry for his excellent > stewardship of Python 3.4 and 3.5! > > Python 3.4 and 3.5 were both pivotal releases. While the features of > these two releases are too numerous to mention here, they introduced such > staples as: > > * asyncio > * enum > * pathlib > * async and await keywords > * matrix multiplication operators > * typing and zipapp modules > > and so much more. For details, see: > > * https://docs.python.org/3/whatsnew/3.4.html > * https://docs.python.org/3/whatsnew/3.5.html > > Larry?s first official release of 3.4.0a1 was on 2013-08-03 and his last > Python 3.5.10 release was 2020-09-05. That?s 7 years of exemplary release > managing! > > Larry, from all of us, and from me personally, thank you so much for your > invaluable contributions to Python. Enjoy your retirement! > > Cheers, > -Barry (on behalf of the PSC and PSF) > > _______________________________________________ > python-committers mailing list -- python-committers at python.org > To unsubscribe send an email to python-committers-leave at python.org > https://mail.python.org/mailman3/lists/python-committers.python.org/ > Message archived at > https://mail.python.org/archives/list/python-committers at python.org/message/QGIHFU64TBYT56K6M5A5LYTYTSVFKHWQ/ > Code of Conduct: https://www.python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* From taleinat at gmail.com Mon Oct 5 15:14:35 2020 From: taleinat at gmail.com (Tal Einat) Date: Mon, 5 Oct 2020 22:14:35 +0300 Subject: [python-committers] Thank you Larry Hastings! In-Reply-To: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> References: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> Message-ID: On Mon, Oct 5, 2020 at 9:39 PM Barry Warsaw wrote: > > They say being a Python Release Manager is a thankless job, so the Python Secret Underground (PSU), which emphatically does not exist, hereby officially doesn?t thank Larry for his years of diligent service as the Python 3.4 and 3.5 release manager. > > On the other hand, the Python Steering Council, Python Software Foundation, and worldwide Python community, all of which emphatically *do* exist, all extend our heartfelt thanks to Larry for his excellent stewardship of Python 3.4 and 3.5! > > Python 3.4 and 3.5 were both pivotal releases. While the features of these two releases are too numerous to mention here, they introduced such staples as: > > * asyncio > * enum > * pathlib > * async and await keywords > * matrix multiplication operators > * typing and zipapp modules > > and so much more. For details, see: > > * https://docs.python.org/3/whatsnew/3.4.html > * https://docs.python.org/3/whatsnew/3.5.html > > Larry?s first official release of 3.4.0a1 was on 2013-08-03 and his last Python 3.5.10 release was 2020-09-05. That?s 7 years of exemplary release managing! > > Larry, from all of us, and from me personally, thank you so much for your invaluable contributions to Python. Enjoy your retirement! > > Cheers, > -Barry (on behalf of the PSC and PSF) These praises are certainly very well deserved! You have my thanks as well, Larry. - Tal Einat From lukasz at langa.pl Mon Oct 5 16:22:07 2020 From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=) Date: Mon, 5 Oct 2020 22:22:07 +0200 Subject: [RELEASE] Python 3.9.0 is now available, and you can already test 3.10.0a1! Message-ID: On behalf of the Python development community and the Python 3.9 release team, I?m pleased to announce the availability of Python 3.9.0. Python 3.9.0 is the newest feature release of the Python language, and it contains many new features and optimizations. You can find Python 3.9.0 here: https://www.python.org/downloads/release/python-390/ Most third-party distributors of Python should be making 3.9.0 packages available soon. See the ?What?s New in Python 3.9 ? document for more information about features included in the 3.9 series. Detailed information about all changes made in 3.9.0 can be found in its change log . Maintenance releases for the 3.9 series will follow at regular bi-monthly intervals starting in late November of 2020. OK, boring! Where is Python 4? Not so fast! The next release after 3.9 will be 3.10. It will be an incremental improvement over 3.9, just as 3.9 was over 3.8, and so on. In fact, our newest Release Manager, Pablo Galindo Salgado, prepared the first alpha release of what will become 3.10.0 a year from now. You can check it out here: https://www.python.org/downloads/release/python-3100a1/ We hope you enjoy the new releases! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. https://www.python.org/psf/ More resources Online Documentation PEP 596 , 3.9 Release Schedule PEP 619 , 3.10 Release Schedule Report bugs at https://bugs.python.org . Help fund Python and its community . Your friendly release team, Ned Deily @nad Steve Dower @steve.dower Pablo Galindo Salgado @pablogsal ?ukasz Langa @ambv From lukasz at langa.pl Mon Oct 5 16:28:23 2020 From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=) Date: Mon, 5 Oct 2020 22:28:23 +0200 Subject: [python-committers] Thank you Larry Hastings! In-Reply-To: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> References: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> Message-ID: <7DBD640F-31B0-4B2F-BE57-3B148D7C7FE9@langa.pl> > On 5 Oct 2020, at 20:38, Barry Warsaw wrote: > > Larry, from all of us, and from me personally, thank you so much for your invaluable contributions to Python. Yes, definitely! Thank you. > Enjoy your retirement! Not so fast! Now you have all that extra free time to return to the Gilectomy! ? - ? From tjreedy at udel.edu Mon Oct 5 20:43:01 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 5 Oct 2020 20:43:01 -0400 Subject: [RELEASE] Python 3.9.0 is now available, and you can already test 3.10.0a1! In-Reply-To: References: Message-ID: > OK, boring! Where is Python 4? > > Not so fast! The next release after 3.9 will be 3.10. It will be an incremental improvement over 3.9, just as 3.9 was over 3.8, and so on. > > In fact, our newest Release Manager, Pablo Galindo Salgado, prepared the first alpha release of what will become 3.10.0 a year from now. You can check it out here: > > https://www.python.org/downloads/release/python-3100a1/ I am really happy to see this. Partly because it is the first fully post-2.x release. Partly because it is the first 3.xx release, breaking the '2 digit' minor version 'barrier' and mostly killing the spectre of an arbitrarily scheduled 4.0. Even more, because it makes new features added since the 3.9 feature freeze late last May available to anyone. It feels right to me that a bleeding-edge next-version preview release come out alone with the first production release of the new 'current' version. -- Terry Jan Reedy From cs at cskk.id.au Tue Oct 6 04:37:48 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 6 Oct 2020 19:37:48 +1100 Subject: [python-committers] Thank you Larry Hastings! In-Reply-To: References: Message-ID: <20201006083748.GA30940@cskk.homeip.net> On 05Oct2020 22:14, Tal Einat wrote: >You have my thanks as well, Larry. And mine. - Cameron Simpson From ncoghlan at gmail.com Tue Oct 6 05:07:54 2020 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 6 Oct 2020 19:07:54 +1000 Subject: [python-committers] Thank you Larry Hastings! In-Reply-To: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> References: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> Message-ID: Thank you, Larry! Cheers, Nick. From loris.bennett at fu-berlin.de Tue Oct 6 05:25:42 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Tue, 06 Oct 2020 11:25:42 +0200 Subject: [poetry] Entry points not converted to scripts Message-ID: <87y2kjyacp.fsf@hornfels.zedat.fu-berlin.de> Hi, I'm using poetry and in my pyproject.toml I have [tool.poetry.scripts] batchmon = "batch_monitor.main:main" I build the package with poetry build and then install with pip3 install --target=/home/loris/test/lib/python-3.6/site-packages --install-option="--install-scripts=/home/loris/test/bin" /home/loris/gitlab/batch_monitor/dist/batch_monitor-0.2.0-py3-none-any.whl --upgrade The package is installed OK in the target directory, but the 'bin' directory remains empty. Am I wrong in assuming that some sort of command-line script should be automatically created in 'bin' or am I just doing something wrong? Either way, how should I proceed? Cheers, Loris -- This signature is currently under construction. From loris.bennett at fu-berlin.de Tue Oct 6 09:30:55 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Tue, 06 Oct 2020 15:30:55 +0200 Subject: [poetry] Entry points not converted to scripts References: <87y2kjyacp.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <87tuv7xz00.fsf@hornfels.zedat.fu-berlin.de> "Loris Bennett" writes: > Hi, > > I'm using poetry and in my pyproject.toml I have > > [tool.poetry.scripts] > batchmon = "batch_monitor.main:main" > > I build the package with > > poetry build > > and then install with > > pip3 install --target=/home/loris/test/lib/python-3.6/site-packages > --install-option="--install-scripts=/home/loris/test/bin" > /home/loris/gitlab/batch_monitor/dist/batch_monitor-0.2.0-py3-none-any.whl > --upgrade > > The package is installed OK in the target directory, but the 'bin' > directory remains empty. > > Am I wrong in assuming that some sort of command-line script should be > automatically created in 'bin' or am I just doing something wrong? > > Either way, how should I proceed? I have worked out that poetry install will create the script in ~/.cache/pypoetry/virtualenvs/batch-monitor-JsZvz0Fs-py3.6/bin/batchmon and that export PYTHONUSERBASE=/home/loris/test pip3 install --user /home/loris/gitlab/batch_monitor/dist/batch_monitor-0.2.0-py3-none-any.whl --upgrade installs things as expected. I then just need export PYTHONPATH=/home/loris/test/lib/python3.6/site-packages to get the scripts to run. Cheers, Loris -- This signature is currently under construction. From agnese.camellini at gmail.com Tue Oct 6 16:33:23 2020 From: agnese.camellini at gmail.com (Agnese Camellini) Date: Tue, 6 Oct 2020 22:33:23 +0200 Subject: A new project to be started Message-ID: Hello to everyone, i don't have a clear idea about who to write about this project, which is only an idea, but it has to be written i think. At first it was just a comparative literature research project, but now that i am more involved in development, it has started to become more like a different programming language or framework. There is someone here who can receive attachments and who has the time to read the research project and look at the presentation i am making? Is anyone interested in developing a new language/framework on python? Who should i ask to? I only have a degree in Philosophy, i didn't have the money to take a new one in computer science and so i studied by myself (luckily the university exam bibliographies are public in Italy). I have an idea of these two fields but there is another one involved, that is Theory of language and logic (mathematical and constructivist logic). However is there anyone here i can speak to about those arguments? Thanks a lot. Agnese Camellini From Marco.Sulla.Python at gmail.com Tue Oct 6 18:38:02 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Wed, 7 Oct 2020 00:38:02 +0200 Subject: [poetry] Entry points not converted to scripts In-Reply-To: <87tuv7xz00.fsf@hornfels.zedat.fu-berlin.de> References: <87y2kjyacp.fsf@hornfels.zedat.fu-berlin.de> <87tuv7xz00.fsf@hornfels.zedat.fu-berlin.de> Message-ID: I do not know poetry, but it seems it uses virtual environments, so I suppose it's quite more simple if you run poetry shell and install and run all you need. From mkarkera98 at gmail.com Tue Oct 6 23:22:03 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Wed, 7 Oct 2020 08:52:03 +0530 Subject: Truncation error Message-ID: How is PYTHON better than other software's(MATLAB) in case of truncation or rounding off error. Thanks Meghna From Marco.Sulla.Python at gmail.com Wed Oct 7 01:53:55 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Wed, 7 Oct 2020 07:53:55 +0200 Subject: Truncation error In-Reply-To: References: Message-ID: If you want to avoid float problems, you can use Decimal: https://docs.python.org/3/library/decimal.html On Wed, 7 Oct 2020 at 05:23, Meghna Karkera wrote: > > How is PYTHON better than other software's(MATLAB) in case of truncation or > rounding off error. > > Thanks > Meghna > -- > https://mail.python.org/mailman/listinfo/python-list From loris.bennett at fu-berlin.de Wed Oct 7 02:30:28 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Wed, 07 Oct 2020 08:30:28 +0200 Subject: [poetry] Entry points not converted to scripts References: <87y2kjyacp.fsf@hornfels.zedat.fu-berlin.de> <87tuv7xz00.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <87r1qatunv.fsf@hornfels.zedat.fu-berlin.de> Marco Sulla writes: > I do not know poetry, but it seems it uses virtual environments, so I > suppose it's quite more simple if you run > > poetry shell > > and install and run all you need. As I understand it, that would just create a shell within the virtual environment. That wouldn't help me. What I wanted to do was install the package I have written somewhere in the file system (in my case actually in a NFS mounted directory), so that it can be used just like any command-line tool in the OS. As I wrote pip3 install --user is what I needed. Cheers, Loris -- This signature is currently under construction. From mkarkera98 at gmail.com Wed Oct 7 03:59:26 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Wed, 7 Oct 2020 13:29:26 +0530 Subject: Truncation error In-Reply-To: References: Message-ID: When I use the same code in MATLAB I get the answer as 4.6e-06 and when I use the same code in PYTHON I get the answer as 4.7e-06. How do I know which is the most precise and accurate value. Actually the answer is a big matrix, I've only compared the first entry of the matrix. On Wed, Oct 7, 2020, 11:24 Marco Sulla wrote: > If you want to avoid float problems, you can use Decimal: > > https://docs.python.org/3/library/decimal.html > > On Wed, 7 Oct 2020 at 05:23, Meghna Karkera wrote: > > > > How is PYTHON better than other software's(MATLAB) in case of truncation > or > > rounding off error. > > > > Thanks > > Meghna > > -- > > https://mail.python.org/mailman/listinfo/python-list > From Marco.Sulla.Python at gmail.com Wed Oct 7 07:04:48 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Wed, 7 Oct 2020 13:04:48 +0200 Subject: [poetry] Entry points not converted to scripts In-Reply-To: <87r1qatunv.fsf@hornfels.zedat.fu-berlin.de> References: <87y2kjyacp.fsf@hornfels.zedat.fu-berlin.de> <87tuv7xz00.fsf@hornfels.zedat.fu-berlin.de> <87r1qatunv.fsf@hornfels.zedat.fu-berlin.de> Message-ID: You can also, and this is the preferred way, install it in the venv and use it in the venv. When you activate the venv shell, you can `pip install` anything you want. The packages will be installed inside the venv, and you don't need any PYTHONUSERBASE or PYTHONPATH. The venv already manages this. If you think it's easier to have global installed packages (as I thought), probably you'll change your opinion with some years of experience. From loris.bennett at fu-berlin.de Wed Oct 7 07:06:04 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Wed, 07 Oct 2020 13:06:04 +0200 Subject: Embedding version in command-line program Message-ID: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> Hi, I have written a program, which I can run on the command-line thus mypyprog --version and the get the version, which is currently derived from a variable in the main module file. However, I also have the version in an __init__.py file and in a pyproject.toml (as I'm using poetry, otherwise this would be in setup.py). What's the best way of reducing these three places where the version is defined to a single one? Cheers, Loris -- This signature is currently under construction. From Marco.Sulla.Python at gmail.com Wed Oct 7 08:02:26 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Wed, 7 Oct 2020 14:02:26 +0200 Subject: Embedding version in command-line program In-Reply-To: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> Message-ID: In __init__.py, you can parse the toml file, extract the version and store it in a __version__ variable. From Marco.Sulla.Python at gmail.com Wed Oct 7 11:17:22 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Wed, 7 Oct 2020 17:17:22 +0200 Subject: Embedding version in command-line program In-Reply-To: <87blhexmcj.fsf@hornfels.zedat.fu-berlin.de> References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> <87blhexmcj.fsf@hornfels.zedat.fu-berlin.de> Message-ID: On Wed, 7 Oct 2020 at 14:16, Loris Bennett wrote: > But the toml file isn't part of the distribution and so it won't be > installed. > > I suppose I could write a separate program which parses the toml file > and then just injects the version into __init__.py. Yes, I do not know poetry, but I suppose you can generate it in its setup. I usually create a separate VERSION file and I read it in __init__.py. Other people creates a version.py that is evaled inside __init__.py From neves_kahn at hotmail.com Wed Oct 7 04:00:08 2020 From: neves_kahn at hotmail.com (rebecca kahn) Date: Wed, 7 Oct 2020 08:00:08 +0000 Subject: help with installation Message-ID: Good morning. I need to install numpy and matplotlib for school. But everytime I run the comand i get a error on the metadata fase. Can you offer assistance? Sincerely Rebecca Kahn Microsoft Windows [Version 10.0.18362.1082] (c) 2019 Microsoft Corporation. Todos os direitos reservados. C:\Users\Acer>python -m pip install numpy Collecting numpy Using cached numpy-1.19.2.zip (7.3 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... error ERROR: Command errored out with exit status 1: command: 'C:\Users\Acer\AppData\Local\Programs\Python\Python39\python.exe' 'C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\Acer\AppData\Local\Temp\tmppy7jzjum' cwd: C:\Users\Acer\AppData\Local\Temp\pip-install-x6gpr088\numpy Complete output (200 lines): Running from numpy source directory. setup.py:470: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates run_build = parse_setuppy_commands() Processing numpy/random\_bounded_integers.pxd.in Processing numpy/random\bit_generator.pyx Processing numpy/random\mtrand.pyx Processing numpy/random\_bounded_integers.pyx.in Processing numpy/random\_common.pyx Processing numpy/random\_generator.pyx Processing numpy/random\_mt19937.pyx Processing numpy/random\_pcg64.pyx Processing numpy/random\_philox.pyx Processing numpy/random\_sfc64.pyx Cythonizing sources blas_opt_info: blas_mkl_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries mkl_rt not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE blis_info: libraries blis not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE openblas_info: libraries openblas not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']' customize GnuFCompiler Could not locate executable g77 Could not locate executable f77 customize IntelVisualFCompiler Could not locate executable ifort Could not locate executable ifl customize AbsoftFCompiler Could not locate executable f90 customize CompaqVisualFCompiler Could not locate executable DF customize IntelItaniumVisualFCompiler Could not locate executable efl customize Gnu95FCompiler Could not locate executable gfortran Could not locate executable f95 customize G95FCompiler Could not locate executable g95 customize IntelEM64VisualFCompiler customize IntelEM64TFCompiler Could not locate executable efort Could not locate executable efc customize PGroupFlangCompiler Could not locate executable flang don't know how to compile Fortran code on platform 'nt' NOT AVAILABLE atlas_3_10_blas_threads_info: Setting PTATLAS=ATLAS libraries tatlas not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE atlas_3_10_blas_info: libraries satlas not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE atlas_blas_threads_info: Setting PTATLAS=ATLAS libraries ptf77blas,ptcblas,atlas not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE atlas_blas_info: libraries f77blas,cblas,atlas not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE accelerate_info: NOT AVAILABLE C:\Users\Acer\AppData\Local\Temp\pip-install-x6gpr088\numpy\numpy\distutils\system_info.py:1914: UserWarning: Optimized (vendor) Blas libraries are not found. Falls back to netlib Blas library which has worse performance. A better performance should be easily gained by switching Blas library. if self._calc_info(blas): blas_info: libraries blas not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE C:\Users\Acer\AppData\Local\Temp\pip-install-x6gpr088\numpy\numpy\distutils\system_info.py:1914: UserWarning: Blas (http://www.netlib.org/blas/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [blas]) or by setting the BLAS environment variable. if self._calc_info(blas): blas_src_info: NOT AVAILABLE C:\Users\Acer\AppData\Local\Temp\pip-install-x6gpr088\numpy\numpy\distutils\system_info.py:1914: UserWarning: Blas (http://www.netlib.org/blas/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [blas_src]) or by setting the BLAS_SRC environment variable. if self._calc_info(blas): NOT AVAILABLE non-existing path in 'numpy\\distutils': 'site.cfg' lapack_opt_info: lapack_mkl_info: libraries mkl_rt not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE openblas_lapack_info: libraries openblas not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE openblas_clapack_info: libraries openblas,lapack not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE flame_info: libraries flame not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE atlas_3_10_threads_info: Setting PTATLAS=ATLAS libraries lapack_atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib libraries tatlas,tatlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib libraries lapack_atlas not found in C:\ libraries tatlas,tatlas not found in C:\ libraries lapack_atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\libs libraries tatlas,tatlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\libs NOT AVAILABLE atlas_3_10_info: libraries lapack_atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib libraries satlas,satlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib libraries lapack_atlas not found in C:\ libraries satlas,satlas not found in C:\ libraries lapack_atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\libs libraries satlas,satlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\libs NOT AVAILABLE atlas_threads_info: Setting PTATLAS=ATLAS libraries lapack_atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib libraries ptf77blas,ptcblas,atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib libraries lapack_atlas not found in C:\ libraries ptf77blas,ptcblas,atlas not found in C:\ libraries lapack_atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\libs libraries ptf77blas,ptcblas,atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\libs NOT AVAILABLE atlas_info: libraries lapack_atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib libraries f77blas,cblas,atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib libraries lapack_atlas not found in C:\ libraries f77blas,cblas,atlas not found in C:\ libraries lapack_atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\libs libraries f77blas,cblas,atlas not found in C:\Users\Acer\AppData\Local\Programs\Python\Python39\libs NOT AVAILABLE lapack_info: libraries lapack not found in ['C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\Acer\\AppData\\Local\\Programs\\Python\\Python39\\libs'] NOT AVAILABLE C:\Users\Acer\AppData\Local\Temp\pip-install-x6gpr088\numpy\numpy\distutils\system_info.py:1748: UserWarning: Lapack (http://www.netlib.org/lapack/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [lapack]) or by setting the LAPACK environment variable. return getattr(self, '_calc_info_{}'.format(name))() lapack_src_info: NOT AVAILABLE C:\Users\Acer\AppData\Local\Temp\pip-install-x6gpr088\numpy\numpy\distutils\system_info.py:1748: UserWarning: Lapack (http://www.netlib.org/lapack/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [lapack_src]) or by setting the LAPACK_SRC environment variable. return getattr(self, '_calc_info_{}'.format(name))() NOT AVAILABLE numpy_linalg_lapack_lite: FOUND: language = c define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')] C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'define_macros' warnings.warn(msg) running dist_info running build_src build_src building py_modules sources creating build creating build\src.win-amd64-3.9 creating build\src.win-amd64-3.9\numpy creating build\src.win-amd64-3.9\numpy\distutils building library "npymath" sources error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ ---------------------------------------- ERROR: Command errored out with exit status 1: 'C:\Users\Acer\AppData\Local\Programs\Python\Python39\python.exe' 'C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\Acer\AppData\Local\Temp\tmppy7jzjum' Check the logs for full command output. Enviado do Correio para Windows 10 From thrnciar at redhat.com Wed Oct 7 05:10:54 2020 From: thrnciar at redhat.com (Tomas Hrnciar) Date: Wed, 7 Oct 2020 11:10:54 +0200 Subject: [RELEASE] Python 3.9.0 is now available, and you can already test 3.10.0a1! In-Reply-To: References: Message-ID: Hello, I am getting PGP error with the new Python3.10.0a1. I would like to ask what key it was signed with and whether it wasn't Pablo's. If so, it might be missing in pubkeys.txt. Thank you. T. On Mon, Oct 5, 2020 at 10:48 PM ?ukasz Langa wrote: > On behalf of the Python development community and the Python 3.9 release > team, I?m pleased to announce the availability of Python 3.9.0. > > Python 3.9.0 is the newest feature release of the Python language, and it > contains many new features and optimizations. You can find Python 3.9.0 > here: > > https://www.python.org/downloads/release/python-390/ < > https://www.python.org/downloads/release/python-390/> > > Most third-party distributors of Python should be making 3.9.0 packages > available soon. > > See the ?What?s New in Python 3.9 < > https://docs.python.org/release/3.9.0/whatsnew/3.9.html>? document for > more information about features included in the 3.9 series. Detailed > information about all changes made in 3.9.0 can be found in its change log < > https://docs.python.org/release/3.9.0/whatsnew/changelog.html#changelog>. > > Maintenance releases for the 3.9 series will follow at regular bi-monthly > intervals starting in late November of 2020. > > > > OK, boring! Where is Python 4? > > Not so fast! The next release after 3.9 will be 3.10. It will be an > incremental improvement over 3.9, just as 3.9 was over 3.8, and so on. > > In fact, our newest Release Manager, Pablo Galindo Salgado, prepared the > first alpha release of what will become 3.10.0 a year from now. You can > check it out here: > > https://www.python.org/downloads/release/python-3100a1/ < > https://www.python.org/downloads/release/python-3100a1/> > > We hope you enjoy the new releases! > > Thanks to all of the many volunteers who help make Python Development and > these releases possible! Please consider supporting our efforts by > volunteering yourself or through organization contributions to the Python > Software Foundation. > > https://www.python.org/psf/ > More resources > > Online Documentation > PEP 596 , 3.9 Release Schedule > PEP 619 , 3.10 Release Schedule > Report bugs at https://bugs.python.org . > Help fund Python and its community >. > Your friendly release team, > Ned Deily @nad > Steve Dower @steve.dower > Pablo Galindo Salgado @pablogsal > ?ukasz Langa @ambv > _______________________________________________ > Python-announce-list mailing list -- python-announce-list at python.org > To unsubscribe send an email to python-announce-list-leave at python.org > https://mail.python.org/mailman3/lists/python-announce-list.python.org/ > Member address: thrnciar at redhat.com > From nichalvedant07 at gmail.com Wed Oct 7 08:19:15 2020 From: nichalvedant07 at gmail.com (nichalvedant07) Date: Wed, 07 Oct 2020 17:49:15 +0530 Subject: Reply: Issues in Python Installation In-Reply-To: <5f7d5779.1c69fb81.93fa1.2ffe@mx.google.com> References: <5f7d5779.1c69fb81.93fa1.2ffe@mx.google.com> Message-ID: someone please help me out it would be of great help Sent from vivo smartphone > Hello, > > ? > > I am an amateur python developer but I?m facing a lot of issues regarding python installation on windows 10...whenever I install python on y pc...irrespective of its version my scripts folder is always empty..so I tried installing pip from the zip file available at pipy.org...pip got installed successfully but when I used it I received an error saying? > > OsError [Errno9]: Bad File Descriptor > > So, I?m not able to install pip and other modules due to which I?m facing a lot of issues. > > I would really appreciate a lot if you can help me out of this. > > I have tried out alternatives for python interpreter like anaconda, mimiconda, win python, etc.. But in vain.. > > I have tried 100s of solutions but still for no good... > > Requesting you to please please please help me out of this... > > I will be really happy and grateful to you if you could help me out of this... > > ? > > Thanks and Regards, > > Vedant Nichal > > ? > > Sent from Mail for Windows 10 > > ? > > > Virus-free. www.avast.com From loris.bennett at fu-berlin.de Wed Oct 7 08:16:28 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Wed, 7 Oct 2020 14:16:28 +0200 Subject: Embedding version in command-line program In-Reply-To: (Marco Sulla's message of "Wed, 7 Oct 2020 14:02:26 +0200") References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <874kn6xkw3.fsf@hornfels.zedat.fu-berlin.de> Hi Marco, Marco Sulla writes: > In __init__.py, you can parse the toml file, extract the version and > store it in a __version__ variable. But the toml file isn't part of the distribution and so it won't be installed. I suppose I could write a separate program which parses the toml file and then just injects the version into __init__.py. Cheers, Loris -- This signature is currently under construction. From pkpearson at nowhere.invalid Wed Oct 7 15:16:45 2020 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 7 Oct 2020 19:16:45 GMT Subject: Truncation error References: Message-ID: On Wed, 7 Oct 2020 13:29:26 +0530, Meghna Karkera wrote: > On Wed, Oct 7, 2020, 11:24 Marco Sulla wrote: >> On Wed, 7 Oct 2020 at 05:23, Meghna Karkera wrote: >> > >> > How is PYTHON better than other software's(MATLAB) in case of >> > truncation or rounding off error. > >> [snip] > > When I use the same code in MATLAB I get the answer as 4.6e-06 and when I > use the same code in PYTHON I get the answer as 4.7e-06. How do I know > which is the most precise and accurate value. Actually the answer is a big > matrix, I've only compared the first entry of the matrix. I hope your big matrix has many elements much larger than 4.7e-06, so that you don't really have to worry about which package has the smaller roundoff error. If you *are* in the situation of having to worry about roundoff error, that's likely to mean that you have to plan your entire computation around the goal of minimizing its susceptibility to tiny amounts of noise, and that's a problem much more complex than choosing a language. -- To email me, substitute nowhere->runbox, invalid->com. From loris.bennett at fu-berlin.de Thu Oct 8 09:00:37 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Thu, 08 Oct 2020 15:00:37 +0200 Subject: Embedding version in command-line program References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> <87blhexmcj.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <877ds0kh3e.fsf@hornfels.zedat.fu-berlin.de> Marco Sulla writes: > On Wed, 7 Oct 2020 at 14:16, Loris Bennett > wrote: > >> But the toml file isn't part of the distribution and so it won't be >> installed. >> >> I suppose I could write a separate program which parses the toml file >> and then just injects the version into __init__.py. > > Yes, I do not know poetry, but I suppose you can generate it in its > setup. I usually create a separate VERSION file and I read it in > __init__.py. Other people creates a version.py that is evaled inside > __init__.py I ended up using the module poetry_version which allows one to extract the version like this: import poetry_version __version__ = poetry_version.extract(source_file=__file__) Cheers, Loris -- This signature is currently under construction. From mats at python.org Thu Oct 8 12:28:08 2020 From: mats at python.org (Mats Wichmann) Date: Thu, 8 Oct 2020 10:28:08 -0600 Subject: help with installation In-Reply-To: References: Message-ID: On 10/7/20 2:00 AM, rebecca kahn wrote: > Good morning. > I need to install numpy and matplotlib for school. But everytime I run the comand i get a error on the metadata fase. Can you offer assistance? > Sincerely Rebecca Kahn > > Microsoft Windows [Version 10.0.18362.1082] > (c) 2019 Microsoft Corporation. Todos os direitos reservados. > > C:\Users\Acer>python -m pip install numpy > Collecting numpy > Using cached numpy-1.19.2.zip (7.3 MB) > Installing build dependencies ... done > Getting requirements to build wheel ... done > Preparing wheel metadata ... error > ERROR: Command errored out with exit status 1: Short answer: be patient. The root of this problem is Python 3.9 was *just* released, and some (many?) of the packages on PyPI that include version-specific wheels have not been updated yet. Use a Python 3.8 version if you're in a hurry. There is a site that has unofficial builds of many interesting packages for Windows, but personally I'm a little reluctant to point people there, as they're unsupported if there are problems. You can check the numpy status, as for any package on PyPI by searching it and going to the list of downloadable files. Here: https://pypi.org/project/numpy/#files Slightly longer description - why you see lots of scary error messages - is since pip doesn't find an appropriate wheel, it embarks on the process of building one from the source distribution. This nearly always fails for the ordinary Windows user, since the required build setup will not be present, complete, or configured. The errors come from this, but that's only because the per-built wheel was not found. (this happens every time a new Python version, that is X in 3.X comes out) From python at mrabarnett.plus.com Thu Oct 8 12:59:12 2020 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 8 Oct 2020 17:59:12 +0100 Subject: help with installation In-Reply-To: References: Message-ID: On 2020-10-08 17:28, Mats Wichmann wrote: > On 10/7/20 2:00 AM, rebecca kahn wrote: >> Good morning. >> I need to install numpy and matplotlib for school. But everytime I run the comand i get a error on the metadata fase. Can you offer assistance? >> Sincerely Rebecca Kahn >> >> Microsoft Windows [Version 10.0.18362.1082] >> (c) 2019 Microsoft Corporation. Todos os direitos reservados. >> >> C:\Users\Acer>python -m pip install numpy >> Collecting numpy >> Using cached numpy-1.19.2.zip (7.3 MB) >> Installing build dependencies ... done >> Getting requirements to build wheel ... done >> Preparing wheel metadata ... error >> ERROR: Command errored out with exit status 1: > > Short answer: be patient. > > The root of this problem is Python 3.9 was *just* released, and some > (many?) of the packages on PyPI that include version-specific wheels > have not been updated yet. > > Use a Python 3.8 version if you're in a hurry. There is a site that has > unofficial builds of many interesting packages for Windows, but > personally I'm a little reluctant to point people there, as they're > unsupported if there are problems. > > You can check the numpy status, as for any package on PyPI by searching > it and going to the list of downloadable files. Here: > > https://pypi.org/project/numpy/#files > > Slightly longer description - why you see lots of scary error messages - > is since pip doesn't find an appropriate wheel, it embarks on the > process of building one from the source distribution. This nearly > always fails for the ordinary Windows user, since the required build > setup will not be present, complete, or configured. The errors come > from this, but that's only because the per-built wheel was not found. > > (this happens every time a new Python version, that is X in 3.X comes out) > It's always worth looking at Christoph Gohlke's site: https://www.lfd.uci.edu/~gohlke/pythonlibs/ Yes, it does have numpy and matplotlib. From info at wingware.com Thu Oct 8 19:12:33 2020 From: info at wingware.com (Wingware) Date: Thu, 08 Oct 2020 19:12:33 -0400 Subject: ANN: Wing Python IDE 7.2.6 has been released Message-ID: <5F7F9CE1.6070107@wingware.com> Wing 7.2.6 improves exception reporting for pytest, implements 2w in vi mode, fixes problems with setting up a new Django project, improves auto-spacing for / and :, reduces CPU use when analyzing and waiting for remote files, and makes a number of usability improvements. Details: https://wingware.com/news/2020-10-07 Downloads: https://wingware.com/downloads == About Wing == Wing is a light-weight but full-featured Python IDE designed specifically for Python, with powerful editing, code inspection, testing, and debugging capabilities. Wing's deep code analysis provides auto-completion, auto-editing, and refactoring that speed up development. Its top notch debugger works with any Python code, locally or on a remote host. Wing also supports test-driven development, version control, UI color and layout customization, and includes extensive documentation and support. Wing is available in three product levels: Wing Pro is the full-featured Python IDE for professional developers, Wing Personal is a free Python IDE for students and hobbyists (omits some features), and Wing 101 is a very simplified free Python IDE for beginners (omits many features). Learn more at https://wingware.com/ From nospam at yrl.co.uk Thu Oct 8 19:31:20 2020 From: nospam at yrl.co.uk (Elliott Roper) Date: Thu, 08 Oct 2020 23:31:20 GMT Subject: Help! I broke python 3.9 installation on macOS Message-ID: First problem: I can no longer say Obfuscated at MyMac ~ % python3 pip -m list It cries in pain with: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3: can't open file '/Users/Obfuscated/pip': [Errno 2] No such file or directory. Why is it looking at my $HOME?? Here's some hopefully relevant outputs: First, this to show terminal has picked up $PATH from .zprofile and runs python 3.9.0 Obfuscated at MyMac ~ % python3 Python 3.9.0 (v3.9.0:9cf6752276, Oct 5 2020, 11:29:23) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> ^D however, typing various flavours of pip commands direct into the shell gives me this:- Obfuscated at MyMac ~ % pip3 list Package Version ---------- ------- pip 20.2.3 setuptools 49.2.1 and Obfuscated at MyMac ~ % pip3.8 list Package Version --------------- --------- certifi 2020.6.20 cycler 0.10.0 kiwisolver 1.2.0 matplotlib 3.3.2 numexpr 2.7.1 numpy 1.19.2 pandas 1.1.2 Pillow 7.2.0 pip 20.2.3 pyparsing 2.4.7 python-dateutil 2.8.1 pytz 2020.1 scipy 1.5.2 setuptools 49.2.1 six 1.15.0 wheel 0.35.1 Obfuscated at MyMac ~ % Something has gone wrong with site.py probably unable to fall back to using the older site-packages because of my $PATH abuse. which now reads as echo $PATH /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Pyt hon.framework/Versions/3.8/bin:/Users/Obfuscated/bin:/usr/local/bin:/usr/bin: /bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/Library/Appl e/usr/bin I tried installing the packages into 3.9 one at a time but got errors indicating that it was trying to re-compile modules like pandas from source. I saw a reply to a windows user on this list today who was advised to be patient because 3.9 might be too new to have all the binary modules in PyPi I scrubbed all of 3.9 from /Library/Frameworks/Python.framework/Versions/ and re-installed python 3.9 from Python.org to get back to the same situation described above. I have tried to work out what was wrong by reading site.py but got lost. Am I facing a ruthless deletion of every trace of Python and starting again, or waiting patiently for the binary modules to appear (3.8 still works OK, so I can live with that)?? Or is there some piece of obvious magic I have missed blundering in the land of the Sorcerer's Apprentice? Thanks -- To de-mung my e-mail address:- fsnospam$elliott$$ PGP Fingerprint: 1A96 3CF7 637F 896B C810 E199 7E5C A9E4 8E59 E248 From rosuav at gmail.com Thu Oct 8 20:07:55 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 9 Oct 2020 11:07:55 +1100 Subject: Help! I broke python 3.9 installation on macOS In-Reply-To: References: Message-ID: On Fri, Oct 9, 2020 at 10:36 AM Elliott Roper wrote: > > First problem: I can no longer say > Obfuscated at MyMac ~ % python3 pip -m list > > It cries in pain with: > > /Library/Frameworks/Python.framework/Versions/3.9/bin/python3: can't open file > '/Users/Obfuscated/pip': [Errno 2] No such file or directory. > Why is it looking at my $HOME?? > If that's an exact copy/paste from your terminal session, I may have some good news for you: the solution is easy. Try "python3 -m pip list" instead - putting the "-m" before "pip" instead of after it - and see if that solves your problem :) It's looking in your home directory because that's the current directory. If you'd typed "python3 pip.py" with no other arguments, it's more obvious that it should be reading that file from the current directory. ChrisA From Richard at Damon-Family.org Thu Oct 8 21:29:05 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Thu, 8 Oct 2020 21:29:05 -0400 Subject: Help! I broke python 3.9 installation on macOS In-Reply-To: References: Message-ID: <87bb17e6-d149-e52b-1d6b-7addd68c0b06@Damon-Family.org> On 10/8/20 7:31 PM, Elliott Roper wrote: > First problem: I can no longer say > Obfuscated at MyMac ~ % python3 pip -m list isn't that supposed to be python3 -m pip list -- Richard Damon From soyeomul at doraji.xyz Thu Oct 8 23:05:29 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Fri, 09 Oct 2020 12:05:29 +0900 Subject: Thank you Larry Hastings! References: <8890AE10-0DAD-424A-912B-2084DB98F94B@python.org> Message-ID: Barry Warsaw writes: > They say being a Python Release Manager is a thankless job, so the > Python Secret Underground (PSU), which emphatically does not exist, > hereby officially doesn?t thank Larry for his years of diligent > service as the Python 3.4 and 3.5 release manager. > > On the other hand, the Python Steering Council, Python Software > Foundation, and worldwide Python community, all of which emphatically > *do* exist, all extend our heartfelt thanks to Larry for his excellent > stewardship of Python 3.4 and 3.5! > > Python 3.4 and 3.5 were both pivotal releases. While the features of > these two releases are too numerous to mention here, they introduced > such staples as: > > * asyncio > * enum > * pathlib > * async and await keywords > * matrix multiplication operators > * typing and zipapp modules > > and so much more. For details, see: > > * https://docs.python.org/3/whatsnew/3.4.html > * https://docs.python.org/3/whatsnew/3.5.html > > Larry?s first official release of 3.4.0a1 was on 2013-08-03 and his > last Python 3.5.10 release was 2020-09-05. That?s 7 years of > exemplary release managing! > > Larry, from all of us, and from me personally, thank you so much for > your invaluable contributions to Python. Enjoy your retirement! > > Cheers, > -Barry (on behalf of the PSC and PSF) 7 years is very long. Also i would like to add personal "Thanks". Sincerely, Python fan Byung-Hee -- ^????? _????_ ?????_^))// From nichalvedant07 at gmail.com Thu Oct 8 23:36:04 2020 From: nichalvedant07 at gmail.com (Vedant Nichal) Date: Fri, 9 Oct 2020 09:06:04 +0530 Subject: Issues installing python Message-ID: Hello, I am an amateur python developer but I?m facing a lot of issues regarding python installation on windows 10...whenever I install python on my pc...irrespective of its version my scripts folder is always empty..so I tried installing pip from the zip file available at pypi.org...pip got installed successfully but when I used it I received an error saying? OsError [Errno9]: Bad File Descriptor So, I?m not able to install pip and other modules due to which I?m facing a lot of issues. I would really appreciate a lot if you can help me out of this. I have tried out alternatives for python interpreters like anaconda, miniconda, win python, etc.. But in vain.. I have tried 100s of solutions but still for no good... Requesting you to please please please help me out of this... I will be really happy and grateful to you if you could help me out of this... Thanks and Regards, Vedant Nichal From blenderclass4u at gmail.com Fri Oct 9 02:27:18 2020 From: blenderclass4u at gmail.com (Harshit Sharma) Date: Thu, 8 Oct 2020 23:27:18 -0700 (PDT) Subject: file to bits text and text containing bits to file Message-ID: <7e1522eb-c98e-4765-9bcb-428f9f79f224n@googlegroups.com> I want to read bits data of all file of any extention in 0s and 1s. And also want to do back means means construct file from bits text data how to do that tell with proof please. I am on a work of something like new sloot method but here I stuck.help everything else is done. From nospam at yrl.co.uk Fri Oct 9 06:06:58 2020 From: nospam at yrl.co.uk (Elliott Roper) Date: Fri, 09 Oct 2020 10:06:58 GMT Subject: Help! I broke python 3.9 installation on macOS References: <87bb17e6-d149-e52b-1d6b-7addd68c0b06@Damon-Family.org> Message-ID: <6DWfH.62594$HI3.12614@fx26.am4> On 9 Oct 2020 at 02:29:05 BST, "Richard Damon" wrote: > On 10/8/20 7:31 PM, Elliott Roper wrote: >> First problem: I can no longer say >> Obfuscated at MyMac ~ % python3 pip -m list > > isn't that supposed to be python3 -m pip list Oh! (insert embarrassed grin here) Thank you, and Chris. -- To de-mung my e-mail address:- fsnospam$elliott$$ PGP Fingerprint: 1A96 3CF7 637F 896B C810 E199 7E5C A9E4 8E59 E248 From rosuav at gmail.com Fri Oct 9 07:28:30 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 9 Oct 2020 22:28:30 +1100 Subject: Help! I broke python 3.9 installation on macOS In-Reply-To: <6DWfH.62594$HI3.12614@fx26.am4> References: <87bb17e6-d149-e52b-1d6b-7addd68c0b06@Damon-Family.org> <6DWfH.62594$HI3.12614@fx26.am4> Message-ID: On Fri, Oct 9, 2020 at 9:11 PM Elliott Roper wrote: > > On 9 Oct 2020 at 02:29:05 BST, "Richard Damon" > wrote: > > > On 10/8/20 7:31 PM, Elliott Roper wrote: > >> First problem: I can no longer say > >> Obfuscated at MyMac ~ % python3 pip -m list > > > > isn't that supposed to be python3 -m pip list > > Oh! (insert embarrassed grin here) > > Thank you, and Chris. > It's no shame to fail to spot things... we've all done it. Many times. It's great to know that the solution was easy :) ChrisA From jjallard at aol.com Thu Oct 8 12:58:35 2020 From: jjallard at aol.com (jjallard at aol.com) Date: Thu, 8 Oct 2020 16:58:35 +0000 (UTC) Subject: Fwd: Python 3..9.0 In-Reply-To: <1158956975.481752.1602176026519@mail.yahoo.com> References: <1158956975.481752.1602176026519.ref@mail.yahoo.com> <1158956975.481752.1602176026519@mail.yahoo.com> Message-ID: <1274432553.478807.1602176315629@mail.yahoo.com> Hi, I just downloaded the above for Windows but am unable to get it to run.? I have gone to the directory and double-clicked the "python.exe" file but that just brings me to the command prompt. Any suggestions as to what I am doing wrong? Thank you. Joe From saaad.fiji at gmail.com Fri Oct 9 03:02:08 2020 From: saaad.fiji at gmail.com (Muhammad Saad) Date: Fri, 9 Oct 2020 12:02:08 +0500 Subject: Which Version Of Python Is Best To Install Now.. Message-ID: <6A2274B6-5D67-43D3-9918-9B7B1E4CC15C@hxcore.ol> ? ? Sent from [1]Mail for Windows 10 I Want To Reinstall Python Now Which Version I Install Now References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 From jlnitchie at gmail.com Fri Oct 9 06:23:09 2020 From: jlnitchie at gmail.com (Jamie) Date: Fri, 9 Oct 2020 20:23:09 +1000 Subject: Crashing and opening problems Message-ID: I?ve downloaded python and when I try to launch a application to use with python it opens then closes fast but when I double click it it opens the installer and not python, so I have to use ?Open with? ? ? Sent from [1]Mail for Windows 10 ? References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 From mats at python.org Fri Oct 9 10:07:49 2020 From: mats at python.org (Mats Wichmann) Date: Fri, 9 Oct 2020 08:07:49 -0600 Subject: Crashing and opening problems In-Reply-To: References: Message-ID: On 10/9/20 4:23 AM, Jamie wrote: > I?ve downloaded python and when I try to launch a application to use with > python it opens then closes fast but when I double click it it opens the > installer and not python, so I have to use ?Open with? The window opened on behalf of the program is no longer needed once the program is done, so it closes once Python has exited. That's the normal behavior. You can launch programs from a command shell (cmd or powershell) and you'll see them running to completion without the shell window closing. "When I double click it" - double click what? If the download saved the installer to your desktop and that's what you're double-clicking, then indeed, you're going to get the installer again. You don't need the installer any more, so you can get rid of it if it will reduce confusion. Try launching it by finding it in the start menu - that should give you the chance to launch a Python interactive shell, or IDLE, the included IDE program. Or start typing Python into the search/Cortana box, that should give you another way to launch the actual interpreter. From mats at wichmann.us Fri Oct 9 10:17:30 2020 From: mats at wichmann.us (Mats Wichmann) Date: Fri, 9 Oct 2020 08:17:30 -0600 Subject: Which Version Of Python Is Best To Install Now.. In-Reply-To: <6A2274B6-5D67-43D3-9918-9B7B1E4CC15C@hxcore.ol> References: <6A2274B6-5D67-43D3-9918-9B7B1E4CC15C@hxcore.ol> Message-ID: On 10/9/20 1:02 AM, Muhammad Saad wrote: > ? > > ? > > Sent from [1]Mail for Windows 10 > > I Want To Reinstall Python Now Which Version I Install Now > > References > > Visible links > 1. https://go.microsoft.com/fwlink/?LinkId=550986 > The latest, 3.9, is as always considered the "best available" version. But there is no need to upgrade immediately. If you use lots of installed modules you should check if they have "caught up" - if there is actually a 3.9 version available. Popular things like numpy have not yet been released for 3.9. If you do use such packages, you can go to pypi.org and search for the modules you care about - click on Download Files and if there are lots of what look like version/operating system-encoded names like *-cp37-win_amd64.whl, *-cp38-win_amd64.whl, etc. then make sure there are ones with 39 if you want to install 3.9. If not, you'll want to stay with 3.8 for a while. From mats at python.org Fri Oct 9 10:49:14 2020 From: mats at python.org (Mats Wichmann) Date: Fri, 9 Oct 2020 08:49:14 -0600 Subject: Issues installing python In-Reply-To: References: Message-ID: On 10/8/20 9:36 PM, Vedant Nichal wrote: > Hello, > > I am an amateur python developer but I?m facing a lot of issues regarding > python installation on windows 10...whenever I install python on my > pc...irrespective of its version my scripts folder is always empty.. are you sure you're actually looking in the right place? Python Windows versions do all come with pip now. Can you launch Python itself? e.g. from a command shell: py (that assumes you installed the Python Launcher, which is a good idea if you used the Windows installer from python.org). If that works, then try: py -m pip --version if you get something comprehensible back, then you have pip installed fine. Invoke it that way, as "py -m pip" instead of using it as a standalone command. From nichalvedant07 at gmail.com Fri Oct 9 10:55:56 2020 From: nichalvedant07 at gmail.com (nichalvedant07) Date: Fri, 09 Oct 2020 20:25:56 +0530 Subject: Reply: Re: Issues installing python In-Reply-To: References: Message-ID: No.... when. I do anything of that sort it says that pip isn't recognised as an internal or external command and that's because it isn't installed....I searched the internet and it asked me to check the scripts folder to see if I have pip and it wasn't there...and im pretty sure. That I checked in the correct folder...so after that I installed pip from pypi.org but after that when I ran pip I got an error saying OS ERROR (ERRNO9): Bad file descriptor Pls help me Sent from vivo smartphone > On 10/8/20 9:36 PM, Vedant Nichal wrote: > > Hello, > > > > I am an amateur python developer but I?m facing a lot of issues regarding > > python installation on windows 10...whenever I install python on my > > pc...irrespective of its version my scripts folder is always empty.. > > are you sure you're actually looking in the right place?? Python Windows > versions do all come with pip now. > > Can you launch Python itself? > > e.g. from a command shell: > > py > > (that assumes you installed the Python Launcher, which is a good idea if > you used the Windows installer from python.org). > > If that works, then try: > > py -m pip --version > > if you get something comprehensible back, then you have pip installed > fine.? Invoke it that way, as "py -m pip" instead of using it as a > standalone command. > -- > https://mail.python.org/mailman/listinfo/python-list From nulla.epistola at web.de Fri Oct 9 11:10:55 2020 From: nulla.epistola at web.de (Sibylle Koczian) Date: Fri, 9 Oct 2020 17:10:55 +0200 Subject: Fwd: Python 3..9.0 In-Reply-To: <1274432553.478807.1602176315629@mail.yahoo.com> References: <1158956975.481752.1602176026519.ref@mail.yahoo.com> <1158956975.481752.1602176026519@mail.yahoo.com> <1274432553.478807.1602176315629@mail.yahoo.com> Message-ID: <1378f0a9-0e36-de56-c306-c87d1670d5ab@web.de> Am 08.10.2020 um 18:58 schrieb Joe via Python-list: > > Hi, > I just downloaded the above for Windows but am unable to get it to run.? I have gone to the directory and double-clicked the "python.exe" file but that just brings me to the command prompt. > Any suggestions as to what I am doing wrong? > Thank you. > Joe > How does this command prompt look? Like this, only with "Python 3.9.0", another date etc.? Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> That would be exactly right: you have opened the interactive interpreter where you can try out things - evaluate expressions, write short functions and call them etc. At this point the official tutorial will help further. Or like this (other version number, other starting directory)? Microsoft Windows [Version 10.0.19041.508] (c) 2020 Microsoft Corporation. Alle Rechte vorbehalten. C:\Users\Sibylle> In that case something is really wrong: this would be the usual Windows command prompt, nothing to do with Python. From nulla.epistola at web.de Fri Oct 9 11:10:55 2020 From: nulla.epistola at web.de (Sibylle Koczian) Date: Fri, 9 Oct 2020 17:10:55 +0200 Subject: Fwd: Python 3..9.0 In-Reply-To: <1274432553.478807.1602176315629@mail.yahoo.com> References: <1158956975.481752.1602176026519.ref@mail.yahoo.com> <1158956975.481752.1602176026519@mail.yahoo.com> <1274432553.478807.1602176315629@mail.yahoo.com> Message-ID: <1378f0a9-0e36-de56-c306-c87d1670d5ab@web.de> Am 08.10.2020 um 18:58 schrieb Joe via Python-list: > > Hi, > I just downloaded the above for Windows but am unable to get it to run.? I have gone to the directory and double-clicked the "python.exe" file but that just brings me to the command prompt. > Any suggestions as to what I am doing wrong? > Thank you. > Joe > How does this command prompt look? Like this, only with "Python 3.9.0", another date etc.? Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> That would be exactly right: you have opened the interactive interpreter where you can try out things - evaluate expressions, write short functions and call them etc. At this point the official tutorial will help further. Or like this (other version number, other starting directory)? Microsoft Windows [Version 10.0.19041.508] (c) 2020 Microsoft Corporation. Alle Rechte vorbehalten. C:\Users\Sibylle> In that case something is really wrong: this would be the usual Windows command prompt, nothing to do with Python. From heindsight at kruger.dev Fri Oct 9 12:23:55 2020 From: heindsight at kruger.dev (Heinrich Kruger) Date: Fri, 09 Oct 2020 16:23:55 +0000 Subject: Embedding version in command-line program In-Reply-To: <877ds0kh3e.fsf@hornfels.zedat.fu-berlin.de> References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> <87blhexmcj.fsf@hornfels.zedat.fu-berlin.de> <877ds0kh3e.fsf@hornfels.zedat.fu-berlin.de> Message-ID: ??????? Original Message ??????? On Thursday, October 8, 2020 2:00 PM, Loris Bennett wrote: > Marco Sulla Marco.Sulla.Python at gmail.com writes: > > > On Wed, 7 Oct 2020 at 14:16, Loris Bennett loris.bennett at fu-berlin.de > > wrote: > > > > > But the toml file isn't part of the distribution and so it won't be > > > installed. > > > I suppose I could write a separate program which parses the toml file > > > and then just injects the version into init.py. > > > > Yes, I do not know poetry, but I suppose you can generate it in its > > setup. I usually create a separate VERSION file and I read it in > > init.py. Other people creates a version.py that is evaled inside > > init.py > > I ended up using the module > > poetry_version > > which allows one to extract the version like this: > > import poetry_version > > version = poetry_version.extract(source_file=file) > It looks to me like that package also just reads the pyproject.toml file. You could try using the "importlib.metadata" module (https://docs.python.org/3.8/library/importlib.metadata.html). If you're still using python 3.7 (or older) you can install importlib-metadata from PyPI (https://pypi.org/project/importlib-metadata/). Try putting something like ``` from importlib import metadata __version__ = metadata.version(__name__) ``` in your __init__.py file. Then you can do something like: ``` from . import __version__ def main(): print(f"Version: {__version__}") ``` Bear in mind that this would only work if your package is installed (e.g. in virtual environment). Otherwise the `metadata.version(__name__)` call will fail with a `importlib.metadata.PackageNotFoundError` exception (of course you could catch that and fall back to trying to read the pyproject.toml file). -- Heinrich Kruger From mahmoodia.reza at gmail.com Fri Oct 9 12:44:12 2020 From: mahmoodia.reza at gmail.com (reza) Date: Fri, 9 Oct 2020 09:44:12 -0700 (PDT) Subject: find command from command list by Python and natural language processing Message-ID: <090e9839-1581-48ae-80ca-60e64a7bfe83n@googlegroups.com> I want to build a speech recognition system so that when I give an instruction it can execute the command I want. I came and said the voice through the microphone and gave it to a model (speech to text ) to return the text. Now I want to know which command this text belongs to among the different commands. for example : The command I said through the microphone: Shut down the system the system Shut down Shut down Or another command Turn on the system My command list: command_list = ["open" ,"shut down " , "close " , "turn of " ,........] Can you tell me what code to write in Python and natural language processing? From Joseph.Schachner at Teledyne.com Fri Oct 9 12:52:10 2020 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Fri, 9 Oct 2020 16:52:10 +0000 Subject: Python 3..9.0 In-Reply-To: <1274432553.478807.1602176315629@mail.yahoo.com> References: <1158956975.481752.1602176026519.ref@mail.yahoo.com> <1158956975.481752.1602176026519@mail.yahoo.com> <1274432553.478807.1602176315629@mail.yahoo.com> Message-ID: You're not doing anything wrong, but clearly it's not what you want to do. You are running the Python interpreter and not specifying any script to run, so it opens a command prompt and promptly closes it, I'll bet. What you want to do is open a development environment. Try Idle, it's there in your Python installation. Or download PyScripter, or Jetbrains' PyCharm, or Wing (see recent new version announcement). --- Joseph S. -----Original Message----- From: jjallard at aol.com Sent: Thursday, October 8, 2020 12:59 PM To: python-list at python.org Subject: Fwd: Python 3..9.0 Hi, I just downloaded the above for Windows but am unable to get it to run.? I have gone to the directory and double-clicked the "python.exe" file but that just brings me to the command prompt. Any suggestions as to what I am doing wrong? Thank you. Joe From PythonList at DancesWithMice.info Fri Oct 9 16:12:28 2020 From: PythonList at DancesWithMice.info (dn) Date: Sat, 10 Oct 2020 09:12:28 +1300 Subject: file to bits text and text containing bits to file In-Reply-To: <7e1522eb-c98e-4765-9bcb-428f9f79f224n@googlegroups.com> References: <7e1522eb-c98e-4765-9bcb-428f9f79f224n@googlegroups.com> Message-ID: <210330d5-cef6-d509-6ef6-78e5507f2436@DancesWithMice.info> On 09/10/2020 19:27, Harshit Sharma wrote: > I want to read bits data of all file of any extention in 0s and 1s. And also want to do back means means construct file from bits text data how to do that tell with proof please. I am on a work of something like new sloot method but here I stuck.help everything else is done. Which (Python) tool(s) are you currently using? What (Python) research have you done? -- Regards =dn From blenderclass4u at gmail.com Sat Oct 10 03:57:30 2020 From: blenderclass4u at gmail.com (Harshit Sharma) Date: Sat, 10 Oct 2020 00:57:30 -0700 (PDT) Subject: file to bits text and text containing bits to file In-Reply-To: References: <210330d5-cef6-d509-6ef6-78e5507f2436@DancesWithMice.info> <7e1522eb-c98e-4765-9bcb-428f9f79f224n@googlegroups.com> Message-ID: On Saturday, October 10, 2020 at 1:43:09 AM UTC+5:30, dn wrote: > On 09/10/2020 19:27, Harshit Sharma wrote: > > I want to read bits data of all file of any extention in 0s and 1s. And also want to do back means means construct file from bits text data how to do that tell with proof please. I am on a work of something like new sloot method but here I stuck.help everything else is done. > Which (Python) tool(s) are you currently using? > What (Python) research have you done? > -- > Regards =dn I have got solution to that using bitstring module. I will tell to the world when program will get ready my blueprint of program is fully ready but I don't know coding very much so it will take time. it may take 3 or 4 months to code because I have to search on net everything how to do this or that in code. Or take help in social media. I also have to manage my studies side by side. Is there anyone who will code the program for me and make me owner for free or whatever I can make that but slowly. From hedge.tom14 at yahoo.com Sat Oct 10 02:22:55 2020 From: hedge.tom14 at yahoo.com (Tom Hedge) Date: Sat, 10 Oct 2020 06:22:55 +0000 (UTC) Subject: Trying to Download PygameZero References: <1820119831.51290.1602310975004.ref@mail.yahoo.com> Message-ID: <1820119831.51290.1602310975004@mail.yahoo.com> I am in a 8 grade coding class at the moment and my teacher asked me to download a script called pgzero. I can not seem to download pgzer or pygame when i try it shoots me a error message:??ERROR: Command errored out with exit status 1:? ? ?command: 'c:\program files\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\thedg\\AppData\\Local\\Temp\\pip-install-g9sb_mr0\\pygame\\setup.py'"'"'; __file__='"'"'C:\\Users\\thedg\\AppData\\Local\\Temp\\pip-install-g9sb_mr0\\pygame\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\thedg\AppData\Local\Temp\pip-pip-egg-info-rre7x6r3'? ? ? ? ?cwd: C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\? ? Complete output (17 lines): ? ? WARNING, No "Setup" File Exists, Running "buildconfig/config.py"? ? Using WINDOWS configuration... ? ? Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? [Y/n]Traceback (most recent call last):? ? ? File "", line 1, in ? ? ? File "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\setup.py", line 194, in ? ? ? ? buildconfig.config.main(AUTO_CONFIG)? ? ? File "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\config.py", line 210, in main? ? ? ? deps = CFG.main(**kwds)? ? ? File "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\config_win.py", line 576, in main? ? ? ? and download_win_prebuilt.ask(**download_kwargs):? ? ? File "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask? ? ? ? reply = raw_input(? ? EOFError: EOF when reading a line? ? ----------------------------------------ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Please let me know ASAP how to fix this. Ive spent countless hours trying to fix this, ive tried my changing my Path becasue thats what everyone told me. I have also tried some other means to fix this and non have been sucsussful. Please Help me, From suwoniwonni at gmail.com Sat Oct 10 09:54:10 2020 From: suwoniwonni at gmail.com (=?UTF-8?B?7IiY6r+N7J20?=) Date: Sat, 10 Oct 2020 06:54:10 -0700 (PDT) Subject: python Message-ID: <877a940c-dec1-44a9-867c-53fce11e8768n@googlegroups.com> import numpy as np import matplotlib.pylab as plt x = [1, -2 , 1]; h = [1 , 2 , -1 , 0 , 3 , 1]; nx = nx=[0,1,2]; nh =[0,1,2,3,4,5] y = np.convolve(x ,h) ny = np.arange(nx[0] + nh[0], nx[-1] + nx[-1]+1,nx[1]); print(ny,y) plt.subplot(1,1,1); plt.stem(y) plt.subplot(1,1,1); plt.stem( ny, y) ValueError: x and y must have same first dimension, but have shapes (5,) and (8,) -whan can i do?? please comment please ?? From mats at python.org Sat Oct 10 11:11:11 2020 From: mats at python.org (Mats Wichmann) Date: Sat, 10 Oct 2020 09:11:11 -0600 Subject: Trying to Download PygameZero In-Reply-To: <1820119831.51290.1602310975004@mail.yahoo.com> References: <1820119831.51290.1602310975004.ref@mail.yahoo.com> <1820119831.51290.1602310975004@mail.yahoo.com> Message-ID: <4abc93ea-5a8d-7f48-aa15-bfdf96140611@python.org> On 10/10/20 12:22 AM, Tom Hedge via Python-list wrote: > I am in a 8 grade coding class at the moment and my teacher asked me to download a script called pgzero. I can not seem to download pgzer or pygame when i try it shoots me a error message:??ERROR: Command errored out with exit status 1:? ? ?command: 'c:\program files\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\thedg\\AppData\\Local\\Temp\\pip-install-g9sb_mr0\\pygame\\setup.py'"'"'; __file__='"'"'C:\\Users\\thedg\\AppData\\Local\\Temp\\pip-install-g9sb_mr0\\pygame\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\thedg\AppData\Local\Temp\pip-pip-egg-info-rre7x6r3'? ? ? ? ?cwd: C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\? ? Complete output (17 lines): > > ? ? WARNING, No "Setup" File Exists, Running "buildconfig/config.py"? ? Using WINDOWS configuration... > > ? ? Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? [Y/n]Traceback (most recent call last):? ? ? File "", line 1, in ? ? ? File "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\setup.py", line 194, in ? ? ? ? buildconfig.config.main(AUTO_CONFIG)? ? ? File "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\config.py", line 210, in main? ? ? ? deps = CFG.main(**kwds)? ? ? File "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\config_win.py", line 576, in main? ? ? ? and download_win_prebuilt.ask(**download_kwargs):? ? ? File "C:\Users\thedg\AppData\Local\Temp\pip-install-g9sb_mr0\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask? ? ? ? reply = raw_input(? ? EOFError: EOF when reading a line? ? ----------------------------------------ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. > > Please let me know ASAP how to fix this. Ive spent countless hours trying to fix this, ive tried my changing my Path becasue thats what everyone told me. I have also tried some other means to fix this and non have been sucsussful. > Please Help me, > The problem is the pygame developers have not released a pygame for Python 3.9 and you're using Python 3.9. You can check the availability here: https://pypi.org/project/pygame/#files Easiest answer is to stick with Python 3.8.6 for now. Slightly longer: all those daunting error messages are because pip didn't find a wheel file matching your python version / operating system / architecture, and thus wants to instead download the source distribution and build it (that's the pygame\\setup.py). And that fails, as it normally does for Windows users. From pkpearson at nowhere.invalid Sat Oct 10 11:58:18 2020 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 10 Oct 2020 15:58:18 GMT Subject: Python's carbon guilt Message-ID: Python advocates might want to organize their thoughts on this subject before their bosses spring the suggestion: >From https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change : . . . Astronomers should also abandon popular programming languages such as Python in favor of efficient compiled languages. Languages such as Fortran and C++, Zwart calculates, are more than 100 times more carbon efficient than Python because they require fewer operations. -- To email me, substitute nowhere->runbox, invalid->com. From hjp-python at hjp.at Sat Oct 10 11:58:34 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 10 Oct 2020 17:58:34 +0200 Subject: Truncation error In-Reply-To: References: Message-ID: <20201010155834.GA6137@hjp.at> On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: > If you want to avoid float problems, you can use Decimal: Decimal doesn't avoid floating point problems, because it is a floating point format. For example: Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from decimal import * >>> a = Decimal(3) >>> a Decimal('3') >>> b = Decimal(1E50) >>> b Decimal('100000000000000007629769841091887003294964970946560') >>> c = Decimal(2) >>> a + b - c - b Decimal('8112996705035029053440') >>> b - b + a - c Decimal('1') >>> a + (b - b) - c Decimal('1') >>> a + b - b - c Decimal('8112996705035029053438') >>> Mathematically, all four expressions should have the result 1, but with floating point numbers they don't because intermediate results are rounded. For comparison, here are the results with float: >>> a + b - c - b 0.0 >>> b - b + a - c 1.0 >>> a + (b - b) - c 1.0 >>> a + b - b - c -2.0 >>> One could argue that these are at least closer to the truth, although I think that's just luck, Decimal does have two advantages over float: a) It's precision is configurable and even by default higher. So on average, the error is smaller (but still not zero). b) It uses decimal numbers like we learned in school. So it will make the same errors as we make when we use pencil and paper, which is less confusing to laypersons than the seemingly arbitrary errors from converting from decimal to binary and back. The disadvantages are of course higher memory consumption and lower speed. Also, I'm very confident that the engineers at Intel and AMD knew what they were doing when they designed the FP units of their processors. I'm slightly less confident about the authors of the Decimal module. And I'm much less confident that the average Python programmer can implement a matrix multiplication with Decimal which is as numerically stable as what Matlab or Pandas provide using IEEE-754 arithmetic. hp PS: I recently read an interesting article on the Android calculator. That goes to extreme lengths to avoid unexpected rounding errors. It is also very slow, but still faster than a human can look, so it doesn't matter. -- _ | 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 mkarkera98 at gmail.com Sat Oct 10 12:24:38 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Sat, 10 Oct 2020 21:54:38 +0530 Subject: Truncation error In-Reply-To: <20201010155834.GA6137@hjp.at> References: <20201010155834.GA6137@hjp.at> Message-ID: Thanks, the problem was I solved a covariance matrix manually, but my fellow mate using the covariance syntax. That's why there was difference in Matlab and python results. But now when I use the covariance syntax in python, matlab and python gives the same results. On Sat, Oct 10, 2020, 21:37 Peter J. Holzer wrote: > On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: > > If you want to avoid float problems, you can use Decimal: > > Decimal doesn't avoid floating point problems, because it is a floating > point format. For example: > > Python 3.8.5 (default, Jul 28 2020, 12:59:40) > [GCC 9.3.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> from decimal import * > >>> a = Decimal(3) > >>> a > Decimal('3') > >>> b = Decimal(1E50) > >>> b > Decimal('100000000000000007629769841091887003294964970946560') > >>> c = Decimal(2) > >>> a + b - c - b > Decimal('8112996705035029053440') > >>> b - b + a - c > Decimal('1') > >>> a + (b - b) - c > Decimal('1') > >>> a + b - b - c > Decimal('8112996705035029053438') > >>> > > Mathematically, all four expressions should have the result 1, but with > floating point numbers they don't because intermediate results are > rounded. > > For comparison, here are the results with float: > > >>> a + b - c - b > 0.0 > >>> b - b + a - c > 1.0 > >>> a + (b - b) - c > 1.0 > >>> a + b - b - c > -2.0 > >>> > > One could argue that these are at least closer to the truth, although I > think that's just luck, > > Decimal does have two advantages over float: > > a) It's precision is configurable and even by default higher. So on > average, the error is smaller (but still not zero). > > b) It uses decimal numbers like we learned in school. So it will make > the same errors as we make when we use pencil and paper, which is > less confusing to laypersons than the seemingly arbitrary errors from > converting from decimal to binary and back. > > > The disadvantages are of course higher memory consumption and lower > speed. Also, I'm very confident that the engineers at Intel and AMD knew > what they were doing when they designed the FP units of their > processors. I'm slightly less confident about the authors of the Decimal > module. And I'm much less confident that the average Python programmer > can implement a matrix multiplication with Decimal which is as > numerically stable as what Matlab or Pandas provide using IEEE-754 > arithmetic. > > hp > > PS: I recently read an interesting article on the Android calculator. > That goes to extreme lengths to avoid unexpected rounding errors. > It is also very slow, but still faster than a human can look, so it > doesn't matter. > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp at hjp.at | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > -- > https://mail.python.org/mailman/listinfo/python-list > From hjp-python at hjp.at Sat Oct 10 12:31:43 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 10 Oct 2020 18:31:43 +0200 Subject: Python's carbon guilt In-Reply-To: References: Message-ID: <20201010163143.GB6137@hjp.at> On 2020-10-10 15:58:18 +0000, Peter Pearson wrote: > Python advocates might want to organize their thoughts on > this subject before their bosses spring the suggestion: > > From https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change : > > . . . Astronomers should also abandon popular programming languages > such as Python in favor of efficient compiled languages. Languages > such as Fortran and C++, Zwart calculates, are more than 100 times > more carbon efficient than Python because they require fewer > operations. > It would be interesting on which data he based these calculations. For simple benchmarks of numerical code that's almost certainly true, but I doubt anyone writes code intended to run on a supercomputer in plain Python. Surely such programs would use numpy or other specialized libraries which are already written in C or Fortran and may even use a GPU if present? There is of course still some overhead, but it's much smaller. 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 rosuav at gmail.com Sat Oct 10 13:30:21 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 11 Oct 2020 04:30:21 +1100 Subject: Python's carbon guilt In-Reply-To: References: Message-ID: On Sun, Oct 11, 2020 at 3:01 AM Peter Pearson wrote: > > Python advocates might want to organize their thoughts on > this subject before their bosses spring the suggestion: > > From https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change : > > . . . Astronomers should also abandon popular programming languages > such as Python in favor of efficient compiled languages. Languages > such as Fortran and C++, Zwart calculates, are more than 100 times > more carbon efficient than Python because they require fewer > operations. > > Ahh, yes, a new way for people to worship the little tin god. How cute. :) ChrisA From Marco.Sulla.Python at gmail.com Sat Oct 10 15:35:15 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Sat, 10 Oct 2020 21:35:15 +0200 Subject: Python's carbon guilt In-Reply-To: References: Message-ID: He should also calculate the carbon dioxide emitted by brains that works in C++ only. I omit other sources. From avigross at verizon.net Sat Oct 10 17:48:34 2020 From: avigross at verizon.net (Avi Gross) Date: Sat, 10 Oct 2020 17:48:34 -0400 Subject: Python's carbon guilt In-Reply-To: References: Message-ID: <024c01d69f4f$1abf0f50$503d2df0$@verizon.net> People have a tendency to go too far in their religious zeal, Peter. We could go back to writing on chalkboards to do calculations then re-use the chalk dust when erasing to write again. Many computers do almost nothing 90+ percent of the time. Want to outlaw those or force them to accept random jobs from the internet when relatively idle? But all kidding aside, anything used frequently and not changed often might be a good candidate for an efficient solution that uses fewer resources. Yet our computers, so far, have been in many ways getting cheaper and in many cases use less electricity to do the same number of calculations. But there are tradeoffs such as optimizing speed over memory use or other resources that are external and thus slower. The ultimate carbon cost can sometimes be for carbon-based organisms, most of them suitable to be called human. When you measure how long it takes them to develop applications and verify they have minimal bugs, you may notice that some development environments seem to take lots more time than others for common tasks. Interactive has huge advantages in many cases. Slowest would be asking people to go back to writing in machine code, not very portably. The reality is that speed and other resource use do matter for anything run often or that would take a very long time. Languages like python and R acknowledge that and quite a few parts are now replaced by calls to libraries in other language or C/C++ code. But often that is done only later when the code is not going to be changed regularly. I think there is a reality here. The costs of computing end sometimes of power usage, often are dropping. The users like getting extra features and underneath the covers, that often means lots of extra IF statements or other checks, or loops that keep checking regularly to see if they need to do anything. If you program a GUI that allows the user to click or type in many places at random, there can be lots of overhead even when done in a compiled language. True speed and efficiency might require removing lots of features entirely as too expensive. It may well be cheaper to do some operations on matrices where every row/column is of the same object type but there are very serious advantages to allowing a mixed type operation such as a data.frame where each column is a hidden vector of some type or even at times to allowing every cell/item to be of any object type. The overhead rises in terms of storage and CPU time used but it allows higher levels of abstraction and often the ability to write code with fewer lines that handles many more conditions, sometimes invisibly. Consider how computing is being used and ask if a little more carbon footprint there may reduce the carbon footprint elsewhere. Would you rather have people spend years or months developing some app that can be used in a way that reduces overall carbon dioxide production? If your answer is that you can have it both ways, fine. But you may have trouble hiring enough people willing to work under those constraints and you may be told of lots of things they won't feel comfortable doing and it may take longer and ... A question. Are recent compiled languages that add features as small and fast as earlier ones? For example, many older languages required a function to take a fixed number of arguments in a fixed order and of exactly the types mentioned when created. Some interpreted languages allow lots of additional functionality, some of which could easily be provided such as allowing named arguments in any order, or allowing additional optional arguments or default values and so on. Much of this could be done in a compiled way, but with additional compile time and even run-time cost. But some features, by definition, must be at run time and especially for code that modifies itself or creates new objects dynamically. IF you want some of these new features, how would you supply them in a compiled way without adding lots of the overhead you want to reduce? Carbon guilt should not be taken seriously as an immediate goal as compared to an overall goal. If we make more people able to work from home or nearby offices and avoid long commutes, does it matter if your remote work is much more carbon friendly than the costs to travel and then still use other energy there for lighting and more computers and ... -----Original Message----- From: Python-list On Behalf Of Peter Pearson Sent: Saturday, October 10, 2020 11:58 AM To: python-list at python.org Subject: Python's carbon guilt Python advocates might want to organize their thoughts on this subject before their bosses spring the suggestion: From https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confr ont-their-role-and-vulnerability-climate-change : . . . Astronomers should also abandon popular programming languages such as Python in favor of efficient compiled languages. Languages such as Fortran and C++, Zwart calculates, are more than 100 times more carbon efficient than Python because they require fewer operations. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list From Gronicus at SGA.Ninja Sat Oct 10 18:17:26 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sat, 10 Oct 2020 18:17:26 -0400 Subject: Problem saving datetime to file and reading it back for a calculation Message-ID: <001001d69f53$232704f0$69750ed0$@SGA.Ninja> I would like to use the line: HoursDiff = int((d2-d1).total_seconds()/3600) to determine the difference in hours between two timedate entries. The variable d2 is from datetime.now() and d1 is read from a text file. I can save d2 to the file only if I convert it to string and, at a later date, it gets read back in as d1 as string. The variable d1 as string will not work in the HoursDiff statement. To me, it looks like a problem in formatting. How do I fix this? Steve From pkpearson at nowhere.invalid Sat Oct 10 20:06:10 2020 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 11 Oct 2020 00:06:10 GMT Subject: Problem saving datetime to file and reading it back for a calculation References: <001001d69f53$232704f0$69750ed0$@SGA.Ninja> Message-ID: On Sat, 10 Oct 2020 18:17:26 -0400, Steve wrote: > I would like to use the line: > HoursDiff = int((d2-d1).total_seconds()/3600) > to determine the difference in hours between two timedate entries. > > The variable d2 is from datetime.now() > and d1 is read from a text file. > > I can save d2 to the file only if I convert it to string and, at a later > date, it gets read back in as d1 as string. The variable d1 as string will > not work in the HoursDiff statement. > > To me, it looks like a problem in formatting. > How do I fix this? datetime.datetime.strftime and datetime.datetime.strptime ? >>> t = datetime.datetime.now() >>> t.strftime("%Y-%m-%d %H:%M:%S") '2020-10-10 18:02:33' >>> b = datetime.datetime.strptime("2020-09-09 12:34:56", "%Y-%m-%d %H:%M:%S") >>> b.strftime("%Y-%m-%d %H:%M:%S") '2020-09-09 12:34:56' >>> -- To email me, substitute nowhere->runbox, invalid->com. From cs at cskk.id.au Sat Oct 10 21:50:11 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Sun, 11 Oct 2020 12:50:11 +1100 Subject: Problem saving datetime to file and reading it back for a calculation In-Reply-To: <001001d69f53$232704f0$69750ed0$@SGA.Ninja> References: <001001d69f53$232704f0$69750ed0$@SGA.Ninja> Message-ID: <20201011015011.GA37900@cskk.homeip.net> On 10Oct2020 18:17, Steve wrote: >I would like to use the line: >HoursDiff = int((d2-d1).total_seconds()/3600) >to determine the difference in hours between two timedate entries. > >The variable d2 is from datetime.now() >and d1 is read from a text file. > >I can save d2 to the file only if I convert it to string and, at a later >date, it gets read back in as d1 as string. That is the nature of text files. >The variable d1 as string will >not work in the HoursDiff statement. Because it is a string. Peter has described a way to transcribe a datetime in an arbitrary string format and back. Note that his example formats are "naive" - they don't know what you timezone is, and you want that if that ever varies (not just datetimes in contexts from different places, but also at different times of the year if you run different summer and winter times, particularly troublesome around the transition from one to the other). >To me, it looks like a problem in formatting. >How do I fix this? Personally I strongly dislike using datetimes for computation or as the basis for time record keeping, essentially because of the timezone issue but also because the human calendar is a complex disaster of illfitting units (days in a year? variable; days in a month? variable; that table of days per unit? variable depending on your time in history). Instead, I always try to work in POSIX timestamps, an absolute number of seconds since midnight, 1 January 1970 GMT. You can always do arithmetic directly between these in seconds, then convert for presentation purposes whenever. Because you're now working in seconds directly, you go: HoursDiff = int((t2-t1)/3600) or: HoursDiff = (t2-t1) // 3600 When you first collect your datetime, convert it to a POSIX timestamp immediately. If you're _starting_ from datetime.now(), do not do that! Just start with time.time() and no conversion is needed at all. Just _present_ in datetime formats if you need to. DO NOT try to work with them as your basic type - they are a source of pitfalls. As far as storing timestamps in a file, they're ints or floats; just write them out. Cheers, Cameron Simpson From rosuav at gmail.com Sat Oct 10 22:02:15 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 11 Oct 2020 13:02:15 +1100 Subject: Problem saving datetime to file and reading it back for a calculation In-Reply-To: <20201011015011.GA37900@cskk.homeip.net> References: <001001d69f53$232704f0$69750ed0$@SGA.Ninja> <20201011015011.GA37900@cskk.homeip.net> Message-ID: On Sun, Oct 11, 2020 at 12:57 PM Cameron Simpson wrote: > Personally I strongly dislike using datetimes for computation or as the > basis for time record keeping, essentially because of the timezone issue > but also because the human calendar is a complex disaster of illfitting > units (days in a year? variable; days in a month? variable; that table > of days per unit? variable depending on your time in history). > > Instead, I always try to work in POSIX timestamps, an absolute number of > seconds since midnight, 1 January 1970 GMT. You can always do arithmetic > directly between these in seconds, then convert for presentation > purposes whenever. > Absolutely agree, with the annoying exception of recurring events. If a human says "this happens every Monday at 2pm", then the human expects it to recur every Monday at 2pm, not every 604800 seconds. The difference shows up when the conversion between UTC and local time changes - most commonly when Daylight Saving Time starts or ends... (And I guess if you care about leap seconds, then Unix time would be inappropriate there too. But I rather doubt that most of us are bothered by that.) ChrisA From tjreedy at udel.edu Sat Oct 10 11:58:33 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 10 Oct 2020 11:58:33 -0400 Subject: Trying to Download PygameZero In-Reply-To: <4abc93ea-5a8d-7f48-aa15-bfdf96140611@python.org> References: <1820119831.51290.1602310975004.ref@mail.yahoo.com> <1820119831.51290.1602310975004@mail.yahoo.com> <4abc93ea-5a8d-7f48-aa15-bfdf96140611@python.org> Message-ID: On 10/10/2020 11:11 AM, Mats Wichmann wrote: > On 10/10/20 12:22 AM, Tom Hedge via Python-list wrote: >> I am in a 8 grade coding class at the moment and my teacher asked me to download a script ... [on Windows according to file paths]... . > > The problem is the pygame developers have not released a pygame for > Python 3.9 and you're using Python 3.9. https://www.lfd.uci.edu/~gohlke/pythonlibs/ has wheels for pygame. ('wheel' is the distribution format use by pypi.) Download to you system and install with pip from that. -- Terry Jan Reedy From info at tundraware.com Sat Oct 10 17:45:10 2020 From: info at tundraware.com (Tim Daneliuk) Date: Sat, 10 Oct 2020 16:45:10 -0500 Subject: Python's carbon guilt In-Reply-To: References: Message-ID: <6km95h-nn2.ln1@oceanview.tundraware.com> On 10/10/20 2:35 PM, Marco Sulla wrote: > He should also calculate the carbon dioxide emitted by brains that > works in C++ only. I omit other sources. > yes, methane is an alleged greenhouse gas as well From grant.b.edwards at gmail.com Sat Oct 10 21:40:42 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 11 Oct 2020 01:40:42 -0000 (UTC) Subject: Truncation error References: <20201010155834.GA6137@hjp.at> Message-ID: On 2020-10-10, Peter J. Holzer wrote: > On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: >> If you want to avoid float problems, you can use Decimal: > > Decimal doesn't avoid floating point problems, because it is a floating > point format. For example: > [...] > >>> from decimal import * > >>> a = Decimal(3) > >>> a > Decimal('3') > >>> b = Decimal(1E50) > >>> b > Decimal('100000000000000007629769841091887003294964970946560') > [...] There are two problems with your code: 1. You meant Decimal('1e50'). What you typed creates a Decimal value from the IEEE 64-bit floating point value closest to 1e50. 2. You need to increase the context precision. It defaults to 28, and you're example needs it to be at least 51: >>> getcontext().prec = 100 >>> a = Decimal(3) >>> b = Decimal('1e50') >>> c = Decimal(2) >>> a + b - c - b Decimal('1') >>> b - b + a - c Decimal('1') >>> a + (b - b) - c Decimal('1') >>> a + b - b - c Decimal('1') Like other floating point systems, you still need to know what you're doing if you want to get the "right" results. -- Grant From tjreedy at udel.edu Sat Oct 10 22:58:12 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 10 Oct 2020 22:58:12 -0400 Subject: Python's carbon guilt In-Reply-To: References: Message-ID: On 10/10/2020 11:58 AM, Peter Pearson wrote: > Python advocates might want to organize their thoughts on > this subject before their bosses spring the suggestion: > > From https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change : > > . . . Astronomers should also abandon popular programming languages > such as Python in favor of efficient compiled languages. Languages > such as Fortran and C++, Zwart calculates, are more than 100 times > more carbon efficient than Python because they require fewer > operations. Here is my reply to the "senior correspondent for astronomy..." who wrote the columm. --- Dear Mr. Clery: You report that Zwart of Leiden U says ... "Astronomers should also abandon popular programming languages such as Python in favor of efficient compiled languages. Languages such as Fortran and C++, Zwart calculates, are more than 100 times more carbon efficient than Python because they require fewer operations." Summary counter claim: the claim is phony. As actually used by astronomers for computationally intensive tasks, Python is nearly if not as 'carbon efficient' -- because nearly all the computation is done with machine code compiled from C, Fortran, C++, or whatever. (I am not an expert here, but am reporting to you a summary of what is generally known among experienced Python users. I am leaving out numerous details. Feel free to contact scientific Python experts for more.) Here is how anti-Python, pro-OtherLanguage people come up with such misleading numbers as '100x slower'. Confuse the issue by ascribing efficiency to languages rather than implementations. Then compare a relatively efficient 'production' implementation of some algorithm in OtherLanguage to an computer inefficient (but human efficient) 'development' implementation in Python that ignores how Python is being used in practice by scientific communities, such as the astronomy community. Step 1: Create a file with couple of numerically intensive functions such as matrix_init and matrix_invert written in directly compiled OtherLanguage. Add calls to matrix_init and matrix_invert. Time one or more runs. Step 2: Naively translate OtherLanguage directly into Python. Don't allow imports. Time one or more runs with the CPython interpreter. Compare the OtherLanguage time to this worst case Python time. Imply that users of Python are stupid enough to stop here for production usage. I consider this a bit slanderous. In practice, Python users inverting matrices, for instance, import the compiled numpy module, which among other things, wraps the standard Linpack package, which uses machine-specific, assemble-coded, Basic Linear Algebra Subroutines (BLAS) when available. In practice, I have read, the overhead of calling C libraries from Python instead of C is only a few percent. The original and still main Python implementation, CPython, is written in C. It interprets Python code, which is 'slow', but the Python code can include calls to fast, compiled, pre-written C functions. CPython was designed from the beginning to be extended with other other modules and functions written in C. (Fortran extensions were included either immediately or soon after, but I don't know which.) Some of these are included in the standard library, others from third-parties. Since the release of Python 1.0 in 1992, real-world Python users, have been extending CPython when appropriate for production usage. Indeed, numerical scientific computation was Python's first 'killer application'. Now, most every open-source C library with significant usage has been wrapped. There are at least hundreds. The current standard numerical package, numpy, is the third, and the needs of astronomers were among those that contributed to the design. -- Terry Jan Reedy From officialjoemayami at gmail.com Sat Oct 10 07:02:42 2020 From: officialjoemayami at gmail.com (Joe Mayami) Date: Sat, 10 Oct 2020 04:02:42 -0700 (PDT) Subject: For Creatives and Developers Only Message-ID: We are recruiting Developers, and Creatives to join our community into building personal portfolios, personal development skills, work on Open Source Projects, Devops, Collaboration, User Testing and Supports. Community members include experts in product designs, python programming, data science, creative writers, graphics and designs, artificial intelligence and a lot more. Link to join: https://chat.whatsapp.com/Geld8FNt4QCLGhYpA8DxkG From mkarkera98 at gmail.com Sun Oct 11 08:17:14 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Sun, 11 Oct 2020 17:47:14 +0530 Subject: Truncation error In-Reply-To: References: <20201010155834.GA6137@hjp.at> Message-ID: May I request you to let me know the steps python follows in order to compute covariance matrix using the inbuilt syntax. np.cov(cov_mat) . >>cov_mat = np.stack((x, y), axis = 0) >>np.cov(cov_mat) On Sun, Oct 11, 2020 at 9:14 AM Grant Edwards wrote: > On 2020-10-10, Peter J. Holzer wrote: > > On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: > >> If you want to avoid float problems, you can use Decimal: > > > > Decimal doesn't avoid floating point problems, because it is a floating > > point format. For example: > > [...] > > > >>> from decimal import * > > >>> a = Decimal(3) > > >>> a > > Decimal('3') > > >>> b = Decimal(1E50) > > >>> b > > Decimal('100000000000000007629769841091887003294964970946560') > > [...] > > There are two problems with your code: > > 1. You meant Decimal('1e50'). What you typed creates a Decimal value > from the IEEE 64-bit floating point value closest to 1e50. > > 2. You need to increase the context precision. It defaults to 28, > and you're example needs it to be at least 51: > > >>> getcontext().prec = 100 > >>> a = Decimal(3) > >>> b = Decimal('1e50') > >>> c = Decimal(2) > >>> a + b - c - b > Decimal('1') > >>> b - b + a - c > Decimal('1') > >>> a + (b - b) - c > Decimal('1') > >>> a + b - b - c > Decimal('1') > > Like other floating point systems, you still need to know what you're > doing if you want to get the "right" results. > > -- > Grant > > -- > https://mail.python.org/mailman/listinfo/python-list > From torriem at gmail.com Sun Oct 11 11:28:05 2020 From: torriem at gmail.com (Michael Torrie) Date: Sun, 11 Oct 2020 09:28:05 -0600 Subject: Python's carbon guilt In-Reply-To: References: Message-ID: <9072a8fb-f18d-e097-e9c1-d8187b489f19@gmail.com> On 10/10/20 9:58 AM, Peter Pearson wrote: > Python advocates might want to organize their thoughts on > this subject before their bosses spring the suggestion: > > From https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change : > > . . . Astronomers should also abandon popular programming languages > such as Python in favor of efficient compiled languages. Languages > such as Fortran and C++, Zwart calculates, are more than 100 times > more carbon efficient than Python because they require fewer > operations. Most of the math heavy lifting is done by compiled code that is merely called from Python. I seriously doubt there is anything to save by abandoning Python for something that is harder to use, slower, and probably burns way more electricity with all those compile cycles that they'd be forced to do. From Gronicus at SGA.Ninja Sun Oct 11 15:25:01 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sun, 11 Oct 2020 15:25:01 -0400 Subject: Problem saving datetime to file and reading it back for a calculation In-Reply-To: <24451.14119.563674.940831@ixdm.fritz.box> References: <001001d69f53$232704f0$69750ed0$@SGA.Ninja> <24451.14119.563674.940831@ixdm.fritz.box> Message-ID: <006e01d6a004$378fe9a0$a6afbce0$@SGA.Ninja> Thanks for the response. I must have spent hours looking on-line for a method to treat datetime variables yet not one site mentioned the "pickle" module you indicatged. I did, however solve my problem. It may be a kluge but it seems to work. I learned that I cannot use print() to display the value of datetime but once I saved it to a file, I could see it. If I used "d3 = d2.isoformat" it could be sent to a file with a write statement. Apparently, it gives a write/read format and places a T between the date and time as a separator. In trying to read it back into the program and work the calculation, I had to replace the T with a space and some formatting. It all worked. #=============================================== LBD = "LBD" d2 = datetime.now() d2i = d2.isoformat() with open("TimeDate.txt", 'r') as infile: for BottleInfo in infile: # loop to find each line in the file for that dose BottleInfo = BottleInfo.strip() if ((BottleInfo[0:3]== "LBD")): BottleData = BottleInfo[0:43].strip() BottleDataA = BottleData[4:14].strip() BottleDataB = BottleData[16:30].strip() BottleDataC = BottleDataA + " " + BottleDataB print("BottleDataC = <" + BottleDataC + ">") # I guess I could have searched for the "T" and replaced it. print() d1 = BottleDataC import datetime dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') dti = dto.isoformat() HoursDiff = int((d2-dto).total_seconds()/3600) print("HoursDiff = " + str(HoursDiff)) print() TimeDateInfo=open("TimeDate.txt", "a") TimeDateInfo.write("{0:>5} {1:>25} {2:>5}\n".format (LBD, d2i, HoursDiff)) TimeDateInfo.close() # =========================================== Granted, there may be other ways to do this but I actually enjoy the exploration... Still, I would like to see other methods. Steve -----Original Message----- From: Dieter Maurer Sent: Sunday, October 11, 2020 12:48 PM To: Steve Subject: Re: Problem saving datetime to file and reading it back for a calculation Steve wrote at 2020-10-10 18:17 -0400: >I would like to use the line: >HoursDiff = int((d2-d1).total_seconds()/3600) to determine the >difference in hours between two timedate entries. > >The variable d2 is from datetime.now() >and d1 is read from a text file. > >I can save d2 to the file only if I convert it to string and, at a later >date, it gets read back in as d1 as string. The variable d1 as string will >not work in the HoursDiff statement. Python's "pickle" module provides support for storing (most) objects to files and read them back. From python at mrabarnett.plus.com Sun Oct 11 17:08:26 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 11 Oct 2020 22:08:26 +0100 Subject: Problem saving datetime to file and reading it back for a calculation In-Reply-To: <006e01d6a004$378fe9a0$a6afbce0$@SGA.Ninja> References: <001001d69f53$232704f0$69750ed0$@SGA.Ninja> <24451.14119.563674.940831@ixdm.fritz.box> <006e01d6a004$378fe9a0$a6afbce0$@SGA.Ninja> Message-ID: <51771cf0-3fe0-8c30-7235-f793315c2b1f@mrabarnett.plus.com> On 2020-10-11 20:25, Steve wrote: > Thanks for the response. > > I must have spent hours looking on-line for a method to treat datetime > variables yet not one site mentioned the "pickle" module you indicatged. I > did, however solve my problem. It may be a kluge but it seems to work. > > I learned that I cannot use print() to display the value of datetime but > once I saved it to a file, I could see it. If I used "d3 = d2.isoformat" it > could be sent to a file with a write statement. Apparently, it gives a > write/read format and places a T between the date and time as a separator. > > In trying to read it back into the program and work the calculation, I had > to replace the T with a space and some formatting. It all worked. [snip] Given: import datetime To convert a datetime d to an ISO-format string, you can use: s = d.isoformat() To convert an ISO-format string s to a datetime, you can use: d = datetime.datetime.fromisoformat() From Gronicus at SGA.Ninja Sun Oct 11 20:39:45 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sun, 11 Oct 2020 20:39:45 -0400 Subject: Problem saving datetime to file and reading it back for a calculation In-Reply-To: <51771cf0-3fe0-8c30-7235-f793315c2b1f@mrabarnett.plus.com> References: <001001d69f53$232704f0$69750ed0$@SGA.Ninja> <24451.14119.563674.940831@ixdm.fritz.box> <006e01d6a004$378fe9a0$a6afbce0$@SGA.Ninja> <51771cf0-3fe0-8c30-7235-f793315c2b1f@mrabarnett.plus.com> Message-ID: <008901d6a030$2f284150$8d78c3f0$@SGA.Ninja> Thanks for the responses. Somehow, all of my python messages were shifted into the deleted folder so I missed all of them until I caught the one from MRAB. I will sift through them and probably update my technique to use seconds as suggested. Still, I enjoyed the kluge I created making it work based on discovery... Footnote: If 666 is evil then 25.8 is the square root of all evil. From akshat0508 at gmail.com Sun Oct 11 04:13:40 2020 From: akshat0508 at gmail.com (hey) Date: Sun, 11 Oct 2020 13:43:40 +0530 Subject: FW: NEED SOLUTION FOR ERROR In-Reply-To: <5f81c0e8.1c69fb81.a74f6.28ce@mx.google.com> References: <5f81c0e8.1c69fb81.a74f6.28ce@mx.google.com> Message-ID: <5f82beb4.1c69fb81.5021c.38ce@mx.google.com> Sent from Mail for Windows 10 From: hey Sent: Saturday, October 10, 2020 7:40 PM To: python-list at python.org Subject: NEED SOLUTION FOR ERROR I am Akshat Sharma one of python user from INDIA . I am facing problem in getting pip installed. When I am trying to install a module using PIP it showing me error : No such file found in directory . Then I tried to install pip doing so , I am getting another error : OSError [errno 9] Bad File Descriptor. Please guide me what should I do to overcome this type of error. THANK YOU Regards Sent from Mail for Windows 10 From tjreedy at udel.edu Sun Oct 11 17:21:14 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 11 Oct 2020 17:21:14 -0400 Subject: numpy covariance (was Re: Truncation error) In-Reply-To: References: <20201010155834.GA6137@hjp.at> Message-ID: On 10/11/2020 8:17 AM, Meghna Karkera wrote: > May I request you to let me know the steps python follows in order to > compute covariance matrix using the inbuilt > syntax. > np.cov(cov_mat) 1. When starting a new topic, start a new thread with a new topic. 2. Questions about the internals of a 3rd party module are better asked on the discussion forum for that module. Such exist for numpy. 3. Your question is too vague to reliably answer. I am not sure what you mean by 'inbuilt syntax'. I presume that numpy cov calls 1 or more functions from the included LinPack code. If this is not enough of an answer, read the numpy doc and code and if you still have questions, ask a more detailed question on a numpy forum. -- Terry Jan Reedy From python at mrabarnett.plus.com Sun Oct 11 22:09:01 2020 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 12 Oct 2020 03:09:01 +0100 Subject: FW: NEED SOLUTION FOR ERROR In-Reply-To: <5f82beb4.1c69fb81.5021c.38ce@mx.google.com> References: <5f81c0e8.1c69fb81.a74f6.28ce@mx.google.com> <5f82beb4.1c69fb81.5021c.38ce@mx.google.com> Message-ID: <0bdb38e7-bba5-f8ff-fde1-bd804a44a9ae@mrabarnett.plus.com> On 2020-10-11 09:13, hey wrote: > > > Sent from Mail for Windows 10 > > From: hey > Sent: Saturday, October 10, 2020 7:40 PM > To: python-list at python.org > Subject: NEED SOLUTION FOR ERROR > > I am Akshat Sharma one of python user from INDIA . I am facing problem in getting pip installed. > When I am trying to install a module using PIP it showing me error : No such file found in directory . > Then I tried to install pip doing so , I am getting another error : OSError [errno 9] Bad File Descriptor. > Please guide me what should I do to overcome this type of error. > THANK YOU > Regards > You could try using the pip module via the Python launcher. Instead of: pip install something try: py -m pip install something From mkarkera98 at gmail.com Sun Oct 11 22:45:14 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Mon, 12 Oct 2020 08:15:14 +0530 Subject: Fwd: Truncation error In-Reply-To: References: <20201010155834.GA6137@hjp.at> Message-ID: May I request you to let me know the steps python follows in order to compute covariance matrix using the inbuilt syntax. np.cov(cov_mat) . >>cov_mat = np.stack((x, y), axis = 0) >>np.cov(cov_mat) On Sun, Oct 11, 2020 at 9:14 AM Grant Edwards wrote: > On 2020-10-10, Peter J. Holzer wrote: > > On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: > >> If you want to avoid float problems, you can use Decimal: > > > > Decimal doesn't avoid floating point problems, because it is a floating > > point format. For example: > > [...] > > > >>> from decimal import * > > >>> a = Decimal(3) > > >>> a > > Decimal('3') > > >>> b = Decimal(1E50) > > >>> b > > Decimal('100000000000000007629769841091887003294964970946560') > > [...] > > There are two problems with your code: > > 1. You meant Decimal('1e50'). What you typed creates a Decimal value > from the IEEE 64-bit floating point value closest to 1e50. > > 2. You need to increase the context precision. It defaults to 28, > and you're example needs it to be at least 51: > > >>> getcontext().prec = 100 > >>> a = Decimal(3) > >>> b = Decimal('1e50') > >>> c = Decimal(2) > >>> a + b - c - b > Decimal('1') > >>> b - b + a - c > Decimal('1') > >>> a + (b - b) - c > Decimal('1') > >>> a + b - b - c > Decimal('1') > > Like other floating point systems, you still need to know what you're > doing if you want to get the "right" results. > > -- > Grant > > -- > https://mail.python.org/mailman/listinfo/python-list > From cs at cskk.id.au Mon Oct 12 00:01:25 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 12 Oct 2020 15:01:25 +1100 Subject: Problem saving datetime to file and reading it back for a calculation In-Reply-To: <008901d6a030$2f284150$8d78c3f0$@SGA.Ninja> References: <008901d6a030$2f284150$8d78c3f0$@SGA.Ninja> Message-ID: <20201012040125.GA2273@cskk.homeip.net> On 11Oct2020 20:39, Steve wrote: >Still, I enjoyed the kluge I created making it work based on discovery... Poking around in the datetime module will definitely make you aware of its power, and its pitfalls. Well worth doing. At the very least you'll usually want it when printing times out for humans. But seconds is generally simpler and reliable, particularly as it tosses timezones straight out the window - it is all just arithmetic. Cheers, Cameron Simpson From Gronicus at SGA.Ninja Mon Oct 12 06:12:48 2020 From: Gronicus at SGA.Ninja (Steve) Date: Mon, 12 Oct 2020 06:12:48 -0400 Subject: What might cause my sample program to forget that already imported datetime? Message-ID: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> At the top of my sample program, I have: import datetime from datetime import * But import datetime also has to be entered on line 21 as shown. The error is printed at the bottom of the code. Why does the code seem to forget that I have already imported datetime? ============================================================= import datetime from datetime import * d2 = datetime.now() d2i = d2.isoformat() with open("TimeDate.txt", 'r') as infile: for BottleInfo in infile: # loop to find each line in the file for that dose BottleInfo = BottleInfo.strip() if ((BottleInfo[0:3]== "LBD")): BottleData = BottleInfo[0:43].strip() BottleDataA = BottleData[4:14].strip() BottleDataB = BottleData[16:30].strip() BottleDataC = BottleDataA + " " + BottleDataB print("BottleDataC = <" + BottleDataC + ">") print() d1 = BottleDataC import datetime #Why does this have to be here? line 21 dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') dti = dto.isoformat() HoursDiff = int((d2-dto).total_seconds()/3600) print("HoursDiff = " + str(HoursDiff)) print() TimeDateInfo=open("TimeDate.txt", "a") TimeDateInfo.write("{0:>5} {1:>25} {2:>5}\n".format ("LBD", d2i, HoursDiff)) TimeDateInfo.close() print("Done") """ This is the error I get if I comment out line 21: Traceback (most recent call last): File "F:/Med Insulin codes A/A TEST 10-07-2020/ReadWriteTimeDate POSIX Samplea.py", line 38, in dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') AttributeError: type object 'datetime.datetime' has no attribute 'datetime' """ This code will be copied into another program as a function and the presence of import datetime in line 21 causes another error. ================================================================== Footnote: The human brain is one of the most complex things known to man. according to the human brain. From joel.goldstick at gmail.com Mon Oct 12 06:34:43 2020 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Mon, 12 Oct 2020 06:34:43 -0400 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> Message-ID: On Mon, Oct 12, 2020 at 6:14 AM Steve wrote: > > At the top of my sample program, I have: > > import datetime > from datetime import * This second import tramples on the first. What happens if you remove it? > > But import datetime also has to be entered on line 21 as shown. > The error is printed at the bottom of the code. > Why does the code seem to forget that I have already imported datetime? > ============================================================= > import datetime > from datetime import * > > d2 = datetime.now() > d2i = d2.isoformat() > > with open("TimeDate.txt", 'r') as infile: > for BottleInfo in infile: # loop to find each line in the file for that > dose > BottleInfo = BottleInfo.strip() > > if ((BottleInfo[0:3]== "LBD")): > BottleData = BottleInfo[0:43].strip() > > BottleDataA = BottleData[4:14].strip() > BottleDataB = BottleData[16:30].strip() > BottleDataC = BottleDataA + " " + BottleDataB > print("BottleDataC = <" + BottleDataC + ">") > print() > d1 = BottleDataC > > import datetime #Why does this have to be here? line 21 > > dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') With the second import the above line will work if you do this: dto = datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') > dti = dto.isoformat() > > HoursDiff = int((d2-dto).total_seconds()/3600) > print("HoursDiff = " + str(HoursDiff)) > print() > > TimeDateInfo=open("TimeDate.txt", "a") > TimeDateInfo.write("{0:>5} {1:>25} {2:>5}\n".format ("LBD", d2i, HoursDiff)) > TimeDateInfo.close() > > print("Done") > > """ > This is the error I get if I comment out line 21: > > Traceback (most recent call last): > File "F:/Med Insulin codes A/A TEST 10-07-2020/ReadWriteTimeDate POSIX > Samplea.py", line 38, in > dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') > AttributeError: type object 'datetime.datetime' has no attribute 'datetime' > """ > This code will be copied into another program as a function and the presence > of import datetime in line 21 causes another error. > > ================================================================== > Footnote: > The human brain is one of the most complex things known to man. > according to the human brain. > > > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From rosuav at gmail.com Mon Oct 12 06:36:57 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 12 Oct 2020 21:36:57 +1100 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> Message-ID: On Mon, Oct 12, 2020 at 9:14 PM Steve wrote: > > At the top of my sample program, I have: > > import datetime > from datetime import * > > But import datetime also has to be entered on line 21 as shown. > The error is printed at the bottom of the code. > Why does the code seem to forget that I have already imported datetime? > ============================================================= > import datetime > from datetime import * > > d2 = datetime.now() > d2i = d2.isoformat() > > with open("TimeDate.txt", 'r') as infile: > for BottleInfo in infile: # loop to find each line in the file for that > dose > BottleInfo = BottleInfo.strip() > > if ((BottleInfo[0:3]== "LBD")): > BottleData = BottleInfo[0:43].strip() > > BottleDataA = BottleData[4:14].strip() > BottleDataB = BottleData[16:30].strip() > BottleDataC = BottleDataA + " " + BottleDataB > print("BottleDataC = <" + BottleDataC + ">") > print() > d1 = BottleDataC > > import datetime #Why does this have to be here? line 21 > > dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') > dti = dto.isoformat() > > HoursDiff = int((d2-dto).total_seconds()/3600) > print("HoursDiff = " + str(HoursDiff)) > print() > > TimeDateInfo=open("TimeDate.txt", "a") > TimeDateInfo.write("{0:>5} {1:>25} {2:>5}\n".format ("LBD", d2i, HoursDiff)) > TimeDateInfo.close() > > print("Done") > > """ > This is the error I get if I comment out line 21: > > Traceback (most recent call last): > File "F:/Med Insulin codes A/A TEST 10-07-2020/ReadWriteTimeDate POSIX > Samplea.py", line 38, in > dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') > AttributeError: type object 'datetime.datetime' has no attribute 'datetime' > """ > This code will be copied into another program as a function and the presence > of import datetime in line 21 causes another error. > The issue here is that you've done two different imports at the top: import datetime from datetime import * These are incompatible with each other, so you're going to get issues. I'd recommend doing just the first one, and then identifying d2 as datetime.datetime.now() instead. ChrisA From arj.python at gmail.com Mon Oct 12 06:57:47 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 12 Oct 2020 14:57:47 +0400 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> Message-ID: Btw why a datetime in datetime? It causes much confusion. I dont know the design decision behind, if someone knows, it might be good to explain I dont expect it to change anytime soon due to backward compatibility, but just for knowledge. Kind Regards, Abdur-Rahmaan Janhangeer https://www.github.com/Abdur-RahmaanJ Mauritius sent from gmail client on Android, that's why the signature is so ugly. From rosuav at gmail.com Mon Oct 12 07:20:27 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 12 Oct 2020 22:20:27 +1100 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> Message-ID: On Mon, Oct 12, 2020 at 9:58 PM Abdur-Rahmaan Janhangeer wrote: > > Btw why a datetime in datetime? > > It causes much confusion. I dont know > the design decision behind, if someone knows, it might be good to explain > There are quite a few modules that have one "most obvious" entrypoint, and there's really no better name for either that thing or the module it lives in. The pprint module has a pprint function, giving the same phenomenon. This is yet another reason that "from MODULE import *" is a bad idea. Instead, just import the module itself, and take whatever you need. ChrisA From bernard+work at ei8fdb.org Mon Oct 12 07:28:17 2020 From: bernard+work at ei8fdb.org (Bernard Tyers - Sane UX Design) Date: Mon, 12 Oct 2020 13:28:17 +0200 Subject: Your experience of backtacking during a pip install Message-ID: <80a8fd06-fbfe-ee64-730b-e203095862c5@ei8fdb.org> Hello there, The pip team is implementing some improvements to pip's output to deal with situations where, during a `pip install`, it needs to backtrack on package(s). To do this we need to make some decisions. We'd appreciate your input using this very short (1 question!) poll: https://saneuxdesign.survey.fm/your-experience-of-pip-backtracking To follow the implementation discussion, see it here: https://github.com/pypa/pip/issues/8975 best wishes, Bernard -- Bernard Tyers UX Designer, pip Team User Researcher & Interaction Designer | Sane UX Design PGP Key: https://keybase.io/ei8fdb -- Bernard Tyers, User Researcher & Interaction Designer Sane UX Design | PGP Key: https://keybase.io/ei8fdb I am currently working with the Python Software Foundation and Reset.tech I work on User Centred Design, Open Source Software, and user privacy. From naveenroyv at gmail.com Mon Oct 12 07:57:26 2020 From: naveenroyv at gmail.com (Naveen Roy Vikkram) Date: Mon, 12 Oct 2020 04:57:26 -0700 (PDT) Subject: MERGE SQL in cx_Oracle executemany Message-ID: <82291952-57d4-4ef2-96f2-5b8a2fadb903n@googlegroups.com> Hi there, I'm looking to insert values into an oracle table (my_table) using the query below. The insert query works when the PROJECT is not NULL/empty (""). However when PROJECT is an empty string(''), the query creates a new duplicate row every time the code is executed (with project value populating as null). I would like to modify my query so a new row is not inserted when all column values are matched (including when project code is null). I'm guessing I would need to include a "when matched" statement, but not too sure on how to get this going. Would appreciate help with this, thanks. ``` con = cx_Oracle.connect(connstr) cur = con.cursor() rows = [tuple(x) for x in df.values] cur3.executemany('''merge into my_table using dual on (YEAR = :1 and QUARTER = :2 and CODE = :3 and AMOUNT = :4 and DATE = :5 and COMMENTS = :6 and PROJECT = :7) when not matched then insert values (:1, :2, :3, :4, :5, :6, :7) ''',rows) con.commit() cur.close() con.close() ``` From loris.bennett at fu-berlin.de Mon Oct 12 08:04:37 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Mon, 12 Oct 2020 14:04:37 +0200 Subject: Embedding version in command-line program In-Reply-To: (Heinrich Kruger's message of "Fri, 9 Oct 2020 16:23:55 +0000") References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> <87blhexmcj.fsf@hornfels.zedat.fu-berlin.de> <877ds0kh3e.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <87v9ffveei.fsf@hornfels.zedat.fu-berlin.de> Hi Heinrich, Heinrich Kruger writes: > ??????? Original Message ??????? > On Thursday, October 8, 2020 2:00 PM, Loris Bennett wrote: > >> Marco Sulla Marco.Sulla.Python at gmail.com writes: >> >> > On Wed, 7 Oct 2020 at 14:16, Loris Bennett loris.bennett at fu-berlin.de >> > wrote: >> > >> > > But the toml file isn't part of the distribution and so it won't be >> > > installed. >> > > I suppose I could write a separate program which parses the toml file >> > > and then just injects the version into init.py. >> > >> > Yes, I do not know poetry, but I suppose you can generate it in its >> > setup. I usually create a separate VERSION file and I read it in >> > init.py. Other people creates a version.py that is evaled inside >> > init.py >> >> I ended up using the module >> >> poetry_version >> >> which allows one to extract the version like this: >> >> import poetry_version >> >> version = poetry_version.extract(source_file=file) >> > > It looks to me like that package also just reads the pyproject.toml file. > > You could try using the "importlib.metadata" module > (https://docs.python.org/3.8/library/importlib.metadata.html). If you're still > using python 3.7 (or older) you can install importlib-metadata from PyPI > (https://pypi.org/project/importlib-metadata/). > > Try putting something like > > ``` > from importlib import metadata > > __version__ = metadata.version(__name__) > ``` > in your __init__.py file. > > Then you can do something like: > ``` > from . import __version__ > > def main(): > print(f"Version: {__version__}") > ``` > > Bear in mind that this would only work if your package is installed (e.g. in > virtual environment). Otherwise the `metadata.version(__name__)` call will fail > with a `importlib.metadata.PackageNotFoundError` exception (of course you could > catch that and fall back to trying to read the pyproject.toml file). You're right of course, that 'poetry_version' just looks at the toml file. I'm using Python 3.6, so I had to do import importlib_metadata as metadata which works, although as you mention in you caveat, it is a bit of a pain that this gives me the version of the installed version. As someone who has only dabbled in Python up to know, I'm slightly surprised that there is no obvious and accepted way of keeping the version in the metadata of a module and the version which a command-line wrapper around the module in sync. Is my expectation that this should be straightforward misguided? At the least I would have expected that, since poetry regards the toml file as the primary source of project data, although it isn't part of the installed package, that the 'poetry version' command would offer the option of bumping the version directly in the code. Cheers, Loris -- This signature is currently under construction. From Richard at Damon-Family.org Mon Oct 12 09:11:24 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Mon, 12 Oct 2020 09:11:24 -0400 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> Message-ID: On 10/12/20 7:20 AM, Chris Angelico wrote: > On Mon, Oct 12, 2020 at 9:58 PM Abdur-Rahmaan Janhangeer > wrote: >> Btw why a datetime in datetime? >> >> It causes much confusion. I dont know >> the design decision behind, if someone knows, it might be good to explain >> > There are quite a few modules that have one "most obvious" entrypoint, > and there's really no better name for either that thing or the module > it lives in. The pprint module has a pprint function, giving the same > phenomenon. > > This is yet another reason that "from MODULE import *" is a bad idea. > Instead, just import the module itself, and take whatever you need. > > ChrisA And if you don't like doing datetime.datatime all the time, you can also do from MODULE import SYMBOL and do from MODULE import SYMBOL as ALIAS when you get conflicts. The big issue is that you lose control with * as it pulls 'arbitrary' things into your name space. I do sometimes do things like the combination import MODULE from MODULE import SYMBOL if there is some name in the module I want to use a lot. I don't see much need for: import MODULE from MODULE import * as if you are bringing in ALL the names into the current module name space, when will you need to use the module.symbol notation? -- Richard Damon From hjp-python at hjp.at Mon Oct 12 13:28:39 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 12 Oct 2020 19:28:39 +0200 Subject: Truncation error In-Reply-To: References: <20201010155834.GA6137@hjp.at> Message-ID: <20201012172839.GA23540@hjp.at> On 2020-10-10 13:31:34 -0400, Dennis Lee Bieber wrote: > On Sat, 10 Oct 2020 17:58:34 +0200, "Peter J. Holzer" > declaimed the following: > > >On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: > >> If you want to avoid float problems, you can use Decimal: > > > >Decimal doesn't avoid floating point problems, because it is a floating > >point format. For example: > > > > > >>> b = Decimal(1E50) > > >>> b > > Decimal('100000000000000007629769841091887003294964970946560') > > That one's a red herring... The "problem" occurs with the 1E50 /float/ > before conversion to decimal No. At least not the problem I wanted to demonstrate which is that like any floating-point format, Decimal has limited precision and hence A + B - A is in general not equal to B. I could have written b = Decimal('100000000000000007629769841091887003294964970946560') instead, but b = Decimal(1E50) was less to type. Also, with Decimal('1E150') the result is less spectacular, but also wrong. Decimal is especially devious here, because while it will happily store a value with 51 digits, it will round results of operations to the configured precision. So by mixing operands with different precision you get results which are very hard to predict. At least with float you know the precision[1], so you can reason about the results. hp [1] This is actually not always true. Some architectures (like x87) use a higher precision for intermediate results, which is generally good but makes it really hard to estimate errors unless you know exactly what code the compiler generates. -- _ | 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 hjp-python at hjp.at Mon Oct 12 13:46:06 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 12 Oct 2020 19:46:06 +0200 Subject: Truncation error In-Reply-To: References: <20201010155834.GA6137@hjp.at> Message-ID: <20201012174606.GB23540@hjp.at> On 2020-10-11 01:40:42 -0000, Grant Edwards wrote: > On 2020-10-10, Peter J. Holzer wrote: > > On 2020-10-07 07:53:55 +0200, Marco Sulla wrote: > >> If you want to avoid float problems, you can use Decimal: > > > > Decimal doesn't avoid floating point problems, because it is a floating > > point format. For example: > > [...] > > > >>> from decimal import * > > >>> a = Decimal(3) > > >>> a > > Decimal('3') > > >>> b = Decimal(1E50) > > >>> b > > Decimal('100000000000000007629769841091887003294964970946560') > > [...] > > There are two problems with your code: > > 1. You meant Decimal('1e50'). No. I meant Decimal(1E50) > What you typed creates a Decimal value > from the IEEE 64-bit floating point value closest to 1e50. Which is what I wanted. I gave me some "random" digits at the end without having to type them. But I realize that I should have used Decimal('1e50') to remove that red herring - the problem can be demonstrated with Decimal('1e50') just as well, it's just less spectacular. (OTOH using Decimal(1E50) has the advantage of demonstrating the dangers of mixing operands of different precision, but again, that may just be confusing). > 2. You need to increase the context precision. It defaults to 28, > and you're example needs it to be at least 51: That helps for that specific example, but not in general. > > >>> getcontext().prec = 100 So then maybe there is an operand with 150 digits. Or you want to add 1E70 to 1E-70. The fact is that any non-trivial computation will always exceed the precision (even a simple division like Decimal('1') / Decimal('3') needs an infinite number of digits, but you can't set precision to infinite) and require rounding. You can make the error very small, but it will still be there. You have to be aware of that. Using Decimal will not give you mathematically correct results - it will just give you different (und usually, but not always, as I've demonstrated) errors. 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 Gronicus at SGA.Ninja Mon Oct 12 13:47:39 2020 From: Gronicus at SGA.Ninja (Steve) Date: Mon, 12 Oct 2020 13:47:39 -0400 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> Message-ID: <000001d6a0bf$c8800880$59801980$@SGA.Ninja> Thank you, those two fixes took care of the problem. Footnote: The only time incorrectly is spelled incorrectly is when it is spelled "incorrectly". -----Original Message----- From: Python-list On Behalf Of Chris Angelico Sent: Monday, October 12, 2020 6:37 AM To: Python Subject: Re: What might cause my sample program to forget that already imported datetime? On Mon, Oct 12, 2020 at 9:14 PM Steve wrote: > > At the top of my sample program, I have: > > import datetime > from datetime import * > > But import datetime also has to be entered on line 21 as shown. > The error is printed at the bottom of the code. > Why does the code seem to forget that I have already imported datetime? > ============================================================= > import datetime > from datetime import * > > d2 = datetime.now() > d2i = d2.isoformat() > > with open("TimeDate.txt", 'r') as infile: > for BottleInfo in infile: # loop to find each line in the file > for that dose > BottleInfo = BottleInfo.strip() > > if ((BottleInfo[0:3]== "LBD")): > BottleData = BottleInfo[0:43].strip() > > BottleDataA = BottleData[4:14].strip() BottleDataB = > BottleData[16:30].strip() BottleDataC = BottleDataA + " " + > BottleDataB print("BottleDataC = <" + BottleDataC + ">") > print() > d1 = BottleDataC > > import datetime #Why does this have to be here? line 21 > > dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') dti = > dto.isoformat() > > HoursDiff = int((d2-dto).total_seconds()/3600) > print("HoursDiff = " + str(HoursDiff)) > print() > > TimeDateInfo=open("TimeDate.txt", "a") TimeDateInfo.write("{0:>5} > {1:>25} {2:>5}\n".format ("LBD", d2i, HoursDiff)) > TimeDateInfo.close() > > print("Done") > > """ > This is the error I get if I comment out line 21: > > Traceback (most recent call last): > File "F:/Med Insulin codes A/A TEST 10-07-2020/ReadWriteTimeDate > POSIX Samplea.py", line 38, in > dto = datetime.datetime.strptime(d1, '%Y-%m-%d %H:%M:%S.%f') > AttributeError: type object 'datetime.datetime' has no attribute 'datetime' > """ > This code will be copied into another program as a function and the > presence of import datetime in line 21 causes another error. > The issue here is that you've done two different imports at the top: import datetime from datetime import * These are incompatible with each other, so you're going to get issues. I'd recommend doing just the first one, and then identifying d2 as datetime.datetime.now() instead. ChrisA -- https://mail.python.org/mailman/listinfo/python-list From PythonList at DancesWithMice.info Mon Oct 12 20:53:09 2020 From: PythonList at DancesWithMice.info (dn) Date: Tue, 13 Oct 2020 13:53:09 +1300 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: <000001d6a0bf$c8800880$59801980$@SGA.Ninja> References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> <000001d6a0bf$c8800880$59801980$@SGA.Ninja> Message-ID: <07ddeab6-0952-970a-58e7-e5646568467e@DancesWithMice.info> On 13/10/2020 06:47, Steve wrote: > Thank you, those two fixes took care of the problem. >> At the top of my sample program, I have: >> >> import datetime >> from datetime import * ... > These are incompatible with each other, so you're going to get issues. > I'd recommend doing just the first one, and then identifying d2 as > datetime.datetime.now() instead. These questions befuddle the mind when first presented, yet the answer seems so logical once it becomes hindsight... Evidence:- (blank lines added for readability) dn $ ... python3 Python 3.8.5 (default, Aug 12 2020, 00:00:00) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from pprint import pprint as pp >>> pp( locals() ) {'__annotations__': {}, '__builtins__': , '__doc__': None, '__loader__': , '__name__': '__main__', '__package__': None, '__spec__': None, 'pp': } >>> import datetime >>> pp( locals() ) {'__annotations__': {}, '__builtins__': , '__doc__': None, '__loader__': , '__name__': '__main__', '__package__': None, '__spec__': None, 'datetime': , 'pp': } >>> from datetime import * >>> pp( locals() ) {'MAXYEAR': 9999, 'MINYEAR': 1, '__annotations__': {}, '__builtins__': , '__doc__': None, '__loader__': , '__name__': '__main__', '__package__': None, '__spec__': None, 'date': , 'datetime': , 'datetime_CAPI': , 'pp': , 'sys': , 'time': , 'timedelta': , 'timezone': , 'tzinfo': } Apologies for the awkward email word-wrap. Note the (absence and then) changing entry for 'datetime'. -- Regards =dn From mkarkera98 at gmail.com Tue Oct 13 00:36:42 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Tue, 13 Oct 2020 10:06:42 +0530 Subject: Covariance matrix syntax Message-ID: May I know the steps or procedure behind covariance matrix syntax, np.cov(covar_matrix) in python From mkarkera98 at gmail.com Tue Oct 13 00:52:56 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Tue, 13 Oct 2020 10:22:56 +0530 Subject: Covariance matrix syntax In-Reply-To: <291564577.630412.1602564274535@mail.yahoo.com> References: <291564577.630412.1602564274535@mail.yahoo.com> Message-ID: Could you let me know what is the back end calculation of this covariance matrix syntax np.cov On Tue, Oct 13, 2020, 10:14 Bruno P. Kinoshita wrote: > I think the np.cov is from the numpy module (imported/aliased as np?). > > If so, the numpy repository should have what you are looking for: > > > > https://github.com/numpy/numpy/blob/156cd054e007b05d4ac4829e10a369d19dd2b0b1/numpy/lib/function_base.py#L2276 > > > Hope that helps > > Bruno > > On Tuesday, 13 October 2020, 5:38:55 pm NZDT, Meghna Karkera < > mkarkera98 at gmail.com> wrote: > > > May I know the steps or procedure behind covariance matrix syntax, > np.cov(covar_matrix) in python > -- > https://mail.python.org/mailman/listinfo/python-list > From auriocus at gmx.de Tue Oct 13 02:14:11 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Tue, 13 Oct 2020 08:14:11 +0200 Subject: Covariance matrix syntax In-Reply-To: References: <291564577.630412.1602564274535@mail.yahoo.com> Message-ID: Am 13.10.20 um 06:52 schrieb Meghna Karkera: > Could you let me know what is the back end calculation of this covariance > matrix syntax np.cov > You can look it up yourself: Go to the docs https://numpy.org/doc/stable/reference/generated/numpy.cov.html At the right hand side, just right of the function signature, there is a link [source]. Click there and it takes you to the implementation. Apparently it is done in straightforward Python. Christian PS: Snipped a lot of unrelated citation at the bottom > On Tue, Oct 13, 2020, 10:14 Bruno P. Kinoshita > wrote: > [...] >> I think the np.cov is from the numpy module (imported/aliased as np?). From aeros167 at gmail.com Tue Oct 13 04:16:23 2020 From: aeros167 at gmail.com (Kyle Stanley) Date: Tue, 13 Oct 2020 04:16:23 -0400 Subject: FW: NEED SOLUTION FOR ERROR In-Reply-To: <0bdb38e7-bba5-f8ff-fde1-bd804a44a9ae@mrabarnett.plus.com> References: <5f81c0e8.1c69fb81.a74f6.28ce@mx.google.com> <5f82beb4.1c69fb81.5021c.38ce@mx.google.com> <0bdb38e7-bba5-f8ff-fde1-bd804a44a9ae@mrabarnett.plus.com> Message-ID: It would also be helpful to list the full traceback as well as the exact command used (e.g. package attempted to install and passed arguments to pip). A bad file descriptor error sounds like there's a fair chance of it being an issue within a specific module, or something like your OS running out of FDs (rare, but definitely possible if the max limit is low). On Sun, Oct 11, 2020 at 10:12 PM MRAB wrote: > On 2020-10-11 09:13, hey wrote: > > > > > > Sent from Mail for Windows 10 > > > > From: hey > > Sent: Saturday, October 10, 2020 7:40 PM > > To: python-list at python.org > > Subject: NEED SOLUTION FOR ERROR > > > > I am Akshat Sharma one of python user from INDIA . I am facing problem > in getting pip installed. > > When I am trying to install a module using PIP it showing me error : No > such file found in directory . > > Then I tried to install pip doing so , I am getting another error : > OSError [errno 9] Bad File Descriptor. > > Please guide me what should I do to overcome this type of error. > > THANK YOU > > Regards > > > You could try using the pip module via the Python launcher. > > Instead of: > > pip install something > > try: > > py -m pip install something > -- > https://mail.python.org/mailman/listinfo/python-list > From Gronicus at SGA.Ninja Tue Oct 13 04:51:54 2020 From: Gronicus at SGA.Ninja (Steve) Date: Tue, 13 Oct 2020 04:51:54 -0400 Subject: Weird behavior for IDLE... Message-ID: <003501d6a13e$19f79ab0$4de6d010$@SGA.Ninja> Why does IDLE always open with the lowest three lines of the window end up hidden below the bottom of the screen behind the task bar? Every time I use it, I have to stop and grab the top of the window and drag it up to see the line and row information. I explored the Options/Configure IDLE but did not see anything that would help. It is most annoying, is there a fix for it? I explored Steve ========================================================== Footnote: Mars is the only known planet in our solar system solely inhabited by functioning robots. From tony.flury at btinternet.com Tue Oct 13 04:52:39 2020 From: tony.flury at btinternet.com (Tony Flury) Date: Tue, 13 Oct 2020 09:52:39 +0100 Subject: Simple question - end a raw string with a single backslash ? Message-ID: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> I am trying to write a simple expression to build a raw string that ends in a single backslash. My understanding is that a raw string should ignore attempts at escaping characters but I get this : >>> a = r'end\' ? File "", line 1 ??? a = r'end\' ????????????? ^ SyntaxError: EOL while scanning string literal I interpret this as meaning that the \' is actually being interpreted as a literal quote - is that a bug ? If I try to escaped the backslash I get a different problem: >>> a = r'end\\' >>> a 'end\\\\' >>> print(a) end\\ >>> len(a) 5 >>> list(a) ['e', 'n', 'd', '\\', '\\'] So you can see that our string (with the escaped backslash)? is now 5 characters with two literal backslash characters The only solution I have found is to do this : >>> a = r'end' + chr(92) >>> a 'end\\' >>> list(a) ['e', 'n', 'd', '\\'] or >>> a = r'end\\'[:-1] >>> list(a) ['e', 'n', 'd', '\\'] Neither of which are nice. From eryksun at gmail.com Tue Oct 13 05:50:30 2020 From: eryksun at gmail.com (Eryk Sun) Date: Tue, 13 Oct 2020 04:50:30 -0500 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> Message-ID: On 10/13/20, Tony Flury via Python-list wrote: > I am trying to write a simple expression to build a raw string that ends > in a single backslash. My understanding is that a raw string should > ignore attempts at escaping characters but I get this : > > >>> a = r'end\' > File "", line 1 > a = r'end\' > ^ > SyntaxError: EOL while scanning string literal Since r'\'' represents a two-character string with a backslash and a single quote, ending a raw string literal with an odd number of backslashes requires adding the final backslash using implicit string-literal concatenation. For example: >>> r'some\raw\string''\\' 'some\\raw\\string\\' Other ways to get the same result may operate at runtime instead of at compile time. From darcy at VybeNetworks.com Tue Oct 13 05:51:25 2020 From: darcy at VybeNetworks.com (D'Arcy Cain) Date: Tue, 13 Oct 2020 05:51:25 -0400 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> Message-ID: <92b56215-e136-f7c8-6221-0a88cc63af3d@VybeNetworks.com> On 10/12/20 7:20 AM, Chris Angelico wrote: > This is yet another reason that "from MODULE import *" is a bad idea. > Instead, just import the module itself, and take whatever you need. Or just import the objects that you need; from datetime import datetime, SYMBOL, etc... I use Decimal a lot. I would hate to have to write "decimal.Decimal(str)" for example. Whichever method you use the most important thing is to be consistent as much as possible. -- D'Arcy J.M. Cain Vybe Networks Inc. A unit of Excelsior Solutions Corporation - Propelling Business Forward http://www.VybeNetworks.com/ IM:darcy at VybeNetworks.com VoIP: sip:darcy at VybeNetworks.com -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 236 bytes Desc: OpenPGP digital signature URL: From rosuav at gmail.com Tue Oct 13 06:04:52 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 13 Oct 2020 21:04:52 +1100 Subject: What might cause my sample program to forget that already imported datetime? In-Reply-To: <92b56215-e136-f7c8-6221-0a88cc63af3d@VybeNetworks.com> References: <00b401d6a080$3d078790$b71696b0$@SGA.Ninja> <92b56215-e136-f7c8-6221-0a88cc63af3d@VybeNetworks.com> Message-ID: On Tue, Oct 13, 2020 at 9:03 PM D'Arcy Cain wrote: > > On 10/12/20 7:20 AM, Chris Angelico wrote: > > This is yet another reason that "from MODULE import *" is a bad idea. > > Instead, just import the module itself, and take whatever you need. > > Or just import the objects that you need; > > from datetime import datetime, SYMBOL, etc... > > I use Decimal a lot. I would hate to have to write "decimal.Decimal(str)" > for example. > > Whichever method you use the most important thing is to be consistent as > much as possible. Yep - either "import module" or "from module import name", but not "import *". Be precise. Be efficient. Have a plan to import every module you meet. ChrisA From brunodepaulak at yahoo.com.br Tue Oct 13 00:44:34 2020 From: brunodepaulak at yahoo.com.br (Bruno P. Kinoshita) Date: Tue, 13 Oct 2020 04:44:34 +0000 (UTC) Subject: Covariance matrix syntax In-Reply-To: References: Message-ID: <291564577.630412.1602564274535@mail.yahoo.com> I think the np.cov is from the numpy module (imported/aliased as np?). If so, the numpy repository should have what you are looking for: https://github.com/numpy/numpy/blob/156cd054e007b05d4ac4829e10a369d19dd2b0b1/numpy/lib/function_base.py#L2276 Hope that helps Bruno On Tuesday, 13 October 2020, 5:38:55 pm NZDT, Meghna Karkera wrote: May I know the steps or procedure behind covariance matrix syntax, np.cov(covar_matrix) in python -- https://mail.python.org/mailman/listinfo/python-list From tjreedy at udel.edu Tue Oct 13 07:12:49 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 13 Oct 2020 07:12:49 -0400 Subject: Weird behavior for IDLE... In-Reply-To: <003501d6a13e$19f79ab0$4de6d010$@SGA.Ninja> References: <003501d6a13e$19f79ab0$4de6d010$@SGA.Ninja> Message-ID: On 10/13/2020 4:51 AM, Steve wrote: > Why does IDLE always open with the lowest three lines of the window end up > hidden below the bottom of the screen behind the task bar? Every time I use > it, I have to stop and grab the top of the window and drag it up to see the > line and row information. I explored the Options/Configure IDLE but did not > see anything that would help. The issue is lines on the screen, which depends on screen, font, and fontsize, versus lines in the editor window plus lines above the editor window. On the General tab, you can ask for fewer lines in the editor window. Use Options -> Zoom Height to get the max lines possible. The positioning of the top of the window is the tk default. This might be changed if it became the highest priority. -- Terry Jan Reedy From storchaka at gmail.com Tue Oct 13 09:14:37 2020 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 13 Oct 2020 16:14:37 +0300 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> Message-ID: 13.10.20 11:52, Tony Flury via Python-list ????: > I am trying to write a simple expression to build a raw string that ends > in a single backslash. My understanding is that a raw string should > ignore attempts at escaping characters but I get this : > > ??? >>> a = r'end\' > ??? ? File "", line 1 > ??? ??? a = r'end\' > ??? ????????????? ^ > ?? SyntaxError: EOL while scanning string literal > > I interpret this as meaning that the \' is actually being interpreted as > a literal quote - is that a bug ? r'You can\'t end raw string literal with a single "\"' If backslash be true inner in a raw string, the above literal would end after \'. It would be very hard to write a raw string containing both \' and \", and even \''' and \""" (there are such strings in the stdlib). So you have problem either with trailing backslash, or with inner backslash followed by quotes. Both problems cannot be solved at the same time. Python parser works as it works because initially it was easier to implement, and now this cannot be changed because it would break some amount of correct code. > The only solution I have found is to do this : > > ??? >>> a = r'end' + chr(92) > ??? >>> a > ?? 'end\\' > ??? >>> list(a) > ?? ['e', 'n', 'd', '\\'] > > or > > > ??? >>> a = r'end\\'[:-1] > ??? >>> list(a) > ?? ['e', 'n', 'd', '\\'] > > Neither of which are nice. You can also write r'end' '\\'. It is not too nice, but it looks nicer to me then two other variants. From phoenix1987 at gmail.com Tue Oct 13 10:38:30 2020 From: phoenix1987 at gmail.com (Gabriele) Date: Tue, 13 Oct 2020 14:38:30 GMT Subject: [ANN] Austin -- CPython frame stack sampler v2.0.0 is now available Message-ID: I am delighted to announce the release 2.0.0 of Austin. If you haven't heard of Austin before, it is an open source frame stack sampler for CPython, distributed under the GPLv3 license. It can be used to obtain statistical profiling data out of a running Python application without a single line of instrumentation. This means that you can start profiling a Python application straightaway, even while it's running on a production environment, with minimal impact on performance. The simplest way of using Austin is by piping its output to FlameGraph for a quick and detailed representation of the collected samples. The latest release introduces a memory profiling mode which allows you to profile memory usage. Austin is a pure C application that has no other dependencies other than the C standard library. Its source code is hosted on GitHub at https://github.com/P403n1x87/austin The README contains installation and usage details, as well as some examples of Austin in action. Details on how to contribute to Austin's development can be found at the bottom of the page. Austin can be installed easily on the following platforms and from the following sources: Linux: - Snap Store - Debian repositories macOS: - Homebrew Windows: - Chocolatey - Scoop Austin is also simple to compile from sources as it only depends on the standard C library, if you don't have access to the above listed sources. Besides support for Python 3.9, this new release of Austin brings a considerable performance enhancement that allows it to sample up to 8 times faster than previous versions. But please do read on until the end to find out about some new tools that take advantage of all the key features of Austin. Due to increasing popularity, the sample Python applications that were included in the main repository have been moved to dedicated projects on GitHub. The TUI can now be found at https://github.com/P403n1x87/austin-tui while Austin Web is now available from https://github.com/P403n1x87/austin-web They can both be installed easily from PyPI, but in order to use them the Austin binary needs to be on the PATH environment variable. These projects now rely on the austin-python Python package that provides a Python wrapper around Austin. If you are considering making your own profiling tool based on Austin, this package can spare you from writing boilerplate code, so it's worth having a look at it at https://github.com/P403n1x87/austin-python The documentation is hosted on RTD at https://austin-python.readthedocs.io/en/latest/ Finally, I am happy to announce the release of pytest-austin, a plugin for pytest that allows you to set up performance regression testing by simply decorating your existing pytest test suite. The plugin launches Austin to profile your test runs, meaning that no further instrumentation is required. For more details, check out the project on GitHub https://github.com/P403n1x87/pytest-austin Like the other Austin tools, pytest-austin can be installed easily from PyPI. You can stay up-to-date with the project's development by following Austin on Twitter (https://twitter.com/AustinSampler). All the best, Gabriele

Austin 2.0.0 - frame stack sampler for CPython. (13-Oct-20)

From david at dpconsulting.co.nz Tue Oct 13 19:05:33 2020 From: david at dpconsulting.co.nz (David Painter) Date: Wed, 14 Oct 2020 12:05:33 +1300 Subject: lmoments3 and scipy (again) Message-ID: I'm aware there have been problems with previous versions of lmoments3 working with scipy -- comb having been replaced in scipy. I thought by using pip to install numpy, scipy, lmoments3 [whence distr] I would get compatible latest versions. I'm using 32-bit Python 3.8.6. I've verified scipy 1.5.2 and lmoments3 1.10.4 are present. But I still get a traceback referring to attribute comb not being present in module scipy.misc. Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:37:30) [MSC v.1927 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> import numpy >>> import scipy >>> import lmoments3 >>> from lmoments3 import distr >>> data = [135.2 ,130.1 ,117 ,109.3 ,92.1 ,91.4 ,83.1 ,80.5 ,74.7 ,69.8,65.2,58.6,56.5,55.4,54.6,54.5,49.5,48.9,48.3,46.6] >>> paras = distr.gpa.lmom_fit(data) Traceback (most recent call last): File "", line 1, in paras = distr.gpa.lmom_fit(data) File "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\distr.py", line 59, in lmom_fit lmom_ratios = lm.lmom_ratios(data, nmom=n_min) File "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\__init__.py", line 82, in lmom_ratios return _samlmusmall(data, nmom) File "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\__init__.py", line 159, in _samlmusmall l1 = np.sum(x) / sm.comb(n, 1, exact=True) AttributeError: module 'scipy.misc' has no attribute 'comb' What am I doing wrong? From aeros167 at gmail.com Wed Oct 14 02:47:57 2020 From: aeros167 at gmail.com (Kyle Stanley) Date: Wed, 14 Oct 2020 02:47:57 -0400 Subject: lmoments3 and scipy (again) In-Reply-To: References: Message-ID: Based on a search of the scipy docs, it looks like the function might have moved namespaces from scipy.misc.comb to scipy.special.comb ( https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.comb.html?highlight=comb#scipy-special-comb) when referenced in lmoments3. Alternatively, if you clone the package from the repo directly, it seems to have been addressed in a recent commit: https://github.com/OpenHydrology/lmoments3/commit/3349b90463f649aea02be5dc3726d22e5e500dc3 . On Wed, Oct 14, 2020 at 12:00 AM David Painter wrote: > I'm aware there have been problems with previous versions of > lmoments3 working with scipy -- comb having been replaced in scipy. I > thought by using pip to install numpy, scipy, lmoments3 [whence distr] I > would get compatible latest versions. I'm using 32-bit Python 3.8.6. I've > verified scipy 1.5.2 and lmoments3 1.10.4 are present. But I still get a > traceback referring to attribute comb not being present in > module scipy.misc. > Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:37:30) [MSC v.1927 32 > bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license()" for more information. > >>> import numpy > >>> import scipy > >>> import lmoments3 > >>> from lmoments3 import distr > >>> data = [135.2 ,130.1 ,117 ,109.3 ,92.1 ,91.4 ,83.1 ,80.5 ,74.7 > ,69.8,65.2,58.6,56.5,55.4,54.6,54.5,49.5,48.9,48.3,46.6] > >>> paras = distr.gpa.lmom_fit(data) > Traceback (most recent call last): > File "", line 1, in > paras = distr.gpa.lmom_fit(data) > File > > "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\distr.py", > line 59, in lmom_fit > lmom_ratios = lm.lmom_ratios(data, nmom=n_min) > File > > "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\__init__.py", > line 82, in lmom_ratios > return _samlmusmall(data, nmom) > File > > "C:\Users\David\AppData\Local\Programs\Python\Python38-32\lib\site-packages\lmoments3\__init__.py", > line 159, in _samlmusmall > l1 = np.sum(x) / sm.comb(n, 1, exact=True) > AttributeError: module 'scipy.misc' has no attribute 'comb' > > What am I doing wrong? > -- > https://mail.python.org/mailman/listinfo/python-list > From 0204477 at up.edu.mx Wed Oct 14 13:29:22 2020 From: 0204477 at up.edu.mx (=?UTF-8?Q?Ana_Mar=C3=ADa_Pliego_San_Mart=C3=ADn?=) Date: Wed, 14 Oct 2020 12:29:22 -0500 Subject: Python for Windows Message-ID: Hi! I've tried to install Python a couple of times on my computer. Although it works fine when first downloaded, every time I turn off my computer and then back on Python says it has a problem that needs fixing. After "fixing" it, I still encounter some issues and have the need to uninstall it and install it again. Do you know what the problem is? Thank you. Ana -- *POL?TICA DE PRIVACIDAD: Las instituciones pertenecientes al Sistema UP-IPADE utilizar?n cualquier dato personal expuesto en el presente correo electr?nico, ?nica y exclusivamente para cuestiones acad?micas, administrativas, de comunicaci?n, o bien para las finalidades expresadas en cada asunto en concreto, esto en cumplimiento con la Ley Federal de Protecci?n de Datos Personales en Posesi?n de los Particulares. Para mayor informaci?n acerca del tratamiento y de los derechos que puede hacer valer, usted puede acceder al aviso de privacidad integral a trav?s de nuestras p?ginas de Internet: www.up.edu.mx / prepaup.up.edu.mx / www.ipade.mx / www.ipadealumni.com.mx ? La informaci?n contenida en este correo es privada y confidencial, dirigida exclusivamente a su destinatario. Si usted no es el destinatario del mismo debe destruirlo y notificar al remitente absteni?ndose de obtener copias, ni difundirlo por ning?n sistema, ya que est? prohibido y goza de la protecci?n legal de las comunicaciones.* From david at dpconsulting.co.nz Wed Oct 14 17:25:09 2020 From: david at dpconsulting.co.nz (David Painter) Date: Thu, 15 Oct 2020 10:25:09 +1300 Subject: lmoments3 and scipy (again) In-Reply-To: References: Message-ID: Thank you, Kyle and Dennis. The developer version from 17 months ago, which I hadn't spotted, has solved my immediate problem. It would be good to have it mainstreamed to prevent others having the same problem. David On Thu, 15 Oct 2020 at 09:07, Dennis Lee Bieber wrote: > On Wed, 14 Oct 2020 12:05:33 +1300, David Painter > declaimed the following: > > >I'm aware there have been problems with previous versions of > >lmoments3 working with scipy -- comb having been replaced in scipy. I > >thought by using pip to install numpy, scipy, lmoments3 [whence distr] I > >would get compatible latest versions. I'm using 32-bit Python 3.8.6. I've > >verified scipy 1.5.2 and lmoments3 1.10.4 are present. But I still get a > > > > >What am I doing wrong? > > Well, the snarky answer would be "using SciPy 1.5.2" > > > https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.comb.html > > "comb" is now under scipy.special, not scipy.misc. But the real fault > likely needs to be put on lmoments3, since scipy.misc.comb has been > deprecated all the way back in scipy 1.0.0! > > > https://docs.scipy.org/doc/scipy-1.2.0/reference/generated/scipy.misc.comb.html > > https://pypi.org/project/lmoments3/#history indicates that lmoments3 > hasn't > been updated in over FIVE years. > > A change was merged into the /development/ branch a year and a > half ago > https://github.com/OpenHydrology/lmoments3/tree/develop explicitly for > this > situation, but has not gone "mainstream" > > > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com > http://wlfraed.microdiversity.freeddns.org/ > > -- > https://mail.python.org/mailman/listinfo/python-list > From torriem at gmail.com Wed Oct 14 20:04:34 2020 From: torriem at gmail.com (Michael Torrie) Date: Wed, 14 Oct 2020 18:04:34 -0600 Subject: Python for Windows In-Reply-To: References: Message-ID: <9ed9c132-7d96-07fd-3041-93fca5e2d8d1@gmail.com> On 10/14/20 11:29 AM, Ana Mar?a Pliego San Mart?n wrote: > I've tried to install Python a couple of times on my computer. Although it > works fine when first downloaded, every time I turn off my computer and > then back on Python says it has a problem that needs fixing. After "fixing" > it, I still encounter some issues and have the need to uninstall it and > install it again. Do you know what the problem is? You are running the installer again, not the Python interpreter. Kindly delete the installer file so this won't happen again. Please see this on-line documentation: https://docs.python.org/3/using/windows.html. Note that Python is an interpreter. It's not a GUI app, and it's not an IDE. It requires a python script (program) to do anything. Again, see the link above. Python does ship with a program called IDLE, which does provide an editor and means of running scripts without using the command prompt. It should be in your start menu. From samuelmarks at gmail.com Thu Oct 15 05:53:34 2020 From: samuelmarks at gmail.com (Samuel Marks) Date: Thu, 15 Oct 2020 20:53:34 +1100 Subject: =?UTF-8?B?Q0xJIHBhcnNpbmfigJR3aXRoIGAtLWhlbHBgIHRleHTigJRgLS1mb28gYmFyYCwgaG93IA==?= =?UTF-8?B?dG8gZ2l2ZSBhZGRpdGlvbmFsIHBhcmFtZXRlcnMgdG8gYGJhcmA/?= Message-ID: Previously I have solved related problems with explicit `-}` and `-{` (or `-b`) as in `nginxctl`: ``` $ python -m nginxctl serve --temp_dir '/tmp' \ -b 'server' \ --server_name 'localhost' --listen '8080' \ -b location '/' \ --root '/tmp/wwwroot' \ -} \ -} nginx is running. Stop with: /usr/local/bin/nginx -c /tmp/nginx.conf -s stop ``` To illustrate the issue, using `ml-params` and ml-params-tensorflow: ``` $ python -m ml_params --engine 'tensorflow' train --help usage: python -m ml_params train [-h] --optimizer {Adadelta,Adagrad,Adam,Adamax,Ftrl,Nadam,RMSprop} Run the training loop for your ML pipeline. optional arguments: -h, --help show this help message and exit --optimizer {Adadelta,Adagrad,Adam,Adamax,Ftrl,Nadam,RMSprop} The optimizer ``` Idea: preprocess `sys.argv` so that this syntax would work `--optimizer Adam[learning_rate=0.01]`* *square rather than round so as not to require escape characters or quoting in `sh` Unfortunately this approach wouldn't give nice `--help` text. What's the right solution here? Thanks, Samuel Marks Charity | consultancy | open-source | LinkedIn From stephie at osohq.com Thu Oct 15 11:53:06 2020 From: stephie at osohq.com (Stephie Glaser) Date: Thu, 15 Oct 2020 11:53:06 -0400 Subject: Efficient authorization for Django list views with oso Message-ID: Hi All! We're building an open source policy engine for adding access control (permissions, roles, etc.) to apps, called oso. oso policies are declarative, and enable users to cleanly separate authorization logic from the rest of their application code. In our latest release of django-oso, we added functionality to enforce authorization policies directly on Django QuerySets. The declarative policy is translated into filters that can be understood by the Django ORM, in a way that is fully abstracted from the library user. In the future, we'll be adding support for SQLAlchemy and other Python ORMs. We wrote about it in this blog post. Cleanly separating an authorization policy from other application code can be challenging, especially when authorizing a collection of objects, often necessary in list views. This feature makes it possible to enforce authorization as a filter when querying the application data store while still taking full advantage of the declarative policy provided by oso. This functionality is in preview in the 0.3.0 release of django-oso . Install via pip: pip install django-oso Let us know what you think in our Slack channel or on this thread! join-slack.osohq.com From dieter at handshake.de Thu Oct 15 12:14:48 2020 From: dieter at handshake.de (Dieter Maurer) Date: Thu, 15 Oct 2020 18:14:48 +0200 Subject: CLI parsing=?utf-8?B?4oCU?=with `--help` text=?utf-8?B?4oCU?=`--foo bar`, how to give additional parameters to `bar`? In-Reply-To: References: Message-ID: <24456.30072.597902.990996@ixdm.fritz.box> Samuel Marks wrote at 2020-10-15 20:53 +1100: > ... >To illustrate the issue, using `ml-params` and ml-params-tensorflow: > ... >What's the right solution here? While Python provides several modules in its standard library to process parameters (e.g. the simple `getopt` and the flexible `argparse`), it is up to the "application" whether it uses such a module (and which one) or whether it handle arguments on its own. Apparently, `ml_param` is not a staudard Python module. Is it a package of your own? Then I suggest to check `argparse` whether it supports your use case (I know, it can be customized to do it, but maybe, it does it already out of the box). If `ml_param` is a third party module, then the question is actually an `ml_param` question. Ask its support mailing lists or have a look at its source. From roland.em0001 at googlemail.com Thu Oct 15 15:16:46 2020 From: roland.em0001 at googlemail.com (=?UTF-8?Q?Roland_M=c3=bcller?=) Date: Thu, 15 Oct 2020 22:16:46 +0300 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> Message-ID: On 10/13/20 4:14 PM, Serhiy Storchaka wrote: > 13.10.20 11:52, Tony Flury via Python-list ????: >> I am trying to write a simple expression to build a raw string that ends >> in a single backslash. My understanding is that a raw string should >> ignore attempts at escaping characters but I get this : >> >> ??? >>> a = r'end\' >> ??? ? File "", line 1 >> ??? ??? a = r'end\' >> ??? ????????????? ^ >> ?? SyntaxError: EOL while scanning string literal >> >> I interpret this as meaning that the \' is actually being interpreted as >> a literal quote - is that a bug ? > r'You can\'t end raw string literal with a single "\"' > > If backslash be true inner in a raw string, the above literal would end > after \'. It would be very hard to write a raw string containing both \' > and \", and even \''' and \""" (there are such strings in the stdlib). > > So you have problem either with trailing backslash, or with inner > backslash followed by quotes. Both problems cannot be solved at the same > time. Python parser works as it works because initially it was easier to > implement, and now this cannot be changed because it would break some > amount of correct code. > >> The only solution I have found is to do this : >> >> ??? >>> a = r'end' + chr(92) >> ??? >>> a >> ?? 'end\\' >> ??? >>> list(a) >> ?? ['e', 'n', 'd', '\\'] >> >> or >> >> >> ??? >>> a = r'end\\'[:-1] >> ??? >>> list(a) >> ?? ['e', 'n', 'd', '\\'] >> >> Neither of which are nice. > You can also write r'end' '\\'. It is not too nice, but it looks nicer > to me then two other variants. > I used the triple single quotes as delimiter: >>> s = r'''a single quote ', a double quote "''' >>> s 'a single quote \', a double quote "' BR, Roland From storchaka at gmail.com Thu Oct 15 15:37:02 2020 From: storchaka at gmail.com (Serhiy Storchaka) Date: Thu, 15 Oct 2020 22:37:02 +0300 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> Message-ID: 15.10.20 22:16, Roland M?ller via Python-list ????: > I used the triple single quotes as delimiter: > >>>> s = r'''a single quote ', a double quote "''' >>>> s > > 'a single quote \', a double quote "' It does not help if the string contains both kinds of triple quotes You have to use triple quotes (''', """) for docstrings. or contains one kind of triple quote and ends with a single quote of other kind. a triple single quote ''', a single double quote " Of course there are workarounds, but the fact that changing the current rules will break existing code. From samuelmarks at gmail.com Thu Oct 15 19:09:09 2020 From: samuelmarks at gmail.com (Samuel Marks) Date: Fri, 16 Oct 2020 10:09:09 +1100 Subject: =?UTF-8?B?UmU6IENMSSBwYXJzaW5n4oCUd2l0aCBgLS1oZWxwYCB0ZXh04oCUYC0tZm9vIGJhcmAsIA==?= =?UTF-8?B?aG93IHRvIGdpdmUgYWRkaXRpb25hbCBwYXJhbWV0ZXJzIHRvIGBiYXJgPw==?= In-Reply-To: <24456.30072.597902.990996@ixdm.fritz.box> References: <24456.30072.597902.990996@ixdm.fritz.box> Message-ID: Yes it?s my module, and I?ve been using argparse https://github.com/SamuelMarks/ml-params No library I?ve found provides a solution to CLI argument parsing for my use-case. So I?ll write one. But what should it look like, syntactically and semantically? On Fri, 16 Oct 2020 at 3:14 am, Dieter Maurer wrote: > Samuel Marks wrote at 2020-10-15 20:53 +1100: > > ... > >To illustrate the issue, using `ml-params` and ml-params-tensorflow: > > ... > >What's the right solution here? > > While Python provides several modules in its standard library > to process parameters (e.g. the simple `getopt` and the flexible > `argparse`), > it is up to the "application" whether it uses such a module (and which one) > or whether it handle arguments on its own. > > Apparently, `ml_param` is not a staudard Python module. > Is it a package of your own? Then I suggest to check `argparse` whether > it supports your use case (I know, it can be customized to do it, > but maybe, it does it already out of the box). > > If `ml_param` is a third party module, then the question > is actually an `ml_param` question. Ask its support mailing lists > or have a look at its source. > > -- Samuel Marks Charity | consultancy | open-source | LinkedIn < https://linkedin.com/in/samuelmarks> From cs at cskk.id.au Thu Oct 15 19:20:40 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 16 Oct 2020 10:20:40 +1100 Subject: CLI =?utf-8?Q?parsing=E2=80=94with_`--?= =?utf-8?Q?help`_text=E2=80=94`--fo?= =?utf-8?Q?o?= bar`, how to give additional parameters to `bar`? In-Reply-To: References: Message-ID: <20201015232040.GA32729@cskk.homeip.net> On 16Oct2020 10:09, Samuel Marks wrote: >Yes it?s my module, and I?ve been using argparse >https://github.com/SamuelMarks/ml-params > >No library I?ve found provides a solution to CLI argument parsing for my >use-case. > >So I?ll write one. But what should it look like, syntactically and >semantically? I would make it look like argparse, if you're using argparse already. Can argparse be subclassed, eg to override some internal option-gathering method? In particular, I would not invent yet another command line syntax. I'd stick with the common -a and --long-name style, maybe using the -{ -} stuff you cited from nginx if it meets your needs. As with any bracketing syntax, you may one day find yourself needing to embed the literal end-bracket symbol in your command line one day, and thus may need some kind of escaping notion ("no! not closing the brackets yet!"). I can't offer mch specific advice on argparse, I use getopt myself. Cheers, Cameron Simpson From cs at cskk.id.au Thu Oct 15 19:26:31 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 16 Oct 2020 10:26:31 +1100 Subject: CLI =?utf-8?Q?parsing=E2=80=94with_`--?= =?utf-8?Q?help`_text=E2=80=94`--fo?= =?utf-8?Q?o?= bar`, how to give additional parameters to `bar`? In-Reply-To: References: Message-ID: <20201015232631.GA46784@cskk.homeip.net> One other thing: On 15Oct2020 20:53, Samuel Marks wrote: >Idea: preprocess `sys.argv` so that this syntax would work >`--optimizer Adam[learning_rate=0.01]`* > >*square rather than round so as not to require escape characters or >quoting in `sh` Square brackets are also shell syntax, introducing glob character ranges. You're only not noticing probably because an unmatched glob is normally let through unchanged. For example: somecmd x[b] would go through as "x[b]" _unless_ you had a matching local filename (in this case a file named "xb") in which case the shell would match the glob and pass through the match (in this case "xb"). You'll find this issue a fair bit: if you want some punctuation, someone else has probably already wanted that punctuation for something. You'll still need to quote things for a lot of stuff. Commas are not special. You could try: --optimizer Adam,learning_rate=0.01,something_else=3 which would work for a fair amount of stuff. >Unfortunately this approach wouldn't give nice `--help` text. >What's the right solution here? To get nice help text you need your command line parser to be able to compose that help text in some way. Usually the help text in argparse is supplied when you define the option. Cheers, Cameron Simpson From samuelmarks at gmail.com Thu Oct 15 19:59:16 2020 From: samuelmarks at gmail.com (Samuel Marks) Date: Fri, 16 Oct 2020 10:59:16 +1100 Subject: =?UTF-8?B?UmU6IENMSSBwYXJzaW5n4oCUd2l0aCBgLS1oZWxwYCB0ZXh04oCUYC0tZm9vIGJhcmAsIA==?= =?UTF-8?B?aG93IHRvIGdpdmUgYWRkaXRpb25hbCBwYXJhbWV0ZXJzIHRvIGBiYXJgPw==?= In-Reply-To: <20201015232631.GA46784@cskk.homeip.net> References: <20201015232631.GA46784@cskk.homeip.net> Message-ID: --optimizer Adam,learning_rate=0.01,something_else=3 That syntax isn?t so bad! =] How would you suggest the help text for this looks? (don?t worry about implementation, just what goes to stdout/stderr) PS: Yeah I used square brackets for my Bash arrays On Fri, 16 Oct 2020 at 10:26 am, Cameron Simpson wrote: > One other thing: > > On 15Oct2020 20:53, Samuel Marks wrote: > >Idea: preprocess `sys.argv` so that this syntax would work > >`--optimizer Adam[learning_rate=0.01]`* > > > >*square rather than round so as not to require escape characters or > >quoting in `sh` > > Square brackets are also shell syntax, introducing glob character > ranges. You're only not noticing probably because an unmatched glob is > normally let through unchanged. > > For example: > > somecmd x[b] > > would go through as "x[b]" _unless_ you had a matching local filename > (in this case a file named "xb") in which case the shell would match the > glob and pass through the match (in this case "xb"). > > You'll find this issue a fair bit: if you want some punctuation, someone > else has probably already wanted that punctuation for something. You'll > still need to quote things for a lot of stuff. > > Commas are not special. You could try: > > --optimizer Adam,learning_rate=0.01,something_else=3 > > which would work for a fair amount of stuff. > > >Unfortunately this approach wouldn't give nice `--help` text. > >What's the right solution here? > > To get nice help text you need your command line parser to be able to > compose that help text in some way. Usually the help text in argparse is > supplied when you define the option. > > Cheers, > Cameron Simpson > -- Samuel Marks Charity | consultancy | open-source | LinkedIn < https://linkedin.com/in/samuelmarks> From klsshaeffer at icloud.com Thu Oct 15 20:08:19 2020 From: klsshaeffer at icloud.com (Karen Shaeffer) Date: Thu, 15 Oct 2020 17:08:19 -0700 Subject: =?utf-8?Q?Re=3A_CLI_parsing=E2=80=94with_=60--help=60_text?= =?utf-8?Q?=E2=80=94=60--foo_bar=60=2C_how_to_give_additional_parameters_t?= =?utf-8?Q?o_=60bar=60=3F?= In-Reply-To: References: <24456.30072.597902.990996@ixdm.fritz.box> Message-ID: <2B34D1E1-61BA-445A-87BE-EB61F68EC114@icloud.com> Hi Sam, I?ve been using abseil python API. https://abseil.io/docs/python/guides/flags https://abseil.io/docs/python/quickstart It?s a distributed command line system with features that appear to support your needs. Karen > On Oct 15, 2020, at 4:09 PM, Samuel Marks wrote: > > Yes it?s my module, and I?ve been using argparse > https://github.com/SamuelMarks/ml-params > > No library I?ve found provides a solution to CLI argument parsing for my > use-case. > > So I?ll write one. But what should it look like, syntactically and > semantically? > > On Fri, 16 Oct 2020 at 3:14 am, Dieter Maurer > wrote: > >> Samuel Marks wrote at 2020-10-15 20:53 +1100: >>> ... >>> To illustrate the issue, using `ml-params` and ml-params-tensorflow: >>> ... >>> What's the right solution here? >> >> While Python provides several modules in its standard library >> to process parameters (e.g. the simple `getopt` and the flexible >> `argparse`), >> it is up to the "application" whether it uses such a module (and which one) >> or whether it handle arguments on its own. >> >> Apparently, `ml_param` is not a staudard Python module. >> Is it a package of your own? Then I suggest to check `argparse` whether >> it supports your use case (I know, it can be customized to do it, >> but maybe, it does it already out of the box). >> >> If `ml_param` is a third party module, then the question >> is actually an `ml_param` question. Ask its support mailing lists >> or have a look at its source. >> >> -- > Samuel Marks > Charity > | consultancy > > | open-source > > | LinkedIn < > https://linkedin.com/in/samuelmarks > > -- > https://mail.python.org/mailman/listinfo/python-list From 2QdxY4RzWzUUiLuE at potatochowder.com Thu Oct 15 20:15:21 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Thu, 15 Oct 2020 19:15:21 -0500 Subject: CLI =?utf-8?Q?parsing=E2=80=94with_`--?= =?utf-8?Q?help`_text=E2=80=94`--fo?= =?utf-8?Q?o?= bar`, how to give additional parameters to `bar`? In-Reply-To: References: <20201015232631.GA46784@cskk.homeip.net> Message-ID: <20201016001521.GB328313@scrozzle> On 2020-10-16 at 10:59:16 +1100, Samuel Marks wrote: > --optimizer Adam,learning_rate=0.01,something_else=3 > > That syntax isn?t so bad! =] > > How would you suggest the help text for this looks? (don?t worry about > implementation, just what goes to stdout/stderr) --optimizer name[,option=value...] Obviously, you'll have to explain that the brackets and the words option and value are meta syntax, but you're probably already doing that for your current meta syntax anyway. From 2QdxY4RzWzUUiLuE at potatochowder.com Thu Oct 15 19:50:21 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Thu, 15 Oct 2020 18:50:21 -0500 Subject: CLI =?utf-8?Q?parsing=E2=80=94with_`--?= =?utf-8?Q?help`_text=E2=80=94`--fo?= =?utf-8?Q?o?= bar`, how to give additional parameters to `bar`? In-Reply-To: <20201015232040.GA32729@cskk.homeip.net> References: <20201015232040.GA32729@cskk.homeip.net> Message-ID: <20201015235021.GA328313@scrozzle> On 2020-10-16 at 10:20:40 +1100, Cameron Simpson wrote: > On 16Oct2020 10:09, Samuel Marks wrote: > >Yes it?s my module, and I?ve been using argparse > >https://github.com/SamuelMarks/ml-params > > > >No library I?ve found provides a solution to CLI argument parsing for my > >use-case. Out of curiosity, what do your command line interfaces require that argparse and other libraries don't have? Yes, if my only tool is a hammer, then every problem looks like a nail, but I've yet to have a requirement that the POSIX rules don't cover. > >So I?ll write one ... Been there. Done that. :-) > > [...] But what should it look like, syntactically and semantically? [...] > In particular, I would not invent yet another command line syntax. I agree. The POSIX Utility Syntax and Guidelines: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html (I believe argparse supports a superset of the POSIX syntax.) I haven't found a definitive definition of GNU long options, only examples. HTH, Dan From samuelmarks at gmail.com Thu Oct 15 20:27:56 2020 From: samuelmarks at gmail.com (Samuel Marks) Date: Fri, 16 Oct 2020 11:27:56 +1100 Subject: =?UTF-8?B?UmU6IENMSSBwYXJzaW5n4oCUd2l0aCBgLS1oZWxwYCB0ZXh04oCUYC0tZm9vIGJhcmAsIA==?= =?UTF-8?B?aG93IHRvIGdpdmUgYWRkaXRpb25hbCBwYXJhbWV0ZXJzIHRvIGBiYXJgPw==?= In-Reply-To: <20201015235021.GA328313@scrozzle> References: <20201015232040.GA32729@cskk.homeip.net> <20201015235021.GA328313@scrozzle> Message-ID: Hi Dan, The feature that existing CLI parsers are missing is a clean syntax for specifying options on the second parameter (the "value"), where there may be different options available depending on which you choose. For example: https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/Adam has `learning_rate`, `beta_1`, `beta_2`, `epsilon`, and `amsgrad`* Whereas https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/RMSprop has `learning_rate`, `rho`, `momentum`, `epsilon`, `centered`* *with clipnorm, clipvalue, decay hidden behind kwargs So the question is how to expose this as CLI options. `--optimizer Adam` is a good first step, but it should error if I try and give it `momentum`. The comma syntax is my favourite so far. I guess I'll just have to write a validator outside the CLI parser to handle this? Samuel Marks Charity | consultancy | open-source | LinkedIn On Fri, Oct 16, 2020 at 11:19 AM <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > > On 2020-10-16 at 10:20:40 +1100, > Cameron Simpson wrote: > > > On 16Oct2020 10:09, Samuel Marks wrote: > > >Yes it?s my module, and I?ve been using argparse > > >https://github.com/SamuelMarks/ml-params > > > > > >No library I?ve found provides a solution to CLI argument parsing for my > > >use-case. > > Out of curiosity, what do your command line interfaces require that > argparse and other libraries don't have? > > Yes, if my only tool is a hammer, then every problem looks like a nail, > but I've yet to have a requirement that the POSIX rules don't cover. > > > >So I?ll write one ... > > Been there. Done that. :-) > > > > [...] But what should it look like, syntactically and semantically? > > [...] > > > In particular, I would not invent yet another command line syntax. > > I agree. The POSIX Utility Syntax and Guidelines: > > https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html > > (I believe argparse supports a superset of the POSIX syntax.) > > I haven't found a definitive definition of GNU long options, only > examples. > > HTH, > Dan > -- > https://mail.python.org/mailman/listinfo/python-list From cs at cskk.id.au Thu Oct 15 22:01:26 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 16 Oct 2020 13:01:26 +1100 Subject: CLI =?utf-8?Q?parsing=E2=80=94with_`--?= =?utf-8?Q?help`_text=E2=80=94`--fo?= =?utf-8?Q?o?= bar`, how to give additional parameters to `bar`? In-Reply-To: References: Message-ID: <20201016020126.GA26610@cskk.homeip.net> On 16Oct2020 10:59, Samuel Marks wrote: >--optimizer Adam,learning_rate=0.01,something_else=3 > >That syntax isn?t so bad! =] > >How would you suggest the help text for this looks? (don?t worry about >implementation, just what goes to stdout/stderr) Maybe: Usage: ....... ................ --optimizer name[,param=value...] Specify use of the named optimizer with optional additional parameters: learning_rate Scale of gullibility, a float. something_else Another tuning thing, ... which is the style I use in my own usage messages. Possibly also allow the "=value" to be optional (where sensible per parameter), since it is so easy. >PS: Yeah I used square brackets for my Bash arrays By the time I want real arrays in my shell scripts I'm often verging on the regime where it's time to transition to a more expressive language. Like Python :-) (Unless of course you're using a bunch of shell control constructs like pipes, which are succintly written in the shell.) Cheers, Cameron Simpson From 2QdxY4RzWzUUiLuE at potatochowder.com Thu Oct 15 22:59:10 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Thu, 15 Oct 2020 21:59:10 -0500 Subject: CLI =?utf-8?Q?parsing=E2=80=94with_`--?= =?utf-8?Q?help`_text=E2=80=94`--fo?= =?utf-8?Q?o?= bar`, how to give additional parameters to `bar`? In-Reply-To: References: <20201015232040.GA32729@cskk.homeip.net> <20201015235021.GA328313@scrozzle> Message-ID: <20201016025910.GC328313@scrozzle> On 2020-10-16 at 11:27:56 +1100, Regarding "Re: CLI parsing?with `--help` text?`--foo bar`, how to give additional parameters to `bar`?," Samuel Marks wrote: > The feature that existing CLI parsers are missing is a clean syntax > for specifying options on the second parameter (the "value"), where > there may be different options available depending on which you > choose. > > For example: > https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/Adam > has `learning_rate`, `beta_1`, `beta_2`, `epsilon`, and `amsgrad`* > Whereas > https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/RMSprop > has `learning_rate`, `rho`, `momentum`, `epsilon`, `centered`* > > *with clipnorm, clipvalue, decay hidden behind kwargs > > So the question is how to expose this as CLI options. `--optimizer > Adam` is a good first step, but it should error if I try and give it > `momentum`. The comma syntax is my favourite so far. I guess to me, that level of complexity (an optimizer followed by a series of key/value pairs) is at least partially an application problem rather than a library problem. IOW, if my command line parser tells me that the user specified "--optimizer" with an argument of "Adam,learning_rate=1.0,beta_1=3.0," then I'll parse the rest in my application. At some point, I might consider a lex/yacc or ini-file solution instead of that kind of command line. > I guess I'll just have to write a validator outside the CLI parser to > handle this? Exactly. :-) -- ?Whoever undertakes to set himself up as a judge of Truth and Knowledge is shipwrecked by the laughter of the gods.? ? Albert Einstein Dan Sommers, http://www.tombstonezero.net/dan From dieter at handshake.de Fri Oct 16 00:47:38 2020 From: dieter at handshake.de (Dieter Maurer) Date: Fri, 16 Oct 2020 06:47:38 +0200 Subject: CLI parsing=?utf-8?B?4oCU?=with `--help` text=?utf-8?B?4oCU?=`--foo bar`, how to give additional parameters to `bar`? In-Reply-To: References: <24456.30072.597902.990996@ixdm.fritz.box> Message-ID: <24457.9706.602677.464104@ixdm.fritz.box> Samuel Marks wrote at 2020-10-16 10:09 +1100: >Yes it?s my module, and I?ve been using argparse >https://github.com/SamuelMarks/ml-params > >No library I?ve found provides a solution to CLI argument parsing for my >use-case. Do you know that with `argparse` you can specify how many arguments an option expects? Thus, it should be quite easily possible to have --opt ... Do you know that you can define new `Action`s for `argparse`? This way, you could properly process `--opt ,, ...`. From samuelmarks at gmail.com Fri Oct 16 00:58:37 2020 From: samuelmarks at gmail.com (Samuel Marks) Date: Fri, 16 Oct 2020 15:58:37 +1100 Subject: =?UTF-8?B?UmU6IFJlOiBDTEkgcGFyc2luZ+KAlHdpdGggYC0taGVscGAgdGV4dOKAlGAtLWZvbyBiYQ==?= =?UTF-8?B?cmAsIGhvdyB0byBnaXZlIGFkZGl0aW9uYWwgcGFyYW1ldGVycyB0byBgYmFyYD8=?= In-Reply-To: <24457.9706.602677.464104@ixdm.fritz.box> References: <24456.30072.597902.990996@ixdm.fritz.box> <24457.9706.602677.464104@ixdm.fritz.box> Message-ID: Yeah I've played with custom actions before https://github.com/offscale/argparse-utils/tree/master/argparse_utils/actions But this would only help in one phase, the important phase of providing help text will need to be provided out-of-argparse and thrown in (like my trivial absl alternative, exposing a function which takes an argparse instance and returns an argparse instance) The only hack remaining is that I have to pass through `sys.argv` at least once before giving it to argparse. I wonder if there's a way to not need to explicitly go through it at all? https://github.com/SamuelMarks/ml-params/blob/d1fb184/ml_params/__main__.py#L89 [I didn't know `getopt` was exposed otherwise I'd use that , but there has to be a solution just using argparse?] Samuel Marks Charity | consultancy | open-source | LinkedIn Samuel Marks Charity | consultancy | open-source | LinkedIn On Fri, Oct 16, 2020 at 3:47 PM Dieter Maurer wrote: > > Samuel Marks wrote at 2020-10-16 10:09 +1100: > >Yes it?s my module, and I?ve been using argparse > >https://github.com/SamuelMarks/ml-params > > > >No library I?ve found provides a solution to CLI argument parsing for my > >use-case. > > Do you know that with `argparse` you can specify how many arguments an option > expects? Thus, it should be quite easily possible to > have --opt ... > Do you know that you can define new `Action`s for `argparse`? > This way, you could properly process `--opt ,, ...`. From Gronicus at SGA.Ninja Fri Oct 16 03:42:37 2020 From: Gronicus at SGA.Ninja (Steve) Date: Fri, 16 Oct 2020 03:42:37 -0400 Subject: How do I get datetime to stop showing seconds? Message-ID: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> d2 = datetime.datetime.now() #Time Right now Show this: 2020-10-16 02:53 and not this: 2020-10-16 02:53:48.585865 ============================================================== Footnote: If you double major in psychology and reverse psychology, to they cancel each other out? -- From samuelmarks at gmail.com Fri Oct 16 03:45:13 2020 From: samuelmarks at gmail.com (Samuel Marks) Date: Fri, 16 Oct 2020 18:45:13 +1100 Subject: =?UTF-8?B?UmU6IENMSSBwYXJzaW5n4oCUd2l0aCBgLS1oZWxwYCB0ZXh04oCUYC0tZm9vIGJhcmAsIA==?= =?UTF-8?B?aG93IHRvIGdpdmUgYWRkaXRpb25hbCBwYXJhbWV0ZXJzIHRvIGBiYXJgPw==?= In-Reply-To: References: <24456.30072.597902.990996@ixdm.fritz.box> <24457.9706.602677.464104@ixdm.fritz.box> <508A7ACC-C841-44AD-BB7A-573500B3582A@icloud.com> Message-ID: Yeah, but the risk with config files is you need a website?and/or full JSON schema output?to figure out what?s needed. (Although I should mention that with my doctrans project you can generate a config class?and class method?from/to your argparse parser; enabling the config file scenario rather cleanly) Also there is a project which takes your CLI and turns it into a GUI (Gooey). At some future point doctrans will be ?complete?, and then you can provide inputs via: - CLI arguments - Config file - RPC* - REST* *TODO, will also optionally generate ORM classes for persistence On Fri, 16 Oct 2020 at 6:08 pm, Karen Shaeffer wrote: > Passing a lot of command line parameters is very error prone. Opening a > file and specifying flags is much more user friendly, because you have any > necessary help documented right there. In my eyes, the command line is only > useful for simple scripts. > > Karen > > > On Oct 15, 2020, at 11:44 PM, Karen Shaeffer > wrote: > > > > In my work, for complex ML modeling code, I never pass anything through > the command line. I implement absl.flags in each module, specifying all the > defaults. At runtime I instantiate the flags as class variables of a > ModelConfiguration class that gets passed into the model class. Absl > supports all I need for this scheme. Of course, for a package, I can have a > configuration module for all these configuration classes. > > > > This scheme is easy to maintain. It can be dynamically customized at run > time. It?s very easy to document and maintain and to use. In one project, I > even supported console inputs that dynamically managed configurations of > pipelines. Nothing was ever passed in on command lines. I wonder why you > need to play on the command line. > > > > And yea, I?ve written a command line parsing function in C a long time > ago. I thought that really cool at the time. I wouldn?t want to do it now. > > > > Karen. > > > >> On Oct 15, 2020, at 9:58 PM, Samuel Marks > wrote: > >> > >> Yeah I've played with custom actions before > >> > https://github.com/offscale/argparse-utils/tree/master/argparse_utils/actions > >> > >> But this would only help in one phase, the important phase of > >> providing help text will need to be provided out-of-argparse and > >> thrown in > >> > >> (like my trivial absl alternative, exposing a function which takes an > >> argparse instance and returns an argparse instance) > >> > >> The only hack remaining is that I have to pass through `sys.argv` at > >> least once before giving it to argparse. I wonder if there's a way to > >> not need to explicitly go through it at all? > >> > https://github.com/SamuelMarks/ml-params/blob/d1fb184/ml_params/__main__.py#L89 > >> > >> [I didn't know `getopt` was exposed otherwise I'd use that >> sometimes do in C>, but there has to be a solution just using > >> argparse?] > >> > >> Samuel Marks > >> Charity | consultancy > >> | open-source | > >> LinkedIn > >> > >> > >> Samuel Marks > >> Charity | consultancy | open-source | LinkedIn > >> > >> > >> On Fri, Oct 16, 2020 at 3:47 PM Dieter Maurer > wrote: > >>> > >>> Samuel Marks wrote at 2020-10-16 10:09 +1100: > >>>> Yes it?s my module, and I?ve been using argparse > >>>> https://github.com/SamuelMarks/ml-params > >>>> > >>>> No library I?ve found provides a solution to CLI argument parsing for > my > >>>> use-case. > >>> > >>> Do you know that with `argparse` you can specify how many arguments an > option > >>> expects? Thus, it should be quite easily possible to > >>> have --opt ... > >>> Do you know that you can define new `Action`s for `argparse`? > >>> This way, you could properly process `--opt ,, ...`. > >> -- > >> https://mail.python.org/mailman/listinfo/python-list > > > > -- Samuel Marks Charity | consultancy | open-source | LinkedIn < https://linkedin.com/in/samuelmarks> From frank at chagford.com Fri Oct 16 04:34:01 2020 From: frank at chagford.com (Frank Millman) Date: Fri, 16 Oct 2020 10:34:01 +0200 Subject: How do I get datetime to stop showing seconds? In-Reply-To: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> References: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> Message-ID: <41a03272-84e9-bf3e-030a-424dab8aa6ab@chagford.com> On 2020-10-16 9:42 AM, Steve wrote: > d2 = datetime.datetime.now() #Time Right now > > Show this: 2020-10-16 02:53 > and not this: 2020-10-16 02:53:48.585865 > >>> >>> str(d2) '2020-10-16 10:29:38.423371' >>> >>> d2.strftime('%Y-%m-%d %H:%M') '2020-10-16 10:29' >>> Frank Millman From frank at chagford.com Fri Oct 16 04:34:01 2020 From: frank at chagford.com (Frank Millman) Date: Fri, 16 Oct 2020 10:34:01 +0200 Subject: How do I get datetime to stop showing seconds? In-Reply-To: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> References: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> Message-ID: <41a03272-84e9-bf3e-030a-424dab8aa6ab@chagford.com> On 2020-10-16 9:42 AM, Steve wrote: > d2 = datetime.datetime.now() #Time Right now > > Show this: 2020-10-16 02:53 > and not this: 2020-10-16 02:53:48.585865 > >>> >>> str(d2) '2020-10-16 10:29:38.423371' >>> >>> d2.strftime('%Y-%m-%d %H:%M') '2020-10-16 10:29' >>> Frank Millman From Marco.Sulla.Python at gmail.com Fri Oct 16 04:40:03 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Fri, 16 Oct 2020 10:40:03 +0200 Subject: How do I get datetime to stop showing seconds? In-Reply-To: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> References: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> Message-ID: Another way is: '{:%Y-%m-%d %H:%M}'.format(d2) From Gronicus at SGA.Ninja Fri Oct 16 06:20:34 2020 From: Gronicus at SGA.Ninja (Steve) Date: Fri, 16 Oct 2020 06:20:34 -0400 Subject: How do I get datetime to stop showing seconds? In-Reply-To: <41a03272-84e9-bf3e-030a-424dab8aa6ab@chagford.com> References: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> <41a03272-84e9-bf3e-030a-424dab8aa6ab@chagford.com> Message-ID: <000001d6a3a5$fc35bd80$f4a13880$@SGA.Ninja> Right on target, Many Thanks.... FootNote: If money does not grow on trees, then why do banks have branches? -----Original Message----- From: Python-list On Behalf Of Frank Millman Sent: Friday, October 16, 2020 4:34 AM To: python-list at python.org Subject: Re: How do I get datetime to stop showing seconds? On 2020-10-16 9:42 AM, Steve wrote: > d2 = datetime.datetime.now() #Time Right now > > Show this: 2020-10-16 02:53 > and not this: 2020-10-16 02:53:48.585865 > >>> >>> str(d2) '2020-10-16 10:29:38.423371' >>> >>> d2.strftime('%Y-%m-%d %H:%M') '2020-10-16 10:29' >>> Frank Millman -- https://mail.python.org/mailman/listinfo/python-list From eryksun at gmail.com Fri Oct 16 06:50:13 2020 From: eryksun at gmail.com (Eryk Sun) Date: Fri, 16 Oct 2020 05:50:13 -0500 Subject: How do I get datetime to stop showing seconds? In-Reply-To: <000001d6a3a5$fc35bd80$f4a13880$@SGA.Ninja> References: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> <41a03272-84e9-bf3e-030a-424dab8aa6ab@chagford.com> <000001d6a3a5$fc35bd80$f4a13880$@SGA.Ninja> Message-ID: On 10/16/20, Steve wrote: > -----Original Message----- > From: Python-list On > Behalf Of Frank Millman > Sent: Friday, October 16, 2020 4:34 AM > To: python-list at python.org > Subject: Re: How do I get datetime to stop showing seconds? > > On 2020-10-16 9:42 AM, Steve wrote: >> d2 = datetime.datetime.now() #Time Right now >> >> Show this: 2020-10-16 02:53 >> and not this: 2020-10-16 02:53:48.585865 > > >>> > >>> str(d2) > '2020-10-16 10:29:38.423371' > >>> > >>> d2.strftime('%Y-%m-%d %H:%M') > '2020-10-16 10:29' datetime also supports the __format__ protocol [1]. For example: >>> d2 = datetime(2020, 10, 16, 10, 29, 38, 423371) >>> format(d2, '%Y-%m-%d %H:%M') '2020-10-16 10:29' >>> f'{d2:%Y-%m-%d %H:%M}' '2020-10-16 10:29' [1] https://docs.python.org/3/library/datetime.html#datetime.datetime.__format__ From cousinstanley at gmail.com Fri Oct 16 10:23:58 2020 From: cousinstanley at gmail.com (Cousin Stanley) Date: Fri, 16 Oct 2020 07:23:58 -0700 Subject: How do I get datetime to stop showing seconds? References: <008001d6a38f$ebe088e0$c3a19aa0$@SGA.Ninja> Message-ID: Steve wrote: > d2 = datetime.datetime.now() #Time Right now > > Show this: 2020-10-16 02:53 > and not this: 2020-10-16 02:53:48.585865 > > > ============================================================== > Footnote: > If you double major in psychology and reverse psychology, to they cancel > each other out? > > -- py> py> import datetime as dt py> py> d = dt.datetime.now().strftime( '%Y-%m-%d %H:%M' ) py> py> print( '\n ' , d ) 2020-10-16 07:22 -- Stanley C. Kitching Human Being Phoenix, Arizona From sjeik_appie at hotmail.com Fri Oct 16 16:07:58 2020 From: sjeik_appie at hotmail.com (sjeik_appie at hotmail.com) Date: Fri, 16 Oct 2020 22:07:58 +0200 Subject: How do I get datetime to stop showing seconds? In-Reply-To: Message-ID: On 16 Oct 2020 12:50, Eryk Sun wrote: On 10/16/20, Steve wrote: > -----Original Message----- > From: Python-list On > Behalf Of Frank Millman > Sent: Friday, October 16, 2020 4:34 AM > To: python-list at python.org > Subject: Re: How do I get datetime to stop showing seconds? > > On 2020-10-16 9:42 AM, Steve wrote: >> d2 =? datetime.datetime.now() #Time Right now >>? I was using datetime.now().isoformat('T', 'seconds') Not 100% sure, but the strings seemed to be 2hrs off. Could it be that this Linux server was using the wrong time zone? From cs at cskk.id.au Fri Oct 16 18:51:04 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 17 Oct 2020 09:51:04 +1100 Subject: How do I get datetime to stop showing seconds? In-Reply-To: References: Message-ID: <20201016225104.GA65841@cskk.homeip.net> On 16Oct2020 22:07, Albert-Jan Roskam wrote: > I was using datetime.now().isoformat('T', 'seconds') > Not 100% sure, but the strings seemed to be 2hrs off. Could it be that > this Linux server was using the wrong time zone? Maybe. This is why timezones are such a nightmare, and programmes working with datetime as their primary structure are fragile (hmm, is this _naive_ (untimezoned) datetime in local time? What _is_ local time? Was the naive datetime obtained correctly? etc). Hence the common recommendation to work in seconds since an epoch (on UNIX that epoch is midnight 01 January 1970 GMT). Then timezones are just when presenting to a human. But also, on UNIX and UNIX-like (Linux) the timezone is an aspect of your environment; setting the $TZ environment various suitably will display times according to your preference. The system default for when $TZ is not set is usually in the /etc/timezone file, but you can set $TZ for yourself and have your own localtimes generally displayed. Cheers, Cameron Simpson From mats at python.org Fri Oct 16 20:20:42 2020 From: mats at python.org (Mats Wichmann) Date: Fri, 16 Oct 2020 18:20:42 -0600 Subject: =?UTF-8?B?UmU6IENMSSBwYXJzaW5n4oCUd2l0aCBgLS1oZWxwYCB0ZXh04oCUYC0t?= =?UTF-8?Q?foo_bar=60=2c_how_to_give_additional_parameters_to_=60bar=60=3f?= In-Reply-To: References: <24456.30072.597902.990996@ixdm.fritz.box> Message-ID: <96985ce0-9841-4bde-0214-37d7619da1c7@python.org> On 10/15/20 5:09 PM, Samuel Marks wrote: > Yes it?s my module, and I?ve been using argparse > https://github.com/SamuelMarks/ml-params > > No library I?ve found provides a solution to CLI argument parsing for my > use-case. > > So I?ll write one. But what should it look like, syntactically and > semantically? Jumping back to an earlier point in the thread... There are an astonishing number of "argument parsers" for the Python universe, but if none of them do what you want it's certainly not illegal to write your own. Reinventing the wheel is ok if existing wheels don't work right on your vehicle - but do take the time check. getopt, optparse, and argparse from the standard library have all adopted some of the relatively well specified POSIX argument syntax. Python has a heritage in the POSIX-y world, but not all systems (Windows!) follow that model anyway. All have some quirks (I find optparse and argparse irritating for some of the choices they've made). If you haven't seen it, Dan Bader and his crew at the excellent RealPython have a comparsion of some of them: https://realpython.com/comparing-python-command-line-parsing-libraries-argparse-docopt-click The thing is, if your situation is that you've looked at existing implementations and don't like them, then it's hard to ask us here as a group what a replacement should look like - by not liking what you've seen you must have some model in your mind of what would look more sane that you're comparing against, and we can't mind-read! From aniruddhaghosh280605 at gmail.com Sat Oct 17 13:39:20 2020 From: aniruddhaghosh280605 at gmail.com (Aniruddha Ghosh) Date: Sat, 17 Oct 2020 10:39:20 -0700 (PDT) Subject: python unistallation Message-ID: I by chance deleted the python 3.9 files from my file explorer and now while unistalling it is showing fatal error . I cant uninstall it . please anyone help. From python at mrabarnett.plus.com Sat Oct 17 14:10:47 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 17 Oct 2020 19:10:47 +0100 Subject: python unistallation In-Reply-To: References: Message-ID: On 2020-10-17 18:39, Aniruddha Ghosh wrote: > I by chance deleted the python 3.9 files from my file explorer and now while unistalling it is showing fatal error . I cant uninstall it . please anyone help. > Have you tried using the installer to repair it first? From davedungan7 at yahoo.com Fri Oct 16 23:04:03 2020 From: davedungan7 at yahoo.com (Dave Dungan) Date: Sat, 17 Oct 2020 03:04:03 +0000 (UTC) Subject: Subprocess Connection Error References: <1075264989.313424.1602903843269.ref@mail.yahoo.com> Message-ID: <1075264989.313424.1602903843269@mail.yahoo.com> Hello, I bought a book called Coding for Beginners to learn how to code using Python. The first few exercises went fine. When I got to the page called Recognizing types and did the exercise and saved it and tried to run the module it comes up with a Subprocess Connection Error. It says, "IDLE's subprocess didn't make connection. See the Start up failure section of the IDLE doc, online at https://docs.python.org/3/library/idle.html#startup-failure." I went there and it said to try uninstalling python and then reinstalling it. I did this and it did the same thing again. It also said something about it is because of the antivirus software. I tried installing python on a different computer and it happened at the exact same place in the exercises in the book. I am far from being a computer whiz, just thought it would be fun to learn some simple coding. Any help would be appreciated. One more thing, the book says to save it as "types.py". Thank you, Dave Dungan From drsalists at gmail.com Sat Oct 17 17:00:33 2020 From: drsalists at gmail.com (Dan Stromberg) Date: Sat, 17 Oct 2020 14:00:33 -0700 Subject: Subprocess Connection Error In-Reply-To: <1075264989.313424.1602903843269@mail.yahoo.com> References: <1075264989.313424.1602903843269.ref@mail.yahoo.com> <1075264989.313424.1602903843269@mail.yahoo.com> Message-ID: Does this help? https://stackoverflow.com/questions/29567051/python-error-idles-subprocess-didnt-make-connection-either-idle-cant-start On Sat, Oct 17, 2020 at 12:44 PM Dave Dungan via Python-list < python-list at python.org> wrote: > Hello, > > I bought a book called Coding for Beginners to learn how to code using > Python. The first few exercises went fine. When I got to the page called > Recognizing types and did the exercise and saved it and tried to run the > module it comes up with a Subprocess Connection Error. It says, "IDLE's > subprocess didn't make connection. See the Start up failure section of the > IDLE doc, online at > https://docs.python.org/3/library/idle.html#startup-failure." I went > there and it said to try uninstalling python and then reinstalling it. I > did this and it did the same thing again. It also said something about it > is because of the antivirus software. I tried installing python on a > different computer and it happened at the exact same place in the exercises > in the book. I am far from being a computer whiz, just thought it would be > fun to learn some simple coding. Any help would be appreciated. One more > thing, the book says to save it as "types.py". > > Thank you, > Dave Dungan > -- > https://mail.python.org/mailman/listinfo/python-list > From mgogala at yahoo.com Sat Oct 17 17:03:26 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Sat, 17 Oct 2020 21:03:26 -0000 (UTC) Subject: Simple question - end a raw string with a single backslash ? References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> Message-ID: On Thu, 15 Oct 2020 21:30:15 +0000, Stefan Ram wrote: > Tony Flury writes: >> >>> a = r'end' + chr(92) > > Or maybe, > > a = r''' > end\ > '''[ 1: -1 ] > > ? The first and the last line are messy, but in the middle, > the intended string is clearly visible. You can use perl module for python. It is installable by pip. Perl has no problems with handling backslashes. https://pypi.org/project/perl/ What you need is something like this: mgogala at umajor:~$ perl -e '$a="abcd";$a=~s/$/\\/; print "$a\n";' abcd\ Python has a problem with backslashes: Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> a="abcd" >>> b=re.sub('$',chr(28),a) >>> b 'abcd\x1c' >>> b=re.sub('$',chr(0x41),a) >>> b 'abcdA' >>> b=re.sub('$','Z',a) >>> b 'abcdZ' >>> b=re.sub('$',chr(0x1C),a) >>> b 'abcd\x1c' >>> Any other character is shown as it should be, except backslash. -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From Gronicus at SGA.Ninja Sat Oct 17 18:12:16 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sat, 17 Oct 2020 18:12:16 -0400 Subject: File Name issue Message-ID: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> The line: with open("HOURLYLOG.txt", 'r') as infile: works but, when I rename the file, the line: with open("HOURLY-LOG.txt", 'r') as infile: does not. The complaint is: Cannot Assign to operator However, I have: BPM_O2s=open("BPM-O2-Readings.txt","a") And it works. At first, I thought the issue was due to having the - in the filename. Is there a fix or explanation for this? Steve FootNote: Would it be ironic if Popeye's chicken was fried in Olive Oil? From tjreedy at udel.edu Sat Oct 17 18:42:03 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 17 Oct 2020 18:42:03 -0400 Subject: Subprocess Connection Error In-Reply-To: References: <1075264989.313424.1602903843269.ref@mail.yahoo.com> <1075264989.313424.1602903843269@mail.yahoo.com> Message-ID: On 10/17/2020 5:00 PM, Dan Stromberg wrote: > Does this help? > > https://stackoverflow.com/questions/29567051/python-error-idles-subprocess-didnt-make-connection-either-idle-cant-start I believe I included every legitimate answer on stackoverflow, including that post, in the doc section linked below. > On Sat, Oct 17, 2020 at 12:44 PM Dave Dungan via Python-list < > python-list at python.org> wrote: > >> Hello, >> >> I bought a book called Coding for Beginners to learn how to code using >> Python. The first few exercises went fine. When I got to the page called >> Recognizing types and did the exercise and saved it and tried to run the >> module it comes up with a Subprocess Connection Error. It says, "IDLE's >> subprocess didn't make connection. See the Start up failure section of the >> IDLE doc, online at >> https://docs.python.org/3/library/idle.html#startup-failure." I went >> there and it said to try uninstalling python and then reinstalling it. It actually says, for 3.8+, [some things to try] Python installation issues occasionally stop IDLE: multiple versions can clash, or a single installation might need admin access. If one [cannot] undo the clash, or cannot or does not want to run as admin, it might be easiest to completely remove Python and start over. [more things to try]. I should fix the type and move this down to the bottom as a last resort. >> I did this and it did the same thing again. It also said something about it >> is because of the antivirus software. I tried installing python on a >> different computer and it happened at the exact same place in the exercises >> in the book. I am far from being a computer whiz, just thought it would be >> fun to learn some simple coding. Any help would be appreciated. One more >> thing, the book says to save it as "types.py". I'm glad you added that. Naming files after stdlib modules is a bad idea and is covered by the the first item in the doc. "A common cause of failure is a user-written file with the same name as a standard library module, such as random.py and tkinter.py. When such a file is located in the same directory as a file that is about to be run, IDLE cannot import the stdlib file. The current fix is to rename the user file." types.py is a standard library file, so try a different name and see if this is the problem. -- Terry Jan Reedy From mgogala at yahoo.com Sat Oct 17 18:51:11 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Sat, 17 Oct 2020 22:51:11 -0000 (UTC) Subject: File Name issue References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> Message-ID: On Sat, 17 Oct 2020 18:12:16 -0400, Steve wrote: > with open("HOURLYLOG.txt", 'r') as infile: > works but, when I rename the file, the line: > with open("HOURLY-LOG.txt", 'r') as infile: > does not. The complaint is: Cannot Assign to operator Try this: with open("HOURLY\-LOG.txt", 'r') as infile: -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From python at mrabarnett.plus.com Sat Oct 17 19:31:08 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 18 Oct 2020 00:31:08 +0100 Subject: File Name issue In-Reply-To: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> Message-ID: <92ec59da-644b-a491-6e59-f956d1d7d61b@mrabarnett.plus.com> On 2020-10-17 23:12, Steve wrote: > The line: > with open("HOURLYLOG.txt", 'r') as infile: > works but, when I rename the file, the line: > with open("HOURLY-LOG.txt", 'r') as infile: > does not. The complaint is: Cannot Assign to operator > > However, I have: > BPM_O2s=open("BPM-O2-Readings.txt","a") > And it works. > > At first, I thought the issue was due to having the - in the filename. > > Is there a fix or explanation for this? > Steve > I see nothing wrong in those lines as written. Try reducing it to the smallest complete example that shows the problem. From mgogala at yahoo.com Sat Oct 17 19:58:12 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Sat, 17 Oct 2020 23:58:12 -0000 (UTC) Subject: File Name issue References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> Message-ID: On Sat, 17 Oct 2020 22:51:11 +0000, Mladen Gogala wrote: > On Sat, 17 Oct 2020 18:12:16 -0400, Steve wrote: > >> with open("HOURLYLOG.txt", 'r') as infile: >> works but, when I rename the file, the line: >> with open("HOURLY-LOG.txt", 'r') as infile: >> does not. The complaint is: Cannot Assign to operator > > Try this: > > with open("HOURLY\-LOG.txt", 'r') as infile: BTW, I used this cp /var/log/syslog ./in-file.log #!/usr/bin/env python3 import io with open("in-file.log","r") as infile: for line in infile: print(line) I got a different error: Traceback (most recent call last): File "./test.py", line 4, in for line in infile: File "/usr/lib/python3.8/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd8 in position 897: invalid continuation byte However, that doesn't have anything to do with your problem. -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From greg.ewing at canterbury.ac.nz Sat Oct 17 21:04:22 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 18 Oct 2020 14:04:22 +1300 Subject: Subprocess Connection Error In-Reply-To: References: <1075264989.313424.1602903843269.ref@mail.yahoo.com> <1075264989.313424.1602903843269@mail.yahoo.com> Message-ID: On 17/10/20 4:04 pm, Dave Dungan wrote: > One more thing, the book says to save it as "types.py". Which is probably a bad thing to do, because there is a built-in module called "types" that this will shadow. If IDLE happens to use that module, bad things could happen. Have you tried using a different name, such as "my_types.py"? -- Greg From greg.ewing at canterbury.ac.nz Sat Oct 17 21:04:22 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 18 Oct 2020 14:04:22 +1300 Subject: Subprocess Connection Error In-Reply-To: References: <1075264989.313424.1602903843269.ref@mail.yahoo.com> <1075264989.313424.1602903843269@mail.yahoo.com> Message-ID: On 17/10/20 4:04 pm, Dave Dungan wrote: > One more thing, the book says to save it as "types.py". Which is probably a bad thing to do, because there is a built-in module called "types" that this will shadow. If IDLE happens to use that module, bad things could happen. Have you tried using a different name, such as "my_types.py"? -- Greg From shrimp_banana at REMOVETHISprotonmail.com Sat Oct 17 21:47:21 2020 From: shrimp_banana at REMOVETHISprotonmail.com (shrimp_banana) Date: Sat, 17 Oct 2020 19:47:21 -0600 Subject: File Name issue In-Reply-To: References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> Message-ID: On 10/17/20 4:12 PM, Steve wrote: > The line: > with open("HOURLYLOG.txt", 'r') as infile: > works but, when I rename the file, the line: > with open("HOURLY-LOG.txt", 'r') as infile: > does not. The complaint is: Cannot Assign to operator > > However, I have: > BPM_O2s=open("BPM-O2-Readings.txt","a") > And it works. > > At first, I thought the issue was due to having the - in the filename. > > Is there a fix or explanation for this? > Steve I am unsure if this will help but you could try putting an r in front of the quotes to make it take raw data only. ie. with open(r"HOURLY-LOG.txt", 'r') as infile From tony.flury at btinternet.com Thu Oct 15 05:04:22 2020 From: tony.flury at btinternet.com (Tony Flury) Date: Thu, 15 Oct 2020 10:04:22 +0100 Subject: Embedding version in command-line program In-Reply-To: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <12938843-3341-fb9b-d371-66118db338c7@btinternet.com> On 07/10/2020 12:06, Loris Bennett wrote: > Hi, > > I have written a program, which I can run on the command-line thus > > mypyprog --version > > and the get the version, which is currently derived from a variable in > the main module file. > > However, I also have the version in an __init__.py file and in a > pyproject.toml (as I'm using poetry, otherwise this would be in > setup.py). > > What's the best way of reducing these three places where the version is > defined to a single one? > > Cheers, > > Loris My top level package always has a version.py file which defines __version__, __author__ etc. I am not sure if that helps in your .toml file though - is it executed or does it have the ability to read files when it creates the distributable ? From jsf80238 at gmail.com Sat Oct 17 23:23:40 2020 From: jsf80238 at gmail.com (Jason Friedman) Date: Sat, 17 Oct 2020 21:23:40 -0600 Subject: MERGE SQL in cx_Oracle executemany In-Reply-To: <82291952-57d4-4ef2-96f2-5b8a2fadb903n@googlegroups.com> References: <82291952-57d4-4ef2-96f2-5b8a2fadb903n@googlegroups.com> Message-ID: > > I'm looking to insert values into an oracle table (my_table) using the > query below. The insert query works when the PROJECT is not NULL/empty > (""). However when PROJECT is an empty string(''), the query creates a new > duplicate row every time the code is executed (with project value > populating as null). I would like to modify my query so a new row is not > inserted when all column values are matched (including when project code is > null). > I'm guessing I would need to include a "when matched" statement, but not > too sure on how to get this going. Would appreciate help with this, thanks. > > ``` > con = cx_Oracle.connect(connstr) > cur = con.cursor() > rows = [tuple(x) for x in df.values] > cur3.executemany('''merge into my_table > using dual > on (YEAR = :1 and QUARTER = :2 and CODE = :3 and AMOUNT = :4 and DATE = :5 > and COMMENTS = :6 and PROJECT = :7) > when not matched then insert values (:1, :2, :3, :4, :5, :6, :7) > ''',rows) > con.commit() > cur.close() > con.close() > Perhaps the issue is that NULL is not equal to anything. Oracle provides the IS NULL function to determine if a value is NULL. Note also you define "cur" but executemany with "cur3". And is "rows = [tuple(x) for x in df.values]" what you want? Print it. From mgogala at yahoo.com Sun Oct 18 02:35:03 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Sun, 18 Oct 2020 06:35:03 -0000 (UTC) Subject: MERGE SQL in cx_Oracle executemany References: <82291952-57d4-4ef2-96f2-5b8a2fadb903n@googlegroups.com> Message-ID: On Sat, 17 Oct 2020 21:23:40 -0600, Jason Friedman wrote: >> I'm looking to insert values into an oracle table (my_table) using the >> query below. The insert query works when the PROJECT is not NULL/empty >> (""). However when PROJECT is an empty string(''), the query creates a >> new duplicate row every time the code is executed (with project value >> populating as null). I would like to modify my query so a new row is >> not inserted when all column values are matched (including when project >> code is null). >> I'm guessing I would need to include a "when matched" statement, but >> not too sure on how to get this going. Would appreciate help with this, >> thanks. >> >> ``` >> con = cx_Oracle.connect(connstr) >> cur = con.cursor() >> rows = [tuple(x) for x in df.values] >> cur3.executemany('''merge into my_table using dual on (YEAR = :1 and >> QUARTER = :2 and CODE = :3 and AMOUNT = :4 and DATE = :5 and COMMENTS = >> :6 and PROJECT = :7) >> when not matched then insert values (:1, :2, :3, :4, :5, :6, :7) >> ''',rows) >> con.commit() >> cur.close() >> con.close() >> >> > Perhaps the issue is that NULL is not equal to anything. Oracle provides > the IS NULL function to determine if a value is NULL. > > Note also you define "cur" but executemany with "cur3". > > And is "rows = [tuple(x) for x in df.values]" what you want? Print it. Obviously, the "PROJECT" column is causing the issue. NULL in Oracle database is never equal to anything. If :7 is NULL, your "not matched" condition is satisfied and your MERGE statement will insert a new and exciting row. That has nothing to do with Python. The only solution is "ALTER TABLE my_table modify(project not null)" or "ALTER TABLE my_table add constraint project_nn check(project is not null)" I If you already have NULL values in the PROJECT column than use "add constraint" with NOVALIDATE option. Other than that, allowing NULL values in key columns is a sign of bad design. Namely, Oracle cannot index NULL columns, so PROJECT IS NULL predicate cannot be resolved by an index. -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From PythonList at DancesWithMice.info Sun Oct 18 04:00:18 2020 From: PythonList at DancesWithMice.info (dn) Date: Sun, 18 Oct 2020 21:00:18 +1300 Subject: File Name issue In-Reply-To: References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> Message-ID: On 18/10/2020 12:58, Mladen Gogala via Python-list wrote: > On Sat, 17 Oct 2020 22:51:11 +0000, Mladen Gogala wrote: >> On Sat, 17 Oct 2020 18:12:16 -0400, Steve wrote: >> >>> with open("HOURLYLOG.txt", 'r') as infile: >>> works but, when I rename the file, the line: >>> with open("HOURLY-LOG.txt", 'r') as infile: >>> does not. The complaint is: Cannot Assign to operator >>> with open( "HOURLY-LOG.txt", "r" ) as f: ... print( f.read() ) ... yes ^^^ the entire contents of a magnificent test-file NB: Python 3.8.5 (default, Aug 12 2020, 00:00:00) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)] on linux > BTW, I used this > cp /var/log/syslog ./in-file.log > #!/usr/bin/env python3 > import io > with open("in-file.log","r") as infile: > for line in infile: > print(line) > I got a different error: > Traceback (most recent call last): > File "./test.py", line 4, in > for line in infile: > File "/usr/lib/python3.8/codecs.py", line 322, in decode > (result, consumed) = self._buffer_decode(data, self.errors, final) > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd8 in position 897: > invalid continuation byte @Mladen: is syslog a text file or binary format? -- Regards =dn From Gronicus at SGA.Ninja Sun Oct 18 05:55:11 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sun, 18 Oct 2020 05:55:11 -0400 Subject: File Name issue In-Reply-To: <92ec59da-644b-a491-6e59-f956d1d7d61b@mrabarnett.plus.com> References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> <92ec59da-644b-a491-6e59-f956d1d7d61b@mrabarnett.plus.com> Message-ID: <016301d6a534$c5d9b530$518d1f90$@SGA.Ninja> I am not sure if what I did to repair it but the problem is gone. A copy/paste/rename was performed on the original code file and now I do not get the error. No need for "r" or "\"... WTH? I hate it when that happens. Steve Footnote: "What rhymes with orange?" "No it doesn't.." -----Original Message----- From: Python-list On Behalf Of MRAB Sent: Saturday, October 17, 2020 7:31 PM To: python-list at python.org Subject: Re: File Name issue On 2020-10-17 23:12, Steve wrote: > The line: > with open("HOURLYLOG.txt", 'r') as infile: > works but, when I rename the file, the line: > with open("HOURLY-LOG.txt", 'r') as infile: > does not. The complaint is: Cannot Assign to operator > > However, I have: > BPM_O2s=open("BPM-O2-Readings.txt","a") > And it works. > > At first, I thought the issue was due to having the - in the filename. > > Is there a fix or explanation for this? > Steve > I see nothing wrong in those lines as written. Try reducing it to the smallest complete example that shows the problem. -- https://mail.python.org/mailman/listinfo/python-list From darcy at VybeNetworks.com Sun Oct 18 07:31:21 2020 From: darcy at VybeNetworks.com (D'Arcy Cain) Date: Sun, 18 Oct 2020 07:31:21 -0400 Subject: File Name issue In-Reply-To: <016301d6a534$c5d9b530$518d1f90$@SGA.Ninja> References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> <92ec59da-644b-a491-6e59-f956d1d7d61b@mrabarnett.plus.com> <016301d6a534$c5d9b530$518d1f90$@SGA.Ninja> Message-ID: On 10/18/20 5:55 AM, Steve wrote: > I am not sure if what I did to repair it but the problem is gone. > A copy/paste/rename was performed on the original code file and now I do not > get the error. No need for "r" or "\"... > > WTH? I hate it when that happens. Could that original hyphen have been a unicode character? -- D'Arcy J.M. Cain Vybe Networks Inc. A unit of Excelsior Solutions Corporation - Propelling Business Forward http://www.VybeNetworks.com/ IM:darcy at VybeNetworks.com VoIP: sip:darcy at VybeNetworks.com -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 236 bytes Desc: OpenPGP digital signature URL: From shishaozhong at gmail.com Sun Oct 18 07:53:34 2020 From: shishaozhong at gmail.com (Shaozhong SHI) Date: Sun, 18 Oct 2020 12:53:34 +0100 Subject: Are there Python ways to execute queries on PostgreSQL without getting data over? Message-ID: Are there Python ways to execute queries on PostgreSQL without getting data over? Are there ways just to fire off PostgreSQL queries and not get data into Python? Regards, David From mats at python.org Sun Oct 18 08:37:49 2020 From: mats at python.org (Mats Wichmann) Date: Sun, 18 Oct 2020 06:37:49 -0600 Subject: Are there Python ways to execute queries on PostgreSQL without getting data over? In-Reply-To: References: Message-ID: <7f7e80bd-f627-608c-5e5f-cb984cf69007@python.org> On 10/18/20 5:53 AM, Shaozhong SHI wrote: > Are there Python ways to execute queries on PostgreSQL without getting data > over? > > Are there ways just to fire off PostgreSQL queries and not get data into > Python? > > Regards, > > David > When you "execute" the query, you don't get back the data, just a row count. You then have to use one of the "fetch" functions to actually retrieve it. Is that what you're asking? From hjp-python at hjp.at Sun Oct 18 09:48:13 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 18 Oct 2020 15:48:13 +0200 Subject: MERGE SQL in cx_Oracle executemany In-Reply-To: References: <82291952-57d4-4ef2-96f2-5b8a2fadb903n@googlegroups.com> Message-ID: <20201018134813.GA15694@hjp.at> On 2020-10-18 06:35:03 -0000, Mladen Gogala via Python-list wrote: > On Sat, 17 Oct 2020 21:23:40 -0600, Jason Friedman wrote: > >> I'm looking to insert values into an oracle table (my_table) using the > >> query below. The insert query works when the PROJECT is not NULL/empty > >> (""). However when PROJECT is an empty string(''), the query creates a > >> new duplicate row every time the code is executed (with project value > >> populating as null). I would like to modify my query so a new row is > >> not inserted when all column values are matched (including when project > >> code is null). [...] > > Perhaps the issue is that NULL is not equal to anything. Oracle provides > > the IS NULL function to determine if a value is NULL. > > > > Note also you define "cur" but executemany with "cur3". > > > > And is "rows = [tuple(x) for x in df.values]" what you want? Print it. > > Obviously, the "PROJECT" column is causing the issue. NULL in Oracle > database is never equal to anything. Not only in Oracle. This is standard SQL behaviour. NULL means "unknown", and if you compare two unknown values, the result is of course also unknown. However, Oracle adds an additional complication because it converts '' (the empty string) to NULL on insert. > If :7 is NULL, your "not matched" > condition is satisfied and your MERGE statement will insert a new and > exciting row. That has nothing to do with Python. The only solution is > "ALTER TABLE my_table modify(project not null)" or > "ALTER TABLE my_table add constraint project_nn check(project is not null)" I Yup. In addition, because that won't accept an empty string, you'll have to use some non-empty string (e.g. '-' or '(no project)') to signify that there is no project. (One might argue that this is better design anyway (explicit rather than implicit).) > If you already have NULL values in the PROJECT column than use "add constraint" > with NOVALIDATE option. Other than that, allowing NULL values in key columns is > a sign of bad design. Namely, Oracle cannot index NULL columns, so PROJECT IS NULL > predicate cannot be resolved by an index. It can with a bitmap index. However, last time I looked (admittedly long ago) this was an enterprise edition feature. 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 mal at europython.eu Sun Oct 18 09:54:57 2020 From: mal at europython.eu (M.-A. Lemburg) Date: Sun, 18 Oct 2020 15:54:57 +0200 Subject: EuroPython 2020: Edited videos are online Message-ID: We?re happy to announce that all edited videos of this year?s conference are now available on our YouTube channel: * EuroPython 2020 Playlist * https://www.youtube.com/watch?v=CvbQArKEFes&list=PL8uoeex94UhHgMD9GOCbEHWku7pEPx9fW We have 131 videos available in total, covering a very broad set of Python topics, so there?s going to be something interesting for everyone. We hope to see you all again next year and perhaps even have a few more people attending EuroPython 2021 Online, now that the format has proven successful. Stay safe. 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/632313693115416577/europython-2020-edited-videos-are-online Tweet: https://twitter.com/europython/status/1317793661061615616 Thanks, -- EuroPython 2020 Team https://ep2020.europython.eu/ https://www.europython-society.org/ From rosuav at gmail.com Sun Oct 18 09:59:20 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 19 Oct 2020 00:59:20 +1100 Subject: File Name issue In-Reply-To: References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> <92ec59da-644b-a491-6e59-f956d1d7d61b@mrabarnett.plus.com> <016301d6a534$c5d9b530$518d1f90$@SGA.Ninja> Message-ID: On Sun, Oct 18, 2020 at 10:32 PM D'Arcy Cain wrote: > > On 10/18/20 5:55 AM, Steve wrote: > > I am not sure if what I did to repair it but the problem is gone. > > A copy/paste/rename was performed on the original code file and now I do not > > get the error. No need for "r" or "\"... > > > > WTH? I hate it when that happens. > > Could that original hyphen have been a unicode character? > Or it wasn't in quotes. The original complaint from the interpreter was regarding an operator. This is why it's ALWAYS best to provide actual code, copied and pasted, and the corresponding output. ChrisA From hjp-python at hjp.at Sun Oct 18 10:13:16 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 18 Oct 2020 16:13:16 +0200 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> Message-ID: <20201018141316.GB15694@hjp.at> On 2020-10-17 21:03:26 -0000, Mladen Gogala via Python-list wrote: > On Thu, 15 Oct 2020 21:30:15 +0000, Stefan Ram wrote: > > Tony Flury writes: > >> >>> a = r'end' + chr(92) > > > > Or maybe, > > > > a = r''' > > end\ > > '''[ 1: -1 ] > > > > ? The first and the last line are messy, but in the middle, > > the intended string is clearly visible. > > > You can use perl module for python. Ah, I see, that the sillyness of Perl's grammar-altering modules (which let you write Perl in Latin (with proper declensions and conjugations, of course) or Chinese) has found its way to Python :-) > It is installable by pip. > Perl has no problems with handling backslashes. > > https://pypi.org/project/perl/ > > What you need is something like this: > > mgogala at umajor:~$ perl -e '$a="abcd";$a=~s/$/\\/; print "$a\n";' > abcd\ > > Python has a problem with backslashes: > > Python 3.8.5 (default, Jul 28 2020, 12:59:40) > [GCC 9.3.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import re > >>> a="abcd" > >>> b=re.sub('$',chr(28),a) > >>> b > 'abcd\x1c' > > >>> b=re.sub('$',chr(0x41),a) > >>> b > 'abcdA' > >>> b=re.sub('$','Z',a) > >>> b > 'abcdZ' > >>> b=re.sub('$',chr(0x1C),a) > >>> b > 'abcd\x1c' > >>> > > Any other character is shown as it should be, except backslash. 0x1C isn't a backslash, it's a control character (FS - File Separator). 0x5C is a backslash, but of course that doesn't work here either, because the second argument to re.sub isn't a simple string: It contains escape sequences to be interpreted, and a single \ isn't well-formed (note that you doubled the \ in your Perl example, too). b=re.sub('$', '\\\\', a) or b=re.sub('$', chr(0x5C)+chr(0x5C), a) works just fine, as does b = a + chr(0x5C) In all these cases, print(b) prints abcd\ (with a single backslash at the end) But simply typing "b" at the REPL produces 'abcd\\' because prints the __repr__() of an object. Note that it also prints single quotes, which are also not part of the string. 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 mgogala at yahoo.com Sun Oct 18 12:58:32 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Sun, 18 Oct 2020 16:58:32 -0000 (UTC) Subject: File Name issue References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> Message-ID: On Sun, 18 Oct 2020 21:00:18 +1300, dn wrote: > On 18/10/2020 12:58, Mladen Gogala via Python-list wrote: >> On Sat, 17 Oct 2020 22:51:11 +0000, Mladen Gogala wrote: >>> On Sat, 17 Oct 2020 18:12:16 -0400, Steve wrote: >>> >>>> with open("HOURLYLOG.txt", 'r') as infile: >>>> works but, when I rename the file, the line: >>>> with open("HOURLY-LOG.txt", 'r') as infile: >>>> does not. The complaint is: Cannot Assign to operator > > >>> with open( "HOURLY-LOG.txt", "r" ) as f: > ... print( f.read() ) > ... > yes > ^^^ the entire contents of a magnificent test-file > > NB: > Python 3.8.5 (default, Aug 12 2020, 00:00:00) > [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)] on linux > > >> BTW, I used this >> cp /var/log/syslog ./in-file.log >> #!/usr/bin/env python3 >> import io >> with open("in-file.log","r") as infile: >> for line in infile: >> print(line) >> I got a different error: >> Traceback (most recent call last): >> File "./test.py", line 4, in >> for line in infile: >> File "/usr/lib/python3.8/codecs.py", line 322, in decode >> (result, consumed) = self._buffer_decode(data, self.errors, final) >> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd8 in position 897: >> invalid continuation byte > > > @Mladen: is syslog a text file or binary format? Hi! Syslog is the system log. It's a text file. This only happens if I use infile as iterable. If I use readline, all is well: #!/usr/bin/env python3 import io with open("in-file.log","r") as infile: while True: line=infile.readline() if not line: break print(line) I don't particularly like this idiom, but it works. That is probably a bug in the utf-8 decoder on Ubuntu. It doesn't happen on my Fedora 32 VM. I haven't tried with infile.reconfigure(encoding=None) -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From mgogala at yahoo.com Sun Oct 18 13:07:13 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Sun, 18 Oct 2020 17:07:13 -0000 (UTC) Subject: Simple question - end a raw string with a single backslash ? References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <20201018141316.GB15694@hjp.at> Message-ID: On Sun, 18 Oct 2020 16:13:16 +0200, Peter J. Holzer wrote: > > Ah, I see, that the sillyness of Perl's grammar-altering modules (which > let you write Perl in Latin (with proper declensions and conjugations, > of course) or Chinese) has found its way to Python > To tell the truth, I only installed it to test whether it works. I am an old Perl hack forced to learn Python by the market forces. I learned Perl in 1994 which means that it is my first love of a sort. The fundamental difference between the two languages is that Perl is procedural while Python is a fully OO language. Discussion of Perl vs Python necessarily devolves into the discussion of procedural vs OO paradigms. And that has been decided long time ago, with the advent of Java over COBOL. Market has spoken and I had to learn Python. So, I stopped worrying and learned to love Python. Any resemblance to the subtitle of "Dr. Strangelove" is purely accidental. BTW, Visual Studio Code uses pylint to evaluate my adherence to PEP8 and there is a "kite" extension with autocompletion. Nothing like that was ever available for Perl. It certainly is easier to write Python scripts than to write Perl scripts. I do sort of miss $_, @_ and $!. Python's argparse is supreme and much better than Getopt::Long. -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From torriem at gmail.com Sun Oct 18 14:19:18 2020 From: torriem at gmail.com (Michael Torrie) Date: Sun, 18 Oct 2020 12:19:18 -0600 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <20201018141316.GB15694@hjp.at> Message-ID: <191966cf-53ec-ac56-fe87-bce91c2f9e93@gmail.com> On 10/18/20 11:07 AM, Mladen Gogala via Python-list wrote: > The fundamental > difference between the two languages is that Perl is procedural while > Python is a fully OO language. Discussion of Perl vs Python necessarily > devolves into the discussion of procedural vs OO paradigms. Python certainly is procedural. A script starts at the top and executes through to the bottom and ends, barring any flow control in the middle. Like Perl you can use it in many different ways and paradigms including OO if you desire. From PythonList at DancesWithMice.info Sun Oct 18 14:48:00 2020 From: PythonList at DancesWithMice.info (dn) Date: Mon, 19 Oct 2020 07:48:00 +1300 Subject: File Name issue In-Reply-To: References: <010a01d6a4d2$930739a0$b915ace0$@SGA.Ninja> Message-ID: <15d24043-e880-de50-2d16-c50f5011e4bc@DancesWithMice.info> On 19/10/2020 05:58, Mladen Gogala via Python-list wrote: > On Sun, 18 Oct 2020 21:00:18 +1300, dn wrote: >> On 18/10/2020 12:58, Mladen Gogala via Python-list wrote: >>> On Sat, 17 Oct 2020 22:51:11 +0000, Mladen Gogala wrote: >>> BTW, I used this >>> cp /var/log/syslog ./in-file.log >>> #!/usr/bin/env python3 >>> import io >>> with open("in-file.log","r") as infile: >>> for line in infile: >>> print(line) >>> I got a different error: >>> Traceback (most recent call last): >>> File "./test.py", line 4, in >>> for line in infile: >>> File "/usr/lib/python3.8/codecs.py", line 322, in decode >>> (result, consumed) = self._buffer_decode(data, self.errors, final) >>> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd8 in position > 897: >>> invalid continuation byte >> >> >> @Mladen: is syslog a text file or binary format? > > Hi! > Syslog is the system log. It's a text file. This only happens if I use > infile as iterable. If I use readline, all is well: > > #!/usr/bin/env python3 > import io > with open("in-file.log","r") as infile: > while True: > line=infile.readline() > if not line: > break > print(line) > > I don't particularly like this idiom, but it works. That is probably a bug > in the utf-8 decoder on Ubuntu. It doesn't happen on my Fedora 32 VM. I > haven't tried with infile.reconfigure(encoding=None) [Slightly OT from OP] Some logging has started to move from simple-text to a more compressed?efficient 'binary' - hence my thinking. Your observation, doubly-interesting. Fedora uses UTF-8 by default. I would have expected the same of Ubuntu. One wonders if different decoder/encoder defaults are set by the repo-managers, or some-such explanation. Using Fedora 32, (as before), and a copy of "/var/log/messages" because it doesn't use "syslog", it works happily: >>> with open( "messages", "r" ) as infile: ... for line in infile: ... print(line) ... break ... Oct 18 00:01:01 JrBrown systemd[1]: Starting update of the root trust anchor for DNSSEC validation in unbound... However, the decisive-point is the actual data. Have you worked-out which line in the log causes the error - and thus the offending string of characters? -- Regards =dn From shishaozhong at gmail.com Sun Oct 18 16:09:41 2020 From: shishaozhong at gmail.com (Shaozhong SHI) Date: Sun, 18 Oct 2020 21:09:41 +0100 Subject: How to expand and flatten a nested of list of dictionaries of varied lengths? Message-ID: Even worse is that, in some cases, an addition called serviceRatings as a key occur with new data unexpectedly. How to produce a robust Python/Panda script to coping with all these? Regards, David u'historicRatings': [{u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Requires improvement'}, {u'name': u'Well-led', u'rating': u'Requires improvement'}], u'rating': u'Requires improvement'}, u'reportDate': u'2019-10-04', u'reportLinkId': u'63ff05ec-4d31-406e-83de-49a271cfdc43'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Good'}, {u'name': u'Well-led', u'rating': u'Good'}, {u'name': u'Caring', u'rating': u'Good'}, {u'name': u'Responsive', u'rating': u'Good'}, {u'name': u'Effective', u'rating': u'Requires improvement'}], u'rating': u'Good'}, u'reportDate': u'2017-09-08', u'reportLinkId': u'4f20da40-89a4-4c45-a7f9-bfd52b48f286'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Requires improvement'}, {u'name': u'Well-led', u'rating': u'Requires improvement'}, {u'name': u'Caring', u'rating': u'Requires improvement'}, {u'name': u'Responsive', u'rating': u'Requires improvement'}, {u'name': u'Effective', u'rating': u'Good'}], u'rating': u'Requires improvement'}, u'reportDate': u'2016-06-11', u'reportLinkId': u'0cc4226b-401e-4f0f-ba35-062cbadffa8f'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Good'}, {u'name': u'Well-led', u'rating': u'Good'}, {u'name': u'Caring', u'rating': u'Good'}, {u'name': u'Responsive', u'rating': u'Requires improvement'}, {u'name': u'Effective', u'rating': u'Good'}], u'rating': u'Good'}, u'reportDate': u'2015-01-12', u'reportLinkId': u'a11c1e52-ddfd-4cd8-8b56-1b96ac287c96'}] From PythonList at DancesWithMice.info Sun Oct 18 16:44:45 2020 From: PythonList at DancesWithMice.info (dn) Date: Mon, 19 Oct 2020 09:44:45 +1300 Subject: How to expand and flatten a nested of list of dictionaries of varied lengths? In-Reply-To: References: Message-ID: On 19/10/2020 09:09, Shaozhong SHI wrote: > Even worse is that, in some cases, an addition called serviceRatings as a > key occur with new data unexpectedly. "Even worse" than what? Do you need to keep a list of acceptable/applicable/available keys? (and reject or deal with others in some alternate fashion) > How to produce a robust Python/Panda script to coping with all these? > u'historicRatings': [{u'overall': {u'keyQuestionRatings': [{u'name': > u'Safe', u'rating': u'Requires improvement'}, {u'name': u'Well-led', > u'rating': u'Requires improvement'}], u'rating': u'Requires improvement'}, > u'reportDate': u'2019-10-04', u'reportLinkId': > u'63ff05ec-4d31-406e-83de-49a271cfdc43'}, {u'overall': > {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Good'}, {u'name': > u'Well-led', u'rating': u'Good'}, {u'name': u'Caring', u'rating': u'Good'}, > {u'name': u'Responsive', u'rating': u'Good'}, {u'name': u'Effective', > u'rating': u'Requires improvement'}], u'rating': u'Good'}, u'reportDate': > u'2017-09-08', u'reportLinkId': u'4f20da40-89a4-4c45-a7f9-bfd52b48f286'}, > {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': > u'Requires improvement'}, {u'name': u'Well-led', u'rating': u'Requires > improvement'}, {u'name': u'Caring', u'rating': u'Requires improvement'}, > {u'name': u'Responsive', u'rating': u'Requires improvement'}, {u'name': > u'Effective', u'rating': u'Good'}], u'rating': u'Requires improvement'}, > u'reportDate': u'2016-06-11', u'reportLinkId': > u'0cc4226b-401e-4f0f-ba35-062cbadffa8f'}, {u'overall': > {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Good'}, {u'name': > u'Well-led', u'rating': u'Good'}, {u'name': u'Caring', u'rating': u'Good'}, > {u'name': u'Responsive', u'rating': u'Requires improvement'}, {u'name': > u'Effective', u'rating': u'Good'}], u'rating': u'Good'}, u'reportDate': > u'2015-01-12', u'reportLinkId': u'a11c1e52-ddfd-4cd8-8b56-1b96ac287c96'}] You may find it helpful to use the pprint ("pretty printing" library to print data-structures in a more readable/structured format). To "flatten" a dictionary, you must first be sure that there will be no keys that will clash (else the second entry will completely replace the first, without trace). Thus, we will need to understand more about this particular definition of "flatten" in relation to the range of incoming data. Perhaps explain them in English first... -- Regards =dn From mats at wichmann.us Sun Oct 18 17:12:21 2020 From: mats at wichmann.us (Mats Wichmann) Date: Sun, 18 Oct 2020 15:12:21 -0600 Subject: How to expand and flatten a nested of list of dictionaries of varied lengths? In-Reply-To: References: Message-ID: <6ccec42f-ccdd-8314-f129-8c929392fce5@wichmann.us> On 10/18/20 2:09 PM, Shaozhong SHI wrote: > Even worse is that, in some cases, an addition called serviceRatings as a > key occur with new data unexpectedly. > > How to produce a robust Python/Panda script to coping with all these? > > Regards, > > David > > u'historicRatings': [{u'overall': {u'keyQuestionRatings': [{u'name': > u'Safe', u'rating': u'Requires improvement'}, {u'name': u'Well-led', > u'rating': u'Requires improvement'}], u'rating': u'Requires improvement'}, truncating this to avoid a huge paste... can you give an example of what it would look like "flattened"? list flattening is pretty straightforward, and even has a standard library method, itertools.chain, to help out. to flatten a dict though, you have to deal with what would happen if the keys aren't unique. if you look at the above, for example, there are two places where there's a key 'rating' though they're at different levels in the data structure, so you have to be clear on what should happen here. From mgogala at yahoo.com Sun Oct 18 19:37:25 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Sun, 18 Oct 2020 23:37:25 -0000 (UTC) Subject: Simple question - end a raw string with a single backslash ? References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <20201018141316.GB15694@hjp.at> <191966cf-53ec-ac56-fe87-bce91c2f9e93@gmail.com> Message-ID: On Sun, 18 Oct 2020 12:19:18 -0600, Michael Torrie wrote: > Python certainly is procedural. A script starts at the top and executes > through to the bottom and ends, barring any flow control in the middle. > Like Perl you can use it in many different ways and paradigms including > OO if you desire. That's not the point. In Python, regular expressions are a class. So are strings and lists. In Perl, there are no classes. Procedural paradigm means that you are modelling the real world with the objects provided by the computer environment: strings, numbers, lists or hashes (known as "dictionaries" in Python). OO paradigm allows you to create objects and make them behave like in the real world. In other words, in OO paradighm, data and functions are related. The basic idea of the OO was to make code sharing much easier. However, things do not always work as they should: https://medium.com/better-programming/object-oriented-programming-the-trillion-dollar-disaster-92a4b666c7c7 https://towardsdatascience.com/object-oriented-programming-is-dead-wait-really-db1f1f05cc44 Of course, not everybody agrees. People never do: https://techbeacon.com/app-dev-testing/object-oriented-programming-dead-not-long-shot Sometimes, OO has its funny side: https://www.wearethemighty.com/articles/that-time-the-australian-air-force-squared-off-against-missile-shooting-kangaroos -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From PythonList at danceswithmice.info Sun Oct 18 19:51:36 2020 From: PythonList at danceswithmice.info (dn) Date: Mon, 19 Oct 2020 12:51:36 +1300 Subject: How to expand and flatten a nested of list of dictionaries of varied lengths? In-Reply-To: References: Message-ID: <701b8b25-b463-99bf-550d-8caeb591439d@DancesWithMice.info> If I may, a couple of items of list-etiquette (polite behavior), as I understand them: 1 please reply to the list (cf only myself) because @Mats (who responded earlier) and others on this list are much smarter than me, and might be able to help you more quickly 2 top-posting seems to take the form 'answer, then question' which is illogical to everyone, except apparently Microsoft. It is better to have the conversation 'develop' as it proceeds - all the early information at the beginning, and the more detailed towards the 'end'. That is not to say that we can't "snip" or 'do some gardening', to remove unnecessary or erroneous material, as the conversation progresses. You will notice (as below) that this also enables a posting with multiple questions, to be discussed point-by-point. Now to work... > On Sun, 18 Oct 2020 at 21:48, dn via Python-list > wrote: > > On 19/10/2020 09:09, Shaozhong SHI wrote: > > Even worse is that, in some cases, an addition called > serviceRatings as a > > key occur with new data unexpectedly. > > "Even worse" than what? > > Do you need to keep a list of acceptable/applicable/available keys? > (and reject or deal with others in some alternate fashion) > > > > How to produce a robust Python/Panda script to coping with all these? ... [I often use ellipsis to indicate that I have snipped 'stuff in the middle', others are more overt and will write "" or similar] > You may find it helpful to use the pprint ("pretty printing" library to > print data-structures in a more readable/structured format). > > To "flatten" a dictionary, you must first be sure that there will be no > keys that will clash (else the second entry will completely replace the > first, without trace). > > Thus, we will need to understand more about this particular definition > of "flatten" in relation to the range of incoming data. Perhaps explain > them in English first... On 19/10/2020 12:14, Shaozhong SHI wrote: > Hi, DN, > > This is the result of pprint. [{u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Requires improvement'}, {u'name': u'Well-led', u'rating': u'Requires improvement'}], u'rating': u'Requires improvement'}, u'reportDate': u'2019-10-04', u'reportLinkId': u'63ff05ec-4d31-406e-83de-49a271cfdc43'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Good'}, {u'name': u'Well-led', u'rating': u'Good'}, {u'name': u'Caring', u'rating': u'Good'}, {u'name': u'Responsive', u'rating': u'Good'}, {u'name': u'Effective', u'rating': u'Requires improvement'}], u'rating': u'Good'}, u'reportDate': u'2017-09-08', u'reportLinkId': u'4f20da40-89a4-4c45-a7f9-bfd52b48f286'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Requires improvement'}, {u'name': u'Well-led', u'rating': u'Requires improvement'}, {u'name': u'Caring', u'rating': u'Requires improvement'}, {u'name': u'Responsive', u'rating': u'Requires improvement'}, {u'name': u'Effective', u'rating': u'Good'}], u'rating': u'Requires improvement'}, u'reportDate': u'2016-06-11', u'reportLinkId': u'0cc4226b-401e-4f0f-ba35-062cbadffa8f'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Good'}, {u'name': u'Well-led', u'rating': u'Good'}, {u'name': u'Caring', u'rating': u'Good'}, {u'name': u'Responsive', u'rating': u'Requires improvement'}, {u'name': u'Effective', u'rating': u'Good'}], u'rating': u'Good'}, u'reportDate': u'2015-01-12', u'reportLinkId': u'a11c1e52-ddfd-4cd8-8b56-1b96ac287c96'}] Well done! This looks so much better, and more to the point, it is easier for 'us' to see the structure - but oh dear, doesn't email wrapping make our lives difficult! > Normally, it is like this. > But sometimes, serviceRatings is added to the key list - [u'overall', > u'reportDate', u'reportLinkId'] > > That is what I meant about dynamically growing tree. OK, (and only you/your user can answer this question) why do all the examples (above) not have a service-rating? I am wondering if the use of the word "unexpectedly" has translated accurately between languages - if a data-item is part of the data-input, then our code must be able to handle it or "clean" it, as specified (by the user). - are you able to add a service-rating to each "overall" entry? - where service-ratings are not currently-available, would it be acceptable to add the field with a value of None? (or some other "sentinel-value" - if the analysis-phase does not consider service-ratings, can we write code to read the field from the data-source, but discard it whilst loading everything else into a Pandas matrix? > How best to handle this? This requires understanding how the service-rating value will be used in the analysis, and thus how relevant records may be selected/ignored. Just because it features in the data, doesn't mean it needs to be included in the analysis! Have I understood the question? -- Regards =dn From torriem at gmail.com Sun Oct 18 21:20:53 2020 From: torriem at gmail.com (Michael Torrie) Date: Sun, 18 Oct 2020 19:20:53 -0600 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <20201018141316.GB15694@hjp.at> <191966cf-53ec-ac56-fe87-bce91c2f9e93@gmail.com> Message-ID: On 10/18/20 5:37 PM, Mladen Gogala via Python-list wrote: > On Sun, 18 Oct 2020 12:19:18 -0600, Michael Torrie wrote: > >> Python certainly is procedural. A script starts at the top and executes >> through to the bottom and ends, barring any flow control in the middle. >> Like Perl you can use it in many different ways and paradigms including >> OO if you desire. > > That's not the point. But it is. Yes I can see why this devolves so quickly for you! :) From mkarkera98 at gmail.com Mon Oct 19 01:23:39 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Mon, 19 Oct 2020 10:53:39 +0530 Subject: Covariance matrix syntax In-Reply-To: References: <291564577.630412.1602564274535@mail.yahoo.com> Message-ID: Dear Sir I am unable to find the *formula for covariance* used in np.cov syntax in PYTHON given in link https://numpy.org/doc/stable/reference/generated/numpy.cov.html. Could you please help me out. Thanks Meghna On Tue, Oct 13, 2020 at 11:46 AM Christian Gollwitzer wrote: > Am 13.10.20 um 06:52 schrieb Meghna Karkera: > > Could you let me know what is the back end calculation of this covariance > > matrix syntax np.cov > > > > You can look it up yourself: Go to the docs > https://numpy.org/doc/stable/reference/generated/numpy.cov.html > > At the right hand side, just right of the function signature, there is a > link [source]. Click there and it takes you to the implementation. > > Apparently it is done in straightforward Python. > > Christian > > PS: Snipped a lot of unrelated citation at the bottom > > > On Tue, Oct 13, 2020, 10:14 Bruno P. Kinoshita < > brunodepaulak at yahoo.com.br> > > wrote: > > [...] > >> I think the np.cov is from the numpy module (imported/aliased as np?). > -- > https://mail.python.org/mailman/listinfo/python-list > From auriocus at gmx.de Mon Oct 19 01:48:27 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Mon, 19 Oct 2020 07:48:27 +0200 Subject: Covariance matrix syntax In-Reply-To: References: <291564577.630412.1602564274535@mail.yahoo.com> Message-ID: Am 19.10.20 um 07:23 schrieb Meghna Karkera: > I am unable to find the *formula for covariance* used in np.cov syntax in > PYTHON given in link > https://numpy.org/doc/stable/reference/generated/numpy.cov.html. Could you > please help me out. As said, you should click on the link [source] just at the right hand side of the page, at the top. There is numpy.cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=None) and just next to it there is the link. It takes you there: https://github.com/numpy/numpy/blob/v1.19.0/numpy/lib/function_base.py#L2270-L2481 Which is the source code of the function. Best regards, Christian > Thanks > Meghna > > On Tue, Oct 13, 2020 at 11:46 AM Christian Gollwitzer > wrote: > >> Am 13.10.20 um 06:52 schrieb Meghna Karkera: >>> Could you let me know what is the back end calculation of this covariance >>> matrix syntax np.cov >>> >> >> You can look it up yourself: Go to the docs >> https://numpy.org/doc/stable/reference/generated/numpy.cov.html >> >> At the right hand side, just right of the function signature, there is a >> link [source]. Click there and it takes you to the implementation. >> >> Apparently it is done in straightforward Python. >> >> Christian >> >> PS: Snipped a lot of unrelated citation at the bottom >> >>> On Tue, Oct 13, 2020, 10:14 Bruno P. Kinoshita < >> brunodepaulak at yahoo.com.br> >>> wrote: >>> [...] >>>> I think the np.cov is from the numpy module (imported/aliased as np?). >> -- >> https://mail.python.org/mailman/listinfo/python-list >> From mgogala at yahoo.com Mon Oct 19 02:24:18 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Mon, 19 Oct 2020 06:24:18 -0000 (UTC) Subject: Simple question - end a raw string with a single backslash ? References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <20201018141316.GB15694@hjp.at> <191966cf-53ec-ac56-fe87-bce91c2f9e93@gmail.com> Message-ID: On Mon, 19 Oct 2020 02:44:25 +0000, Stefan Ram wrote: > Mladen Gogala writes: >>In Perl, there are no classes. > > If there are no classes in Perl, then what does > > bless REF,CLASSNAME > > do? bless \$ref will make the given reference a reference to the class. And classes is Perl are called "modules". However, Perl classes are not the classes in the real sense. There is no inheritance. You can have a similar thing in C: it's called "struct", it can do similar things like Perl modules. But C isn't object oriented. Inheritance is an essential characteristic of object orientation. There were attempts to turn Perl into OO language with Moose (https://metacpan.org/pod/Moose) However, Moose is complex, tedious and rarely used. Perl6 is an OO language, but nobody uses it. The problem is CPAN and all the Perl5 modules which are not compatible with Perl6 or "Roku" as it is known. -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From rosuav at gmail.com Mon Oct 19 02:52:38 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 19 Oct 2020 17:52:38 +1100 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <20201018141316.GB15694@hjp.at> <191966cf-53ec-ac56-fe87-bce91c2f9e93@gmail.com> Message-ID: On Mon, Oct 19, 2020 at 5:26 PM Mladen Gogala via Python-list wrote: > bless \$ref will make the given reference a reference to the class. And classes is Perl > are called "modules". However, Perl classes are not the classes in the real sense. There > is no inheritance. You can have a similar thing in C: it's called "struct", it can do > similar things like Perl modules. But C isn't object oriented. Inheritance is an > essential characteristic of object orientation. Funny thing about how languages "are" or "are not" object oriented.... back in the day, I used to do SOM programming on OS/2, which was entirely in C, and most definitely had all the features you'd expect of object orientation. Inheritance, the ability to override your parent's methods, the ability to call the parent's method during the implementation of your own, etc, etc, etc. It was all done through DLLs, so you could subclass someone else's class (a very common thing was to subclass one of the standard classes and add a small amount of functionality to it) without having the source code. So, yeah, I don't think there's any fundamental in any language that says whether or not you can do OOP. There are features which make OOP easier, and some languages have more of them than others do. That's about all you can really say. ChrisA From antoon.pardon at vub.be Mon Oct 19 04:25:20 2020 From: antoon.pardon at vub.be (Antoon Pardon) Date: Mon, 19 Oct 2020 10:25:20 +0200 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> Message-ID: <85b202ae-0f02-67a2-acc6-5283d7624121@vub.be> Op 13/10/20 om 15:14 schreef Serhiy Storchaka: > 13.10.20 11:52, Tony Flury via Python-list ????: >> I am trying to write a simple expression to build a raw string that ends >> in a single backslash. My understanding is that a raw string should >> ignore attempts at escaping characters but I get this : >> >> ??? >>> a = r'end\' >> ??? ? File "", line 1 >> ??? ??? a = r'end\' >> ??? ????????????? ^ >> ?? SyntaxError: EOL while scanning string literal >> >> I interpret this as meaning that the \' is actually being interpreted as >> a literal quote - is that a bug ? > > r'You can\'t end raw string literal with a single "\"' > > If backslash be true inner in a raw string, the above literal would end > after \'. It would be very hard to write a raw string containing both \' > and \", and even \''' and \""" (there are such strings in the stdlib). > > So you have problem either with trailing backslash, or with inner > backslash followed by quotes. Both problems cannot be solved at the same > time. Python parser works as it works because initially it was easier to > implement, and now this cannot be changed because it would break some > amount of correct code. IMO the way python does this is broken. >>> st=r'You can\'t end raw string literal with a single "\"' >>> print(st) Now either the \ is special or it is not. 1) If it is special, it should change how the ' is treated but not appear itself. 2) If it is not special, it should just appear and not change how the ' is treated. What python does here is a combination of both. The \ appears and it changes how the ' is treated. That is IMO broken. -- Antoon Pardon. From stephen_tucker at sil.org Mon Oct 19 05:07:31 2020 From: stephen_tucker at sil.org (Stephen Tucker) Date: Mon, 19 Oct 2020 10:07:31 +0100 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: <85b202ae-0f02-67a2-acc6-5283d7624121@vub.be> References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <85b202ae-0f02-67a2-acc6-5283d7624121@vub.be> Message-ID: For a neatish way to get a string to end with a single backslash, how about mystr = r"abc\ "[:-1] (Note the space at the end of the rough-quoted string.) Virus-free. www.avast.com <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> On Mon, Oct 19, 2020 at 9:26 AM Antoon Pardon wrote: > > > Op 13/10/20 om 15:14 schreef Serhiy Storchaka: > > 13.10.20 11:52, Tony Flury via Python-list ????: > >> I am trying to write a simple expression to build a raw string that ends > >> in a single backslash. My understanding is that a raw string should > >> ignore attempts at escaping characters but I get this : > >> > >> >>> a = r'end\' > >> File "", line 1 > >> a = r'end\' > >> ^ > >> SyntaxError: EOL while scanning string literal > >> > >> I interpret this as meaning that the \' is actually being interpreted as > >> a literal quote - is that a bug ? > > > > r'You can\'t end raw string literal with a single "\"' > > > > If backslash be true inner in a raw string, the above literal would end > > after \'. It would be very hard to write a raw string containing both \' > > and \", and even \''' and \""" (there are such strings in the stdlib). > > > > So you have problem either with trailing backslash, or with inner > > backslash followed by quotes. Both problems cannot be solved at the same > > time. Python parser works as it works because initially it was easier to > > implement, and now this cannot be changed because it would break some > > amount of correct code. > > IMO the way python does this is broken. > > >>> st=r'You can\'t end raw string literal with a single "\"' > >>> print(st) > > Now either the \ is special or it is not. > > 1) If it is special, it should change how the ' is treated but not > appear itself. > > 2) If it is not special, it should just appear and not change how the ' > is treated. > > What python does here is a combination of both. The \ appears and it > changes how the ' is treated. That is IMO broken. > > -- > Antoon Pardon. > -- > https://mail.python.org/mailman/listinfo/python-list > From loris.bennett at fu-berlin.de Mon Oct 19 05:29:43 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Mon, 19 Oct 2020 11:29:43 +0200 Subject: Embedding version in command-line program References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> <12938843-3341-fb9b-d371-66118db338c7@btinternet.com> Message-ID: <875z76y35k.fsf@hornfels.zedat.fu-berlin.de> Tony Flury writes: > On 07/10/2020 12:06, Loris Bennett wrote: >> Hi, >> >> I have written a program, which I can run on the command-line thus >> >> mypyprog --version >> >> and the get the version, which is currently derived from a variable in >> the main module file. >> >> However, I also have the version in an __init__.py file and in a >> pyproject.toml (as I'm using poetry, otherwise this would be in >> setup.py). >> >> What's the best way of reducing these three places where the version is >> defined to a single one? >> >> Cheers, >> >> Loris > My top level package always has a version.py file which defines __version__, > __author__ etc. I am not sure if that helps in your .toml file though - is it > executed or does it have the ability to read files when it creates the > distributable ? The problem is that the .toml file is not by default part of the distribution, but AFAIU is intended to store the project metadata used to create the METADATA file in dist-info when the package is built. Thus, the version defined in the .toml file is not directly available to the module itself. It seems to me, as a python novice, that poetry's function 'version' needs to be extended. One possibility is that it should not only bump the version in the .toml file, but also bump the version in a version file like 'version.py' as well. Alternatively, the value of the key 'version' in the .toml file, if it is not the version itself, could be path to a file, such as a 'version.py', which holds the version. If that sounds reasonable, I could suggest it to the developers of poetry. Cheers, Loris -- This signature is currently under construction. From David.Raymond at tomtom.com Mon Oct 19 09:26:42 2020 From: David.Raymond at tomtom.com (David Raymond) Date: Mon, 19 Oct 2020 13:26:42 +0000 Subject: Are there Python ways to execute queries on PostgreSQL without getting data over? In-Reply-To: References: Message-ID: > Are there Python ways to execute queries on PostgreSQL without getting data over? > > Are there ways just to fire off PostgreSQL queries and not get data into Python? > > Regards, > > David What is your use case for this? Normally when you do basic things like an UPDATE/DELETE, etc all you get back is a row count of how many records the statement updated/deleted. Normally SELECT is the only thing to send a bunch of data back to you, and well, why would you run selects if you don't care about the output? Without knowing what you're doing it for, the only other option I could suggest might be to use EXPLAIN ANALYZE. That would still send back the EXPLAIN ANALYZE output. But it will actually run the query, and if the output would have been thousands/millions of rows, then the explain output is going to be a lot smaller. From markos at c2o.pro.br Mon Oct 19 11:34:49 2020 From: markos at c2o.pro.br (Markos) Date: Mon, 19 Oct 2020 12:34:49 -0300 Subject: Covariance matrix syntax In-Reply-To: References: <291564577.630412.1602564274535@mail.yahoo.com> Message-ID: <780fc283-d1e4-f7b6-3885-e0953b889c52@c2o.pro.br> Hi Meghna, I organized some tutorials about Machine Learning for Chemistry with Python. Where you can find some info about the use of Covariance Matrix that may help you. The originals are in Portugueese, but you can read using Google Translator: https://tinyurl.com/yybazx9n https://tinyurl.com/y29mule6 https://tinyurl.com/yxtg4tce Best Regards, Markos Em 19-10-2020 02:23, Meghna Karkera escreveu: > Dear Sir > > I am unable to find the *formula for covariance* used in np.cov syntax in > PYTHON given in link > https://numpy.org/doc/stable/reference/generated/numpy.cov.html. Could you > please help me out. > > Thanks > Meghna > > On Tue, Oct 13, 2020 at 11:46 AM Christian Gollwitzer > wrote: > >> Am 13.10.20 um 06:52 schrieb Meghna Karkera: >>> Could you let me know what is the back end calculation of this covariance >>> matrix syntax np.cov >>> >> You can look it up yourself: Go to the docs >> https://numpy.org/doc/stable/reference/generated/numpy.cov.html >> >> At the right hand side, just right of the function signature, there is a >> link [source]. Click there and it takes you to the implementation. >> >> Apparently it is done in straightforward Python. >> >> Christian >> >> PS: Snipped a lot of unrelated citation at the bottom >> >>> On Tue, Oct 13, 2020, 10:14 Bruno P. Kinoshita < >> brunodepaulak at yahoo.com.br> >>> wrote: >>> [...] >>>> I think the np.cov is from the numpy module (imported/aliased as np?). >> -- >> https://mail.python.org/mailman/listinfo/python-list >> From grant.b.edwards at gmail.com Mon Oct 19 10:04:55 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 19 Oct 2020 14:04:55 -0000 (UTC) Subject: Simple question - end a raw string with a single backslash ? References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <85b202ae-0f02-67a2-acc6-5283d7624121@vub.be> Message-ID: On 2020-10-19, Stephen Tucker wrote: > For a neatish way to get a string to end with a single backslash, how about > mystr = r"abc\ "[:-1] > (Note the space at the end of the rough-quoted string.) That's the first thing I thought of, though I would probably use a non-space character to avoid convusion when reading: mystr = r'abc\_'[:-1] -- Grant From azhar5266 at gmail.com Mon Oct 19 11:12:24 2020 From: azhar5266 at gmail.com (Azhar Ansari) Date: Mon, 19 Oct 2020 20:42:24 +0530 Subject: Help with the best practice to learn python Message-ID: Hello Python Community, Kindly help me with the best practice to learn python. Lots of material over net but its very confusing. Thanks and Regards, Azhar Ansari From Marco.Sulla.Python at gmail.com Mon Oct 19 13:47:26 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Mon, 19 Oct 2020 19:47:26 +0200 Subject: Help with the best practice to learn python In-Reply-To: References: Message-ID: The first time I started python I simply followed the official tutorial: https://docs.python.org/3.9/tutorial/introduction.html PS: Note that this is for Python 3.9. You can change the version in the page if you have another one. From eryksun at gmail.com Mon Oct 19 14:21:40 2020 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 19 Oct 2020 13:21:40 -0500 Subject: Simple question - end a raw string with a single backslash ? In-Reply-To: References: <7898eaff-9550-78a1-cb4c-73ded163a8b3@btinternet.com> <85b202ae-0f02-67a2-acc6-5283d7624121@vub.be> Message-ID: On 10/19/20, Grant Edwards wrote: > On 2020-10-19, Stephen Tucker wrote: > >> For a neatish way to get a string to end with a single backslash, how >> about >> mystr = r"abc\ "[:-1] >> (Note the space at the end of the rough-quoted string.) > > That's the first thing I thought of, though I would probably use a > non-space character to avoid convusion when reading: > > mystr = r'abc\_'[:-1] But it doesn't actually "end a raw string with a single backslash". The compiler could be optimized for slicing string literals, but it's not. For example: >>> dis.dis(r"r'spam\eggs\_'[:-1]") 1 0 LOAD_CONST 0 ('spam\\eggs\\_') 2 LOAD_CONST 1 (None) 4 LOAD_CONST 2 (-1) 6 BUILD_SLICE 2 8 BINARY_SUBSCR 10 RETURN_VALUE For comparison: >>> dis.dis(r"r'spam\eggs' '\\'") 1 0 LOAD_CONST 0 ('spam\\eggs\\') 2 RETURN_VALUE From PythonList at DancesWithMice.info Mon Oct 19 15:28:50 2020 From: PythonList at DancesWithMice.info (dn) Date: Tue, 20 Oct 2020 08:28:50 +1300 Subject: Help with the best practice to learn python In-Reply-To: References: Message-ID: <3125967e-6839-6e48-7406-e6eba58911c1@DancesWithMice.info> On 20/10/2020 04:12, Azhar Ansari wrote: > Hello Python Community, > Kindly help me with the best practice to learn python. > Lots of material over net but its very confusing. You are so right - it is very confusing! Different people have different preferences for 'the best way to learn'. Also, we probably have widely-different reasons for wanting to learn Python, and/or what we plan to do with such skills 'afterwards'*. Some people are keen on the (apparent) brevity of a 'code camp' approach - rapid learning under pressure, with a view to quickly acquiring the skills which will (supposedly) justify a job application. It is necessary though, to understand the difference between "job" and "career". At the other end of the scale, one can study at a university for three/four years. Some take the simplistic approach of visiting YouTube's web-site and 'clicking on' anything that looks-likely. I recommend a more structured approach that will 'cover the ground' in a logical learning-path, and with consistency. As well as the Python Tutorial (mentioned elsewhere), @Alan over on the Python-Tutor discussion list*, also maintains something similar. A good book or two will provide structure and coverage - again though, many texts aim in a particular direction, eg Data Science, which may/not suit your own interests/objectives. I recommend on-line courses using reputable platforms such as Coursera and edX*, which can be attempted for $free, or to gain certification, paid. These are offered by various educational institutions and include discussion lists to enable trainees to 'compare notes' and discuss questions that will assist understanding (which a text book cannot do). * - most professionals understand that "continuing education" or 'continual learning' is a feature of this business - there's no such thing as 'leaving school' knowing it all! - the 'Tutor' list is an helpful environment for learners to ask questions which might seem 'simple' to professionals and skilled-practitioners: https://mail.python.org/mailman/listinfo/tutor - I use the edX platform (for non-Python training) -- Regards =dn From Marco.Sulla.Python at gmail.com Mon Oct 19 18:28:08 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Tue, 20 Oct 2020 00:28:08 +0200 Subject: Pickle in C does not work Message-ID: I tried this code: static PyObject * frozendict_reduce(PyFrozenDictObject* mp, PyObject *Py_UNUSED(ignored)) { PyObject* args = PyTuple_New(1); if (args == NULL) { return NULL; } PyTuple_SET_ITEM(args, 0, (PyObject *)mp); PyObject *d = PyObject_Call((PyObject *)&PyDict_Type, args, NULL); Py_INCREF(mp); return Py_BuildValue("O(N)", Py_TYPE(mp), d); } but I get: _pickle.PicklingError: Can't pickle : attribute lookup frozendict on builtins failed The identical (?) Python code works: def __reduce__(self, *args, **kwargs): return (self.__class__, (dict(self), )) From torriem at gmail.com Mon Oct 19 20:28:46 2020 From: torriem at gmail.com (Michael Torrie) Date: Mon, 19 Oct 2020 18:28:46 -0600 Subject: Help with the best practice to learn python In-Reply-To: References: Message-ID: On 10/19/20 9:12 AM, Azhar Ansari wrote: > Hello Python Community, > Kindly help me with the best practice to learn python. > Lots of material over net but its very confusing. What is your goal? Python is a tool. What do you want to do with it? If you don't have any particular thing in mind, it's much harder to learn any language. But of course if you don't have anything particular in mind, you could enroll in an on-line courses in Python programming. The lesson plan would at least provide you with exercises to do. From loris.bennett at fu-berlin.de Tue Oct 20 03:26:45 2020 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Tue, 20 Oct 2020 09:26:45 +0200 Subject: Embedding version in command-line program References: <87mu0yxplv.fsf@hornfels.zedat.fu-berlin.de> <12938843-3341-fb9b-d371-66118db338c7@btinternet.com> <875z76y35k.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <87h7qp4atm.fsf@hornfels.zedat.fu-berlin.de> "Loris Bennett" writes: > Tony Flury writes: > >> On 07/10/2020 12:06, Loris Bennett wrote: >>> Hi, >>> >>> I have written a program, which I can run on the command-line thus >>> >>> mypyprog --version >>> >>> and the get the version, which is currently derived from a variable in >>> the main module file. >>> >>> However, I also have the version in an __init__.py file and in a >>> pyproject.toml (as I'm using poetry, otherwise this would be in >>> setup.py). >>> >>> What's the best way of reducing these three places where the version is >>> defined to a single one? >>> >>> Cheers, >>> >>> Loris > >> My top level package always has a version.py file which defines __version__, >> __author__ etc. I am not sure if that helps in your .toml file though - is it >> executed or does it have the ability to read files when it creates the >> distributable ? > > The problem is that the .toml file is not by default part of the > distribution, but AFAIU is intended to store the project metadata used > to create the METADATA file in dist-info when the package is built. > Thus, the version defined in the .toml file is not directly available to > the module itself. > > It seems to me, as a python novice, that poetry's function 'version' > needs to be extended. One possibility is that it should not only bump > the version in the .toml file, but also bump the version in a version > file like 'version.py' as well. Alternatively, the value of the key > 'version' in the .toml file, if it is not the version itself, could be > path to a file, such as a 'version.py', which holds the version. > > If that sounds reasonable, I could suggest it to the developers of > poetry. This is a known issue with a solution using 'importlib.metadata' or 'importlib_metadata' described here: https://github.com/python-poetry/poetry/pull/2366#issuecomment-652418094 Cheers, Loris -- This signature is currently under construction. From agnese.camellini at gmail.com Tue Oct 20 06:05:40 2020 From: agnese.camellini at gmail.com (Agnese Camellini) Date: Tue, 20 Oct 2020 12:05:40 +0200 Subject: web conference on python Message-ID: Hello, i am not a staff member, but some connection on likeding asked me to share this link and i would be happy if it helps someone. https://python.geekle.us/? From storchaka at gmail.com Tue Oct 20 05:16:30 2020 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 20 Oct 2020 12:16:30 +0300 Subject: Pickle in C does not work In-Reply-To: References: Message-ID: 20.10.20 01:28, Marco Sulla ????: > PyObject *d = PyObject_Call((PyObject *)&PyDict_Type, args, NULL); You can use PyDict_New() + PyDict_Merge() to create a dict from your mapping. > but I get: > _pickle.PicklingError: Can't pickle : attribute lookup > frozendict on builtins failed tp_name of your class should include the module name. From Marco.Sulla.Python at gmail.com Tue Oct 20 10:12:24 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Tue, 20 Oct 2020 16:12:24 +0200 Subject: Pickle in C does not work In-Reply-To: References: Message-ID: On Tue, 20 Oct 2020 at 16:07, Serhiy Storchaka wrote: > You can use PyDict_New() + PyDict_Merge() to create a dict from your > mapping. > Well, yes, I know. I just wrote it for simplicity now. Do you think this is the problem? I forgot to say that copy and deepcopy works. For what I know, they use __reduce__ if it's present. > tp_name of your class should include the module name. > It will be done :-) From Marco.Sulla.Python at gmail.com Tue Oct 20 10:43:10 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Tue, 20 Oct 2020 16:43:10 +0200 Subject: Pickle in C does not work In-Reply-To: References: Message-ID: On Tue, 20 Oct 2020 at 16:12, Marco Sulla wrote: > tp_name of your class should include the module name. >> > > It will be done :-) > It was the name... Thank you a lot! From Marco.Sulla.Python at gmail.com Tue Oct 20 11:05:29 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Tue, 20 Oct 2020 17:05:29 +0200 Subject: Py_BuildValue vs PyTuple_Pack vs PyTuple_New Message-ID: I read these three C api functions, They are similar, because they all construct a tuple[1]. IMHO, Py_BuildValue is more simple to use than PyTuple_Pack that is more simple to use than PyTuple_New. Where to use one or the other? What's the relative performance of the three functions? [1] actually, Py_BuildValue can also return non-tuple objects. From storchaka at gmail.com Tue Oct 20 14:08:57 2020 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 20 Oct 2020 21:08:57 +0300 Subject: Pickle in C does not work In-Reply-To: References: Message-ID: 20.10.20 17:12, Marco Sulla ????: > On Tue, 20 Oct 2020 at 16:07, Serhiy Storchaka wrote: >> You can use PyDict_New() + PyDict_Merge() to create a dict from your >> mapping. > Well, yes, I know. I just wrote it for simplicity now. Do you think this is > the problem? I think that it can be more performant and maybe even simpler. > I forgot to say that copy and deepcopy works. For what I know, they use > __reduce__ if it's present. They do not resolve class by name. They just use the result of __reduce__ to reconstruct an instance. From storchaka at gmail.com Tue Oct 20 15:52:38 2020 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 20 Oct 2020 22:52:38 +0300 Subject: Py_BuildValue vs PyTuple_Pack vs PyTuple_New In-Reply-To: References: Message-ID: 20.10.20 18:05, Marco Sulla ????: > I read these three C api functions, They are similar, because they all > construct a tuple[1]. > > IMHO, Py_BuildValue is more simple to use than PyTuple_Pack that is more > simple to use than PyTuple_New. > > Where to use one or the other? What's the relative performance of the three > functions? Py_BuildValue is the most powerful (it can creates not only tuple, it can create items from V integers, strings, etc, it can decrement refcount), but it is slower. It is used when the performance less important than saving few lines of code. PyTuple_Pack() is convenient when you create a tuple from constant number of Python objects. It is a good compromise with readability and performance. PyTuple_New is used for creating a variable-size tuple. In combination with macros PyTuple_SET_ITEM it can be use3d as more verbose but slightly more efficient version of PyTuple_Pack. But PyTuple_SET_ITEM is not in the limited API. For your case I suggest to use PyTuple_Pack (unless you find that PyTuple_New+PyTuple_SET_ITEM is critically more performant). From Marco.Sulla.Python at gmail.com Tue Oct 20 17:55:18 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Tue, 20 Oct 2020 23:55:18 +0200 Subject: Py_BuildValue vs PyTuple_Pack vs PyTuple_New In-Reply-To: References: Message-ID: Good, thank you a lot again. From Marco.Sulla.Python at gmail.com Wed Oct 21 09:32:49 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Wed, 21 Oct 2020 15:32:49 +0200 Subject: How to create a C Extension that uses CPython internals (outside limited API)? Message-ID: I'm working on a C extension for frozendict. To make it working, I had to: 1. add by hand the whole path of dictobject.c (/home/marco/sources/cpython/Objects/dictobject.c) 2. add -DPy_BUILD_CORE 3. add the whole path of CPython includes (/home/marco/sources/cpython/Include and so on) This works on my machine, but I suspect that nobody will download the whole CPython code and add the extra CFLAGS only to make it work. What do I have to do? I have to copy the CPython source code that I need inside my c extension folder? What if I also want to support CPython from 3.6 to 3.9? From shishaozhong at gmail.com Wed Oct 21 17:24:28 2020 From: shishaozhong at gmail.com (Shaozhong SHI) Date: Wed, 21 Oct 2020 22:24:28 +0100 Subject: How to write differently to remove this type hint in Python 2.7? Message-ID: Is there another way to do this? def greet(name: str) -> str: return "Hello, " + name greet File "", line 1 def greet(name: str) -> str: ^ SyntaxError: invalid syntax From rosuav at gmail.com Wed Oct 21 17:28:25 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 22 Oct 2020 08:28:25 +1100 Subject: How to write differently to remove this type hint in Python 2.7? In-Reply-To: References: Message-ID: On Thu, Oct 22, 2020 at 8:26 AM Shaozhong SHI wrote: > > Is there another way to do this? > > def greet(name: str) -> str: > return "Hello, " + name > greet > > File "", line 1 def greet(name: str) -> str: > ^ SyntaxError: invalid syntax If you need to support Python 2, don't use annotations. It's that simple. :) Bear in mind that Python 2 is now extremely old, and is no longer supported. A much better option is to use a newer interpreter. ChrisA From mats at wichmann.us Wed Oct 21 19:41:22 2020 From: mats at wichmann.us (Mats Wichmann) Date: Wed, 21 Oct 2020 17:41:22 -0600 Subject: How to write differently to remove this type hint in Python 2.7? In-Reply-To: References: Message-ID: <4dc468ef-7276-d7b9-1ec0-56b0fe2cfb42@wichmann.us> On 10/21/20 3:24 PM, Shaozhong SHI wrote: > Is there another way to do this? > > def greet(name: str) -> str: > return "Hello, " + name > greet > > File "", line 1 def greet(name: str) -> str: > ^ SyntaxError: invalid syntax > The hinting pep PEP (484) has an alternate syntax that doesn't break 2.7. From shishaozhong at gmail.com Thu Oct 22 05:27:14 2020 From: shishaozhong at gmail.com (Shaozhong SHI) Date: Thu, 22 Oct 2020 10:27:14 +0100 Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO Message-ID: I found this last option is very interesting. Saving the dataframe to memory using StringIO https://naysan.ca/2020/06/21/pandas-to-postgresql-using-psycopg2-copy_from/ But, testing shows unicode argument expected, got 'str' Any working example for getting DataFrame into a PostgreSQL table directly? Regards, David From Marco.Sulla.Python at gmail.com Thu Oct 22 06:33:39 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Thu, 22 Oct 2020 12:33:39 +0200 Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO In-Reply-To: References: Message-ID: Try to save it in a binary field on PG using hdf5: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_hdf.html On Thu, 22 Oct 2020 at 11:29, Shaozhong SHI wrote: > I found this last option is very interesting. > > Saving the dataframe to memory using StringIO > > https://naysan.ca/2020/06/21/pandas-to-postgresql-using-psycopg2-copy_from/ > > But, testing shows > unicode argument expected, got 'str' > > Any working example for getting DataFrame into a PostgreSQL table directly? > > Regards, > > David > -- > https://mail.python.org/mailman/listinfo/python-list > From samuelmarks at gmail.com Thu Oct 22 06:56:22 2020 From: samuelmarks at gmail.com (Samuel Marks) Date: Thu, 22 Oct 2020 21:56:22 +1100 Subject: =?UTF-8?Q?Static_typing=E2=80=94with_annotations=E2=80=94function_name_=26_a?= =?UTF-8?Q?rguments=2C_or_result_of_call=2C_or_string?= Message-ID: >From my understanding, `ast.arguments` and `inspect.Signature` are the two builtin ways of defining the function name and arguments in a structured way. What I am creating is a way of configuring? well let's be specific to my use-case. I am building a way to configure TensorFlow. One which is very type-driven, and will error as early-as-possible when incorrect types or lack of required parameters are provided. I can dynamically infer things like so: ``` import inspect import tensorflow as tf sig = inspect.signature(tf.keras.optimizers.Adam) tuple({ "default": sig.parameters[param].default, "name": param, "typ": type(sig.parameters[param].default).__name__ if sig.parameters[param].default is not inspect._empty and sig.parameters[param].annotation is inspect._empty else sig.parameters[param].annotation, } for param in sig.parameters if param != 'name' ) ``` I can also parse the docstring, as I do in my doctrans library and tool. Which will give me the options I can provide the class. So there's an obvious solution, to generate these classes: ``` class TensorFlowConfig(object): optimizer: Optional[Optimizer] = None # Or maybe a `Protocol`? class Optimizer(object): pass class AdamConfig(Optimizer): learning_rate: float = 0.001 beta_1: float = 0.9 beta_2: float = 0.999 epsilon: float = 1e-07 amsgrad: bool = False kwargs: dict = {} TensorFlowConfig().optimizer = AdamConfig() ``` But, keeping in mind the goal to expose everything in all interfaces, the question then becomes how to generate an argparse parser from this. And how to generate a function from this. And how to ensure that whatever code-completion interface one uses in Python, that it can figure out what the correct parameters are. So I should get an error about incorrect type when I: ``` # CLI --optimizer 'Adam' 'learning_rate = True' # class* TensorFlowConfig().optimizer = tf.keras.optimizers.Adam(learning_rate=True) TensorFlowConfig().optimizer = AdamConfig(learning_rate=True) # Function* MyTensorFlowClass.train(optimizer=tf.keras.optimizers.Adam(learning_rate=True)) MyTensorFlowClass.train(optimizer=AdamConfig(learning_rate=True)) * both of these next two lines?after the heading?should be equivalent ``` Syntax like this should also be valid ``` TensorFlowConfig().optimizer = 'tf.keras.optimizers.Adam' TensorFlowConfig().optimizer = 'Adam' MyTensorFlowClass.train(optimizer='tf.keras.optimizers.Adam') MyTensorFlowClass.train(optimizer='Adam') ``` Do I have huge annotations like this*, with an `Any` lopped on for further analysis down the line? - So it can easily generate into `choices` for argparse? [which will need to be subclassed in order to enable that "--optimizer 'Adam' 'learning_rate = True'" syntax] * https://github.com/SamuelMarks/ml-params-tensorflow/blob/1d48502/ml_params_tensorflow/ml_params/trainer.py#L213-L215 What makes sense? Thanks for your insights, Samuel Marks Charity | consultancy | open-source | LinkedIn PS: This is the `doctrans` project I referenced https://github.com/SamuelMarks/doctrans From Marco.Sulla.Python at gmail.com Thu Oct 22 07:23:11 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Thu, 22 Oct 2020 13:23:11 +0200 Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO In-Reply-To: References: Message-ID: I would add that usually I do not recommend saving files on databases. I usually save the file on the disk and the path and mime on a dedicated table. From rosuav at gmail.com Thu Oct 22 08:34:41 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 22 Oct 2020 23:34:41 +1100 Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO In-Reply-To: References: Message-ID: On Thu, Oct 22, 2020 at 8:28 PM Shaozhong SHI wrote: > > I found this last option is very interesting. > > Saving the dataframe to memory using StringIO > > https://naysan.ca/2020/06/21/pandas-to-postgresql-using-psycopg2-copy_from/ > > But, testing shows > unicode argument expected, got 'str' > > Any working example for getting DataFrame into a PostgreSQL table directly? > That error suggests that you're using a legacy version of Python. The page you're linking to has been written on the assumption that you're using Python 3. ChrisA From darcy at VybeNetworks.com Thu Oct 22 08:37:15 2020 From: darcy at VybeNetworks.com (D'Arcy Cain) Date: Thu, 22 Oct 2020 08:37:15 -0400 Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO In-Reply-To: References: Message-ID: <045050ba-d0de-6760-903d-a05b0366b68c@VybeNetworks.com> On 10/22/20 7:23 AM, Marco Sulla wrote: > I would add that usually I do not recommend saving files on databases. I > usually save the file on the disk and the path and mime on a dedicated > table. I used to do that because backing up the database became huge. Now I use ZFS snapshots with send/receive so the backup only copies the changed blocks so I keep it in the database. That way the data is available from any client with database access without the need to give access to the server. PostgreSQL can handle it. -- D'Arcy J.M. Cain Vybe Networks Inc. A unit of Excelsior Solutions Corporation - Propelling Business Forward http://www.VybeNetworks.com/ IM:darcy at VybeNetworks.com VoIP: sip:darcy at VybeNetworks.com -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 236 bytes Desc: OpenPGP digital signature URL: From Marco.Sulla.Python at gmail.com Thu Oct 22 09:18:58 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Thu, 22 Oct 2020 15:18:58 +0200 Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO In-Reply-To: <045050ba-d0de-6760-903d-a05b0366b68c@VybeNetworks.com> References: <045050ba-d0de-6760-903d-a05b0366b68c@VybeNetworks.com> Message-ID: Never worked with ZFS, it sounds interesting. Anyway, IMHO it's much more simple to save to disk also for debugging: you have not to extract the data from the db if you need to inspect them. On Thu, 22 Oct 2020 at 14:39, D'Arcy Cain wrote: > On 10/22/20 7:23 AM, Marco Sulla wrote: > > I would add that usually I do not recommend saving files on databases. I > > usually save the file on the disk and the path and mime on a dedicated > > table. > > I used to do that because backing up the database became huge. Now I use > ZFS snapshots with send/receive so the backup only copies the changed > blocks > so I keep it in the database. That way the data is available from any > client with database access without the need to give access to the server. > > PostgreSQL can handle it. > > -- > D'Arcy J.M. Cain > Vybe Networks Inc. > A unit of Excelsior Solutions Corporation - Propelling Business Forward > http://www.VybeNetworks.com/ > IM:darcy at VybeNetworks.com VoIP: sip:darcy at VybeNetworks.com > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Thu Oct 22 10:01:56 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 23 Oct 2020 01:01:56 +1100 Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO In-Reply-To: References: Message-ID: On Fri, Oct 23, 2020 at 12:15 AM Shaozhong SHI wrote: > > Thanks, Chris. > > What should I know or watch out if I decide to move from Python 2.7 to Python 3? > > What are the key issues? Syntax? > Keep it on-list please :) Key issues? Well, for starters, you don't have to worry about whether your strings are Unicode or not. They just are, unless you explicitly need them to be bytes. Syntax is probably going to be fine, since you're taking examples that were written for Python 3 anyway. There's a LOT more features in Python 3, since it's had another decade of development than Python 2 has had. Give it a try. ChrisA From julio at diegidio.name Thu Oct 22 12:25:34 2020 From: julio at diegidio.name (Julio Di Egidio) Date: Thu, 22 Oct 2020 09:25:34 -0700 (PDT) Subject: Question on ABC classes Message-ID: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> Hello guys, I am professional programmer but quite new to Python, and I am trying to get the grips of some peculiarities of the language. Here is a basic question: if I define an ABC class, I can still instantiate the class unless there are abstract methods defined in the class. (In the typical OO language the class would be not instantiable, period, since it's "abstract". But this is not so in Python, to the point that, also for uniformity, I am feeling compelled to define an @abstractmethod __init__ in my ABC classes, whether they need one or not, and whether there are other abstract methods in the class or not.) Now, I do read in the docs that that is as intended, but I am not understanding the rationale of it: why only if there are abstract methods defined in an ABC class is instantiation disallowed? IOW, why isn't subclassing from ABC enough? Thanks for any enlightenment, Julio From grant.b.edwards at gmail.com Thu Oct 22 11:57:44 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 22 Oct 2020 15:57:44 -0000 (UTC) Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO References: Message-ID: On 2020-10-22, Chris Angelico wrote: > On Fri, Oct 23, 2020 at 12:15 AM Shaozhong SHI wrote: >> What should I know or watch out if I decide to move from Python 2.7 >> to Python 3? > > Key issues? Well, for starters, you don't have to worry about whether > your strings are Unicode or not. They just are, unless you explicitly > need them to be bytes. The 'bytes' thing is important. If you use serial ports, sockets, or anything else that's raw bytes, that code will need to be examined carefully. The usage of the 'bytes' type in 3.x isn't at all like 2.x: Python2: >>> bytes('abcd') 'abcd' >>> bytes(3) '3' >>> bytes([0,1,2]) '[0, 1, 2]' Python3: >>> bytes('abcd') Traceback (most recent call last): File "", line 1, in TypeError: string argument without an encoding >>> bytes(3) b'\x00\x00\x00' >>> bytes([0,1,2]) b'\x00\x01\x02 Python2: >>> b'abcd'[2] 'c' Python3: >>> b'abcd'[2] 99 Moving from 2.x to 3.x isn't too bad, but trying to maintain compatiblity with both is painful. At this point, I would probably just abandon 2.x. -- Grant From rosuav at gmail.com Thu Oct 22 13:58:52 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 23 Oct 2020 04:58:52 +1100 Subject: Dataframe to postgresql - Saving the dataframe to memory using StringIO In-Reply-To: References: Message-ID: On Fri, Oct 23, 2020 at 3:35 AM Grant Edwards wrote: > Moving from 2.x to 3.x isn't too bad, but trying to maintain > compatiblity with both is painful. At this point, I would probably > just abandon 2.x. > Definitely. No point trying to support both when you're starting with code from a Py3 example. ChrisA From jrubiando at gmail.com Thu Oct 22 14:58:57 2020 From: jrubiando at gmail.com (Lammie Jonson) Date: Thu, 22 Oct 2020 11:58:57 -0700 (PDT) Subject: GUI (tkinter) popularity and job prospects for Message-ID: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> I have been a rails developer as well as JS/react. I had wanted to look at python a bit due to it's popularity. I looked at tkinter which seems to have quite a few examples out there, but when I searched indeed.com for tkinter and wxpython it appeared that there was hardly any job listings mentioning those. Why is that ? It's a bit of a demotivating factor to get very serious with tk etc. I was going to look at something like tensorflow perhaps, though I am not sure if machine learning is that easy to pickup or not From Marco.Sulla.Python at gmail.com Thu Oct 22 16:09:40 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Thu, 22 Oct 2020 22:09:40 +0200 Subject: Question on ABC classes In-Reply-To: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> Message-ID: On Thu, 22 Oct 2020 at 18:31, Julio Di Egidio wrote: > why > only if there are abstract methods defined in an ABC > class is instantiation disallowed? > Not sure because I never tried or needed, but if no @abstractsomething in A is defined and your B class is a subclass of A, B should be an abstract class, not a concrete class. From Marco.Sulla.Python at gmail.com Thu Oct 22 16:18:40 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Thu, 22 Oct 2020 22:18:40 +0200 Subject: Question on ABC classes In-Reply-To: References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> Message-ID: On Thu, 22 Oct 2020 at 22:09, Marco Sulla wrote: > Not sure because I never tried or needed, but if no @abstractsomething in > A is defined and your B class is a subclass of A, B should be an abstract > class, not a concrete class. > Now I'm sure: >>> from abc import ABC, abstractmethod >>> class A(ABC): pass ... >>> class B(A): ... @abstractmethod ... def hello(self): ... print("hello") ... >>> B() Traceback (most recent call last): File "", line 1, in TypeError: Can't instantiate abstract class B with abstract methods hello > > From ethan at stoneleaf.us Thu Oct 22 17:03:41 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 22 Oct 2020 14:03:41 -0700 Subject: Question on ABC classes In-Reply-To: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> Message-ID: <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> On 10/22/20 9:25 AM, Julio Di Egidio wrote: > Now, I do read in the docs that that is as intended, > but I am not understanding the rationale of it: why > only if there are abstract methods defined in an ABC > class is instantiation disallowed? IOW, why isn't > subclassing from ABC enough? Let's say you subclass from ABC: class Abstract(ABC): pass Then you subclass from that: class Concrete(Abstract): pass Then subclass from that: class MoreConcrete(Concrete): pass If you do a issubclass(, ABC) you'll get True The idea behind abstract classes is the prevention of creating non-functional instances, which means if any abstract methods, properties, etc., are present in an abstract class, then it's instances will not be fully functional; contrariwise, if there are no abstract anythings in the class, then it is functional and there's no reason not to allow it to be created. Put another way: if ABC is anywhere in a class' parentage, then it is "abstract" -- the only way to tell if instantiating it is okay is by the presence/absence of abstract pieces in the class. -- ~Ethan~ From rshepard at appl-ecosys.com Thu Oct 22 15:50:43 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 22 Oct 2020 12:50:43 -0700 (PDT) Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: On Thu, 22 Oct 2020, Lammie Jonson wrote: > I looked at tkinter which seems to have quite a few examples out there, > but when I searched indeed.com for tkinter and wxpython it appeared that > there was hardly any job listings mentioning those. Why is that ? It's a > bit of a demotivating factor to get very serious with tk etc. I was going > to look at something like tensorflow perhaps, though I am not sure if > machine learning is that easy to pickup or not Lammie, I'm not a computer professional but I've worked with computers for 40+ years, from main frames to personal ones. I also run a solo practitioner consultancy after working for others so I know both sides of the job market. My advice is free so there's no obligation for you to consider it. You're looking for a job from the wrong end. Let me offer an analogy I use to describe how you ought to go about your job search. I've often said that you can teach someone how to use a word processor but that does not make them a writer. Your rails/JS experiences and your interest in tkinter or wxpython is focused on tools, not the products produced by those tools. If you wanted to hire a professional chef how would you respond to someone who told you they had great knife skills? Your interest is in what they could do with those skills to prepare outstanding meals for you. After all, it's the meals you're buying, not how uniform are their diced onions. An employer will hire those who will benefit the employer's company and position. The tools used to provide those benefits are less important than the prospective employee's skill in using them to solve a problem or increase company profits and prove how great a manager is for hiring you. Make a list of what you can do and what you've accomplished, not a list of tools you know. I've no idea what you really want to do but define that in terms of both your personal satisfaction and what an employer would value. And keep in mind the three steps in getting the job/career you want: 1. The cover letter's only purpose is to get the recipient to read the enclosed resume. 2. The resume's only purpose is to get you an interview with an ultimate decision-maker (not a personnel gate keeper). 3. The interview's purpose is to sell yourself as a benefit to the company and proof of how clever the interviewer is by hiring you. Good luck ... and stay well, Rich From taleinat at gmail.com Thu Oct 22 17:33:40 2020 From: taleinat at gmail.com (Tal Einat) Date: Fri, 23 Oct 2020 00:33:40 +0300 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: Hi Lammie, On Thu, Oct 22, 2020 at 10:03 PM Lammie Jonson wrote: > > I looked at tkinter which seems to have quite a few examples out there, > but when I searched indeed.com for tkinter and wxpython it appeared that > there was hardly any job listings mentioning those. Why is that ? > My guess would be that that is because we are after quite a few years of a world-wide, cross-industry move away from making desktop apps towards making web apps and mobile apps. To my knowledge, there are very few job listings looking for mastery of any desktop UI technologies, certainly relative to web-based UI technologies. (There are exceptions to this, of course.) I was going to look at something like tensorflow perhaps, though I am not > sure if machine learning is that easy to pickup or not > "Data science", using machine learning or otherwise, has become very popular and there are many jobs in most tech hubs for those with relevant skills. It requires a somewhat different set of skills, such as a solid working knowledge of statistics. Generally speaking and without knowing your specific circumstances, I think this would be a much safer bet in terms of employment options than learning desktop UI techs. It's not for everyone though; how hard it will be for you is hard to say, it's an individual thing. It's also a different type of work, so your motivation and interest in it may not be the same, for better or worse. If you're interested, there are plenty of learning resources out there; perhaps try an introductory "data science" course or book and see how it feels to you. - Tal From torriem at gmail.com Thu Oct 22 17:35:13 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 22 Oct 2020 15:35:13 -0600 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: <6df135cb-90b9-4715-94c4-f7017661ba8a@gmail.com> On 10/22/20 12:58 PM, Lammie Jonson wrote: > > I have been a rails developer as well as JS/react. I had wanted to > look at python a bit due to it's popularity. > > I looked at tkinter which seems to have quite a few examples out > there, but when I searched indeed.com for tkinter and wxpython it > appeared that there was hardly any job listings mentioning those. Why > is that ? It's a bit of a demotivating factor to get very serious > with tk etc. I doubt you'll find any jobs connected a particular Python GUI toolkit. Except maybe at Red Hat. Most likely you'll find Python used in web app development, back-end server system programming, scripting, etc. Of course Python can be used with a variety of GUI toolkits including Tk, wx, GTK+, and Qt, to make desktop applications of course, but it's not commercially common and I wouldn't ever expect to see that on a job posting. > I was going to look at something like tensorflow perhaps, though I am > not sure if machine learning is that easy to pickup or not Not sure anything difficult and worthwhile, even if it is popular and in demand, is something you can just "[easily] pick up." But good luck to you. If you can find some fun side projects to do with with it while gaining experience, I'm sure that will look good on a resume. From rosuav at gmail.com Thu Oct 22 18:15:04 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 23 Oct 2020 09:15:04 +1100 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: <6df135cb-90b9-4715-94c4-f7017661ba8a@gmail.com> References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> <6df135cb-90b9-4715-94c4-f7017661ba8a@gmail.com> Message-ID: On Fri, Oct 23, 2020 at 8:39 AM Michael Torrie wrote: > > I was going to look at something like tensorflow perhaps, though I am > > not sure if machine learning is that easy to pickup or not > > Not sure anything difficult and worthwhile, even if it is popular and in > demand, is something you can just "[easily] pick up." But good luck to > you. If you can find some fun side projects to do with with it while > gaining experience, I'm sure that will look good on a resume. True, but not everything worthwhile is difficult. If a competent programmer, knowing 20 distinct programming languages, needs to learn a 21st for a project, it should be straight-forward to master it in a short time (at least to the point of being able to muffle through - doesn't mean s/he would know all the idioms of course). Learning ML is certainly a big task, but learning some specific subpart of ML would be doable, and then you learn another subpart, and another and another, until you're employable. ChrisA From jrubiando at gmail.com Thu Oct 22 17:20:23 2020 From: jrubiando at gmail.com (Lammie Jonson) Date: Thu, 22 Oct 2020 14:20:23 -0700 (PDT) Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: <08e21db1-a39b-4096-a846-1a68200595afn@googlegroups.com> Thanks, Yes, I have some sense about how to do job interviews and market myself which is always an ongoing process. I also just have an interest in different technologies that I may want to investigate as I can get bored with certain things a little at times. If some technology seems a little interesting to me but I don't see that there are a lot of job listings for it however, then I sometimes wonder why that is etc From julio at diegidio.name Thu Oct 22 21:13:19 2020 From: julio at diegidio.name (Julio Di Egidio) Date: Thu, 22 Oct 2020 18:13:19 -0700 (PDT) Subject: Question on ABC classes In-Reply-To: References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> Message-ID: On Thursday, 22 October 2020 23:04:25 UTC+2, Ethan Furman wrote: > On 10/22/20 9:25 AM, Julio Di Egidio wrote: > > > Now, I do read in the docs that that is as intended, > > but I am not understanding the rationale of it: why > > only if there are abstract methods defined in an ABC > > class is instantiation disallowed? IOW, why isn't > > subclassing from ABC enough? > > Let's say you subclass from ABC: > > class Abstract(ABC): > pass > > Then you subclass from that: > > class Concrete(Abstract): > pass > > Then subclass from that: > > class MoreConcrete(Concrete): > pass > > If you do a > > issubclass(, ABC) > > you'll get > > True Ah, right, that's the point I was missing: how to tell the compiler when a more derived class is *not* abstract... I was indeed making the mistake of inheriting from ABC also in the derived classes, and omitting it in the classes that are eventually concrete, not realising that ABC isn't just a keywork or a decorator, so it gets inherited all the way. > The idea behind abstract classes is the prevention of creating > non-functional instances Well, in Python, not in any other OO language, where abstract is just synonym with must-override (hence cannot instantiate), no other constraints. I am now thinking whether I could achieve the "standard" behaviour via another approach, say with decorators, somehow intercepting calls to __new__... maybe. Anyway, abstract classes are the gist of most library code, and I remain a bit puzzled by the behaviour implemented in Python: but I am not complaining, I know it will take me some time before I actually understand the language... For now, thank you and Marco very much for your feedback, Julio From 2QdxY4RzWzUUiLuE at potatochowder.com Thu Oct 22 18:56:31 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Thu, 22 Oct 2020 17:56:31 -0500 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: <20201022225631.GC514692@scrozzle> On 2020-10-22 at 12:50:43 -0700, Rich Shepard wrote: > On Thu, 22 Oct 2020, Lammie Jonson wrote: > > I looked at tkinter which seems to have quite a few examples out > > there, but when I searched indeed.com for tkinter and wxpython it > > appeared that there was hardly any job listings mentioning > > those. Why is that ? It's a bit of a demotivating factor to get very > > serious with tk etc. I was going to look at something like > > tensorflow perhaps, though I am not sure if machine learning is that > > easy to pickup or not [...] > You're looking for a job from the wrong end. Let me offer an analogy I > use to describe how you ought to go about your job search. I've often > said that you can teach someone how to use a word processor but that > does not make them a writer. Your rails/JS experiences and your > interest in tkinter or wxpython is focused on tools, not the products > produced by those tools. > If you wanted to hire a professional chef how would you respond to > someone who told you they had great knife skills? Your interest is in > what they could do with those skills to prepare outstanding meals for > you. After all, it's the meals you're buying, not how uniform are > their diced onions. > An employer will hire those who will benefit the employer's company > and position. The tools used to provide those benefits are less > important than the prospective employee's skill in using them to solve > a problem or increase company profits and prove how great a manager is > for hiring you. > Make a list of what you can do and what you've accomplished, not a > list of tools you know. I've no idea what you really want to do but > define that in terms of both your personal satisfaction and what an > employer would value. I'll second that. I had a 40+ year career spanning multiple companies and multiple industries, and putting a tool on your resume may get you past a gatekeeper, but that's rarely why you actually get hired or paid. I picked up Python in 1997 to build some proofs-of-concept for some designs I was working on. I ended up with a tkinter based GUI, but only because the command line programs came together so quickly. IMO, the GUI didn't add anything to my design or to the proofs-of-concept. But I digress. Pick a few tools, learn them well, and use them to build something (often, those last two go hand in hand). Build something that interests you, or something related to an industry or a technology in which you'd like to work, or something that might be useful to you or to someone else. Pick a new tool here or there, but only as a means to improve some other area of knowledge, like building GUIs, or concurrency, or scientific software, or a different style of programming, or whatever. Happy hacking. -- ?Whoever undertakes to set himself up as a judge of Truth and Knowledge is shipwrecked by the laughter of the gods.? ? Albert Einstein Dan Sommers, http://www.tombstonezero.net/dan From tjreedy at udel.edu Thu Oct 22 18:58:47 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 22 Oct 2020 18:58:47 -0400 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: On 10/22/2020 2:58 PM, Lammie Jonson wrote: > I looked at tkinter which seems to have quite a few examples out there, but when I searched indeed.com for tkinter and wxpython it appeared that there was hardly any job listings mentioning those. Why is that ? I think that commercial desktop applications with a python compatible GUI would likely use QT or a Python binding thereof. -- Terry Jan Reedy From stpasha at gmail.com Thu Oct 22 20:51:54 2020 From: stpasha at gmail.com (Pasha Stetsenko) Date: Thu, 22 Oct 2020 17:51:54 -0700 Subject: Debugging a memory leak Message-ID: Dear Python gurus, I'm a maintainer of a python library "datatable" (can be installed from PyPi), and i've been recently trying to debug a memory leak that occurs in my library. The program that exposes the leak is quite simple: ``` import datatable as dt import gc # just in case def leak(n=10**7): for i in range(n): z = dt.update() leak() gc.collect() input("Press enter") ``` Note that despite the name, the `dt.update` is actually a class, though it is defined via Python C API. Thus, this script is expected to create and then immediately destroy 10 million simple python objects. The observed behavior, however, is that the script consumes more and more memory, eventually ending up at about 500M. The amount of memory the program ends up consuming is directly proportional to the parameter `n`. The `gc.get_objects()` does not show any extra objects however. The `tracemalloc` module shows that there are indeed `n` objects leaked in the `z=dt.update()` line, but doesn't give any extra details. In order to dig deeper, I let the process wait on the "input()" line, and wrote a script to dump the process' memory into a file. Then I scanned through the file looking at any repeated patterns of 64-bit words. Inside the memory dump, the following sequences were the most common: ``` 0x0000000000000000 - 28660404 0x00000001024be6e8 - 4999762 0x0000000101cbdea0 - 119049 0x0000000000000054 - 59537 0x00000fd000000ff0 - 59526 0x0000000000000001 - 16895 0xffffffffffffffff - 12378 ... ``` The most suspicious sequence here is 0x00000001024be6e8, which if you look at that address with lldb, is the address of the PyTypeObject "dt.update", which looks approximately like this: ``` (lldb) p *(PyTypeObject*)(0x000000010f4206e8) (PyTypeObject) $0 = { ob_base = { ob_base = { ob_refcnt = 8 ob_type = 0x000000010ec216b0 } ob_size = 0 } tp_name = 0x000000010f3a442c "datatable.update" tp_basicsize = 48 tp_itemsize = 0 tp_dealloc = 0x000000010f0a8040 (_datatable.cpython-36m-darwin.so`void py::_safe_dealloc(_object*) at xobject.h:270) tp_print = 0x0000000000000000 tp_getattr = 0x0000000000000000 tp_setattr = 0x0000000000000000 tp_as_async = 0x0000000000000000 tp_repr = 0x000000010eab3fa0 (Python`object_repr) tp_as_number = 0x0000000000000000 tp_as_sequence = 0x0000000000000000 tp_as_mapping = 0x0000000000000000 tp_hash = 0x000000010eb48640 (Python`_Py_HashPointer) tp_call = 0x0000000000000000 tp_str = 0x000000010eab40d0 (Python`object_str) tp_getattro = 0x000000010eaa1ae0 (Python`PyObject_GenericGetAttr) tp_setattro = 0x000000010eaa1ce0 (Python`PyObject_GenericSetAttr) tp_as_buffer = 0x0000000000000000 tp_flags = 266240 ... ``` Thus, I can be quite certain that 0x1024be6e8 is the address of the `dt.update` type structure. The way this address appears in the memory dump looks like this: ``` 0x7f97875cbb10: 0x00000000 0x00000000 0x024be6e8 0x00000001 0x7f97875cbb20: 0x00000000 0x00000000 0x00000000 0x00000000 0x7f97875cbb30: 0x00000000 0x00000000 0x00000000 0x00000000 0x7f97875cbb40: 0x00000000 0x00000000 0x024be6e8 0x00000001 0x7f97875cbb50: 0x00000000 0x00000000 0x00000000 0x00000000 0x7f97875cbb60: 0x00000000 0x00000000 0x00000000 0x00000000 0x7f97875cbb70: 0x00000000 0x00000000 0x024be6e8 0x00000001 0x7f97875cbb80: 0x00000000 0x00000000 0x00000000 0x00000000 0x7f97875cbb90: 0x00000000 0x00000000 0x00000000 0x00000000 0x7f97875cbba0: 0x00000000 0x00000000 0x024be6e8 0x00000001 0x7f97875cbbb0: 0x00000000 0x00000000 0x00000000 0x00000000 0x7f97875cbbc0: 0x00000000 0x00000000 0x00000000 0x00000000 ``` If i guess that all these represent the leaked objects, then inspecting any of them shows the following: ``` (lldb) p *(PyObject*)(0x7f97875cbb10) (PyObject) $2 = { ob_refcnt = 0 ob_type = 0x000000010f4206e8 } ``` Thus, the object didn't actually "leak" in the normal sense: its refcount is 0 and it was reclaimed by the Python runtime (when i print a debug message in tp_dealloc, i see that the destructor gets called every time). Still, Python keeps requesting more and more memory from the system instead of reusing the memory that was supposed to be freed. I'm currently not sure where to go from here. Is there something wrong with my python object that prevents it from being correctly processed by the Python runtime? Because this doesn't seem to be the usual case of incrementing the refcount too many times. This behavior was observed in Python 3.6.6 and also Python 3.8.0b2. From rosuav at gmail.com Thu Oct 22 21:50:09 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 23 Oct 2020 12:50:09 +1100 Subject: Debugging a memory leak In-Reply-To: References: Message-ID: On Fri, Oct 23, 2020 at 12:20 PM Pasha Stetsenko wrote: > I'm currently not sure where to go from here. Is there something wrong with > my python object that prevents it from being correctly processed by the > Python runtime? Because this doesn't seem to be the usual case of > incrementing the refcount too many times. Hard to say without seeing the source code. Is your code available anywhere? A few things to test: 1) Can you replicate this behaviour with only standard library classes? Try to find something implemented in C that uses tp_dealloc in a similar way to you. 2) Can you replicate this with an extremely simple cut-down class, and then publish the code for that class along with your question? 3) Does this happen on other operating systems or only on Mac OS? If you can't yourself test this, hopefully posting code from the other two questions will allow other people to try it. ChrisA From jfong at ms4.hinet.net Thu Oct 22 22:10:46 2020 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Thu, 22 Oct 2020 19:10:46 -0700 (PDT) Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: <08e21db1-a39b-4096-a846-1a68200595afn@googlegroups.com> References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> <08e21db1-a39b-4096-a846-1a68200595afn@googlegroups.com> Message-ID: <91730317-0600-4e83-bd77-ba24c4a324b8o@googlegroups.com> Lammie Jonson? 2020?10?23???? UTC+8??5?20?45???? > Thanks, > > Yes, I have some sense about how to do job interviews and market myself which is always an ongoing process. > > I also just have an interest in different technologies that I may want to investigate as I can get bored with certain things a little at times. If some technology seems a little interesting to me but I don't see that there are a lot of job listings for it however, then I sometimes wonder why that is etc A job listing shows the interest of the society, how it connects with your interest? --Jach From klsshaeffer at icloud.com Fri Oct 23 00:19:04 2020 From: klsshaeffer at icloud.com (Karen Shaeffer) Date: Thu, 22 Oct 2020 21:19:04 -0700 Subject: Debugging a memory leak In-Reply-To: References: Message-ID: <2852B341-FF5E-4001-B74C-36E8C2B516EE@icloud.com> > On Oct 22, 2020, at 5:51 PM, Pasha Stetsenko wrote: > > Dear Python gurus, > > I'm a maintainer of a python library "datatable" (can be installed from > PyPi), and i've been recently trying to debug a memory leak that occurs in > my library. > The program that exposes the leak is quite simple: > ``` > import datatable as dt > import gc # just in case > > def leak(n=10**7): > for i in range(n): > z = dt.update() > > leak() > gc.collect() > input("Press enter") > ``` Hi Pasha, dt.update() is acting on some object(s) outside the leak function body. And so even though, local objects z, i and n are eventually garbage collected, the side-effects of dt.update() are not affected by the return from the leak function. You need to look at your module and carefully trace what happens when dt.update() is executed. It seems to me that any memory consumed when dt.update() is executed will not be released when the leak function returns. humbly, Karen From greg.ewing at canterbury.ac.nz Fri Oct 23 01:36:10 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 23 Oct 2020 18:36:10 +1300 Subject: Question on ABC classes In-Reply-To: References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> Message-ID: On 23/10/20 2:13 pm, Julio Di Egidio wrote: > I am now thinking whether I could achieve the "standard" > behaviour via another approach, say with decorators, somehow > intercepting calls to __new__... maybe. I'm inclined to step back and ask -- why do you care about this? Would it actually do any harm if someone instantiated your base class? If not, then it's probably not worth going out of your way to prevent it. -- Greg From julio at diegidio.name Fri Oct 23 02:35:21 2020 From: julio at diegidio.name (Julio Di Egidio) Date: Thu, 22 Oct 2020 23:35:21 -0700 (PDT) Subject: Question on ABC classes In-Reply-To: References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> Message-ID: <7a6a90a2-4ba9-4556-a0ee-cf715d6db692o@googlegroups.com> On Friday, 23 October 2020 07:36:39 UTC+2, Greg Ewing wrote: > On 23/10/20 2:13 pm, Julio Di Egidio wrote: > > I am now thinking whether I could achieve the "standard" > > behaviour via another approach, say with decorators, somehow > > intercepting calls to __new__... maybe. > > I'm inclined to step back and ask -- why do you care about this? > > Would it actually do any harm if someone instantiated your > base class? If not, then it's probably not worth going out > of your way to prevent it. This is the first little library I try to put together in Python, and it was natural for me to hit it with all the relevant decorations as well as type annotations in order to expose *strict* contracts, plus hopefully have intellisense work all over the place. After several days of struggling, I am indeed finding that impossible in Python, at least with the available tools, and I am indeed going out of my way to just get some half-decent results... But, if I give up on strict contracts, I can as well give up on type annotations and the whole lot, indeed why even subclass ABC? Which is maybe too drastic, maybe not: it's the next thing I am going to try, and see what I remain with. :) Of course, any more hints welcome... Julio From mikaelpetterson1 at gmail.com Fri Oct 23 06:41:31 2020 From: mikaelpetterson1 at gmail.com (mikael petterson) Date: Fri, 23 Oct 2020 03:41:31 -0700 (PDT) Subject: Basic Python help Message-ID: Hi, I need to use the following code but in java. END_DELIM = '\n##\n' def start_delim(data_len): return '\n#%s\n' % (data_len) data = "%s%s%s" % (start_delim(len(data)), data, END_DELIM) Can anyone help me to understand what it means: I am guessing now: a function defined "start_delim" takes the length of a data string. function does modulo on something. This something I am not sure of :-) Does '\n#%s\n' will this be evaluated to a number when %s i replaced with data_len? Then the result is used as one parameter in "%s%s%s" start_delim then for the other data END_DELIM Your help is greatly appreciated! br, //mike From frank at chagford.com Fri Oct 23 07:22:10 2020 From: frank at chagford.com (Frank Millman) Date: Fri, 23 Oct 2020 13:22:10 +0200 Subject: Basic Python help In-Reply-To: References: Message-ID: <3e1a2e64-5754-2be0-d52e-d3f52177cb6a@chagford.com> On 2020-10-23 12:41 PM, mikael petterson wrote: > Hi, > > I need to use the following code but in java. > > END_DELIM = '\n##\n' > def start_delim(data_len): return '\n#%s\n' % (data_len) > data = "%s%s%s" % (start_delim(len(data)), data, END_DELIM) > > Can anyone help me to understand what it means: > > I am guessing now: > > a function defined "start_delim" takes the length of a data string. > function does modulo on something. This something I am not sure of > :-) > Does '\n#%s\n' will this be evaluated to a number when %s i replaced with data_len? > > Then the result is used as one parameter in "%s%s%s" > start_delim then for the other > data > END_DELIM > I think it is simpler than that. >>> >>> '\n#%s\n' % 2 '\n#2\n' >>> All it is doing is replacing '%s' with the length of the string. So the result is the concatenation of - 1. '\n' + '#' + length of string + '\n' as the start delimiter 2. the string itself 3. '\n' + '#' + '#' + '\n' as the end delimiter Frank Millman From frank at chagford.com Fri Oct 23 07:22:10 2020 From: frank at chagford.com (Frank Millman) Date: Fri, 23 Oct 2020 13:22:10 +0200 Subject: Basic Python help In-Reply-To: References: Message-ID: <3e1a2e64-5754-2be0-d52e-d3f52177cb6a@chagford.com> On 2020-10-23 12:41 PM, mikael petterson wrote: > Hi, > > I need to use the following code but in java. > > END_DELIM = '\n##\n' > def start_delim(data_len): return '\n#%s\n' % (data_len) > data = "%s%s%s" % (start_delim(len(data)), data, END_DELIM) > > Can anyone help me to understand what it means: > > I am guessing now: > > a function defined "start_delim" takes the length of a data string. > function does modulo on something. This something I am not sure of > :-) > Does '\n#%s\n' will this be evaluated to a number when %s i replaced with data_len? > > Then the result is used as one parameter in "%s%s%s" > start_delim then for the other > data > END_DELIM > I think it is simpler than that. >>> >>> '\n#%s\n' % 2 '\n#2\n' >>> All it is doing is replacing '%s' with the length of the string. So the result is the concatenation of - 1. '\n' + '#' + length of string + '\n' as the start delimiter 2. the string itself 3. '\n' + '#' + '#' + '\n' as the end delimiter Frank Millman From mikaelpetterson1 at gmail.com Fri Oct 23 08:09:10 2020 From: mikaelpetterson1 at gmail.com (mikael petterson) Date: Fri, 23 Oct 2020 05:09:10 -0700 (PDT) Subject: Basic Python help In-Reply-To: References: <3e1a2e64-5754-2be0-d52e-d3f52177cb6a@chagford.com> Message-ID: fredag 23 oktober 2020 kl. 13:22:55 UTC+2 skrev Frank Millman: > On 2020-10-23 12:41 PM, mikael petterson wrote: > > Hi, > > > > I need to use the following code but in java. > > > > END_DELIM = '\n##\n' > > def start_delim(data_len): return '\n#%s\n' % (data_len) > > data = "%s%s%s" % (start_delim(len(data)), data, END_DELIM) > > > > Can anyone help me to understand what it means: > > > > I am guessing now: > > > > a function defined "start_delim" takes the length of a data string. > > function does modulo on something. This something I am not sure of > > :-) > > Does '\n#%s\n' will this be evaluated to a number when %s i replaced with data_len? > > > > Then the result is used as one parameter in "%s%s%s" > > start_delim then for the other > > data > > END_DELIM > > > I think it is simpler than that. > > >>> > >>> '\n#%s\n' % 2 > '\n#2\n' > >>> > > All it is doing is replacing '%s' with the length of the string. > > So the result is the concatenation of - > > 1. '\n' + '#' + length of string + '\n' as the start delimiter > > 2. the string itself > > 3. '\n' + '#' + '#' + '\n' as the end delimiter > > Frank Millman Yes that was simpler than I thought. Thanks a lot! From grant.b.edwards at gmail.com Fri Oct 23 00:44:38 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 23 Oct 2020 04:44:38 -0000 (UTC) Subject: GUI (tkinter) popularity and job prospects for References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> <6df135cb-90b9-4715-94c4-f7017661ba8a@gmail.com> Message-ID: On 2020-10-22, Michael Torrie wrote: > I doubt you'll find any jobs connected a particular Python GUI toolkit. > Except maybe at Red Hat. A couple years ago my employer was looking for (and hired) a Python wx application developer. > Most likely you'll find Python used in web app development, back-end > server system programming, scripting, etc. Where I work, we use it exclusively for command line and GUI application development. That may not be terribly common, but there are jobs in actual application development. > Of course Python can be used with a variety of GUI toolkits including > Tk, wx, GTK+, and Qt, to make desktop applications of course, but it's > not commercially common and I wouldn't ever expect to see that on a job > posting. Really? Never? -- Grant From grant.b.edwards at gmail.com Fri Oct 23 00:47:45 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 23 Oct 2020 04:47:45 -0000 (UTC) Subject: GUI (tkinter) popularity and job prospects for References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: On 2020-10-22, Terry Reedy wrote: > On 10/22/2020 2:58 PM, Lammie Jonson wrote: > >> I looked at tkinter which seems to have quite a few examples out >> there, but when I searched indeed.com for tkinter and wxpython it >> appeared that there was hardly any job listings mentioning >> those. Why is that ? > > I think that commercial desktop applications with a python > compatible GUI would likely use QT or a Python binding thereof. Agreed. If you want to improve you "hirability" for GUI application development, I would probably put Qt first. Then gobject or wx. Tkinter would probably be last. -- Grant From ifeanyi.kz.obinelo at gmail.com Fri Oct 23 05:52:14 2020 From: ifeanyi.kz.obinelo at gmail.com (Ifeanyi Obinelo) Date: Fri, 23 Oct 2020 10:52:14 +0100 Subject: Issue with Python Message-ID: Hello! I am a Python programmer and I love the language. However, I installed Python 3.9 and suddenly, pip does not install Python libraries anymore. It says that I need Visual Studio C++ 2014 and exits with: "ERROR: Command errored out with exit status 1:..error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/" (The complete output is about 302 lines long. I will attach at the end of the email.) But I never needed Visual C++ 14 to install modules. Plus I have a bunch of C++ redistributables (but not 14). Is there any thing I can do to fix this? Also, is there any way to carry over my libraries and modules from my previous Python installation (Python 3.8.5)? Or do I need to manually reinstall them? Thank you for your help. Python is awesome! CMD OUTPUT BELOW... C:\Users\USER-1>pip install pandas Defaulting to user installation because normal site-packages is not writeable Collecting pandas Using cached pandas-1.1.3.tar.gz (5.2 MB) Installing build dependencies ... error ERROR: Command errored out with exit status 1: command: 'c:\program files\python39\python.exe' 'c:\program files\python39\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\USER-1\AppData\Local\Temp\pip-build-env-mhg8fpe_\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.29.21,<3' 'numpy==1.15.4; python_version=='"'"'3.6'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.15.4; python_version=='"'"'3.7'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.6'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.7'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"' and platform_system=='"'"'AIX'"'"'' cwd: None Complete output (302 lines): Ignoring numpy: markers 'python_version == "3.6" and platform_system != "AIX"' don't match your environment Ignoring numpy: markers 'python_version == "3.7" and platform_system != "AIX"' don't match your environment Ignoring numpy: markers 'python_version == "3.6" and platform_system == "AIX"' don't match your environment Ignoring numpy: markers 'python_version == "3.7" and platform_system == "AIX"' don't match your environment Ignoring numpy: markers 'python_version >= "3.8" and platform_system == "AIX"' don't match your environment Collecting setuptools Using cached setuptools-50.3.2-py3-none-any.whl (785 kB) Collecting wheel Using cached wheel-0.35.1-py2.py3-none-any.whl (33 kB) Collecting Cython<3,>=0.29.21 Using cached Cython-0.29.21-py2.py3-none-any.whl (974 kB) Collecting numpy==1.17.3 Using cached numpy-1.17.3.zip (6.4 MB) Using legacy 'setup.py install' for numpy, since package 'wheel' is not installed. Installing collected packages: setuptools, wheel, Cython, numpy Running setup.py install for numpy: started Running setup.py install for numpy: finished with status 'error' ERROR: Command errored out with exit status 1: command: 'c:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\USER-1\\AppData\\Local\\Temp\\pip-install-vtk9r3ug\\numpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\USER-1\\AppData\\Local\\Temp\\pip-install-vtk9r3ug\\numpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\USER-1\AppData\Local\Temp\pip-record-1i78k7r5\install-record.txt' --single-version-externally-managed --prefix 'C:\Users\USER-1\AppData\Local\Temp\pip-build-env-mhg8fpe_\overlay' --compile --install-headers 'C:\Users\USER-1\AppData\Local\Temp\pip-build-env-mhg8fpe_\overlay\Include\numpy' cwd: C:\Users\USER-1\AppData\Local\Temp\pip-install-vtk9r3ug\numpy\ Complete output (277 lines): Running from numpy source directory. Note: if you need reliable uninstall behavior, then install with pip instead of using `setup.py install`: - `pip install .` (from a git repo or downloaded source release) - `pip install numpy` (last NumPy release on PyPi) blas_opt_info: blas_mkl_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries mkl_rt not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE blis_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries blis not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE openblas_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries openblas not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']' customize GnuFCompiler Could not locate executable g77 Could not locate executable f77 customize IntelVisualFCompiler Could not locate executable ifort Could not locate executable ifl customize AbsoftFCompiler Could not locate executable f90 customize CompaqVisualFCompiler Could not locate executable DF customize IntelItaniumVisualFCompiler Could not locate executable efl customize Gnu95FCompiler Could not locate executable gfortran Could not locate executable f95 customize G95FCompiler Could not locate executable g95 customize IntelEM64VisualFCompiler customize IntelEM64TFCompiler Could not locate executable efort Could not locate executable efc customize PGroupFlangCompiler Could not locate executable flang don't know how to compile Fortran code on platform 'nt' NOT AVAILABLE atlas_3_10_blas_threads_info: Setting PTATLAS=ATLAS No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries tatlas not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE atlas_3_10_blas_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries satlas not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE atlas_blas_threads_info: Setting PTATLAS=ATLAS No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries ptf77blas,ptcblas,atlas not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE atlas_blas_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries f77blas,cblas,atlas not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE accelerate_info: NOT AVAILABLE C:\Users\USER-1\AppData\Local\Temp\pip-install-vtk9r3ug\numpy\numpy\distutils\system_info.py:690: UserWarning: Optimized (vendor) Blas libraries are not found. Falls back to netlib Blas library which has worse performance. A better performance should be easily gained by switching Blas library. self.calc_info() blas_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries blas not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE C:\Users\USER-1\AppData\Local\Temp\pip-install-vtk9r3ug\numpy\numpy\distutils\system_info.py:690: UserWarning: Blas (http://www.netlib.org/blas/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [blas]) or by setting the BLAS environment variable. self.calc_info() blas_src_info: NOT AVAILABLE C:\Users\USER-1\AppData\Local\Temp\pip-install-vtk9r3ug\numpy\numpy\distutils\system_info.py:690: UserWarning: Blas (http://www.netlib.org/blas/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [blas_src]) or by setting the BLAS_SRC environment variable. self.calc_info() NOT AVAILABLE 'svnversion' is not recognized as an internal or external command, operable program or batch file. non-existing path in 'numpy\\distutils': 'site.cfg' lapack_opt_info: lapack_mkl_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries mkl_rt not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE openblas_lapack_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries openblas not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE openblas_clapack_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries openblas,lapack not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE flame_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries flame not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE atlas_3_10_threads_info: Setting PTATLAS=ATLAS No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in c:\program files\python39\lib No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries tatlas,tatlas not found in c:\program files\python39\lib No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in C:\ No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries tatlas,tatlas not found in C:\ No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in c:\program files\python39\libs No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries tatlas,tatlas not found in c:\program files\python39\libs NOT AVAILABLE atlas_3_10_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in c:\program files\python39\lib No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries satlas,satlas not found in c:\program files\python39\lib No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in C:\ No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries satlas,satlas not found in C:\ No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in c:\program files\python39\libs No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries satlas,satlas not found in c:\program files\python39\libs NOT AVAILABLE atlas_threads_info: Setting PTATLAS=ATLAS No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in c:\program files\python39\lib No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries ptf77blas,ptcblas,atlas not found in c:\program files\python39\lib No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in C:\ No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries ptf77blas,ptcblas,atlas not found in C:\ No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in c:\program files\python39\libs No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries ptf77blas,ptcblas,atlas not found in c:\program files\python39\libs NOT AVAILABLE atlas_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in c:\program files\python39\lib No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries f77blas,cblas,atlas not found in c:\program files\python39\lib No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in C:\ No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries f77blas,cblas,atlas not found in C:\ No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack_atlas not found in c:\program files\python39\libs No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries f77blas,cblas,atlas not found in c:\program files\python39\libs NOT AVAILABLE lapack_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils customize MSVCCompiler libraries lapack not found in ['c:\\program files\\python39\\lib', 'C:\\', 'c:\\program files\\python39\\libs'] NOT AVAILABLE C:\Users\USER-1\AppData\Local\Temp\pip-install-vtk9r3ug\numpy\numpy\distutils\system_info.py:1712: UserWarning: Lapack (http://www.netlib.org/lapack/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [lapack]) or by setting the LAPACK environment variable. if getattr(self, '_calc_info_{}'.format(lapack))(): lapack_src_info: NOT AVAILABLE C:\Users\USER-1\AppData\Local\Temp\pip-install-vtk9r3ug\numpy\numpy\distutils\system_info.py:1712: UserWarning: Lapack (http://www.netlib.org/lapack/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [lapack_src]) or by setting the LAPACK_SRC environment variable. if getattr(self, '_calc_info_{}'.format(lapack))(): NOT AVAILABLE c:\program files\python39\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'define_macros' warnings.warn(msg) running install running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options running build_src build_src building py_modules sources creating build creating build\src.win-amd64-3.9 creating build\src.win-amd64-3.9\numpy creating build\src.win-amd64-3.9\numpy\distutils building library "npymath" sources No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ ---------------------------------------- ERROR: Command errored out with exit status 1: 'c:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\USER-1\\AppData\\Local\\Temp\\pip-install-vtk9r3ug\\numpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\USER-1\\AppData\\Local\\Temp\\pip-install-vtk9r3ug\\numpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\USER-1\AppData\Local\Temp\pip-record-1i78k7r5\install-record.txt' --single-version-externally-managed --prefix 'C:\Users\USER-1\AppData\Local\Temp\pip-build-env-mhg8fpe_\overlay' --compile --install-headers 'C:\Users\USER-1\AppData\Local\Temp\pip-build-env-mhg8fpe_\overlay\Include\numpy' Check the logs for full command output. WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available. You should consider upgrading via the 'c:\program files\python39\python.exe -m pip install --upgrade pip' command. ---------------------------------------- ERROR: Command errored out with exit status 1: 'c:\program files\python39\python.exe' 'c:\program files\python39\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\USER-1\AppData\Local\Temp\pip-build-env-mhg8fpe_\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.29.21,<3' 'numpy==1.15.4; python_version=='"'"'3.6'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.15.4; python_version=='"'"'3.7'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.6'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.7'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"' and platform_system=='"'"'AIX'"'"'' Check the logs for full command output. WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available. You should consider upgrading via the 'c:\program files\python39\python.exe -m pip install --upgrade pip' command. From johnpote at jptechnical.co.uk Fri Oct 23 12:52:14 2020 From: johnpote at jptechnical.co.uk (John Pote) Date: Fri, 23 Oct 2020 17:52:14 +0100 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: On 23/10/2020 05:47, Grant Edwards wrote: > >> I think that commercial desktop applications with a python >> compatible GUI would likely use QT or a Python binding thereof. > Agreed. If you want to improve you "hirability" for GUI application > development, I would probably put Qt first. Then gobject or > wx. Tkinter would probably be last. I've used tkinter and wxPython occasionally in the past for 1 off test tasks (and interest). What's the advantage of Qt? John From mats at wichmann.us Fri Oct 23 13:32:04 2020 From: mats at wichmann.us (Mats Wichmann) Date: Fri, 23 Oct 2020 11:32:04 -0600 Subject: Issue with Python In-Reply-To: References: Message-ID: On 10/23/20 3:52 AM, Ifeanyi Obinelo wrote: > Hello! I am a Python programmer and I love the language. However, I > installed Python 3.9 and suddenly, pip does not install Python libraries > anymore. It says that I need Visual Studio C++ 2014 and exits with: > > "ERROR: Command errored out with exit status 1:..error: Microsoft Visual > C++ 14.0 is required. Get it with "Build Tools for Visual Studio": > https://visualstudio.microsoft.com/downloads/" > (The complete output is about 302 lines long. I will attach at the end of > the email.) > > But I never needed Visual C++ 14 to install modules. Plus I have a bunch of > C++ redistributables (but not 14). Is there any thing I can do to fix this? > > Also, is there any way to carry over my libraries and modules from my > previous Python installation (Python 3.8.5)? Or do I need to manually > reinstall them? Sometimes it's good to be a little patient! *Some* modules, certainly not all, use compiled binary components. Usually if they're big and consider they have performance-critical elements, so they use the C API to make binary bits. When pip goes to install, it tries to find a wheel that matches your configuration. If there are no binary bits, an "any" type wheel will work fine, and there are no issues. If there are binary bits, it looks for a combination of python version, architecture, and maybe bit-ness. Failing to find a suitable wheel, it pulls the source distribution and tries to install that (by calling setup.py), and that will try to compile. Since Windows doesn't come with a C compiler by default, that fails for you. You could be ambitious and install Visual Studio Build Tools (Community edition) or some such, and hope it works; it usually doesn't without further setup. Check if modules you care about exist for 3.9 by searching for them on pypi.org and clicking on Download to see the available versions. The projects you care about will inevitably catch up, but it's still early days for 3.9 and they have their own release processes to go through. Or you can look on an unofficial site that does early builds - take to heart the warning about the unsupported nature of these and tread carefully: https://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-image Or... stick with 3.8 for a while longer, there's nothing at all wrong with 3.8! "Do I need to manually reinstall" - get pip to dump out the modules into a requirements.txt file, and use that to populate your new environment. Then at least it won't be manual. From dieter at handshake.de Fri Oct 23 13:44:07 2020 From: dieter at handshake.de (Dieter Maurer) Date: Fri, 23 Oct 2020 19:44:07 +0200 Subject: Debugging a memory leak In-Reply-To: References: Message-ID: <24467.5735.886299.105459@ixdm.fritz.box> Pasha Stetsenko wrote at 2020-10-22 17:51 -0700: > ... >I'm a maintainer of a python library "datatable" (can be installed from >PyPi), and i've been recently trying to debug a memory leak that occurs in >my library. >The program that exposes the leak is quite simple: >``` >import datatable as dt >import gc # just in case > >def leak(n=10**7): > for i in range(n): > z = dt.update() > >leak() >gc.collect() >input("Press enter") >``` >Note that despite the name, the `dt.update` is actually a class, though it >is defined via Python C API. Thus, this script is expected to create and >then immediately destroy 10 million simple python objects. >The observed behavior, however, is that the script consumes more and more >memory, eventually ending up at about 500M. The amount of memory the >program ends up consuming is directly proportional to the parameter `n`. > >The `gc.get_objects()` does not show any extra objects however. For efficiency reasons, the garbage collector treats only objects from types which are known to be potentially involved in cycles. A type implemented in "C" must define `tp_traverse` (in its type structure) to indicate this possibility. `tp_traverse` also tells the garbage collector how to find referenced objects. You will never find an object in the result of `get_objects` the type of which does not define `tp_traverse`. > ... >Thus, the object didn't actually "leak" in the normal sense: its refcount >is 0 and it was reclaimed by the Python runtime (when i print a debug >message in tp_dealloc, i see that the destructor gets called every time). >Still, Python keeps requesting more and more memory from the system instead >of reusing the memory that was supposed to be freed. I would try to debug what happens further in `tp_dealloc` and its callers. You should eventually see a `PyMem_free` which gives the memory back to the Python memory management (built on top of the C memory management). Note that your `tp_dealloc` should not call the "C" library's "free". Python builds its own memory management (--> "PyMem_*") on top of the "C" library. It handles all "small" memory requests and, if necessary, requests big data chunks via `malloc` to split them into the smaller sizes. Should you "free" small memory blocks directly via "free", that memory becomes effectively unusable by Python (unless you have a special allocation as well). From valjhuber at gmail.com Fri Oct 23 14:22:52 2020 From: valjhuber at gmail.com (gMail) Date: Fri, 23 Oct 2020 11:22:52 -0700 Subject: Logic Bank Message-ID: Hello, All I am pleased to announce the release of Logic Bank. Logic Bank introduces spreadsheet-like rules for multi-table derivation and constraint logic for SQLAchemy databases - 40X more concise than legacy code, extensible and manageable using Python. Described in this article , open source on git. From auriocus at gmx.de Fri Oct 23 14:25:39 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Fri, 23 Oct 2020 20:25:39 +0200 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: <87pn5a53oh.fsf@nightsong.com> References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> <6df135cb-90b9-4715-94c4-f7017661ba8a@gmail.com> <87pn5a53oh.fsf@nightsong.com> Message-ID: Am 22.10.20 um 23:52 schrieb Paul Rubin: > Michael Torrie writes: >> I doubt you'll find any jobs connected a particular Python GUI toolkit. > It would be really nice if there was a way to straightforwardly run > Tkinter applications on Android. You'd install a single .apk and that > would let you run your Tkinter apps and make launchers for them. It's not unrealistic - there is AndroWish to run Tcl/Tk on Android including GUI and connection to Android specific services (subcommand "borg"). Someone in the Python community would need to make the Tkinter bridge with a native Python for Android. https://www.androwish.org/home/home Christian From stpasha at gmail.com Fri Oct 23 14:32:41 2020 From: stpasha at gmail.com (Pasha Stetsenko) Date: Fri, 23 Oct 2020 11:32:41 -0700 Subject: Debugging a memory leak In-Reply-To: <24467.5735.886299.105459@ixdm.fritz.box> References: <24467.5735.886299.105459@ixdm.fritz.box> Message-ID: Thanks for all the replies! Following Chris's advice, I tried to reduce the code to the smallest reproducible example (I guess I should have done it sooner), but here's what I came up with: ``` #include #include static int my_init(PyObject*, PyObject*, PyObject*) { return 0; } static void my_dealloc(PyObject*) {} static void init_mytype(PyObject* module) { PyTypeObject* type = new PyTypeObject(); std::memset(type, 0, sizeof(PyTypeObject)); Py_INCREF(type); type->tp_basicsize = static_cast(sizeof(PyObject)); type->tp_itemsize = 0; type->tp_flags = Py_TPFLAGS_DEFAULT; type->tp_new = &PyType_GenericNew; type->tp_name = "mytype"; type->tp_doc = "[temporary]"; type->tp_init = my_init; type->tp_dealloc = my_dealloc; PyType_Ready(type); PyModule_AddObject(module, "mytype", reinterpret_cast(type)); } ``` (my original `update` object had some fields in it, but it turns out they don't need to be present in order for the problem to manifest. So in this case I'm creating a custom object which is the same as basic PyObject). The `init_mytype()` function creates a custom type and attaches it to a module. After this, creating 100M instances of the object will cause the process memory to swell to 1.5G: ``` for i in range(10**8): z = dt.mytype() ``` I know this is not normal because if instead i used a builtin type such as `list`, or a python-defined class such as `class A: pass`, then the process will remain at steady RAM usage of about 6Mb. I've tested this on a Linux platform as well (using docker image quay.io/pypa/manylinux2010_x86_64), and the problem is present there as well. --- PS: The library I'm working on is open source, available at https://github.com/h2oai/datatable, but the code I posted above is completely independent from my library. On Fri, Oct 23, 2020 at 10:44 AM Dieter Maurer wrote: > Pasha Stetsenko wrote at 2020-10-22 17:51 -0700: > > ... > >I'm a maintainer of a python library "datatable" (can be installed from > >PyPi), and i've been recently trying to debug a memory leak that occurs in > >my library. > >The program that exposes the leak is quite simple: > >``` > >import datatable as dt > >import gc # just in case > > > >def leak(n=10**7): > > for i in range(n): > > z = dt.update() > > > >leak() > >gc.collect() > >input("Press enter") > >``` > >Note that despite the name, the `dt.update` is actually a class, though it > >is defined via Python C API. Thus, this script is expected to create and > >then immediately destroy 10 million simple python objects. > >The observed behavior, however, is that the script consumes more and > more > >memory, eventually ending up at about 500M. The amount of memory the > >program ends up consuming is directly proportional to the parameter `n`. > > > >The `gc.get_objects()` does not show any extra objects however. > > For efficiency reasons, the garbage collector treats only > objects from types which are known to be potentially involved in cycles. > A type implemented in "C" must define `tp_traverse` (in its type > structure) to indicate this possibility. > `tp_traverse` also tells the garbage collector how to find referenced > objects. > You will never find an object in the result of `get_objects` the > type of which does not define `tp_traverse`. > > > ... > >Thus, the object didn't actually "leak" in the normal sense: its refcount > >is 0 and it was reclaimed by the Python runtime (when i print a debug > >message in tp_dealloc, i see that the destructor gets called every time). > >Still, Python keeps requesting more and more memory from the system > instead > >of reusing the memory that was supposed to be freed. > > I would try to debug what happens further in `tp_dealloc` and its callers. > You should eventually see a `PyMem_free` which gives the memory back > to the Python memory management (built on top of the C memory management). > > Note that your `tp_dealloc` should not call the "C" library's "free". > Python builds its own memory management (--> "PyMem_*") on top > of the "C" library. It handles all "small" memory requests > and, if necessary, requests big data chunks via `malloc` to split > them into the smaller sizes. > Should you "free" small memory blocks directly via "free", that memory > becomes effectively unusable by Python (unless you have a special > allocation as well). > From Joseph.Schachner at Teledyne.com Fri Oct 23 14:42:05 2020 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Fri, 23 Oct 2020 18:42:05 +0000 Subject: Question on ABC classes In-Reply-To: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> Message-ID: I'm a C++ programmer and Python programmer as well. Python classes are not exactly like C++ classes. If you define a class where every method has an implementation, then it really isn't abstract. It can be instantiated. You can force it to be abstract by doing from abc import ABCMeta and declare class myclass(metaClass=ABCMeta). Otherwise, Python does not have a way to know that you intend the class to be abstract unless it contains an @abstractmethod that makes it actually abstract. Such a method must be overridden. Usually, an Abstract Base Class defines an interface. You can make all the functions @abstractmethod, and separately make a another class that is based on your ABC and provides default implementations for all the functions. Other classes can be based on that class. I am not an authority on this so let me refer you to actual documentation: See: https://docs.python.org/3/library/abc.html, that should help you. -----Original Message----- From: Julio Di Egidio Sent: Thursday, October 22, 2020 12:26 PM To: python-list at python.org Subject: Question on ABC classes Hello guys, I am professional programmer but quite new to Python, and I am trying to get the grips of some peculiarities of the language. Here is a basic question: if I define an ABC class, I can still instantiate the class unless there are abstract methods defined in the class. (In the typical OO language the class would be not instantiable, period, since it's "abstract". But this is not so in Python, to the point that, also for uniformity, I am feeling compelled to define an @abstractmethod __init__ in my ABC classes, whether they need one or not, and whether there are other abstract methods in the class or not.) Now, I do read in the docs that that is as intended, but I am not understanding the rationale of it: why only if there are abstract methods defined in an ABC class is instantiation disallowed? IOW, why isn't subclassing from ABC enough? Thanks for any enlightenment, Julio From python at mrabarnett.plus.com Fri Oct 23 14:54:30 2020 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 23 Oct 2020 19:54:30 +0100 Subject: Debugging a memory leak In-Reply-To: References: <24467.5735.886299.105459@ixdm.fritz.box> Message-ID: <533067f0-25bb-19dc-775c-0fd871863a7f@mrabarnett.plus.com> On 2020-10-23 19:32, Pasha Stetsenko wrote: > Thanks for all the replies! > Following Chris's advice, I tried to reduce the code to the smallest > reproducible example (I guess I should have done it sooner), > but here's what I came up with: > ``` > #include > #include > > static int my_init(PyObject*, PyObject*, PyObject*) { return 0; } > static void my_dealloc(PyObject*) {} > > static void init_mytype(PyObject* module) { > PyTypeObject* type = new PyTypeObject(); > std::memset(type, 0, sizeof(PyTypeObject)); > Py_INCREF(type); > > type->tp_basicsize = static_cast(sizeof(PyObject)); > type->tp_itemsize = 0; > type->tp_flags = Py_TPFLAGS_DEFAULT; > type->tp_new = &PyType_GenericNew; > type->tp_name = "mytype"; > type->tp_doc = "[temporary]"; > type->tp_init = my_init; > type->tp_dealloc = my_dealloc; > PyType_Ready(type); > PyModule_AddObject(module, "mytype", reinterpret_cast(type)); > } > ``` You're setting the deallocation function to 'my_dealloc', but that function isn't deallocating the object. Try something like this: static void my_dealloc(PyObject* obj) { PyObject_DEL(obj); } [snip] From stpasha at gmail.com Fri Oct 23 15:55:18 2020 From: stpasha at gmail.com (Pasha Stetsenko) Date: Fri, 23 Oct 2020 12:55:18 -0700 Subject: Debugging a memory leak In-Reply-To: <533067f0-25bb-19dc-775c-0fd871863a7f@mrabarnett.plus.com> References: <24467.5735.886299.105459@ixdm.fritz.box> <533067f0-25bb-19dc-775c-0fd871863a7f@mrabarnett.plus.com> Message-ID: Thanks MRAB, this was it. I guess I was thinking about tp_dealloc as a C++ destructor, where the base class' destructor is called automatically. On Fri, Oct 23, 2020 at 11:59 AM MRAB wrote: > On 2020-10-23 19:32, Pasha Stetsenko wrote: > > Thanks for all the replies! > > Following Chris's advice, I tried to reduce the code to the smallest > > reproducible example (I guess I should have done it sooner), > > but here's what I came up with: > > ``` > > #include > > #include > > > > static int my_init(PyObject*, PyObject*, PyObject*) { return 0; } > > static void my_dealloc(PyObject*) {} > > > > static void init_mytype(PyObject* module) { > > PyTypeObject* type = new PyTypeObject(); > > std::memset(type, 0, sizeof(PyTypeObject)); > > Py_INCREF(type); > > > > type->tp_basicsize = static_cast(sizeof(PyObject)); > > type->tp_itemsize = 0; > > type->tp_flags = Py_TPFLAGS_DEFAULT; > > type->tp_new = &PyType_GenericNew; > > type->tp_name = "mytype"; > > type->tp_doc = "[temporary]"; > > type->tp_init = my_init; > > type->tp_dealloc = my_dealloc; > > PyType_Ready(type); > > PyModule_AddObject(module, "mytype", > reinterpret_cast(type)); > > } > > ``` > > You're setting the deallocation function to 'my_dealloc', but that > function isn't deallocating the object. > > Try something like this: > > static void my_dealloc(PyObject* obj) { > PyObject_DEL(obj); > } > > [snip] > -- > https://mail.python.org/mailman/listinfo/python-list > From dieter at handshake.de Fri Oct 23 16:00:34 2020 From: dieter at handshake.de (Dieter Maurer) Date: Fri, 23 Oct 2020 22:00:34 +0200 Subject: Debugging a memory leak In-Reply-To: References: <24467.5735.886299.105459@ixdm.fritz.box> Message-ID: <24467.13922.384648.375575@ixdm.fritz.box> Pasha Stetsenko wrote at 2020-10-23 11:32 -0700: > ... > static int my_init(PyObject*, PyObject*, PyObject*) { return 0; } > static void my_dealloc(PyObject*) {} I think, the `dealloc` function is responsible to actually free the memory area. I see for example: static void Spec_dealloc(Spec* self) { /* PyType_GenericAlloc that you get when you don't specify a tp_alloc always tracks the object. */ PyObject_GC_UnTrack((PyObject *)self); if (self->weakreflist != NULL) { PyObject_ClearWeakRefs(OBJECT(self)); } Spec_clear(self); Py_TYPE(self)->tp_free(OBJECT(self)); } From grant.b.edwards at gmail.com Fri Oct 23 15:59:17 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 23 Oct 2020 19:59:17 -0000 (UTC) Subject: GUI (tkinter) popularity and job prospects for References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: On 2020-10-23, John Pote wrote: > On 23/10/2020 05:47, Grant Edwards wrote: >> >>> I think that commercial desktop applications with a python >>> compatible GUI would likely use QT or a Python binding thereof. >> Agreed. If you want to improve you "hirability" for GUI application >> development, I would probably put Qt first. Then gobject or >> wx. Tkinter would probably be last. > > I've used tkinter and wxPython occasionally in the past for 1 off test > tasks (and interest). What's the advantage of Qt? I think it may look/act more "native" than the others. It has also had good support for multiple platforms for a long time. For whatever reason, it seems to the more popular choice for commercially distributed Python apps. Getting Tkinter to look and act like a "native" app takes a lot of effort, and sometimes is just not possible. Distributing Tkinter apps is a PITA. Even trivial apps tend to turn into large bundles because you're including all of TCL with them. -- Grant From tjreedy at udel.edu Fri Oct 23 21:42:55 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 23 Oct 2020 21:42:55 -0400 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: On 10/23/2020 12:52 PM, John Pote wrote: > > On 23/10/2020 05:47, Grant Edwards wrote: >> >>> I think that commercial desktop applications with a python >>> compatible GUI would likely use QT or a Python binding thereof. >> Agreed. If you want to improve you "hirability" for GUI application >> development, I would probably put Qt first.? Then gobject or >> wx. Tkinter would probably be last. > > I've used tkinter and wxPython occasionally in the past for 1 off test > tasks (and interest). What's the advantage of Qt? For you usage, perhaps None. Qt is an *application* framework that includes a GUI module likely bigger than tkinter. Its non-GUI parts replace things other than tkinter in the stdlib or on pypi. -- Terry Jan Reedy From mkarkera98 at gmail.com Sat Oct 24 11:41:55 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Sat, 24 Oct 2020 21:11:55 +0530 Subject: Covariance matrix syntax In-Reply-To: <780fc283-d1e4-f7b6-3885-e0953b889c52@c2o.pro.br> References: <291564577.630412.1602564274535@mail.yahoo.com> <780fc283-d1e4-f7b6-3885-e0953b889c52@c2o.pro.br> Message-ID: Dear Sir Now I figured out why there was a difference when I manually computed covariance and when I use the np. cov syntax in python. The formula I used was ((yi-ymean)(yj-ymean))/n...unbiasdness. The formula np.cov uses is ((yi-ymean)(yj-ymean)) /n-1. Thanks Sincerely Meghna Raviraj Karkera On Mon, Oct 19, 2020, 21:30 Markos wrote: > Hi Meghna, > > I organized some tutorials about Machine Learning for Chemistry with > Python. > > Where you can find some info about the use of Covariance Matrix that may > help you. > > The originals are in Portugueese, but you can read using Google Translator: > > https://tinyurl.com/yybazx9n > > https://tinyurl.com/y29mule6 > > https://tinyurl.com/yxtg4tce > > Best Regards, > Markos > > Em 19-10-2020 02:23, Meghna Karkera escreveu: > > Dear Sir > > > > I am unable to find the *formula for covariance* used in np.cov syntax in > > PYTHON given in link > > https://numpy.org/doc/stable/reference/generated/numpy.cov.html. Could > you > > please help me out. > > > > Thanks > > Meghna > > > > On Tue, Oct 13, 2020 at 11:46 AM Christian Gollwitzer > > wrote: > > > >> Am 13.10.20 um 06:52 schrieb Meghna Karkera: > >>> Could you let me know what is the back end calculation of this > covariance > >>> matrix syntax np.cov > >>> > >> You can look it up yourself: Go to the docs > >> https://numpy.org/doc/stable/reference/generated/numpy.cov.html > >> > >> At the right hand side, just right of the function signature, there is a > >> link [source]. Click there and it takes you to the implementation. > >> > >> Apparently it is done in straightforward Python. > >> > >> Christian > >> > >> PS: Snipped a lot of unrelated citation at the bottom > >> > >>> On Tue, Oct 13, 2020, 10:14 Bruno P. Kinoshita < > >> brunodepaulak at yahoo.com.br> > >>> wrote: > >>> [...] > >>>> I think the np.cov is from the numpy module (imported/aliased as np?). > >> -- > >> https://mail.python.org/mailman/listinfo/python-list > >> > > -- > https://mail.python.org/mailman/listinfo/python-list > From mkarkera98 at gmail.com Sat Oct 24 11:49:42 2020 From: mkarkera98 at gmail.com (Meghna Karkera) Date: Sat, 24 Oct 2020 21:19:42 +0530 Subject: Covariance matrix syntax In-Reply-To: References: <291564577.630412.1602564274535@mail.yahoo.com> <780fc283-d1e4-f7b6-3885-e0953b889c52@c2o.pro.br> Message-ID: Is there any syntax for covariance which uses the unbiased formula (yi-ymean)*(yj-ymean) /n...Monte Carlo method On Sat, Oct 24, 2020, 21:11 Meghna Karkera wrote: > Dear Sir > > Now I figured out why there was a difference when I manually computed > covariance and when I use the np. cov syntax in python. > > The formula I used was ((yi-ymean)(yj-ymean))/n...unbiasdness. > > > The formula np.cov uses is ((yi-ymean)(yj-ymean)) /n-1. > > Thanks > > Sincerely > Meghna Raviraj Karkera > > On Mon, Oct 19, 2020, 21:30 Markos wrote: > >> Hi Meghna, >> >> I organized some tutorials about Machine Learning for Chemistry with >> Python. >> >> Where you can find some info about the use of Covariance Matrix that may >> help you. >> >> The originals are in Portugueese, but you can read using Google >> Translator: >> >> https://tinyurl.com/yybazx9n >> >> https://tinyurl.com/y29mule6 >> >> https://tinyurl.com/yxtg4tce >> >> Best Regards, >> Markos >> >> Em 19-10-2020 02:23, Meghna Karkera escreveu: >> > Dear Sir >> > >> > I am unable to find the *formula for covariance* used in np.cov syntax >> in >> > PYTHON given in link >> > https://numpy.org/doc/stable/reference/generated/numpy.cov.html. >> Could you >> > please help me out. >> > >> > Thanks >> > Meghna >> > >> > On Tue, Oct 13, 2020 at 11:46 AM Christian Gollwitzer >> > wrote: >> > >> >> Am 13.10.20 um 06:52 schrieb Meghna Karkera: >> >>> Could you let me know what is the back end calculation of this >> covariance >> >>> matrix syntax np.cov >> >>> >> >> You can look it up yourself: Go to the docs >> >> https://numpy.org/doc/stable/reference/generated/numpy.cov.html >> >> >> >> At the right hand side, just right of the function signature, there is >> a >> >> link [source]. Click there and it takes you to the implementation. >> >> >> >> Apparently it is done in straightforward Python. >> >> >> >> Christian >> >> >> >> PS: Snipped a lot of unrelated citation at the bottom >> >> >> >>> On Tue, Oct 13, 2020, 10:14 Bruno P. Kinoshita < >> >> brunodepaulak at yahoo.com.br> >> >>> wrote: >> >>> [...] >> >>>> I think the np.cov is from the numpy module (imported/aliased as >> np?). >> >> -- >> >> https://mail.python.org/mailman/listinfo/python-list >> >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From Marco.Sulla.Python at gmail.com Sat Oct 24 18:19:01 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Sun, 25 Oct 2020 00:19:01 +0200 Subject: Covariance matrix syntax In-Reply-To: References: <291564577.630412.1602564274535@mail.yahoo.com> <780fc283-d1e4-f7b6-3885-e0953b889c52@c2o.pro.br> Message-ID: If you read the documentation, there's a `bias` bool parameter. From greg.ewing at canterbury.ac.nz Sat Oct 24 19:08:59 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 25 Oct 2020 12:08:59 +1300 Subject: Covariance matrix syntax In-Reply-To: References: <291564577.630412.1602564274535@mail.yahoo.com> <780fc283-d1e4-f7b6-3885-e0953b889c52@c2o.pro.br> Message-ID: On 25/10/20 4:49 am, Meghna Karkera wrote: > Is there any syntax for covariance which uses the unbiased formula > (yi-ymean)*(yj-ymean) /n...Monte Carlo method I think you have "biased" and "unbiased" backwards. The formula with n-1 is used when you want to calculate an *unbiased* estimate for a population given a sample of that population. The formula with n is used when your data consists of the entire population. Which situation do you have? (I think the "bias" parameter to numpy.cov is badly named, btw. If you're using it appropriately, setting biased=True does *not* make your result biased -- quite the contrary!) -- Greg From Gronicus at SGA.Ninja Sat Oct 24 19:21:55 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sat, 24 Oct 2020 19:21:55 -0400 Subject: Is there a log file that tracks every statement that is being executed when a program is running? Message-ID: <06fe01d6aa5c$77572000$66056000$@SGA.Ninja> This would seriously help troubleshooting for me. I updated a data file and now my main program is choking on it. When the program encounters an error, it dumps a bit of information to the screen for a few steps before the error but that is not enough. Footnote: English sprakers on a roller coaster: "Weeee" Spanish speakers on a rollercoaster: " Nosostros" -----Original Message----- From: Python-list On Behalf Of shrimp_banana Sent: Saturday, October 17, 2020 9:47 PM To: python-list at python.org Subject: Re: File Name issue On 10/17/20 4:12 PM, Steve wrote: > The line: > with open("HOURLYLOG.txt", 'r') as infile: > works but, when I rename the file, the line: > with open("HOURLY-LOG.txt", 'r') as infile: > does not. The complaint is: Cannot Assign to operator > > However, I have: > BPM_O2s=open("BPM-O2-Readings.txt","a") > And it works. > > At first, I thought the issue was due to having the - in the filename. > > Is there a fix or explanation for this? > Steve I am unsure if this will help but you could try putting an r in front of the quotes to make it take raw data only. ie. with open(r"HOURLY-LOG.txt", 'r') as infile -- https://mail.python.org/mailman/listinfo/python-list From python at mrabarnett.plus.com Sat Oct 24 19:50:49 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 25 Oct 2020 00:50:49 +0100 Subject: Is there a log file that tracks every statement that is being executed when a program is running? In-Reply-To: <06fe01d6aa5c$77572000$66056000$@SGA.Ninja> References: <06fe01d6aa5c$77572000$66056000$@SGA.Ninja> Message-ID: On 2020-10-25 00:21, Steve wrote: > This would seriously help troubleshooting for me. I updated a data file and > now my main program is choking on it. When the program encounters an error, > it dumps a bit of information to the screen for a few steps before the error > but that is not enough. > You could install Visual Studio Code and the extension for Python. That will let you single-step through the code. From maxischmeii at gmail.com Sun Oct 25 07:14:52 2020 From: maxischmeii at gmail.com (Maxime S) Date: Sun, 25 Oct 2020 12:14:52 +0100 Subject: Is there a log file that tracks every statement that is being executed when a program is running? In-Reply-To: <06fe01d6aa5c$77572000$66056000$@SGA.Ninja> References: <06fe01d6aa5c$77572000$66056000$@SGA.Ninja> Message-ID: Hi, You can use the trace module for that: https://docs.python.org/3.8/library/trace.html Personally I tend to put print statement at strategic places instead, I find that easier to analyse than a full trace but YMMV. Maxime Le dim. 25 oct. 2020 ? 01:25, Steve a ?crit : > This would seriously help troubleshooting for me. I updated a data file > and > now my main program is choking on it. When the program encounters an > error, > it dumps a bit of information to the screen for a few steps before the > error > but that is not enough. > > > > > Footnote: > English sprakers on a roller coaster: "Weeee" > Spanish speakers on a rollercoaster: " Nosostros" > > -----Original Message----- > From: Python-list On > Behalf Of shrimp_banana > Sent: Saturday, October 17, 2020 9:47 PM > To: python-list at python.org > Subject: Re: File Name issue > > On 10/17/20 4:12 PM, Steve wrote: > > The line: > > with open("HOURLYLOG.txt", 'r') as infile: > > works but, when I rename the file, the line: > > with open("HOURLY-LOG.txt", 'r') as infile: > > does not. The complaint is: Cannot Assign to operator > > However, I > have: > > BPM_O2s=open("BPM-O2-Readings.txt","a") > > And it works. > > > > At first, I thought the issue was due to having the - in the filename. > > > > Is there a fix or explanation for this? > > Steve > > I am unsure if this will help but you could try putting an r in front of > the > quotes to make it take raw data only. > ie. > > with open(r"HOURLY-LOG.txt", 'r') as infile > -- > https://mail.python.org/mailman/listinfo/python-list > > -- > https://mail.python.org/mailman/listinfo/python-list > From Gronicus at SGA.Ninja Sun Oct 25 12:47:26 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sun, 25 Oct 2020 12:47:26 -0400 Subject: Is there a log file that tracks every statement that is being executed when a program is running? In-Reply-To: References: <06fe01d6aa5c$77572000$66056000$@SGA.Ninja> Message-ID: <077501d6aaee$85998ee0$90ccaca0$@SGA.Ninja> Yes, I have been doing this already. I include the line number to help me find, or search for, the location of the print statement. Unfortunately, it requires a keen understanding in which the program has progressed in order to trace. A printout of every line number executed could help. FootNote: If money does not grow on trees, then why do banks have branches? From: Maxime S Sent: Sunday, October 25, 2020 7:15 AM To: Steve Cc: Python Subject: Re: Is there a log file that tracks every statement that is being executed when a program is running? Hi, You can use the trace module for that: https://docs.python.org/3.8/library/trace.html Personally I tend to put print statement at strategic places instead, I find that easier to analyse than a full trace but YMMV. Maxime Le dim. 25 oct. 2020 ? 01:25, Steve > a ?crit : This would seriously help troubleshooting for me. I updated a data file and now my main program is choking on it. When the program encounters an error, it dumps a bit of information to the screen for a few steps before the error but that is not enough. Footnote: English sprakers on a roller coaster: "Weeee" Spanish speakers on a rollercoaster: " Nosostros" -----Original Message----- From: Python-list > On Behalf Of shrimp_banana Sent: Saturday, October 17, 2020 9:47 PM To: python-list at python.org Subject: Re: File Name issue On 10/17/20 4:12 PM, Steve wrote: > The line: > with open("HOURLYLOG.txt", 'r') as infile: > works but, when I rename the file, the line: > with open("HOURLY-LOG.txt", 'r') as infile: > does not. The complaint is: Cannot Assign to operator > > However, I have: > BPM_O2s=open("BPM-O2-Readings.txt","a") > And it works. > > At first, I thought the issue was due to having the - in the filename. > > Is there a fix or explanation for this? > Steve I am unsure if this will help but you could try putting an r in front of the quotes to make it take raw data only. ie. with open(r"HOURLY-LOG.txt", 'r') as infile -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list From barry at barrys-emacs.org Sun Oct 25 15:25:37 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Sun, 25 Oct 2020 19:25:37 +0000 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: > On 23 Oct 2020, at 17:52, John Pote wrote: > > > On 23/10/2020 05:47, Grant Edwards wrote: >> >>> I think that commercial desktop applications with a python >>> compatible GUI would likely use QT or a Python binding thereof. >> Agreed. If you want to improve you "hirability" for GUI application >> development, I would probably put Qt first. Then gobject or >> wx. Tkinter would probably be last. Agreed. > > I've used tkinter and wxPython occasionally in the past for 1 off test tasks (and interest). What's the advantage of Qt? I have not looked at tk for a very long time, cannot comment on it. I used to use wxPython but ported all my code to PyQt. They took too long to get to python 3 support. PyQt has far fewer platform specific behaviours that need working around than wxPython does (did?). It should be noted that the developer of PyQt does it as his job, so there is enough work to keep him well payed. Barry > > John > > -- > https://mail.python.org/mailman/listinfo/python-list > From hjp-python at hjp.at Sun Oct 25 15:48:35 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 25 Oct 2020 20:48:35 +0100 Subject: Question on ABC classes In-Reply-To: <7a6a90a2-4ba9-4556-a0ee-cf715d6db692o@googlegroups.com> References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> <7a6a90a2-4ba9-4556-a0ee-cf715d6db692o@googlegroups.com> Message-ID: <20201025194835.GA20782@hjp.at> On 2020-10-22 23:35:21 -0700, Julio Di Egidio wrote: > On Friday, 23 October 2020 07:36:39 UTC+2, Greg Ewing wrote: > > On 23/10/20 2:13 pm, Julio Di Egidio wrote: > > > I am now thinking whether I could achieve the "standard" > > > behaviour via another approach, say with decorators, somehow > > > intercepting calls to __new__... maybe. > > > > I'm inclined to step back and ask -- why do you care about this? > > > > Would it actually do any harm if someone instantiated your > > base class? If not, then it's probably not worth going out > > of your way to prevent it. > > This is the first little library I try to put together > in Python, and it was natural for me to hit it with all > the relevant decorations as well as type annotations in > order to expose *strict* contracts, plus hopefully have > intellisense work all over the place. I think you are trying to use Python in a way contrary to its nature. Python is a dynamically typed language. Its variables don't have types, only its objects. And basically everything can be changed at runtime ... It now has type annotations, but they are ignored both by the compiler and at run-time. They are only for the benefit of linting tools like mypy and editor features like intellisense. > and the whole lot, indeed why even subclass ABC? Good question. In six years of programming Python, I've never used ABC. But then I came from another dynamically typed language to Python. 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 mgogala at yahoo.com Sun Oct 25 17:58:41 2020 From: mgogala at yahoo.com (Mladen Gogala) Date: Sun, 25 Oct 2020 21:58:41 -0000 (UTC) Subject: Is there a log file that tracks every statement that is being executed when a program is running? References: <06fe01d6aa5c$77572000$66056000$@SGA.Ninja> Message-ID: On Sun, 25 Oct 2020 12:14:52 +0100, Maxime S wrote: > Hi, > > You can use the trace module for that: > https://docs.python.org/3.8/library/trace.html > > Personally I tend to put print statement at strategic places instead, I > find that easier to analyse than a full trace but YMMV. > > Maxime Thank you. I am a YAPN (yet another Python newbie) and this helps me a lot. -- Mladen Gogala Database Consultant http://mgogala.byethost5.com From gay at sfu.ca Sun Oct 25 20:13:42 2020 From: gay at sfu.ca (Ian Gay) Date: Sun, 25 Oct 2020 17:13:42 -0700 Subject: _pydoc.css Message-ID: The default colors of pydoc are truly horrendous! Has anyone written a _pydoc.css file to produce something reasonable? (running 3.6 on OpenSuse 15.1) Ian -- *********** To reply by e-mail, make w single in address ************** From edmondo.giovannozzi at gmail.com Mon Oct 26 12:03:05 2020 From: edmondo.giovannozzi at gmail.com (Edmondo Giovannozzi) Date: Mon, 26 Oct 2020 09:03:05 -0700 (PDT) Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: Il giorno venerd? 23 ottobre 2020 alle 18:55:53 UTC+2 john... ha scritto: > On 23/10/2020 05:47, Grant Edwards wrote: > > > >> I think that commercial desktop applications with a python > >> compatible GUI would likely use QT or a Python binding thereof. > > Agreed. If you want to improve you "hirability" for GUI application > > development, I would probably put Qt first. Then gobject or > > wx. Tkinter would probably be last. > I've used tkinter and wxPython occasionally in the past for 1 off test > tasks (and interest). What's the advantage of Qt? > > John I use PyQt in research application, there is a library pyqtgraph (http://www.pyqtgraph.org/) based on Qt that is very fast, you can zoom and pan even complicated plots, it is much faster than matplotlib. For me, the graphic makes the difference. From dieter at handshake.de Mon Oct 26 12:35:02 2020 From: dieter at handshake.de (Dieter Maurer) Date: Mon, 26 Oct 2020 17:35:02 +0100 Subject: Question on ABC classes In-Reply-To: <20201025194835.GA20782@hjp.at> References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> <7a6a90a2-4ba9-4556-a0ee-cf715d6db692o@googlegroups.com> <20201025194835.GA20782@hjp.at> Message-ID: <24470.64182.79200.605062@ixdm.fritz.box> Peter J. Holzer wrote at 2020-10-25 20:48 +0100: >On 2020-10-22 23:35:21 -0700, Julio Di Egidio wrote: > ... >> and the whole lot, indeed why even subclass ABC? You often have the case that a base class can implement a lot of functionality based on a few methods defined by derived classes. An example is a mapping class (with methods such as keys, values, items, iteration, subscription, ...). All those methods can be implemented generically based on "__len__", "__iter__", "__getitem__" and "__getitem__". In those cases, you can decorate the base methods with `abstractmethod`. Formerly, you had `raise NotImplementedError` in the body of those methods. If a derived class forgot to implement a required method, the exception was raised as soon as the method was called. With `abstractmethod` you see the problem earlier. From urayushmishra at gmail.com Mon Oct 26 08:19:38 2020 From: urayushmishra at gmail.com (Ayush Mishra) Date: Mon, 26 Oct 2020 17:49:38 +0530 Subject: Regarding the issue I had faced In-Reply-To: <5f96bb63.1c69fb81.51de2.4bc8@mx.google.com> References: <5f96bb63.1c69fb81.51de2.4bc8@mx.google.com> Message-ID: <5f96bec9.1c69fb81.7ced7.a480@mx.google.com> Hi I would to like to say that Python is a very good language with a vast area of application and an easy way to start for the beginner. I am also a beginner and I am very much comfortable with syntax of Python. Now coming to my problem. Say for example if I have created a n HTML file and want to edit it in Brackets , I will right on the file and select the option ? Edit with Bracket? . We also have a similar thing in IDLE too , when we right click on .py file we get the option ? Edit with IDLE? comes but I don?t get that option on right clicking .py file . One more hint regarding the problem I mentioned is that when I select the repair option in ?Python Setup window a dialog box appears stating ? Ensure you have access to ? ? . I am using Windows 10 Home 64-bit (Specification of my laptop) , I hope it will help. Please contact me on the same email id to help me resolve the issue . I would be very much thankful to developer team for the help from your side. Sent from Mail for Windows 10 From maillist at schwertberger.de Mon Oct 26 14:51:59 2020 From: maillist at schwertberger.de (Dietmar Schwertberger) Date: Mon, 26 Oct 2020 19:51:59 +0100 Subject: GUI (tkinter) popularity and job prospects for In-Reply-To: References: <12f6ae3e-7f84-4ffb-a183-183e98ee91ean@googlegroups.com> Message-ID: On 23.10.2020 18:52, John Pote wrote: > I've used tkinter and wxPython occasionally in the past for 1 off test > tasks (and interest). What's the advantage of Qt? Qt does support mobile and touch oriented user interfaces. Also, it does support GUI programs on microcontrollers now on bare-metal. Desktop development has long moved out of the focus of the Qt company. (This shift dates back to the time when Nokia was the owner.) Just have a look at their start page and you know the focus. Qt company is living from expensive industry licenses. Providing frees solutions to the open source community is not the core business. Qt still supports traditional desktop development in form of Qt Widgets, but there's pressure to move to QML. This is more comparable to the HTML/CSS/Javascript approach. Personally I would not want to go that way for desktop applications. The traditional single-language approach with API and debugger seems much more straightforward and time-saving. For many types of desktop applications I would just recommend wxPython, together with wxGlade as a GUI builder. This will provide a quick start and high productivity for many tasks. That's another point: Qt Designer is recognized as one of the most advanced GUI builders, but when you actually want to use it with Python it does not really help you much. Using it is too complicated for the beginner or casual user and for the advanced user it's easier to avoid it completely. Regards Dietmar From gri6507 at gmail.com Tue Oct 27 15:21:36 2020 From: gri6507 at gmail.com (Paul Grinberg) Date: Tue, 27 Oct 2020 12:21:36 -0700 (PDT) Subject: Python extension module with callbacks into Python Message-ID: <998974a7-c468-4eb9-bf70-b881e18af0a7n@googlegroups.com> As full disclosure, I posted this question on StackOverflow as well, but it looks like questions with [Python] [Extension-Module] tags are not frequently answered. The link to my question there is https://stackoverflow.com/questions/64559322/python-extension-module-with-callbacks-into-python I am running into unpredictable behavior with my Python extension module that wraps around a C++ library that starts a new pthread and, after doing some work, generates callbacks back into the caller. I've greatly simplified this to a simplistic example which still demonstrates this problem. The following will sometimes generate a Fatal Python error: PyEval_SaveThread: NULL tstate, usually rather quickly. Sometimes it SIGSEGV on tupledealoc. Occasionally this deadlocks. I am at a loss why. Does anyone have any ideas? The relevant code for this is below, between the ==== sections ==== === python program === import mymod from time import sleep from random import randrange def my_cb1(s): print("Python cb %s" % (s)); for x in range(1,1000): num_cb = randrange(5) + 1 print("Starting %d" % mymod.doit(my_cb1, "myid" + str(x), num_cb)) while True: sleep(1) === Extension Module === #include #define PY_SSIZE_T_CLEAN #include #include #include #include #include #include #include #include static std::map cb_map; static std::mutex map_mtx; struct fake_cb_info { fake_cb_info() = delete; fake_cb_info(const unsigned long &num_cb, const std::string &id) : num_cb(num_cb), id(id) { } const unsigned long num_cb; const std::string id; }; static std::deque deq; static std::mutex deq_mtx; static bool is_worker_thread_running = false; static std::thread worker_thread; typedef std::function doit_cb_t; static void internal_cb(const std::string &id, const std::string &s) { std::scoped_lock lk(map_mtx); if (0 != cb_map.count(id)) { PyGILState_STATE gstate; gstate = PyGILState_Ensure(); PyObject *arglist = Py_BuildValue("(s)", s.c_str()); PyObject *result = PyObject_CallObject(cb_map.at(id), arglist); Py_DECREF(arglist); if (NULL == result) { if (NULL == PyErr_Occurred()) { std::cerr << "Unknown error occurred in C callback" << std::endl; } else { PyErr_Print(); } } else { Py_DECREF(result); } PyGILState_Release(gstate); } else { std::cerr << "Unknown callback id " << id << std::endl; } } void static worker() { size_t x = 0; while(true) { std::scoped_lock lk(deq_mtx); if (deq.size() == 0) { usleep(1000); continue; } auto info = deq.front(); deq.pop_front(); for (unsigned long i=0; i lk(map_mtx); if (0 == cb_map.count(id_std)) { Py_INCREF(cb); cb_map.insert(std::make_pair(id_std, cb)); // N.B. The corresponding Py_DECREF for the callback function PyObject // is intentionally not here. It is in another extension module method // that is not listed here (just trying to keep this example as small // and lean as possible) } else { std::cerr << "Only one callback for ID!" << std::endl; abort(); } } if (PyEval_ThreadsInitialized ()) { std::cout << "Saving thread" << std::endl; py_thread_state = PyEval_SaveThread(); } { // Stash away the info so that we will know how many callbacks to // generate and sleep a bit. This is to simulate a real external library // doing work which will, in turn, generate callbacks struct fake_cb_info info(num_callbacks, id_std); std::scoped_lock lk(deq_mtx); deq.push_back(info); if (!is_worker_thread_running) { std::cout << "@@@@ Creating a new thread\n"; worker_thread = std::thread(&worker); pthread_setname_np(worker_thread.native_handle(), "worker_thread"); worker_thread.detach(); is_worker_thread_running = true; } usleep(10000); } if (py_thread_state) { std::cout << "Restoring thread" << std::endl; PyEval_RestoreThread(py_thread_state); } py_retval = Py_BuildValue((char *) "k", num_callbacks); return py_retval; } static PyMethodDef mymod_functions[] = { { (char *) "doit", (PyCFunction) _wrap_doit, METH_KEYWORDS | METH_VARARGS, "Generate requested number of multi-threaded callbacks.\n doit(callback_fn, id, num_callbacks)" }, {NULL, NULL, 0, NULL} }; static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "mymod", "pthread test module", -1, mymod_functions, }; #define MOD_ERROR NULL #define MOD_INIT(name) PyObject* PyInit_##name(void) #define MOD_RETURN(val) val #if defined(__cplusplus) extern "C" #endif #if defined(__GNUC__) && __GNUC__ >= 4 __attribute__ ((visibility("default"))) #endif MOD_INIT(mymod) { PyObject *m = PyModule_Create(&moduledef); if (m == NULL) { return MOD_ERROR; } return MOD_RETURN(m); } From barry at barrys-emacs.org Wed Oct 28 08:23:22 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Wed, 28 Oct 2020 12:23:22 +0000 Subject: Python extension module with callbacks into Python In-Reply-To: <998974a7-c468-4eb9-bf70-b881e18af0a7n@googlegroups.com> References: <998974a7-c468-4eb9-bf70-b881e18af0a7n@googlegroups.com> Message-ID: > On 27 Oct 2020, at 19:21, Paul Grinberg wrote: > > As full disclosure, I posted this question on StackOverflow as well, but it looks like questions with [Python] [Extension-Module] tags are not frequently answered. The link to my question there is https://stackoverflow.com/questions/64559322/python-extension-module-with-callbacks-into-python > > I am running into unpredictable behavior with my Python extension module that wraps around a C++ library that starts a new pthread and, after doing some work, generates callbacks back into the caller. I've greatly simplified this to a simplistic example which still demonstrates this problem. The following will sometimes generate a Fatal Python error: PyEval_SaveThread: NULL tstate, usually rather quickly. Sometimes it SIGSEGV on tupledealoc. Occasionally this deadlocks. I am at a loss why. Does anyone have any ideas? You did not say what OS and python version you are working with. Why do you need to call PyEval_ThreadsInitialized()? its deprecated. PyInitialize sets up threads unconditionally since 3.7. When I have been in a similar situation I have used the debugger to find out what the CPYTHON code is expecting and worked backwards from there. Reading the python sources helps a lot. Barry > > The relevant code for this is below, between the ==== sections ==== > > === python program === > > import mymod > from time import sleep > from random import randrange > > def my_cb1(s): > print("Python cb %s" % (s)); > > for x in range(1,1000): > num_cb = randrange(5) + 1 > print("Starting %d" % mymod.doit(my_cb1, "myid" + str(x), num_cb)) > > while True: > sleep(1) > > === Extension Module === > > #include > > #define PY_SSIZE_T_CLEAN > #include > #include > > #include > #include > #include > #include > #include > #include > > static std::map cb_map; > static std::mutex map_mtx; > > struct fake_cb_info > { > fake_cb_info() = delete; > fake_cb_info(const unsigned long &num_cb, const std::string &id) : > num_cb(num_cb), id(id) > { > } > const unsigned long num_cb; > const std::string id; > }; > static std::deque deq; > static std::mutex deq_mtx; > > static bool is_worker_thread_running = false; > static std::thread worker_thread; > > typedef std::function doit_cb_t; > static void internal_cb(const std::string &id, const std::string &s) > { > std::scoped_lock lk(map_mtx); > > if (0 != cb_map.count(id)) > { > PyGILState_STATE gstate; > gstate = PyGILState_Ensure(); > > PyObject *arglist = Py_BuildValue("(s)", s.c_str()); > PyObject *result = PyObject_CallObject(cb_map.at(id), arglist); > Py_DECREF(arglist); > > if (NULL == result) > { > if (NULL == PyErr_Occurred()) > { > std::cerr << "Unknown error occurred in C callback" << std::endl; > } > else > { > PyErr_Print(); > } > } > else > { > Py_DECREF(result); > } > > PyGILState_Release(gstate); > } > else > { > std::cerr << "Unknown callback id " << id << std::endl; > } > } > > void static worker() > { > size_t x = 0; > while(true) > { > std::scoped_lock lk(deq_mtx); > if (deq.size() == 0) > { > usleep(1000); > continue; > } > > auto info = deq.front(); > deq.pop_front(); > for (unsigned long i=0; i { > internal_cb(info.id, std::to_string(x++)); > } > } > } > > PyObject * _wrap_doit(void *self, PyObject *args, PyObject *kwargs) > { > PyObject *py_retval; > PyThreadState *py_thread_state = NULL; > PyObject *cb; > const char *id = NULL; > Py_ssize_t id_len; > std::string id_std; > unsigned long num_callbacks; > const char *keywords[] = {"cb_func", "id", "num_cb", NULL}; > > if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Os#k", (char **) keywords, &cb, &id, &id_len, &num_callbacks)) > { > abort(); > } > if (!PyCallable_Check(cb)) > { > abort(); > } > > id_std = std::string(id, id_len); > > { > std::scoped_lock lk(map_mtx); > if (0 == cb_map.count(id_std)) > { > Py_INCREF(cb); > cb_map.insert(std::make_pair(id_std, cb)); > > // N.B. The corresponding Py_DECREF for the callback function PyObject > // is intentionally not here. It is in another extension module method > // that is not listed here (just trying to keep this example as small > // and lean as possible) > } > else > { > std::cerr << "Only one callback for ID!" << std::endl; > abort(); > } > } > > if (PyEval_ThreadsInitialized ()) > { > std::cout << "Saving thread" << std::endl; > py_thread_state = PyEval_SaveThread(); > } > > { > // Stash away the info so that we will know how many callbacks to > // generate and sleep a bit. This is to simulate a real external library > // doing work which will, in turn, generate callbacks > struct fake_cb_info info(num_callbacks, id_std); > std::scoped_lock lk(deq_mtx); > deq.push_back(info); > > if (!is_worker_thread_running) > { > std::cout << "@@@@ Creating a new thread\n"; > worker_thread = std::thread(&worker); > pthread_setname_np(worker_thread.native_handle(), "worker_thread"); > worker_thread.detach(); > is_worker_thread_running = true; > } > > usleep(10000); > } > > if (py_thread_state) > { > std::cout << "Restoring thread" << std::endl; > PyEval_RestoreThread(py_thread_state); > } > > py_retval = Py_BuildValue((char *) "k", num_callbacks); > return py_retval; > } > > static PyMethodDef mymod_functions[] = { > { > (char *) "doit", > (PyCFunction) _wrap_doit, > METH_KEYWORDS | METH_VARARGS, > "Generate requested number of multi-threaded callbacks.\n doit(callback_fn, id, num_callbacks)" > }, > {NULL, NULL, 0, NULL} > }; > > static struct PyModuleDef moduledef = { > PyModuleDef_HEAD_INIT, > "mymod", > "pthread test module", > -1, > mymod_functions, > }; > > #define MOD_ERROR NULL > #define MOD_INIT(name) PyObject* PyInit_##name(void) > #define MOD_RETURN(val) val > > #if defined(__cplusplus) > extern "C" > #endif > > #if defined(__GNUC__) && __GNUC__ >= 4 > __attribute__ ((visibility("default"))) > #endif > > > MOD_INIT(mymod) > { > PyObject *m = PyModule_Create(&moduledef); > if (m == NULL) { > return MOD_ERROR; > } > return MOD_RETURN(m); > } > -- > https://mail.python.org/mailman/listinfo/python-list > From kjk562 at gmail.com Wed Oct 28 08:49:37 2020 From: kjk562 at gmail.com (ktkelly_1) Date: Wed, 28 Oct 2020 05:49:37 -0700 (PDT) Subject: Live Write to File with Code That is Reading File and Writing to Serial Port Message-ID: <2d1a28e5-9310-4fb4-b575-975651e846f6n@googlegroups.com> Currently have a code that takes in a .txt file and submits commands to the serial. Then it reads the reply from the serial port and writes it to a hardcoded .txt file. The problem is it doesn't save it live and so if I need to stop the code for any reason, I can't gather current data and the text file is blank. I'm not as familiar with buffering and things like that and tried "outputFile = open("./outputFile.txt", "a", 0)" but that gave me the error "can't have an unbuffered text I/O? in python 3?" so I'm not sure what to do. Here is the general layout if you would like to mess around with it: with open(test_file) as file_test: Lines = file_test.readlines() for line in Lines: #send_str is the command to send to the serial port send_str = line file_result.write(line + "\n") #<--- if I were to cancel out after this it wouldn't be saved(*) ser.write(send_str.encode('utf-8')) time.sleep(send_pause) reply_str = ser.readline().decode('utf-8').strip() file_result.write("reply:" + reply_str + "\n") #<---(*) file_result.write('\n') #<---(*) anything helps thank you in advanced From albert at cherry. Wed Oct 28 09:21:27 2020 From: albert at cherry. (none albert) Date: 28 Oct 2020 13:21:27 GMT Subject: Symlinks already present References: <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: <5f997057$0$297$e4fe514c@news.xs4all.nl> In article , Grant Edwards wrote: >On 2020-09-01, Richard Damon wrote: > >> Remember, we are talking about a hypothetical OS that handles hardlinks >> to directories, and defines that .. will point to the parent used to >> come to it, NOT just having current *NIX allowing hardlinks to >> directories with no remediation of the issues cause. > >I can testify from personal experience that SunOS 3/4 was in the >latter category. After creating a hard-link to a directory, things >like fsck and the filesystem dump backup utility got very upset and >confused. IIRC the only way to recover was to nuke the involved >inodes then let fsck try to pick up the pieces and put them in the >lost+found. IIRC, I managed to recover without losing any files, but >it wasn't a fun day. It was a defect ("bug") in the SUNOS that this was possible. So reread this thread. "Let us imagine the situation that a severe, known defect was reintroduced in linux, just for the fun of it." > >-- >Grant Groetjes Albert -- This is the first day of the end of your life. It may not kill you, but it does make your weaker. If you can't beat them, too bad. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From gri6507 at gmail.com Wed Oct 28 09:25:41 2020 From: gri6507 at gmail.com (Paul Grinberg) Date: Wed, 28 Oct 2020 06:25:41 -0700 (PDT) Subject: Python extension module with callbacks into Python In-Reply-To: References: <998974a7-c468-4eb9-bf70-b881e18af0a7n@googlegroups.com> Message-ID: <565582df-8de9-4055-ab53-15ceaae4291an@googlegroups.com> > > I am running into unpredictable behavior with my Python extension module that wraps around a C++ library that starts a new pthread and, after doing some work, generates callbacks back into the caller. I've greatly simplified this to a simplistic example which still demonstrates this problem. The following will sometimes generate a Fatal Python error: PyEval_SaveThread: NULL tstate, usually rather quickly. Sometimes it SIGSEGV on tupledealoc. Occasionally this deadlocks. I am at a loss why. Does anyone have any ideas? > You did not say what OS and python version you are working with. I apologize. I am running this on Ubuntu 18.04 under Python 3.6 (default for this Ubuntu's Bionic release) fully updated to the latest provided by Ubuntu's standard repos, which is 3.6.9-1~18.04ubuntu1.3. After posting this question here I continued investigating this problem and found that when I repeat the same test under Python 3.7.3 or 3.8.5 (installed via PyEnv), there are no issues. Then, I went back to the most recent 3.6 release which is 3.6.12 (also installed via PyEnv) and again saw the issue. This seems to suggest that the problem is in 3.6.x Python. > Why do you need to call PyEval_ThreadsInitialized()? its deprecated. > > PyInitialize sets up threads unconditionally since 3.7. I did not realize that PyEval_ThreadsInitialized() is deprecated. However, I was also running under 3.6. I will move away from that once I move to a newer version of Python From albert at cherry. Wed Oct 28 09:12:35 2020 From: albert at cherry. (none albert) Date: 28 Oct 2020 13:12:35 GMT Subject: Symlinks already present References: <20200831072635.GA27335@cskk.homeip.net> Message-ID: <5f996e43$0$297$e4fe514c@news.xs4all.nl> In article , Cameron Simpson wrote: > >Yeah, makes me ill. That's because these days "pwd" is usually a shell >builtin with funny semantics and a cache/sanity=check against $PWD >(which gets computed as you cd around, typically). And if has a -P >option and friends explicitly because of this hideous stuff. Would you be a fan of nash , the Never Again so complicated SHell ? The base idea that it is a Forth interpreter that has a few shell like features tucked onto it, like executing programs. And if you type pwd, sure as hell it would look through $PATH and execute the exact program you want. (You could defined `pwd' in the interpreter yourself to do something different. If you do that, probably you want it.) > >Cheers, >Cameron Simpson Groetjes Albert -- This is the first day of the end of your life. It may not kill you, but it does make your weaker. If you can't beat them, too bad. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From klsshaeffer at icloud.com Wed Oct 28 10:58:31 2020 From: klsshaeffer at icloud.com (Karen Shaeffer) Date: Wed, 28 Oct 2020 07:58:31 -0700 Subject: Live Write to File with Code That is Reading File and Writing to Serial Port In-Reply-To: <2d1a28e5-9310-4fb4-b575-975651e846f6n@googlegroups.com> References: <2d1a28e5-9310-4fb4-b575-975651e846f6n@googlegroups.com> Message-ID: <3930D94C-90DD-4855-B358-B74A154E6C99@icloud.com> > On Oct 28, 2020, at 5:49 AM, ktkelly_1 wrote: > > Currently have a code that takes in a .txt file and submits commands to the serial. Then it reads the reply from the serial port and writes it to a hardcoded .txt file. The problem is it doesn't save it live and so if I need to stop the code for any reason, I can't gather current data and the text file is blank. I'm not as familiar with buffering and things like that and tried "outputFile = open("./outputFile.txt", "a", 0)" but that gave me the error "can't have an unbuffered text I/O? in python 3?" so I'm not sure what to do. Here is the general layout if you would like to mess around with it: from os import fsync > with open(test_file) as file_test: > Lines = file_test.readlines() > for line in Lines: > #send_str is the command to send to the serial port > send_str = line > file_result.write(line + "\n") #<--- if I were to cancel out after this it wouldn't be saved(*) file_result.flush() os.fsync() > > ser.write(send_str.encode('utf-8')) > time.sleep(send_pause) > reply_str = ser.readline().decode('utf-8').strip() > file_result.write("reply:" + reply_str + "\n") #<---(*) > file_result.write('\n') #<---(*) file_result.flush() os.fsync() Karen From barry at barrys-emacs.org Wed Oct 28 11:05:02 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Wed, 28 Oct 2020 15:05:02 +0000 Subject: Python extension module with callbacks into Python In-Reply-To: <565582df-8de9-4055-ab53-15ceaae4291an@googlegroups.com> References: <998974a7-c468-4eb9-bf70-b881e18af0a7n@googlegroups.com> <565582df-8de9-4055-ab53-15ceaae4291an@googlegroups.com> Message-ID: <9854C6D6-110A-4285-B21B-FB5774A5A71F@barrys-emacs.org> > On 28 Oct 2020, at 13:25, Paul Grinberg wrote: > >>> I am running into unpredictable behavior with my Python extension module that wraps around a C++ library that starts a new pthread and, after doing some work, generates callbacks back into the caller. I've greatly simplified this to a simplistic example which still demonstrates this problem. The following will sometimes generate a Fatal Python error: PyEval_SaveThread: NULL tstate, usually rather quickly. Sometimes it SIGSEGV on tupledealoc. Occasionally this deadlocks. I am at a loss why. Does anyone have any ideas? > >> You did not say what OS and python version you are working with. > > I apologize. I am running this on Ubuntu 18.04 under Python 3.6 (default for this Ubuntu's Bionic release) fully updated to the latest provided by Ubuntu's standard repos, which is 3.6.9-1~18.04ubuntu1.3. After posting this question here I continued investigating this problem and found that when I repeat the same test under Python 3.7.3 or 3.8.5 (installed via PyEnv), there are no issues. Then, I went back to the most recent 3.6 release which is 3.6.12 (also installed via PyEnv) and again saw the issue. This seems to suggest that the problem is in 3.6.x Python. > >> Why do you need to call PyEval_ThreadsInitialized()? its deprecated. >> >> PyInitialize sets up threads unconditionally since 3.7. > > I did not realize that PyEval_ThreadsInitialized() is deprecated. However, I was also running under 3.6. I will move away from that once I move to a newer version of Python Try calling PyEval_InitThreads() to force the python threading to be all setup. Barry > > -- > https://mail.python.org/mailman/listinfo/python-list > From gri6507 at gmail.com Wed Oct 28 11:18:48 2020 From: gri6507 at gmail.com (Paul Grinberg) Date: Wed, 28 Oct 2020 08:18:48 -0700 (PDT) Subject: Python extension module with callbacks into Python In-Reply-To: References: <998974a7-c468-4eb9-bf70-b881e18af0a7n@googlegroups.com> <9854C6D6-110A-4285-B21B-FB5774A5A71F@barrys-emacs.org> <565582df-8de9-4055-ab53-15ceaae4291an@googlegroups.com> Message-ID: <59e3a0c1-5dd8-4255-9ee3-feb37fa2cc0an@googlegroups.com> > Try calling PyEval_InitThreads() to force the python threading to be all setup. Can you please clarify where/when I should call PyEval_InitThreads()? Is this in the main python thread before any pthread callbacks are generated? If so, should this be done only once? From barry at barrys-emacs.org Wed Oct 28 17:50:33 2020 From: barry at barrys-emacs.org (Barry) Date: Wed, 28 Oct 2020 21:50:33 +0000 Subject: Python extension module with callbacks into Python In-Reply-To: <59e3a0c1-5dd8-4255-9ee3-feb37fa2cc0an@googlegroups.com> References: <59e3a0c1-5dd8-4255-9ee3-feb37fa2cc0an@googlegroups.com> Message-ID: > On 28 Oct 2020, at 15:22, Paul Grinberg wrote: > > ? >> >> Try calling PyEval_InitThreads() to force the python threading to be all setup. > > Can you please clarify where/when I should call PyEval_InitThreads()? Is this in the main python thread before any pthread callbacks are generated? If so, should this be done only once? Do it in your module init. That function is safe to be called multiple time. You could have answered the second part by reading the docs, which is what I did to check what I was telling you. Personally I do not code against the C api I use PyCXX to ease a lot of the hardship of using the C api. See http://cxx.sourceforge.net/PyCXX-Python3.html Disclaimer I am the PyCXX maintainer. I have c++ classes to handle the Gil release and acquire that I use in pysvn that you might find useful. See http://cxx.sourceforge.net/PyCXX-Python3.html and the PythonAllowThreads PythonDisallowThreads classes that to the hard workin a type safe way. Barry > -- > https://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Wed Oct 28 19:14:20 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 28 Oct 2020 19:14:20 -0400 Subject: Live Write to File with Code That is Reading File and Writing to Serial Port In-Reply-To: <2d1a28e5-9310-4fb4-b575-975651e846f6n@googlegroups.com> References: <2d1a28e5-9310-4fb4-b575-975651e846f6n@googlegroups.com> Message-ID: On 10/28/2020 8:49 AM, ktkelly_1 wrote: > Currently have a code that takes in a .txt file and submits commands to the serial. Then it reads the reply from the serial port and writes it to a hardcoded .txt file. The problem is it doesn't save it live and so if I need to stop the code for any reason, I can't gather current data and the text file is blank. I'm not as familiar with buffering and things like that and tried "outputFile = open("./outputFile.txt", "a", 0)" but that gave me the error "can't have an unbuffered text I/O? in python 3?" so I'm not sure what to do. Here is the general layout if you would like to mess around with it: > with open(test_file) as file_test: > Lines = file_test.readlines() > for line in Lines: > #send_str is the command to send to the serial port > send_str = line Both input and output should be controlled by the with statement. Same for serial port? Open files are line iterables. readlines is only needed if you need the whole file at once. Two names for the same line is a buglet. with open(test_file) as f_in, open(results) as f_out: for command in f_in: # Sent to serial port > file_result.write(line + "\n") #<--- if I were to cancel out after this it wouldn't be saved(*) Do you really want a command at the end of the file without results? If not, write command and result in one write after getting result. > ser.write(send_str.encode('utf-8')) > time.sleep(send_pause) > reply_str = ser.readline().decode('utf-8').strip() > file_result.write("reply:" + reply_str + "\n") #<---(*) > file_result.write('\n') #<---(*) -- Terry Jan Reedy From flaskee at protonmail.com Thu Oct 29 11:54:33 2020 From: flaskee at protonmail.com (flaskee) Date: Thu, 29 Oct 2020 15:54:33 +0000 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. Message-ID: Hello! I've been reading the GUI toolkit posts. If anyone can give me a push in the right python direction on my needs, I'd be grateful. This is for business applications, not games. (but if a game toolkit fits...) I'm coming from Actionscript, where there is a lot of GUI flexibility. The Python toolkits that I've looked at feel mostly grid-oriented or zone-oriented (you can put the button on the left, or middle, or right, etc). I am 100% committed to using Python now; so I just want to see what toolkit(s)/pieces/frameworks will get me as much of the following as possible. What I'd like: * To target MacOS, Windows, Linux, Android using native widgets (this drops out Kivy). * To get the screen-size before loading anything else, and to resize controls & forms to have the same as aspect ratio across screen sizes. In actionscript you can say form.scale *= 1.5; and the form and ALL children resize appropriately with that one line. * To resize a control/widget and be able to easily move it later. Needed for the following point. * To handle portrait vs landscape rotation. I'm okay on the logic of resizing and repositioning controls accordingly [if the facility to do so exists]. * Touch events, like swiping, pinch-to-resize, etc. BeeWare (Toga) has some of this, but BeeWare seems "under-developed" and it is not even listed on any of the Python GUI comparison sites that I've seen. I just don't want to go too far down the wrong path, if you good folks can help. Right now I am plugging away on Gtk to see where that takes me. Thank you for your help in advance! Sent with [ProtonMail](https://protonmail.com) Secure Email. From giannismd4 at gmail.com Thu Oct 29 13:07:11 2020 From: giannismd4 at gmail.com (Gian_Xatzak.) Date: Thu, 29 Oct 2020 19:07:11 +0200 Subject: Module Download Problem Message-ID: <514F8AB5-FDE6-4EC5-AFFB-E996E761F8F7@hxcore.ol> Hello!! ? I just download the latest version of python3 (Python3.9) and I have problem to download NumPy,? etc. ? Sent from [1]Mail for Windows 10 ? References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 From gri6507 at gmail.com Thu Oct 29 14:05:57 2020 From: gri6507 at gmail.com (Paul Grinberg) Date: Thu, 29 Oct 2020 11:05:57 -0700 (PDT) Subject: Python extension module with callbacks into Python In-Reply-To: References: <59e3a0c1-5dd8-4255-9ee3-feb37fa2cc0an@googlegroups.com> Message-ID: > > Can you please clarify where/when I should call PyEval_InitThreads()? Is this in the main python thread before any pthread callbacks are generated? If so, should this be done only once? > Do it in your module init. That function is safe to be called multiple time. > I decided to do it in the extension module shared library initialization routine. It's guaranteed to be called when the shared library is loaded. > You could have answered the second part by reading the docs, which is what I did to check what I was telling you. > My apologies. I realized that I should have read the manual first, but only after the impulse reaction to send the response. > Personally I do not code against the C api I use PyCXX to ease a lot of the > hardship of using the C api. See http://cxx.sourceforge.net/PyCXX-Python3.html > Disclaimer I am the PyCXX maintainer. > > I have c++ classes to handle the Gil release and acquire that I use in pysvn > that you might find useful. > > See http://cxx.sourceforge.net/PyCXX-Python3.html and the > PythonAllowThreads PythonDisallowThreads classes that to the hard workin a type safe way. > Thank you for that reference. I do not write a lot of python extension modules. However, when I do it again, I will seriously consider this as an option. From ikorot01 at gmail.com Thu Oct 29 14:19:35 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Thu, 29 Oct 2020 13:19:35 -0500 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: Hi, On Thu, Oct 29, 2020 at 1:05 PM Dennis Lee Bieber wrote: > > On Thu, 29 Oct 2020 15:54:33 +0000, flaskee via Python-list > declaimed the following: > > > > >What I'd like: > > > >* To target MacOS, Windows, Linux, Android using native widgets (this drops out Kivy). > > > That's going to knock out a lot of stuff. wxWidgets (base for wxPython) > claims to use true "native widgets" on each supported OS (Android may > depend upon support for generic X-Window) https://www.wxwidgets.org/about/ This is not a claim - its reality. ;-) However Android will be a problem - it is not supported by the library, since its written in C++, and Android is JAVA-based. The best way is to learn "JAVAsucks" and write natively for Android. Thank you. > > > QT and GTK do not use the actual "native widgets" -- they instead have > styles/themes applied to their own widgets to make them look closer to the > OS native stuff, but may not behave quite the same. > > Tkinter is Tk-based, and doesn't look "native" on anything > > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ > > -- > https://mail.python.org/mailman/listinfo/python-list From giannismd4 at gmail.com Thu Oct 29 15:34:09 2020 From: giannismd4 at gmail.com (Gian_Xatzak.) Date: Thu, 29 Oct 2020 21:34:09 +0200 Subject: FW: Module Download Problem In-Reply-To: <514F8AB5-FDE6-4EC5-AFFB-E996E761F8F7@hxcore.ol> References: <514F8AB5-FDE6-4EC5-AFFB-E996E761F8F7@hxcore.ol> Message-ID: Sorry I forgot: I have Windows10 ? Sent from [1]Mail for Windows 10 ? From: [2]Gian_Xatzak. Sent: Thursday, October 29, 2020 7:07 PM To: [3]python-list at python.org Subject: Module Download Problem ? Hello!! ? I just download the latest version of python3 (Python3.9) and I have problem to download NumPy,? etc. ? Sent from [4]Mail for Windows 10 ? ? References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 2. mailto:giannismd4 at gmail.com 3. mailto:python-list at python.org 4. https://go.microsoft.com/fwlink/?LinkId=550986 From mats at wichmann.us Thu Oct 29 15:34:33 2020 From: mats at wichmann.us (Mats Wichmann) Date: Thu, 29 Oct 2020 13:34:33 -0600 Subject: Module Download Problem In-Reply-To: <514F8AB5-FDE6-4EC5-AFFB-E996E761F8F7@hxcore.ol> References: <514F8AB5-FDE6-4EC5-AFFB-E996E761F8F7@hxcore.ol> Message-ID: On 10/29/20 11:07 AM, Gian_Xatzak. wrote: > Hello!! > > ? > > I just download the latest version of python3 (Python3.9) and I have > problem to download NumPy,? etc. There are projects who have not released their 3.9-compatible wheels yet - the schedule for doing so is up to each of those projects. Check pypi for the packages that matter to you. For now, stick with Python 3.8. From maillist at schwertberger.de Thu Oct 29 15:43:09 2020 From: maillist at schwertberger.de (Dietmar Schwertberger) Date: Thu, 29 Oct 2020 20:43:09 +0100 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: <3fada6f3-6914-a0e4-07a6-5ef070ece20d@schwertberger.de> On 29.10.2020 16:54, flaskee via Python-list wrote: > Thank you for your help in advance! Maybe, you should outline what you actually want to accomplish on each platform group (desktop / mobile). Regards, Dietmar From ikorot01 at gmail.com Thu Oct 29 14:30:14 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Thu, 29 Oct 2020 13:30:14 -0500 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: Hi, On Thu, Oct 29, 2020 at 11:33 AM flaskee via Python-list wrote: > > Hello! > > I've been reading the GUI toolkit posts. > > If anyone can give me a push in the right python direction on > my needs, I'd be grateful. > > This is for business applications, not games. > (but if a game toolkit fits...) > > I'm coming from Actionscript, > where there is a lot of GUI flexibility. > > The Python toolkits that I've looked at feel mostly grid-oriented > or zone-oriented (you can put the button on the left, or middle, > or right, etc). I don't think it is easily possible in a cross-platform environment. But even if your software is one platform only how will you handle DPI change, theme change and other system changes? You will have to have some kind of layout system. > > I am 100% committed to using Python now; > so I just want to see what toolkit(s)/pieces/frameworks > will get me as much of the following as possible. > > What I'd like: > > * To target MacOS, Windows, Linux, Android using native widgets (this drops out Kivy). See my previous reply. > > * To get the screen-size before loading anything else, and to resize controls & forms to have the same as aspect ratio across screen sizes. In actionscript you can say form.scale *= 1.5; and the form and ALL children resize appropriately with that one line. You are overthinking it. What if the window will be positioned on half normal DPI screen and half on HighDPI one? Or there was a theme change with the start of your software? As I said you absolutely have to have some kind of layout system or end up having 100 copies of same window prepared for a different layouts. Just accept that there are different layouts available for you that will handle every possible situation. > > * To resize a control/widget and be able to easily move it later. Needed for the following point. > > * To handle portrait vs landscape rotation. > I'm okay on the logic of resizing and repositioning controls accordingly [if the facility to do so exists]. You mean positioning controls on the screen with portrait vs landscape? Or during printing? Please clarify. > > * Touch events, like swiping, pinch-to-resize, etc. > > BeeWare (Toga) has some of this, but BeeWare seems "under-developed" and > it is not even listed on any of the Python GUI comparison sites > that I've seen. > > I just don't want to go too far down the wrong path, if you good folks can help. > > Right now I am plugging away on Gtk to see where that takes me. As being said GTK does not use native widgets. > > Thank you for your help in advance! If you have any further questions you can contact me directly. Thank you. > > Sent with [ProtonMail](https://protonmail.com) Secure Email. > -- > https://mail.python.org/mailman/listinfo/python-list From flaskee at protonmail.com Thu Oct 29 18:09:57 2020 From: flaskee at protonmail.com (flaskee) Date: Thu, 29 Oct 2020 22:09:57 +0000 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. Message-ID: > The Python toolkits that I've looked at feel mostly grid-oriented > or zone-oriented (you can put the button on the left, or middle, > or right, etc). I don't think it is easily possible in a cross-platform environment. But even if your software is one platform only how will you handle DPI change, theme change and other system changes? You will have to have some kind of layout system. ----------------------------------------------------- Thanks Igor. I'm actually converting a large actionscript set of apps, that already had Android/iOS, Windows app, Mac app and Browser versions; and that all shared about 80% of the self-written, layout code. Works great -- resizes between mobile device sizes automatically, scales widgets to fit, rotates portrait to landscape, all of that. But it had Very poor Linux support. I want to rebuild for all of these platforms, plus Linux. Really, MOSTLY, for Linux. And I really want Python as the new core for most things. Thanks Sent with [ProtonMail](https://protonmail.com) Secure Email. From ethan at stoneleaf.us Thu Oct 29 19:48:06 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 29 Oct 2020 16:48:06 -0700 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: <67ee929c-0c6f-4819-1da8-27fb82355e3e@stoneleaf.us> On 10/29/20 11:30 AM, Igor Korot wrote: > If you have any further questions you can contact me directly. Please do not. By keeping the discussion on the list many people can participate and learn. -- ~Ethan~ From ikorot01 at gmail.com Thu Oct 29 20:25:24 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Thu, 29 Oct 2020 19:25:24 -0500 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: <67ee929c-0c6f-4819-1da8-27fb82355e3e@stoneleaf.us> References: <67ee929c-0c6f-4819-1da8-27fb82355e3e@stoneleaf.us> Message-ID: Hi, Ethan, On Thu, Oct 29, 2020 at 6:51 PM Ethan Furman wrote: > > On 10/29/20 11:30 AM, Igor Korot wrote: > > > If you have any further questions you can contact me directly. > > Please do not. By keeping the discussion on the list many people can participate and learn. If the OP has further questions about wx{Widgets, Python, Phoenix} (s)he can send me direct e-mail. But of course if it's related to python itself I'd forward it to the ML. Thank you. > > -- > ~Ethan~ > -- > https://mail.python.org/mailman/listinfo/python-list From julio at diegidio.name Thu Oct 29 22:03:34 2020 From: julio at diegidio.name (Julio Di Egidio) Date: Thu, 29 Oct 2020 19:03:34 -0700 (PDT) Subject: Question on ABC classes In-Reply-To: References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> <7a6a90a2-4ba9-4556-a0ee-cf715d6db692o@googlegroups.com> <20201025194835.GA20782@hjp.at> Message-ID: On Sunday, 25 October 2020 20:55:26 UTC+1, Peter J. Holzer wrote: > On 2020-10-22 23:35:21 -0700, Julio Di Egidio wrote: > > On Friday, 23 October 2020 07:36:39 UTC+2, Greg Ewing wrote: > > > On 23/10/20 2:13 pm, Julio Di Egidio wrote: > > > > I am now thinking whether I could achieve the "standard" > > > > behaviour via another approach, say with decorators, somehow > > > > intercepting calls to __new__... maybe. > > > > > > I'm inclined to step back and ask -- why do you care about this? > > > > > > Would it actually do any harm if someone instantiated your > > > base class? If not, then it's probably not worth going out > > > of your way to prevent it. > > > > This is the first little library I try to put together > > in Python, and it was natural for me to hit it with all > > the relevant decorations as well as type annotations in > > order to expose *strict* contracts, plus hopefully have > > intellisense work all over the place. > > I think you are trying to use Python in a way contrary to its nature. > Python is a dynamically typed language. Its variables don't have types, > only its objects. And basically everything can be changed at runtime ... Consider this example: def abs(x): return math.sqrt(x.re**2 + x.im**2) That of course fails if we pass an object not of the correct (duck) type. But the exception is raised by math.sqrt, which, properly speaking, beside considerations on usability, is a private detail of the implementation of abs. The point is more about what the function semantically represents and to which point the implementation fulfils that promise/contract. What is that "abs" really supposed to provide? Let's say: << 'abs', given a "complex number" (duck-typed or not), returns its "real number" magnitude >>. And that's it, not just the doc but really what *type* of computation it is, and then the mathematics we can apply to types. And an effect is that, by constraining the domains (and codomains) of functions, we make verification of correctness, the need for defensive coding, as well as for plain testing, less onerous by orders of magnitude. So, at least for a function in a public interface, we *must* add validation (and the doc string): def abs(x): """...as above...""" if not isinstance(x, ComplexNumber): raise TypeError(...) return math.sqrt(x.re**2 + x.im**2) and then why not rather write: @typechecked def abs(x: ComplexNumber) -> RealNumber: return math.sqrt(x.re**2 + x.im**2) i.e. checked by the tools statically and/or at runtime, with, for easy intellisense, the default doc string that comes from the signature? More generally, I do think dynamic typing leads to interesting patterns of reuse, but I think "unconstrained" is a red herring: ab initio there is a *requirement* to fulfil. > It now has type annotations, but they are ignored both by the compiler > and at run-time. They are only for the benefit of linting tools like > mypy and editor features like intellisense. For the chronicle, I have meanwhile switched from pylint to mypy (in VSCode) and things have improved dramatically, from configurability to intellisense to static type checking working pretty well. I have meanwhile also realised that the built-in solutions (the typing module and so on) as well as the tools supporting them (including those for runtime validation) are still quite young, so instead of venting frustration (and I must say so far I think the typing module is a mess), as I have done in the OP, I should be patient, rather possibly give a hand... > > and the whole lot, indeed why even subclass ABC? > > Good question. In six years of programming Python, I've never used ABC. > But then I came from another dynamically typed language to Python. Back in the day we had a laugh when intellisense was invented... but now, with the eco-info-system booming with everything and the contrary of everything (to put it charitably), I think it's about (formal, as much as possible) verifiability and correctness. Anyway. my 2c. Sorry for the long post and thanks for the feedback. Julio From drsalists at gmail.com Thu Oct 29 22:18:27 2020 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 29 Oct 2020 19:18:27 -0700 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: <67ee929c-0c6f-4819-1da8-27fb82355e3e@stoneleaf.us> References: <67ee929c-0c6f-4819-1da8-27fb82355e3e@stoneleaf.us> Message-ID: On Thu, Oct 29, 2020 at 4:48 PM Ethan Furman wrote: > On 10/29/20 11:30 AM, Igor Korot wrote: > > > If you have any further questions you can contact me directly. > > Please do not. By keeping the discussion on the list many people can > participate and learn. > This list isn't terribly overnoisy. But sun-managers had a terrific signal/noise ratio back in the day, by asking OP's to receive messages off list, and sending a self-composed summary of the replies back to the list. From rosuav at gmail.com Fri Oct 30 00:08:55 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 30 Oct 2020 15:08:55 +1100 Subject: Question on ABC classes In-Reply-To: References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> <7a6a90a2-4ba9-4556-a0ee-cf715d6db692o@googlegroups.com> <20201025194835.GA20782@hjp.at> Message-ID: On Fri, Oct 30, 2020 at 1:06 PM Julio Di Egidio wrote: > > On Sunday, 25 October 2020 20:55:26 UTC+1, Peter J. Holzer wrote: > > I think you are trying to use Python in a way contrary to its nature. > > Python is a dynamically typed language. Its variables don't have types, > > only its objects. And basically everything can be changed at runtime ... > > Consider this example: > > def abs(x): > return math.sqrt(x.re**2 + x.im**2) > > That of course fails if we pass an object not of the correct > (duck) type. But the exception is raised by math.sqrt, which, > properly speaking, beside considerations on usability, is a > private detail of the implementation of abs. Not sure what sorts of errors you're expecting, but for the most part, if it's not a complex number, you should get an AttributeError before you get into the sqrt. (Although I'm not sure why you're looking for ".re" and ".im" - typo? Python's complex type has ".real" and ".imag", and you can accept any numeric type that way - even fractions.Fraction.) It's highly unlikely that you'd have real and imaginary parts that can be squared and summed, but the result can't be squirted. But here's the thing: even if that IS the case, most Python programmers are fine with getting an AttributeError stating exactly what the problem is, rather than a TypeError complaining that it has to be the exact type some other programmer intended. A good example is dictionaries and dict-like objects; if your code type checks for a dict, I have to give you a dict, but if you just try to do whichever operations you need, I can create something more dynamic and give you that instead. Python doesn't push for heavy type checking because it's almost certainly not necessary in the majority of cases. Just use the thing as you expect it to be, and if there's a problem, your caller can handle it. That's why we have call stacks. ChrisA From julio at diegidio.name Fri Oct 30 02:14:39 2020 From: julio at diegidio.name (Julio Di Egidio) Date: Thu, 29 Oct 2020 23:14:39 -0700 (PDT) Subject: Question on ABC classes In-Reply-To: References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> <7a6a90a2-4ba9-4556-a0ee-cf715d6db692o@googlegroups.com> <20201025194835.GA20782@hjp.at> Message-ID: <3a350e15-6bc0-4294-8e61-9f9aaa474033o@googlegroups.com> On Friday, 30 October 2020 05:09:34 UTC+1, Chris Angelico wrote: > On Fri, Oct 30, 2020 at 1:06 PM Julio Di Egidio wrote: > > On Sunday, 25 October 2020 20:55:26 UTC+1, Peter J. Holzer wrote: > > > I think you are trying to use Python in a way contrary to its nature. > > > Python is a dynamically typed language. Its variables don't have types, > > > only its objects. And basically everything can be changed at runtime ... > > > > Consider this example: > > > > def abs(x): > > return math.sqrt(x.re**2 + x.im**2) > > > > That of course fails if we pass an object not of the correct > > (duck) type. But the exception is raised by math.sqrt, which, > > properly speaking, beside considerations on usability, is a > > private detail of the implementation of abs. > > Not sure what sorts of errors you're expecting, but for the most part, > if it's not a complex number, you should get an AttributeError before > you get into the sqrt. Yes, sorry, I was glossing over an example that was meant to be just general. I could have written something like: def abs(x): ...bunch of possibly complex operations... and that that is completely opaque both to the user of the function as well as, in my opinion, to its author (code must speak to speak for itself!). Not to mention, from the point of view of formal verification, this is the corresponding annotated version, and it is in fact worse than useless: def abs(x: Any) -> Any: ...some code here... Useless as in plain incorrect: functions written in a totally unconstrained style are rather pretty much guaranteed not to accept arbitrary input... and, what's really worse, to be unsound on part of the input that they do accept: read undefined behaviour. > But here's the thing: even if that IS the case, most Python > programmers are fine with getting an AttributeError stating exactly > what the problem is, rather than a TypeError complaining that it has > to be the exact type some other programmer intended. A good example is > dictionaries and dict-like objects; if your code type checks for a > dict, I have to give you a dict, but if you just try to do whichever > operations you need, I can create something more dynamic and give you > that instead. I did say "duck-typing or not". I was not talking of restricting dynamism (python protocols are an implementation of duck typing and can be used in typing annotations, even generic protocols), the point is making intentions explicit: to the benefit of the user of that code, but also to that of the author, as even the author has to have some "plan" in mind. As well as, eventually, to the various tools and checkers. > Python doesn't push for heavy type checking because it's almost > certainly not necessary in the majority of cases. Just use the thing > as you expect it to be, and if there's a problem, your caller can > handle it. That's why we have call stacks. I am learning Pandas and I can rather assure you that it is an absolute pain as well as loss of productivity that, whenever I misuse a function (in spite of reading the docs), I indeed get a massive stack trace down to the private core, and have to figure out, sometimes by looking at the source code, what I actually did wrong and what I should do instead. To the point that, since I want to become a proficient user, I am ending up reverse engineering the whole thing... Now, as I said up-thread, I am not complaining as the whole ecosystem is pretty young, but here the point is: "by my book" that code is simply called not production level. Julio From rosuav at gmail.com Fri Oct 30 02:34:03 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 30 Oct 2020 17:34:03 +1100 Subject: Question on ABC classes In-Reply-To: <3a350e15-6bc0-4294-8e61-9f9aaa474033o@googlegroups.com> References: <60ed8321-ad27-40bb-af4f-ded45760c16fo@googlegroups.com> <95ac7c0d-f942-d74b-792a-776d20f250eb@stoneleaf.us> <7a6a90a2-4ba9-4556-a0ee-cf715d6db692o@googlegroups.com> <20201025194835.GA20782@hjp.at> <3a350e15-6bc0-4294-8e61-9f9aaa474033o@googlegroups.com> Message-ID: On Fri, Oct 30, 2020 at 5:16 PM Julio Di Egidio wrote: > Not to mention, from the point of view of formal verification, > this is the corresponding annotated version, and it is in fact > worse than useless: > > def abs(x: Any) -> Any: > ...some code here... > Useless because, in the absence of annotations or other information saying otherwise, "Any" is exactly what you'd get. There's no point whatsoever in annotating that it ... is exactly what it would be without annotations. Unless you're trying for some sort of rule "all functions must be annotated", or something, it's best to just not bother. > Useless as in plain incorrect: functions written in a totally > unconstrained style are rather pretty much guaranteed not to > accept arbitrary input... and, what's really worse, to be > unsound on part of the input that they do accept: read > undefined behaviour. Not quite true. You're assuming that the annotation is the only thing which determines what a function will accept. Consider that the function had been written thus: def abs(x): """Calculate the magnitude of a (possibly complex) number""" return (x.real ** 2 + x.imag ** 2) ** 0.5 The docstring clearly states that it expects a number. But ANY number will do, so long as it has .real and .imag attributes. Python's core types all have those; the numpy int, float, and complex types all have those; any well-behaved numerical type in Python will have these attributes. In fact, if you were to annotate this as "x: numbers.Complex", it would give exactly zero more information. This function requires a number with real and imag attributes - that's all. If anything, such an annotation would confuse people into thinking that it *has* to receive a complex number, which isn't true. There is nothing undefined here. If you give it (say) a string, you get a nice easy AttributeError saying that it needs to have a .real attribute. > > Python doesn't push for heavy type checking because it's almost > > certainly not necessary in the majority of cases. Just use the thing > > as you expect it to be, and if there's a problem, your caller can > > handle it. That's why we have call stacks. > > I am learning Pandas and I can rather assure you that it is an > absolute pain as well as loss of productivity that, whenever I > misuse a function (in spite of reading the docs), I indeed get > a massive stack trace down to the private core, and have to > figure out, sometimes by looking at the source code, what I > actually did wrong and what I should do instead. To the point > that, since I want to become a proficient user, I am ending up > reverse engineering the whole thing... Now, as I said up-thread, > I am not complaining as the whole ecosystem is pretty young, > but here the point is: "by my book" that code is simply called > not production level. > Part of the art of reading exception tracebacks rapidly is locating which part is in your code and which part is library code. Most of the time, the bug is at the boundary between those two. There are tools that can help you with this, or you can develop the skill of quickly eyeballing a raw traceback and finding the part that's relevant to you. I don't think this is a consequence of the ecosystem being young (Pandas has been around for twelve years now, according to Wikipedia), but more that the Python community doesn't like to destroy good debugging information and the ability to fully duck-type. Solve the correct problem. If tracebacks are too hard to read, solve the traceback problem, don't try to force everything through type checks. ChrisA From hongyi.zhao at gmail.com Fri Oct 30 09:22:25 2020 From: hongyi.zhao at gmail.com (Hongyi Zhao) Date: Fri, 30 Oct 2020 06:22:25 -0700 (PDT) Subject: Extract the package list from pypi simple api efficiently. Message-ID: <5b598b9b-49f4-4976-a05a-c2f5c900c69co@googlegroups.com> Hi, The pypi exposes its simple api at , which can be used to extract the complete package name list. I want to do the job efficiently and write the following simple codes: import requests proxies = { 'http': 'socks5h://127.0.0.1:18888', 'https': 'socks5h://127.0.0.1:18888' } requests.packages.urllib3.disable_warnings() r = requests.get('https://pypi.org/simple/', proxies=proxies, verify=False) The package name info is included in the r.text string object, but I still can't figure out how to further extract them efficiently. Any hints will be highly appreciated. Regards, HY From flaskee at protonmail.com Fri Oct 30 11:44:32 2020 From: flaskee at protonmail.com (flaskee) Date: Fri, 30 Oct 2020 15:44:32 +0000 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: <67ee929c-0c6f-4819-1da8-27fb82355e3e@stoneleaf.us> Message-ID: I was actually working on a summarized list for my question. I thought that I'd produce an up-to-date list of GUI toolkits, with everyone's responses; plus what I've cobbled together from comparisons on other sites. Sent with ProtonMail Secure Email. ??????? Original Message ??????? On Thursday, October 29, 2020 10:18 PM, Dan Stromberg wrote: > On Thu, Oct 29, 2020 at 4:48 PM Ethan Furman ethan at stoneleaf.us wrote: > > > On 10/29/20 11:30 AM, Igor Korot wrote: > > > > > If you have any further questions you can contact me directly. > > > > Please do not. By keeping the discussion on the list many people can > > participate and learn. > > This list isn't terribly overnoisy. > > But sun-managers had a terrific signal/noise ratio back in the day, by > asking OP's to receive messages off list, and sending a self-composed > summary of the replies back to the list. > > --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > https://mail.python.org/mailman/listinfo/python-list From flaskee at protonmail.com Fri Oct 30 11:56:17 2020 From: flaskee at protonmail.com (flaskee) Date: Fri, 30 Oct 2020 15:56:17 +0000 Subject: Best way to determine user's screensize? Message-ID: Perhaps a more tactical approach would best to figure out how to do cross-platform python apps. What is the best approach to determining the user's available screensize, when they open your python application? Note that the "desktop" application could be running on Android, iOS, MacOS, Windows or Linux (I think that I understand how to handle it for browser-based things.) As close to an all Python answer as possible, would be optimal. Thank you! From ikorot01 at gmail.com Fri Oct 30 12:45:01 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Fri, 30 Oct 2020 11:45:01 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: Hi, On Fri, Oct 30, 2020, 10:59 AM flaskee via Python-list < python-list at python.org> wrote: > Perhaps a more tactical approach would best to figure > out how to do cross-platform python apps. > > What is the best approach to determining the user's available screensize, > when they open your python application? > It depends on the framework you are using... Thank you. > Note that the "desktop" application could be running on Android, iOS, > MacOS, Windows or Linux (I think that I understand how to handle it for > browser-based things.) > > As close to an all Python answer as possible, would be optimal. > > Thank you! > -- > https://mail.python.org/mailman/listinfo/python-list > From grant.b.edwards at gmail.com Fri Oct 30 12:05:30 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 30 Oct 2020 16:05:30 -0000 (UTC) Subject: Best way to determine user's screensize? References: Message-ID: On 2020-10-30, flaskee via Python-list wrote: > What is the best approach to determining the user's available > screensize, when they open your python application? Why do you think that's something your application needs to know? I _hate_ applications that think just because they've been started they now own the entire computer and everything reachable from it. All you need to know is how big your application window is. The user's available screen size is none of your business. -- Grant From ikorot01 at gmail.com Fri Oct 30 14:48:42 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Fri, 30 Oct 2020 13:48:42 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: Hi, On Fri, Oct 30, 2020 at 12:26 PM Grant Edwards wrote: > > On 2020-10-30, flaskee via Python-list wrote: > > > What is the best approach to determining the user's available > > screensize, when they open your python application? > > Why do you think that's something your application needs to know? > > I _hate_ applications that think just because they've been started > they now own the entire computer and everything reachable from it. > > All you need to know is how big your application window is. The user's > available screen size is none of your business. In addition - what if the user decides to change the monitor DPI? Then the screen size you retrieved will be useless... Thank you. > > -- > Grant > > -- > https://mail.python.org/mailman/listinfo/python-list From giannismd4 at gmail.com Fri Oct 30 15:38:16 2020 From: giannismd4 at gmail.com (Gian_Xatzak.) Date: Fri, 30 Oct 2020 21:38:16 +0200 Subject: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Message-ID: <1EA4B055-7A18-447F-9AA0-2F97ABDD35D8@hxcore.ol> When I tried to download ?matplotlib, it show me that message in the end: ? ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ? *I have Windows 10, Python3.8.6(64bit) ? ? Sent from [1]Mail for Windows 10 ? References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 From rosuav at gmail.com Fri Oct 30 16:03:51 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 07:03:51 +1100 Subject: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. In-Reply-To: <1EA4B055-7A18-447F-9AA0-2F97ABDD35D8@hxcore.ol> References: <1EA4B055-7A18-447F-9AA0-2F97ABDD35D8@hxcore.ol> Message-ID: On Sat, Oct 31, 2020 at 6:39 AM Gian_Xatzak. wrote: > > When I tried to download matplotlib, it show me that message in the end: > > > > ERROR: Command errored out with exit status 1: python setup.py egg_info > Check the logs for full command output. > Did you check the logs? You should find the full command output there. ChrisA From random832 at fastmail.com Fri Oct 30 17:17:03 2020 From: random832 at fastmail.com (Random832) Date: Fri, 30 Oct 2020 17:17:03 -0400 Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: On Fri, Oct 30, 2020, at 12:05, Grant Edwards wrote: > Why do you think that's something your application needs to know? > > I _hate_ applications that think just because they've been started > they now own the entire computer and everything reachable from it. > > All you need to know is how big your application window is. The user's > available screen size is none of your business. The application decides how big the application window is. The user can resize it, but there's no reason for the screen size not to be one of the inputs considered for the initial choice. From ikorot01 at gmail.com Fri Oct 30 17:31:25 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Fri, 30 Oct 2020 16:31:25 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: Hi, On Fri, Oct 30, 2020 at 4:20 PM Random832 wrote: > > On Fri, Oct 30, 2020, at 12:05, Grant Edwards wrote: > > Why do you think that's something your application needs to know? > > > > I _hate_ applications that think just because they've been started > > they now own the entire computer and everything reachable from it. > > > > All you need to know is how big your application window is. The user's > > available screen size is none of your business. > > The application decides how big the application window is. The user can resize it, but there's no reason for the screen size not to be one of the inputs considered for the initial choice. Nope. It is nNOT up to application. It is either up to the developer (if he calls Maximize() ) on the main frame, or the OS if the main frame is using defaults. Thank you. > -- > https://mail.python.org/mailman/listinfo/python-list From hjp-python at hjp.at Fri Oct 30 18:46:25 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Fri, 30 Oct 2020 23:46:25 +0100 Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: <20201030224625.GB24901@hjp.at> On 2020-10-30 16:31:25 -0500, Igor Korot wrote: > On Fri, Oct 30, 2020 at 4:20 PM Random832 wrote: > > > > On Fri, Oct 30, 2020, at 12:05, Grant Edwards wrote: > > > Why do you think that's something your application needs to know? > > > > > > I _hate_ applications that think just because they've been started > > > they now own the entire computer and everything reachable from it. > > > > > > All you need to know is how big your application window is. The user's > > > available screen size is none of your business. > > > > The application decides how big the application window is. The user > > can resize it, but there's no reason for the screen size not to be > > one of the inputs considered for the initial choice. > > Nope. > It is nNOT up to application. > It is either up to the developer The developer writes the application. The application doesn't decide to do anything it hasn't been programmed to do. So saying "it is not up the the application, it is up to the developer" doesn't make any sense. Oh, and I just realized that "application" is ambiguous. It could mean the program, or it could be what the program is used for. Of course the developer should consider the latter when writing the former. > (if he calls Maximize() ) on the main frame, An application shouldn't do that unless explicitely directed to by the user. > or the OS if the main frame is using defaults. I'm not sure if OS's even have a default window size. In any case, one size doesn't fit all. There are many cases where the initial size should depend on the application: * A terminal emulator would make the window large enough for a typical terminal size (e.g. 80x25 characters) plus chrome. * An image viewer would make it large enough for the image, but not larger than the screen (if the image is larger than the screen (quite probable for photos) it will be scaled down). * A MUA would make it large enough for a list of mailboxes, a list of mails and one mail in some default pane configuration, but again not larger than the screen. * A media player would make it large enough for the playlist and some chrome. etc. -- _ | 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 flaskee at protonmail.com Fri Oct 30 18:54:17 2020 From: flaskee at protonmail.com (flaskee) Date: Fri, 30 Oct 2020 22:54:17 +0000 Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> ??????? Original Message ??????? On Friday, October 30, 2020 5:31 PM, Igor Korot wrote: > Hi, > > On Fri, Oct 30, 2020 at 4:20 PM Random832 random832 at fastmail.com wrote: > > > On Fri, Oct 30, 2020, at 12:05, Grant Edwards wrote: > > > > > Why do you think that's something your application needs to know? > > > I hate applications that think just because they've been started > > > they now own the entire computer and everything reachable from it. > > > All you need to know is how big your application window is. The user's > > > available screen size is none of your business. > > > > The application decides how big the application window is. The user can resize it, but there's no reason for the screen size not to be one of the inputs considered for the initial choice. > > Nope. > It is nNOT up to application. > It is either up to the developer (if he calls Maximize() ) on the main > frame, or the OS if the main frame is using defaults. > > Thank you. > Exactly Igor & random832. I have done all of this resizing and layout stuff before. I just ignored the grouchy user with the hate over me wanting screensize. (every list has one of those types, eh? :-) Screensize, in part, determines the aspect ratio calcs to dynamically resize and place the components on the screen. Anyway, I'm pushing on to do this under python. With, or without, Mr. Grouchy. Igor --- I think you asked why for portrait vs landscape? It is so that when the user flips a phone or tablet to the side (landscape), or straight up/down (portrait) that the widgets can be dynamically resized & re-positioned to fit. In actionscript a RESIZE event fires when flipping to the side or back, that can then be reacted to, to reposition things. I just need to re-figure this all out under Python, et al. Thanks From rosuav at gmail.com Fri Oct 30 19:02:12 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 10:02:12 +1100 Subject: Best way to determine user's screensize? In-Reply-To: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On Sat, Oct 31, 2020 at 9:55 AM flaskee via Python-list wrote: > I have done all of this resizing and layout stuff before. > > I just ignored the grouchy user with the hate over me wanting screensize. > (every list has one of those types, eh? :-) > > Screensize, in part, determines the aspect ratio calcs to dynamically > resize and place the components on the screen. > So what would you do if it turns out that my screen is 5440 x 2104? That's what mine is right now. I add my voice to those who detest applications that think they know best and decide that they own the entire screen. It is incredibly annoying. ChrisA From flaskee at protonmail.com Fri Oct 30 19:15:38 2020 From: flaskee at protonmail.com (flaskee) Date: Fri, 30 Oct 2020 23:15:38 +0000 Subject: Best way to determine user's screensize? In-Reply-To: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: I'm closing in on the screen width/height, at least. In odd screen sizes or multi-monitor situations, I make the best guess, but allow the user to alter things, via preferences. No complaints in 10 years. So there's that. # For MacOS Code: import AppKit [(screen.frame().size.width, screen.frame().size.height) for screen in AppKit.NSScreen.screens()] $ For Windows Code: from win32api import GetSystemMetrics print("Width =", GetSystemMetrics(0)) print("Height =", GetSystemMetrics(1)) # QT Code from PySide import QtGui dw=QtGui.QDesktopWidget() dw.screenGeometry() dw.availableGeometry() # this is a sub rect of screenGeometry because it e.g. ignores the space occupied by the task bar on Windows # GDK, GTK from gi.repository import Gdk s = Gdk.Screen.get_default() print(s.get_width()) print(s.get_height()) # ---------------------- from gi.repository import Gdk, Gtk # Replace w with the GtkWindow of your application w = Gtk.Window() # Get the screen from the GtkWindow s = w.get_screen() # Using the screen of the Window, the monitor it's on can be identified m = s.get_monitor_at_window(s.get_active_window()) # Then get the geometry of that monitor monitor = s.get_monitor_geometry(m) # This is an example output print("Height: %s, Width: %s" % (monitor.height, monitor.width)) From rosuav at gmail.com Fri Oct 30 19:21:51 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 10:21:51 +1100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On Sat, Oct 31, 2020 at 10:17 AM flaskee via Python-list wrote: > > > I'm closing in on the screen width/height, at least. > > > In odd screen sizes or multi-monitor situations, > I make the best guess, > but allow the user to alter things, > via preferences. > > No complaints in 10 years. > So there's that. > Funny thing about complaints... you don't hear any from people who just uninstall your app and move right on with their lives. Multi-monitor situations are pretty common. Since you don't seem to care about them, I no longer care about your app. Whatever it is, I don't need it. ChrisA From ikorot01 at gmail.com Fri Oct 30 19:44:23 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Fri, 30 Oct 2020 18:44:23 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: Hi, On Fri, Oct 30, 2020 at 6:24 PM Chris Angelico wrote: > > On Sat, Oct 31, 2020 at 10:17 AM flaskee via Python-list > wrote: > > > > > > I'm closing in on the screen width/height, at least. > > > > > > In odd screen sizes or multi-monitor situations, > > I make the best guess, > > but allow the user to alter things, > > via preferences. > > > > No complaints in 10 years. > > So there's that. > > > > Funny thing about complaints... you don't hear any from people who > just uninstall your app and move right on with their lives. > > Multi-monitor situations are pretty common. Since you don't seem to > care about them, I no longer care about your app. Whatever it is, I > don't need it. Exactly. And since most of such setups are different DPIs it actually becomes more fun. Especially since some applications tend to save and restore their positions (not saying this is the case here, but...). But windows positioning/layout never should be hardcoded and it should depend on some kind of layout system. All cross-platform toolkit does it - JAVA, wxWidgets, GTK, Qt. And so from what I understand - the OP is just trying to re-invent the wheel. All I can say is - every tool is different.And whatever was good 20 years ago, today is completely obsolete. Good luck to him. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From flaskee at protonmail.com Fri Oct 30 19:45:14 2020 From: flaskee at protonmail.com (flaskee) Date: Fri, 30 Oct 2020 23:45:14 +0000 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: > Funny thing about complaints... you don't hear any from people who > just uninstall your app and move right on with their lives. > > Multi-monitor situations are pretty common. Since you don't seem to > care about them, I no longer care about your app. Whatever it is, I > don't need it. > > ChrisA Funny thing about people who bitch and complain and offer no help, on these kinds of lists, I don't need them either. You have No idea what the app is, No idea how I handle multi-monitors, etc. But you have your little opinion anyway. I am horribly crushed that you won't use my app(s) /s Bye, bye. From hjp-python at hjp.at Fri Oct 30 19:56:30 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 00:56:30 +0100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: <20201030235630.GC24901@hjp.at> On 2020-10-31 10:02:12 +1100, Chris Angelico wrote: > On Sat, Oct 31, 2020 at 9:55 AM flaskee via Python-list > wrote: > > I have done all of this resizing and layout stuff before. > > > > I just ignored the grouchy user with the hate over me wanting screensize. > > (every list has one of those types, eh? :-) > > > > Screensize, in part, determines the aspect ratio calcs to dynamically > > resize and place the components on the screen. > > > > So what would you do if it turns out that my screen is 5440 x 2104? > That's what mine is right now. That depends on the application. If for example the application is in image viewer and the image to be viewed is 4576x3432 pixels large, that wouldn't fit on the screen. Assuming 200 pixels of vertical chrome (title bar, window borders, menu bar and/or buttons), the image would have to be resized to (at most) 2539x1904 pixels. So the window would be sized to accommodate that. (If you use a multi-screen setup, the calculation should be based on the current screen, of course, not on the combined size of all screens) > I add my voice to those who detest applications that think they know > best and decide that they own the entire screen. So, assuming the user is invoking the application for the first time, how should an application determine how much of the screen it should use? It has to make some choice, and any hard-coded value is almost certainly wrong. So why should an application not use the screen size as one factor? 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 robertvstepp at gmail.com Fri Oct 30 20:11:56 2020 From: robertvstepp at gmail.com (boB Stepp) Date: Fri, 30 Oct 2020 19:11:56 -0500 Subject: Best way to determine user's screensize? In-Reply-To: <20201030235630.GC24901@hjp.at> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> Message-ID: <20201031001156.GN9135@Dream-Machine1> On Sat, Oct 31, 2020 at 12:56:30AM +0100, Peter J. Holzer wrote: >So, assuming the user is invoking the application for the first time, >how should an application determine how much of the screen it should >use? It has to make some choice, and any hard-coded value is almost >certainly wrong. So why should an application not use the screen size as >one factor? I have been following this discussion with some interest (except for the grumpy parts ~(:>)) ), and have wondered this same thing. Is there any good guidance on how to answer this question? Or should it be up to the combination of GUI toolkit and OS being used? It seems that if the programmer does nothing, some default size is generated. As a user I have not been too concerned about the size presented upon first using a program. What gets my dander up is what happens *after* I set the size I prefer. Many programs do not store this preference for future runs of the program or even during the same session when a new window is generated of the exact same type. A Windows-based application I use for work constantly annoys me in this regard, especially when I am working at home on my (not as wide as Chris') ultra-wide monitor: I open external beam planning window for patient #1, resize it. Open same for next patient -- must resize once again (...and again, and again, ...). -- Wishing you only the best, boB Stepp From ikorot01 at gmail.com Fri Oct 30 20:18:22 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Fri, 30 Oct 2020 19:18:22 -0500 Subject: Best way to determine user's screensize? In-Reply-To: <20201030235630.GC24901@hjp.at> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> Message-ID: Hi, On Fri, Oct 30, 2020 at 6:59 PM Peter J. Holzer wrote: > > On 2020-10-31 10:02:12 +1100, Chris Angelico wrote: > > On Sat, Oct 31, 2020 at 9:55 AM flaskee via Python-list > > wrote: > > > I have done all of this resizing and layout stuff before. > > > > > > I just ignored the grouchy user with the hate over me wanting screensize. > > > (every list has one of those types, eh? :-) > > > > > > Screensize, in part, determines the aspect ratio calcs to dynamically > > > resize and place the components on the screen. > > > > > > > So what would you do if it turns out that my screen is 5440 x 2104? > > That's what mine is right now. > > That depends on the application. > > If for example the application is in image viewer and the image to be > viewed is 4576x3432 pixels large, that wouldn't fit on the screen. > Assuming 200 pixels of vertical chrome (title bar, window borders, menu > bar and/or buttons), the image would have to be resized to (at most) > 2539x1904 pixels. So the window would be sized to accommodate that. > > (If you use a multi-screen setup, the calculation should be based on > the current screen, of course, not on the combined size of all screens) > > > > I add my voice to those who detest applications that think they know > > best and decide that they own the entire screen. > > So, assuming the user is invoking the application for the first time, > how should an application determine how much of the screen it should > use? It has to make some choice, and any hard-coded value is almost > certainly wrong. So why should an application not use the screen size as > one factor? It is not up to application. It is up to the underlying layout system to decide. Thank you. > > hp > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp at hjp.at | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > -- > https://mail.python.org/mailman/listinfo/python-list From songbird at anthive.com Fri Oct 30 20:47:50 2020 From: songbird at anthive.com (songbird) Date: Fri, 30 Oct 2020 20:47:50 -0400 Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: Chris Angelico wrote: ... > I add my voice to those who detest applications that think they know > best and decide that they own the entire screen. It is incredibly > annoying. do you object to a window being put in the approximate center of the screen? songbird From ikorot01 at gmail.com Fri Oct 30 21:12:47 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Fri, 30 Oct 2020 20:12:47 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: Hi, On Fri, Oct 30, 2020 at 7:52 PM songbird wrote: > > Chris Angelico wrote: > ... > > I add my voice to those who detest applications that think they know > > best and decide that they own the entire screen. It is incredibly > > annoying. > > do you object to a window being put in the approximate > center of the screen? As a matter of fact I do. On Windows there is something called CW_USEDEFAULT. I'm sure that other OS/toolkits have something similar. And if not - there is always "Maximize()" and/or Center() and if this is not desirable then let the layout system decide. Thank you. > > > songbird > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Fri Oct 30 21:26:25 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 12:26:25 +1100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On Sat, Oct 31, 2020 at 11:51 AM songbird wrote: > > Chris Angelico wrote: > ... > > I add my voice to those who detest applications that think they know > > best and decide that they own the entire screen. It is incredibly > > annoying. > > do you object to a window being put in the approximate > center of the screen? > If that's where my window manager chooses to put it, great! The application just says "I want a window of this size" and the window manager decides where that should go. The application doesn't. ChrisA From 2QdxY4RzWzUUiLuE at potatochowder.com Fri Oct 30 21:29:54 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Fri, 30 Oct 2020 20:29:54 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: <20201031012954.GA33753@scrozzle> On 2020-10-30 at 20:47:50 -0400, songbird wrote: > Chris Angelico wrote: > ... > > I add my voice to those who detest applications that think they know > > best and decide that they own the entire screen. It is incredibly > > annoying. > > do you object to a window being put in the approximate > center of the screen? At times, yes. At my last place of employment, I had a lot of screen real estate. It's very annoying to be working in a corner of it and have some kind of modal dialog pop up way over there in the middle of the screen. In a dual screen setup when the screens are the same, "the center of the screen" spans two physical screens. If the screens are different, then a window "in the center of the screen" might not even be fully visible (e.g., two 1920x1080 screens, one portrait and one landscape, positioned to form an "L"). From rosuav at gmail.com Fri Oct 30 21:30:43 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 12:30:43 +1100 Subject: Best way to determine user's screensize? In-Reply-To: <20201030235630.GC24901@hjp.at> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> Message-ID: On Sat, Oct 31, 2020 at 10:57 AM Peter J. Holzer wrote: > > On 2020-10-31 10:02:12 +1100, Chris Angelico wrote: > > On Sat, Oct 31, 2020 at 9:55 AM flaskee via Python-list > > wrote: > > > I have done all of this resizing and layout stuff before. > > > > > > I just ignored the grouchy user with the hate over me wanting screensize. > > > (every list has one of those types, eh? :-) > > > > > > Screensize, in part, determines the aspect ratio calcs to dynamically > > > resize and place the components on the screen. > > > > > > > So what would you do if it turns out that my screen is 5440 x 2104? > > That's what mine is right now. > > That depends on the application. > > If for example the application is in image viewer and the image to be > viewed is 4576x3432 pixels large, that wouldn't fit on the screen. > Assuming 200 pixels of vertical chrome (title bar, window borders, menu > bar and/or buttons), the image would have to be resized to (at most) > 2539x1904 pixels. So the window would be sized to accommodate that. > > (If you use a multi-screen setup, the calculation should be based on > the current screen, of course, not on the combined size of all screens) > But what is the "current screen"? That's the problem. MANY applications (mostly games) decide to put themselves on monitor #4 and size themselves according to monitor #1, or some other mismatching. Or, I alt-tab away from something, come back in, and it resizes itself to a different screen size. There is no valid way for an application to read my mind and size itself. Attempting to query my screen size seems to just make things worse in a lot of situations. ChrisA From siddharth654choudhary at gmail.com Fri Oct 30 22:04:43 2020 From: siddharth654choudhary at gmail.com (Siddhharth Choudhary) Date: Fri, 30 Oct 2020 19:04:43 -0700 (PDT) Subject: Why x+=1 doesn't return x value instead of an object Message-ID: I want to know why x+=1 does not return the value of the variable. It would be great if It has returned the value of the variable instead of an object. It will increase the beauty of python. For instance, x = 5 x+=1 print(x) = 6 If x+=1 had returned the value instead of object x = 5 print(x+=1) = 6 which is not possible? From jon+usenet at unequivocal.eu Fri Oct 30 22:48:27 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sat, 31 Oct 2020 02:48:27 -0000 (UTC) Subject: Why x+=1 doesn't return x value instead of an object References: Message-ID: On 2020-10-31, Stefan Ram wrote: > Siddhharth Choudhary writes: >>I want to know why x+=1 does not return the value of the variable. > > Which value? The old or the new one? > > Expressions never return values. Except when they're assignment expressions, when they do. From jfong at ms4.hinet.net Fri Oct 30 23:08:35 2020 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Fri, 30 Oct 2020 20:08:35 -0700 (PDT) Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: <8ea0edf2-e08f-4d57-93d7-ca47134b4cabo@googlegroups.com> What's wrong the OP's question? Why can't just answer it? --Jach From rosuav at gmail.com Fri Oct 30 23:20:59 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 14:20:59 +1100 Subject: Why x+=1 doesn't return x value instead of an object In-Reply-To: References: Message-ID: On Sat, Oct 31, 2020 at 1:51 PM Jon Ribbens via Python-list wrote: > > On 2020-10-31, Stefan Ram wrote: > > Siddhharth Choudhary writes: > >>I want to know why x+=1 does not return the value of the variable. > > > > Which value? The old or the new one? > > > > Expressions never return values. > > Except when they're assignment expressions, when they do. Expressions DO have values, but assignment is a statement, not an expression. (Assignment expressions don't have augmented forms, so there's no ambiguity.) ChrisA From jon+usenet at unequivocal.eu Fri Oct 30 23:37:10 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sat, 31 Oct 2020 03:37:10 -0000 (UTC) Subject: Why x+=1 doesn't return x value instead of an object References: Message-ID: On 2020-10-31, Chris Angelico wrote: > On Sat, Oct 31, 2020 at 1:51 PM Jon Ribbens via Python-list > wrote: >> >> On 2020-10-31, Stefan Ram wrote: >> > Siddhharth Choudhary writes: >> >>I want to know why x+=1 does not return the value of the variable. >> > >> > Which value? The old or the new one? >> > >> > Expressions never return values. >> >> Except when they're assignment expressions, when they do. > > Expressions DO have values, but assignment is a statement, not an > expression. (Assignment expressions don't have augmented forms, so > there's no ambiguity.) Sorry, could you say that again in English? From random832 at fastmail.com Fri Oct 30 23:41:27 2020 From: random832 at fastmail.com (Random832) Date: Fri, 30 Oct 2020 23:41:27 -0400 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> Message-ID: <4b35d612-39d5-4c56-a43c-8aba4b815154@www.fastmail.com> On Fri, Oct 30, 2020, at 20:18, Igor Korot wrote: > Hi, > > On Fri, Oct 30, 2020 at 6:59 PM Peter J. Holzer wrote: > > So, assuming the user is invoking the application for the first time, > > how should an application determine how much of the screen it should > > use? It has to make some choice, and any hard-coded value is almost > > certainly wrong. So why should an application not use the screen size as > > one factor? > > It is not up to application. > It is up to the underlying layout system to decide. What is a "layout system"? I don't think such a thing exists, in general, for positioning top-level windows on major platforms. Each application has to write its own, and it is reasonable for the layout system itself [which, as I've pointed out, is part of the application - there is no such thing as a system service] to need access to this information. From rosuav at gmail.com Sat Oct 31 00:00:37 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 15:00:37 +1100 Subject: Why x+=1 doesn't return x value instead of an object In-Reply-To: References: Message-ID: On Sat, Oct 31, 2020 at 2:41 PM Jon Ribbens via Python-list wrote: > > On 2020-10-31, Chris Angelico wrote: > > On Sat, Oct 31, 2020 at 1:51 PM Jon Ribbens via Python-list > > wrote: > >> > >> On 2020-10-31, Stefan Ram wrote: > >> > Siddhharth Choudhary writes: > >> >>I want to know why x+=1 does not return the value of the variable. > >> > > >> > Which value? The old or the new one? > >> > > >> > Expressions never return values. > >> > >> Except when they're assignment expressions, when they do. > > > > Expressions DO have values, but assignment is a statement, not an > > expression. (Assignment expressions don't have augmented forms, so > > there's no ambiguity.) > > Sorry, could you say that again in English? An expression has a value. For instance, "x + 1" is an expression; its value is whatever you get by adding one to x. The expression "lambda x, y: x + y" also has a value - specifically, a function. Every expression has a value (unless it raises an exception at runtime). Statements do not have values. There's no meaningful value in "if x > 2:" or "pass". They do their stuff and that's that. (Some languages have expressions that can contain statements, such as function definitions. That doesn't change this, since the value of the expression is still the function object.) In Python, "x = 1" is a statement and does not have a value. So is "x += 1", which is called an augmented assignment, and it does both assignment and addition (possibly in-place). There is the special assignment expression form "x := 1", which does have a value; however, there's no augmented form "x +:=1" or "x :+= 1", so there's no way for the augmented form to have a value. In languages such as C, where augmented assignment is an expression, it's theoretically possible to write something like this: x += y -= z *= 3; This is not good code. Don't do it. But it IS legal. :) The most common valid uses of assignment as an expression in C are all with the simple form, such as quickly setting a number of things to the same value: x = y = z = 100; Messing around with augmented forms as expressions is usually a bad idea. There's one very very specific mutator (technically two - or four) in C that is useful as an expression, and that's the in-place increment/decrement operator; and it's very carefully designed so you get the choice of whether you want the before or the after. You can write "array[idx++]" to advance to the next slot, or "id = ++max_id" to claim the next ID and bump up the top marker. This has been proposed for Python a few times, but the use cases have never been strong enough to get it added to the language. I don't think we'll ever see "x += 1" become an expression in Python. ChrisA From rosuav at gmail.com Sat Oct 31 00:01:44 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 15:01:44 +1100 Subject: Best way to determine user's screensize? In-Reply-To: <4b35d612-39d5-4c56-a43c-8aba4b815154@www.fastmail.com> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <4b35d612-39d5-4c56-a43c-8aba4b815154@www.fastmail.com> Message-ID: On Sat, Oct 31, 2020 at 2:43 PM Random832 wrote: > > On Fri, Oct 30, 2020, at 20:18, Igor Korot wrote: > > Hi, > > > > On Fri, Oct 30, 2020 at 6:59 PM Peter J. Holzer wrote: > > > So, assuming the user is invoking the application for the first time, > > > how should an application determine how much of the screen it should > > > use? It has to make some choice, and any hard-coded value is almost > > > certainly wrong. So why should an application not use the screen size as > > > one factor? > > > > It is not up to application. > > It is up to the underlying layout system to decide. > > What is a "layout system"? I don't think such a thing exists, in general, for positioning top-level windows on major platforms. Each application has to write its own, and it is reasonable for the layout system itself [which, as I've pointed out, is part of the application - there is no such thing as a system service] to need access to this information. > Window managers most certainly do exist, and they are something that the user, not the application, controls. ChrisA From ikorot01 at gmail.com Sat Oct 31 01:26:29 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Sat, 31 Oct 2020 00:26:29 -0500 Subject: Best way to determine user's screensize? In-Reply-To: <4b35d612-39d5-4c56-a43c-8aba4b815154@www.fastmail.com> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <4b35d612-39d5-4c56-a43c-8aba4b815154@www.fastmail.com> Message-ID: Hi, On Fri, Oct 30, 2020 at 10:44 PM Random832 wrote: > > On Fri, Oct 30, 2020, at 20:18, Igor Korot wrote: > > Hi, > > > > On Fri, Oct 30, 2020 at 6:59 PM Peter J. Holzer wrote: > > > So, assuming the user is invoking the application for the first time, > > > how should an application determine how much of the screen it should > > > use? It has to make some choice, and any hard-coded value is almost > > > certainly wrong. So why should an application not use the screen size as > > > one factor? > > > > It is not up to application. > > It is up to the underlying layout system to decide. > > What is a "layout system"? I don't think such a thing exists, in general, for positioning top-level windows on major platforms. Each application has to write its own, and it is reasonable for the layout system itself [which, as I've pointed out, is part of the application - there is no such thing as a system service] to need access to this information. This one is for "JAVAsucks" - https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html This one is for wxWidgets - https://docs.wxwidgets.org/3.0/overview_sizer.html This one is for Qt - https://doc.qt.io/qt-5/layout.html This one is for GTK - https://developer.gnome.org/gtk3/stable/LayoutContainers.html Are you still going to argue "it does not exist"? Every cross-platform has a layout system otherwise it will a burden to write cross-platform apps. Thank you Thank you. > -- > https://mail.python.org/mailman/listinfo/python-list From PythonList at DancesWithMice.info Sat Oct 31 01:42:54 2020 From: PythonList at DancesWithMice.info (dn) Date: Sat, 31 Oct 2020 18:42:54 +1300 Subject: Why x+=1 doesn't return x value instead of an object In-Reply-To: References: Message-ID: On 31/10/2020 16:20, Chris Angelico wrote: > On Sat, Oct 31, 2020 at 1:51 PM Jon Ribbens via Python-list > wrote: >> >> On 2020-10-31, Stefan Ram wrote: >>> Siddhharth Choudhary writes: >>>> I want to know why x+=1 does not return the value of the variable. >>> >>> Which value? The old or the new one? >>> >>> Expressions never return values. >> >> Except when they're assignment expressions, when they do. > > Expressions DO have values, but assignment is a statement, not an > expression. (Assignment expressions don't have augmented forms, so > there's no ambiguity.) So, you've already realised that: >>> x = 1 >>> print( x += 2 ) File "", line 1 print( x += 2 ) isn't going to work. However it is possible to achieve something of what you ask (Python 3.8+), using the 'walrus operator' in/as an assignment-expression: >>> x = 1 >>> print( x := x + 2 ) 3 but as others have said, an augmented-expression is not a "named expression". Accordingly, the more usual walrus application will be something like: >>> if ( x := 1 + 2 ) > 1.5: ... print( f"Yes! { x }" ) ... else: ... print( f"No! { x } <= 1.5" ) ... Yes! 3 Documented in the manual at https://docs.python.org/3/reference/expressions.html?highlight=walrus#assignment-expressions Read more at https://www.python.org/dev/peps/pep-0572/ Free advice: whatever you do, don't call @Chris a walrus! -- Regards =dn From rosuav at gmail.com Sat Oct 31 02:41:23 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 17:41:23 +1100 Subject: Why x+=1 doesn't return x value instead of an object In-Reply-To: References: Message-ID: On Sat, Oct 31, 2020 at 4:44 PM dn via Python-list wrote: > Free advice: whatever you do, don't call @Chris a walrus! Yeah... I do have quite a moustache, but it doesn't merit a high title like that! :) ChrisA From barry at barrys-emacs.org Sat Oct 31 04:36:14 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Sat, 31 Oct 2020 08:36:14 +0000 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: > On 29 Oct 2020, at 15:54, flaskee via Python-list wrote: > > Hello! > > I've been reading the GUI toolkit posts. > > If anyone can give me a push in the right python direction on > my needs, I'd be grateful. > > This is for business applications, not games. > (but if a game toolkit fits...) > I choose to use PyQt5 for my apps that run on Linux, macOS and Windows. You can see my apps code if you wish to see working examples: https://barrys-emacs.org https://scm-workbench.barrys-emacs.org/ In the past I had used wxPython but it had too many problems and it was cheaper for me to port in PyQt5 then have to carry a lot of platform specific workarounds. PyQt5 can target iOS and android. With PyQt5 I can develop on Linux and have high confidence that the code will run the same way on macOS and Windows. Barry From hjp-python at hjp.at Sat Oct 31 07:29:43 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 12:29:43 +0100 Subject: Best way to determine user's screensize? In-Reply-To: <8ea0edf2-e08f-4d57-93d7-ca47134b4cabo@googlegroups.com> References: <8ea0edf2-e08f-4d57-93d7-ca47134b4cabo@googlegroups.com> Message-ID: <20201031112943.GA22631@hjp.at> On 2020-10-30 20:08:35 -0700, jfong at ms4.hinet.net wrote: > What's wrong the OP's question? Why can't just answer it? Igor already answered it: There is no best way in Python, because it depends on the framework (and there are many frameworks). 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 hjp-python at hjp.at Sat Oct 31 07:47:02 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 12:47:02 +0100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> Message-ID: <20201031114702.GB22631@hjp.at> On 2020-10-30 19:18:22 -0500, Igor Korot wrote: > On Fri, Oct 30, 2020 at 6:59 PM Peter J. Holzer wrote: > > On 2020-10-31 10:02:12 +1100, Chris Angelico wrote: > > > I add my voice to those who detest applications that think they know > > > best and decide that they own the entire screen. > > > > So, assuming the user is invoking the application for the first time, > > how should an application determine how much of the screen it should > > use? It has to make some choice, and any hard-coded value is almost > > certainly wrong. So why should an application not use the screen size as > > one factor? > > It is not up to application. > It is up to the underlying layout system to decide. This only works if all the GUI elements are of fixed size. If you are writing a MUA, for example, there are several elements which are essentially of arbitrary size: A list or tree of mailboxes. A list (or forest) of mails in the current mailbox. A pane to display the current mail. To size these properly you have to know what kind of information is going to be displayed. Depending on the screen size it may be better to only show one of them at a time. The application programmer knows this. The layout system doesn't. This should also be configurable by the user, which again means that the application has to a) provide a configuration UI and b) has to be able to set the layout the way the user configured it. Layout systems are important and useful. But they are tools, they can't do everything by themselves. In the end the application programmer has to decide how to use them. 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 hjp-python at hjp.at Sat Oct 31 08:02:03 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 13:02:03 +0100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> Message-ID: <20201031120203.GC22631@hjp.at> On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > On Sat, Oct 31, 2020 at 10:57 AM Peter J. Holzer wrote: > > On 2020-10-31 10:02:12 +1100, Chris Angelico wrote: > > > On Sat, Oct 31, 2020 at 9:55 AM flaskee via Python-list > > > wrote: > > > > I have done all of this resizing and layout stuff before. > > > > > > > > I just ignored the grouchy user with the hate over me wanting screensize. > > > > (every list has one of those types, eh? :-) > > > > > > > > Screensize, in part, determines the aspect ratio calcs to dynamically > > > > resize and place the components on the screen. > > > > > > > > > > So what would you do if it turns out that my screen is 5440 x 2104? > > > That's what mine is right now. > > > > That depends on the application. > > > > If for example the application is in image viewer and the image to be > > viewed is 4576x3432 pixels large, that wouldn't fit on the screen. > > Assuming 200 pixels of vertical chrome (title bar, window borders, menu > > bar and/or buttons), the image would have to be resized to (at most) > > 2539x1904 pixels. So the window would be sized to accommodate that. > > > > (If you use a multi-screen setup, the calculation should be based on > > the current screen, of course, not on the combined size of all screens) > > > > But what is the "current screen"? That's the problem. The one where the window manager decided to put the window? (Ok, there may be a bit of a catch-22 here: You might want that information before actually creating the window, but the window manager can only place the window once it's created. Plus the placement might depend on the size.) > MANY applications (mostly games) decide to put themselves on monitor > #4 and size themselves according to monitor #1, or some other > mismatching. Well, that's obviously a bug. (Presumably the programmer didn't expect there to be more than one screen, or at least not screens of different sizes.) > Or, I alt-tab away from something, come back in, and it resizes itself > to a different screen size. > > There is no valid way for an application to read my mind and size > itself. Attempting to query my screen size seems to just make things > worse in a lot of situations. You still haven't answered the question: Where should the initial window size come from? Does your window manager tell the application how large a window should be? And if it does, can you as a user configure that? I don't think mine (xfce) does that. (I guess tiling WMs generally do that, but I've never used one.) 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 hjp-python at hjp.at Sat Oct 31 08:06:26 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 13:06:26 +0100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: <20201031120626.GD22631@hjp.at> On 2020-10-30 20:47:50 -0400, songbird wrote: > Chris Angelico wrote: > > I add my voice to those who detest applications that think they know > > best and decide that they own the entire screen. It is incredibly > > annoying. > > do you object to a window being put in the approximate > center of the screen? Yes, I do. That puts all the windows on top of each other and I have to move them to a better position. I have configured my window manager to place new windows so that the overlap with existing windows is minimised. 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 lizzyhollins99 at gmail.com Sat Oct 31 08:35:32 2020 From: lizzyhollins99 at gmail.com (Betty Hollinshead) Date: Sat, 31 Oct 2020 05:35:32 -0700 (PDT) Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: <3536c216-7b2a-4f3a-9aa1-f8b4244e2b78n@googlegroups.com> On Saturday, 31 October 2020 at 08:36:48 UTC, Barry Scott wrote: > > On 29 Oct 2020, at 15:54, flaskee via Python-list wrote: > > > > Hello! > > > > I've been reading the GUI toolkit posts. > > > > If anyone can give me a push in the right python direction on > > my needs, I'd be grateful. > > > > This is for business applications, not games. > > (but if a game toolkit fits...) > > > I choose to use PyQt5 for my apps that run on Linux, macOS and Windows. > > You can see my apps code if you wish to see working examples: > > https://barrys-emacs.org > https://scm-workbench.barrys-emacs.org/ > > In the past I had used wxPython but it had too many problems and it was cheaper for > me to port in PyQt5 then have to carry a lot of platform specific workarounds. > > PyQt5 can target iOS and android. > > With PyQt5 I can develop on Linux and have high confidence that the code will run the > same way on macOS and Windows. > > Barry From lizzyhollins99 at gmail.com Sat Oct 31 08:42:46 2020 From: lizzyhollins99 at gmail.com (Betty Hollinshead) Date: Sat, 31 Oct 2020 05:42:46 -0700 (PDT) Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: <24153f67-588f-4a6f-99ee-d40085e38577n@googlegroups.com> On Saturday, 31 October 2020 at 08:36:48 UTC, Barry Scott wrote: > > On 29 Oct 2020, at 15:54, flaskee via Python-list wrote: > > > > Hello! > > > > I've been reading the GUI toolkit posts. > > > > snip > > > Barry Suggest you look at Glade and pure Python3 Works well on Linux (Fedora here) No idea about other platforms GUI Design: Glade GUI designer which produces an XML description of the target GUI (e.g. mainwin.glade) Python3 code outline from gi.repository import GObject, Gio, Gdk, Gtk ... class AppWindow(object): def __init__(): ... try: builder = Gtk.Builder.new_from_file("mainwin.glade") builder.connect_signals(self) except GObject.GError: print("Error reading GUI file") raise There is identical support for using the Glade xml in a C application (but Python is easier!). Liz From 2QdxY4RzWzUUiLuE at potatochowder.com Sat Oct 31 08:51:38 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Sat, 31 Oct 2020 07:51:38 -0500 Subject: Best way to determine user's screensize? In-Reply-To: <20201031120203.GC22631@hjp.at> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> Message-ID: <20201031125138.GB33753@scrozzle> On 2020-10-31 at 13:02:03 +0100, "Peter J. Holzer" wrote: > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > > There is no valid way for an application to read my mind and size > > itself. Attempting to query my screen size seems to just make things > > worse in a lot of situations. > You still haven't answered the question: Where should the initial > window size come from? Does your window manager tell the application > how large a window should be? And if it does, can you as a user > configure that? I don't think mine (xfce) does that. (I guess tiling > WMs generally do that, but I've never used one.) The intial/default window should be big enough to contain the initial/default content, regardless of the configuration of the screen(s)/monitor(s). "The GUI," whether it's something near the bottom, like X11, or something more complicated, like GTK or Qt, should have the information and/or the API to make the widgets usable and the text readable, possibly based on user configuration (e.g., I like 6 point type on my 288dpi laptop display; other people might like 12 point type on their 72dpi big screen monitor). From rosuav at gmail.com Sat Oct 31 08:57:08 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2020 23:57:08 +1100 Subject: Best way to determine user's screensize? In-Reply-To: <20201031125138.GB33753@scrozzle> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> Message-ID: On Sat, Oct 31, 2020 at 11:53 PM <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > > On 2020-10-31 at 13:02:03 +0100, > "Peter J. Holzer" wrote: > > > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > > > > There is no valid way for an application to read my mind and size > > > itself. Attempting to query my screen size seems to just make things > > > worse in a lot of situations. > > > You still haven't answered the question: Where should the initial > > window size come from? Does your window manager tell the application > > how large a window should be? And if it does, can you as a user > > configure that? I don't think mine (xfce) does that. (I guess tiling > > WMs generally do that, but I've never used one.) > > The intial/default window should be big enough to contain the > initial/default content, regardless of the configuration of the > screen(s)/monitor(s). "The GUI," whether it's something near the > bottom, like X11, or something more complicated, like GTK or Qt, should > have the information and/or the API to make the widgets usable and the > text readable, possibly based on user configuration (e.g., I like 6 > point type on my 288dpi laptop display; other people might like 12 point > type on their 72dpi big screen monitor). This. The window manager gets information from the internal layout manager, but the application itself shouldn't care. I should be able to build a window by saying "it should have a notebook, and that notebook should have a label saying Name and an input big enough for 20 characters, and below that a label saying Class and a drop-down with options Wizard, Cleric, Fighter, etc, etc, etc, etc". At no point should pixel sizes or screen sizes be within the scope of my application. ChrisA From hjp-python at hjp.at Sat Oct 31 09:37:52 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 14:37:52 +0100 Subject: Best way to determine user's screensize? In-Reply-To: <20201031125138.GB33753@scrozzle> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> Message-ID: <20201031133752.GA5683@hjp.at> On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > On 2020-10-31 at 13:02:03 +0100, > "Peter J. Holzer" wrote: > > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > > > There is no valid way for an application to read my mind and size > > > itself. Attempting to query my screen size seems to just make things > > > worse in a lot of situations. > > > You still haven't answered the question: Where should the initial > > window size come from? Does your window manager tell the application > > how large a window should be? And if it does, can you as a user > > configure that? I don't think mine (xfce) does that. (I guess tiling > > WMs generally do that, but I've never used one.) > > The intial/default window should be big enough to contain the > initial/default content, regardless of the configuration of the > screen(s)/monitor(s). As I already wrote in an answer to Igor, this is only possible if the initial/default content is of fixed size (or at least guaranteed to be smaller than the screen size). Very often this is not the case: An image viewer will be used to display images which are larger than the screen. A MUA may have to display hundreds of mailboxes, and maybe tens of thousands of mails in a single mailbox. In these cases an application can't use the "natural size": It would be bigger than the screen, and depending on the window manager, the user might not even be able to resize it because the handles are off-screen. It could use some size which is small enough to fit on any screen (how large is that? Can you assume 1366x768 these days?). But for most users this would be annoying, since they would have to resize the window. (And note that "the user has to do than only once, the second time the application can use the saved layout" doesn't hold either: The user may have invoked the application on a large desktop monitor the first time, but at some point they use the small laptop monitor or a projector.) I am very much a fan of letting layout and window managers do as much as possible. But I don't think they can do everything. They simply don't have the necessary information. 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 mats at wichmann.us Sat Oct 31 11:42:44 2020 From: mats at wichmann.us (Mats Wichmann) Date: Sat, 31 Oct 2020 09:42:44 -0600 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On 10/30/20 6:47 PM, songbird wrote: > Chris Angelico wrote: > ... >> I add my voice to those who detest applications that think they know >> best and decide that they own the entire screen. It is incredibly >> annoying. > > do you object to a window being put in the approximate > center of the screen? Absolutely! I'm fighting that on a system which, after an update, insists on opening new terminal windows centered - some recent policy change is now doing that instead of where the same thing was placed the last time it was open (I assume I'll find the knob for that eventually). As others have said, there's no one-size-fits-all; on a big screen you certainly don't want the same things as on a phone, where "take over the whole screen" might indeed be the only thing that makes sense. From mats at wichmann.us Sat Oct 31 11:55:00 2020 From: mats at wichmann.us (Mats Wichmann) Date: Sat, 31 Oct 2020 09:55:00 -0600 Subject: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. In-Reply-To: <1EA4B055-7A18-447F-9AA0-2F97ABDD35D8@hxcore.ol> References: <1EA4B055-7A18-447F-9AA0-2F97ABDD35D8@hxcore.ol> Message-ID: <3e3ca801-edfc-41b9-8f7f-890ff24d97fa@wichmann.us> On 10/30/20 1:38 PM, Gian_Xatzak. wrote: > When I tried to download ?matplotlib, it show me that message in the end: > > ? > > ERROR: Command errored out with exit status 1: python setup.py egg_info > Check the logs for full command output. > > ? > > *I have Windows 10, Python3.8.6(64bit) TL;DR - don't be in such a hurry to upgrade to 3.9. I'll bet the full errors would show pip is calling setup on the sdist version because you've updated to 3.9 and there's no wheel for 3.9 for matplotlib yet. The fallback, compilation, usually fails for Windows users, although you could attempt to follow the project's instructions for getting a build environment set up correctly. When various projects which have binary wheels release their versions supporting a new Python release is up to them; this happens every time a new X in the Python 3.X series is released. You can check for the presence of binary wheels for your system and Python version by querying for the package on pypi.org and clicking to see the downloadable files. There is a place you can get unofficial builds of many popular packages early on, but I kind of don't like to recommend people use "unofficial" builds. With suitable cautions, you can look there if you want (you'd be looking for names containing 'cp39') https://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib From grant.b.edwards at gmail.com Fri Oct 30 21:20:39 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 31 Oct 2020 01:20:39 -0000 (UTC) Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> Message-ID: On 2020-10-30, Peter J. Holzer wrote: > So, assuming the user is invoking the application for the first time, > how should an application determine how much of the screen it should > use? You arrange the widgets the way you want them using the user's settings for the toolkit and let the sizers figure out the size. > It has to make some choice, and any hard-coded value is almost > certainly wrong. Definitely, absolutely wrong. > So why should an application not use the screen size as > one factor? Because it's got nothing to do with the appropriate window size for the application? Why should the application start out any larger just because the screen is larger? -- Grant From grant.b.edwards at gmail.com Fri Oct 30 21:24:52 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 31 Oct 2020 01:24:52 -0000 (UTC) Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On 2020-10-30, flaskee via Python-list wrote: > In odd screen sizes or multi-monitor situations, > I make the best guess, Stop guessing. Let the window manager, and layout algorithm do the jobs for which they were designed. > but allow the user to alter things, via preferences. If you want to remember when a user resizes the application and re-open with that same geometry, that's OK. Doin't it "via preferences" is right out. From grant.b.edwards at gmail.com Fri Oct 30 21:27:31 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 31 Oct 2020 01:27:31 -0000 (UTC) Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On 2020-10-30, flaskee via Python-list wrote: > Funny thing about people who bitch and complain > and offer no help, Layout your widgets using appropriate sizers and constraints, and then let them and the window manager do their jobs. You shouldn't be messing about with window sizes and locations, or you end up with abominations like Visual Basic programmers used to produce in the bad old days. From grant.b.edwards at gmail.com Fri Oct 30 21:22:43 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 31 Oct 2020 01:22:43 -0000 (UTC) Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On 2020-10-31, songbird wrote: > Chris Angelico wrote: > ... >> I add my voice to those who detest applications that think they know >> best and decide that they own the entire screen. It is incredibly >> annoying. > > do you object to a window being put in the approximate > center of the screen? YES. I've configured my window manager so windows start up where I want them to start up. It's none of the application's business where it's window is. When developing an application, try to remember IT'S NOT YOUR COMPUTER. From grant.b.edwards at gmail.com Fri Oct 30 22:04:28 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 31 Oct 2020 02:04:28 -0000 (UTC) Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On 2020-10-31, Chris Angelico wrote: > >> do you object to a window being put in the approximate >> center of the screen? >> > > If that's where my window manager chooses to put it, great! The > application just says "I want a window of this size" But let the widget/toolkit layout engine figure out the size. The application developer should just specify what widgets are needed and how they are to be arranged. The developer should _not_ be specifying window sizes. > and the window manager decides where that should go. The application > doesn't. Exactly. Don't try to override the window manager if I've configured it to open your application in at certain location and/or a certain window size. It's my computer. From tjreedy at udel.edu Sat Oct 31 04:40:34 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 31 Oct 2020 04:40:34 -0400 Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: On 10/30/2020 12:05 PM, Grant Edwards wrote: > On 2020-10-30, flaskee via Python-list wrote: > >> What is the best approach to determining the user's available >> screensize, when they open your python application? IDLE, based on tkinter based on tcl/tk has a feature to vertically zoom an editor window to the full usable height, which is vertical pixel - top and or bottom taskbar pixels. The only way we found to do that is to go full screen, get the window size, and revert to previous size. Not foolproof (or rather, not expert-proof), but a best-known effor. > All you need to know is how big your application window is. The user's > available screen size is none of your business. See above. -- Terry Jan Reedy From pjfarley3 at earthlink.net Sat Oct 31 01:17:23 2020 From: pjfarley3 at earthlink.net (pjfarley3 at earthlink.net) Date: Sat, 31 Oct 2020 01:17:23 -0400 Subject: Can property getters and setters have additional arguments? Message-ID: <000001d6af45$1df77850$59e668f0$@earthlink.net> I asked this question over on the python-forum-io group but haven't gotten much in the way of answers. I hope someone here can advise me. I am trying to implement getters and setters in a class using a numpy array as the base instance value, but I am not able to pass an array index argument to the getter function (and probably not to the setter function, but it never gets that far). This is all happening on a Win10x64 system using python 3.8.5. Please help me understand whether what I tried to code here is even possible. Peter The code is as follows: ---- cut here ---- import numpy as np class Matrix: def __init__(self, msize): self.msize = msize self.mvalues = np.full([msize + 2, msize + 2, msize + 2], -1, dtype=np.int32) self.mvalues[1:-1, 1:-1, 1:-1] = 0 self.visited = np.zeros([msize + 2, msize + 2, msize + 2], dtype=np.int32) @property def visits(self, coord): return self.visited[coord[0], coord[1], coord[2]] @visits.setter def incr_visits(self, coord, incr): self.visited[coord[0], coord[1], coord[2]] += incr def Coord(x, y, z): return np.full([3,], (x, y, z), dtype=np.int32) mycoord = Coord(1, 2, 3) print("mycoord={}".format(mycoord)) mygal = Matrix(10) print("Before set:{}".format(mygal.visits(mycoord))) mygal.incr_visits(mycoord, 10) print("After set:{}".format(mygal.visits(mycoord))) ---- cut here ---- The output I get is as follows: ---- output ---- mycoord=[1 2 3] Traceback (most recent call last): File "C:\Users\MyUser\Test\clstest4.py", line 28, in print("Before set:{}".format(mygal.visits(mycoord))) TypeError: visits() missing 1 required positional argument: 'coord' ---- output ---- From grant.b.edwards at gmail.com Sat Oct 31 11:14:52 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 31 Oct 2020 15:14:52 -0000 (UTC) Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <4b35d612-39d5-4c56-a43c-8aba4b815154@www.fastmail.com> Message-ID: On 2020-10-31, Random832 wrote: > On Fri, Oct 30, 2020, at 20:18, Igor Korot wrote: >> Hi, >> >> On Fri, Oct 30, 2020 at 6:59 PM Peter J. Holzer wrote: >> > So, assuming the user is invoking the application for the first time, >> > how should an application determine how much of the screen it should >> > use? It has to make some choice, and any hard-coded value is almost >> > certainly wrong. So why should an application not use the screen size as >> > one factor? >> >> It is not up to application. >> It is up to the underlying layout system to decide. > > What is a "layout system"? In a GUI toolkit, it's a set of constructs that lets you specify the relative positions of widgets, which widgets are flexible and which aren't, and so on. The layout system then determines the sizes of widgets and windows. > I don't think such a thing exists, in > general, for positioning top-level windows on major platforms. On Linux/Unix, there certainly is. It's called a window manager. There are many to chose from, and they have various user-configurable settings that allow the user to control the sizes and positions of top-level windows. > Each application has to write its own, Nonsense. > and it is reasonable for the layout system itself [which, as I've > pointed out, is part of the application - there is no such thing as > a system service] to need access to this information. There are two levels of layout system services: the GUI toolkit/framework and the window manager. From grant.b.edwards at gmail.com Sat Oct 31 11:17:36 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 31 Oct 2020 15:17:36 -0000 (UTC) Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> Message-ID: On 2020-10-31, Peter J. Holzer wrote: > You still haven't answered the question: Where should the initial window > size come from? The GUI toolkit used by the application calculates a "desired" window size based on the widgets and layout constraints. That desire is passed to the window manager, and the window manager then decides what the winow size is. > Does your window manager tell the application how large a window > should be? Yes. > And if it does, can you as a user configure that? Yes. > I don't think mine (xfce) does that. (I guess tiling WMs generally > do that, but I've never used one.) -- Grant From grant.b.edwards at gmail.com Sat Oct 31 11:22:30 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 31 Oct 2020 15:22:30 -0000 (UTC) Subject: Best way to determine user's screensize? References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> Message-ID: On 2020-10-31, Peter J. Holzer wrote: > Very often this is not the case: An image viewer will be used to > display images which are larger than the screen. Tell the image widget what image you want to display, and then forget about it. Let the toolkit and window manager do their jobs. > A MUA may have to display hundreds of mailboxes, and maybe tens of > thousands of mails in a single mailbox. No. It doesn't. It has to display a tree widget that shows N items and holds tens of thousands of items, or a scrolling list widget than shows M items and holds tens of thousands of items. Pick reasonable initial default values for N,M and then let the window manager and user do the right thing. > I am very much a fan of letting layout and window managers do as > much as possible. But I don't think they can do everything. They > simply don't have the necessary information. They do in a well-written application. -- Gran From pjfarley3 at earthlink.net Sat Oct 31 10:54:17 2020 From: pjfarley3 at earthlink.net (pjfarley3 at earthlink.net) Date: Sat, 31 Oct 2020 10:54:17 -0400 Subject: Can property getters and setters have additional arguments? Message-ID: <000001d6af95$b57a7e20$206f7a60$@earthlink.net> Apologies if you receive two copies of this message, but I sent it almost 10 hours ago and still have not seen it come back to me or appear in the archives. I would appreciate any help or RTFM you can provide. Peter > -----Original Message----- > From: Peter Farley > Sent: Saturday, October 31, 2020 1:17 AM > To: 'python-list at python.org' > Subject: Can property getters and setters have additional arguments? > > I asked this question over on the python-forum-io group but haven't gotten > much in the way of answers. I hope someone here can advise me. > > I am trying to implement getters and setters in a class using a numpy array as the > base instance value, but I am not able to pass an array index argument to the > getter function (and probably not to the setter function, but it never gets that > far). > > This is all happening on a Win10x64 system using python 3.8.5. > > Please help me understand whether what I tried to code here is even possible. > > Peter > > The code is as follows: > > ---- cut here ---- > import numpy as np > > class Matrix: > def __init__(self, msize): > self.msize = msize > self.mvalues = np.full([msize + 2, msize + 2, msize + 2], -1, > dtype=np.int32) > self.mvalues[1:-1, 1:-1, 1:-1] = 0 > self.visited = np.zeros([msize + 2, msize + 2, msize + 2], > dtype=np.int32) > > @property > def visits(self, coord): > return self.visited[coord[0], coord[1], coord[2]] > > @visits.setter > def incr_visits(self, coord, incr): > self.visited[coord[0], coord[1], coord[2]] += incr > > > def Coord(x, y, z): > return np.full([3,], (x, y, z), dtype=np.int32) > > mycoord = Coord(1, 2, 3) > print("mycoord={}".format(mycoord)) > > mygal = Matrix(10) > print("Before set:{}".format(mygal.visits(mycoord))) > > mygal.incr_visits(mycoord, 10) > print("After set:{}".format(mygal.visits(mycoord))) > ---- cut here ---- > > The output I get is as follows: > > ---- output ---- > mycoord=[1 2 3] > Traceback (most recent call last): > File "C:\Users\MyUser\Test\clstest4.py", line 28, in > print("Before set:{}".format(mygal.visits(mycoord))) > TypeError: visits() missing 1 required positional argument: 'coord' > ---- output ---- > From ikorot01 at gmail.com Sat Oct 31 12:37:10 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Sat, 31 Oct 2020 11:37:10 -0500 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: Hi, Barry, On Sat, Oct 31, 2020, 3:39 AM Barry Scott wrote: > > > > On 29 Oct 2020, at 15:54, flaskee via Python-list < > python-list at python.org> wrote: > > > > Hello! > > > > I've been reading the GUI toolkit posts. > > > > If anyone can give me a push in the right python direction on > > my needs, I'd be grateful. > > > > This is for business applications, not games. > > (but if a game toolkit fits...) > > > > I choose to use PyQt5 for my apps that run on Linux, macOS and Windows. > > You can see my apps code if you wish to see working examples: > > https://barrys-emacs.org > https://scm-workbench.barrys-emacs.org/ < > https://scm-workbench.barrys-emacs.org/> > > In the past I had used wxPython but it had too many problems and it was > cheaper for > me to port in PyQt5 then have to carry a lot of platform specific > workarounds. > > PyQt5 can target iOS and android. > > With PyQt5 I can develop on Linux and have high confidence that the code > will run the > same way on macOS and Windows. > Qt does not use native controls on 3 major platforms and so is out of the question... Thank you. > Barry > > -- > https://mail.python.org/mailman/listinfo/python-list > From ikorot01 at gmail.com Sat Oct 31 12:43:52 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Sat, 31 Oct 2020 11:43:52 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> Message-ID: Hi, On Sat, Oct 31, 2020, 8:00 AM Chris Angelico wrote: > On Sat, Oct 31, 2020 at 11:53 PM <2QdxY4RzWzUUiLuE at potatochowder.com> > wrote: > > > > On 2020-10-31 at 13:02:03 +0100, > > "Peter J. Holzer" wrote: > > > > > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > > > > > > There is no valid way for an application to read my mind and size > > > > itself. Attempting to query my screen size seems to just make things > > > > worse in a lot of situations. > > > > > You still haven't answered the question: Where should the initial > > > window size come from? Does your window manager tell the application > > > how large a window should be? And if it does, can you as a user > > > configure that? I don't think mine (xfce) does that. (I guess tiling > > > WMs generally do that, but I've never used one.) > > > > The intial/default window should be big enough to contain the > > initial/default content, regardless of the configuration of the > > screen(s)/monitor(s). "The GUI," whether it's something near the > > bottom, like X11, or something more complicated, like GTK or Qt, should > > have the information and/or the API to make the widgets usable and the > > text readable, possibly based on user configuration (e.g., I like 6 > > point type on my 288dpi laptop display; other people might like 12 point > > type on their 72dpi big screen monitor). > > This. The window manager gets information from the internal layout > manager, but the application itself shouldn't care. I should be able > to build a window by saying "it should have a notebook, and that > notebook should have a label saying Name and an input big enough for > 20 characters, and below that a label saying Class and a drop-down > with options Wizard, Cleric, Fighter, etc, etc, etc, etc". At no point > should pixel sizes or screen sizes be within the scope of my > application. > Amen to that, Chris. Thank you. > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Sat Oct 31 12:47:08 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 1 Nov 2020 03:47:08 +1100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On Sun, Nov 1, 2020 at 3:35 AM Grant Edwards wrote: > > On 2020-10-31, Chris Angelico wrote: > > > >> do you object to a window being put in the approximate > >> center of the screen? > >> > > > > If that's where my window manager chooses to put it, great! The > > application just says "I want a window of this size" > > But let the widget/toolkit layout engine figure out the size. The > application developer should just specify what widgets are needed and > how they are to be arranged. The developer should _not_ be specifying > window sizes. Correct. There's effectively a negotiation up and down the chain where the application itself doesn't care one iota what a "pixel" is, and its window's size is defined by content. A lot of sizes will be defined in terms of text ("I want an entry field big enough for 40 characters", which is an approximation of course, but a useful one), and others might be defined by other things, but the precise pixel dimensions are up to the layout engine - which should be using native widgets, which effectively puts the control back in the hands of the window manager. And putting control in the hands of the window manager means putting it in the hands of the user. The user can configure his/her computer completely. It is not the application's computer, it is the user's. ChrisA From hjp-python at hjp.at Sat Oct 31 12:48:55 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 17:48:55 +0100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> Message-ID: <20201031164855.GA5897@hjp.at> On 2020-10-31 01:20:39 -0000, Grant Edwards wrote: > On 2020-10-30, Peter J. Holzer wrote: > > > So, assuming the user is invoking the application for the first time, > > how should an application determine how much of the screen it should > > use? > > You arrange the widgets the way you want them using the user's > settings for the toolkit and let the sizers figure out the size. Ok. I am trying one last time. Consider a very minimalistic image viewer. It has a menu bar at the top and shows one image. The path to the image may be passed as sys.argv[1], in which case it should be immediately displayed. The image should be displayed in "natural" size but must be scaled down if it doesn't fit. How do you do that? You may use any framework, preferrably (since this is a Python group) a cross-platform framework usable from Python. 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 ethan at stoneleaf.us Sat Oct 31 12:48:50 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Sat, 31 Oct 2020 09:48:50 -0700 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: On 10/30/20 6:24 PM, Grant Edwards wrote: > On 2020-10-30, flaskee via Python-list wrote: >> but allow the user to alter things, via preferences. > > If you want to remember when a user resizes the application and > re-open with that same geometry, that's OK. Doin't it "via > preferences" is right out. Why is using preferences "right out"? Is that not the user saying where they want the app to be positioned? -- ~Ethan~ From rosuav at gmail.com Sat Oct 31 12:49:09 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 1 Nov 2020 03:49:09 +1100 Subject: Can property getters and setters have additional arguments? In-Reply-To: <000001d6af45$1df77850$59e668f0$@earthlink.net> References: <000001d6af45$1df77850$59e668f0$@earthlink.net> Message-ID: On Sun, Nov 1, 2020 at 3:46 AM wrote: > > I asked this question over on the python-forum-io group but haven't gotten > much in the way of answers. I hope someone here can advise me. > > I am trying to implement getters and setters in a class using a numpy array > as the base instance value, but I am not able to pass an array index > argument to the getter function (and probably not to the setter function, > but it never gets that far). > I'm not sure why you're using getters and setters there, but I think what you want is best handled with a simple member function. Try to keep it really really simple and it'll almost certainly be correct. ChrisA From ikorot01 at gmail.com Sat Oct 31 12:54:59 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Sat, 31 Oct 2020 11:54:59 -0500 Subject: Best way to determine user's screensize? In-Reply-To: <20201031133752.GA5683@hjp.at> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> Message-ID: Hi, On Sat, Oct 31, 2020, 8:40 AM Peter J. Holzer wrote: > On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > On 2020-10-31 at 13:02:03 +0100, > > "Peter J. Holzer" wrote: > > > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > > > > There is no valid way for an application to read my mind and size > > > > itself. Attempting to query my screen size seems to just make things > > > > worse in a lot of situations. > > > > > You still haven't answered the question: Where should the initial > > > window size come from? Does your window manager tell the application > > > how large a window should be? And if it does, can you as a user > > > configure that? I don't think mine (xfce) does that. (I guess tiling > > > WMs generally do that, but I've never used one.) > > > > The intial/default window should be big enough to contain the > > initial/default content, regardless of the configuration of the > > screen(s)/monitor(s). > > As I already wrote in an answer to Igor, this is only possible if the > initial/default content is of fixed size (or at least guaranteed to be > smaller than the screen size). > Any control at any given moment has a fixed size. If I can't set the initial size of the control in the appropriate layout system, then this is not a layout system. After the initial size is set it is up to the application to properly give the aspect ratio, font sizes, etc when the application is moved between the windows, resized, or DPI has changed, etc. > Very often this is not the case: An image viewer will be used to display > images which are larger than the screen. A MUA may have to display > hundreds of mailboxes, and maybe tens of thousands of mails in a single > mailbox. > > In these cases an application can't use the "natural size": It would be > bigger than the screen, and depending on the window manager, the user > might not even be able to resize it because the handles are off-screen. > What is natural size? Please define this term. > It could use some size which is small enough to fit on any screen (how > large is that? Can you assume 1366x768 these days?). But for most users > this would be annoying, since they would have to resize the window. > > (And note that "the user has to do than only once, the second time the > application can use the saved layout" doesn't hold either: The user may > have invoked the application on a large desktop monitor the first time, > but at some point they use the small laptop monitor or a projector.) > This is exactly my point. If the underlying toolkit is smart enough and the layout system is good then it won't matter. > I am very much a fan of letting layout and window managers do as much as > possible. But I don't think they can do everything. They simply don't > have the necessary information. > Of course not. Thats why software devs are paid big money to do proper designs. ? Thank you. > hp > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp at hjp.at | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > -- > https://mail.python.org/mailman/listinfo/python-list > From 2QdxY4RzWzUUiLuE at potatochowder.com Sat Oct 31 12:58:41 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Sat, 31 Oct 2020 11:58:41 -0500 Subject: Best way to determine user's screensize? In-Reply-To: <20201031133752.GA5683@hjp.at> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> Message-ID: <20201031165841.GC33753@scrozzle> On 2020-10-31 at 14:37:52 +0100, "Peter J. Holzer" wrote: > On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > The intial/default window should be big enough to contain the > > initial/default content, regardless of the configuration of the > > screen(s)/monitor(s). > > As I already wrote in an answer to Igor, this is only possible if the > initial/default content is of fixed size ... Bear with me, but I think that that's part of the problem. Suppose my application edits documents. The initial content is two buttons, New and Open (I depend on the underlying OS and/or window manager for quitting). Is the window a fixed size? No, it's big enough to hold two buttons, sized and scaled based on user supplied defaults, possibly at a lower level, like X11 or Qt. Placement of the window is up to the window manager, which is also ultimately configured by the user. > ... (or at least guaranteed to be smaller than the screen size). Then how will I *ever* display that 8x10 glossy (with my apologies for the idiom; 8x10 inches is a "standard" size for a physical desk photo) of yours truly on my phone? > Very often this is not the case: An image viewer will be used to display > images which are larger than the screen. A MUA may have to display > hundreds of mailboxes, and maybe tens of thousands of mails in a single > mailbox. I never claimed it was easy. Yes, the author of an MUA has to make a guess and a bunch of decisions about a useful default setup (such a set of defaults already appears elsewhere in this thread). But I'm sticking to my story: that setup should be based on *application domain* objects, like messages and mailboxes, and not size(s) of the screen(s) (in pixels or inches). Also, yes, image viewers are different from MUAs. The latter has to be much more aware of certain aspects of the display devices(s), but should still base window sizes on *content* rather than choosing to be "full screens (plural), because I'm the most important application ever." > In these cases an application can't use the "natural size": It would be > bigger than the screen, and depending on the window manager, the user > might not even be able to resize it because the handles are off-screen. I remember window managers that let applications open windows that I can't move. Aside from a few tricks to "hide" windows, that's a bug. > It could use some size which is small enough to fit on any screen (how > large is that? Can you assume 1366x768 these days?). But for most users > this would be annoying, since they would have to resize the window. It should request the size it wants, and be prepared to handle not getting it. Usually, that means scroll bars. > (And note that "the user has to do than only once, the second time the > application can use the saved layout" doesn't hold either: The user may > have invoked the application on a large desktop monitor the first time, > but at some point they use the small laptop monitor or a projector.) Aha! On this we agree! :-) > I am very much a fan of letting layout and window managers do as much > as possible. But I don't think they can do everything. They simply > don't have the necessary information. I don't think we're disagreeing too much here, either. IMO, the user should be in control, whether by config file or command line or whatever, and not the application inflicting its own ideas on me about how to use my screen real estate. From ikorot01 at gmail.com Sat Oct 31 12:59:06 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Sat, 31 Oct 2020 11:59:06 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> Message-ID: Hi, On Sat, Oct 31, 2020, 11:33 AM Grant Edwards wrote: > On 2020-10-31, songbird wrote: > > Chris Angelico wrote: > > ... > >> I add my voice to those who detest applications that think they know > >> best and decide that they own the entire screen. It is incredibly > >> annoying. > > > > do you object to a window being put in the approximate > > center of the screen? > > YES. I've configured my window manager so windows start up where I > want them to start up. It's none of the application's business where > it's window is. > > When developing an application, try to remember IT'S NOT YOUR > COMPUTER. > And its not you that will use an application. So whatever works for you may not work for user. Thank you. > > -- > https://mail.python.org/mailman/listinfo/python-list > From ikorot01 at gmail.com Sat Oct 31 13:07:24 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Sat, 31 Oct 2020 12:07:24 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> Message-ID: Hi, On Sat, Oct 31, 2020, 11:40 AM Grant Edwards wrote: > On 2020-10-31, Peter J. Holzer wrote: > > > Very often this is not the case: An image viewer will be used to > > display images which are larger than the screen. > > Tell the image widget what image you want to display, and then forget > about it. Let the toolkit and window manager do their jobs. > You also should pick an appropriate control for displaying it. I don't think you can use static window - you should be using something with the scrollbar, which will size accordingly and display scrollers on demand. > > A MUA may have to display hundreds of mailboxes, and maybe tens of > > thousands of mails in a single mailbox. > > No. It doesn't. It has to display a tree widget that shows N items and > holds tens of thousands of items, or a scrolling list widget than > shows M items and holds tens of thousands of items. Pick reasonable > initial default values for N,M and then let the window manager and > user do the right thing. > Exactly. > > I am very much a fan of letting layout and window managers do as > > much as possible. But I don't think they can do everything. They > > simply don't have the necessary information. > > They do in a well-written application. > As I said earlier - that's why devs get their money. > -- > Gran > > -- > https://mail.python.org/mailman/listinfo/python-list > From ikorot01 at gmail.com Sat Oct 31 13:22:39 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Sat, 31 Oct 2020 12:22:39 -0500 Subject: Best way to determine user's screensize? In-Reply-To: <20201031165841.GC33753@scrozzle> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> <20201031165841.GC33753@scrozzle> Message-ID: Hi, On Sat, Oct 31, 2020, 12:01 PM <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > On 2020-10-31 at 14:37:52 +0100, > "Peter J. Holzer" wrote: > > > On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > > > The intial/default window should be big enough to contain the > > > initial/default content, regardless of the configuration of the > > > screen(s)/monitor(s). > > > > As I already wrote in an answer to Igor, this is only possible if the > > initial/default content is of fixed size ... > > Bear with me, but I think that that's part of the problem. Suppose my > application edits documents. The initial content is two buttons, New > and Open (I depend on the underlying OS and/or window manager for > quitting). Is the window a fixed size? No, it's big enough to hold two > buttons, sized and scaled based on user supplied defaults, possibly at a > lower level, like X11 or Qt. Placement of the window is up to the > window manager, which is also ultimately configured by the user. > It is also based on the theme used and the screen DPI > > ... (or at least guaranteed to be smaller than the screen size). > > Then how will I *ever* display that 8x10 glossy (with my apologies for > the idiom; 8x10 inches is a "standard" size for a physical desk photo) > of yours truly on my phone? > ? > > Very often this is not the case: An image viewer will be used to display > > images which are larger than the screen. A MUA may have to display > > hundreds of mailboxes, and maybe tens of thousands of mails in a single > > mailbox. > > I never claimed it was easy. Yes, the author of an MUA has to make a > guess and a bunch of decisions about a useful default setup (such a set > of defaults already appears elsewhere in this thread). But I'm sticking > to my story: that setup should be based on *application domain* > objects, like messages and mailboxes, and not size(s) of the screen(s) > (in pixels or inches). > > Also, yes, image viewers are different from MUAs. The latter has to be > much more aware of certain aspects of the display devices(s), but should > still base window sizes on *content* rather than choosing to be "full > screens (plural), because I'm the most important application ever." > Agreed. However, the application may start full screen on the first run and let the user position and size it saving it for restarting. Or the app can let the WM position it and again let the user place it saving the position/size for restart. > > In these cases an application can't use the "natural size": It would be > > bigger than the screen, and depending on the window manager, the user > > might not even be able to resize it because the handles are off-screen. > > I remember window managers that let applications open windows that I > can't move. Aside from a few tricks to "hide" windows, that's a bug. > > > It could use some size which is small enough to fit on any screen (how > > large is that? Can you assume 1366x768 these days?). But for most users > > this would be annoying, since they would have to resize the window. > > It should request the size it wants, and be prepared to handle not > getting it. Usually, that means scroll bars. > > > (And note that "the user has to do than only once, the second time the > > application can use the saved layout" doesn't hold either: The user may > > have invoked the application on a large desktop monitor the first time, > > but at some point they use the small laptop monitor or a projector.) > > Aha! On this we agree! :-) > > > I am very much a fan of letting layout and window managers do as much > > as possible. But I don't think they can do everything. They simply > > don't have the necessary information. > > I don't think we're disagreeing too much here, either. IMO, the user > should be in control, whether by config file or command line or > whatever, and not the application inflicting its own ideas on me about > how to use my screen real estate. > -- > https://mail.python.org/mailman/listinfo/python-list > From python.list at tim.thechases.com Sat Oct 31 13:25:43 2020 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 31 Oct 2020 12:25:43 -0500 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> Message-ID: <20201031122543.67ac8951@bigbox.attlocal.net> On 2020-10-31 15:22, Grant Edwards wrote: > > A MUA may have to display hundreds of mailboxes, and maybe tens of > > thousands of mails in a single mailbox. > > No. It doesn't. It has to display a tree widget that shows N items > and holds tens of thousands of items, or a scrolling list widget > than shows M items and holds tens of thousands of items. Pick > reasonable initial default values for N,M and then let the window > manager and user do the right thing. But that's exactly the issue. On my phone, a "reasonable default N" might be 7 items and consume the whole screen; whereas on my netbook, a "reasonable default N" might be 15 in one layout or 25 in another; and on my daily driver, a "reasonable default N" might well be 50 or 100 depending on layout or monitor orientation. How does the application determine "reasonable"? It probes the system for screen dimensions (hopefully with multi-monitor smarts) and then makes an attempt to paint the display. This doesn't free it from being subject to a window manager's subsequent constraints, but at least allows the application to make some sensible choices for initial defaults. Some window-managers are dumb (glares at Windows), some are accommodating (I like how Fluxbox behaves), some are dictatorial (e.g. tiling window managers that give far less wiggle-room for applications' dimensions), and some largely ignore the user ("maximize" on MacOS annoys me to no end, maximizing only enough to display all the content; when what I want is to obscure everything else for single-app focus; requiring me to manually resize the window with the mouse so it fills the screen). -tkc From rosuav at gmail.com Sat Oct 31 14:19:18 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 1 Nov 2020 05:19:18 +1100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> Message-ID: On Sun, Nov 1, 2020 at 4:10 AM Igor Korot wrote: > > Hi, > > On Sat, Oct 31, 2020, 8:40 AM Peter J. Holzer wrote: > > > On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > > On 2020-10-31 at 13:02:03 +0100, > > > "Peter J. Holzer" wrote: > > > > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > > > > > There is no valid way for an application to read my mind and size > > > > > itself. Attempting to query my screen size seems to just make things > > > > > worse in a lot of situations. > > > > > > > You still haven't answered the question: Where should the initial > > > > window size come from? Does your window manager tell the application > > > > how large a window should be? And if it does, can you as a user > > > > configure that? I don't think mine (xfce) does that. (I guess tiling > > > > WMs generally do that, but I've never used one.) > > > > > > The intial/default window should be big enough to contain the > > > initial/default content, regardless of the configuration of the > > > screen(s)/monitor(s). > > > > As I already wrote in an answer to Igor, this is only possible if the > > initial/default content is of fixed size (or at least guaranteed to be > > smaller than the screen size). > > > > Any control at any given moment has a fixed size. Yes - as determined by the layout manager, NOT the application. > If I can't set the initial size of the control in the appropriate layout > system, then this is not a layout system. Sure, but the initial size should not be defined in pixels - it should be defined by whatever makes logical sense ("a list box with room to show these items"). > After the initial size is set it is up to the application to properly give > the aspect ratio, font sizes, etc when the application is moved between the > windows, resized, or DPI has changed, etc. Why? Are you running on a potato where these kinds of basics aren't handled by the window manager? Get a better window manager. > > It could use some size which is small enough to fit on any screen (how > > large is that? Can you assume 1366x768 these days?). But for most users > > this would be annoying, since they would have to resize the window. > > > > (And note that "the user has to do than only once, the second time the > > application can use the saved layout" doesn't hold either: The user may > > have invoked the application on a large desktop monitor the first time, > > but at some point they use the small laptop monitor or a projector.) > > > > This is exactly my point. > If the underlying toolkit is smart enough and the layout system is good > then it won't matter. > > > > I am very much a fan of letting layout and window managers do as much as > > possible. But I don't think they can do everything. They simply don't > > have the necessary information. > > > > Of course not. > Thats why software devs are paid big money to do proper designs. > And that's why the companies that pay big money to get software devs to do "proper designs" inevitably end up with pixel-precise rigid layouts that are utterly unusable on any system the devs didn't test on. Meanwhile, people like me - and several others who've posted in this thread - take the lower-effort option that gives better results. We define our layouts by rules, and allow the system to define the flow. Pages like this might be a bit ugly, but I've spent maybe half an hour working on the layout: https://sikorsky.rosuav.com/hypetrain?for=devicat The mobile version took me FAR more effort. I might have put... an entire hour into this. Maybe even 90 minutes. https://sikorsky.rosuav.com/hypetrain?for=devicat&mobile=1 Try those on different sizes of screens. Try them on different font sizes, DPI settings, or anything else you care about. They might not be the fanciest, they might not be the most showy, but they're not much more ugly on any other system than they are on my own. I do the same with desktop layouts too, although it's harder to showcase that. My Dungeons & Dragons character sheet manager is entirely rule-based in its GUI, with everything defined as "put a box here labelled Attributes, and inside it, label/input pairs for STR, DEX, INT, WIS, CON, CHA". It is *far* easier to maintain than something where you have to manually lay everything out in pixel positions. Why do people get paid big money to make suboptimal designs? Because the people paying them want something that looks good, not something that can actually be used by everyone. Because actual usability testing is incredibly rare. Because it's really hard to put a graph of how annoyed your customers get with your web site onto a PowerPoint slide. ChrisA From hjp-python at hjp.at Sat Oct 31 14:24:34 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 19:24:34 +0100 Subject: Best way to determine user's screensize? In-Reply-To: <20201031165841.GC33753@scrozzle> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> <20201031165841.GC33753@scrozzle> Message-ID: <20201031182434.GB5897@hjp.at> On 2020-10-31 11:58:41 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > On 2020-10-31 at 14:37:52 +0100, > "Peter J. Holzer" wrote: > > > On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > > > The intial/default window should be big enough to contain the > > > initial/default content, regardless of the configuration of the > > > screen(s)/monitor(s). > > > > As I already wrote in an answer to Igor, this is only possible if the > > initial/default content is of fixed size ... > > Bear with me, but I think that that's part of the problem. Suppose my > application edits documents. The initial content is two buttons, New > and Open (I depend on the underlying OS and/or window manager for > quitting). Is the window a fixed size? No, it's big enough to hold two > buttons, sized and scaled based on user supplied defaults, possibly at a > lower level, like X11 or Qt. In my book that counts as fixed size. The layout manager can use the information it has (font family and size, margins, etc.) compute the sizes of the two buttons, then compute the size of the container (possibly using that info to resize the buttons), and use that to compute the size of the window. The application then requests a window of that size from the window manager. Now consider what happens when the user clicks on that Open button and loads the document to be edited. You have to add a text editor widget to your window. How large should that be? You know hwo many lines your document has, but using a 5000 line text widget for a 5000 line document would be ridiculous. You could say "the rest of the window", but your window is just large enough for the buttons, so your text widget would end up with 0 lines - not very useful. Any fixed size will be too large or too small (and while users can usually cope with too small, many of them are completely flummoxed by windows which are too large). > Placement of the window is up to the > window manager, which is also ultimately configured by the user. No argument there. I'm talking about determining the size of widgets. > > ... (or at least guaranteed to be smaller than the screen size). > > Then how will I *ever* display that 8x10 glossy (with my apologies for > the idiom; 8x10 inches is a "standard" size for a physical desk photo) > of yours truly on my phone? Phones are easy: All apps are full-screen (or half-screen, if the OS supports that). The app can't request a window size, it has to work with what it's got. (Same for web applications: They can't resize the browser, so they have fit the layout into available space.) Desktop Applications OTOH can request a window size (and I think they even have to, at least with X11, and I think also with Windows). So the application must somehow determine how large a window it should request. > > Very often this is not the case: An image viewer will be used to display > > images which are larger than the screen. A MUA may have to display > > hundreds of mailboxes, and maybe tens of thousands of mails in a single > > mailbox. > > I never claimed it was easy. Yes, the author of an MUA has to make a > guess and a bunch of decisions about a useful default setup (such a set > of defaults already appears elsewhere in this thread). Aha. And why would be better to "make a guess" than to use information available at runtime? > But I'm sticking to my story: that setup should be based on > *application domain* objects, like messages and mailboxes, and not > size(s) of the screen(s) (in pixels or inches). I'm also sticking to my story that those objects are frequently too large too display completely. They will need a container with a scroll-bar. And then you need to decide how large that container should be. > Also, yes, image viewers are different from MUAs. The latter has to be > much more aware of certain aspects of the display devices(s), but should > still base window sizes on *content* rather than choosing to be "full > screens (plural), because I'm the most important application ever." I never argued that applications should be full screen. Full screen is easy (see above). The hard part is figuring out a size which is acceptable for most users. (Also, yes, image viewers are different from MUAs, but for the topic at hand they share an important property: There is no single "correct" size for the thing(s) they display) > > In these cases an application can't use the "natural size": It would be > > bigger than the screen, and depending on the window manager, the user > > might not even be able to resize it because the handles are off-screen. > > I remember window managers that let applications open windows that I > can't move. Aside from a few tricks to "hide" windows, that's a bug. > > > It could use some size which is small enough to fit on any screen (how > > large is that? Can you assume 1366x768 these days?). But for most users > > this would be annoying, since they would have to resize the window. > > It should request the size it wants, Yes. The problem of figuring out that size is what we are talking about. What I'm reading here is only that the screen size should not be an input to the solution even though it's the single hard constraint. What I'm not reading here is how to do it. Except a wishy-washy "let the layout manager figure it out", which I don't think it can because it doesn't have the necessary information. I'd really like to see some code. (See my challenge in another mail. Feel free to do something more complicated if you think that's too easy). > and be prepared to handle not getting it. Usually, that means scroll > bars. Of course. But that's not the problem we are talking about. When the size of the window is set from the outside (either because of configured constraints or because the user resizes the window) that gives a fixed set of constraints to the layout manager. What I'm talking about is when the layout manager doesn't have such constraints. > > I am very much a fan of letting layout and window managers do as much > > as possible. But I don't think they can do everything. They simply > > don't have the necessary information. > > I don't think we're disagreeing too much here, either. IMO, the user > should be in control, whether by config file or command line or > whatever, Config files and command lines are inputs to the application. The programmer has to decide what options to accept, what they mean and how to process them. As far as this discussion is concerned, they are strictly part of the application. hp PS: Just for teh lulz, I installed PyQt5 and invoked the designer: It gave me a fixed size window. I also dug up a bit of C#-code I'd written a few years ago. The MainWindow.xaml also specifies a fixed size. You can probably change that in both cases, but it's what you get when you naively use graphical design tools. -- _ | 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 ethan at stoneleaf.us Sat Oct 31 14:52:31 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Sat, 31 Oct 2020 11:52:31 -0700 Subject: Best way to determine user's screensize? In-Reply-To: <20201031182434.GB5897@hjp.at> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> <20201031165841.GC33753@scrozzle> <20201031182434.GB5897@hjp.at> Message-ID: On 10/31/20 11:24 AM, Peter J. Holzer wrote: > On 2020-10-31 11:58:41 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: >> I don't think we're disagreeing too much here, either. IMO, the user >> should be in control, whether by config file or command line or >> whatever, > > Config files and command lines are inputs to the application. The > programmer has to decide what options to accept, what they mean and how > to process them. As far as this discussion is concerned, they are > strictly part of the application. I'm not sure which of the above two snippets I'm (dis)agreeing with, but if the user has specified in the config file that they want "full screen", how does the application tell the layout manager that? (And yes, I have three screens, and each one has a full-size window running in it. Also, four virtual desktops, one for each area of interest. I hate overlapping windows.) -- ~Ethan~ From hjp-python at hjp.at Sat Oct 31 15:11:26 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 20:11:26 +0100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> Message-ID: <20201031191126.GC5897@hjp.at> On 2020-10-31 11:54:59 -0500, Igor Korot wrote: > On Sat, Oct 31, 2020, 8:40 AM Peter J. Holzer wrote: > > > On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > > On 2020-10-31 at 13:02:03 +0100, > > > "Peter J. Holzer" wrote: > > > > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote: > > > > > There is no valid way for an application to read my mind and size > > > > > itself. Attempting to query my screen size seems to just make things > > > > > worse in a lot of situations. > > > > > > > You still haven't answered the question: Where should the initial > > > > window size come from? Does your window manager tell the application > > > > how large a window should be? And if it does, can you as a user > > > > configure that? I don't think mine (xfce) does that. (I guess tiling > > > > WMs generally do that, but I've never used one.) > > > > > > The intial/default window should be big enough to contain the > > > initial/default content, regardless of the configuration of the > > > screen(s)/monitor(s). > > > > As I already wrote in an answer to Igor, this is only possible if the > > initial/default content is of fixed size (or at least guaranteed to be > > smaller than the screen size). > > > > Any control at any given moment has a fixed size. > If I can't set the initial size of the control in the appropriate layout > system, then this is not a layout system. Correct. But you and Chris and others were arguing that this size should never be based on the screen size. Instead suggestions included "a guess" and "a reasonable N". > > Very often this is not the case: An image viewer will be used to display > > images which are larger than the screen. A MUA may have to display > > hundreds of mailboxes, and maybe tens of thousands of mails in a single > > mailbox. > > > > In these cases an application can't use the "natural size": It would be > > bigger than the screen, and depending on the window manager, the user > > might not even be able to resize it because the handles are off-screen. > > > > What is natural size? Please define this term. Depends on the thing to be displayed of course. For a JPG or PNG image, the "natural size" would be one image pixel = one display pixel. Except that for small images on high dpi displays it might be a "logical pixel" (is that the correct term?) instead. For a a text, the natural size is a box around the complete text typeset in the way it should be displayed. Similarly for a list or a table. A tree has two sizes that could be considered "natural": Fully collapsed and fully expanded. But it will almost always be somewhere in between, so that's another situation where a programmer would need to determine what is reasonable. > > It could use some size which is small enough to fit on any screen (how > > large is that? Can you assume 1366x768 these days?). But for most users > > this would be annoying, since they would have to resize the window. > > > > (And note that "the user has to do than only once, the second time the > > application can use the saved layout" doesn't hold either: The user may > > have invoked the application on a large desktop monitor the first time, > > but at some point they use the small laptop monitor or a projector.) > > > > This is exactly my point. > If the underlying toolkit is smart enough and the layout system is good > then it won't matter. Well. I haven't seen one which is smart enough. It might be because I don't do desktop development (when I need a UI, I write a web app), but I think the problem is (in general) unsolvable without domain knowledge, and so far nobody has written anything to change my mind. I would need to see either code or at least an explanation how this is done. "It just works" is not a good argument for a techie. > > I am very much a fan of letting layout and window managers do as much as > > possible. But I don't think they can do everything. They simply don't > > have the necessary information. > > > > Of course not. > Thats why software devs are paid big money to do proper designs. ? Well, I have to agree with Chris here. Most programmers (especially those who are paid big bucks) don't do proper designs. 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 hjp-python at hjp.at Sat Oct 31 15:19:59 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 31 Oct 2020 20:19:59 +0100 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> <20201031165841.GC33753@scrozzle> <20201031182434.GB5897@hjp.at> Message-ID: <20201031191959.GD5897@hjp.at> On 2020-10-31 11:52:31 -0700, Ethan Furman wrote: > On 10/31/20 11:24 AM, Peter J. Holzer wrote: > > On 2020-10-31 11:58:41 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > > I don't think we're disagreeing too much here, either. IMO, the user > > > should be in control, whether by config file or command line or > > > whatever, > > > > Config files and command lines are inputs to the application. The > > programmer has to decide what options to accept, what they mean and how > > to process them. As far as this discussion is concerned, they are > > strictly part of the application. > > I'm not sure which of the above two snippets I'm (dis)agreeing with, but if > the user has specified in the config file that they want "full screen", how > does the application tell the layout manager that? It doesn't directly. It tells the window manager that it wants to go full screen. The window manager resizes the window, which causes a resize event to be sent to the application. The application then asks the layout manager to recompute the layout based on the new window size (the latter will probably be managed automatically by the framework, so the programmer doesn't have to write code for that, but it's still part of the application). 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 random832 at fastmail.com Sat Oct 31 15:37:42 2020 From: random832 at fastmail.com (Random832) Date: Sat, 31 Oct 2020 15:37:42 -0400 Subject: Best way to determine user's screensize? In-Reply-To: References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <4b35d612-39d5-4c56-a43c-8aba4b815154@www.fastmail.com> Message-ID: <2c17d05c-4d6a-4234-b171-46f15a5c3ffd@www.fastmail.com> On Sat, Oct 31, 2020, at 01:26, Igor Korot wrote: > This one is for "JAVAsucks" - > https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html > This one is for wxWidgets - https://docs.wxwidgets.org/3.0/overview_sizer.html > This one is for Qt - https://doc.qt.io/qt-5/layout.html > This one is for GTK - > https://developer.gnome.org/gtk3/stable/LayoutContainers.html > > Are you still going to argue "it does not exist"? Those have nothing to do with the sizing or placement of top-level windows, they are for placements of widgets within the top-level window. From PythonList at DancesWithMice.info Sat Oct 31 15:51:59 2020 From: PythonList at DancesWithMice.info (dn) Date: Sun, 1 Nov 2020 08:51:59 +1300 Subject: Why x+=1 doesn't return x value instead of an object In-Reply-To: References: Message-ID: <3a510e29-a378-8bfd-ada6-a452afd89f05@DancesWithMice.info> On 31/10/2020 19:41, Chris Angelico wrote: > On Sat, Oct 31, 2020 at 4:44 PM dn via Python-list > wrote: >> Free advice: whatever you do, don't call @Chris a walrus! > > Yeah... I do have quite a moustache, but it doesn't merit a high title > like that! :) It's the tusks I'd be worried about! Is Dracula jealous of your bite? -- Regards =dn From barry at barrys-emacs.org Sat Oct 31 16:44:02 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Sat, 31 Oct 2020 20:44:02 +0000 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: > On 31 Oct 2020, at 16:37, Igor Korot wrote: > > Hi, Barry, > > On Sat, Oct 31, 2020, 3:39 AM Barry Scott > wrote: > > > > On 29 Oct 2020, at 15:54, flaskee via Python-list > wrote: > > > > Hello! > > > > I've been reading the GUI toolkit posts. > > > > If anyone can give me a push in the right python direction on > > my needs, I'd be grateful. > > > > This is for business applications, not games. > > (but if a game toolkit fits...) > > > > I choose to use PyQt5 for my apps that run on Linux, macOS and Windows. > > You can see my apps code if you wish to see working examples: > > https://barrys-emacs.org > > https://scm-workbench.barrys-emacs.org/ > > > In the past I had used wxPython but it had too many problems and it was cheaper for > me to port in PyQt5 then have to carry a lot of platform specific workarounds. > > PyQt5 can target iOS and android. > > With PyQt5 I can develop on Linux and have high confidence that the code will run the > same way on macOS and Windows. > > Qt does not use native controls on 3 major platforms and so is out of the question... It looks and feels native so I've been very happy with the way the Qt widgets work. It does not appear to me that use native widgets is important for a tool kit. So I think that Qt is worth considering. Barry > > Thank you. > > > Barry > > -- > https://mail.python.org/mailman/listinfo/python-list From 2QdxY4RzWzUUiLuE at potatochowder.com Sat Oct 31 18:12:36 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Sat, 31 Oct 2020 17:12:36 -0500 Subject: Best way to determine user's screensize? In-Reply-To: <20201031182434.GB5897@hjp.at> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> <20201031165841.GC33753@scrozzle> <20201031182434.GB5897@hjp.at> Message-ID: <20201031221236.GD33753@scrozzle> On 2020-10-31 at 19:24:34 +0100, "Peter J. Holzer" wrote: > On 2020-10-31 11:58:41 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > On 2020-10-31 at 14:37:52 +0100, > > "Peter J. Holzer" wrote: > > > > > On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > > > > > The intial/default window should be big enough to contain the > > > > initial/default content, regardless of the configuration of the > > > > screen(s)/monitor(s). > > > > > > As I already wrote in an answer to Igor, this is only possible if the > > > initial/default content is of fixed size ... > > > > Bear with me, but I think that that's part of the problem. Suppose my > > application edits documents. The initial content is two buttons, New > > and Open (I depend on the underlying OS and/or window manager for > > quitting). Is the window a fixed size? No, it's big enough to hold two > > buttons, sized and scaled based on user supplied defaults, possibly at a > > lower level, like X11 or Qt. > > In my book that counts as fixed size ... Then we already have a terminology issue. :-) I'll take at least part of the blame because my question as written is ambiguous: what I meant to ask was whether or not the application can specify a predetermined size, in pixels or in millimeters, for that window. I believe that the answer is no, because the "correct" size for that window depends on other things, like the size of the font, the density of the pixels, user preferences, etc., which can change over time. (And my argument remains that said correct size does *not* depend on the size(s) or the aspect ratio(s) of the screen(s).) > ... The layout manager can use the information it has (font family and > size, margins, etc.) compute the sizes of the two buttons, then > compute the size of the container (possibly using that info to resize > the buttons), and use that to compute the size of the window. The > application then requests a window of that size from the window > manager. Yep. > Now consider what happens when the user clicks on that Open button and > loads the document to be edited. You have to add a text editor widget to > your window. How large should that be? You know hwo many lines your > document has, but using a 5000 line text widget for a 5000 line document > would be ridiculous. You could say "the rest of the window", but your > window is just large enough for the buttons, so your text widget would > end up with 0 lines - not very useful. Any fixed size will be too large > or too small (and while users can usually cope with too small, many of > them are completely flummoxed by windows which are too large). The application should pick a size for that widget in lines and columns of *glyphs*, or a size that matches a potential physical rendering (like a page in a book) in millimeters, again regardless of the characteristics of the screen. Yes, an initial guess may be suboptimal. Ambitious users can adjust the window and/or their preferences to taste, and have to recognize that such preferences may depend on other things. When I switched from a 1920x1080 laptop display to a 3840x2160 laptop display that was the same size, I had to change a lot of preferences because applications and font libraries made incorrect assumptions about pixel density. I can almost see an application (or a developer) wanting to make that editing widget, say, 80 characters wide and 2/3 as tall as the screen, because vertical scroll bars are perfectly acceptable. Yeah, that'll look pretty. Until I (the user) get that wall-size display but I still want my editing widgets and the text therein to be the same size as my handwritten notes on real A4 paper. > Phones are easy: All apps are full-screen (or half-screen, if the OS > supports that). The app can't request a window size, it has to work > with what it's got. That's how video terminals used to be, 80x24, until they weren't. That's how Apple Macinntosh's used to be, 512x384x1, until they weren't. You get the idea. :-) In Apple's defense, the docs I used in 1984 laid out a completely heterogeneous display environment, and had instructions for software that would work when a given window spanned multiple physical display devices. I remember how impressed I was when my simple image viewer worded as advertised when we got our first external color displays. > > > Very often this is not the case: An image viewer will be used to display > > > images which are larger than the screen. A MUA may have to display > > > hundreds of mailboxes, and maybe tens of thousands of mails in a single > > > mailbox. > > > > I never claimed it was easy. Yes, the author of an MUA has to make a > > guess and a bunch of decisions about a useful default setup (such a set > > of defaults already appears elsewhere in this thread). > > Aha. And why would be better to "make a guess" than to use information > available at runtime? Some information, sure. Please don't assume that physical pixels or physical millimeters of display space relate to useful window sizes. > > But I'm sticking to my story: that setup should be based on > > *application domain* objects, like messages and mailboxes, and not > > size(s) of the screen(s) (in pixels or inches). > > I'm also sticking to my story that those objects are frequently too > large too display completely. They will need a container with a > scroll-bar. And then you need to decide how large that container should > be. Again, I don't think we're disagreeing. Our shiny new MUA comes up and finds 10 million messages in the user's inbox. Pick a number of messages, like 10, or 42, and start there. Don't start with the screen size and do a bunch of font metric arithmetic to come up with a number of pixels. > > It should request the size it wants, > > Yes. The problem of figuring out that size is what we are talking about. > > What I'm reading here is only that the screen size should not be an > input to the solution even though it's the single hard constraint. > > What I'm not reading here is how to do it. Except a wishy-washy "let the > layout manager figure it out", which I don't think it can because it > doesn't have the necessary information. I'd really like to see some > code. (See my challenge in another mail. Feel free to do something more > complicated if you think that's too easy). > > > > and be prepared to handle not getting it. Usually, that means scroll > > bars. > > Of course. But that's not the problem we are talking about. When the > size of the window is set from the outside (either because of configured > constraints or because the user resizes the window) that gives a fixed > set of constraints to the layout manager. What I'm talking about is when > the layout manager doesn't have such constraints. I guess I've always built my GUIs from the bottom up: put some labels on a set of radio buttons, put those radio buttons in a vertical list, put those boxes next to one another, etc. Macintoshes (it's been a while), Tk, GTK, Qt, and HTML all seem to create reasonable interfaces. Or should I say that their layout managers create reasonable interfaces. If the resulting window is too big for the display, then the user resizes the window (the trend seems to be that double clicking the title bar makes the window full screen and then the user can grab the handles) and the layout manager deals with the resize events. > > > I am very much a fan of letting layout and window managers do as much > > > as possible. But I don't think they can do everything. They simply > > > don't have the necessary information. > > > > I don't think we're disagreeing too much here, either. IMO, the user > > should be in control, whether by config file or command line or > > whatever, > > Config files and command lines are inputs to the application. The > programmer has to decide what options to accept, what they mean and how > to process them. As far as this discussion is concerned, they are > strictly part of the application. If the user specifies, at runtime, to create a window capable of displaying M lines of N characters, then M and N are *not* part of the application. Presumably, there's an algorithm inside the application that can calculate useful (or at least usable) values of M and N without user input; the question is whether that algorithm can/should/must consume the physical screen size. > PS: Just for teh lulz, I installed PyQt5 and invoked the designer: It gave > me a fixed size window. I also dug up a bit of C#-code I'd written a > few years ago. The MainWindow.xaml also specifies a fixed size. You > can probably change that in both cases, but it's what you get when > you naively use graphical design tools. Naively using graphical design tools can be hazardous to your users' health. :-) From hjp-python at hjp.at Sat Oct 31 19:17:26 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 1 Nov 2020 00:17:26 +0100 Subject: Best way to determine user's screensize? In-Reply-To: <20201031221236.GD33753@scrozzle> References: <-4Od9L6qxZ_NGdTB72tL_Lewjt1MpvqqFbDKR0pYEE6Bn1D4GsCqCB2Q102p-O5KtGLJp_mCwEOtC61ceDUsD-PsQ8uw1dXch0Jh89iR6lg=@protonmail.com> <20201030235630.GC24901@hjp.at> <20201031120203.GC22631@hjp.at> <20201031125138.GB33753@scrozzle> <20201031133752.GA5683@hjp.at> <20201031165841.GC33753@scrozzle> <20201031182434.GB5897@hjp.at> <20201031221236.GD33753@scrozzle> Message-ID: <20201031231726.GC21877@hjp.at> On 2020-10-31 17:12:36 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > On 2020-10-31 at 19:24:34 +0100, > "Peter J. Holzer" wrote: > > On 2020-10-31 11:58:41 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > > > I never claimed it was easy. Yes, the author of an MUA has to make a > > > guess and a bunch of decisions about a useful default setup (such a set > > > of defaults already appears elsewhere in this thread). > > > > Aha. And why would be better to "make a guess" than to use information > > available at runtime? > > Some information, sure. Please don't assume that physical pixels or > physical millimeters of display space relate to useful window sizes. It does. It's the upper bound. The window may be smaller, but not larger. > > > But I'm sticking to my story: that setup should be based on > > > *application domain* objects, like messages and mailboxes, and not > > > size(s) of the screen(s) (in pixels or inches). > > > > I'm also sticking to my story that those objects are frequently too > > large too display completely. They will need a container with a > > scroll-bar. And then you need to decide how large that container should > > be. > > Again, I don't think we're disagreeing. Our shiny new MUA comes up and > finds 10 million messages in the user's inbox. Pick a number of > messages, like 10, or 42, and start there. Don't start with the screen > size and do a bunch of font metric arithmetic to come up with a number > of pixels. We do disagree fundamentally here. I think picking an arbitrary number like 10 or 42 out of thin air is fundamentally broken. Computing than number by dividing the screen height (minus chrome) by the height of one element is the right thing to do. (Using the number stored last time when the user resized the window is of course also ok (because that was the user, not the programmer). But the application has to be ready to adjust that if the current screen is smaller) 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 greg.ewing at canterbury.ac.nz Sat Oct 31 19:42:14 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 1 Nov 2020 12:42:14 +1300 Subject: GUI: I am also looking for a nudge into the best (GUI) direction. In-Reply-To: References: Message-ID: On 1/11/20 9:44 am, Barry Scott wrote: > It does not appear to me that use native widgets is important for a tool kit. It's not strictly necessary. However, recreating the exact appearance and behaviour of native widgets is a lot of work, and difficult to do well -- most toolkits that attempt this don't manage to get all the details exactly right. Moreover, a lot of maintenance effort is needed to keep up with changes to the native widgets which frequently happen with OS updates. And even if the toolkit is kept up to date, you need to install a new version of the toolkit when changes occur. On the other hand, if the toolkit wraps the platform's native widgets, it gets all the correct appearance and behaviour, and automatically tracks changes. For these reasons I regard "uses native widgets" as a mark of quality for a toolkit. -- Greg From storchaka at gmail.com Sat Oct 31 16:34:24 2020 From: storchaka at gmail.com (Serhiy Storchaka) Date: Sat, 31 Oct 2020 22:34:24 +0200 Subject: Best way to determine user's screensize? In-Reply-To: References: Message-ID: 30.10.20 17:56, flaskee via Python-list ????: > Perhaps a more tactical approach would best to figure > out how to do cross-platform python apps. > > What is the best approach to determining the user's available screensize, > when they open your python application? > > Note that the "desktop" application could be running on Android, iOS, > MacOS, Windows or Linux (I think that I understand how to handle it for browser-based things.) > > As close to an all Python answer as possible, would be optimal. It depends on the GUI toolkit you are using. For example in Tkinter you can use methods winfo_screenwidth() and winfo_screenheight() of your widget if you need the size in pixels. winfo_screenmmwidth() and winfo_screenmmheight() return the size in millimeters. For other toolkits look at the corresponding documentation. From Bischoop at vimart.net Sat Oct 31 20:36:02 2020 From: Bischoop at vimart.net (Bischoop) Date: Sun, 1 Nov 2020 00:36:02 -0000 (UTC) Subject: Find word by given characters Message-ID: I'm working on a script i which user inputs letters and then a printed words containing those letters. The scripts works however I can't solve one problem , it prints also words in which these letters occur more than once. ------------------- Fore example: Letters: at Output: auto, autobahn. ------------------- I supposed to not print word: "autobahn" because I've given it only one letter "a". Here is a link to the code: https://bpa.st/UTAA Thanks in advance From python at mrabarnett.plus.com Sat Oct 31 21:52:54 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 1 Nov 2020 01:52:54 +0000 Subject: Find word by given characters In-Reply-To: References: Message-ID: <840a9659-d390-1629-46f1-384c0579070a@mrabarnett.plus.com> On 2020-11-01 00:36, Bischoop wrote: > I'm working on a script i which user inputs letters and then a printed > words containing those letters. The scripts works however I can't solve > one problem , it prints also words in which these letters occur more > than once. > ------------------- > Fore example: > Letters: at > Output: auto, autobahn. > ------------------- > > I supposed to not print word: "autobahn" because I've given it only one > letter "a". > > Here is a link to the code: > https://bpa.st/UTAA > > Thanks in advance > This is what's happening in the inner loop: Iteration 1: word contains 1 of 'a', letters contains 2 of 'a', so don't print the word. Iteration 2: word contains 1 of 't', letters contains 1 of 't', so print the word. From tjreedy at udel.edu Sat Oct 31 22:04:22 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 31 Oct 2020 22:04:22 -0400 Subject: Find word by given characters In-Reply-To: References: Message-ID: On 10/31/2020 8:36 PM, Bischoop wrote: > I'm working on a script i which user inputs letters and then a printed > words containing those letters. The scripts works however I can't solve > one problem , it prints also words in which these letters occur more > than once. > ------------------- > Fore example: > Letters: at > Output: auto, autobahn. > ------------------- > > I supposed to not print word: "autobahn" because I've given it only one > letter "a". If you use collections.counter on both the letters and the word, you could check that the counts in letters are matched by the counts for word. Make sure to use 'and' between count matches. -- Terry Jan Reedy