From dieter at handshake.de Wed May 1 02:05:08 2019 From: dieter at handshake.de (dieter) Date: Wed, 01 May 2019 08:05:08 +0200 Subject: Checking network input processing by Python for a multi-threaded server References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <87y33s2f9i.fsf@handshake.de> Message-ID: <877ebapv57.fsf@handshake.de> Markus Elfring writes: > ... >> As you say to have created a "multi-threaded TCP server", I assume >> that your server spawns a thread for each TCP connection. > > Is this the software behaviour we usually get from > the class ?socketserver.ThreadingMixIn?? Look at the source -- and there look especially for so called "docstring"s: : class ThreadingMixIn: : """Mix-in class to handle each request in a new thread.""" From Markus.Elfring at web.de Wed May 1 03:44:07 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Wed, 1 May 2019 09:44:07 +0200 Subject: Dynamic selection for network service ports? In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <8464d60c-cf2f-7c9f-7388-0dcc2dbcd291@web.de> <809f778d-4591-8054-1b8e-35bf067e6cef@web.de> Message-ID: > You'll get anything in the ephemeral ports range. From which documentation source did you get this information for the handling of a zero as an useful setting? > But the other cause is that you recently shut the server down, > and the port is still in the TIME_WAIT state. Does this technical detail occasionally increase the need to choose an additional number for a quickly restarted service in a dynamic way? > You can avoid this with the SO_REUSEADDR flag. Can such a configuration parameter be used also together with programming interfaces from the module ?socketserver?? Regards, Markus From rosuav at gmail.com Wed May 1 03:55:26 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 1 May 2019 17:55:26 +1000 Subject: Dynamic selection for network service ports? In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <8464d60c-cf2f-7c9f-7388-0dcc2dbcd291@web.de> <809f778d-4591-8054-1b8e-35bf067e6cef@web.de> Message-ID: On Wed, May 1, 2019 at 5:44 PM Markus Elfring wrote: > > > You'll get anything in the ephemeral ports range. > > From which documentation source did you get this information for > the handling of a zero as an useful setting? If you don't bind to a port, you get an arbitrary port in the ephemeral port range. That's just how BSD sockets work. Source: a couple of decades of programming experience. > > But the other cause is that you recently shut the server down, > > and the port is still in the TIME_WAIT state. > > Does this technical detail occasionally increase the need to choose > an additional number for a quickly restarted service in a dynamic way? > > > You can avoid this with the SO_REUSEADDR flag. > > Can such a configuration parameter be used also together with > programming interfaces from the module ?socketserver?? How about you do some research with the socket module and see if you can find answers in the docs. I have faith in you :) ChrisA From Markus.Elfring at web.de Wed May 1 03:56:59 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Wed, 1 May 2019 09:56:59 +0200 Subject: Dynamic selection for network service ports? In-Reply-To: <20190430205407.ywpzhpxi4e5xuist@hjp.at> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <8464d60c-cf2f-7c9f-7388-0dcc2dbcd291@web.de> <809f778d-4591-8054-1b8e-35bf067e6cef@web.de> <20190430205407.ywpzhpxi4e5xuist@hjp.at> Message-ID: > If your server listens on a random port how does the client know > which port to connect to? I am fiddling also with the data processing variant that such connection properties are passed as parameters for a command which is executed as a child process so that desired data can be sent back to its caller. Regards, Markus From greg.ewing at canterbury.ac.nz Wed May 1 04:05:13 2019 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 01 May 2019 20:05:13 +1200 Subject: Generating generations of files In-Reply-To: References: <33e0998d-c809-eb39-ac8b-d1751f0b9c06@DancesWithMice.info> <20190430010829.GA60079@cskk.homeip.net> Message-ID: > On 2019-04-30, Cameron Simpson wrote: > >>I'm pretty sure the VMS built in file versioning >>went on the scheme MRAB described: rewriting version.rpt caused the old >>version to become "version.rpt;n" where n counted up from 1. The version numbers certainly counted upwards. But I'm fairly sure a version number was assigned as soon as you created a file, and if you referred to just "version.rpt" it would default to the latest version. Also I think a directory listing would only show the latest version of each file unless you told it otherwise. -- Greg From greg.ewing at canterbury.ac.nz Wed May 1 04:13:13 2019 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 01 May 2019 20:13:13 +1200 Subject: Generating generations of files In-Reply-To: References: <00746782-1a78-7846-e7bf-b2bf58c9414d@etelligence.info> <00b801d4ffcf$d9a06e30$8ce14a90$@verizon.net> Message-ID: Avi Gross wrote: > UNIX flowed the fields together with a limit of 14 that included an > actual optional period as a counted character. The Unix kernel has no notion of a filename extension; a filename is just a sequence of bytes. Using a dot-suffix to indicate a file type is just a user-level convention. -- Greg From Markus.Elfring at web.de Wed May 1 05:27:27 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Wed, 1 May 2019 11:27:27 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> Message-ID: <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> > https://docs.python.org/3/library/socketserver.html#asynchronous-mixins An example is provided also in this software documentation. May I expect that data were completely received from clients and accordingly processed by the request handler in the started threads after the statement ?server.shutdown()? was sucessfully executed? Regards, Markus From ar at zeit.io Wed May 1 07:56:01 2019 From: ar at zeit.io (Arup Rakshit) Date: Wed, 1 May 2019 17:26:01 +0530 Subject: Python Flask-CouchDB - AttributeError: '_AppCtxGlobals' object has no attribute 'couch' Message-ID: Hello, I started to write a simple todo app with couchcb. But as usual I met an error which a search in the internet could not help. I don?t even know how `g` gets its properties. My app: from flask import Flask, render_template, request, g from flaskext.couchdb import CouchDBManager app = Flask(__name__) # DB config app.config['COUCHDB_SERVER'] = 'http://127.0.0.1:5984' app.config['COUCHDB_DATABASE'] = 'todo-webapp' @app.route('/') def index(): print(dir(g)) document = dict(title="Hello", content="Hello, world!") g.couch['users'] = document return render_template('index.html') if __name__ == '__main__': manager = CouchDBManager() manager.setup(app) manager.sync(app) app.run(debug=True) And when I refresh the page from http://127.0.0.1:5000/ ,, I get an error: ['__class__', '__contains__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'get', 'pop', 'setdefault'] 127.0.0.1 - - [01/May/2019 17:20:13] "GET / HTTP/1.1" 500 - Traceback (most recent call last): File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 2309, in __call__ return self.wsgi_app(environ, start_response) File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise raise value File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise raise value File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/aruprakshit/projects/flask-apps/todo-app/app.py", line 14, in index g.couch['users'] = document File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/werkzeug/local.py", line 348, in __getattr__ return getattr(self._get_current_object(), name) AttributeError: '_AppCtxGlobals' object has no attribute ?couch' Can anyone help me to fix this? Thanks, Arup Rakshit ar at zeit.io From Markus.Elfring at web.de Wed May 1 09:25:44 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Wed, 1 May 2019 15:25:44 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> Message-ID: > https://docs.python.org/3/library/socketserver.html#asynchronous-mixins I have constructed a pair of small scripts for another test. A command (which refers to the second Python script) is executed 100 times by ?subprocess.run()? with parameters so that the child process can send six test records back to the caller over a TCP connection. 1. The received records are appended to a global list variable during each loop iteration. 2. The list length is appended to another global list variable. 3. The stored list lengths are counted by grouping of this information. Now I wonder again about a test result like the following for the software ?Python 3.7.2-3.1? (for an openSUSE system). elfring at Sonne:~/Projekte/Python> time /usr/bin/python3 test-statistic-server1.py incidence|"available records"|"return code"|"command output" 44|6|0| 12|5|0| 13|4|0| 16|3|0| 2|7|0| 8|2|0| 3|8|0| 1|1|0| 1|9|0| real 0m29,123s user 0m5,925s sys 0m1,073s Does this data processing approach indicate a need for further software corrections? Regards, Markus From skip.montanaro at gmail.com Wed May 1 10:02:23 2019 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Wed, 1 May 2019 09:02:23 -0500 Subject: pip as an importable module? Message-ID: I'm trying to get pip-conflict-checker working with Python 3.6: https://github.com/ambitioninc/pip-conflict-checker It would seem that the pip API has changed since this tool was last updated, as what's there appears only to be used in support of pip as a command line tool. Is there something comparable which is being maintained, or a description of how to adapt to the new pip-as-a-module API? Thx, Skip From p.f.moore at gmail.com Wed May 1 10:15:09 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 1 May 2019 15:15:09 +0100 Subject: pip as an importable module? In-Reply-To: References: Message-ID: Pip doesn't have a programming API, so no, you can't do this. Having said that, it looks like pip-conflict-checker only uses `pip.get_installed_distributions`, and setuptools (pkg_resources, specifically) has an API that does this, so you could probably relatively easily fix the code to use that. The stuff here is probably what you want: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#getting-or-creating-distributions Paul On Wed, 1 May 2019 at 15:05, Skip Montanaro wrote: > > I'm trying to get pip-conflict-checker working with Python 3.6: > > https://github.com/ambitioninc/pip-conflict-checker > > It would seem that the pip API has changed since this tool was last > updated, as what's there appears only to be used in support of pip as > a command line tool. Is there something comparable which is being > maintained, or a description of how to adapt to the new > pip-as-a-module API? > > Thx, > > Skip > -- > https://mail.python.org/mailman/listinfo/python-list From phd at phdru.name Wed May 1 12:18:39 2019 From: phd at phdru.name (Oleg Broytman) Date: Wed, 1 May 2019 18:18:39 +0200 Subject: SQLObject 3.7.2 Message-ID: <20190501161839.vdlbkbvvx3clmd2d@phdru.name> Hello! I'm pleased to announce version 3.7.2, the second bugfix release of branch 3.7 of SQLObject. What's new in SQLObject ======================= Minor features -------------- * Adapt Postgres exception handling to ``psycopg2`` version ``2.8``: in the recent ``psycopg2`` errors are in ``psycopg2.errors`` module. * Removed RdbhostConnection: David Keeney and rdbhost seem to be unavailable since 2017. 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.7.2 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 david at aeolia.co.uk Wed May 1 12:44:06 2019 From: david at aeolia.co.uk (David Sumbler) Date: Wed, 01 May 2019 17:44:06 +0100 Subject: A newbie question about using tix In-Reply-To: References: Message-ID: <0c8f97460ee13c3bea72a56a1074c27e81b64bda.camel@aeolia.co.uk> On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote: > On 2019-04-30 16:40, David Sumbler wrote: > > Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6 > > > > I am very new to tkinter. The simple program I am writing requires > > a > > user file to be selected before it does anything else, so I would > > like > > a file selection dialog in the main window as soon as the program > > launches. > > > > Tkinter only has askopenfilename(), but this produces a popup > > dialog. > > I can get something like what I want by specifying a small Tk() > > window > > and then calling askopenfilename() so that it covers the root > > window. > > > > It's not ideal, though. From the documentation I thought that the > > tix > > FileSelectBox would do what I wanted, but I just can't get it to > > work. > > > > If I run: > > > > from tkinter import * > > from tkinter.tix import FileSelectBox > > root = Tk() > > f = FileSelectBox(root) > > > > I get the following: > > > > Traceback (most recent call last): > > File "/home/david/bin/Gradient.py", line 4, in > > f = FileSelectBox(root) > > File "/usr/lib/python3.6/tkinter/tix.py", line 795, in > > __init__ > > TixWidget.__init__(self, master, 'tixFileSelectBox', > > ['options'], cnf, kw) > > File "/usr/lib/python3.6/tkinter/tix.py", line 311, in > > __init__ > > self.tk.call(widgetName, self._w, *extra) > > _tkinter.TclError: invalid command name "tixFileSelectBox" > > > > I realize that assigning the value of FileSelectBox() isn't going > > to > > give me a filename: I'm just trying to get the basic syntax right > > at > > the moment. > > > > I can't figure out what is wrong though. Have I have misunderstood > > how > > it should be called, or is there something missing from my system? > > > > For some reason, tix widgets don't work with normal tkinter widgets, > so > you can't put a tix FileSelectBox on a tkinter.Tk widget. > > There is, however, a tix.Tk widget that you can use instead: > > import tkinter.tix as tix > root = tix.Tk() > f = tix.FileSelectBox(root) > f.pack() Thanks for that. When I ran the above, I got: Traceback (most recent call last): File "/home/david/bin/GradientProfile_v2.py", line 2, in root = tix.Tk() File "/usr/lib/python3.6/tkinter/tix.py", line 214, in __init__ self.tk.eval('package require Tix') _tkinter.TclError: can't find package Tix After an internet search, I tried: sudo apt install tix-dev tk-dev tk8.6-dev libxft-dev libfontconfig1-dev libfreetype6-dev libpng-dev Now when I run the file the program just exits quickly, with no reported errors, but no window(s). If I add 'root.mainloop()' at the end, I get an empty root window for a fraction of a second, then the program exits with: Segmentation fault (core dumped) Any suggestions as to where to go from here? David From darkneskies at gmail.com Wed May 1 09:12:43 2019 From: darkneskies at gmail.com (Ken Martell) Date: Wed, 1 May 2019 08:12:43 -0500 Subject: Python 3.73 cannot install py3exiv2 Message-ID: <5cc99b4b.1c69fb81.6dc9.0803@mx.google.com> I?m a retired aerospace engineer. I?m a Windows 10 user & have zero experience with Python. My goal is to learn, get this working & run lens distortion correction routines using Python. I?ve tried or many hours and read as much as I can but cannot get the py3exiv2 module to install. Other needed modules installed fine. It appears the Python version 2 of evix2 is needed as a dependent for the version 3 but neither pip or pip3 will install old or new. Sorry for taking your time but I?m a newbie just trying to help my fellow photographers correct lens distortion problems in post-processing as well as my own. Any help much appreciated! Thank you Ken Martell This is the error I get : D:\>pip3 install py3exiv2 Collecting py3exiv2 ? Using cached https://files.pythonhosted.org/packages/eb/c4/675823a2c23d8f138e7dc2b7574d09f26959f641d0b59c3ec7faa65764e5/py3exiv2-0.7.0.tar.gz Installing collected packages: py3exiv2 ? Running setup.py install for py3exiv2 ... error ??? Complete output from command d:\apps\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Ken\\AppData\\Local\\Temp\\pip-install-swqqye4_\\py3exiv2\\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\Ken\AppData\Local\Temp\pip-record-4ki8wmrk\install-record.txt --single-version-externally-managed --compile: ??? FIND: Invalid switch ??? FIND: Invalid switch ??? FIND: Invalid switch ??? running install ??? running build ??? running build_py ??? creating build ??? creating build\lib.win-amd64-3.7 ??? creating build\lib.win-amd64-3.7\pyexiv2 ??? copying src\pyexiv2\exif.py -> build\lib.win-amd64-3.7\pyexiv2 ??? copying src\pyexiv2\iptc.py -> build\lib.win-amd64-3.7\pyexiv2 ??? copying src\pyexiv2\metadata.py -> build\lib.win-amd64-3.7\pyexiv2 ??? copying src\pyexiv2\preview.py -> build\lib.win-amd64-3.7\pyexiv2 ??? copying src\pyexiv2\utils.py -> build\lib.win-amd64-3.7\pyexiv2 ??? copying src\pyexiv2\xmp.py -> build\lib.win-amd64-3.7\pyexiv2 ??? copying src\pyexiv2\__init__.py -> build\lib.win-amd64-3.7\pyexiv2 ??? running build_ext ??? building 'libexiv2python' extension ??? creating build\temp.win-amd64-3.7 ??? creating build\temp.win-amd64-3.7\Release ??? creating build\temp.win-amd64-3.7\Release\src ??? C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Id:\apps\python37\include -Id:\apps\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /EHsc /Tpsrc/exiv2wrapper.cpp /Fobuild\temp.win-amd64-3.7\Release\src/exiv2wrapper.obj -g ??? cl : Command line warning D9002 : ignoring unknown option '-g' ??? exiv2wrapper.cpp ??? c:\users\ken\appdata\local\temp\pip-install-swqqye4_\py3exiv2\src\exiv2wrapper.hpp(32): fatal error C1083: Cannot open include file: 'exiv2/image.hpp': No such file or directory ??? error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2 ??? ---------------------------------------- Command "d:\apps\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Ken\\AppData\\Local\\Temp\\pip-install-swqqye4_\\py3exiv2\\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\Ken\AppData\Local\Temp\pip-record-4ki8wmrk\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Ken\AppData\Local\Temp\pip-install-swqqye4_\py3exiv2\ You are using pip version 19.0.3, however version 19.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. Sent from Mail for Windows 10 From skip.montanaro at gmail.com Wed May 1 13:06:29 2019 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Wed, 1 May 2019 12:06:29 -0500 Subject: pip as an importable module? In-Reply-To: References: Message-ID: > Pip doesn't have a programming API, so no, you can't do this. Having > said that, it looks like pip-conflict-checker only uses > `pip.get_installed_distributions`, and setuptools (pkg_resources, > specifically) has an API that does this, so you could probably > relatively easily fix the code to use that. Thanks, that is indeed easily done. Skip From grant.b.edwards at gmail.com Wed May 1 13:16:34 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 1 May 2019 17:16:34 -0000 (UTC) Subject: Generating generations of files References: <33e0998d-c809-eb39-ac8b-d1751f0b9c06@DancesWithMice.info> <20190430010829.GA60079@cskk.homeip.net> Message-ID: On 2019-05-01, Dennis Lee Bieber wrote: > It showed all versions... (at least, it did two years ago before my > lay-off from GE Aviation; which was running OpenVMS in a virtual > environment on some Windows boxes, being used to cross compile Ada > for 68040; and is also what I recall from 24 years at Lockheed). Yow! Cross-compiling Ada for a micro-processor target under VMS. That brings back horrible memories... The compiler I remember couldn't even use normal VMS/FILES-11 files. All the source/object 'files' lived in the Ada subsystem's own proprietary environment/filesystem/database. Every time you needed to make a change, you hand to export the source file from the Ada subsystem into the VMS filesystem, edit it, import it back into the Ada subsystem, then do the build. Yech. -- Grant Edwards grant.b.edwards Yow! Remember, in 2039, at MOUSSE & PASTA will gmail.com be available ONLY by prescription!! From blmadhavan at gmail.com Wed May 1 13:35:59 2019 From: blmadhavan at gmail.com (blmadhavan at gmail.com) Date: Wed, 1 May 2019 10:35:59 -0700 (PDT) Subject: PYTHON equivalents of BITAND and BITSHIFT of MATLAB Message-ID: <751faa2f-ff76-4316-aff2-ca387917dd08@googlegroups.com> Hi, I have the following line from a MATLAB program with FCF (format: UInt_16) as input: ftype = bitand(FCF, 7) typeBits = bitshift(FCF, -9) subtype = bitand(typeBits, 7) I wrote the following in Python for the above commands: ftype = FCF & 7 typeBits = FCF << -9 ------> Is this correct or FCF >> -9? subtype = typeBits & 7 Can someone help me write the equivalent command in PYTHON? Look forward to your suggestions. From brian.j.oney at googlemail.com Wed May 1 13:51:50 2019 From: brian.j.oney at googlemail.com (Brian Oney) Date: Wed, 01 May 2019 19:51:50 +0200 Subject: PYTHON equivalents of BITAND and BITSHIFT of MATLAB In-Reply-To: <751faa2f-ff76-4316-aff2-ca387917dd08@googlegroups.com> References: <751faa2f-ff76-4316-aff2-ca387917dd08@googlegroups.com> Message-ID: <1556733110.1676.3.camel@gmail.com> On Wed, 2019-05-01 at 10:35 -0700, blmadhavan at gmail.com wrote: > Hi, > > I have the following line from a MATLAB program with FCF (format: UInt_16) as input: > > ftype = bitand(FCF, 7) > typeBits = bitshift(FCF, -9) > subtype = bitand(typeBits, 7) > > I wrote the following in Python for the above commands: > > ftype = FCF & 7 > typeBits = FCF << -9 ------> Is this correct or FCF >> -9? > subtype = typeBits & 7 > > Can someone help me write the equivalent command in PYTHON? > > Look forward to your suggestions. >From the Matlab doc: ' intout = bitshift(A,k) intout = bitshift(A,k,assumedtype) Description example intout = bitshift(A,k) returns A shifted to the left by k bits, equivalent to multiplying by 2k. Negative values of k correspond to shifting bits right or dividing by 2|k| and rounding to the nearest integer towards negative infinity. Any overflow bits are truncated.?' So the equivalent would be: >>> typeBits =?FCF >> 9 Cheers Brian From python at mrabarnett.plus.com Wed May 1 14:11:07 2019 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 1 May 2019 19:11:07 +0100 Subject: A newbie question about using tix In-Reply-To: <0c8f97460ee13c3bea72a56a1074c27e81b64bda.camel@aeolia.co.uk> References: <0c8f97460ee13c3bea72a56a1074c27e81b64bda.camel@aeolia.co.uk> Message-ID: <72d61b7e-6770-0410-c423-d4734d3bcaaf@mrabarnett.plus.com> On 2019-05-01 17:44, David Sumbler wrote: > > On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote: > > On 2019-04-30 16:40, David Sumbler wrote: > > > Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6 > > > > > > I am very new to tkinter.? The simple program I am writing requires > > > a > > > user file to be selected before it does anything else, so I would > > > like > > > a file selection dialog in the main window as soon as the program > > > launches. > > > > > > Tkinter only has askopenfilename(), but this produces a popup > > > dialog. > > > I can get something like what I want by specifying a small Tk() > > > window > > > and then calling askopenfilename() so that it covers the root > > > window. > > > > > > It's not ideal, though.? From the documentation I thought that the > > > tix > > > FileSelectBox would do what I wanted, but I just can't get it to > > > work. > > > > > > If I run: > > > > > >?????? from tkinter import * > > >?????? from tkinter.tix import FileSelectBox > > >?????? root = Tk() > > >?????? f = FileSelectBox(root) > > > > > > I get the following: > > > > > >?????? Traceback (most recent call last): > > >???????? File "/home/david/bin/Gradient.py", line 4, in > > >?????????? f = FileSelectBox(root) > > >???????? File "/usr/lib/python3.6/tkinter/tix.py", line 795, in > > > __init__ > > >?????????? TixWidget.__init__(self, master, 'tixFileSelectBox', > > > ['options'], cnf, kw) > > >???????? File "/usr/lib/python3.6/tkinter/tix.py", line 311, in > > > __init__ > > >?????????? self.tk.call(widgetName, self._w, *extra) > > >?????? _tkinter.TclError: invalid command name "tixFileSelectBox" > > > > > > I realize that assigning the value of FileSelectBox() isn't going > > > to > > > give me a filename: I'm just trying to get the basic syntax right > > > at > > > the moment. > > > > > > I can't figure out what is wrong though.? Have I have misunderstood > > > how > > > it should be called, or is there something missing from my system? > > > > > > > For some reason, tix widgets don't work with normal tkinter widgets, > > so > > you can't put a tix FileSelectBox on a tkinter.Tk widget. > > > > There is, however, a tix.Tk widget that you can use instead: > > > > import tkinter.tix as tix > > root = tix.Tk() > > f = tix.FileSelectBox(root) > > f.pack() > > Thanks for that. > > When I ran the above, I got: > >????? Traceback (most recent call last): >??????? File "/home/david/bin/GradientProfile_v2.py", line 2, in >????????? root = tix.Tk() >??????? File "/usr/lib/python3.6/tkinter/tix.py", line 214, in __init__ >????????? self.tk.eval('package require Tix') >????? _tkinter.TclError: can't find package Tix > > After an internet search, I tried: > >???? sudo apt install tix-dev tk-dev tk8.6-dev libxft-dev libfontconfig1-dev libfreetype6-dev libpng-dev > > Now when I run the file the program just exits quickly, with no > reported errors, but no window(s).? If I add 'root.mainloop()' at the > end, I get an empty root window for a fraction of a second, then the > program exits with: > >????? Segmentation fault (core dumped) > > Any suggestions as to where to go from here? > Tested on Raspbian in a terminal window: sudo apt-get install tix python3 import tkinter.tix as tix root = tix.Tk() f = tix.FileSelectBox(root) f.pack() At this point there's a GUi window filled with a file section box. From elef at indiana.edu Wed May 1 13:27:52 2019 From: elef at indiana.edu (Eleftherios Garyfallidis) Date: Wed, 1 May 2019 13:27:52 -0400 Subject: ANN: DIPY 0.16.0 release Message-ID: Hello all!, We are excited to announce a new release of Diffusion Imaging in Python (DIPY). If you use DIPY in your research, please cite us using the following DOI: 10.3389/fninf.2014.00008 DIPY 0.16 (Monday, 10 March 2019) This release received contributions from 14 developers (the full release notes are at: http://dipy.org/release0.16.html ). Thank you for your contributions and feedback! Highlights of this release include: - Horizon, medical visualization interface powered by QuickBundlesX. - New Tractometry tools: Bundle Analysis / Bundle Profiles. - New reconstruction model: IVIM MIX (Variable Projection). - New command line interface: Affine and Diffeomorphic Registration. - New command line interface: Probabilistic, Deterministic and PFT Tracking. - Integration of Cython Guidelines for developers. - Replacement of Nose by Pytest. - Documentation update. - Closed 103 issues and merged 41 pull requests. Note: - DIPY 0.16.0 will be the last version to support Python 2. The next release, DIPY 1.0.0, will support Python 3 only. To upgrade or install DIPY Run the following command in your terminal: pip install --upgrade dipy or conda install -c conda-forge dipy This version of DIPY depends on nibabel (2.3.0+). Questions or suggestions? For any questions go to http://dipy.org, or send an e-mail to dipy at python.org We also have an instant messaging service and chat room available at https://gitter.im/nipy/dipy On behalf of the DIPY developers, Eleftherios Garyfallidis, Ariel Rokem, Serge Koudoro http://dipy.org/developers.html From Markus.Elfring at web.de Wed May 1 14:56:10 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Wed, 1 May 2019 20:56:10 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> Message-ID: <07440199-833c-ac3b-abb4-11a5a83b936b@web.de> > Why not provide them so that anyone trying to analyze what you are > seeing can try them for themselves. I assume that an other information system can be more appropriate for file distribution than this mailing list. > Starting a full process takes time This is usual. - Such an action would be necessary for the test case. > Do you have ANY synchronization enabled, I would expect that this is provided by the run time system for the Python scripting language. > so that you start all the children The main process waits on the exit for the single started command in each loop iteration. > and they all wait for a single "go" signal to be set No. > -- so that they all start processing at the same time? I suggest to take another look at the description for the test algorithm. > No idea what is in each loop... An instance for the class ?threaded_TCP_server? and a call of ?subprocess.run(?)?. > If there is only one list (implied by #1) There are two lists adjusted. 1. Storage for received records before the statement ?server.shutdown()? (and a reset to an empty list) is executed at the end of each loop iteration. 2. List lengths are recorded for analysis after the data collection phase. > Again, it is not clear what is being counted here... How many record sets were stored and are accessible at one point in time in such a data structure? > What is an "incidence", how is "available records" determined? The generated table shows how often a specific number of record sets was temporarily available for further data processing. I would expect that the correct count should be 100 (once) here (instead of the display of deviations from the original six test records). > Also, TCP is a stream protocol, not a record protocol. This view is generally fine. JSON data structures are transmitted by the discussed approach. > A client could use, say, 6 separate .send() operations, This should be happening in this test. > while the server receives everything in a single .recv() call. I hope that the execution of the statement ?server.shutdown()? triggers a separation in the reported inter-process communication. Regards, Markus From Markus.Elfring at web.de Wed May 1 15:14:10 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Wed, 1 May 2019 21:14:10 +0200 Subject: Dynamic selection for network service ports? In-Reply-To: <0njjceh6u3ee3ahe3u8fgn1bqcmnk1kff7@4ax.com> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <8464d60c-cf2f-7c9f-7388-0dcc2dbcd291@web.de> <809f778d-4591-8054-1b8e-35bf067e6cef@web.de> <0njjceh6u3ee3ahe3u8fgn1bqcmnk1kff7@4ax.com> Message-ID: > https://docs.python.org/3.4/library/socketserver.html > about the middle of the page... It seems that you would like to refer to an other document. https://docs.python.org/3/library/socket.html#socket-example Under which circumstances will the execution of the method ?socket.setsockopt? be triggered by a class like ?socketserver.TCPServer?? Regards, Markus From rosuav at gmail.com Wed May 1 15:21:30 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 2 May 2019 05:21:30 +1000 Subject: Dynamic selection for network service ports? In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <8464d60c-cf2f-7c9f-7388-0dcc2dbcd291@web.de> <809f778d-4591-8054-1b8e-35bf067e6cef@web.de> <0njjceh6u3ee3ahe3u8fgn1bqcmnk1kff7@4ax.com> Message-ID: On Thu, May 2, 2019 at 5:15 AM Markus Elfring wrote: > > > https://docs.python.org/3.4/library/socketserver.html > > about the middle of the page... > > It seems that you would like to refer to an other document. > https://docs.python.org/3/library/socket.html#socket-example > > Under which circumstances will the execution of the method ?socket.setsockopt? > be triggered by a class like ?socketserver.TCPServer?? > For the truly lazy, we have hash links. https://docs.python.org/3/library/socketserver.html#socketserver.BaseServer.allow_reuse_address ChrisA From Markus.Elfring at web.de Wed May 1 15:34:56 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Wed, 1 May 2019 21:34:56 +0200 Subject: Dynamic selection for network service ports? In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <8464d60c-cf2f-7c9f-7388-0dcc2dbcd291@web.de> <809f778d-4591-8054-1b8e-35bf067e6cef@web.de> <0njjceh6u3ee3ahe3u8fgn1bqcmnk1kff7@4ax.com> Message-ID: <082c0ada-5d70-63bf-fde8-8f0ddeab3769@web.de> > For the truly lazy, we have hash links. Thanks for your reminder. > https://docs.python.org/3/library/socketserver.html#socketserver.BaseServer.allow_reuse_address The relationship of this class attribute with the identifier (or option) ?SO_REUSEADDR? might become easier to find. The use of such a configuration parameter might need further considerations. Regards, Markus From w.hol at auckland.ac.nz Wed May 1 16:21:25 2019 From: w.hol at auckland.ac.nz (Wen-Chen Hol) Date: Wed, 1 May 2019 20:21:25 +0000 Subject: python3 html to rtf or doc In-Reply-To: References: Message-ID: <5f7f34490bb249fb8bc7733564aee13a@uxcn13-tdc-e.UoA.auckland.ac.nz> Thank you so much Dennis for the direction. :) Wen -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Wednesday, 1 May 2019 4:27 PM To: python-list at python.org Subject: Re: python3 html to rtf or doc On Wed, 1 May 2019 00:16:43 +0000, Wen-Chen Hol declaimed the following: >Looking for a library or utility that could transform html to rtf in redhat environment. >Googled a while still could not find a solution I like. >Any suggestions would be much appreciated Thanks in advance Wen With >python2.7 and zopyx.convert, was able to do html to rtf export, with some css kept and images as well. >zopyx.convert zopy.convert2 seem don't support python3 Recently >switched to python36, with pandoc for html to rtf, found out it doesn't do style or images when export now. >Html code is not in fixed format. Might I suggest Calibre? https://calibre-ebook.com/download_linux HTML is supposed to be one of the supported inputs, and RTF is an option for output conversion. Not sure if it can be scripted -- nor if it works with Python 3.x (requires 2.6+). I only have minimal experience with the Windows version (using a DeDRM plugin to unlock backups of my B&N Nook books; and sometimes doing an epub to epub import/export as I've encountered epubs that have corrupted formats and are unreadable in my Nooks -- Calibre loads and "converts" them into another epub that is valid) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com -- https://mail.python.org/mailman/listinfo/python-list From tjreedy at udel.edu Wed May 1 17:50:52 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 1 May 2019 17:50:52 -0400 Subject: Python 3.73 cannot install py3exiv2 In-Reply-To: <5cc99b4b.1c69fb81.6dc9.0803@mx.google.com> References: <5cc99b4b.1c69fb81.6dc9.0803@mx.google.com> Message-ID: On 5/1/2019 9:12 AM, Ken Martell wrote: > I?m a retired aerospace engineer. I?m a Windows 10 user & have zero experience with Python. My goal is to learn, get this working & run lens distortion correction routines using Python. I?ve tried or many hours and read as much as I can but cannot get the py3exiv2 module to install. Other needed modules installed fine. It appears the Python version 2 of evix2 is needed as a dependent for the version 3 but neither pip or pip3 will install old or new. I don't believe that this is the case. exiv2 is a C++ library. 'pyexiv2' is a python 2 wrapper that makes it accessible from python 2.7. 'py3exiv2' is an python 3 wrapper based on pyexiv2, but it should be independent of pyexiv2. https://pypi.org/project/py3exiv2/ Sorry for taking your time but I?m a newbie just trying to help my fellow photographers correct lens distortion problems in post-processing as well as my own. > > Any help much appreciated! > > Thank you > Ken Martell > > This is the error I get : > > D:\>pip3 install py3exiv2 > Collecting py3exiv2 > ? Using cached https://files.pythonhosted.org/packages/eb/c4/675823a2c23d8f138e7dc2b7574d09f26959f641d0b59c3ec7faa65764e5/py3exiv2-0.7.0.tar.gz > Installing collected packages: py3exiv2 > ? Running setup.py install for py3exiv2 ... error > ??? Complete output from command d:\apps\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Ken\\AppData\\Local\\Temp\\pip-install-swqqye4_\\py3exiv2\\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\Ken\AppData\Local\Temp\pip-record-4ki8wmrk\install-record.txt --single-version-externally-managed --compile: > ??? FIND: Invalid switch > ??? FIND: Invalid switch > ??? FIND: Invalid switch > ??? running install > ??? running build > ??? running build_py > ??? creating build > ??? creating build\lib.win-amd64-3.7 > ??? creating build\lib.win-amd64-3.7\pyexiv2 > ??? copying src\pyexiv2\exif.py -> build\lib.win-amd64-3.7\pyexiv2 > ??? copying src\pyexiv2\iptc.py -> build\lib.win-amd64-3.7\pyexiv2 > ??? copying src\pyexiv2\metadata.py -> build\lib.win-amd64-3.7\pyexiv2 > ??? copying src\pyexiv2\preview.py -> build\lib.win-amd64-3.7\pyexiv2 > ??? copying src\pyexiv2\utils.py -> build\lib.win-amd64-3.7\pyexiv2 > ??? copying src\pyexiv2\xmp.py -> build\lib.win-amd64-3.7\pyexiv2 > ??? copying src\pyexiv2\__init__.py -> build\lib.win-amd64-3.7\pyexiv2 > ??? running build_ext > ??? building 'libexiv2python' extension > ??? creating build\temp.win-amd64-3.7 > ??? creating build\temp.win-amd64-3.7\Release > ??? creating build\temp.win-amd64-3.7\Release\src > ??? C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Id:\apps\python37\include -Id:\apps\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /EHsc /Tpsrc/exiv2wrapper.cpp /Fobuild\temp.win-amd64-3.7\Release\src/exiv2wrapper.obj -g > ??? cl : Command line warning D9002 : ignoring unknown option '-g' > ??? exiv2wrapper.cpp > ??? c:\users\ken\appdata\local\temp\pip-install-swqqye4_\py3exiv2\src\exiv2wrapper.hpp(32): fatal error C1083: Cannot open include file: 'exiv2/image.hpp': No such file or directory This is the reason for the failure. Either the build instruction is incorrect, or the file is missing. The py3exiv2 author is listed on the web page. I forwarded you post to him. > ??? error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2 > > ??? ---------------------------------------- > Command "d:\apps\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Ken\\AppData\\Local\\Temp\\pip-install-swqqye4_\\py3exiv2\\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\Ken\AppData\Local\Temp\pip-record-4ki8wmrk\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Ken\AppData\Local\Temp\pip-install-swqqye4_\py3exiv2\ > You are using pip version 19.0.3, however version 19.1 is available. > You should consider upgrading via the 'python -m pip install --upgrade pip' command. Many package authors write and test on *nix, especially when the package includes C or C++ code that needs to be compiled. Compiling on Windows with VSC++ instead of gcc required additional expertise. https://www.lfd.uci.edu/~gohlke/pythonlibs/ Unofficial Windows Binaries for Python Extension Packages has a build for pyexiv2, for 2.7. I suggested to Christoph that he add py3exiv2 for 3.x. While I normally highly recommend starting with 3.x, you could try the prebuilt 2.7 version until you can either build or download py3exiv. -- Terry Jan Reedy From brittocj at gmail.com Wed May 1 22:22:43 2019 From: brittocj at gmail.com (brittocj at gmail.com) Date: Wed, 1 May 2019 19:22:43 -0700 (PDT) Subject: Populating a timetable with subjects Message-ID: Hi All, We have to populate a timetable with subjects. What would be the best approach? In our sample timetable there are 25 hours (keys), all the FH value should be replaced with random subjects as many as their corresponding hour. timetable = [{'A1': "FH", 'B1': "FH", 'C1': "FH", 'D1': "FH", 'E1': "FH"}, {'A2': "FH", 'B2': "FH", 'C2': "FH", 'D2': "FH", 'E2': "FH"}, {'A3': "FH", 'B3': "FH", 'C3': "FH", 'D3': "FH", 'E3': "FH"}, {'A4': "FH", 'B4': "FH", 'C4': "FH", 'D4': "FH", 'E4': "FH"}, {'A5': "FH", 'B5': "FH", 'C5': "FH", 'D5': "FH", 'E5': "FH"}] subjects_required_hours = {"S1": 4, "S2": 3, "S3": 5, "S4": 3, "S5": 5, "S6": 5} From blmadhavan at gmail.com Thu May 2 00:47:33 2019 From: blmadhavan at gmail.com (blmadhavan at gmail.com) Date: Wed, 1 May 2019 21:47:33 -0700 (PDT) Subject: PYTHON equivalents of BITAND and BITSHIFT of MATLAB In-Reply-To: References: <751faa2f-ff76-4316-aff2-ca387917dd08@googlegroups.com> <1556733110.1676.3.camel@gmail.com> Message-ID: <869a571b-6324-42d1-8865-5392c9a53a5c@googlegroups.com> Hello Brian, Thanks for your suggestion. Which is correct for MATLAB command: typeBits = FCF << -9? typeBits = FCF >> 9 or typeBits = FCF >> -9 I mean to ask if it should be -9 or +9? Thanks in advance Madhavan On Wednesday, May 1, 2019 at 11:22:10 PM UTC+5:30, Brian Oney wrote: > On Wed, 2019-05-01 at 10:35 -0700, blmadhavan at gmail.com wrote: > > Hi, > > > > I have the following line from a MATLAB program with FCF (format: UInt_16) as input: > > > > ftype = bitand(FCF, 7) > > typeBits = bitshift(FCF, -9) > > subtype = bitand(typeBits, 7) > > > > I wrote the following in Python for the above commands: > > > > ftype = FCF & 7 > > typeBits = FCF << -9 ------> Is this correct or FCF >> -9? > > subtype = typeBits & 7 > > > > Can someone help me write the equivalent command in PYTHON? > > > > Look forward to your suggestions. > > >From the Matlab doc: > ' > intout = bitshift(A,k) > intout = bitshift(A,k,assumedtype) > Description > > example > > intout = bitshift(A,k) returns A shifted to the left by k bits, > equivalent to multiplying by 2k. Negative values of k correspond to > shifting bits right or dividing by 2|k| and rounding to the nearest > integer towards negative infinity. Any overflow bits are truncated.?' > > So the equivalent would be: > > >>> typeBits =?FCF >> 9 > > Cheers > Brian From dieter at handshake.de Thu May 2 00:53:09 2019 From: dieter at handshake.de (dieter) Date: Thu, 02 May 2019 06:53:09 +0200 Subject: Checking network input processing by Python for a multi-threaded server References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> Message-ID: <8736lxsbii.fsf@handshake.de> Markus Elfring writes: >> https://docs.python.org/3/library/socketserver.html#asynchronous-mixins > An example is provided also in this software documentation. > May I expect that data were completely received from clients and accordingly > processed by the request handler in the started threads after > the statement ?server.shutdown()? was sucessfully executed? Python delegates those low level services to the underlaying network library, which likely will implement the TCP specification. Thus, check the corresponding documentation to find out. From dieter at handshake.de Thu May 2 01:13:15 2019 From: dieter at handshake.de (dieter) Date: Thu, 02 May 2019 07:13:15 +0200 Subject: Dynamic selection for network service ports? References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <8464d60c-cf2f-7c9f-7388-0dcc2dbcd291@web.de> <809f778d-4591-8054-1b8e-35bf067e6cef@web.de> Message-ID: <87y33pqw0k.fsf@handshake.de> Markus Elfring writes: > ... >> You can avoid this with the SO_REUSEADDR flag. > > Can such a configuration parameter be used also together with > programming interfaces from the module ?socketserver?? The "SO" prefix stands for "SOcket" -- "SO_REUSEADDR" is one of many so called "socket option"s. The name "socketserver" suggests that it is based on sockets. Thus, it is highly likely that you can use "SO_REUSEADDR" together with "socketserver" -- in one way or another. In addition, it is very helpful to read the available documentation. The "socketserver" documentation tells you that a "socketserver" has the attribute "allow_reuse_address", described as: "Whether the server will allow the reuse of an address. This defaults to False, and can be set in subclasses to change the policy." The choice of this attribute's name suggests that it was designed to use the "SO_REUSEADDR" socket option internally to support this frequent use case. From dieter at handshake.de Thu May 2 01:30:14 2019 From: dieter at handshake.de (dieter) Date: Thu, 02 May 2019 07:30:14 +0200 Subject: Python 3.73 cannot install py3exiv2 References: <5cc99b4b.1c69fb81.6dc9.0803@mx.google.com> Message-ID: <87tvedqv89.fsf@handshake.de> Ken Martell writes: > ... > D:\>pip3 install py3exiv2 > Collecting py3exiv2 > ... > ??? C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Id:\apps\python37\include -Id:\apps\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /EHsc /Tpsrc/exiv2wrapper.cpp /Fobuild\temp.win-amd64-3.7\Release\src/exiv2wrapper.obj -g > ... > c:\users\ken\appdata\local\temp\pip-install-swqqye4_\py3exiv2\src\exiv2wrapper.hpp(32): fatal error C1083: Cannot open include file: 'exiv2/image.hpp': No such file or directory "pip" (and "pip3") is a tool to install Python extensions. It does quite a good job for "pure Python" extensions. But, some extensions are not "pure Python" but rely on "external" C/C++ libraries. Those must be installed in your system -- typically in a development variant (i.e. together with header files describing the interfaces) -- before "pip" can successfully install the Python extension. Apparently, this is your case. The external C/C++ library is likely named "exiv2". You must install it before "pip" can install "py3exiv2". If you are lucky, then "py3exiv2" comes with installation instructions which tell you where and how to obtain the dependent libraries. Otherwise, you would need other ways to get the necessary information -- maybe search the internet. From tjol at tjol.eu Thu May 2 02:18:39 2019 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 2 May 2019 08:18:39 +0200 Subject: PYTHON equivalents of BITAND and BITSHIFT of MATLAB In-Reply-To: <869a571b-6324-42d1-8865-5392c9a53a5c@googlegroups.com> References: <751faa2f-ff76-4316-aff2-ca387917dd08@googlegroups.com> <1556733110.1676.3.camel@gmail.com> <869a571b-6324-42d1-8865-5392c9a53a5c@googlegroups.com> Message-ID: On 02/05/2019 06:47, blmadhavan at gmail.com wrote: > Hello Brian, > > Thanks for your suggestion. Which is correct for MATLAB command: typeBits = FCF << -9? > > typeBits = FCF >> 9 > > or > > typeBits = FCF >> -9 > > I mean to ask if it should be -9 or +9? Why don't you just, you know, try them out? Fire up MATLAB or GNU Octave (here I'm using MATLAB R2016a) >> bitshift(1024, -9) ans = 2 >> bitshift(1024, +9) ans = 524288 And fire up Python Python 3.7.1 | packaged by conda-forge | (default, Nov 13 2018, 18:33:04) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1024 >> 9 2 >>> 1024 << 9 524288 >>> 1024 << -9 Traceback (most recent call last): File "", line 1, in ValueError: negative shift count >>> > > Thanks in advance > Madhavan > > On Wednesday, May 1, 2019 at 11:22:10 PM UTC+5:30, Brian Oney wrote: >> On Wed, 2019-05-01 at 10:35 -0700, blmadhavan at gmail.com wrote: >>> Hi, >>> >>> I have the following line from a MATLAB program with FCF (format: UInt_16) as input: >>> >>> ftype = bitand(FCF, 7) >>> typeBits = bitshift(FCF, -9) >>> subtype = bitand(typeBits, 7) >>> >>> I wrote the following in Python for the above commands: >>> >>> ftype = FCF & 7 >>> typeBits = FCF << -9 ------> Is this correct or FCF >> -9? >>> subtype = typeBits & 7 >>> >>> Can someone help me write the equivalent command in PYTHON? >>> >>> Look forward to your suggestions. >> >> >From the Matlab doc: >> ' >> intout = bitshift(A,k) >> intout = bitshift(A,k,assumedtype) >> Description >> >> example >> >> intout = bitshift(A,k) returns A shifted to the left by k bits, >> equivalent to multiplying by 2k. Negative values of k correspond to >> shifting bits right or dividing by 2|k| and rounding to the nearest >> integer towards negative infinity. Any overflow bits are truncated.?' >> >> So the equivalent would be: >> >>>>> typeBits =?FCF >> 9 >> >> Cheers >> Brian > From Markus.Elfring at web.de Thu May 2 03:55:12 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Thu, 2 May 2019 09:55:12 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <8736lxsbii.fsf@handshake.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> Message-ID: >> May I expect that data were completely received from clients and accordingly >> processed by the request handler in the started threads after >> the statement ?server.shutdown()? was sucessfully executed? > > Python delegates those low level services to the underlaying > network library, which likely will implement the TCP specification. * How do you think about data processing consequences when record sets are concurrently received and are appended to a global list (for a Python variable)? * Would you expect that the run time system takes care for data consistency because of involved multi-threading? Regards, Markus From chris at withers.org Thu May 2 04:07:34 2019 From: chris at withers.org (Chris Withers) Date: Thu, 2 May 2019 09:07:34 +0100 Subject: mock 3.0.0 released Message-ID: Hi All, I'm pleased to announce the release of mock 3.0.0: https://pypi.org/project/mock/ This brings to rolling backport up to date with cpython master. It's been a few years since the last release, so I'd be surprised if there weren't some problems. If you hit any issues, please pin to mock<3 and then: - If your issue relates to mock functionality, please report in the python tracker: https://bugs.python.org - If your issue is specific to the backport, please report here: https://github.com/testing-cabal/mock/issues If you're unsure, go for the second one and we'll figure it out. cheers, Chris From tiwari.ram77 at gmail.com Thu May 2 04:43:39 2019 From: tiwari.ram77 at gmail.com (tiwari.ram77 at gmail.com) Date: Thu, 2 May 2019 01:43:39 -0700 (PDT) Subject: Fractal Dimension Computation in Python Code In-Reply-To: #1/1> References: #1/1> Message-ID: On Friday, September 29, 2000 at 12:45:00 PM UTC+5:45, Mike Brenner wrote: > Myk> ... Has anyone got a fast routine for calculating the fractal > dimension of a set of points in 2 or 3D space? Thanks. > > According to the inventor of fractals (Hausdorff in the year 1899), you > can place the set of 2D points next to a wall and shine light through > them, and the fractal dimension is the percentage of shadow on the wall. > > If the points are not dense anywhere, then the fractional dimension will > be zero. But if parts of them are filled in, then they will cast a > shadow. > > Same with the 3D points, just put them next to a four dimensional wall > and shine a four dimensional light through them (the way you measure the > amount of holes in a Swiss Cheese :). > > To do this in Python, you would have to define "dense" as being points > that are within a certain distance of each other according to some > cohesion metric, and then add up all the parts according to their > topological coupling. The algorithm in outline would be something like > this: > > dimension=2 > total_area = point_set.integrate_area(dimension,metric) > area = 0 > coupling = neural_net.cluster(point_set,dimension,metric) > for connected_part in coupling: > area = area + connected_part.integrate_area(dimension,metric) > fractional_dimension = dimension * (total_area - area) / total_area > > To make this work for real, just program the three missing functions: > > METRIC computes the distance between two points > > INTEGRATE_AREA integrates over point sets to get their area > > CLUSTER divides the set into independent connected point sets > > If you don't have a neural net available to do the clustering, you can > use a genetic algorithm or an annealing algorithm, all of which are > equivalent. > > You could do this in an analog fashion by using a CRT projector onto the > wall of a dark room and a sensitive light meter feeding into a ADC > connected to your RS-232 or parallel or IEEE or Firewire port. Draw the > point set on the screen and have the computer read the light meter, then > draw an all white screen and read the light meter again, and take the > ratio. Here is the code: > > graphics.init() > graphics.open() > dimension = 2 > graphics.fill_screen(black) > black_area = firewire.read_ADC_voltage() > graphics.fill_screen(white) > white_area = firewire.read_ADC_voltage() > for point in point_set: > graphics.draw_point(point,black) > area = firewire.read_ADC_voltage() > denominator = white_area - black_area > numerator = area - black_area > fractional_dimension = dimension * numerator - denominator > > This code requires you install a graphic capability, a firewire > capability, a light sensitive meter, an analog-to-digital converter, a > firewire driver for the ADC. To do a 3D point set this way, would > probably involve techniques such as a tomograph machine to do one slice > at a time. > > Mike Brenner > MikeTheMathematician at IEEE.org hello sir my name is Ramkrishna tiwari,assistant proessor of physics in tribhuvan university of nepal. Currently i am in a phd project and needs to calculate box counting dimension from earthquake data(lon,lat,mag,depth) etc.i am using python and don't get any clue at all.would you please help me out by explaining the technique. sincerely Ramkrishna tiwari From info at egenix.com Thu May 2 04:55:11 2019 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Thu, 2 May 2019 10:55:11 +0200 Subject: ANN: PyDDF Python Spring Sprint 2019 Message-ID: [This announcement is in German since it targets a local user group meeting in D?sseldorf, Germany] ________________________________________________________________________ ANK?NDIGUNG PyDDF Python Spring Sprint 2019 in D?sseldorf Samstag, 04.05.2019, 10:00-18:00 Uhr Sonntag, 05.05.2019, 10:00-18:00 Uhr trivago N.V., Kesselstrasse 5-7, 40221 D?sseldorf Python Meeting D?sseldorf https://www.pyddf.de/sprint2019/ ________________________________________________________________________ INFORMATION Das Python Meeting D?sseldorf (PyDDF) veranstaltet mit freundlicher Unterst?tzung der *trivago N.V.* ein Python Sprint Wochenende. Der Sprint findet am Wochenende 4./5.5.2019 in der trivago Niederlassung im Medienhafen D?sseldorf statt (Achtung: Nicht mehr am Karl-Arnold-Platz). * Google Maps: https://goo.gl/maps/dGM6ThfkLiJ2 Folgende Themengebiete haben wir als Anregung angedacht: * Openpyxl - https://pythonhosted.org/openpyxl/ * eGenix PyRun - One file Python Runtime Portierung auf Python 3.7 * Einfache Buchf?hrungssoftware in Python Nat?rlich kann jeder Teilnehmer weitere Themen vorschlagen. Alles weitere und die Anmeldung findet Ihr auf der Sprint Seite: https://www.pyddf.de/sprint2019/ WICHTIG: Ohne Anmeldung k?nnen wir kein Badge f?r den Geb?udezugang bereitstellen lassen. Eine spontane Anmeldung am Sprint Tag wird daher vermutlich nicht funktionieren. Also bitte unbedingt mit vollen Namen bis sp?testens Freitag, 03.05., anmelden. Teilnehmer sollten sich zudem auf der PyDDF Liste anmelden, da wir uns dort koordinieren: https://www.egenix.com/mailman/listinfo/pyddf ________________________________________________________________________ ?BER UNS Das Python Meeting D?sseldorf (PyDDF) ist eine regelm??ige Veranstaltung in D?sseldorf, die sich an Python Begeisterte aus der Region wendet: * https://pyddf.de/ Einen guten ?berblick ?ber die Vortr?ge bietet unser YouTube-Kanal, auf dem wir die Vortr?ge nach den Meetings ver?ffentlichen: * http://www.youtube.com/pyddf/ Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting & Research, D?sseldorf: * http://www.egenix.com/ * http://www.clark-consulting.eu/ Mit freundlichen Gr??en, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, May 02 2019) >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> Python Database Interfaces ... http://products.egenix.com/ >>> Plone/Zope Database Interfaces ... http://zope.egenix.com/ ________________________________________________________________________ ::: We implement business ideas - efficiently in both time and costs ::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ http://www.malemburg.com/ From felixen989 at hotmail.co.uk Thu May 2 05:20:06 2019 From: felixen989 at hotmail.co.uk (felixen989 at hotmail.co.uk) Date: Thu, 2 May 2019 02:20:06 -0700 (PDT) Subject: Help a noob out Message-ID: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> Hey guys, can someone quickly explain why this piece of code doesn't work? (I'm really new to Python) birth_year = input("What year are you born? ") current_year = 2019 age = current_year - birth_year print(age) From rosuav at gmail.com Thu May 2 05:28:50 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 2 May 2019 19:28:50 +1000 Subject: Help a noob out In-Reply-To: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> References: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> Message-ID: On Thu, May 2, 2019 at 7:26 PM wrote: > > Hey guys, can someone quickly explain why this piece of code doesn't work? (I'm really new to Python) > > birth_year = input("What year are you born? ") > current_year = 2019 > age = current_year - birth_year > print(age) Have you looked at the exception message you get back? It's fairly clear. ChrisA From ar at zeit.io Thu May 2 05:30:02 2019 From: ar at zeit.io (Arup Rakshit) Date: Thu, 2 May 2019 15:00:02 +0530 Subject: Help a noob out In-Reply-To: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> References: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> Message-ID: <42EA0354-347A-48E1-B009-4873F23EC875@zeit.io> The input function returns the string value. So you need to convert it to number before the math you do. birth_year = input("What year are you born? ") current_year = 2019 print(type(birth_year)) age = current_year - int(birth_year) print(age) ????? python3 age.py What year are you born? 1989 30 Thanks, Arup Rakshit ar at zeit.io > On 02-May-2019, at 2:50 PM, felixen989 at hotmail.co.uk wrote: > > birth_year = input("What year are you born? ") > current_year = 2019 > age = current_year - birth_year > print(age) From inhahe at gmail.com Thu May 2 05:43:28 2019 From: inhahe at gmail.com (inhahe) Date: Thu, 2 May 2019 05:43:28 -0400 Subject: Help a noob out In-Reply-To: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> References: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> Message-ID: On Thu, May 2, 2019 at 5:26 AM wrote: > Hey guys, can someone quickly explain why this piece of code doesn't work? > (I'm really new to Python) > > birth_year = input("What year are you born? ") > current_year = 2019 > age = current_year - birth_year > print(age) > -- > https://mail.python.org/mailman/listinfo/python-list input() returns a string. So the user enters "1978" for example but he could just have easily entered "Honda Civic". Python doesn't know to interpret it as a number in order to do arithmetic or it until you convert it to an integer. birth_year = int(input("What year were you born?")) should work, unless I missed something else. (the int() converts the string to an integer) Maybe it would be more professional to do some error checking though, e.g. print that there was incorrect input and ask again if they didn't actually input an integer. You could do this using the try and except keywords (in some kind of loop), as int() raises an exception when the string you pass it isn't an actual integer. From felixen989 at hotmail.co.uk Thu May 2 06:38:11 2019 From: felixen989 at hotmail.co.uk (=?UTF-8?Q?Hampus_Sj=C3=B6din?=) Date: Thu, 2 May 2019 03:38:11 -0700 (PDT) Subject: Help a noob out In-Reply-To: References: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> Message-ID: Den torsdag 2 maj 2019 kl. 11:43:53 UTC+2 skrev inhahe: > On Thu, May 2, 2019 at 5:26 AM wrote: > > > Hey guys, can someone quickly explain why this piece of code doesn't work? > > (I'm really new to Python) > > > > birth_year = input("What year are you born? ") > > current_year = 2019 > > age = current_year - birth_year > > print(age) > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > input() returns a string. So the user enters "1978" for example but he > could just have easily entered "Honda Civic". Python doesn't know to > interpret it as a number in order to do arithmetic or it until you convert > it to an integer. > > birth_year = int(input("What year were you born?")) should work, unless I > missed something else. > > (the int() converts the string to an integer) > > Maybe it would be more professional to do some error checking though, e.g. > print that there was incorrect input and ask again if they didn't actually > input an integer. You could do this using the try and except keywords (in > some kind of loop), as int() raises an exception when the string you pass > it isn't an actual integer. Thank you for your responses. I managed to figure it all out with your guys help. From felixen989 at hotmail.co.uk Thu May 2 07:05:55 2019 From: felixen989 at hotmail.co.uk (=?UTF-8?Q?Hampus_Sj=C3=B6din?=) Date: Thu, 2 May 2019 04:05:55 -0700 (PDT) Subject: Errorcode when running scripts in PyCharm Message-ID: <7f3e5e26-5371-4538-94ad-67bac2464e8e@googlegroups.com> Hey guys, so I've managed to ruin PyCharm for myself.. I just finished my first script in PyCharm and I tried renaming the file, so I closed PyCharm to reenter the file using the file manager.. And now it won't run when I try to. This is what I get: C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe: can't find '__main__' module in 'C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts' Process finished with exit code 1 From PythonList at DancesWithMice.info Thu May 2 07:30:56 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 2 May 2019 23:30:56 +1200 Subject: Errorcode when running scripts in PyCharm In-Reply-To: <7f3e5e26-5371-4538-94ad-67bac2464e8e@googlegroups.com> References: <7f3e5e26-5371-4538-94ad-67bac2464e8e@googlegroups.com> Message-ID: <3996822c-dfd5-b261-390e-6b80d5b8db53@DancesWithMice.info> On 2/05/19 11:05 PM, Hampus Sj?din wrote: > Hey guys, so I've managed to ruin PyCharm for myself.. I just finished my first script in PyCharm and I tried renaming the file, so I closed PyCharm to reenter the file using the file manager.. And now it won't run when I try to. > > This is what I get: > > C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts > C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe: can't find '__main__' module in 'C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts' > > Process finished with exit code 1 Is the Python code stored in a file called Scripts, called Scripts.py, or perhaps a file inside the Scripts directory? Perhaps the Windows FAQ might help? https://docs.python.org/3.6/faq/windows.html -- Regards =dn From PythonList at DancesWithMice.info Thu May 2 07:33:01 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 2 May 2019 23:33:01 +1200 Subject: Help a noob out In-Reply-To: <42EA0354-347A-48E1-B009-4873F23EC875@zeit.io> References: <70d91ded-1fbb-4e8f-8744-bd9a3797975f@googlegroups.com> <42EA0354-347A-48E1-B009-4873F23EC875@zeit.io> Message-ID: On 2/05/19 9:30 PM, Arup Rakshit wrote: > The input function returns the string value. So you need to convert it to number before the math you do. > > > birth_year = input("What year are you born? ") > current_year = 2019 > print(type(birth_year)) > age = current_year - int(birth_year) > print(age) > > ????? > > python3 age.py > What year are you born? 1989 > > 30 > > Thanks, > > Arup Rakshit > ar at zeit.io +1 -- Regards =dn From smilesonisamal at gmail.com Thu May 2 07:30:31 2019 From: smilesonisamal at gmail.com (Pradeep Patra) Date: Thu, 2 May 2019 04:30:31 -0700 (PDT) Subject: How to pass username and password in the curl requests using requests python module In-Reply-To: References: Message-ID: <6de58f6a-be0a-4c09-9558-6a250ec58178@googlegroups.com> Can anyone pls help in this regard? From felixen989 at hotmail.co.uk Thu May 2 07:35:27 2019 From: felixen989 at hotmail.co.uk (=?UTF-8?Q?Hampus_Sj=C3=B6din?=) Date: Thu, 2 May 2019 04:35:27 -0700 (PDT) Subject: Errorcode when running scripts in PyCharm In-Reply-To: References: <7f3e5e26-5371-4538-94ad-67bac2464e8e@googlegroups.com> <3996822c-dfd5-b261-390e-6b80d5b8db53@DancesWithMice.info> Message-ID: <65bb7b8b-955b-4f76-9e5d-949285987483@googlegroups.com> Den torsdag 2 maj 2019 kl. 13:31:29 UTC+2 skrev DL Neil: > On 2/05/19 11:05 PM, Hampus Sj?din wrote: > > Hey guys, so I've managed to ruin PyCharm for myself.. I just finished my first script in PyCharm and I tried renaming the file, so I closed PyCharm to reenter the file using the file manager.. And now it won't run when I try to. > > > > This is what I get: > > > > C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts > > C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe: can't find '__main__' module in 'C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts' > > > > Process finished with exit code 1 > > > Is the Python code stored in a file called Scripts, called Scripts.py, > or perhaps a file inside the Scripts directory? > > Perhaps the Windows FAQ might help? > https://docs.python.org/3.6/faq/windows.html > > -- > Regards =dn I have Python installed in: C:\Users\hampu\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7 I have Python.exe installed in: C:\Users\hampu\PycharmProjects\Laboration4\venv\Scripts I have Pycharm installed in: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains And the current python file in: C:\Users\hampu\OneDrive\Skrivbord\lab4 I'm gonna take a wild guess and guess that something needs to be moved. From PythonList at DancesWithMice.info Thu May 2 08:01:01 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 3 May 2019 00:01:01 +1200 Subject: How to pass username and password in the curl requests using requests python module In-Reply-To: <6de58f6a-be0a-4c09-9558-6a250ec58178@googlegroups.com> References: <6de58f6a-be0a-4c09-9558-6a250ec58178@googlegroups.com> Message-ID: <49e5805c-5bb1-5ec7-6f73-82387710ccb1@DancesWithMice.info> On 2/05/19 11:30 PM, Pradeep Patra wrote: > Can anyone pls help in this regard? Yes! | | | | | | | | | | | | | | | | | | | | | | V However, whilst accurate, that answer in NOT helpful? The question is so wide. Which part(s) should we answer? Why don't we start with the code you have written thus far (suitably obfuscated); the errmsg you are experiencing; any lessons, tutorial, or books you are following; plus other pertinent data... (help us to help you!) -- Regards =dn From uri at speedy.net Thu May 2 08:43:17 2019 From: uri at speedy.net (=?UTF-8?B?15DXldeo15k=?=) Date: Thu, 2 May 2019 15:43:17 +0300 Subject: Errorcode when running scripts in PyCharm In-Reply-To: <7f3e5e26-5371-4538-94ad-67bac2464e8e@googlegroups.com> References: <7f3e5e26-5371-4538-94ad-67bac2464e8e@googlegroups.com> Message-ID: Try to contact PyCharm support at support at jetbrains.com ???? uri at speedy.net On Thu, May 2, 2019 at 2:11 PM Hampus Sj?din wrote: > Hey guys, so I've managed to ruin PyCharm for myself.. I just finished my > first script in PyCharm and I tried renaming the file, so I closed PyCharm > to reenter the file using the file manager.. And now it won't run when I > try to. > > This is what I get: > > C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe > C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts > C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe: can't > find '__main__' module in > 'C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts' > > Process finished with exit code 1 > -- > https://mail.python.org/mailman/listinfo/python-list > From vincent.vande.vyvre at telenet.be Thu May 2 05:50:59 2019 From: vincent.vande.vyvre at telenet.be (Vincent Vande Vyvre) Date: Thu, 2 May 2019 11:50:59 +0200 Subject: Python 3.73 cannot install py3exiv2 In-Reply-To: <5cc99b4b.1c69fb81.6dc9.0803@mx.google.com> References: <5cc99b4b.1c69fb81.6dc9.0803@mx.google.com> Message-ID: Le 1/05/19 ? 15:12, Ken Martell a ?crit?: > I?m a retired aerospace engineer. I?m a Windows 10 user & have zero experience with Python. My goal is to learn, get this working & run lens distortion correction routines using Python. I?ve tried or many hours and read as much as I can but cannot get the py3exiv2 module to install. Other needed modules installed fine. It appears the Python version 2 of evix2 is needed as a dependent for the version 3 but neither pip or pip3 will install old or new. Sorry for taking your time but I?m a newbie just trying to help my fellow photographers correct lens distortion problems in post-processing as well as my own. > > Any help much appreciated! > > Thank you > Ken Martell > > > > Sent from Mail for Windows 10 > > The package available on PyPI is for *nix machines. I don't have access to a Windows machine nor the knowledge to build an executable for Windows. But, recently an user send me how it has successfully compiled py3exiv2 for Windows. Hello Vincent, ?I?ve run through the trouble of building py3exiv2 on Windows and was successful in doing so, therefore I?d like to present you the steps I?ve taken to get there, so that you can alter setup.py and give some instructions on how to install it on Windows. This is a copy of his mail: ----------------------------------------------------------------------------------- ?The key part in making this work is https://github.com/Microsoft/vcpkg, it has both exiv2 and boost-python. Here?s what I did: ?[INSTALLING PYEXIV3 ON WINDOWS] - install GIT-2.21.0-64-bit.exe - install VSCodeUserSetup-x64-1.33.1.exe - clone vcpkg, note the folder name ??? $ git clone https://github.com/Microsoft/vcpkg.git - install vcpkg by running .\bootstrap-vcpkg.bat - run vcpkg.exe install boost-python:x64-windows - run vcpkg.exe install exiv2:x64-windows - make sure to add /installed/x64-windows/bin to the PATH (for dll import) - get the pyexiv2 sources from here: http://py3exiv2.tuxfamily.org/downloads - replace setup.py with my version - set the environment variable VCPKG to the folder where you installed it - run pip install -e I?ve attached my modified version of setup.py. It?s very rough since I don?t know much about setuptools at all, but it essentially involves bypassing `get_libboost_name` which fails completely on windows and using the environment variable VCPGK that has to be set by the user to point at the vcpkg directory. There?s probably a cleaner way of doing this, like accepting a command line argument. But again, I have no idea how setuptools handles this so hopefully you can clean it up a bit. `boost_python37-vc140-mt` is also completely hardcoded, you?d probably have to modify `get_libboost_name` to work on Windows. ?While I?m at this, I?ve noticed the lack of support for custom xmp tags. For now I?ve resorted to abusing various IPTC Tags for my purpose, but that?s a rather terrible solution. I?d appreciate it if you could prioritize adding that feature in the future. ?with best regards, Vic setup.py #!/usr/bin/python3 # -*- coding: utf-8 -*- import sys import os import glob import subprocess from setuptools import setup, find_packages, Extension from codecs import open from os import path here = path.abspath(path.dirname(__file__)) # Get the long description from the relevant file with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f: ??? long_description = f.read() def get_libboost_name(): ??? """Returns the name of the lib libboost_python 3 ??? """ ??? # libboost libs are provided without .pc files, so we can't use pkg-config ??? places = ('/usr/lib/', '/usr/local/lib/', '/usr/') ??? for place in places: ??????? cmd = ['find', place, '-name', 'libboost_python*'] ??????? rep = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] ??????? if not rep: ??????????? continue ??????? # rep is type bytes ??????? libs = rep.decode(sys.getfilesystemencoding()).split('\n') ??????? for l in libs: ??????????? _, l = os.path.split(l) ??????????? if '.so' in l: ??????????????? l = l.split('.so')[0] ??????????????? # Assume there's no longer python2.3 in the wild ??????????????? if '3' in l[-2:]: ??????????????????? return l.replace('libboost', 'boost') if os.name == 'nt': ??? basep = os.environ["VCPKG"] + r"\installed\x64-windows" ??? os.environ["INCLUDE"] = basep + r"\include" ??? libboost = basep + r"\lib\boost_python37-vc140-mt" ??? libexiv = basep + r"\lib\exiv2" ??? extra_compile_args = [] else: ??? libboost = get_libboost_name() ??? extra_compile_args = [] ??? libexiv = 'exiv2' setup( ??? name='py3exiv2', ??? version='0.7.0', ??? description='A Python3 binding to the library exiv2', ??? long_description=long_description, ??? url='https://launchpad.net/py3exiv2', ??? author='Vincent Vande Vyvre', ??? author_email='vincent.vandevyvre at oqapy.eu', ??? license='GPL-3', ??? # See https://pypi.python.org/pypi?%3Aaction=list_classifiers ??? classifiers=[ ??????? 'Development Status :: 5 - Production/Stable', ??????? 'Intended Audience :: Developers', ??????? 'Topic :: Software Development', ??????? 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', ??????? 'Programming Language :: C++', ??????? 'Programming Language :: Python :: 3.3', ??????? 'Programming Language :: Python :: 3.4', ??????? 'Programming Language :: Python :: 3.5', ??????? 'Programming Language :: Python :: 3.6', ??????? 'Programming Language :: Python :: 3.7', ??????? 'Programming Language :: Python :: 3.8' ??? ], ??? keywords='exiv2 pyexiv2 EXIF IPTC XMP image metadata', ??? packages = find_packages('src'), ??? package_dir = {'': 'src'}, ??? package_data={'':['src/*.cpp', 'src/*.hpp',]}, ??? #cmdclass={'install': install} ??? ext_modules=[ ??? Extension('libexiv2python', ??????? ['src/exiv2wrapper.cpp', 'src/exiv2wrapper_python.cpp'], ??????? include_dirs=[], ??????? library_dirs=[], ??????? libraries=[libboost, libexiv], ??????? extra_compile_args=extra_compile_args ??????? ) ??? ], ) -------------------------------------------------------------------------------- Vincent From toby at tobiah.org Thu May 2 13:59:51 2019 From: toby at tobiah.org (Tobiah) Date: Thu, 2 May 2019 10:59:51 -0700 Subject: How to pass username and password in the curl requests using requests python module References: <6de58f6a-be0a-4c09-9558-6a250ec58178@googlegroups.com> Message-ID: On 5/2/19 4:30 AM, Pradeep Patra wrote: > Can anyone pls help in this regard? > Something like this?: requests.get('https://api.github.com/user', auth=('user', 'pass')) From Markus.Elfring at web.de Thu May 2 15:38:40 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Thu, 2 May 2019 21:38:40 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <209mcetvned72ganltpnjchvih7vhrfar0@4ax.com> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <07440199-833c-ac3b-abb4-11a5a83b936b@web.de> <209mcetvned72ganltpnjchvih7vhrfar0@4ax.com> Message-ID: <7c6d312d-d6a9-4c82-3c41-5b50df1aeaa1@web.de> >> An instance for the class ?threaded_TCP_server? and a call of ?subprocess.run(?)?. >> > And how many connections does the subprocess make? A new TCP connection is performed with the information from the passed parameters for each call of the function ?sendall?. The test command will send JSON data over these six connections then. > A full connect(), send(), close() for each output? Yes, for this test variant. > OTOH, if you are making multiple connect() calls, then OS scheduling > could result in multiple server threads running. This functionality is desired. ? > Of course, you still have to use your head! ? > For instance, it makes no sense to use a forking server ? I would expect that the main test process will not be forked here. >> I hope that the execution of the statement ?server.shutdown()? triggers >> a separation in the reported inter-process communication. > > .shutdown() stops the server from processing new connections... I hope so, too. (Additional server objects can be created in subsequent loop iterations.) How does this interpretation fit to the wording ?Tell the serve_forever() loop to stop and wait until it does.? from the documentation of the class ?socketserver.BaseServer?? > It does nothing for the nature of TCP streams This aspect should be fine. > I'd be tempted to convert the master and subprocess from TCP to UDP, > just to see if there is a difference. I do not want to change the data transmission technique for this use case. I suggest to take another look at a related discussion topic like ?Data exchange over network interfaces by SmPL scripts? if you would prefer to review a concrete source code example instead of recognising data processing consequences from a known test algorithm. https://systeme.lip6.fr/pipermail/cocci/2019-April/005792.html https://lore.kernel.org/cocci/6ec5b70f-39c3-79e5-608f-446a870f02f3 at web.de/ Will it help to add a bug report in an issue tracker? Regards, Markus From Markus.Elfring at web.de Fri May 3 04:01:45 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Fri, 3 May 2019 10:01:45 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <87y33o878r.fsf@handshake.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> Message-ID: > In any multi-threaded application, you must be carefull when > accessing (and especially modifying) shared (e.g. "global") objects. > In general, you will need locks to synchronize the access. I agree to this general view. > Appending to a list (and some other elementary operations > on Python data structures) is protected by Python's "GIL" > (= "Global Interpreter Lock") and thereby becomes "atomic". > Thus, if all you do is appending - then the append has no need > of explicite locking. Thanks for such information. > It does not protect the integrity of your data structures. It can be that the data protection needs to be extended occasionally. But I am more interested in the detail that a specific Python list variable should reflect the received record sets from a single test command in a consistent way. Did all extra worker threads exit after the statement ?server.shutdown()? was successfully executed? > Thus, if your threads modify shared objects, then you are responsible > to protect access to them with appropriate locking. How do you think about to improve the distinction for the really desired lock granularity in my use case? Regards, Markus From david at aeolia.co.uk Fri May 3 11:10:40 2019 From: david at aeolia.co.uk (David Sumbler) Date: Fri, 03 May 2019 16:10:40 +0100 Subject: tix.FileSelectBox causes crash: was A newbie question about using tix In-Reply-To: <72d61b7e-6770-0410-c423-d4734d3bcaaf@mrabarnett.plus.com> References: <0c8f97460ee13c3bea72a56a1074c27e81b64bda.camel@aeolia.co.uk> <72d61b7e-6770-0410-c423-d4734d3bcaaf@mrabarnett.plus.com> Message-ID: On Wed, 2019-05-01 at 19:11 +0100, MRAB wrote: > On 2019-05-01 17:44, David Sumbler wrote: > > > > On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote: ... > > > For some reason, tix widgets don't work with normal tkinter > widgets, > > > so > > > you can't put a tix FileSelectBox on a tkinter.Tk widget. > > > > > > There is, however, a tix.Tk widget that you can use instead: > > > > > > import tkinter.tix as tix > > > root = tix.Tk() > > > f = tix.FileSelectBox(root) > > > f.pack() > > > > Thanks for that. > > > > When I ran the above, I got: > > > > Traceback (most recent call last): > > File "/home/david/bin/GradientProfile_v2.py", line 2, in > > > root = tix.Tk() > > File "/usr/lib/python3.6/tkinter/tix.py", line 214, in > __init__ > > self.tk.eval('package require Tix') > > _tkinter.TclError: can't find package Tix > > > > After an internet search, I tried: > > > > sudo apt install tix-dev tk-dev tk8.6-dev libxft-dev > libfontconfig1-dev libfreetype6-dev libpng-dev > > > > Now when I run the file the program just exits quickly, with no > > reported errors, but no window(s). If I add 'root.mainloop()' at > the > > end, I get an empty root window for a fraction of a second, then > the > > program exits with: > > > > Segmentation fault (core dumped) > > > > Any suggestions as to where to go from here? > > > Tested on Raspbian in a terminal window: > > sudo apt-get install tix > > python3 > > import tkinter.tix as tix > root = tix.Tk() > f = tix.FileSelectBox(root) > f.pack() > > At this point there's a GUi window filled with a file section box. When I enter the above lines in python 3.6.7 on my desktop computer, running Ubuntu 18.04, the final line causes Python to crash with the message: Segmentation fault (core dumped) I also tried this in python 2.7.15rc1 with the same result. I then tried it on my HP laptop computer, also running Ubuntu 18.04. Again, it produced a segmentation fault. However, on my partner's computer, which is running Ubuntu 16.04, the code works as it should. It looks as if perhaps there is some bug in Ubuntu 18.04 which, so far as my experience goes, only manifests itself when using tix in Python (either version 2 or 3). I have run most of the files in Mark Lutz's Programming Python (including most of the tkinter chapters) without any problem. I can find no reference to a bug of this sort when doing an internet search, so perhaps there could be some other explanation. Does anyone else see the same crash when trying to use tix.FileSelectionBox? David From grant.b.edwards at gmail.com Fri May 3 15:41:15 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 3 May 2019 19:41:15 -0000 (UTC) Subject: Where is getstatusoutput() in subprocess module? Message-ID: I'm trying to update a python2 app to make it python3 compatible. It uses commands.getstatusoutput(), which according to https://docs.python.org/2/library/commands.html#commands.getstatusoutput ... getstatusoutput() and getoutput() have been moved to the subprocess module. Where are they? -- Grant Edwards grant.b.edwards Yow! How many retured at bricklayers from FLORIDA gmail.com are out purchasing PENCIL SHARPENERS right NOW?? From Markus.Elfring at web.de Fri May 3 15:50:26 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Fri, 3 May 2019 21:50:26 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <07440199-833c-ac3b-abb4-11a5a83b936b@web.de> <209mcetvned72ganltpnjchvih7vhrfar0@4ax.com> <7c6d312d-d6a9-4c82-3c41-5b50df1aeaa1@web.de> Message-ID: <9865261e-0ddc-9716-69e9-5d1960ad5649@web.de> > I suggested UDP as a TEST, not for the end use... I can understand such a suggestion. Can it distract from other software surprises? > If UDP gives you the results you expect, it most likely means there is a problem There is a questionable software behaviour still waiting for a proper solution (without switching the data transmission technique for this use case). > in how you are processing TCP data. Which impressions did you get from the implementation of the published Python functions ?receive_data? and ?receive_message? (according to the previously mentioned links)? Regards, Markus From grant.b.edwards at gmail.com Fri May 3 16:41:56 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 3 May 2019 20:41:56 -0000 (UTC) Subject: Where is getstatusoutput() in subprocess module? References: Message-ID: On 2019-05-03, Grant Edwards wrote: > I'm trying to update a python2 app to make it python3 compatible. It > uses commands.getstatusoutput(), which according to > > https://docs.python.org/2/library/commands.html#commands.getstatusoutput > > ... getstatusoutput() and getoutput() have been moved to the subprocess module. > > Where are they? Doh, never mind. They were only moved in Python3. I didn't realize that the "In Python 3.x" qualifier from the beginning of the previous sentence applied to the entire paragraph. -- Grant Edwards grant.b.edwards Yow! I am deeply CONCERNED at and I want something GOOD gmail.com for BREAKFAST! From python at mrabarnett.plus.com Fri May 3 16:59:49 2019 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 3 May 2019 21:59:49 +0100 Subject: Where is getstatusoutput() in subprocess module? In-Reply-To: References: Message-ID: <546ceb79-aeb3-10d1-7fae-64c8abae9366@mrabarnett.plus.com> On 2019-05-03 20:41, Grant Edwards wrote: > I'm trying to update a python2 app to make it python3 compatible. It > uses commands.getstatusoutput(), which according to > > https://docs.python.org/2/library/commands.html#commands.getstatusoutput > > ... getstatusoutput() and getoutput() have been moved to the subprocess module. > > Where are they? > Here: https://docs.python.org/3/library/subprocess.html#subprocess.getstatusoutput From PythonList at DancesWithMice.info Fri May 3 17:02:02 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Sat, 4 May 2019 09:02:02 +1200 Subject: Configuration confusion = Friday Filosofical Finking Message-ID: <519298e7-4822-535d-9d72-9d99674c6865@etelligence.info> When configuring an application, which mechanisms do you [not] use for setting particular operating-parameters, and/or do you *only* utilise a particular method to initialise certain categories of configuration-data? Apologies: as they say in football, this is a game of two halves... 1 In the same way that functions and methods are controlled by parameters/arguments, so are scripts. Whether the code we are building will be long-running, eg a server or web-app; or perhaps it will be run on numerous occasions but for shorter periods, by the same or different users; we (usually) need to configure settings to control or customise its use. Here are some categories of config-data: - k: CONSTANTS or variable_constants - keys: API keys - credentials: DB configurations - logs: log definitions - coding: DEBUG - ops: userID (in the sense of addressing, billing, or control) - limitations: environment (eg only runs under *nix or MS-Windows) - user: personalID, user-category, credentials, 2FA (please add better examples and missing categories) 2 Python offers a veritable range of mechanisms to accomplish configuration tasks. Some are easier to see (literally), whereas others are less visible. Some are easier to access and amend. Some allow for more complex data-relationships. Others limited to Python-coders only. Each has its own virtue, and possibly disadvantage. Here's a list: - mainline* - (import-ed) code module - application .conf/.ini/etc file - user-controlled .conf/.ini/etc file - command-line - (OpSys) environment variable (please add anything missing - together with how you might (not) use it) * old-time terminology? This is the script/program-file executed by the python3 command, called from WSGI, or whatever. Thus, config-data appearing shortly-after the import statements (per PEP-8) or soon after the if __main__ etc construct. Aside It might be easier to imagine the two lists side-by-side - you may recall from primary/elementary school such question-structures, eg a list of animals on one side and another of collective-nouns on the other. The task was to pair "lion" with "pride" and "sheep" with "flock", etc. We even have mechanised grading for this style of question, even though most computer-assessment is the multi-choice a/b/c/d question. Grrr! So, to the question(s) How do you pair various categories of data, with particular mechanisms? Do you separate config-data by mechanism or lump-it-all-in-together? Is it merely a preference, or even a habit, eg I've some utility code close-to-hand? Are some mechanisms too inherently-weak for use in certain situations? Is there too much "risk" if a mechanism can't be included in version-control? Dare we allow users certain tools? (see also previous thread discussing users and .ini/.yaml/etc files) Do some not offer the necessary power/flexibility? Web-Refs: Python Setup and Usage https://docs.python.org/3/using/index.html PEP-8 https://www.python.org/dev/peps/pep-0008/ Zen of Python references (import this): Explicit is better than implicit. There should be one-- and preferably only one --obvious way to do it. -- Regards, =dn From cs at cskk.id.au Fri May 3 19:19:14 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 4 May 2019 09:19:14 +1000 Subject: Configuration confusion = Friday Filosofical Finking In-Reply-To: <519298e7-4822-535d-9d72-9d99674c6865@etelligence.info> References: <519298e7-4822-535d-9d72-9d99674c6865@etelligence.info> Message-ID: <20190503231914.GA46545@cskk.homeip.net> On 04May2019 09:02, DL Neil wrote: >When configuring an application, which mechanisms do you [not] use for >setting particular operating-parameters, and/or do you *only* utilise >a particular method to initialise certain categories of >configuration-data? [...] I don't conventions with have complete coverage of your list, but: >Here are some categories of config-data: > >- k: CONSTANTS or variable_constants I like programmes to be able to run without a configuration file. Aside from API keys and other credentials, I like both modules and main programmes to have reasonable wired in default CONSTANTS for when there is no external configuration. Even for a database I might at least provide something like: DEFAULT_DBHOST = '127.0.0.1' to expect a local database server if there's no configuration. >- keys: API keys >- credentials: DB configurations Keys and credentials are always in separate files, and _not_ under revision control. At least not under the same control as the code - they should never leak into a code repo. However, the location of those files might be configurable. pArticularly when the application can be invoked from the command line it is often desirable to be able to say "get your configuration from over there". >- logs: log definitions I believe the logging module supports putting logging configuration in a file; I haven't used it. >- coding: DEBUG Usually default off (so that production mode is the default, reducing accidents), triggerable by setting the environment variable $DEBUG to "1". And the logging configuration might specific log levels. >- ops: userID (in the sense of addressing, billing, or control) >- limitations: environment (eg only runs under *nix or MS-Windows) >- user: personalID, user-category, credentials, 2FA Userids tend to go in configuration so that one can run an instance of the application for this purpose, and and also for that purpose. Regarding mechanisms, my hierarchy of configuration tends to go: code default CONSTANTS configuration file environment variables command line options in order of override. Not all things get control from all levels. In particular security related modes _might_ not pay attention to any environment variables, and might even mandate explicit settings in a config file. To avoid accidents and assumptions. For flattish configuration I do like the .ini file format: it is very easy to read and edit. The situation is articularly good now that Python3's parser supports both easy dictionary/mapping access to the fields and also will write out such a mapping in .ini format, which is great for generating configurations (example: the "init" step for a new app: it can dump the entire config out to the standard place if there's no existing config file, giving the user a prefilled file with all the setting available for inspection and adjustment). Cheers, Cameron Simpson From cs at cskk.id.au Fri May 3 19:51:36 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 4 May 2019 09:51:36 +1000 Subject: Populating a timetable with subjects In-Reply-To: References: Message-ID: <20190503235136.GA37468@cskk.homeip.net> On 01May2019 19:22, brittocj at gmail.com wrote: >We have to populate a timetable with subjects. What would be the best >approach? That's a pretty open ended question. Often a constraint on generating timetables involves ensuring that no 2 subjects use the same timeslot if a student might need to take both those subjects. Unless that student is Hermoine Grainger. Also, this looks like homework: we're happy to help, but we tend not to write code for you. We'll suggest approaches and answer specific questions. But... >In our sample timetable there are 25 hours (keys), all the FH value should be replaced with random subjects as many as their corresponding hour. > >timetable = [{'A1': "FH", 'B1': "FH", 'C1': "FH", 'D1': "FH", 'E1': "FH"}, > {'A2': "FH", 'B2': "FH", 'C2': "FH", 'D2': "FH", 'E2': "FH"}, > {'A3': "FH", 'B3': "FH", 'C3': "FH", 'D3': "FH", 'E3': "FH"}, > {'A4': "FH", 'B4': "FH", 'C4': "FH", 'D4': "FH", 'E4': "FH"}, > {'A5': "FH", 'B5': "FH", 'C5': "FH", 'D5': "FH", 'E5': "FH"}] > >subjects_required_hours = {"S1": 4, "S2": 3, "S3": 5, "S4": 3, "S5": 5, "S6": 5} Given just the constraint you describe you want to do something like the following: loop over the keys of the timetable for each key, pick a random subject from those available fill in that timetable key with the subject reduce the hour count for that subject by the length of the timetable slot (1 hour, so just 1) The definition of "available subjects" above will be those subject with more than 0 hours. You might do that in a few ways. Two examples: Use "subject_required_hours" (or a copy of it) as your record of available subjects. When a subject's hours drop the 0 (when you subtract 1 above), deleted it from "subject_required_hours" using the "del" Python statement. That way the dict only contains available subjects. So you just pick randomly from the keys of the dict on each loop iteration. Alternatively you could treat it like a deck of cards: make an empty list, and append to it sufficent copies of the subject names so that it looks like: ["S1", "S1", "S1", "S1", "S2", "S2", "S2", "S3" .......] Then in the loop pick a random element from the list, and remove that element. Performance note: deleting an element from anywhere but the end of a list is a little expensive, so you might instead copy the last list element to the "deleted" location, and delete the last element. Python has a "random" module for getting random numbers and you can use that to choose a random index into an array/list. If you pick an approach and then encounter more problems, come back and ask (by replying to this thread, _not_ by making a totally new message), and include both your code and whatever output you're getting, along with a description of what's wrong with the output. Always cut/paste code and errors messages straight into your message - this list strips attachments and non-text. Cheers, Cameron Simpson From cs at cskk.id.au Fri May 3 19:56:43 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 4 May 2019 09:56:43 +1000 Subject: Errorcode when running scripts in PyCharm In-Reply-To: <65bb7b8b-955b-4f76-9e5d-949285987483@googlegroups.com> References: <65bb7b8b-955b-4f76-9e5d-949285987483@googlegroups.com> Message-ID: <20190503235643.GA78921@cskk.homeip.net> On 02May2019 04:35, Hampus Sj?din wrote: >Den torsdag 2 maj 2019 kl. 13:31:29 UTC+2 skrev DL Neil: >> On 2/05/19 11:05 PM, Hampus Sj?din wrote: >> > Hey guys, so I've managed to ruin PyCharm for myself.. I just finished my first script in PyCharm and I tried renaming the file, so I closed PyCharm to reenter the file using the file manager.. And now it won't run when I try to. >> > >> > This is what I get: >> > >> > C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts >> > C:\Users\hampu\AppData\Local\Programs\Python\Python37-32\python.exe: can't find '__main__' module in 'C:/Users/hampu/PycharmProjects/Laboration4/venv/Scripts' >> > >> > Process finished with exit code 1 This looks like you tried to "run" the venv Scripts directory. But you actually want to run your own script. So from the below... [...] >I have Python installed in: >C:\Users\hampu\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7 > >I have Python.exe installed in: C:\Users\hampu\PycharmProjects\Laboration4\venv\Scripts > >I have Pycharm installed in: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains > >And the current python file in: C:\Users\hampu\OneDrive\Skrivbord\lab4 > >I'm gonna take a wild guess and guess that something needs to be moved. it looks like you should be issuing the command: C:\Usershttp://www.cskk.ezoshosting.com/cs/ampu\AppData\Local\Programs\Python\Python37-32\python.exe C:\Usershttp://www.cskk.ezoshosting.com/cs/ampu\OneDrive\Skrivbord\lab4\your_script.py Nothing should be moved: in particualr you do not want to put "your" files anywhere in the application install areas. Keep them where you have them, in your "lab4" folder. You just want to tell Python what script to run. Cheers, Cameron Simpson From cs at cskk.id.au Fri May 3 20:02:30 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 4 May 2019 10:02:30 +1000 Subject: Errorcode when running scripts in PyCharm In-Reply-To: <65bb7b8b-955b-4f76-9e5d-949285987483@googlegroups.com> References: <65bb7b8b-955b-4f76-9e5d-949285987483@googlegroups.com> Message-ID: <20190504000230.GA92671@cskk.homeip.net> Two further things: 1: A keyboard macro of mine mangled my reply. Where I had: http://www.cskk.ezoshosting.com/cs/ you just want "\h", i.e. "C:\Users\hampu\......". Apologies. 2: If your command prompt is already in your "lab4" folder you don't need the full file path. You can just say "your_script.py". Cheers, Cameron Simpson From PythonList at DancesWithMice.info Fri May 3 20:42:00 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Sat, 4 May 2019 12:42:00 +1200 Subject: Populating a timetable with subjects In-Reply-To: <20190503235136.GA37468@cskk.homeip.net> References: <20190503235136.GA37468@cskk.homeip.net> Message-ID: <2bdb9371-4a5d-6570-44c0-c0547fa05323@DancesWithMice.info> On 4/05/19 11:51 AM, Cameron Simpson wrote: > On 01May2019 19:22, brittocj at gmail.com wrote: >> We have to populate a timetable with subjects. What would be the best >> approach? > > That's a pretty open ended question. Often a constraint on generating > timetables involves ensuring that no 2 subjects use the same timeslot if > a student might need to take both those subjects. Unless that student is > Hermoine Grainger. > > Also, this looks like homework: we're happy to help, but we tend not to > write code for you. We'll suggest approaches and answer specific questions. Create Dummy Data in Python Deepanshu Bhalla This article explains various ways to create dummy or random data in Python for practice. Like R, we can create dummy data frames using pandas and numpy packages. Most of the analysts prepare data in MS Excel. Later they import it into Python to hone their data wrangling skills in Python. This is not an efficient approach. The efficient approach is to prepare random data in Python and use it later for data manipulation. Table of Contents Enter Data Manually in Editor Window Read Data from Clipboard Entering Data into Python like SAS Prepare Data using sequence of numeric and character values Generate Random Data Create Categorical Variables Import CSV or Excel File ... https://www.listendata.com/2019/04/create-dummy-data-in-python.html -- Regards =dn From togethercomltd at gmail.com Fri May 3 22:01:36 2019 From: togethercomltd at gmail.com (togethercomltd at gmail.com) Date: Fri, 3 May 2019 19:01:36 -0700 (PDT) Subject: android development Message-ID: <7e733b61-f9a9-4288-8278-e5ad136222db@googlegroups.com> please i want some insight on how to build a file recovery application for android. how do i start aboutit? From heshanfu at gmail.com Sat May 4 00:35:22 2019 From: heshanfu at gmail.com (heshanfu at gmail.com) Date: Fri, 3 May 2019 21:35:22 -0700 (PDT) Subject: A nice collection of often useful awesome Python frameworks Message-ID: <389a31dd-e610-46e3-beac-c08b9d988707@googlegroups.com> A nice collection of often useful awesome Python frameworks, libraries and software. https://pythonawesome.com/ From dieter at handshake.de Sat May 4 02:40:12 2019 From: dieter at handshake.de (dieter) Date: Sat, 04 May 2019 08:40:12 +0200 Subject: Checking network input processing by Python for a multi-threaded server References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> Message-ID: <87v9yqlo37.fsf@handshake.de> Markus Elfring writes: > ... > But I am more interested in the detail that a specific Python list variable > should reflect the received record sets from a single test command > in a consistent way. If you have a multi-threaded application and you want to be on the "safe side", you always use your own locks. Python uses locks to protect its own data structures. Whether this protection is enough for your use of Python types depends on details you may not want to worry about. For example: most operations on Python types are atomic (if they do not involve some kind of "waiting" or "slow operation") *BUT* if they can detroy objects, then arbitrary code (from destructors) can be executed and then they are not atomic. As an example "list.append" is atomic (no object is detroyed), but "list[:] = ..." is not: while the list operation itself is not interrupted by another thread, the operation may destroy objects (the old list components) and other threads may get control before the assignment has finished. From Markus.Elfring at web.de Sat May 4 08:17:52 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Sat, 4 May 2019 14:17:52 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> Message-ID: <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> > Server.shutdown() sets a flag that tells the main server to /stop > accepting new requests/. Can it be that this method should perform a bit more resource management (according to the selected configuration like ?socketserver.ThreadingMixIn?)? > So far as I can tell, for a threaded server, any threads/requests that > were started and haven't completed their handlers will run to completion -- > however long that handler takes to finish the request. Whether > threaded/forked/single-thread -- once a request has been accepted, it will > run to completion. This is good to know and such functionality fits also to my expectations for the software behaviour. > Executing .shutdown() will not kill unfinished handler threads. I got a result like the following from another test variant on a Linux system. elfring at Sonne:~/Projekte/Python> time python3 test-statistic-server2.py incidence|"available records"|"running threads"|"return code"|"command output" 80|6|1|0| 1|4|3|0| 1|4|4|0| 3|5|2|0| 1|5|3|0| 5|7|1|0| 1|3|4|0| 1|8|1|0| 1|4|1|0| 3|5|1|0| 1|4|2|0| 1|3|2|0| 1|6|2|0| real 0m48,373s user 0m6,682s sys 0m1,337s >> How do you think about to improve the distinction for the really >> desired lock granularity in my use case? > > If your request handler updates ANY shared data, YOU have to code the > needed MUTEX locks into that handler. I suggest to increase the precision for such a software requirement. > You may also need to code logic to ensure any handler threads have completed Can a class like ?BaseServer? be responsible for the determination if all extra started threads (or background processes) finished their work as expected? > before your main thread accesses the shared data I became unsure at which point a specific Python list variable will reflect the received record sets from a single test command in a consistent way according to the discussed data processing. > -- that may require a different type of lock; I am curious on corresponding software adjustments. > something that allows multiple threads to hold in parallel > (unfortunately, Event() and Condition() aren't directly suitable) Which data and process management approaches will be needed finally? > Condition() with a global counter (the counter needs its own lock) > might work: handler does something like How much do the programming interfaces from the available classes support the determination that submitted tasks were completely finished? > The may still be a race condition on the last request if it is started > between the .shutdown call and the counter test (ie; the main submits > .shutdown, server starts a thread which doesn't get scheduled yet, > main does the .acquire()s, finds counter is 0 so assumes everything is done, > and THEN the last thread gets scheduled and increments the counter. Should mentioned system constraints be provided already by the Python function (or class) library? Regards, Markus From Markus.Elfring at web.de Sat May 4 08:56:09 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Sat, 4 May 2019 14:56:09 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <87v9yqlo37.fsf@handshake.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <87v9yqlo37.fsf@handshake.de> Message-ID: <4de586a2-48e9-4676-d5bb-852428106ab2@web.de> > If you have a multi-threaded application and you want to be on > the "safe side", you always use your own locks. I suggest to reconsider your software expectations around the word ?always?. There are more software design options available. > Python uses locks to protect its own data structures. > Whether this protection is enough for your use of Python types > depends on details you may not want to worry about. I agree to such a general view. > For example: most operations on Python types are atomic > (if they do not involve some kind of "waiting" or "slow operation") > *BUT* if they can detroy objects, then arbitrary code > (from destructors) can be executed and then they are not atomic. The safe handling of finalizers can trigger development challenges. > As an example "list.append" is atomic (no object is detroyed), > but "list[:] = ..." is not: while the list operation itself > is not interrupted by another thread, the operation may destroy > objects (the old list components) and other threads may get control > before the assignment has finished. How would you determine (with the help of the Python function/class library) that previously submitted tasks were successfully executed? Regards, Markus From Markus.Elfring at web.de Sat May 4 12:56:09 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Sat, 4 May 2019 18:56:09 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> Message-ID: <50fa7cde-4945-5c65-3a32-7e280ae76538@web.de> >>> Server.shutdown() sets a flag that tells the main server to /stop >>> accepting new requests/. >> >> Can it be that this method should perform a bit more resource management >> (according to the selected configuration like ?socketserver.ThreadingMixIn?)? >> > There isn't much more it can do I see further software design possibilities. > -- it has been a long standing axiom that killing threads is not recommended. This data processing approach will trigger various development challenges. >>> You may also need to code logic to ensure any handler threads have completed >> >> Can a class like ?BaseServer? be responsible for the determination >> if all extra started threads (or background processes) finished their work >> as expected? > > You are asking for changes to the Python library for a use case > that is not common. I find this view questionable. > Normally connections to a server are independent and do not share common data Would you like to clarify corresponding application statistics any further? > -- if there is anything in common, Do you identify any more shared functionality? > it is likely stored in a database management system An use case evolved into my need to work also with an ordinary Python list variable for a simple storage interface. > which itself will provide locking for updates, It is nice when you can reuse such software. > and the connection handler will have to be coded to handle retries > if multiple connections try to update the same records. I am not concerned about this aspect for my test case. > Servers aren't meant to be started and shutdown at a rapid rate Their run times can vary considerably. > (it's called "serve_forever" for a reason). Will an other term become more appropriate? > If the socketserver module doesn't provide what you need, It took a while to understand the observed software behaviour better. > you are free to copy socketserver.py to some other file (myserver.py?), > and modify it to fit your needs. Will it help to clarify any software extensions with corresponding maintainers? > Maybe have the function that spawns handler threads append the thread ID > to a list, have the function that cleans up a handler thread at the end > send its ID via a Queue object, This approach can be reasonable to some degree. > and have the master periodically (probably the same loop that checks > for shutdown), read the Queue, and remove the received ID from the list > of active threads. I imagine that there are nicer design options available for notifications according to thread terminations. > On shutdown, you loop reading the Queue and removing IDs from the list > of active threads until the list is empty. Will a condition variable (or a semaphore) be more helpful here? >> How much do the programming interfaces from the available classes support >> the determination that submitted tasks were completely finished? >> > Read the library reference manual and, for those modules with Python > source, the source files (threading.py, socketserver.py, queue.py...) > > The simpler answer is that these modules DON'T... I suggest to improve the software situation a bit more. > It is your responsibility. This view can be partly appropriate. > socketserver threading model is that the main server loops waiting > for connection requests, when it receives a request it creates > a handler thread, and then it completely forgets about the thread I find that this technical detail can be better documented. > -- the thread is independent and completes the handling of the request. Would you occasionally like to wait on the return value from such data processing? (Are these threads joinable?) > If you need to ensure everything has finished before starting > the next server instance, you will have to write the extensions > to socketserver. I might achieve something myself while it can be also nice to achieve adjustments together with other developers. >> Should mentioned system constraints be provided already by the Python >> function (or class) library? > > Again, the model for socketserver, especially in threaded mode, is that > requests being handled are completely independent. shutdown() merely stops > the master from responding to new requests. I find this understanding of the software situation also useful. > In a more normal situation, .shutdown() would be called > and then the entire program would call exit. * Do you expect any more functionality here than an exit from a single thread? * Does this wording include the abortion of threads which were left over? > It is NOT normal for a program to create a server, shut it down, > only to then repeat the sequence. Will your understanding of such an use case grow, too? Regards, Markus From dieter at handshake.de Mon May 6 01:53:34 2019 From: dieter at handshake.de (dieter) Date: Mon, 06 May 2019 07:53:34 +0200 Subject: Checking network input processing by Python for a multi-threaded server References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> Message-ID: <87woj46sdd.fsf@handshake.de> Dennis Lee Bieber writes: > On Sat, 4 May 2019 14:17:52 +0200, Markus Elfring > declaimed the following: > ... > If the socketserver module doesn't provide what you need, you are free > to copy socketserver.py to some other file (myserver.py?), and modify it to > fit your needs. And in addition, you can derive your own class from `socketserver` and override methods to provide whatever additional functionality you think is necessary. From brittocj at gmail.com Mon May 6 01:23:57 2019 From: brittocj at gmail.com (Britto .) Date: Mon, 6 May 2019 10:53:57 +0530 Subject: CAD Application Message-ID: Hello All, What are the frameworks available for developing a CAD application with Python? Regards Britto From blmadhavan at gmail.com Mon May 6 07:27:39 2019 From: blmadhavan at gmail.com (blmadhavan at gmail.com) Date: Mon, 6 May 2019 04:27:39 -0700 (PDT) Subject: How to create a boolean mask for the data arrays with uint16, int8 type? Message-ID: Hi, How can I create a boolean mask for the data arrays with integer type? I want to create a 'useSample' boolean array for masking or discarding the unwanted data from the array. [nr,nc] = np.shape(ftype) # useSamples = np.full((nr,nc), True, dtype=bool) I want to transform the following MATLAB code lines to create the masked array: useSamples(ftype == 3 & subtype ~=2) = false useSamples(cad > -70) = false useSamples(extnQC < 0) = false Finally, I want to extract X variable samples to exclude/ screen out what I don't want (MATLAB expression) X_screened = X(useSamples) Can someone help me how I can transform the above MATLAB lines into Python code? I have the following data arrays with types uint16 and int8. The 8 columns correspond to 8 layers. Number of layers observed is given by 'nlay' variable as shown below. ftype = array([[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [3, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [3, 1, 1, 1, 1, 1, 1, 1], [3, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [3, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [3, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]], dtype=uint16) subtype = array([[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [5, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint16) cad = array([[-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [ -84, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [ -63, -127, -127, -127, -127, -127, -127, -127], [ -72, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [ -38, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [ -70, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127], [-127, -127, -127, -127, -127, -127, -127, -127]], dtype=int8) extnQC = array([[32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [ 18, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [ 18, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [ 0, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [ 0, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [ 18, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768], [32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768]], dtype=uint16) nlay = array([[0], [0], [0], [0], [0], [1], [0], [0], [1], [1], [0], [0], [0], [0], [0], [0], [0], [0], [1], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [1], [0], [0], [0], [0], [0]], dtype=int8) From gherron at digipen.edu Mon May 6 12:27:40 2019 From: gherron at digipen.edu (Gary Herron) Date: Mon, 6 May 2019 09:27:40 -0700 Subject: CAD Application In-Reply-To: References: Message-ID: <5e481e55-21dd-f3d1-ccd3-c6f206484a59@digipen.edu> On 5/5/19 10:23 PM, brittocj at gmail.com wrote: > Hello All, > > What are the frameworks available for developing a CAD application with > Python? > > > Regards > Britto Well, there's PythonCadhttps://sourceforge.net/projects/pythoncad/ It seems to have stopped development about 5 years ago, but it's still available for download. -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From auriocus at gmx.de Mon May 6 14:41:39 2019 From: auriocus at gmx.de (Christian Gollwitzer) Date: Mon, 6 May 2019 20:41:39 +0200 Subject: CAD Application In-Reply-To: References: Message-ID: Am 06.05.19 um 07:23 schrieb Britto .: > What are the frameworks available for developing a CAD application with > Python? For 3D visualization VTK is your best bet. It can efficiently handle large data sets. Christian From sveemani at gmail.com Mon May 6 14:44:59 2019 From: sveemani at gmail.com (sveemani at gmail.com) Date: Mon, 6 May 2019 11:44:59 -0700 (PDT) Subject: Using a Variable Inside the String Message-ID: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> Hi all, I am new learner of python programming and I am into my basics. I got struck with the code in a sample program and refer the same with IDE and googling which did not help me for more than a day. What is wrong with my last 2 lines? what I am missing? ################## my_name = 'Veera' my_age = 40 # Actually 42 my_height = 155 # Inches my_weight = "80" # checking the double quotes my_eyes = 'brown' my_teeth = 'white' my_hair = 'black' print(f"Let's talk about {my_name}.") print(f"He's {my_height} inches tall.") print(f"He's {my_weight} weight heavy.") print("Actually thats not too Heavy.") print(f"He's got {my_eyes} eyes and {my_hair} hair.") print(f"His teeth are actually {my_teeth} depending on the coffee.") ### this line are where I Struck ##### total = my_age + my_height + my_weight print(f"If I add {my_age}, {my_height}, and {my_weight} I get {total} .") ########################## From rosuav at gmail.com Mon May 6 14:51:37 2019 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 7 May 2019 04:51:37 +1000 Subject: Using a Variable Inside the String In-Reply-To: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> References: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> Message-ID: On Tue, May 7, 2019 at 4:50 AM wrote: > > Hi all, > > I am new learner of python programming and I am into my basics. > I got struck with the code in a sample program and refer the same with IDE and googling which did not help me for more than a day. > > What is wrong with my last 2 lines? > what I am missing? > > ################## > my_weight = "80" # checking the double quotes What does this mean? Especially, what does the comment mean? ChrisA From brian.j.oney at googlemail.com Mon May 6 15:35:12 2019 From: brian.j.oney at googlemail.com (Brian Oney) Date: Mon, 06 May 2019 21:35:12 +0200 Subject: CAD Application In-Reply-To: <5e481e55-21dd-f3d1-ccd3-c6f206484a59@digipen.edu> References: <5e481e55-21dd-f3d1-ccd3-c6f206484a59@digipen.edu> Message-ID: FreeCAD is written in Python. It has a python interpreter. From python at mrabarnett.plus.com Mon May 6 15:46:10 2019 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 6 May 2019 20:46:10 +0100 Subject: Using a Variable Inside the String In-Reply-To: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> References: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> Message-ID: <530f27a9-12aa-5e1c-4c5c-4fad666c285c@mrabarnett.plus.com> On 2019-05-06 19:44, sveemani at gmail.com wrote: > Hi all, > > I am new learner of python programming and I am into my basics. > I got struck with the code in a sample program and refer the same with IDE and googling which did not help me for more than a day. > > What is wrong with my last 2 lines? > what I am missing? > > ################## > my_name = 'Veera' > my_age = 40 # Actually 42 > my_height = 155 # Inches > my_weight = "80" # checking the double quotes > my_eyes = 'brown' > my_teeth = 'white' > my_hair = 'black' > > print(f"Let's talk about {my_name}.") > print(f"He's {my_height} inches tall.") > print(f"He's {my_weight} weight heavy.") > print("Actually thats not too Heavy.") > > print(f"He's got {my_eyes} eyes and {my_hair} hair.") > print(f"His teeth are actually {my_teeth} depending on the coffee.") > > > ### this line are where I Struck ##### 'my_age' and 'my_height' are numbers, but 'my_weight' is a string (why?). You can't add a number and a string together. > total = my_age + my_height + my_weight > print(f"If I add {my_age}, {my_height}, and {my_weight} I get {total} .") > > ########################## > From mal at europython.eu Tue May 7 03:46:35 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Tue, 7 May 2019 09:46:35 +0200 Subject: EuroPython 2019: Call for Sponsors Message-ID: <4af6e204-b204-dc65-ac6f-b80243cf4a13@europython.eu> Reach out to many enthusiastic Python developers, users and professionals in Basel this July ! Sponsoring EuroPython guarantees you highly targeted visibility and the opportunity to present yourself and your company in a professional and innovative environment. Also, as a sponsor of EuroPython 2019, you will directly help promote the work of a great open-source community which is becoming a powerhouse of technological development and innovation. Want to know more ? ------------------- Head over to the sponsor packages page and feel free to contact us directly with any questions at sponsoring at europython.eu * https://ep2019.europython.eu/sponsor/packages/ * Special offer for early bird sponsors ------------------------------------- Sponsors who sign up before or on May 17, will receive a special 10% discount on the sponsor package price. Become a sponsor and support EuroPython 2019 today ! Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/184708887222/europython-2019-call-for-sponsors Tweet: https://twitter.com/europython/status/1125664489469370368 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From sveemani at gmail.com Tue May 7 10:53:53 2019 From: sveemani at gmail.com (sveemani at gmail.com) Date: Tue, 7 May 2019 07:53:53 -0700 (PDT) Subject: Using a Variable Inside the String In-Reply-To: References: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> Message-ID: <9720b77d-2c98-468d-b29e-dde8e1eef9ac@googlegroups.com> On Tuesday, May 7, 2019 at 12:22:06 AM UTC+5:30, Chris Angelico wrote: > On Tue, May 7, 2019 at 4:50 AM wrote: > > > > Hi all, > > > > I am new learner of python programming and I am into my basics. > > I got struck with the code in a sample program and refer the same with IDE and googling which did not help me for more than a day. > > > > What is wrong with my last 2 lines? > > what I am missing? > > > > ################## > > my_weight = "80" # checking the double quotes > > What does this mean? Especially, what does the comment mean? > > ChrisA Please ignore my comment. I am learning to code and I am practicing myself to add a comment for my reference. Thanks for understanding .. From lukasz at langa.pl Tue May 7 10:58:27 2019 From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=) Date: Tue, 7 May 2019 10:58:27 -0400 Subject: [RELEASE] Python 3.8.0a4 is now available for testing Message-ID: <27210321-6B27-4629-9643-2A64F62DA85D@langa.pl> It's time for the LAST alpha of Python 3.8.0. Go get it here: https://www.python.org/downloads/release/python-380a4/ Python 3.8.0a4 is the fourth and final alpha release of Python 3.8, the next feature release of Python. During the alpha phase, Python 3.8 remains under heavy development: additional features will be added and existing features may be modified or deleted. Please keep in mind that this is a preview release and its use is not recommended for production environments. The first beta release, 3.8.0b1, is planned for 2019-05-31. The release has slipped a week because of me being overwhelmed with PyCon US this year. There was also a release blocker and a breaking change to ElementTree. Anyway, sorry for the wait! I moved the planned date of beta1 a few days to make up for it. If you have a feature you're working on and you'd like to see it in 3.8.0, NOW IS THE TIME TO ACT. Please don't wait until May 30th, get a proper review and land your change as soon as possible. Q: Can I get my feature in after that date if I ask nicely? A: Yes, of course. I will release it in Python 3.9. - ? -------------- 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 sveemani at gmail.com Tue May 7 10:55:37 2019 From: sveemani at gmail.com (sveemani at gmail.com) Date: Tue, 7 May 2019 07:55:37 -0700 (PDT) Subject: Using a Variable Inside the String In-Reply-To: References: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> <530f27a9-12aa-5e1c-4c5c-4fad666c285c@mrabarnett.plus.com> Message-ID: On Tuesday, May 7, 2019 at 1:20:49 AM UTC+5:30, MRAB wrote: > On 2019-05-06 19:44, sveemani at gmail.com wrote: > > Hi all, > > > > I am new learner of python programming and I am into my basics. > > I got struck with the code in a sample program and refer the same with IDE and googling which did not help me for more than a day. > > > > What is wrong with my last 2 lines? > > what I am missing? > > > > ################## > > my_name = 'Veera' > > my_age = 40 # Actually 42 > > my_height = 155 # Inches > > my_weight = "80" # checking the double quotes > > my_eyes = 'brown' > > my_teeth = 'white' > > my_hair = 'black' > > > > print(f"Let's talk about {my_name}.") > > print(f"He's {my_height} inches tall.") > > print(f"He's {my_weight} weight heavy.") > > print("Actually thats not too Heavy.") > > > > print(f"He's got {my_eyes} eyes and {my_hair} hair.") > > print(f"His teeth are actually {my_teeth} depending on the coffee.") > > > > > > ### this line are where I Struck ##### > > 'my_age' and 'my_height' are numbers, but 'my_weight' is a string > (why?). You can't add a number and a string together. > > > total = my_age + my_height + my_weight > > print(f"If I add {my_age}, {my_height}, and {my_weight} I get {total} .") > > > > ########################## > > Thanks . It worked . Will have to read more on strings to get the exact total value.. From rgaddi at highlandtechnology.invalid Tue May 7 12:43:18 2019 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Tue, 7 May 2019 09:43:18 -0700 Subject: Using a Variable Inside the String In-Reply-To: References: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> <530f27a9-12aa-5e1c-4c5c-4fad666c285c@mrabarnett.plus.com> Message-ID: On 5/7/19 7:55 AM, sveemani at gmail.com wrote: > On Tuesday, May 7, 2019 at 1:20:49 AM UTC+5:30, MRAB wrote: >> On 2019-05-06 19:44, sveemani at gmail.com wrote: >>> Hi all, >>> >>> I am new learner of python programming and I am into my basics. >>> I got struck with the code in a sample program and refer the same with IDE and googling which did not help me for more than a day. >>> >>> What is wrong with my last 2 lines? >>> what I am missing? >>> >>> ################## >>> my_name = 'Veera' >>> my_age = 40 # Actually 42 >>> my_height = 155 # Inches >>> my_weight = "80" # checking the double quotes >>> my_eyes = 'brown' >>> my_teeth = 'white' >>> my_hair = 'black' >>> >>> print(f"Let's talk about {my_name}.") >>> print(f"He's {my_height} inches tall.") >>> print(f"He's {my_weight} weight heavy.") >>> print("Actually thats not too Heavy.") >>> >>> print(f"He's got {my_eyes} eyes and {my_hair} hair.") >>> print(f"His teeth are actually {my_teeth} depending on the coffee.") >>> >>> >>> ### this line are where I Struck ##### >> >> 'my_age' and 'my_height' are numbers, but 'my_weight' is a string >> (why?). You can't add a number and a string together. >> >>> total = my_age + my_height + my_weight >>> print(f"If I add {my_age}, {my_height}, and {my_weight} I get {total} .") >>> >>> ########################## >>> > > > Thanks . It worked . > Will have to read more on strings to get the exact total value.. > The comment can't be ignored because it's sitting there flagging your problem. Strings (in single or double quote) are strings; a sequence of characters as used to write words. Numbers are numbers. You can't add them together. This over here is my friend Bob. What's 31 + 18 + Bob? The question makes no sense, because the operation of addition isn't defined in such a way that allows you to add numbers to human beings. You can't add them to strings either. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From sveemani at gmail.com Tue May 7 13:34:21 2019 From: sveemani at gmail.com (sveemani at gmail.com) Date: Tue, 7 May 2019 10:34:21 -0700 (PDT) Subject: Using a Variable Inside the String In-Reply-To: References: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> <530f27a9-12aa-5e1c-4c5c-4fad666c285c@mrabarnett.plus.com> Message-ID: <72a30e27-75f4-4160-8c74-f68a2287d2a7@googlegroups.com> On Tuesday, May 7, 2019 at 10:13:42 PM UTC+5:30, Rob Gaddi wrote: > On 5/7/19 7:55 AM, sveemani at gmail.com wrote: > > On Tuesday, May 7, 2019 at 1:20:49 AM UTC+5:30, MRAB wrote: > >> On 2019-05-06 19:44, sveemani at gmail.com wrote: > >>> Hi all, > >>> > >>> I am new learner of python programming and I am into my basics. > >>> I got struck with the code in a sample program and refer the same with IDE and googling which did not help me for more than a day. > >>> > >>> What is wrong with my last 2 lines? > >>> what I am missing? > >>> > >>> ################## > >>> my_name = 'Veera' > >>> my_age = 40 # Actually 42 > >>> my_height = 155 # Inches > >>> my_weight = "80" # checking the double quotes > >>> my_eyes = 'brown' > >>> my_teeth = 'white' > >>> my_hair = 'black' > >>> > >>> print(f"Let's talk about {my_name}.") > >>> print(f"He's {my_height} inches tall.") > >>> print(f"He's {my_weight} weight heavy.") > >>> print("Actually thats not too Heavy.") > >>> > >>> print(f"He's got {my_eyes} eyes and {my_hair} hair.") > >>> print(f"His teeth are actually {my_teeth} depending on the coffee.") > >>> > >>> > >>> ### this line are where I Struck ##### > >> > >> 'my_age' and 'my_height' are numbers, but 'my_weight' is a string > >> (why?). You can't add a number and a string together. > >> > >>> total = my_age + my_height + my_weight > >>> print(f"If I add {my_age}, {my_height}, and {my_weight} I get {total} .") > >>> > >>> ########################## > >>> > > > > > > Thanks . It worked . > > Will have to read more on strings to get the exact total value.. > > > > The comment can't be ignored because it's sitting there flagging your > problem. Strings (in single or double quote) are strings; a sequence of > characters as used to write words. Numbers are numbers. You can't add > them together. > > This over here is my friend Bob. What's 31 + 18 + Bob? The question > makes no sense, because the operation of addition isn't defined in such > a way that allows you to add numbers to human beings. You can't add > them to strings either. > > -- > Rob Gaddi, Highland Technology -- www.highlandtechnology.com > Email address domain is currently out of order. See above to fix. ### Thanks for your Inputs. Its a self Exercise for learning of string .and I realized the error, when I got the output of total as 4015580. Then I insert the age and height into strings"" in declaring , so that the total is as expected. From * at eli.users.panix.com Tue May 7 14:29:52 2019 From: * at eli.users.panix.com (Eli the Bearded) Date: Tue, 7 May 2019 18:29:52 +0000 (UTC) Subject: Conway's game of Life, just because. References: <87ef5buehn.fsf@nightsong.com> Message-ID: In comp.lang.python, Paul Rubin wrote: Thanks for posting this. I'm learning python and am very familiar with this "game". > #!/usr/bin/python3 > from itertools import chain > > def adjacents(cell): # generate coordinates of cell neighbors > x, y = cell # a cell is just an x,y coordinate pair > return ((x+i,y+j) for i in [-1,0,1] for j in [-1,0,1] if i or j) This line confuses me. How do you expect "if i or j" to work there? >>> for pair in adjacents((0,0)): ... print(pair) ... (-1, -1) (-1, 0) (-1, 1) (0, -1) (0, 1) (1, -1) (1, 0) (1, 1) >>> def neighboring(cell): ... x, y = cell ... return ((x+i,y+j) for i in [-1,0,1] for j in [-1,0,1]) ... >>> >>> for pair in neighboring((0,0)): ... print(pair) ... (-1, -1) (-1, 0) (-1, 1) (0, -1) (0, 0) (0, 1) (1, -1) (1, 0) (1, 1) >>> Elijah ------ is the torus game board unintentional? From rosuav at gmail.com Tue May 7 14:35:45 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 May 2019 04:35:45 +1000 Subject: Conway's game of Life, just because. In-Reply-To: References: <87ef5buehn.fsf@nightsong.com> Message-ID: On Wed, May 8, 2019 at 4:31 AM Eli the Bearded <*@eli.users.panix.com> wrote: > > In comp.lang.python, Paul Rubin wrote: > > Thanks for posting this. I'm learning python and am very familiar with > this "game". > > > #!/usr/bin/python3 > > from itertools import chain > > > > def adjacents(cell): # generate coordinates of cell neighbors > > x, y = cell # a cell is just an x,y coordinate pair > > return ((x+i,y+j) for i in [-1,0,1] for j in [-1,0,1] if i or j) > > This line confuses me. How do you expect "if i or j" to work there? It means that if either i or j has a non-zero value, this will yield something. With three possible values for i and three for j, it would normally create nine results; but that condition means it will create eight, skipping the (0, 0) option. Since the function is meant to give you all the neighbors of a cell, it makes sense that it shouldn't return the cell itself. ChrisA From python at mrabarnett.plus.com Tue May 7 14:54:03 2019 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 7 May 2019 19:54:03 +0100 Subject: Conway's game of Life, just because. In-Reply-To: References: <87ef5buehn.fsf@nightsong.com> Message-ID: <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> On 2019-05-07 19:29, Eli the Bearded wrote: > In comp.lang.python, Paul Rubin wrote: > > Thanks for posting this. I'm learning python and am very familiar with > this "game". > >> #!/usr/bin/python3 >> from itertools import chain >> >> def adjacents(cell): # generate coordinates of cell neighbors >> x, y = cell # a cell is just an x,y coordinate pair >> return ((x+i,y+j) for i in [-1,0,1] for j in [-1,0,1] if i or j) > [snip] > > Elijah > ------ > is the torus game board unintentional? > I've never seen a version of Conway's Game of Life where the board doesn't wrap around. From rosuav at gmail.com Tue May 7 16:47:42 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 May 2019 06:47:42 +1000 Subject: Change in cache tag in Python 3.8 - pip confused Message-ID: I've been building Python 3.8 pre-alphas and alphas for a while now, and ran into a weird problem. Not sure if this is significant or not, and hoping to get other people's views. It seems that the value of sys.implementation.cache_tag changed from "cpython-38m" to just "cpython-38" at some point. That means that a statement like "import lzo" will no longer find a file called "lzo.cpython-38m-x86_64-linux-gnu.so", which I had had prior to the change. The trouble is, pip *did* recognize that file, and said that the python-lzo package was still installed. Solution: "pip uninstall python-lzo" and then reinstall it. Now it's created "lzo.cpython-38-x86_64-linux-gnu.so" and all is well. Does anyone else know about how pip detects existing files, and whether it could be brought more in sync with the import machinery? ChrisA From * at eli.users.panix.com Tue May 7 15:09:56 2019 From: * at eli.users.panix.com (Eli the Bearded) Date: Tue, 7 May 2019 19:09:56 +0000 (UTC) Subject: Conway's game of Life, just because. References: <87ef5buehn.fsf@nightsong.com> <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> Message-ID: In comp.lang.python, MRAB wrote: > I've never seen a version of Conway's Game of Life where the board > doesn't wrap around. The one I wrote in vi macros doesn't. It's a design choice you can make. (Thanks for the explainations everyone.) Elijah ------ the vi macro one is included in the vim macros directory From p.f.moore at gmail.com Tue May 7 17:12:51 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 7 May 2019 22:12:51 +0100 Subject: Change in cache tag in Python 3.8 - pip confused In-Reply-To: References: Message-ID: On Tue, 7 May 2019 at 21:53, Chris Angelico wrote: > > I've been building Python 3.8 pre-alphas and alphas for a while now, > and ran into a weird problem. Not sure if this is significant or not, > and hoping to get other people's views. > > It seems that the value of sys.implementation.cache_tag changed from > "cpython-38m" to just "cpython-38" at some point. That means that a > statement like "import lzo" will no longer find a file called > "lzo.cpython-38m-x86_64-linux-gnu.so", which I had had prior to the > change. The trouble is, pip *did* recognize that file, and said that > the python-lzo package was still installed. > > Solution: "pip uninstall python-lzo" and then reinstall it. Now it's > created "lzo.cpython-38-x86_64-linux-gnu.so" and all is well. > > Does anyone else know about how pip detects existing files, and > whether it could be brought more in sync with the import machinery? I don't know if this is what you were after, but pip decides if a project FOO is installed by looking for the FOO-X.Y.Z.dist-info directory in site-packages. The RECORD file in that directory contains a list of all files installed when the package was originally installed (that's what pip uses to decide what to uninstall). Paul From rosuav at gmail.com Tue May 7 17:23:45 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 May 2019 07:23:45 +1000 Subject: Change in cache tag in Python 3.8 - pip confused In-Reply-To: References: Message-ID: On Wed, May 8, 2019 at 7:13 AM Paul Moore wrote: > > On Tue, 7 May 2019 at 21:53, Chris Angelico wrote: > > > > I've been building Python 3.8 pre-alphas and alphas for a while now, > > and ran into a weird problem. Not sure if this is significant or not, > > and hoping to get other people's views. > > > > It seems that the value of sys.implementation.cache_tag changed from > > "cpython-38m" to just "cpython-38" at some point. That means that a > > statement like "import lzo" will no longer find a file called > > "lzo.cpython-38m-x86_64-linux-gnu.so", which I had had prior to the > > change. The trouble is, pip *did* recognize that file, and said that > > the python-lzo package was still installed. > > > > Solution: "pip uninstall python-lzo" and then reinstall it. Now it's > > created "lzo.cpython-38-x86_64-linux-gnu.so" and all is well. > > > > Does anyone else know about how pip detects existing files, and > > whether it could be brought more in sync with the import machinery? > > I don't know if this is what you were after, but pip decides if a > project FOO is installed by looking for the FOO-X.Y.Z.dist-info > directory in site-packages. The RECORD file in that directory contains > a list of all files installed when the package was originally > installed (that's what pip uses to decide what to uninstall). > > Paul Ah ha, thank you. That is indeed helpful. So the next question is: Is this actually a problem? If it's something that can only ever happen to people who build prerelease Pythons, it's probably not an issue. Is there any way that a regular installation of Python could ever change its cache_tag? What I experienced would be extremely confusing if it ever happened live ("but it IS installed, no it ISN'T installed..."). When pip installed python-lzo from source, it must have constructed the file name somehow. I've tried digging through pip's sources, but searching for "cache_tag" came up blank, and I'm not sure where it actually figures out what name to save the .so file under. There's a lot of code in pip, though, and I freely admit to having gotten quite lost in the weeds :| ChrisA From p.f.moore at gmail.com Tue May 7 18:09:10 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 7 May 2019 23:09:10 +0100 Subject: Change in cache tag in Python 3.8 - pip confused In-Reply-To: References: Message-ID: On Tue, 7 May 2019 at 22:26, Chris Angelico wrote: > So the next question is: Is this actually a problem? If it's something > that can only ever happen to people who build prerelease Pythons, it's > probably not an issue. Is there any way that a regular installation of > Python could ever change its cache_tag? What I experienced would be > extremely confusing if it ever happened live ("but it IS installed, no > it ISN'T installed..."). I'm probably not the person to answer, because I know *way* to much about how pip works to judge what's confusing :-) However, I'd say that: 1. It's mostly about what core Python/distutils does (compiled module names, and cache tags, are core language things - see PEP 3147 for the details).. 2. In a normal release, Python wouldn't break compatibility like this, so this would be a non-issue in a standard x.y.z Python release. 3. Python doesn't guarantee ABI compatibility across minor releases, and the site-packages locations would normally be different anyway (I know they are on Windows, and I assume they would be on Unix) so you won't have this issue in anything other than X.Y.Z and X.Y.W (where W != Z). I'd normally recommend reinstalling everything when changing a point release too, but I know not everyone does that. ABI compatibility between point releases is maintained, though, so it shouldn't be a problem. Short answer, it's only ever going to be a problem for people building their own Python from git, and they are probably going to know enough to debug the issue themselves (even if, like you, they find it hard to work out what happened...) > When pip installed python-lzo from source, it must have constructed > the file name somehow. I've tried digging through pip's sources, but > searching for "cache_tag" came up blank, and I'm not sure where it > actually figures out what name to save the .so file under. There's a > lot of code in pip, though, and I freely admit to having gotten quite > lost in the weeds :| The build is done in distutils (or maybe, setuptools) so that's where you should probably look. Pip just gets a bunch of files from setuptools, and installs them, at least for up to date projects and versions of pip - it's the "PEP 517" behaviour if you're into recent packaging standards. For older pip versions, or projects not updated to recent standards, pip just says "hey, setuptools, install this stuff and tell me the names of all the files you created". Good luck digging into the setuptools/distutils code - take rations, torches and emergency flares, it's dangerous in there :-) Paul From rosuav at gmail.com Tue May 7 19:26:18 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 May 2019 09:26:18 +1000 Subject: Change in cache tag in Python 3.8 - pip confused In-Reply-To: References: Message-ID: On Wed, May 8, 2019 at 8:09 AM Paul Moore wrote: > > On Tue, 7 May 2019 at 22:26, Chris Angelico wrote: > > So the next question is: Is this actually a problem? If it's something > > that can only ever happen to people who build prerelease Pythons, it's > > probably not an issue. Is there any way that a regular installation of > > Python could ever change its cache_tag? What I experienced would be > > extremely confusing if it ever happened live ("but it IS installed, no > > it ISN'T installed..."). > > I'm probably not the person to answer, because I know *way* to much > about how pip works to judge what's confusing :-) > > However, I'd say that: > > 2. In a normal release, Python wouldn't break compatibility like this, > so this would be a non-issue in a standard x.y.z Python release. Good. > 3. Python doesn't guarantee ABI compatibility across minor releases, > and the site-packages locations would normally be different anyway (I > know they are on Windows, and I assume they would be on Unix) so you > won't have this issue in anything other than X.Y.Z and X.Y.W (where W > != Z). I'd normally recommend reinstalling everything when changing a > point release too, but I know not everyone does that. ABI > compatibility between point releases is maintained, though, so it > shouldn't be a problem. Yeah, also good. (My personal policy isn't to reinstall everything, but simply to leave the old packages behind and then install things as I have need, but same diff.) > Short answer, it's only ever going to be a problem for people building > their own Python from git, and they are probably going to know enough > to debug the issue themselves (even if, like you, they find it hard to > work out what happened...) Cool. Good to know. > > When pip installed python-lzo from source, it must have constructed > > the file name somehow. I've tried digging through pip's sources, but > > searching for "cache_tag" came up blank, and I'm not sure where it > > actually figures out what name to save the .so file under. There's a > > lot of code in pip, though, and I freely admit to having gotten quite > > lost in the weeds :| > > The build is done in distutils (or maybe, setuptools) so that's where > you should probably look. Pip just gets a bunch of files from > setuptools, and installs them, at least for up to date projects and > versions of pip - it's the "PEP 517" behaviour if you're into recent > packaging standards. For older pip versions, or projects not updated > to recent standards, pip just says "hey, setuptools, install this > stuff and tell me the names of all the files you created". > > Good luck digging into the setuptools/distutils code - take rations, > torches and emergency flares, it's dangerous in there :-) Eww. Well, that explains why search-across-files for "cache_tag" didn't come up with anything, but I think... at this point... I don't need to know any more. Many thanks for your information. I'll pass on exploring distutils! ChrisA From ian.g.kelly at gmail.com Tue May 7 21:33:26 2019 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 7 May 2019 19:33:26 -0600 Subject: Conway's game of Life, just because. In-Reply-To: <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> References: <87ef5buehn.fsf@nightsong.com> <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> Message-ID: On Tue, May 7, 2019 at 1:00 PM MRAB wrote: > > On 2019-05-07 19:29, Eli the Bearded wrote: > > In comp.lang.python, Paul Rubin wrote: > > > > Thanks for posting this. I'm learning python and am very familiar with > > this "game". > > > >> #!/usr/bin/python3 > >> from itertools import chain > >> > >> def adjacents(cell): # generate coordinates of cell neighbors > >> x, y = cell # a cell is just an x,y coordinate pair > >> return ((x+i,y+j) for i in [-1,0,1] for j in [-1,0,1] if i or j) > > > [snip] > > > > Elijah > > ------ > > is the torus game board unintentional? > > > I've never seen a version of Conway's Game of Life where the board > doesn't wrap around. I don't think I've ever seen one where it does. From simon.michnowicz at monash.edu Tue May 7 21:18:21 2019 From: simon.michnowicz at monash.edu (Simon Michnowicz) Date: Wed, 8 May 2019 11:18:21 +1000 Subject: Building a statically linked Python, and pip Message-ID: Dear Group, I need to build a statically linked Python that has pip. I built a version following the instructions at https://wiki.python.org/moin/BuildStatically but pip was not present in the binary directory afterwards. I downloaded get-pip.py but when I tried to install it I get an error message /usr/local/python/3.7.3-static/bin/python3 get-pip.py Traceback (most recent call last): File "get-pip.py", line 21361, in main() File "get-pip.py", line 197, in main bootstrap(tmpdir=tmpdir) File "get-pip.py", line 82, in bootstrap import pip._internal File "/tmp/tmp8gvwywom/pip.zip/pip/_internal/__init__.py", line 19, in File "/tmp/tmp8gvwywom/pip.zip/pip/_vendor/urllib3/__init__.py", line 8, in File "/tmp/tmp8gvwywom/pip.zip/pip/_vendor/urllib3/connectionpool.py", line 28, in File "/tmp/tmp8gvwywom/pip.zip/pip/_vendor/urllib3/packages/six.py", line 92, in __get__ File "/tmp/tmp8gvwywom/pip.zip/pip/_vendor/urllib3/packages/six.py", line 115, in _resolve File "/tmp/tmp8gvwywom/pip.zip/pip/_vendor/urllib3/packages/six.py", line 82, in _import_module File "/usr/local/python/3.7.3-static/lib/python3.7/queue.py", line 16, in from _queue import Empty ModuleNotFoundError: No module named '_queue' I also tried this with a Python2, but got a similar but different message ImportError: No module named _ctypes Is there a way to install pip with a statically built Python? I enabled as many modules as possible in Modules/Setup.local but I could not see any thing for _queue thanks for any help *---Simon Michnowicz * Senior Application Specialist, High-Performance Computing *Research Support Services - eSolutions* *Monash eResearch Centre* Monash University 15 Innovation Walk, Building 75, Clayton Campus Wellington Road, VIC 3800 Australia T: +61 3 9902 0794 M: +61 3 0418 302 046 E: simon.michnowicz at monash.edu monash.edu From Richard at Damon-Family.org Tue May 7 22:36:33 2019 From: Richard at Damon-Family.org (Richard Damon) Date: Tue, 7 May 2019 22:36:33 -0400 Subject: Conway's game of Life, just because. In-Reply-To: References: <87ef5buehn.fsf@nightsong.com> <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> Message-ID: <43925af0-ae26-1232-fccc-778355093830@Damon-Family.org> On 5/7/19 9:33 PM, Ian Kelly wrote: > On Tue, May 7, 2019 at 1:00 PM MRAB wrote: >> On 2019-05-07 19:29, Eli the Bearded wrote: >>> In comp.lang.python, Paul Rubin wrote: >>> >>> Elijah >>> ------ >>> is the torus game board unintentional? >>> >> I've never seen a version of Conway's Game of Life where the board >> doesn't wrap around. > I don't think I've ever seen one where it does. My experience is that the wrap around is common, as otherwise the hard edge causes a discontinuity in the rules at the edge, so any pattern that reaches the edge no longer has a valid result. The torus effect still perturbs the result, but that perturbation is effectively that the universe was tiled with an infinite grid of the starting pattern, so represents a possible universe. -- Richard Damon From mal at europython.eu Wed May 8 03:24:03 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Wed, 8 May 2019 09:24:03 +0200 Subject: EuroPython 2019: Early-bird ticket sales Message-ID: <8f4fc020-582d-5aeb-f5db-684fb45533d9@europython.eu> As in the last few years, we will again have early-bird ticket sales for the conference. We plan to open early bird ticket sales on Monday, May 13th at 12:00 CEST. This year, we will have 200 early-bird tickets available when we open up ticket sales. They offer a discount of up to 50% over the standard rate and are usually sold out within a few hours. In 2018 early bird tickets were sold out in just 45 minutes. Early-Bird Conference Tickets ----------------------------- We have the following three categories of early-bird rate ticket prices for the full conference tickets (Beginners? Day workshop, 3 conference days, sprints): * Business conference ticket: EUR 395.00 excl. VAT, EUR 425.42 incl. 7.7% Swiss VAT (for people using Python to make a living) * Personal conference ticket: EUR 265.00 incl. 7.7% Swiss VAT (for people enjoying Python from home) * Student conference ticket: EUR 95.00 incl. 7.7% Swiss VAT (only available for pupils, students and postdoctoral researchers; please bring your student card or declaration from University, stating your affiliation, starting and end dates of your contract) Please note that access to trainings is not included in the early-bird conference ticket price. We will have separate ?Training passes? for this, later in May. We would like to encourage and trust you, to pick a ticket type that reasonably fits your personal situation. For more details, please see the registration page: https://ep2019.europython.eu/registration/buy-tickets/ Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/184731612382/europython-2019-early-bird-ticket-sales Tweet: https://twitter.com/europython/status/1126023879212896256 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From tjol at tjol.eu Wed May 8 02:54:52 2019 From: tjol at tjol.eu (Thomas Jollans) Date: Wed, 8 May 2019 08:54:52 +0200 Subject: Building a statically linked Python, and pip In-Reply-To: References: Message-ID: <49ad0339-873c-7817-83f2-aa40c45f44a0@tjol.eu> On 08/05/2019 03:18, Simon Michnowicz via Python-list wrote: > Dear Group, > I need to build a statically linked Python that has pip. What a curious thing to need. > I built a version following the instructions at > https://wiki.python.org/moin/BuildStatically > but pip was not present in the binary directory afterwards. > > [...] > > ModuleNotFoundError: No module named '_queue' > As the wiki instructions point out, if you want standard library modules written in C (such as _queue), you have to set them up to be built inside your binary. So you'll have to figure out which modules you need for what you're doing and how to include them in your build. From p.f.moore at gmail.com Wed May 8 04:26:08 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 8 May 2019 09:26:08 +0100 Subject: Conway's game of Life, just because. In-Reply-To: <43925af0-ae26-1232-fccc-778355093830@Damon-Family.org> References: <87ef5buehn.fsf@nightsong.com> <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> <43925af0-ae26-1232-fccc-778355093830@Damon-Family.org> Message-ID: On Wed, 8 May 2019 at 03:39, Richard Damon wrote: > My experience is that the wrap around is common, as otherwise the hard > edge causes a discontinuity in the rules at the edge, so any pattern > that reaches the edge no longer has a valid result. The torus effect > still perturbs the result, but that perturbation is effectively that the > universe was tiled with an infinite grid of the starting pattern, so > represents a possible universe. In my experience, "simple" implementations that use a fixed array often wrap around because the inaccuracies (compared to the correct infinite-area result) are less disruptive for simple examples. But more full-featured implementations that I've seen don't have a fixed size. I assume they don't use a simple array as their data model, but rather use something more complex, probably something that's O(number of live cells) rather than something that's O(maximum co-ordinate value ** 2). Paul From brittocj at gmail.com Wed May 8 06:59:10 2019 From: brittocj at gmail.com (Britto .) Date: Wed, 8 May 2019 16:29:10 +0530 Subject: CAD Application In-Reply-To: References: Message-ID: What about PythonOCC, Pandas3D, FreeCAD etc.? Regards Britto On Tue, 7 May 2019 at 00:18, Christian Gollwitzer wrote: > Am 06.05.19 um 07:23 schrieb Britto .: > > What are the frameworks available for developing a CAD application with > > Python? > > For 3D visualization VTK is your best bet. It can efficiently handle > large data sets. > > Christian > -- > https://mail.python.org/mailman/listinfo/python-list > From sinbad.sinbad at gmail.com Wed May 8 07:19:15 2019 From: sinbad.sinbad at gmail.com (sinbad.sinbad at gmail.com) Date: Wed, 8 May 2019 04:19:15 -0700 (PDT) Subject: how is the readline set_completer function suppose to work Message-ID: Below i was expecting the test() function to be called, but it doesn't. Am i doing it wrong? By the way i'm running version 2.7.10 on a mac. $python >>> import readline >>> def test(): ... print("test") ... >>> test() test >>> print(help(readline)) None >>> readline.set_completer(test) >>> raw_input() '\t\t\t' >>> From Richard at Damon-Family.org Wed May 8 07:35:39 2019 From: Richard at Damon-Family.org (Richard Damon) Date: Wed, 8 May 2019 07:35:39 -0400 Subject: Conway's game of Life, just because. In-Reply-To: References: <87ef5buehn.fsf@nightsong.com> <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> <43925af0-ae26-1232-fccc-778355093830@Damon-Family.org> Message-ID: On 5/8/19 4:26 AM, Paul Moore wrote: > On Wed, 8 May 2019 at 03:39, Richard Damon wrote: >> My experience is that the wrap around is common, as otherwise the hard >> edge causes a discontinuity in the rules at the edge, so any pattern >> that reaches the edge no longer has a valid result. The torus effect >> still perturbs the result, but that perturbation is effectively that the >> universe was tiled with an infinite grid of the starting pattern, so >> represents a possible universe. > In my experience, "simple" implementations that use a fixed array > often wrap around because the inaccuracies (compared to the correct > infinite-area result) are less disruptive for simple examples. But > more full-featured implementations that I've seen don't have a fixed > size. I assume they don't use a simple array as their data model, but > rather use something more complex, probably something that's O(number > of live cells) rather than something that's O(maximum co-ordinate > value ** 2). > > Paul > An implementation that creates an infinite grid to work on doesn't need to worry about what happens on the 'edge' as there isn't one. I suspect an implementation that makes an effectively infinite grid might not either, though may include code to try and keep the pattern roughly 'centered' to keep away from the dragons at the edge. If, like likely with a 'high efficiency' language with fixed sized integers, the coordinates wrap around (max_int + 1 => min_int) then it naturally still is a torus, though processing that case may add complexity to keep the computation of a typical cell O(1). You might end up with numbers becoming floating point, where some_big_number +1 -> the same some_big_number that would lead to issues with the stability of the data structure, so maybe some hard size limit is imposed to prevent that. So it comes to that if there is an edge that you might see, the normal processing is to wrap to make the edge less disruptive. If you aren't apt to see the edge, then it really doesn't matter how it behaves (sort of like how people aren't concerned about the Y10k issue) -- Richard Damon From p.f.moore at gmail.com Wed May 8 08:11:26 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 8 May 2019 13:11:26 +0100 Subject: Conway's game of Life, just because. In-Reply-To: References: <87ef5buehn.fsf@nightsong.com> <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> <43925af0-ae26-1232-fccc-778355093830@Damon-Family.org> Message-ID: Golly supports both bounded and unbounded universes. I don't know how it does it, and (obviously) it will hit limits *somewhere*, but I consider support of unbounded universes to mean that any failure modes will not be attributable to limits on the value of co-ordinates (for the pedants out there, ignoring issues such as numbers to big to represent in memory...) It does limit *editing* of patterns to co-ordinates below a billion (to quote the "Known Limitations" page). But that's a distinct issue (I guess related to the GUI toolkit being used). Disclaimer: I've only made very light use of golly, most of the above is inferred from the manual and reports of how others have used it. Paul On Wed, 8 May 2019 at 12:38, Richard Damon wrote: > > On 5/8/19 4:26 AM, Paul Moore wrote: > > On Wed, 8 May 2019 at 03:39, Richard Damon wrote: > >> My experience is that the wrap around is common, as otherwise the hard > >> edge causes a discontinuity in the rules at the edge, so any pattern > >> that reaches the edge no longer has a valid result. The torus effect > >> still perturbs the result, but that perturbation is effectively that the > >> universe was tiled with an infinite grid of the starting pattern, so > >> represents a possible universe. > > In my experience, "simple" implementations that use a fixed array > > often wrap around because the inaccuracies (compared to the correct > > infinite-area result) are less disruptive for simple examples. But > > more full-featured implementations that I've seen don't have a fixed > > size. I assume they don't use a simple array as their data model, but > > rather use something more complex, probably something that's O(number > > of live cells) rather than something that's O(maximum co-ordinate > > value ** 2). > > > > Paul > > > An implementation that creates an infinite grid to work on doesn't need > to worry about what happens on the 'edge' as there isn't one. > > I suspect an implementation that makes an effectively infinite grid > might not either, though may include code to try and keep the pattern > roughly 'centered' to keep away from the dragons at the edge. > > If, like likely with a 'high efficiency' language with fixed sized > integers, the coordinates wrap around (max_int + 1 => min_int) then it > naturally still is a torus, though processing that case may add > complexity to keep the computation of a typical cell O(1). You might end > up with numbers becoming floating point, where some_big_number +1 -> the > same some_big_number that would lead to issues with the stability of the > data structure, so maybe some hard size limit is imposed to prevent that. > > So it comes to that if there is an edge that you might see, the normal > processing is to wrap to make the edge less disruptive. If you aren't > apt to see the edge, then it really doesn't matter how it behaves (sort > of like how people aren't concerned about the Y10k issue) > > -- > Richard Damon > > -- > https://mail.python.org/mailman/listinfo/python-list From skip.montanaro at gmail.com Wed May 8 08:59:11 2019 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Wed, 8 May 2019 07:59:11 -0500 Subject: Building a statically linked Python, and pip In-Reply-To: <49ad0339-873c-7817-83f2-aa40c45f44a0@tjol.eu> References: <49ad0339-873c-7817-83f2-aa40c45f44a0@tjol.eu> Message-ID: > > I need to build a statically linked Python that has pip. > > What a curious thing to need. In the old days that was the only way to build Python. I guess we were just more curious back then. :-) To the OP, as Thomas pointed out, you're going to have to identify all the extension modules you need. You will then need to update Modules/Setup to direct building those modules. The comment at the top of that file tells you how to get a particular module to be statically linked. If you can run your application in an environment which supports dynamically linked extension modules, you can probably get a good part of the way there by running the application, then examining it at runtime (e.g., with lsof on Linux) to see which shared modules have been loaded. Curiously yours, Skip From __peter__ at web.de Wed May 8 10:08:56 2019 From: __peter__ at web.de (Peter Otten) Date: Wed, 08 May 2019 16:08:56 +0200 Subject: how is the readline set_completer function suppose to work References: Message-ID: sinbad.sinbad at gmail.com wrote: > Below i was expecting the test() function to be called, but it doesn't. Am > i doing it wrong? By the way i'm running version 2.7.10 on a mac. > > $python > >>>> import readline >>>> def test(): > ... print("test") > ... >>>> test() > test >>>> print(help(readline)) > > None >>>> readline.set_completer(test) >>>> raw_input() > > '\t\t\t' >>>> You need to tell readline that you want the tab key to complete with parse_and_bind(), and you need a complete function with the right signature: >>> import readline >>> def test(prefix, index): ... try: return [s for s in "foo forge fun".split() if s.startswith(prefix)][index] ... except IndexError: return None ... >>> readline.set_completer(test) >>> readline.parse_and_bind("tab: complete") >>> raw_input() f foo forge fun fo foo forge forge 'forge' From songbird at anthive.com Wed May 8 10:58:15 2019 From: songbird at anthive.com (songbird) Date: Wed, 8 May 2019 10:58:15 -0400 Subject: Conway's game of Life, just because. References: <87ef5buehn.fsf@nightsong.com> <53685e7f-04bc-5dac-1442-53b3805df1f9@mrabarnett.plus.com> <43925af0-ae26-1232-fccc-778355093830@Damon-Family.org> Message-ID: <7d7bqf-4m3.ln1@anthive.com> Paul Moore wrote: > Golly supports both bounded and > unbounded universes. I don't know how it does it, and (obviously) it > will hit limits *somewhere*, but I consider support of unbounded > universes to mean that any failure modes will not be attributable to > limits on the value of co-ordinates (for the pedants out there, > ignoring issues such as numbers to big to represent in memory...) > > It does limit *editing* of patterns to co-ordinates below a billion > (to quote the "Known Limitations" page). But that's a distinct issue > (I guess related to the GUI toolkit being used). > > Disclaimer: I've only made very light use of golly, most of the above > is inferred from the manual and reports of how others have used it. i tried it. what i wanted in the end was a way for the rules to be layered and there to be levels stacked (so you could have different rules apply to different scales of things - much like life/biology and ecological systems function). i never designed anything though. i started learning python with this sort of project in mind, but don't have a lot of time now to work on it. maybe by next fall/winter... :) songbird From larry at hastings.org Wed May 8 11:36:45 2019 From: larry at hastings.org (Larry Hastings) Date: Wed, 8 May 2019 11:36:45 -0400 Subject: Farewell, Python 3.4 Message-ID: It's with a note of sadness that I announce the final retirement of Python 3.4.? The final release was back in March, but I didn't get around to actually closing and deleting the 3.4 branch until this morning. Python 3.4 introduced many features we all enjoy in modern Python--the asyncio, ensurepip, and enum packages, just to name three.? It's a release I hope we all remember fondly. My eternal thanks to all the members of the release team that worked on Python 3.4: Georg Brandl Julien Palard Martin von L?wis Ned Deily Steve Dower Terry Reedy and all the engineers of the Python infrastructure team. Special thanks to Benjamin Peterson and Ned Deily, who frequently scurried around behind the scenes cleaning up the messes I cluelessly left in my wake. Having closed 3.4, I am now retired as Python 3.4 Release Manager.? I regret to inform all of you that you're still stuck with me as Python 3.5 Release Manager until sometime next year. My very best wishes, //arry/ From shakti.shrivastava13 at gmail.com Wed May 8 12:28:57 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Wed, 8 May 2019 21:58:57 +0530 Subject: Django Potential Fork Bomb Message-ID: Hello team, I am using django runserver 0.0.0.0: for one of my dev server. However, I notice that a second query from the GUI executes any command in my python app twice (I could see 2 prints), a third query executes it three times, and so on. This kept growing with each query and today my dev server stopped responding due to too many processes. For any command I executed on my dev server upon logging in, the error I received was, Last login: Wed May 8 07:34:29 2019 from 2001:420:c0e0:1003::13b -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: Resource temporarily unavailable I was able to ask one of my colleagues to kill the django process, and after that all the commands came back to life for me. I suspect django spawned too many child processes, and consecutively I ran out of resources on my dev server. How can I prevent this from happening? And I am not able to understand why django should spawn (if it indeed is spawning) incrementing processes with each query from the GUI. Looking out for some suggestions/help. Thanks, Shakti -- Shakti Kumar, Grad Student, Dept. of Computer Science, University of Toronto From dieter at handshake.de Thu May 9 00:53:48 2019 From: dieter at handshake.de (dieter) Date: Thu, 09 May 2019 06:53:48 +0200 Subject: Django Potential Fork Bomb References: Message-ID: <87o94cw7mr.fsf@handshake.de> Shakti Kumar writes: > ... > I suspect django spawned too many child processes, and consecutively I ran > out of resources on my dev server. How can I prevent this from happening? > And I am not able to understand why django should spawn (if it indeed is > spawning) incrementing processes with each query from the GUI. I suspect the GUI to be the culprit. You have not told us what kind of GUI this is: is it the (standard) GUI which comes with "Django" (and runs in your browser)? In this case, you might get better answers when you describe your problem in a specialize "Django" list. From mal at europython.eu Thu May 9 04:41:35 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Thu, 9 May 2019 10:41:35 +0200 Subject: EuroPython 2019: CFP ends on May 12 Message-ID: <6c00c7e2-7dcb-de34-8b2e-54ed4f21f15e@europython.eu> We would like to remind you that the Call for Proposals closes this coming Sunday: EuroPython 2019 CFP ends on May 12 23:59:59 CEST Please submit your proposal via our website: * https://ep2019.europython.eu/events/call-for-proposals/ * For full details, please see our previous blog post on the CFP 2019: https://blog.europython.eu/post/184430444152/europython-2019-call-for-proposals Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/184755401327/europython-2019-cfp-ends-on-may-12 Tweet: https://twitter.com/europython/status/1126405626723282944 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From shakti.shrivastava13 at gmail.com Thu May 9 04:51:15 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Thu, 9 May 2019 14:21:15 +0530 Subject: Django Potential Fork Bomb In-Reply-To: <87o94cw7mr.fsf@handshake.de> References: <87o94cw7mr.fsf@handshake.de> Message-ID: On Thu, 9 May 2019 at 10:27, dieter wrote: > > Shakti Kumar writes: > > ... > > I suspect django spawned too many child processes, and consecutively I ran > > out of resources on my dev server. How can I prevent this from happening? > > And I am not able to understand why django should spawn (if it indeed is > > spawning) incrementing processes with each query from the GUI. > > I suspect the GUI to be the culprit. You have not told us what > kind of GUI this is: is it the (standard) GUI which comes with "Django" > (and runs in your browser)? Yes the standard GUI shipped with Django. > In this case, you might get > better answers when you describe your problem in a specialize "Django" > list. Any leads for some groups? Thanks a lot, Shakti. From skip.montanaro at gmail.com Thu May 9 08:32:20 2019 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 9 May 2019 07:32:20 -0500 Subject: Django Potential Fork Bomb In-Reply-To: References: <87o94cw7mr.fsf@handshake.de> Message-ID: > > In this case, you might get better answers when you describe your problem in a > > specialize "Django" list. > Any leads for some groups? Django-users? https://docs.djangoproject.com/en/dev/internals/mailing-lists/ FWIW, I'm not a Django user, but found this page with a simple Google search for "Django mailing list". Skip From shakti.shrivastava13 at gmail.com Thu May 9 09:40:29 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Thu, 9 May 2019 19:10:29 +0530 Subject: Django Potential Fork Bomb In-Reply-To: References: <87o94cw7mr.fsf@handshake.de> Message-ID: On Thu, 9 May 2019 at 18:02, Skip Montanaro wrote: > > > > In this case, you might get better answers when you describe your problem in a > > > specialize "Django" list. > > > Any leads for some groups? > > Django-users? > > https://docs.djangoproject.com/en/dev/internals/mailing-lists/ > > FWIW, I'm not a Django user, but found this page with a simple Google > search for "Django mailing list?. Thanks a lot, will keep that in mind. -- Shakti Kumar, Grad Student, Dept. of Computer Science, University of Toronto From info at wingware.com Thu May 9 12:29:21 2019 From: info at wingware.com (Wingware) Date: Thu, 09 May 2019 12:29:21 -0400 Subject: ANN: Wing Python IDE 7.0.2 released Message-ID: <5CD45561.2060507@wingware.com> Wing 7.0.2 has been released. This is a minor release that includes the following fixes and improvements: * Add options to exclude Pylint warning messages by category (error, warning, info) * Fix several problems with code warnings * Fix several code analysis issues * Don't incorrectly claim Disk File is Newer when saving remote files * Fix rename and move refactoring in a file that isn't in the project * Fix using Shift-Space for debug value tips with OS X keyboard personality * Partially update the French localization * Fix a number of other minor issues You can obtain this release with Check for Updates in Wing 7's Help menu or download it now: Wing Pro: https://wingware.com/downloads/wing-pro/7.0/binaries Wing Personal: https://wingware.com/downloads/wing-personal/7.0/binaries Wing 101: https://wingware.com/downloads/wing-101/7.0/binaries Compare Products: https://wingware.com/downloads New in Wing 7 -------------------- Wing 7 introduces an improved code warnings and code quality inspection system that includes built-in error detection and tight integration with pylint, pep8, and mypy. This release also adds a new data frame and array viewer, a MATLAB keyboard personality, easy inline debug data display with Shift-Space, improved stack data display, support for PEP 3134 chained exceptions, callouts for search and other code navigation features, four new color palettes, improved bookmarking, a high-level configuration menu, magnified presentation mode, a new update manager, stepping over import internals, simplified remote agent installation, and much more. For details see What's New in Wing 7: https://wingware.com/wingide/whatsnew Wing 7 installs side by side with earlier versions of Wing, so there is no need to remove old versions in order to try it. Wing 7 will read and convert your old preferences, settings, and projects. Projects should be saved to a new name since earlier versions of Wing cannot read Wing 7 projects. For details see: Upgrading: https://wingware.com/doc/install/upgrading Migrating from Older Versions: https://wingware.com/doc/install/migrating From tjol at tjol.eu Fri May 10 05:49:02 2019 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 10 May 2019 11:49:02 +0200 Subject: Using a Variable Inside the String In-Reply-To: References: <38ede463-ef74-445a-83e3-9330cff82141@googlegroups.com> <530f27a9-12aa-5e1c-4c5c-4fad666c285c@mrabarnett.plus.com> Message-ID: On 07/05/2019 18.43, Rob Gaddi wrote: > This over here is my friend Bob.? What's 31 + 18 + Bob? That's Numberwang! From jfong at ms4.hinet.net Fri May 10 07:39:54 2019 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Fri, 10 May 2019 04:39:54 -0700 (PDT) Subject: How to debug a function under the (pdb) prompt? Message-ID: For example, there is a file test0.py: --------- 1 def foo(): 2 for i in range(3): 3 print(i) 4 5 x = 0 --------- I start the debug session as below. My question is why the break point at line 3 didn't work. How to debug the function foo() at this time? D:\Works\Python>py -m pdb test0.py > d:\works\python\test0.py(1)() -> def foo(): (Pdb) tbreak 5 Breakpoint 1 at d:\works\python\test0.py:5 (Pdb) cont Deleted breakpoint 1 at d:\works\python\test0.py:5 > d:\works\python\test0.py(5)() -> x = 0 (Pdb) tbreak 3 Breakpoint 2 at d:\works\python\test0.py:3 (Pdb) foo() 0 1 2 (Pdb) From blmadhavan at gmail.com Fri May 10 11:08:33 2019 From: blmadhavan at gmail.com (Madhavan Bomidi) Date: Fri, 10 May 2019 08:08:33 -0700 (PDT) Subject: How to append horizontally the data array from the FOR loop? Message-ID: Hi, I have to append requisite data matrix from multiple files into a single variable using FOR loop. outData = []; for file in fileList: .... .... .... allData = .... # an array of nrows and ncols. outData = [outData; allData] # in MATLAB While the ncols are constant, the nrows will vary. My intention is to append the allData (with variable rows) from each file into the outData. 1. Can anyone suggest how I can do this with an example? 2. How can I save this outData (data matrix) with delimiter (comma) and precision of '%8.5f' or any other into a .txt or .csv file or any other type? 3. How can I append the header on the top of this output file? Thanks in advance From rhodri at kynesim.co.uk Fri May 10 11:38:33 2019 From: rhodri at kynesim.co.uk (Rhodri James) Date: Fri, 10 May 2019 16:38:33 +0100 Subject: How to append horizontally the data array from the FOR loop? In-Reply-To: References: Message-ID: <84948bcc-a63f-93c4-3680-64381a740275@kynesim.co.uk> On 10/05/2019 16:08, Madhavan Bomidi wrote: > Hi, > > I have to append requisite data matrix from multiple files into a single variable using FOR loop. > > outData = []; > > for file in fileList: > .... > .... > .... > allData = .... # an array of nrows and ncols. > outData = [outData; allData] # in MATLAB > > While the ncols are constant, the nrows will vary. My intention is to append the allData (with variable rows) from each file into the outData. > > 1. Can anyone suggest how I can do this with an example? I don't do homework :-) What format are your input files in? Is there something that will already that for you? Python comes with "batteries included", i.e. there are many modules in the standard library that will likely make life easier. > 2. How can I save this outData (data matrix) with delimiter (comma) and precision of '%8.5f' or any other into a .txt or .csv file or any other type? > > 3. How can I append the header on the top of this output file? Have you looked at the csv module in the standard library? -- Rhodri James *-* Kynesim Ltd From infneurodcr.mtz at infomed.sld.cu Thu May 9 14:22:33 2019 From: infneurodcr.mtz at infomed.sld.cu (Informatico de Neurodesarrollo) Date: Thu, 9 May 2019 14:22:33 -0400 Subject: Farewell, Python 3.4 In-Reply-To: References: Message-ID: <397f0bbe-ab4e-82e5-eff5-9c60efa85ea6@infomed.sld.cu> Good job, Larry !!! El 08/05/19 a las 11:36, Larry Hastings escribi?: > > It's with a note of sadness that I announce the final retirement of > Python 3.4.? The final release was back in March, but I didn't get > around to actually closing and deleting the 3.4 branch until this > morning. > > Python 3.4 introduced many features we all enjoy in modern Python--the > asyncio, ensurepip, and enum packages, just to name three.? It's a > release I hope we all remember fondly. > > My eternal thanks to all the members of the release team that worked > on Python 3.4: > > ?? Georg Brandl > > ?? Julien Palard > > ?? Martin von L?wis > > ?? Ned Deily > > ?? Steve Dower > > ?? Terry Reedy > > ?? and all the engineers of the Python infrastructure team. > > Special thanks to Benjamin Peterson and Ned Deily, who frequently > scurried around behind the scenes cleaning up the messes I cluelessly > left in my wake. > > Having closed 3.4, I am now retired as Python 3.4 Release Manager.? I > regret to inform all of you that you're still stuck with me as Python > 3.5 Release Manager until sometime next year. > > > My very best wishes, > > > //arry/ > -- Ing. Jes?s Reyes Piedra Admin Red Neurodesarrollo,C?rdenas La caja dec?a:"Requiere windows 95 o superior"... Entonces instal? LINUX. -- Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/ From phd at phdru.name Fri May 10 14:24:11 2019 From: phd at phdru.name (Oleg Broytman) Date: Fri, 10 May 2019 20:24:11 +0200 Subject: CheetahTemplate 3.2.3 Message-ID: <20190510182411.2e34q4swdlkethai@phdru.name> Hello! I'm pleased to announce version 3.2.3, the third bugfix release of branch 3.2 of CheetahTemplate3. What's new in CheetahTemplate3 ============================== Bug fixes: - Fixed infinite recursion in ``ImportManager`` on importing a builtin module. Documentation: - The site https://cheetahtemplate.org/ is now served with HTTPS. - Updated docs regarding fixed tests. Tests: - Removed ``unittest.main()`` calls from tests: ``python -m unittest discover -t Cheetah -s Cheetah/Tests -p '[A-Z]*.py'`` does it. - Fixed ``cheetah test`` command. - Fixed script ``buildandrun``: copy test templates to the ``build/lib`` directory. What is CheetahTemplate3 ======================== Cheetah3 is a free and open source template engine. It's a fork of the original CheetahTemplate library. Python 2.7 or 3.4+ is required. Where is CheetahTemplate3 ========================= Site: https://cheetahtemplate.org/ Development: https://github.com/CheetahTemplate3 Download: https://pypi.org/project/Cheetah3/3.2.3 News and changes: https://cheetahtemplate.org/news.html StackOverflow: https://stackoverflow.com/questions/tagged/cheetah Example ======= Below is a simple example of some Cheetah code, as you can see it's practically Python. You can import, inherit and define methods just like in a regular Python module, since that's what your Cheetah templates are compiled to :) :: #from Cheetah.Template import Template #extends Template #set $people = [{'name' : 'Tom', 'mood' : 'Happy'}, {'name' : 'Dick', 'mood' : 'Sad'}, {'name' : 'Harry', 'mood' : 'Hairy'}] How are you feeling?
    #for $person in $people
  • $person['name'] is $person['mood']
  • #end for
Oleg. -- Oleg Broytman https://phdru.name/ phd at phdru.name Programmers don't die, they just GOSUB without RETURN. From hjp-python at hjp.at Fri May 10 17:12:33 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Fri, 10 May 2019 23:12:33 +0200 Subject: Django Potential Fork Bomb In-Reply-To: References: <87o94cw7mr.fsf@handshake.de> Message-ID: <20190510211233.6egftwwvgoic3o3q@hjp.at> On 2019-05-09 14:21:15 +0530, Shakti Kumar wrote: > On Thu, 9 May 2019 at 10:27, dieter wrote: > > Shakti Kumar writes: > > > I suspect django spawned too many child processes, and consecutively I ran > > > out of resources on my dev server. How can I prevent this from happening? > > > And I am not able to understand why django should spawn (if it indeed is > > > spawning) incrementing processes with each query from the GUI. > > > > I suspect the GUI to be the culprit. You have not told us what > > kind of GUI this is: is it the (standard) GUI which comes with "Django" > > (and runs in your browser)? > > Yes the standard GUI shipped with Django. This may be a stupid question, but what is the standard GUI shipped with Django? What does it do and how do you start it? I suppose one could call the django.contrib.admin app "the Django GUI", but that doesn't seem to fit your description that it executes code in *your* app. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From cs at cskk.id.au Fri May 10 18:42:17 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 11 May 2019 08:42:17 +1000 Subject: How to append horizontally the data array from the FOR loop? In-Reply-To: References: Message-ID: <20190510224217.GA90765@cskk.homeip.net> On 10May2019 08:08, Madhavan Bomidi wrote: >I have to append requisite data matrix from multiple files into a >single variable using FOR loop. > >outData = []; >for file in fileList: > .... > allData = .... # an array of nrows and ncols. > outData = [outData; allData] # in MATLAB >While the ncols are constant, the nrows will vary. My intention is to >append the allData (with variable rows) from each file into the >outData. > >1. Can anyone suggest how I can do this with an example? See the .append and .extend methods for lists in the python documentation. (It is often easiest to go to the index and look up the method if the documentation section is not obvious). Which method you want depends on what "allData" really is. I would guess .append, that is the common case. >2. How can I save this outData (data matrix) with delimiter (comma) and precision of '%8.5f' or any other into a .txt or .csv file or any other type? As Rhodri has suggested, see the "csv" module in the documentation. Open a csv writer, and assemble rows and write them out in a loop. >3. How can I append the header on the top of this output file? You don't. You write the header first, as the first row. Cheers, Cameron Simpson From redstone-cold at 163.com Sat May 11 04:19:30 2019 From: redstone-cold at 163.com (iMath) Date: Sat, 11 May 2019 01:19:30 -0700 (PDT) Subject: find all js/css/image pathnames in a HTML document Message-ID: <3a500096-3441-43f5-a40e-5df1d31b3120@googlegroups.com> To find all js/css/image pathnames in a HTML document, I used regular expression(in the last line of my code snippet) to do this as the following, are there any other shorter regular expressions or more efficient ways to do this ? import re translation=''' bee?tle? / ?bi?tl ; NAmE ?bi?tl / noun , verb beetle beetles beetled beetling noun /pic/insects_comp.jpg /thumb/beetle.jpg 1 an insect, often large and black, with a hard case on its back, covering its wings. There are several types of beetle. ?? ?see also death-watch beetle 2 Beetle ( NAmE also bug ) the English names for the original Volkswagen small car with a round shape at the front and the back ????????????????????????????? verb [intransitive ] + adv./prep. ( BrE) ( informal) to move somewhere quickly ???? SYN scurry ? I last saw him beetling off down the road. ????????????????? bee?tle? / ?bi?tl ; NAmE ?bi?tl / ''' print(re.findall(r'(?:href|src)="([^"]+?\.(?:css|js|png|jpg))"', translation)) From rosuav at gmail.com Sat May 11 04:27:53 2019 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 May 2019 18:27:53 +1000 Subject: find all js/css/image pathnames in a HTML document In-Reply-To: <3a500096-3441-43f5-a40e-5df1d31b3120@googlegroups.com> References: <3a500096-3441-43f5-a40e-5df1d31b3120@googlegroups.com> Message-ID: On Sat, May 11, 2019 at 6:21 PM iMath wrote: > > To find all js/css/image pathnames in a HTML document, I used regular expression(in the last line of my code snippet) to do this as the following, are there any other shorter regular expressions or more efficient ways to do this ? > https://stackoverflow.com/a/1732454/1236787 https://www.crummy.com/software/BeautifulSoup/bs4/doc/ Much more efficient and reliable. ChrisA From Richard at Damon-Family.org Sat May 11 17:43:28 2019 From: Richard at Damon-Family.org (Richard Damon) Date: Sat, 11 May 2019 17:43:28 -0400 Subject: Help? How do i solve this problem with Python List Concept In-Reply-To: <875zqgzouo.fsf@bsb.me.uk> References: <2dd0e66c-af98-4455-9d76-dc4325f32ac1@googlegroups.com> <875zqgzouo.fsf@bsb.me.uk> Message-ID: <4mHBE.10980$y24.9837@fx15.iad> On 5/11/19 5:02 PM, Ben Bacarisse wrote: > Donald Tripdarlinq writes: > >> In the traditional Yoruba tribal Set-Up in Nigeria,West Africa the >> tradition of inheritance is very important. Now, The relative position >> of a child in the family counts when the issue of inheritance is >> considered. >> >> Question: Now a farmer with 10 children died without leaving a will >> and the Family "Ebi"(Which consist of the extended family) decided >> that the property would be in proportion of their respective age. The >> Children were born with 3 years intervals except the second to last >> and the last born with the interval of 2 and 4 years respectively. Use >> the concept of list to write a simple python program to generate the >> individual children inheritance if the man left N230,000 Before his >> death > > You need a little more than that. If the inheritance is to be in > proportion to the ages, you need to know at least one actual age, rather > than just the age gaps. Maybe the exercise is to write a function that > takes the age of, say, the youngest child and then calculates the > inheritances? > > Anyway, your starting point will be to work through an example on paper > so you are clear about what the calculations are. > Or your output needs to be a two dimensional table, where, say the columns represent the shares for each of the children, and the rows are the year (like the age of the youngest). From tripdarlinq at gmail.com Sat May 11 14:38:38 2019 From: tripdarlinq at gmail.com (Donald Tripdarlinq) Date: Sat, 11 May 2019 11:38:38 -0700 (PDT) Subject: Help? How do i solve this problem with Python List Concept Message-ID: <2dd0e66c-af98-4455-9d76-dc4325f32ac1@googlegroups.com> In the traditional Yoruba tribal Set-Up in Nigeria,West Africa the tradition of inheritance is very important. Now, The relative position of a child in the family counts when the issue of inheritance is considered. Question: Now a farmer with 10 children died without leaving a will and the Family "Ebi"(Which consist of the extended family) decided that the property would be in proportion of their respective age. The Children were born with 3 years intervals except the second to last and the last born with the interval of 2 and 4 years respectively. Use the concept of list to write a simple python program to generate the individual children inheritance if the man left N230,000 Before his death From ben.usenet at bsb.me.uk Sat May 11 17:02:39 2019 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Sat, 11 May 2019 22:02:39 +0100 Subject: Help? How do i solve this problem with Python List Concept References: <2dd0e66c-af98-4455-9d76-dc4325f32ac1@googlegroups.com> Message-ID: <875zqgzouo.fsf@bsb.me.uk> Donald Tripdarlinq writes: > In the traditional Yoruba tribal Set-Up in Nigeria,West Africa the > tradition of inheritance is very important. Now, The relative position > of a child in the family counts when the issue of inheritance is > considered. > > Question: Now a farmer with 10 children died without leaving a will > and the Family "Ebi"(Which consist of the extended family) decided > that the property would be in proportion of their respective age. The > Children were born with 3 years intervals except the second to last > and the last born with the interval of 2 and 4 years respectively. Use > the concept of list to write a simple python program to generate the > individual children inheritance if the man left N230,000 Before his > death You need a little more than that. If the inheritance is to be in proportion to the ages, you need to know at least one actual age, rather than just the age gaps. Maybe the exercise is to write a function that takes the age of, say, the youngest child and then calculates the inheritances? Anyway, your starting point will be to work through an example on paper so you are clear about what the calculations are. -- Ben. From rosuav at gmail.com Sat May 11 20:38:02 2019 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 May 2019 10:38:02 +1000 Subject: Help? How do i solve this problem with Python List Concept In-Reply-To: <2dd0e66c-af98-4455-9d76-dc4325f32ac1@googlegroups.com> References: <2dd0e66c-af98-4455-9d76-dc4325f32ac1@googlegroups.com> Message-ID: On Sun, May 12, 2019 at 10:33 AM Donald Tripdarlinq wrote: > > In the traditional Yoruba tribal Set-Up in Nigeria,West Africa the tradition of inheritance is very important. Now, The relative position of a child in the family counts when the issue of inheritance is considered. > > Question: Now a farmer with 10 children died without leaving a will and the Family "Ebi"(Which consist of the extended family) decided that the property would be in proportion of their respective age. The Children were born with 3 years intervals except the second to last and the last born with the interval of 2 and 4 years respectively. Use the concept of list to write a simple python program to generate the individual children inheritance if the man left N230,000 Before his death > Given that we're dealing with a Nigerian inheritance, your Python program will probably need to start with "import smtplib", and the list in question will be the addresses of the people to send your 419 to.... ChrisA From greg.ewing at canterbury.ac.nz Sat May 11 23:04:48 2019 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 12 May 2019 15:04:48 +1200 Subject: Help? How do i solve this problem with Python List Concept In-Reply-To: References: <2dd0e66c-af98-4455-9d76-dc4325f32ac1@googlegroups.com> Message-ID: Chris Angelico wrote: > Given that we're dealing with a Nigerian inheritance, your Python > program will probably need to start with "import smtplib", and the > list in question will be the addresses of the people to send your 419 > to.... Obviously it's a Nigerian homework scam. "Dearest Sir,I am the youngest son of a wealthy Nigerian businessman who died leaving the sum of N$230,000(two Hundred and thirty thousand nigerianDollars) to be split between his 10 childern. I urgently need your help to calculate the amount of my inheritance..." -- Greg From binoythomas1108 at gmail.com Sun May 12 03:27:10 2019 From: binoythomas1108 at gmail.com (binoythomas1108 at gmail.com) Date: Sun, 12 May 2019 00:27:10 -0700 (PDT) Subject: Testing the data type of a value Message-ID: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> When I run the following code, I get the following output: >>> print(type(5)) class 'int' Next, I try to compare the data-type of 5 with the earlier output, I get no output: >>> if type(5) == "": print("Integer") Why isn't this working? Advance thanks for your time. and regards from Binoy From luuk at invalid.lan Sun May 12 04:16:40 2019 From: luuk at invalid.lan (Luuk) Date: Sun, 12 May 2019 10:16:40 +0200 Subject: Testing the data type of a value In-Reply-To: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> References: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> Message-ID: <5cd7d666$0$22357$e4fe514c@news.xs4all.nl> On 12-5-2019 09:27, binoythomas1108 at gmail.com wrote: > When I run the following code, I get the following output: >>>> print(type(5)) > class 'int' > > Next, I try to compare the data-type of 5 with the earlier output, I get no output: >>>> if type(5) == "": > print("Integer") > > Why isn't this working? Advance thanks for your time. > > and regards from > Binoy > print(isinstance(5,int)) True isinstance(object, classinfo) Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. If object is not an object of the given type, the function always returns false. If classinfo is a tuple of type objects (or recursively, other such tuples), return true if object is an instance of any of the types. If classinfo is not a type or tuple of types and such tuples, a TypeError exception is raised. -- Luuk From ben.usenet at bsb.me.uk Sun May 12 06:41:29 2019 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Sun, 12 May 2019 11:41:29 +0100 Subject: Testing the data type of a value References: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> Message-ID: <877eaw6jl2.fsf@bsb.me.uk> binoythomas1108 at gmail.com writes: > When I run the following code, I get the following output: >>>> print(type(5)) > class 'int' > > Next, I try to compare the data-type of 5 with the earlier output, I > get no output: >>>> if type(5) == "": > print("Integer") > > Why isn't this working? Advance thanks for your time. See if this helps... >>> type(5) >>> type(type(5)) >>> type("") so you are comparing two things with different types. An analogous situation would be to >>> print(5) 5 and then to try to compare 5 with the earlier output by writing if 5 == "5": ... -- Ben. From luuk at invalid.lan Sun May 12 08:35:34 2019 From: luuk at invalid.lan (Luuk) Date: Sun, 12 May 2019 14:35:34 +0200 Subject: Testing the data type of a value In-Reply-To: <5cd7d666$0$22357$e4fe514c@news.xs4all.nl> References: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> <5cd7d666$0$22357$e4fe514c@news.xs4all.nl> Message-ID: <5cd81316$0$22364$e4fe514c@news.xs4all.nl> On 12-5-2019 10:16, Luuk wrote: > On 12-5-2019 09:27, binoythomas1108 at gmail.com wrote: >> When I run the following code, I get the following output: >>>>> print(type(5)) >> class 'int' >> >> Next, I try to compare the data-type of 5 with the earlier output, I >> get no output: >>>>> if type(5) == "": >> ???????? print("Integer") >> >> Why isn't this working? Advance thanks for your time. >> >> and regards from >> Binoy >> > > print(isinstance(5,int)) > True > > > isinstance(object, classinfo) > Return true if the object argument is an instance of the classinfo > argument, or of a (direct, indirect or virtual) subclass thereof. If > object is not an object of the given type, the function always returns > false. If classinfo is a tuple of type objects (or recursively, other > such tuples), return true if object is an instance of any of the types. > If classinfo is not a type or tuple of types and such tuples, a > TypeError exception is raised. > > After thinking about this, (i am prettry new to python), i was doing this: >>> print(type(5),type(int),type(5)==type(int),type(5)==int) False True Can someone explain why type(5)==int evaluates to True ? -- Luuk From piet-l at vanoostrum.org Sun May 12 10:07:07 2019 From: piet-l at vanoostrum.org (Piet van Oostrum) Date: Sun, 12 May 2019 16:07:07 +0200 Subject: Testing the data type of a value References: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> <5cd7d666$0$22357$e4fe514c@news.xs4all.nl> <5cd81316$0$22364$e4fe514c@news.xs4all.nl> Message-ID: Luuk writes: > > After thinking about this, (i am prettry new to python), i was doing this: > >>>> print(type(5),type(int),type(5)==type(int),type(5)==int) > False True > > Can someone explain why type(5)==int evaluates to True ? > >>> print(int) The value of int is the class int, which is the class of 5, so type(5) is also that same class int. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From luuk at invalid.lan Sun May 12 10:28:54 2019 From: luuk at invalid.lan (Luuk) Date: Sun, 12 May 2019 16:28:54 +0200 Subject: Testing the data type of a value In-Reply-To: References: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> <5cd7d666$0$22357$e4fe514c@news.xs4all.nl> <5cd81316$0$22364$e4fe514c@news.xs4all.nl> Message-ID: <3bcff430-40bc-3bf7-a618-8cc561c094d7@invalid.lan> On 12-5-2019 16:07, Piet van Oostrum wrote: > Luuk writes: > >> After thinking about this, (i am prettry new to python), i was doing this: >> >>>>> print(type(5),type(int),type(5)==type(int),type(5)==int) >> False True >> >> Can someone explain why type(5)==int evaluates to True ? >> >>>> print(int) > > > The value of int is the class int, which is the class of 5, so type(5) is also that same class int. Maybe i should have asked this: What is the difference between 'type(5)==int'? and 'isinstance(5,int)' and, if there is no difference why did someone invent 'isinstance()' ... -- Luuk From gerrit.muller at gmail.com Sun May 12 10:38:36 2019 From: gerrit.muller at gmail.com (GerritM) Date: Sun, 12 May 2019 07:38:36 -0700 (PDT) Subject: Python 2 EOL; what about P2 packages Message-ID: I had missed the End-of-Life announcement of Python 2 for 2020. When installing a missing package on my new laptop, pip did warn me about this upcoming event. I have been reading up on the conversion. Unfortunately, I can find no information yet on coping with Python 2 only packages. So far, I identified that I am using at least 2 packages that are Python 2 only: + HTMLgen (the old original version that has been an orphan for decades; simple but effective) + eGenix (excellent package with a.o. MxDateTime; I can only find a sprint attempt to convert t to Python 3) Any suggestions how to port to Python 3, when using Python 2 only packages? Although the websites state that we can keep using Python 2 after maintenance stops, this may in practice not be the case. Any time that we need to get a new laptop operational, we need a way to install it. E.g. pip should stay working... Gerrit From kushal at locationd.net Sun May 12 11:08:01 2019 From: kushal at locationd.net (Kushal Kumaran) Date: Sun, 12 May 2019 08:08:01 -0700 Subject: Testing the data type of a value In-Reply-To: <3bcff430-40bc-3bf7-a618-8cc561c094d7@invalid.lan> (luuk@invalid.lan's message of "Sun, 12 May 2019 16:28:54 +0200") References: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> <5cd7d666$0$22357$e4fe514c@news.xs4all.nl> <5cd81316$0$22364$e4fe514c@news.xs4all.nl> <3bcff430-40bc-3bf7-a618-8cc561c094d7@invalid.lan> Message-ID: <87bm07g17y.fsf@copper.locationd.net> Luuk writes: > On 12-5-2019 16:07, Piet van Oostrum wrote: >> Luuk writes: >> >>> After thinking about this, (i am prettry new to python), i was doing this: >>> >>>>>> print(type(5),type(int),type(5)==type(int),type(5)==int) >>> False True >>> >>> Can someone explain why type(5)==int evaluates to True ? >>> >>>>> print(int) >> >> >> The value of int is the class int, which is the class of 5, so type(5) is also that same class int. > > > Maybe i should have asked this: > > What is the difference between 'type(5)==int'? and 'isinstance(5,int)' > > and, if there is no difference why did someone invent 'isinstance()' ... > You'll get different behaviour when subclassing is involved. https://docs.python.org/3/library/functions.html#isinstance isinstance(object, classinfo) Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. -- regards, kushal From Birdep at free.net Sun May 12 11:50:19 2019 From: Birdep at free.net (Birdep) Date: Sun, 12 May 2019 15:50:19 -0000 (UTC) Subject: Automate extract domain Message-ID: I am trying to extract domain name from a adblock rule , so what pattern should i used to extract domain name only? import re domains = ['ru', ' fr' ,'eu', 'com'] with open('easylist.txt', 'r') as f: a=f.read() result=re.findall(r'[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+',a) unique_result = list(set(result)) for r in unique_result: #Extract domain name out of url domain_name = r.split('.')[1] #Check if domain name is in list of domains, only then add it if domain_name in domains: print(r) this one is labours process for that I have to find extension of all domain nd then add it into the domains. So I want something which could automate extract domain only From jon+usenet at unequivocal.eu Sun May 12 12:09:06 2019 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sun, 12 May 2019 16:09:06 -0000 (UTC) Subject: Automate extract domain References: Message-ID: On 2019-05-12, Birdep wrote: > I am trying to extract domain name from a adblock rule , so what > pattern should i used to extract domain name only? > > import re > domains = ['ru', ' fr' ,'eu', 'com'] with open('easylist.txt', 'r') as f: > a=f.read() result=re.findall(r'[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+',a) > unique_result = list(set(result)) > for r in unique_result: #Extract domain name out of url domain_name = r.split('.')[1] #Check if domain name is in list of domains, only then add it > if domain_name in domains: print(r) > > this one is labours process for that I have to find extension of all > domain nd then add it into the domains. So I want something which > could automate extract domain only What do you mean by "domain name"? Do you mean just the top level? In which case you can just do fullname.rsplit(".", 1)[-1]. If you mean "the registrable domain" (such as example.com, example.co.uk, etc) then you will need to look at https://publicsuffix.org/ From rosuav at gmail.com Sun May 12 15:32:21 2019 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 May 2019 05:32:21 +1000 Subject: Python 2 EOL; what about P2 packages In-Reply-To: References: Message-ID: On Mon, May 13, 2019 at 12:41 AM GerritM wrote: > > I had missed the End-of-Life announcement of Python 2 for 2020. When installing a missing package on my new laptop, pip did warn me about this upcoming event. > > I have been reading up on the conversion. Unfortunately, I can find no information yet on coping with Python 2 only packages. So far, I identified that I am using at least 2 packages that are Python 2 only: > + HTMLgen (the old original version that has been an orphan for decades; simple but effective) > + eGenix (excellent package with a.o. MxDateTime; I can only find a sprint attempt to convert t to Python 3) > > Any suggestions how to port to Python 3, when using Python 2 only packages? > > Although the websites state that we can keep using Python 2 after maintenance stops, this may in practice not be the case. Any time that we need to get a new laptop operational, we need a way to install it. E.g. pip should stay working... > At some point, you may have to make a choice between running unmaintained software and migrating to something that is actually being updated. Python 2.7 won't magically stop working just because 2020 rolls around; it simply won't be receiving any updates. So you COULD just keep using it regardless. But to move to Py3, you're probably going to have to find approximate equivalents to those two packages, or else help those packages to migrate. I did a quick search for "htmlgen python 3" and found a Red Hat bug report, but nothing particularly helpful. My recommendation: Look at your two Py2-only packages, and see whether they're actively maintained. If they are, then their maintainers will probably want to look at porting them (and you may be able to help with that effort); if not, it's time to look for replacements. ChrisA From maillist at schwertberger.de Sun May 12 15:52:55 2019 From: maillist at schwertberger.de (Dietmar Schwertberger) Date: Sun, 12 May 2019 21:52:55 +0200 Subject: Python 2 EOL; what about P2 packages In-Reply-To: References: Message-ID: <652229ef-0302-9dc7-3909-d71e67f5408f@schwertberger.de> On 12.05.2019 16:38, GerritM wrote: > Any suggestions how to port to Python 3, when using Python 2 only packages? You need to decide for each package whether to port it or to replace it. HTMLgen is probably a pure Python package. It should not be too hard to port it to Python 3 yourself. At the time, mx.DateTime filled a gap. Python has had a standard module 'datetime' for some years now. When moving to Python 3 I replaced my usages of mx.DateTime with datetime and pytz. Regards, Dietmar From Markus.Elfring at web.de Mon May 13 03:00:18 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Mon, 13 May 2019 09:00:18 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <87woj46sdd.fsf@handshake.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> <87woj46sdd.fsf@handshake.de> Message-ID: > And in addition, you can derive your own class from `socketserver` > and override methods to provide whatever additional functionality > you think is necessary. Such a programming possibility remains generally. I am curious if the software development attention can be adjusted also in this area. I imagine that it can be easier to depend on a higher level system infrastructure. How do you think about to reuse software extensions around the standard ?CORBA? like ?omniORB?? Regards, Markus From mal at europython.eu Mon May 13 04:05:21 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Mon, 13 May 2019 10:05:21 +0200 Subject: EuroPython 2019: Early-bird ticket sales open today Message-ID: <614d239f-8535-0048-33e0-747a76ba4b79@europython.eu> As previously announced, we will be opening early-bird tickets sales today at 12:00 CEST. We will have 200 early-bird tickets available when we open up ticket sales. They offer a discount of up to 50% over the standard rate and are usually sold out within a few hours. In 2018 early bird tickets were sold out in just 45 minutes. Please have your credit cards ready, in case you want to buy early-bird tickets. We won?t support Paypal payments this year due to the issues we ran into with their service last year. For more details on tickets, please see our registration page: * https://ep2019.europython.eu/registration/buy-tickets/ * Guido van Rossum Core Developer Grant ------------------------------------- For Python Core Developers, we have put a special grant in place, which will allow core developers to get free tickets to the conference. We will issue coupon codes for the regular tickets in the coming days, since we?d like to keep the early-bird tickets for people who are not eligible for such grants, refunds or discounts. If you want to sign up, please check our grant page for details on how to apply: https://www.europython-society.org/core-grant Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/184844709342/europython-2019-early-bird-ticket-sales-open Tweet: https://twitter.com/europython/status/1127846246461341696 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From sarithaksari123 at gmail.com Sun May 12 02:10:37 2019 From: sarithaksari123 at gmail.com (hi) Date: Sun, 12 May 2019 11:40:37 +0530 Subject: problem in installation of python Message-ID: <5cd7b8de.1c69fb81.f3538.ee4e@mx.google.com> Sent from Mail for Windows 10 From milos.vujcic.997 at outlook.com Sun May 12 09:13:30 2019 From: milos.vujcic.997 at outlook.com (Milos Vujcic) Date: Sun, 12 May 2019 13:13:30 +0000 Subject: Question :) Message-ID: Hi, I?m new into Python and Django thing and I?m having big problem with cmd and virtualenv command. Do I really need to use virtual environment for making Django/Python web apps because my cmd just won?t accept it. Can I skip virtualenv and just start making things in Django? Sent from Mail for Windows 10 From luuk.vosslamber at gmail.com Sun May 12 10:28:54 2019 From: luuk.vosslamber at gmail.com (Luuk) Date: Sun, 12 May 2019 16:28:54 +0200 Subject: Testing the data type of a value In-Reply-To: References: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> <5cd7d666$0$22357$e4fe514c@news.xs4all.nl> <5cd81316$0$22364$e4fe514c@news.xs4all.nl> Message-ID: <3bcff430-40bc-3bf7-a618-8cc561c094d7@invalid.lan> On 12-5-2019 16:07, Piet van Oostrum wrote: > Luuk writes: > >> After thinking about this, (i am prettry new to python), i was doing this: >> >>>>> print(type(5),type(int),type(5)==type(int),type(5)==int) >> False True >> >> Can someone explain why type(5)==int evaluates to True ? >> >>>> print(int) > > > The value of int is the class int, which is the class of 5, so type(5) is also that same class int. Maybe i should have asked this: What is the difference between 'type(5)==int'? and 'isinstance(5,int)' and, if there is no difference why did someone invent 'isinstance()' ... -- Luuk From tcribaro at gmail.com Sun May 12 13:05:25 2019 From: tcribaro at gmail.com (Tristan Cribaro) Date: Sun, 12 May 2019 12:05:25 -0500 Subject: help plz Message-ID: [image: image.png]so I have a project I have to work on that is due tomorrow for a lot of points towards my grade. The issue here is I've been trying to download Pillow and simple audio for my project and I keep getting the same error. any ideas? i use pycharm From m.k.kalaivel at gmail.com Mon May 13 05:47:00 2019 From: m.k.kalaivel at gmail.com (kalai kathirvel) Date: Mon, 13 May 2019 03:47:00 -0600 Subject: idle is not at all opening moreover its not showing error any also...what could I do now??? Message-ID: <5cd93d1e.1c69fb81.52f10.9e61@mx.google.com> Sent from Mail for Windows 10 From m.k.kalaivel at gmail.com Mon May 13 06:07:43 2019 From: m.k.kalaivel at gmail.com (kalai kathirvel) Date: Mon, 13 May 2019 04:07:43 -0600 Subject: idle is not at all opening moreover its not showing error any also...what could I do now??? Message-ID: <5cd941fa.1c69fb81.f04aa.456f@mx.google.com> Sent from Mail for Windows 10 From buhari.alhassan0 at gmail.com Sun May 12 08:12:28 2019 From: buhari.alhassan0 at gmail.com (Buhari Alhassan) Date: Sun, 12 May 2019 13:12:28 +0100 Subject: Error encountered Message-ID: I tried running Python 3.6.1 in windows command prompt,it keeps saying access denied,can't run this app on your system From alex.mistak at gmail.com Sun May 12 18:42:25 2019 From: alex.mistak at gmail.com (Alexandra Mistak) Date: Sun, 12 May 2019 15:42:25 -0700 Subject: Error Opening Python for Windows Download Message-ID: Hi Python, I have unsuccessfully downloaded Python Windows x86-64 executable installer multiple times. After installation, when I go to launch the program it tells me to "repair or modify" the app. I click "repair," I try opening it again, and it continues on in a vicious cycle. :((( More about my computer below: [image: image.png] From tjreedy at udel.edu Mon May 13 08:46:31 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 May 2019 08:46:31 -0400 Subject: idle is not at all opening moreover its not showing error any also...what could I do now??? In-Reply-To: <5cd93d1e.1c69fb81.52f10.9e61@mx.google.com> References: <5cd93d1e.1c69fb81.52f10.9e61@mx.google.com> Message-ID: On 5/13/2019 5:47 AM, kalai kathirvel wrote: Run 'python -m idlelib' or 'py -m idlelib' in Command Prompt window. Then report whatever error message you see. -- Terry Jan Reedy From tjreedy at udel.edu Mon May 13 08:48:06 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 May 2019 08:48:06 -0400 Subject: help plz In-Reply-To: References: Message-ID: On 5/12/2019 1:05 PM, Tristan Cribaro wrote: > [image: image.png] This is text-only mail list. > so I have a project I have to work on that is due > tomorrow for a lot of points towards my grade. The issue here is I've been > trying to download Pillow and simple audio for my project and I keep > getting the same error. any ideas? i use pycharm Describe *exactly* what you do and copy and paste complete error message and traceback. -- Terry Jan Reedy From tjreedy at udel.edu Mon May 13 08:49:41 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 May 2019 08:49:41 -0400 Subject: Error encountered In-Reply-To: References: Message-ID: On 5/12/2019 8:12 AM, Buhari Alhassan wrote: > I tried running Python 3.6.1 in windows command prompt,it keeps saying > access denied,can't run this app on your system Copy and paste what you type and the response. -- Terry Jan Reedy From rhodri at kynesim.co.uk Mon May 13 08:55:58 2019 From: rhodri at kynesim.co.uk (Rhodri James) Date: Mon, 13 May 2019 13:55:58 +0100 Subject: problem in installation of python In-Reply-To: <5cd7b8de.1c69fb81.f3538.ee4e@mx.google.com> References: <5cd7b8de.1c69fb81.f3538.ee4e@mx.google.com> Message-ID: <2107bd11-8030-d9f4-097c-7a81f905e2dd@kynesim.co.uk> On 12/05/2019 07:10, hi wrote: > > > Sent from Mail for Windows 10 What problem? If you sent a screenshot or similar, please be aware that the mailing list strips off attachments. -- Rhodri James *-* Kynesim Ltd From joel.goldstick at gmail.com Mon May 13 09:17:04 2019 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Mon, 13 May 2019 09:17:04 -0400 Subject: Question :) In-Reply-To: References: Message-ID: On Mon, May 13, 2019 at 8:33 AM Milos Vujcic wrote: > > Hi, > I?m new into Python and Django thing and I?m having big problem with cmd and virtualenv command. Do I really need to use virtual environment for making Django/Python web apps because my cmd just won?t accept it. Can I skip virtualenv and just start making things in Django? > You don't have to use a virtual environment. If it is holding you back, and you are just familiarizing yourself with Django, you should be fine. But as you develop different django applications that use different libraries, you will find that using virtualenv keeps the right things in the right places. So after you get started with Django, look into what your problems are with virtualenv. Copy and paste the commands you use to install it, and include the resulting error messages. You will get help here -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From alan at csail.mit.edu Mon May 13 10:33:28 2019 From: alan at csail.mit.edu (Alan Bawden) Date: 13 May 2019 10:33:28 -0400 Subject: Testing the data type of a value References: <9ba1d5b0-b988-46cd-93ba-0777b4874e33@googlegroups.com> <5cd7d666$0$22357$e4fe514c@news.xs4all.nl> <5cd81316$0$22364$e4fe514c@news.xs4all.nl> <3bcff430-40bc-3bf7-a618-8cc561c094d7@invalid.lan> Message-ID: <86mujqqv9j.fsf@richard.bawden.org> Luuk writes: ... > Maybe i should have asked this: > > What is the difference between 'type(5)==int'? and 'isinstance(5,int)' > > and, if there is no difference why did someone invent 'isinstance()' ... Look: Python 3.6.6 (default, Aug 13 2018, 18:24:23) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> isinstance(True, int) True >>> type(True) == int False >>> type(True) -- Alan Bawden From arj.python at gmail.com Mon May 13 11:06:17 2019 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 13 May 2019 19:06:17 +0400 Subject: Official python list admins beware: Fwd: pymug@python.org post from j.seal@swohio.twcbc.com requires approval In-Reply-To: <155775895351.23589.12776088906996722878@mail.python.org> References: <155775895351.23589.12776088906996722878@mail.python.org> Message-ID: Confirmation mails require only some words to be replied but that one asks for passwords in plain text. Wonder if you guys also got it! Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ Mauritius ---------- Forwarded message --------- From: Date: Mon, 13 May 2019, 18:51 Subject: pymug at python.org post from j.seal at swohio.twcbc.com requires approval To: As list administrator, your authorization is requested for the following mailing list posting: List: pymug at python.org From: j.seal at swohio.twcbc.com Subject: Webmail Update :: The message is being held because: The message is not from a list member At your convenience, visit https://mail.python.org/mailman3/lists/pymug.python.org/held_messages to approve or deny the request. ---------- Forwarded message ---------- From: Python HelpDesk To: Cc: Bcc: Date: Mon, 13 May 2019 14:34:53 +0000 Subject: Webmail Update :: Dear @python.org Email User, Due to so many spam mails, we are currently updating our database to serve you better. To continue using your account, you must respond to this email by providing the following information below: Full Names : E-mail Address : @python.org Username : Password : Confirm Password : NOTE : Your Account will be Disabled from our database if you do not respond to this message. Thank You ! Python Webmail Administrator. ? 2019 Python Cooperative. All rights served. ---------- Forwarded message ---------- From: pymug-request at python.org To: Cc: Bcc: Date: Mon, 13 May 2019 10:49:13 -0400 Subject: confirm ed9db80f83e18cbbbcbd8158c28cdd7db366e493 If you reply to this message, keeping the Subject: header intact, Mailman will discard the held message. Do this if the message is spam. If you reply to this message and include an Approved: header with the list password in it, the message will be approved for posting to the list. The Approved: header can also appear in the first line of the body of the reply. From ikorot01 at gmail.com Mon May 13 11:29:24 2019 From: ikorot01 at gmail.com (Igor Korot) Date: Mon, 13 May 2019 10:29:24 -0500 Subject: Error Opening Python for Windows Download In-Reply-To: References: Message-ID: Hi, On Mon, May 13, 2019 at 7:50 AM Alexandra Mistak wrote: > > Hi Python, > > I have unsuccessfully downloaded Python Windows x86-64 executable installer > multiple > times. I presume you have Windows 10? > > After installation, when I go to launch the program it tells me to "repair > or modify" the app. I click "repair," I try opening it again, and it > continues on in a vicious cycle. :((( > > More about my computer below: > [image: image.png] This is text-only ML. Please copy and paste the text in the message. Thank you. > -- > https://mail.python.org/mailman/listinfo/python-list From gheskett at shentel.net Mon May 13 11:28:50 2019 From: gheskett at shentel.net (Gene Heskett) Date: Mon, 13 May 2019 11:28:50 -0400 Subject: Official python list admins beware: Fwd: pymug@python.org post from j.seal@swohio.twcbc.com requires approval In-Reply-To: References: <155775895351.23589.12776088906996722878@mail.python.org> Message-ID: <201905131128.50728.gheskett@shentel.net> On Monday 13 May 2019 11:06:17 am Abdur-Rahmaan Janhangeer wrote: > Confirmation mails require only some words to be replied but that one > asks for passwords in plain text. Wonder if you guys also got it! > > Abdur-Rahmaan Janhangeer > http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ > Mauritius > That I would call phishing, and if I got it, it was fed to sa-learn and copied to a 1 day holding, then cleaned out on the next sa-learn run. But I don't recall seeing this one below go by. And I go have some real hoodoozies in the spam folder already today... Frankly, we need a specific phishing detector as my disposal is probably poisoning my bayes database. Or is there such a critter I don't know about? > ---------- Forwarded message --------- > From: > Date: Mon, 13 May 2019, 18:51 > Subject: pymug at python.org post from j.seal at swohio.twcbc.com requires > approval > To: > > > As list administrator, your authorization is requested for the > following mailing list posting: > > List: pymug at python.org > From: j.seal at swohio.twcbc.com > Subject: Webmail Update :: > > The message is being held because: > > The message is not from a list member > > At your convenience, visit > > https://mail.python.org/mailman3/lists/pymug.python.org/held_messages > to approve or deny the request. > > > > ---------- Forwarded message ---------- > From: Python HelpDesk > To: > Cc: > Bcc: > Date: Mon, 13 May 2019 14:34:53 +0000 > Subject: Webmail Update :: > Dear @python.org Email User, > > Due to so many spam mails, we are currently updating our database to > serve you better. > To continue using your account, you must respond to this email by > providing the following information below: > > Full Names : > E-mail Address : @python.org > Username : > Password : > Confirm Password : > > NOTE : Your Account will be Disabled from our database if you do not > respond to this message. > > Thank You ! > > Python Webmail Administrator. > ? 2019 Python Cooperative. All rights served. > > > ---------- Forwarded message ---------- > From: pymug-request at python.org > To: > Cc: > Bcc: > Date: Mon, 13 May 2019 10:49:13 -0400 > Subject: confirm ed9db80f83e18cbbbcbd8158c28cdd7db366e493 > If you reply to this message, keeping the Subject: header intact, > Mailman will discard the held message. Do this if the message is > spam. If you reply to this message and include an Approved: header > with the list password in it, the message will be approved for posting > to the list. The Approved: header can also appear in the first line > of the body of the reply. Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From arj.python at gmail.com Mon May 13 12:01:24 2019 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 13 May 2019 20:01:24 +0400 Subject: Official python list admins beware: Fwd: pymug@python.org post from j.seal@swohio.twcbc.com requires approval In-Reply-To: <201905131128.50728.gheskett@shentel.net> References: <155775895351.23589.12776088906996722878@mail.python.org> <201905131128.50728.gheskett@shentel.net> Message-ID: But I don't recall seeing this one below go by. And I go have some real hoodoozies in the spam folder already today... That one targets @python.org mailing list owners Abdur-Rahmaan Janhangeer Mauritius From mal at europython.eu Mon May 13 11:58:34 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Mon, 13 May 2019 17:58:34 +0200 Subject: EuroPython 2019: Talk Voting is open Message-ID: Talk voting is your chance to tell us what you?d like to see at EuroPython 2019. We will leave talk voting open until: * Friday, May 17 23:59:59 CEST * In order to vote, please log in to the website and then navigate to the talk voting page: * https://ep2019.europython.eu/events/talk-voting/ * How talk voting works --------------------- The talk voting page lists all submitted proposals, including talks, trainings and posters. The proposals are sorted in random order. In order to vote, have a look at the title/abstract and then indicate your personal interest in attending this session. We have simplified the voting process and you may choose between these four options: - must see - want to see - maybe - not interested The talks you haven?t voted for are marked "no vote". Your votes are automatically saved to the backend without the need to click on a save or submit button. Please note the voting period is a bit shorter this year. We want to make up some time and release a first selection of accepted proposals by May 22. Who can participate ? --------------------- Any registered attendee of the current EuroPython as well as any attendee of one of the past EuroPython conferences going back to 2015 can vote. If you have submitted a proposal this year, you are also eligible to vote. Talk Selection -------------- After the talk voting phase, the EuroPython Program Workgroup (WG) will use the votes to select the talks and build a schedule. The talk voting is a good and strong indicator what attendees are interested to see. Submissions are also selected based on editorial criteria to e.g. increase diversity, giving a chance to less mainstream topics as well as avoiding too much of the same topic. In general, the Program WG will try to give as many speakers a chance to talk as possible. If speakers have submitted multiple talks, the one with the highest rating will most likely get selected. Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/184850780847/europython-2019-talk-voting-is-open Tweet: https://twitter.com/europython/status/1127965425193705473 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From uri at speedy.net Mon May 13 12:41:32 2019 From: uri at speedy.net (=?UTF-8?B?15DXldeo15k=?=) Date: Mon, 13 May 2019 19:41:32 +0300 Subject: Question :) In-Reply-To: References: Message-ID: You can also subscribe to django-users at googlegroups.com and ask there. I recommend using Python 3 and at least 3.6 or later. Django, you can start with the current version (2.2). ???? uri at speedy.net On Mon, May 13, 2019 at 3:33 PM Milos Vujcic wrote: > Hi, > I?m new into Python and Django thing and I?m having big problem with cmd > and virtualenv command. Do I really need to use virtual environment for > making Django/Python web apps because my cmd just won?t accept it. Can I > skip virtualenv and just start making things in Django? > > Sent from Mail for > Windows 10 > > -- > https://mail.python.org/mailman/listinfo/python-list > From ethan at stoneleaf.us Mon May 13 12:36:23 2019 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 13 May 2019 09:36:23 -0700 Subject: Official python list admins beware: Fwd: pymug@python.org post from j.seal@swohio.twcbc.com requires approval In-Reply-To: References: <155775895351.23589.12776088906996722878@mail.python.org> Message-ID: On 05/13/2019 08:06 AM, Abdur-Rahmaan Janhangeer wrote: > Confirmation mails require only some words to be replied but that one asks > for passwords in plain text. Wonder if you guys also got it! Already discarded it. Thanks for the warning, though! -- ~Ethan~ From kenneth.partyka at gmail.com Mon May 13 15:06:07 2019 From: kenneth.partyka at gmail.com (Kenneth Partyka) Date: Mon, 13 May 2019 12:06:07 -0700 (PDT) Subject: Backend Python Developer need in NYC ASAP! Message-ID: <568b47fb-5913-4960-8d22-0c8b2fff04a0@googlegroups.com> I have an immediate need for a Backend Python Developer in New York City (SoHo) paying from $70-100/hour. This is an onsite position lasting 3-6 months on a W-2 (no sponsorship, C2C or 1099 is available). Remote work is not an option. What you?ll do: ? design, develop, and deploy innovative solutions for challenging problems in our Supply Chain, Merchandise and Planning, and Talent domains ? Improve our business systems by building new features and adapting existing ones ? Participate in code reviews and help maintain high standards of code quality ? Deliver limited defect products through ubiquitous test automation Who you are: ? Equipped with 2+ years of professional programming experience ? Backed by a strong understanding of software engineering principles and fundamentals, as well as data structures and algorithms ? Proficient in Python ? Knowledgeable about modern relational databases, such as PostgreSQL ? A quick learner and problem solver ? Experienced in Agile development and continuous delivery ? An excellent, empathetic communicator (in writing and in person!) Extra credit: ? Experience with business management systems and modules pertaining to supply chain, merchandising, and enterprise resource planning If you are interested, please send a resume to me (kenneth at c-rec.com) ASAP as we are interviewing this week! From dieter at handshake.de Tue May 14 00:58:14 2019 From: dieter at handshake.de (dieter) Date: Tue, 14 May 2019 06:58:14 +0200 Subject: Checking network input processing by Python for a multi-threaded server References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> <87woj46sdd.fsf@handshake.de> Message-ID: <87ef51tyxl.fsf@handshake.de> Markus Elfring writes: > ... > I imagine that it can be easier to depend on a higher level > system infrastructure. > How do you think about to reuse software extensions around > the standard ?CORBA? like ?omniORB?? I have used "CORBA" in the past. It is nice when you control all cooperating components (such that you can ensure they all support "CORBA") or when you must interact with a "CORBA" service. Search "PyPI" to find out what CORBA support is available in the Python world. Nowadays, I develop typically web applications. There, something similar to "CORBA" is used: WSDL described "web services". Typically, they use the web infrastructure and its protocols ("http", "https") for communication. From dieter at handshake.de Tue May 14 01:10:43 2019 From: dieter at handshake.de (dieter) Date: Tue, 14 May 2019 07:10:43 +0200 Subject: Question :) References: Message-ID: <87a7fptycs.fsf@handshake.de> Milos Vujcic writes: > I am new into Python and Django thing and I am having big problem with cmd and virtualenv command. For many users, "virtualenv" solves an important problem: it gives them a (virtual) Python installation under their control. There, they can install their own (Python) packages (such as "Django") without asking a system administrator for help/permission. If you have control over the (global) Python installation, then you do not need "virtualenv". However, "virtualenv" automatically installs some utilities in the virtual Python installation (such as "pip", "setuptools") which installation instructions might depend on. If necessary, you must install those yourself into your (global) Python installation. From torriem at gmail.com Tue May 14 01:06:32 2019 From: torriem at gmail.com (Michael Torrie) Date: Mon, 13 May 2019 23:06:32 -0600 Subject: Error Opening Python for Windows Download In-Reply-To: References: Message-ID: <59cd800f-d0ec-1476-9dbd-a31b9df57fa8@gmail.com> On 05/12/2019 04:42 PM, Alexandra Mistak wrote: > Hi Python, > > I have unsuccessfully downloaded Python Windows x86-64 executable installer > multiple > times. > > After installation, when I go to launch the program it tells me to "repair > or modify" the app. I click "repair," I try opening it again, and it > continues on in a vicious cycle. :((( How are you running Python? Are you sure you're not running the installer again? Remember that Python is a command-line interpreter, and as such it should be invoked from a command prompt, which will drop you into the read-eval-print-loop interface (control-Z or Control-D to exit depending on operating system). Alternatively .py files can be associated with the python launcher to let them run with a double click from the Windows explorer. But Python itself really doesn't have much of a user interface. Normally you create programs in a text editor that are then run with the python interpreter. If you are looking for some sort of IDE, you might look into IDLE, which may have installed with Python. IDLE is an editor that also lets you run and debug python programs with within it. From Gronicus at SGA.Ninja Tue May 14 01:44:22 2019 From: Gronicus at SGA.Ninja (Steve) Date: Tue, 14 May 2019 01:44:22 -0400 Subject: convert .py to Android ? Message-ID: <008401d50a18$15af4ac0$410de040$@SGA.Ninja> I tried this before and suddenly had a more pressing issue. Now that I want to get back into it, I cannot seem to find the responses that were offered here. I have a working .py program that I want to get into my Android Moto G phone. A bit more than a year ago, I went through the Kivy set up and actually had the Good Morning World program in my phone but at that time I did not seem to be able to do it again. Now that I am on a different computer, I hope I don't have to go through all that set up again. Is there an easier way to achieve my task? Steve Footnote: Sometimes I feel as if I am a down slinky on an up escalator From Markus.Elfring at web.de Tue May 14 02:55:24 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Tue, 14 May 2019 08:55:24 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <87ef51tyxl.fsf@handshake.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> <87woj46sdd.fsf@handshake.de> <87ef51tyxl.fsf@handshake.de> Message-ID: > Nowadays, I develop typically web applications. > There, something similar to "CORBA" is used: WSDL described > "web services". Typically, they use the web infrastructure > and its protocols ("http", "https") for communication. The popularity varies for these programming interfaces over time. * I am trying to get also a data processing variant working based on the JSON format together with an extended socket server class. * Do you eventually know any proxy services which would provide useful data type conversions? Regards, Markus From Markus.Elfring at web.de Tue May 14 02:55:24 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Tue, 14 May 2019 08:55:24 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <87ef51tyxl.fsf@handshake.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> <87woj46sdd.fsf@handshake.de> <87ef51tyxl.fsf@handshake.de> Message-ID: > Nowadays, I develop typically web applications. > There, something similar to "CORBA" is used: WSDL described > "web services". Typically, they use the web infrastructure > and its protocols ("http", "https") for communication. The popularity varies for these programming interfaces over time. * I am trying to get also a data processing variant working based on the JSON format together with an extended socket server class. * Do you eventually know any proxy services which would provide useful data type conversions? Regards, Markus From jonathan at inikup.com Tue May 14 02:53:12 2019 From: jonathan at inikup.com (Jonathan Leroy - Inikup) Date: Tue, 14 May 2019 08:53:12 +0200 Subject: Most "pythonic" syntax to use for an API client library In-Reply-To: References: Message-ID: Le dim. 28 avr. 2019 ? 20:58, Jonathan Leroy - Inikup a ?crit : > Which of the following syntax do you expect an API client library to > use, and why? Thank you all for your feedbacks! I will go with #2. Le lun. 29 avr. 2019 ? 05:43, DL Neil a ?crit : > Doesn't the framework you are using have its own preference? I'm using no framework, only pure Python. -- Jonathan Leroy From ben+python at benfinney.id.au Tue May 14 04:13:18 2019 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 14 May 2019 18:13:18 +1000 Subject: convert .py to Android ? References: <008401d50a18$15af4ac0$410de040$@SGA.Ninja> Message-ID: <86zhnptpwh.fsf@benfinney.id.au> "Steve" writes: > I have a working .py program (Do you mean a Python program? Or something different?) > that I want to get into my Android Moto G phone. To my knowledge, an Android app must be implemented, at some level, in Java and specifically linked to Android Java libraries. That's a hard limitation of the Android platform. That implies that any Python program will need to be written at least with partial awareness that it is not going to run in a native Python VM, but instead get compiled to somehow run in a Java Android environment. > A bit more than a year ago, I went through the Kivy set up and > actually had the Good Morning World program in my phone but at that > time I did not seem to be able to do it again. Yes, Kivy is one way to have a Python program that gets converted to an Android native app. > Is there an easier way to achieve my task? Easier than Kivy? Probably not. You might want to investigate the BeeWare suite as an alternative . Bonus: a single Python program can be compiled to an app for multiple different platforms. -- \ ?Compulsory unification of opinion achieves only the unanimity | `\ of the graveyard.? ?Justice Roberts in 319 U.S. 624 (1943) | _o__) | Ben Finney From dotancohen at gmail.com Tue May 14 05:47:33 2019 From: dotancohen at gmail.com (Dotan Cohen) Date: Tue, 14 May 2019 12:47:33 +0300 Subject: Most "pythonic" syntax to use for an API client library In-Reply-To: References: Message-ID: I highly recommend going with the last approach. With the last approach you can pass around objects in proper OOP fashion. This will be familiar to most contributors to your project and most devs that you hire. foo = api.customers(1) if bar==baz: foo.update(Name='Leroy') else: foo.delete() On Mon, Apr 29, 2019 at 4:43 AM Jonathan Leroy - Inikup via Python-list wrote: > > Hi all, > > I'm writing a client library for a REST API. The API endpoints looks like this: > /customers > /customers/1 > /customers/1/update > /customers/1/delete > > Which of the following syntax do you expect an API client library to > use, and why? > > 1/ > api.customers_list() > api.customers_info(1) > api.customers_update(1, name='Bob') > api.customers_delete(1) > > 2/ > api.customers.list() > api.customers.info(1) > api.customers.update(1, name='Bob') > api.customers.delete(1) > > 3/ > api.customers.list() > api.customers(1).info() > api.customers(1).update(name='Bob') > api.customers(1).delete() > > ...any other? > > #3 seems to be more "pretty" to me, but I did not find any "official" > recommendation online. > > Thanks. > > -- > Jonathan. > -- > https://mail.python.org/mailman/listinfo/python-list -- Dotan Cohen http://gibberish.co.il http://what-is-what.com From nimbiotics at gmail.com Tue May 14 10:59:00 2019 From: nimbiotics at gmail.com (Mario R. Osorio) Date: Tue, 14 May 2019 07:59:00 -0700 (PDT) Subject: help plz In-Reply-To: References: Message-ID: On Monday, May 13, 2019 at 8:32:38 AM UTC-4, Tristan Cribaro wrote: > [image: image.png]so I have a project I have to work on that is due > tomorrow for a lot of points towards my grade. The issue here is I've been > trying to download Pillow and simple audio for my project and I keep > getting the same error. any ideas? i use pycharm The most common error I've seen while installing Pillow is due to the fact that you need to be able to compile part of its code and you might not have that privilege in your working environment. However, that is just a wild guess and you do need to give us more information. From eraygezer.94 at gmail.com Tue May 14 06:30:00 2019 From: eraygezer.94 at gmail.com (Eray Erdin) Date: Tue, 14 May 2019 13:30:00 +0300 Subject: [Project Announcement] tglogger: Sending Live Logging Records to A Python Chat Message-ID: I hereby announce my new project called tglogger to Python community. Check it out here . *What It Does* tglogger contains custom handler and formatter implementations in order to send logging records directly to a chat, which means you get logging feed from your application almost instantly. *Features* - The message has hashtags so that you can search chat history easily. - Can be integrated with Django. Even date time stamp in the message is integrated to Django's settings. - Message contains detailed info about log record, such as hashtagged level, which file and line the log was captured, under which method or function the log occured, information about process and thread. Contributions, reviews and usages are very welcome. Have a good day. From rishabhm120497 at gmail.com Tue May 14 03:18:56 2019 From: rishabhm120497 at gmail.com (Rishabh Mishra) Date: Tue, 14 May 2019 12:48:56 +0530 Subject: PYTHONHASHSEED VALUE Message-ID: Dear Sir/Ma'am, I was upgrading a codebase from python2 to python3. The testcases fail in python3 code because the set() function produces a different order from python2. e.g. set in py2 ={"it","is","rishabh","Mishra"} Here in python 2.7 the PYTHONHASHSEED is disabled. in py3 set ={"rishabh","it","is","mishra"} I want the order to stay consistent with python2.7 to pass the test cases. In python 3.3 above PYTHONHASHSEED=0 disbales the random shuffling but it doesn't yield the same order as 2.7 So can you tell me for what value of PYTHONHASHSEED the order will stay consistent? Thank-You! Yours sincerely, Rishabh Mishra From rishabhm120497 at gmail.com Tue May 14 05:46:46 2019 From: rishabhm120497 at gmail.com (Rishabh Mishra) Date: Tue, 14 May 2019 15:16:46 +0530 Subject: PYTHONHASHSEED VALUE Message-ID: Dear Sir/Ma'am, I was upgrading a codebase from python2 to python3. The testcases fail in python3 code because the set() function produces a different order from python2. e.g. set in py2 ={"it","is","rishabh","Mishra"} Here in python 2.7 the PYTHONHASHSEED is disabled. in py3 set ={"rishabh","it","is","mishra"} I want the order to stay consistent with python2.7 to pass the test cases. In python 3.3 above PYTHONHASHSEED=0 disbales the random shuffling but it doesn't yield the same order as 2.7 So can you tell me for what value of PYTHONHASHSEED the order will stay consistent? Thank-You! Yours sincerely, Rishabh Mishra From zacharia.adelaide at gmail.com Tue May 14 04:30:12 2019 From: zacharia.adelaide at gmail.com (Zacharia Khan) Date: Tue, 14 May 2019 18:00:12 +0930 Subject: not working Message-ID: python is not working for me can you help fix it From vinay_sajip at yahoo.co.uk Tue May 14 12:26:43 2019 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 14 May 2019 16:26:43 +0000 (UTC) Subject: ANN: distlib 0.2.9 released on PyPI References: <650084286.676458.1557851203840.ref@mail.yahoo.com> Message-ID: <650084286.676458.1557851203840@mail.yahoo.com> I've recently released version 0.2.9 of distlib on PyPI [1]. For newcomers,distlib is a library of packaging functionality which is intended to beusable as the basis for third-party packaging tools. The main changes in this release are as follows: * Updated default PyPI URL to https://pypi.org/pypi. * Relaxed metadata format checks to ignore 'Provides'. * Fixed #33, #34: simplified script template. * Fixed #115: Relaxed check for '..' in wheel archive entries by not? checking filename parts, only directory segments. * Fixed #116: Corrected parsing of credentials from URLs. * Fixed #122: Skipped entries in archive entries ending with '/' (directories)? when verifying or installing. * Commented out Disqus comment section in documentation. A more detailed change log is available at [2]. Please try it out, and if you find any problems or have any suggestions for improvements,please give some feedback using the issue tracker! [3] Regards, Vinay Sajip [1] https://pypi.org/project/distlib/0.2.9/[2] https://distlib.readthedocs.io/en/latest/overview.html#change-log-for-distlib[3] https://bitbucket.org/pypa/distlib/issues/new From grant.b.edwards at gmail.com Tue May 14 12:42:53 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 14 May 2019 16:42:53 -0000 (UTC) Subject: not working References: Message-ID: On 2019-05-14, Zacharia Khan wrote: > python is not working for me can you help fix it Yes. -- Grant Edwards grant.b.edwards Yow! Hello, GORRY-O!! at I'm a GENIUS from HARVARD!! gmail.com From David.Raymond at tomtom.com Tue May 14 12:57:01 2019 From: David.Raymond at tomtom.com (David Raymond) Date: Tue, 14 May 2019 16:57:01 +0000 Subject: PYTHONHASHSEED VALUE In-Reply-To: References: Message-ID: What is the test case actually checking for, and why? One of the main aspects of a set is that it's unordered. So something checking to make sure the order of an unordered object is some static value seems like it's testing for the wrong thing. -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Rishabh Mishra Sent: Tuesday, May 14, 2019 5:47 AM To: python-list at python.org Subject: PYTHONHASHSEED VALUE Dear Sir/Ma'am, I was upgrading a codebase from python2 to python3. The testcases fail in python3 code because the set() function produces a different order from python2. e.g. set in py2 ={"it","is","rishabh","Mishra"} Here in python 2.7 the PYTHONHASHSEED is disabled. in py3 set ={"rishabh","it","is","mishra"} I want the order to stay consistent with python2.7 to pass the test cases. In python 3.3 above PYTHONHASHSEED=0 disbales the random shuffling but it doesn't yield the same order as 2.7 So can you tell me for what value of PYTHONHASHSEED the order will stay consistent? Thank-You! Yours sincerely, Rishabh Mishra -- https://mail.python.org/mailman/listinfo/python-list From ikorot01 at gmail.com Tue May 14 13:03:31 2019 From: ikorot01 at gmail.com (Igor Korot) Date: Tue, 14 May 2019 12:03:31 -0500 Subject: not working In-Reply-To: References: Message-ID: On Tue, May 14, 2019 at 11:45 AM Grant Edwards wrote: > > On 2019-05-14, Zacharia Khan wrote: > > > python is not working for me can you help fix it "Help" given. Thank you. > > Yes. > > -- > Grant Edwards grant.b.edwards Yow! Hello, GORRY-O!! > at I'm a GENIUS from HARVARD!! > gmail.com > > -- > https://mail.python.org/mailman/listinfo/python-list From * at eli.users.panix.com Tue May 14 13:02:38 2019 From: * at eli.users.panix.com (Eli the Bearded) Date: Tue, 14 May 2019 17:02:38 +0000 (UTC) Subject: convert .py to Android ? References: <008401d50a18$15af4ac0$410de040$@SGA.Ninja> <86zhnptpwh.fsf@benfinney.id.au> Message-ID: In comp.lang.python, Ben Finney wrote: > "Steve" writes: >> I have a working .py program >> that I want to get into my Android Moto G phone. > To my knowledge, an Android app must be implemented, at some level, in > Java and specifically linked to Android Java libraries. That's a hard > limitation of the Android platform. > > That implies that any Python program will need to be written at least > with partial awareness that it is not going to run in a native Python > VM, but instead get compiled to somehow run in a Java Android environment. If it doesn't have a GUI, the easy solution is put Termux on the phone, run "pkg install python" (or python2), then install 'curl' or 'ssh' (for scp) to transfer the program over. I use Termux scripts on my phone for image preprocessing (namely strip exif and downscale) prior to using my photos on the open web. Elijah ------ also uses Termux as an ssh client From hjp-python at hjp.at Tue May 14 17:12:46 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Tue, 14 May 2019 23:12:46 +0200 Subject: Help? How do i solve this problem with Python List Concept In-Reply-To: <875zqgzouo.fsf@bsb.me.uk> References: <2dd0e66c-af98-4455-9d76-dc4325f32ac1@googlegroups.com> <875zqgzouo.fsf@bsb.me.uk> Message-ID: <20190514211246.r3z52ne5saqmimoy@hjp.at> On 2019-05-11 22:02:39 +0100, Ben Bacarisse wrote: > Donald Tripdarlinq writes: > > In the traditional Yoruba tribal Set-Up in Nigeria,West Africa the > > tradition of inheritance is very important. Now, The relative position > > of a child in the family counts when the issue of inheritance is > > considered. > > > > Question: Now a farmer with 10 children died without leaving a will > > and the Family "Ebi"(Which consist of the extended family) decided > > that the property would be in proportion of their respective age. The > > Children were born with 3 years intervals except the second to last > > and the last born with the interval of 2 and 4 years respectively. Use > > the concept of list to write a simple python program to generate the > > individual children inheritance if the man left N230,000 Before his > > death > > You need a little more than that. If the inheritance is to be in > proportion to the ages, you need to know at least one actual age, rather > than just the age gaps. The iron law of school maths problems says that all problems must have a nice solution. This usually means something like ? or e, but in this case we'll just settle for integers. So the sum of the ages of the children must be a divisor of 230000. We can easily work out that the sum must be 10n + 9*4 + 8*2 + (7 + 6 + 5 + 4 + 3 + 2 + 1) * 3 (the details are left as an exercise for the reader) and we can therefore compute the age of the youngest child: #!/usr/bin/python3 def f(): n = 0 while True: s = 10 * n + 136 if 230000 % s == 0: print(n) if s > 230000: return n += 1 f() This immediately returns an empty result. Which means that there is an error in the problem statement. Finding the teacher's mistakes is of course every students favourite pastime and teachers try to please their students by making trivial mistakes, like swapping two numbers. And indeed, if we swap the age gaps between the youngest children, we get nice round numbers: The youngest child is 5, the oldest 32, and the divisor is 1250. So the youngest inherits 6250 NGN, the oldest 40000 NGN, and the rest are trivial to compute. You owe the Oracle a first print of "Rechnung auff der Linihen und Federn" and the first-born of a Nigerian princess. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From chip at gct3engineering.com Tue May 14 13:22:54 2019 From: chip at gct3engineering.com (Chip Towner) Date: Tue, 14 May 2019 11:22:54 -0600 Subject: Tkinter on Mac OS crashes python Message-ID: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> I am trying to use tkinter and when I attempt to do so Python crashes. I am accessing Python (v 3.6.8) in Spyder (v3.6) from Anaconda. The version of TkVersion tells me the version is 8.6 and the Anaconda environment browser tells me it is 8.6.8. An example piece of code I am trying to run (pulled from the __init__.py file in the tkinter code installed by Anaconda) is provided below. The code crashes when tk = tkinter.Tk() is called. I have traced the crash into this method to a call to _tkinter.create(). The debugger can?t step any further. I can provide crash logs if desired. Any help is appreciated. import tkinter from tkinter.constants import * tk = tkinter.Tk() frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2) frame.pack(fill=BOTH,expand=1) label = tkinter.Label(frame, text="Hello, World") label.pack(fill=X, expand=1) button = tkinter.Button(frame,text="Exit",command=tk.destroy) button.pack(side=BOTTOM) tk.mainloop() Chip From rosuav at gmail.com Tue May 14 21:25:57 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 May 2019 11:25:57 +1000 Subject: Tkinter on Mac OS crashes python In-Reply-To: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> Message-ID: On Wed, May 15, 2019 at 11:13 AM Chip Towner wrote: > > I am trying to use tkinter and when I attempt to do so Python crashes. I am accessing Python (v 3.6.8) in Spyder (v3.6) from Anaconda. The version of TkVersion tells me the version is 8.6 and the Anaconda environment browser tells me it is 8.6.8. > > An example piece of code I am trying to run (pulled from the __init__.py file in the tkinter code installed by Anaconda) is provided below. The code crashes when tk = tkinter.Tk() is called. I have traced the crash into this method to a call to _tkinter.create(). The debugger can?t step any further. > Possibly significant: This is not the Python provided by Mac OS; you have multiple installations of Python. Can you try this, please? >>> import sys, tkinter >>> sys.executable, tkinter.__file__ Might be that you're getting tkinter from a different installation, which could break all manner of things. Might be not, too, but worth checking. ChrisA From best_lay at yahoo.com Tue May 14 21:27:20 2019 From: best_lay at yahoo.com (Wildman) Date: Tue, 14 May 2019 20:27:20 -0500 Subject: Tkinter on Mac OS crashes python References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> Message-ID: On Tue, 14 May 2019 11:22:54 -0600, Chip Towner wrote: > I am trying to use tkinter and when I attempt to do so Python crashes. I am accessing Python (v 3.6.8) in Spyder (v3.6) from Anaconda. The version of TkVersion tells me the version is 8.6 and the Anaconda environment browser tells me it is 8.6.8. > > An example piece of code I am trying to run (pulled from the __init__.py file in the tkinter code installed by Anaconda) is provided below. The code crashes when tk = tkinter.Tk() is called. I have traced the crash into this method to a call to _tkinter.create(). The debugger can?t step any further. > > I can provide crash logs if desired. Any help is appreciated. > > import tkinter > from tkinter.constants import * > tk = tkinter.Tk() > frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2) > frame.pack(fill=BOTH,expand=1) > label = tkinter.Label(frame, text="Hello, World") > label.pack(fill=X, expand=1) > button = tkinter.Button(frame,text="Exit",command=tk.destroy) > button.pack(side=BOTTOM) > tk.mainloop() > > Chip You might need to add... from tkinter import Tk -- GNU/Linux user #557453 The cow died so I don't need your bull! From tjreedy at udel.edu Wed May 15 00:46:23 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 May 2019 00:46:23 -0400 Subject: Tkinter on Mac OS crashes python In-Reply-To: References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> Message-ID: On 5/14/2019 9:27 PM, Wildman via Python-list wrote: > On Tue, 14 May 2019 11:22:54 -0600, Chip Towner wrote: > >> I am trying to use tkinter and when I attempt to do so Python crashes. I am accessing Python (v 3.6.8) in Spyder (v3.6) from Anaconda. The version of TkVersion tells me the version is 8.6 and the Anaconda environment browser tells me it is 8.6.8. >> >> An example piece of code I am trying to run (pulled from the __init__.py file in the tkinter code installed by Anaconda) is provided below. The code crashes when tk = tkinter.Tk() is called. I have traced the crash into this method to a call to _tkinter.create(). The debugger can?t step any further. >> >> I can provide crash logs if desired. Any help is appreciated. >> >> import tkinter >> from tkinter.constants import * >> tk = tkinter.Tk() >> frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2) >> frame.pack(fill=BOTH,expand=1) >> label = tkinter.Label(frame, text="Hello, World") >> label.pack(fill=X, expand=1) >> button = tkinter.Button(frame,text="Exit",command=tk.destroy) >> button.pack(side=BOTTOM) >> tk.mainloop() >> >> Chip > > You might need to add... > > from tkinter import Tk No, Tk is a class defined in tkinter.py. -- Terry Jan Reedy From tjreedy at udel.edu Wed May 15 00:59:39 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 May 2019 00:59:39 -0400 Subject: Tkinter on Mac OS crashes python In-Reply-To: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> Message-ID: On 5/14/2019 1:22 PM, Chip Towner wrote: > I am trying to use tkinter and when I attempt to do so Python crashes. I am accessing Python (v 3.6.8) in Spyder (v3.6) from Anaconda. The version of TkVersion tells me the version is 8.6 and the Anaconda environment browser tells me it is 8.6.8. Before releasing the PSF 3.6.8 Mac installer on python.org, Ned Deily experimented with different recent tcl/builds to pick the one that worked best. (I believe there are different builds with the designation 8.6.8). What he choose was not the most recent version available. One issue is that different builds worked best with the then new macOS version (Mohave?) and earlier versions. (You did not say which you are running.) I presume tkinter.Tk() ran on all versions he tested, as that is needed for any tkinter program. If Anaconda installs any build of tcl/tk other than the one istalled by the 'official' installer, then they should deal with this issus. You could try installing from the python.org installer and test again. -- Terry Jan Reedy From Irv at furrypants.com Wed May 15 13:52:35 2019 From: Irv at furrypants.com (Irv Kalb) Date: Wed, 15 May 2019 10:52:35 -0700 Subject: Instance vs Class variable oddity Message-ID: I just saw some code that confused me. The confusion has to do with class variables and instance variables. In order to understand it better, I built this very small example: class Test: x = 0 def __init__(self, id): self.id = id self.show() def show(self): print('ID:', self.id, 'self.x is:', self.x) def increment(self): self.x = self.x + 1 # Create two instances of the Test object, each shows itself t1 = Test('first') t2 = Test('second') # Ask t1 to increment itself twice t1.increment() t1.increment() # Ask each to show themselves t1.show() t2.show() # Let's see what the class has print('Test.x is:', Test.x) When I instantiate two objects (t1 and t2), the __init__ method calls the show method, which prints a value of self.x. I'm not understanding why this is legal. I would expect that I would get an error message saying that self.x does not exist, since no instance variable named self.x has been defined. However, this code runs fine, and gives the following output: ID: first self.x is: 0 ID: second self.x is: 0 ID: first self.x is: 2 ID: second self.x is: 0 Test.x is: 0 My guess is that there is some scoping rule that says that if there is no instance variable by a given name, then see if there is one in the class. If that is the case, then this line in the increment method seems odd: self.x = self.x + 1 If the self.x on the right hand side refers to the class variable, and creates an instance variable called self.x on the left hand side, then how does the second call work using the value of the instance variable on the right hand side? Can someone explain what's going on here? Disclaimer: I would never write code like this, but I saw this in someone else's code and didn't understand how it was working. Irv From rgaddi at highlandtechnology.invalid Wed May 15 14:02:55 2019 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Wed, 15 May 2019 11:02:55 -0700 Subject: Instance vs Class variable oddity In-Reply-To: References: Message-ID: On 5/15/19 10:52 AM, Irv Kalb wrote: > I just saw some code that confused me. The confusion has to do with class variables and instance variables. In order to understand it better, I built this very small example: > > > class Test: > x = 0 > > def __init__(self, id): > self.id = id > self.show() > > def show(self): > print('ID:', self.id, 'self.x is:', self.x) > > def increment(self): > self.x = self.x + 1 > > > # Create two instances of the Test object, each shows itself > t1 = Test('first') > t2 = Test('second') > > # Ask t1 to increment itself twice > t1.increment() > t1.increment() > > # Ask each to show themselves > t1.show() > t2.show() > > # Let's see what the class has > print('Test.x is:', Test.x) > > > When I instantiate two objects (t1 and t2), the __init__ method calls the show method, which prints a value of self.x. I'm not understanding why this is legal. I would expect that I would get an error message saying that self.x does not exist, since no instance variable named self.x has been defined. > > However, this code runs fine, and gives the following output: > > ID: first self.x is: 0 > ID: second self.x is: 0 > ID: first self.x is: 2 > ID: second self.x is: 0 > Test.x is: 0 > > My guess is that there is some scoping rule that says that if there is no instance variable by a given name, then see if there is one in the class. If that is the case, then this line in the increment method seems odd: > > self.x = self.x + 1 > > If the self.x on the right hand side refers to the class variable, and creates an instance variable called self.x on the left hand side, then how does the second call work using the value of the instance variable on the right hand side? Can someone explain what's going on here? > Pretty much exactly like that. The first time you call t1.increment, you fail to find x in the instance dictionary, fall back and find it equal to 0, add 1 makes 1, and store x=1 into the instance dictionary. The second time, you find x=1 in the instance dictionary, add 1 makes 2, and overwrite x=2 into the instance dictionary. You never call increment on t2, so it never gets an x in its instance dictionary, so t2.x still refers to Test.x. > Disclaimer: I would never write code like this, but I saw this in someone else's code and didn't understand how it was working. > Sometimes when I'm feeling lazy it's a convenient way to set defaults on instance variables. I don't love it, but I also can't explain what I find wrong with it. > Irv > > > -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From chip at gct3engineering.com Wed May 15 14:25:39 2019 From: chip at gct3engineering.com (Chip Towner) Date: Wed, 15 May 2019 12:25:39 -0600 Subject: Tkinter on Mac OS crashes python In-Reply-To: References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> Message-ID: <26B6EBAD-7927-4934-A163-93AF85CE0B46@gct3engineering.com> Terry, Thanks for the input and FYI I am running 10.14.4 Mojave. When I looked at the version of tkinter as suggested by Chris Angelico earlier in this thread it returned '/Users/chip/anaconda3/lib/python3.6/tkinter/__init__.py?. This is obviously not he build Apple provided and I believe Apple?s version of python is version 2.7 and I need to use 3.6 for my current efforts. I will reach out to Anaconda to see if they have any thoughts and will look into the Python.org installers. Will look at the Python.org installers also. Thanks! Chip Towner chip at gct3engineering.com > On May 14, 2019, at 22:59, Terry Reedy wrote: > > On 5/14/2019 1:22 PM, Chip Towner wrote: >> I am trying to use tkinter and when I attempt to do so Python crashes. I am accessing Python (v 3.6.8) in Spyder (v3.6) from Anaconda. The version of TkVersion tells me the version is 8.6 and the Anaconda environment browser tells me it is 8.6.8. > > Before releasing the PSF 3.6.8 Mac installer on python.org, Ned Deily experimented with different recent tcl/builds to pick the one that worked best. (I believe there are different builds with the designation 8.6.8). What he choose was not the most recent version available. One issue is that different builds worked best with the then new macOS version (Mohave?) and earlier versions. (You did not say which you are running.) I presume tkinter.Tk() ran on all versions he tested, as that is needed for any tkinter program. > > If Anaconda installs any build of tcl/tk other than the one istalled by the 'official' installer, then they should deal with this issus. > > You could try installing from the python.org installer and test again. > > -- > Terry Jan Reedy > > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Wed May 15 14:31:46 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 May 2019 04:31:46 +1000 Subject: Tkinter on Mac OS crashes python In-Reply-To: <26B6EBAD-7927-4934-A163-93AF85CE0B46@gct3engineering.com> References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> <26B6EBAD-7927-4934-A163-93AF85CE0B46@gct3engineering.com> Message-ID: On Thu, May 16, 2019 at 4:27 AM Chip Towner wrote: > > Terry, > Thanks for the input and FYI I am running 10.14.4 Mojave. When I looked at the version of tkinter as suggested by Chris Angelico earlier in this thread it returned '/Users/chip/anaconda3/lib/python3.6/tkinter/__init__.py?. This is obviously not he build Apple provided and I believe Apple?s version of python is version 2.7 and I need to use 3.6 for my current efforts. > Okay, that looks good - it means you're getting tkinter from the same place that you're getting Python from. > I will reach out to Anaconda to see if they have any thoughts and will look into the Python.org installers. Will look at the Python.org installers also. > Yeah, try the vanilla installers before reaching out to Anaconda. Or use "brew install python". ChrisA From tjreedy at udel.edu Wed May 15 16:58:17 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 May 2019 16:58:17 -0400 Subject: Tkinter on Mac OS crashes python In-Reply-To: <26B6EBAD-7927-4934-A163-93AF85CE0B46@gct3engineering.com> References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> <26B6EBAD-7927-4934-A163-93AF85CE0B46@gct3engineering.com> Message-ID: On 5/15/2019 2:25 PM, Chip Towner wrote: > Terry, > Thanks for the input and FYI I am running 10.14.4 Mojave. When I looked at the version of tkinter as suggested by Chris Angelico earlier in this thread it returned '/Users/chip/anaconda3/lib/python3.6/tkinter/__init__.py?. This is obviously not he build Apple provided and I believe Apple?s version of python is version 2.7 and I need to use 3.6 for my current efforts. FYI: Apple's version of python comes with a version of tcl/tk that does not work with Apple's current graphics. Apple does not care because Apple does not use tkinter/tk. Hence, even if one does want to use 2.7, and tkinter with it, one must install a newer tcl/tk 8.5 compiled for macOS. The same is true for early 3.6 releases and before. There is a webpage linked on the download page that explains. Mac users should best ignore the system Python and install something else. -- Terry Jan Reedy From amoxletne5 at gmail.com Wed May 15 17:31:46 2019 From: amoxletne5 at gmail.com (amoxletne5 at gmail.com) Date: Wed, 15 May 2019 14:31:46 -0700 (PDT) Subject: Can someone help me paral/accelerate this code for Cuda? Message-ID: <829954bc-1e49-46f4-add9-9a5b43279b06@googlegroups.com> It?s pretty darn slow. I don?t think it?s optimizing the Nvidia Tesla v100 power. It uses some openCv , and it just screams for paral/acceleration. I?d also love to learn and see how it?s done import cv2 import numpy as np import os import pickle import sys from cgls import cgls from filterplot import filterplot from gaussian2d import gaussian2d from gettrainargs import gettrainargs from hashkey import hashkey from math import floor from matplotlib import pyplot as plt from scipy import interpolate from skimage import transform args = gettrainargs() # Define parameters R = 2 patchsize = 11 gradientsize = 9 Qangle = 24 Qstrength = 3 Qcoherence = 3 trainpath = 'train' # Calculate the margin maxblocksize = max(patchsize, gradientsize) margin = floor(maxblocksize/2) patchmargin = floor(patchsize/2) gradientmargin = floor(gradientsize/2) Q = np.zeros((Qangle, Qstrength, Qcoherence, R*R, patchsize*patchsize, patchsize*patchsize)) V = np.zeros((Qangle, Qstrength, Qcoherence, R*R, patchsize*patchsize)) h = np.zeros((Qangle, Qstrength, Qcoherence, R*R, patchsize*patchsize)) # Read Q,V from file if args.qmatrix: with open(args.qmatrix, "rb") as fp: Q = pickle.load(fp) if args.vmatrix: with open(args.vmatrix, "rb") as fp: V = pickle.load(fp) # Matrix preprocessing # Preprocessing normalized Gaussian matrix W for hashkey calculation weighting = gaussian2d([gradientsize, gradientsize], 2) weighting = np.diag(weighting.ravel()) # Get image list imagelist = [] for parent, dirnames, filenames in os.walk(trainpath): for filename in filenames: if filename.lower().endswith(('.bmp', '.dib', '.png', '.jpg', '.jpeg', '.pbm', '.pgm', '.ppm', '.tif', '.tiff')): imagelist.append(os.path.join(parent, filename)) # Compute Q and V imagecount = 1 for image in imagelist: print('\r', end='') print(' ' * 60, end='') print('\rProcessing image ' + str(imagecount) + ' of ' + str(len(imagelist)) + ' (' + image + ')') origin = cv2.imread(image) # Extract only the luminance in YCbCr grayorigin = cv2.cvtColor(origin, cv2.COLOR_BGR2YCrCb)[:,:,0] # Normalized to [0,1] grayorigin = cv2.normalize(grayorigin.astype('float'), None, grayorigin.min()/255, grayorigin.max()/255, cv2.NORM_MINMAX) # Downscale (bicubic interpolation) height, width = grayorigin.shape LR = transform.resize(grayorigin, (floor((height+1)/2),floor((width+1)/2)), mode='reflect', anti_aliasing=False) # Upscale (bilinear interpolation) height, width = LR.shape heightgrid = np.linspace(0, height-1, height) widthgrid = np.linspace(0, width-1, width) bilinearinterp = interpolate.interp2d(widthgrid, heightgrid, LR, kind='linear') heightgrid = np.linspace(0, height-1, height*2-1) widthgrid = np.linspace(0, width-1, width*2-1) upscaledLR = bilinearinterp(widthgrid, heightgrid) # Calculate A'A, A'b and push them into Q, V height, width = upscaledLR.shape operationcount = 0 totaloperations = (height-2*margin) * (width-2*margin) for row in range(margin, height-margin): for col in range(margin, width-margin): if round(operationcount*100/totaloperations) != round((operationcount+1)*100/totaloperations): print('\r|', end='') print('#' * round((operationcount+1)*100/totaloperations/2), end='') print(' ' * (50 - round((operationcount+1)*100/totaloperations/2)), end='') print('| ' + str(round((operationcount+1)*100/totaloperations)) + '%', end='') sys.stdout.flush() operationcount += 1 # Get patch patch = upscaledLR[row-patchmargin:row+patchmargin+1, col-patchmargin:col+patchmargin+1] patch = np.matrix(patch.ravel()) # Get gradient block gradientblock = upscaledLR[row-gradientmargin:row+gradientmargin+1, col-gradientmargin:col+gradientmargin+1] # Calculate hashkey angle, strength, coherence = hashkey(gradientblock, Qangle, weighting) # Get pixel type pixeltype = ((row-margin) % R) * R + ((col-margin) % R) # Get corresponding HR pixel pixelHR = grayorigin[row,col] # Compute A'A and A'b ATA = np.dot(patch.T, patch) ATb = np.dot(patch.T, pixelHR) ATb = np.array(ATb).ravel() # Compute Q and V Q[angle,strength,coherence,pixeltype] += ATA V[angle,strength,coherence,pixeltype] += ATb imagecount += 1 # Write Q,V to file with open("q.p", "wb") as fp: pickle.dump(Q, fp) with open("v.p", "wb") as fp: pickle.dump(V, fp) # Preprocessing permutation matrices P for nearly-free 8x more learning examples print('\r', end='') print(' ' * 60, end='') print('\rPreprocessing permutation matrices P for nearly-free 8x more learning examples ...') sys.stdout.flush() P = np.zeros((patchsize*patchsize, patchsize*patchsize, 7)) rotate = np.zeros((patchsize*patchsize, patchsize*patchsize)) flip = np.zeros((patchsize*patchsize, patchsize*patchsize)) for i in range(0, patchsize*patchsize): i1 = i % patchsize i2 = floor(i / patchsize) j = patchsize * patchsize - patchsize + i2 - patchsize * i1 rotate[j,i] = 1 k = patchsize * (i2 + 1) - i1 - 1 flip[k,i] = 1 for i in range(1, 8): i1 = i % 4 i2 = floor(i / 4) P[:,:,i-1] = np.linalg.matrix_power(flip,i2).dot(np.linalg.matrix_power(rotate,i1)) Qextended = np.zeros((Qangle, Qstrength, Qcoherence, R*R, patchsize*patchsize, patchsize*patchsize)) Vextended = np.zeros((Qangle, Qstrength, Qcoherence, R*R, patchsize*patchsize)) for pixeltype in range(0, R*R): for angle in range(0, Qangle): for strength in range(0, Qstrength): for coherence in range(0, Qcoherence): for m in range(1, 8): m1 = m % 4 m2 = floor(m / 4) newangleslot = angle if m2 == 1: newangleslot = Qangle-angle-1 newangleslot = int(newangleslot-Qangle/2*m1) while newangleslot < 0: newangleslot += Qangle newQ = P[:,:,m-1].T.dot(Q[angle,strength,coherence,pixeltype]).dot(P[:,:,m-1]) newV = P[:,:,m-1].T.dot(V[angle,strength,coherence,pixeltype]) Qextended[newangleslot,strength,coherence,pixeltype] += newQ Vextended[newangleslot,strength,coherence,pixeltype] += newV Q += Qextended V += Vextended # Compute filter h print('Computing h ...') sys.stdout.flush() operationcount = 0 totaloperations = R * R * Qangle * Qstrength * Qcoherence for pixeltype in range(0, R*R): for angle in range(0, Qangle): for strength in range(0, Qstrength): for coherence in range(0, Qcoherence): if round(operationcount*100/totaloperations) != round((operationcount+1)*100/totaloperations): print('\r|', end='') print('#' * round((operationcount+1)*100/totaloperations/2), end='') print(' ' * (50 - round((operationcount+1)*100/totaloperations/2)), end='') print('| ' + str(round((operationcount+1)*100/totaloperations)) + '%', end='') sys.stdout.flush() operationcount += 1 h[angle,strength,coherence,pixeltype] = cgls(Q[angle,strength,coherence,pixeltype], V[angle,strength,coherence,pixeltype]) # Write filter to file with open("filter.p", "wb") as fp: pickle.dump(h, fp) # Plot the learned filters if args.plot: filterplot(h, R, Qangle, Qstrength, Qcoherence, patchsize) print('\r', end='') print(' ' * 60, end='') print('\rFinished.') From Irv at furrypants.com Wed May 15 17:44:08 2019 From: Irv at furrypants.com (Irv Kalb) Date: Wed, 15 May 2019 14:44:08 -0700 Subject: Instance vs Class variable oddity In-Reply-To: References: Message-ID: <82068836-0225-4860-B00D-9C8D77946671@furrypants.com> > On May 15, 2019, at 11:02 AM, Rob Gaddi wrote: > > On 5/15/19 10:52 AM, Irv Kalb wrote: >> I just saw some code that confused me. The confusion has to do with class variables and instance variables. In order to understand it better, I built this very small example: >> class Test: >> x = 0 >> def __init__(self, id): >> self.id = id >> self.show() >> def show(self): >> print('ID:', self.id, 'self.x is:', self.x) >> def increment(self): >> self.x = self.x + 1 >> # Create two instances of the Test object, each shows itself >> t1 = Test('first') >> t2 = Test('second') >> # Ask t1 to increment itself twice >> t1.increment() >> t1.increment() >> # Ask each to show themselves >> t1.show() >> t2.show() >> # Let's see what the class has >> print('Test.x is:', Test.x) >> When I instantiate two objects (t1 and t2), the __init__ method calls the show method, which prints a value of self.x. I'm not understanding why this is legal. I would expect that I would get an error message saying that self.x does not exist, since no instance variable named self.x has been defined. >> However, this code runs fine, and gives the following output: >> ID: first self.x is: 0 >> ID: second self.x is: 0 >> ID: first self.x is: 2 >> ID: second self.x is: 0 >> Test.x is: 0 >> My guess is that there is some scoping rule that says that if there is no instance variable by a given name, then see if there is one in the class. If that is the case, then this line in the increment method seems odd: >> self.x = self.x + 1 >> If the self.x on the right hand side refers to the class variable, and creates an instance variable called self.x on the left hand side, then how does the second call work using the value of the instance variable on the right hand side? Can someone explain what's going on here? > > Pretty much exactly like that. The first time you call t1.increment, you fail to find x in the instance dictionary, fall back and find it equal to 0, add 1 makes 1, and store x=1 into the instance dictionary. > > The second time, you find x=1 in the instance dictionary, add 1 makes 2, and overwrite x=2 into the instance dictionary. > > You never call increment on t2, so it never gets an x in its instance dictionary, so t2.x still refers to Test.x. > >> Disclaimer: I would never write code like this, but I saw this in someone else's code and didn't understand how it was working. > > Sometimes when I'm feeling lazy it's a convenient way to set defaults on instance variables. I don't love it, but I also can't explain what I find wrong with it. > >> Irv >> > Thanks for the confirmation. I still think its weird to have: self.x = self.x + 1 and have it refer to two potentially different variables at different times, but at least I understand what's going on. Irv From ben+python at benfinney.id.au Wed May 15 20:41:47 2019 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 16 May 2019 10:41:47 +1000 Subject: Instance vs Class variable oddity References: Message-ID: <86r28ztelw.fsf@benfinney.id.au> Irv Kalb writes: > I just saw some code that confused me. The confusion has to do with > class variables and instance variables. (Perhaps unrelated, but here's another confusion you may be suffering from: There's no such thing as a ?class variable? or ?instance variable?. In Python, a ?variable? is always a *binding* between a name and and object. The ?variable? has no concept of different types.) > When I instantiate two objects (t1 and t2), the __init__ method calls > the show method, which prints a value of self.x. That's right. The ?__init__? method initialises an already-created instance, and so has the same access any other instance method has. > I'm not understanding why this is legal. I would expect that I would > get an error message saying that self.x does not exist, since no > instance variable named self.x has been defined. Note that you're not calling the initialiser (?__init__?) directly. Also note that the initialiser receives, as its first argument, the already-existing instance. So something has already created that instance before calling the initialiser. The initialiser ?__init__? is called from the constructor (?__new__?), and this happens only *after the instance is created*. For details see the documentation for the constructor method, ?__new__?. > My guess is that there is some scoping rule that says that if there is > no instance variable by a given name, then see if there is one in the > class. Yes, though that is an entirely separate issue from when the initialiser gets called. You are correct that the scope resolution includes: * Does the attribute exist on this instance? * Does the attribute exist on this instance's class? and it continues with the class's superclass(es), and so on until it finds an attribute with that name. > If the self.x on the right hand side refers to the class variable For the purpose of resolving the value of the right hand side, yes. > and creates an instance variable called self.x on the left hand side Yes. (The correct terms are ?class attribute? and ?instance attribute?.) > then how does the second call work using the value of the instance > variable on the right hand side? I'm not sure I understand the confusion; once the instance has an attribute of that name, the same logic you outlined above applies when attempting to resolve that attribute. When ?self.x? exists on the instance, that's what will be used when resolving ?self.x?. I hope that helps. -- \ ?To me, boxing is like a ballet, except there's no music, no | `\ choreography, and the dancers hit each other.? ?Jack Handey | _o__) | Ben Finney From pauldubar at gmail.com Thu May 16 05:36:38 2019 From: pauldubar at gmail.com (pauldubar at gmail.com) Date: Thu, 16 May 2019 02:36:38 -0700 (PDT) Subject: Python installer hangs in Windows 7 In-Reply-To: References: <765703485.1601081.1486357381135.ref@mail.yahoo.com> <765703485.1601081.1486357381135@mail.yahoo.com> Message-ID: <90874aa4-8144-426f-91e6-b7e9cc61980c@googlegroups.com> On Monday, 6 February 2017 16:16:24 UTC+11, Jean-Claude Roy wrote: > ? I am trying to install Python 3.6.0 on a Windows 7 computer. > The download of 29.1 MB is successful and I get the nextwindow.? I?choose the "install now" selection and thatopens the Setup Program window. > Now the trouble starts:I get "Installing:" and the Initialization progress...and nothing else. > There is no additional disk activity, no progress on initialization, andeverything appears dead.? Even after 20 minutes there is zero progress. > I've repeated this as both a user and the administrator of this Windowscomputer.? I get the same results in either case. > If I go to the task manager it shows that Python 3.6.0 (32-bit) setup is running.? If I try to end the task Iget the message that the program is not responding. > Do you have any suggestions as to how I can get past this? > Thank you. Even for Python 3.7.3 same issue and Unchecking "Install launcher for all users" sorted things. From auriocus at gmx.de Thu May 16 16:39:42 2019 From: auriocus at gmx.de (Christian Gollwitzer) Date: Thu, 16 May 2019 22:39:42 +0200 Subject: Tkinter on Mac OS crashes python In-Reply-To: References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> <26B6EBAD-7927-4934-A163-93AF85CE0B46@gct3engineering.com> Message-ID: Am 15.05.19 um 20:25 schrieb Chip Towner: > Terry, > Thanks for the input and FYI I am running 10.14.4 Mojave. Apple changed a couple of APIs on Mojave (versus High Sierra) that made Tk stop working, when it was compiled with the Mojave SDK. Tk compiled against the High Sierra SDK continued to work. A lot of work was done by the Tk maintainers to fix this and hopefully now it should work again - the most recent release is Tk 8.6.9. So if you compile this yourself with the Mojave SDK, you should at least upgrade to Tcl/Tk 8.6.9. Still, direct crashing upon loading Tcl/Tk might be another problem; make sure that you compile tkinter against the same versiof of Python that you use it with. Christian From rshepard at appl-ecosys.com Thu May 16 17:50:50 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 16 May 2019 14:50:50 -0700 (PDT) Subject: Import module from a different subdirectory Message-ID: I'm developing a Python3 application using Python3-3.7.3 and virtualenv-16.5.0 on a Slackware-14.2 host. The project directory contains subdirectories, including gui/ (with the tkinter views) and classes/ with the SQLAlchemy model.py. Within the gui/ directory as the cwd testing the code for a view needs to import the 'model' module from the class/ subdirectory and I have not been able to use the correct syntax to import that module. The view module starts with: from classes import model as m import data_entry_validators from commonDlgs import LabelInput import tkinter as tk from tkinter import ttk from datetime import datetime When I try to display this UI view I get an error: $ python3 test_act_de.py Traceback (most recent call last): File "test_act_de.py", line 1, in from classes import model as m ModuleNotFoundError: No module named 'classes' Of course, 'classes' is a subdirectory not a module. My web searches have not found the proper syntax to import the 'model' module from the separate subdirectory classes and I need to learn how to do this. Regards, Rich From duncan at invalid.invalid Thu May 16 19:15:16 2019 From: duncan at invalid.invalid (duncan smith) Date: Fri, 17 May 2019 00:15:16 +0100 Subject: Import module from a different subdirectory In-Reply-To: References: Message-ID: <9amDE.86417$Kv5.36383@fx45.iad> On 16/05/2019 22:50, Rich Shepard wrote: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within the gui/ directory as the cwd testing the code for a view needs to > import the 'model' module from the class/ subdirectory and I have not been > able to use the correct syntax to import that module. The view module > starts > with: > > from classes import model as m > import data_entry_validators > from commonDlgs import LabelInput > > import tkinter as tk > from tkinter import ttk > from datetime import datetime > > When I try to display this UI view I get an error: > > $ python3 test_act_de.py Traceback (most recent call last): > ? File "test_act_de.py", line 1, in > ??? from classes import model as m > ModuleNotFoundError: No module named 'classes' > > Of course, 'classes' is a subdirectory not a module. My web searches have > not found the proper syntax to import the 'model' module from the separate > subdirectory classes and I need to learn how to do this. > > Regards, > > Rich You could make the subdirectories Python packages. Google (or better DuckDuckGo) is your friend. Duncan From python at mrabarnett.plus.com Thu May 16 19:24:39 2019 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 17 May 2019 00:24:39 +0100 Subject: Tkinter on Mac OS crashes python In-Reply-To: References: <5128013A-943E-4FA1-9A70-3FC1F6428CD5@gct3engineering.com> <26B6EBAD-7927-4934-A163-93AF85CE0B46@gct3engineering.com> Message-ID: On 2019-05-16 21:39, Christian Gollwitzer wrote: > Am 15.05.19 um 20:25 schrieb Chip Towner: >> Terry, >> Thanks for the input and FYI I am running 10.14.4 Mojave. > > Apple changed a couple of APIs on Mojave (versus High Sierra) that made > Tk stop working, when it was compiled with the Mojave SDK. Tk compiled > against the High Sierra SDK continued to work. A lot of work was done by > the Tk maintainers to fix this and hopefully now it should work again - > the most recent release is Tk 8.6.9. So if you compile this yourself > with the Mojave SDK, you should at least upgrade to Tcl/Tk 8.6.9. > > Still, direct crashing upon loading Tcl/Tk might be another problem; > make sure that you compile tkinter against the same versiof of Python > that you use it with. > FYI, there was also a change in Tcl/Tk 8.6.9 concerned with setting the colour of text in the Treeview widget: Issue 36468: Treeview: wrong color change - Python tracker https://bugs.python.org/issue36468 From rshepard at appl-ecosys.com Thu May 16 20:24:15 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 16 May 2019 17:24:15 -0700 (PDT) Subject: Import module from a different subdirectory In-Reply-To: <9amDE.86417$Kv5.36383@fx45.iad> References: <9amDE.86417$Kv5.36383@fx45.iad> Message-ID: On Fri, 17 May 2019, duncan smith wrote: > You could make the subdirectories Python packages. Google (or better > DuckDuckGo) is your friend. Duncan, My understanding is that Python3 does not require subdirectories to have an __init__.py file, only Python2 does. If that's not correct I'll add the blank file. Rich From dieter at handshake.de Fri May 17 00:57:28 2019 From: dieter at handshake.de (dieter) Date: Fri, 17 May 2019 06:57:28 +0200 Subject: Import module from a different subdirectory References: Message-ID: <87v9y9isp3.fsf@handshake.de> Rich Shepard writes: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within the gui/ directory as the cwd testing the code for a view needs to > import the 'model' module from the class/ subdirectory and I have not been > able to use the correct syntax to import that module. The view module starts > with: > > from classes import model as m > import data_entry_validators > from commonDlgs import LabelInput > > import tkinter as tk > from tkinter import ttk > from datetime import datetime > > When I try to display this UI view I get an error: > > $ python3 test_act_de.py Traceback (most recent call last): > File "test_act_de.py", line 1, in > from classes import model as m > ModuleNotFoundError: No module named 'classes' Recently, there has been a long discussion in this list about a similar topic. Use your favorit search engine to search for it. The likely cause for your problem is that viewed from the location of "test_act_de.py", "classes" is not a subdirectory. Either put your scripts in the top level folder of your project (such that "classes" and friends are subdirectories of the script containing folder) or extend "sys.path" in your scripts (before the imports) to contain this folder. From songofacandy at gmail.com Fri May 17 01:25:55 2019 From: songofacandy at gmail.com (Inada Naoki) Date: Fri, 17 May 2019 14:25:55 +0900 Subject: Import module from a different subdirectory In-Reply-To: References: <9amDE.86417$Kv5.36383@fx45.iad> Message-ID: 2019?5?17?(?) 9:25 Rich Shepard : > > My understanding is that Python3 does not require subdirectories to have an > __init__.py file, only Python2 does. If that's not correct I'll add the > blank file. > This is slightly off topic (not relating to your problem), but please don't think "Python 3 doesn't require __init__.py for packages". It is common misunderstanding. Package directory without __init__.py is "namespace package". Namespace package is not a regular package. See [1] for detail. [1]: https://packaging.python.org/guides/packaging-namespace-packages/ There are some difference between regular package and namespace package. They have different module search order. Testing tools including unittest doesn't search namespace package. (If they do, they may take minutes to search million files in `node_modules` directory in your project!) So abusing namespace package will bite you at some point. Regards, -- Inada Naoki From auriocus at gmx.de Fri May 17 02:57:50 2019 From: auriocus at gmx.de (Christian Gollwitzer) Date: Fri, 17 May 2019 08:57:50 +0200 Subject: repr = expression representation? In-Reply-To: References: Message-ID: Am 17.05.19 um 06:13 schrieb Stefan Ram: However, look at this > > |>>> print( str( print )) > | > > |>>> print( repr( print )) > | > > . While it is nice that ?str( print )? gives some useful > information, I would expect ?repr( print )? to give > ?print? - This is impossible. Python does not use "call by name", so a function cannot know how the argument is called in the upper stack level. Consider: Apfelkiste:inotes chris$ python3 Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> blafasel = print >>> print(repr(blafasel)) >>> You'll have to accept that not all Python objects can be represented as literals. While a user defined function /could/ be printed as a lambda, so expecting: def test(x): return 2*x print(repr(test)) -> lambda x : 2*x would be half-reasonable, it is impossible to print out the C source code of the built-in print function, unless one builds a JIT C compiler into Python. Christian From mal at europython.eu Fri May 17 03:27:37 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Fri, 17 May 2019 09:27:37 +0200 Subject: EuroPython 2019: Sponsor brochure available Message-ID: <9b70be22-b13d-a1a6-b153-9f821cf728f4@europython.eu> We are pleased to present our EuroPython 2019 Sponsor Brochure: * https://ep2019.europython.eu/sponsor/brochure/ * We have worked with our designer to compile all relevant information about the conference in a nice to read brochure, you can use to discuss a possible sponsorship in your company. If you have questions, please contact our sponsor team at sponsoring at europython.eu. Once you have decided, please sign up via the form on our sponsor package page. https://ep2019.europython.eu/sponsor/packages/ Early-bird sponsorship deal --------------------------- If you are quick to decide, you can benefit from a 10% early-bird discount we give on sponsor packages, if you sign up today (Friday, May 17): https://ep2019.europython.eu/sponsor/packages/ Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/184937371007/europython-2019-sponsor-brochure-available Tweet: https://twitter.com/europython/status/1129286303055568896 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From damianleejob at gmail.com Fri May 17 04:07:56 2019 From: damianleejob at gmail.com (damianleejob at gmail.com) Date: Fri, 17 May 2019 01:07:56 -0700 (PDT) Subject: How to read barcoded value from PDF In-Reply-To: References: Message-ID: <2830cfe1-3f25-4f5b-9360-05f2c8ac011b@googlegroups.com> ? 2011?6?28???? UTC+8??5:30:21?Robin Becker??? > On 28/06/2011 06:59, Asif Jamadar wrote: > > Hi, > > > ........... > > > > In Reportlab I can do the following code to generate barcode and to get the value of that barcode > > > > > > > > barcode=code39.Extended39("123456789",barWidth=0.2*mm,barHeight=8*mm) > > > > > > > > bc = Paragraph("Barcode value: %s" % barcode.value, STYLES['Normal']) > > > > > > > > document.append(bc) > > > > But how can I achieve this from the existing PDF document?? > ......... > > you might consider asking on the reportlab list as there is considerable > experience there about pdf in general. > > It's unlikely that you will be able to easily discern which string/text in the > pdf corresponds to the barcode values that you are interested in. > > PDF does allow things called annotations which reportlab can generate. > > Alternatively you can generate an invisible string which may make more sense > than the simple barcode value. So when you draw the barcode you also need to add > the magic string using some prefix/postfix that allows easy extraction with > pypdf or similar eg > > "===radamajfisa===123456789===radamajfisa===". Your text extractor should be > able to find this without too much trouble. > -- > Robin Becker You can check out this .net barcode reader for PDF document: http://www.barcodec.com/products/netpdfbarcodereader-all.html. It might be helpful. From ben.usenet at bsb.me.uk Fri May 17 06:47:13 2019 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Fri, 17 May 2019 11:47:13 +0100 Subject: repr = expression representation? References: Message-ID: <87bm01fjda.fsf@bsb.me.uk> Christian Gollwitzer writes: > Am 17.05.19 um 06:13 schrieb Stefan Ram: However, look at this >> >> |>>> print( str( print )) >> | >> >> |>>> print( repr( print )) >> | >> >> . While it is nice that ?str( print )? gives some useful >> information, I would expect ?repr( print )? to give >> ?print? - > > This is impossible. Python does not use "call by name", so a function > cannot know how the argument is called in the upper stack > level. Consider: > > Apfelkiste:inotes chris$ python3 > Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) > [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> blafasel = print >>>> print(repr(blafasel)) > >>>> I don't think that renaming is important to SR. The result should be, in his view, a string representing the /value/ of the argument to repr, so repr(print) and replr(blafasel) could both return the same (as they indeed do) thing and I think he'd be happy. > You'll have to accept that not all Python objects can be represented > as literals. I don't think SR minds if the result is not a literal. I think the hope was simply that eval(repr(E)) === E for any expression E. You could, in a very limited way, fudge it like this: def myrepr(e): if isinstance(e, types.BuiltinFunctionType): return e.__name__ return repr(e) The trouble is that print does not always mean print because that identifier can be rebound. Python could try to provide some /other/ name for every object, one that can't be rebound (something like an environment + string lookup) but it's probably not worth it. -- Ben. From jpn.jha1 at gmail.com Fri May 17 08:19:31 2019 From: jpn.jha1 at gmail.com (Jpn Jha) Date: Fri, 17 May 2019 17:49:31 +0530 Subject: About: Python not recognizing command even after installed Python 3.7.3 Message-ID: Dear Team I have already installed python 3.7.3 64-bit in my window 8.1. I started learning Django using python. But after few days 4-5 days I found python not recognizing command. Could you please advise me. Is there any possibilities of Antivirous update and running for removing virous . Thanks Regards Jai Prakash From rshepard at appl-ecosys.com Fri May 17 08:45:16 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Fri, 17 May 2019 05:45:16 -0700 (PDT) Subject: Import module from a different subdirectory In-Reply-To: References: <9amDE.86417$Kv5.36383@fx45.iad> Message-ID: On Fri, 17 May 2019, Inada Naoki wrote: > This is slightly off topic (not relating to your problem), but please > don't think "Python 3 doesn't require __init__.py for packages". It is > common misunderstanding. Inada, Actually, your response is on topic and probably the reason I have the import problem. > Package directory without __init__.py is "namespace package". > Namespace package is not a regular package. See [1] for detail. Thank you for correcting me. Regards, Rich From rshepard at appl-ecosys.com Fri May 17 11:30:25 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Fri, 17 May 2019 08:30:25 -0700 (PDT) Subject: Import module from a different subdirectory In-Reply-To: References: Message-ID: On Thu, 16 May 2019, Rich Shepard wrote: > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. Getting closer, but still missing a piece of the solution. First, I added __init__.py to each module subdirectory to specify that the subdirectory is a package. Second, in ~/.bash_profile I added two lines, the first is the project's root directory: PYTHONPATH=$HOME/development/bustrac export PYTHONPATH Testing this suggests that python is finding the path: $ python3 Python 3.7.3 (default, Mar 26 2019, 06:40:28) [GCC 5.5.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.environ["PYTHONPATH"] '/home/rshepard/development/bustrac' but the import is still not working. Do I need to specify each bustrac/ subdirectory in the PYTHONPATH? If not, what am I still missing? Regards, Rich From matthias at weckbecker.name Fri May 17 05:02:00 2019 From: matthias at weckbecker.name (Matthias Weckbecker) Date: Fri, 17 May 2019 11:02:00 +0200 Subject: subscribe Message-ID: <20190517102007.09de2c47@slytherin> From ethan at stoneleaf.us Fri May 17 13:59:00 2019 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 17 May 2019 10:59:00 -0700 Subject: subscribe In-Reply-To: <20190517102007.09de2c47@slytherin> References: <20190517102007.09de2c47@slytherin> Message-ID: <6d023a95-b40c-e165-4248-5f6da6e3159e@stoneleaf.us> You have been subscribed. Welcome to Python List! -- ~Ethan~ From Irv at furrypants.com Fri May 17 14:37:02 2019 From: Irv at furrypants.com (Irv Kalb) Date: Fri, 17 May 2019 11:37:02 -0700 Subject: Instance vs Class variable oddity In-Reply-To: <86r28ztelw.fsf@benfinney.id.au> References: <86r28ztelw.fsf@benfinney.id.au> Message-ID: <24CA82F5-DC95-4695-ADD8-715EB79174DA@furrypants.com> > On May 15, 2019, at 5:41 PM, Ben Finney wrote: > > Irv Kalb writes: > >> I just saw some code that confused me. The confusion has to do with >> class variables and instance variables. > > (Perhaps unrelated, but here's another confusion you may be suffering > from: There's no such thing as a ?class variable? or ?instance > variable?. In Python, a ?variable? is always a *binding* between a name > and and object. The ?variable? has no concept of different types.) > >> > > I'm not sure I understand the confusion; once the instance has an > attribute of that name, the same logic you outlined above applies when > attempting to resolve that attribute. When ?self.x? exists on the > instance, that's what will be used when resolving ?self.x?. > > I hope that helps. > Thanks for your comments. I am very aware of all the other issues that you explained. The only thing that threw me was that in a line like: self.x = self.x + 1 in a method, these two uses of self.x can refer to different variables. I actually teach Python, and this would be a very difficult thing to explain to students. I have never run across this issue because I would never use the same name as an instance attribute and a class attribute. (I also know that "attribute" is the "official" terms, but I've called them instance variables and class variables for so many years (working in other languages), that I use those terms without thinking.) Thanks, Irv From rosuav at gmail.com Fri May 17 14:46:26 2019 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 18 May 2019 04:46:26 +1000 Subject: Instance vs Class variable oddity In-Reply-To: <24CA82F5-DC95-4695-ADD8-715EB79174DA@furrypants.com> References: <86r28ztelw.fsf@benfinney.id.au> <24CA82F5-DC95-4695-ADD8-715EB79174DA@furrypants.com> Message-ID: On Sat, May 18, 2019 at 4:40 AM Irv Kalb wrote: > > Thanks for your comments. I am very aware of all the other issues that you explained. > > The only thing that threw me was that in a line like: > > self.x = self.x + 1 > > in a method, these two uses of self.x can refer to different variables. I actually teach Python, and this would be a very difficult thing to explain to students. > > I have never run across this issue because I would never use the same name as an instance attribute and a class attribute. (I also know that "attribute" is the "official" terms, but I've called them instance variables and class variables for so many years (working in other languages), that I use those terms without thinking.) > Yes, this is a little unusual. It's a consequence of the run-time-lookup that defines attributes, as opposed to the compile-time-lookup that defines most name bindings. For instance: x = 0 def f(): print(x) x = 1 print(x) will raise UnboundLocalError, rather than printing zero followed by one. But the global and builtin namespaces are looked up completely dynamically: class int(int): pass This will look up the built-in "int" type, create a subclass, and make that a global. So this is uncommon, but not unique. Sometimes, if one thing doesn't exist, you find another - even if it's going to exist a moment later. ChrisA From ethan at stoneleaf.us Fri May 17 14:45:26 2019 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 17 May 2019 11:45:26 -0700 Subject: Instance vs Class variable oddity In-Reply-To: <24CA82F5-DC95-4695-ADD8-715EB79174DA@furrypants.com> References: <86r28ztelw.fsf@benfinney.id.au> <24CA82F5-DC95-4695-ADD8-715EB79174DA@furrypants.com> Message-ID: <5d345d81-e329-96d0-7eff-0222f5614a79@stoneleaf.us> On 05/17/2019 11:37 AM, Irv Kalb wrote: > self.x = self.x + 1 > > I have never run across this issue because I would never use the same name as an instance attribute and a class attribute. So you treat your class attributes as if they were static? -- ~Ethan~ From jfong at ms4.hinet.net Fri May 17 23:49:34 2019 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Fri, 17 May 2019 20:49:34 -0700 (PDT) Subject: Instance vs Class variable oddity In-Reply-To: References: Message-ID: <51140638-2a73-46c7-a001-21e923a8ecbf@googlegroups.com> Correct me if I am wrong, please. I always think that the LEGB rule (e.g. the namespace to look up for) was applied at compile-time, only the binding was resolved "dynamically" at run-time. For example: def foo(): print(x) foo() will cause a NameError. But after x = 5 foo() will run correctly. I also don't think the term "variable" and "attribute" can be used exchangeable. Variable apply to an unbound name, and attribute applies to bounded name. For example: foo.x = 3 will create an attribute x of function foo. It's either not a local variable, or a global variable. It's more likely a class instance attribute, and it's resolved by applying MRO rule dynamically. --Jach From dieter at handshake.de Sat May 18 00:51:04 2019 From: dieter at handshake.de (dieter) Date: Sat, 18 May 2019 06:51:04 +0200 Subject: Import module from a different subdirectory References: Message-ID: <87imu8gybr.fsf@handshake.de> Rich Shepard writes: >> The project directory contains subdirectories, including gui/ (with the >> tkinter views) and classes/ with the SQLAlchemy model.py. > ... > Second, in ~/.bash_profile I added two lines, the first is the project's > root directory: > > PYTHONPATH=$HOME/development/bustrac > export PYTHONPATH > > Testing this suggests that python is finding the path: > > $ python3 > Python 3.7.3 (default, Mar 26 2019, 06:40:28) [GCC 5.5.0] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import os >>>> os.environ["PYTHONPATH"] > '/home/rshepard/development/bustrac' Test this by looking at "sys.path" instead: >>> import sys >>> sys.path It is "sys.path" which actually controls the import machinery. > ... > Do I need to specify each bustrac/ subdirectory in the PYTHONPATH? If not, > what am I still missing? This depends on how you make the import. "sys.path" is typically a sequence of folders. Python's import machinery will look in those folders for modules/paackages for its (absolute) imports. Thus, if you use "import XXXX" or "from XXXX import ...", then one of those folders should contain a module or package named "XXXX". From dieter at handshake.de Sat May 18 01:04:59 2019 From: dieter at handshake.de (dieter) Date: Sat, 18 May 2019 07:04:59 +0200 Subject: Instance vs Class variable oddity References: <86r28ztelw.fsf@benfinney.id.au> <24CA82F5-DC95-4695-ADD8-715EB79174DA@furrypants.com> Message-ID: <87ef4wgxok.fsf@handshake.de> Irv Kalb writes: > ... > The only thing that threw me was that in a line like: > > self.x = self.x + 1 > > in a method, these two uses of self.x can refer to different variables. I actually teach Python, and this would be a very difficult thing to explain to students. > > I have never run across this issue because I would never use the same name as an instance attribute and a class attribute. I use this regularly. Think of the "class attribute" as providing a default for a potential "instance attribute" of the same name. In Python, almost everything from a class can be overridden by the instance (exceptions: some special methods, descriptors). Thus, one can (almost) view a class as a defaults provider for its instances. Class attributes are just one case. From rosuav at gmail.com Sat May 18 03:09:09 2019 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 18 May 2019 17:09:09 +1000 Subject: Instance vs Class variable oddity In-Reply-To: <51140638-2a73-46c7-a001-21e923a8ecbf@googlegroups.com> References: <51140638-2a73-46c7-a001-21e923a8ecbf@googlegroups.com> Message-ID: On Sat, May 18, 2019 at 1:51 PM wrote: > > Correct me if I am wrong, please. > > I always think that the LEGB rule (e.g. the namespace to look up for) was applied at compile-time, only the binding was resolved "dynamically" at run-time. For example: > > def foo(): > print(x) > > foo() will cause a NameError. But after > > x = 5 > > foo() will run correctly. This is correct; however, this function will fail with UnboundLocalError: x = 1 def foo(): print(x) x = 2 Function locals ARE locked in at compile time. ChrisA From jfong at ms4.hinet.net Sat May 18 03:33:41 2019 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Sat, 18 May 2019 00:33:41 -0700 (PDT) Subject: Instance vs Class variable oddity In-Reply-To: References: <51140638-2a73-46c7-a001-21e923a8ecbf@googlegroups.com> Message-ID: <2b4091ca-7951-45c6-8dce-139e4c186492@googlegroups.com> Chris Angelico? 2019?5?18???? UTC+8??3?09?37???? > On Sat, May 18, 2019 at 1:51 PM wrote: > > > > Correct me if I am wrong, please. > > > > I always think that the LEGB rule (e.g. the namespace to look up for) was applied at compile-time, only the binding was resolved "dynamically" at run-time. For example: > > > > def foo(): > > print(x) > > > > foo() will cause a NameError. But after > > > > x = 5 > > > > foo() will run correctly. > > This is correct; however, this function will fail with UnboundLocalError: > > x = 1 > def foo(): > print(x) > x = 2 > > Function locals ARE locked in at compile time. > > ChrisA Thank you. This example proves that the LEGB rule was applied at compile-time, and it fails to resolve the binding at run-time. --Jach From rshepard at appl-ecosys.com Sat May 18 08:45:23 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sat, 18 May 2019 05:45:23 -0700 (PDT) Subject: Import module from a different subdirectory In-Reply-To: <87imu8gybr.fsf@handshake.de> References: <87imu8gybr.fsf@handshake.de> Message-ID: On Sat, 18 May 2019, dieter wrote: > Test this by looking at "sys.path" instead: >>>> import sys >>>> sys.path > It is "sys.path" which actually controls the import machinery. Dieter, Thank you. I missed this when researching PYTHONPATH. Here's what I get: >>> sys.path ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/lib/python3.7/site-packages'] All directories are present, and the one for the current project is the first one searched. > "sys.path" is typically a sequence of folders. Python's import machinery > will look in those folders for modules/paackages for its (absolute) > imports. Thus, if you use "import XXXX" or "from XXXX import ...", then > one of those folders should contain a module or package named "XXXX". I understand this. Within ~/development/bustrac as the CWD when I invoke the test application with the first line: from classes import model as m I still see this result: $ python3 test_act_de.py Traceback (most recent call last): File "test_act_de.py", line 1, in from classes import model as m ModuleNotFoundError: No module named 'classes' 'classes' is a package (a subdirectory) containing an empty __init__.py, not a module. 'classes' conains a single module, model.py. Since the project's root directory is seen by sys.path I don't know why the import statement keeps failing. Thanks, Rich From hjp-python at hjp.at Sat May 18 12:22:19 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 18 May 2019 18:22:19 +0200 Subject: Import module from a different subdirectory In-Reply-To: References: <87imu8gybr.fsf@handshake.de> Message-ID: <20190518162219.wzzrgxk7m7ntl4ei@hjp.at> On 2019-05-18 05:45:23 -0700, Rich Shepard wrote: > On Sat, 18 May 2019, dieter wrote: > > > > sys.path > ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', > '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', > '/usr/lib/python3.7/site-packages'] > > All directories are present, and the one for the current project is the > first one searched. [...] > I understand this. Within ~/development/bustrac as the CWD when I invoke the > test application with the first line: > > from classes import model as m > > I still see this result: > > $ python3 test_act_de.py Traceback (most recent call last): > File "test_act_de.py", line 1, in > from classes import model as m > ModuleNotFoundError: No module named 'classes' > > 'classes' is a package (a subdirectory) containing an empty __init__.py, not > a module. 'classes' conains a single module, model.py. This works for me: hrunkner:~ 18:14 :-) 1141% cd tmp hrunkner:~/tmp 18:14 :-) 1142% mkdir bustrac hrunkner:~/tmp 18:14 :-) 1143% cd bustrac hrunkner:~/tmp/bustrac 18:14 :-) 1144% mkdir classes hrunkner:~/tmp/bustrac 18:14 :-) 1145% touch classes/__init__.py hrunkner:~/tmp/bustrac 18:14 :-) 1146% touch classes/model.py hrunkner:~/tmp/bustrac 18:14 :-) 1147% python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from classes import model >>> "" is in sys.path, so "classes" and classes.model are found. Now lets go to a different subdirectory: hrunkner:~/tmp/bustrac 18:15 :-) 1148% mkdir scripts hrunkner:~/tmp/bustrac 18:15 :-) 1149% cd scripts hrunkner:~/tmp/bustrac/scripts 18:15 :-) 1150% python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from classes import model Traceback (most recent call last): File "", line 1, in ImportError: No module named 'classes' >>> This doesn't work, since there is no classes/model.py in "", only in "..". But if I add a PYTHONPATH, it works again: hrunkner:~/tmp/bustrac/scripts 18:15 :-) 1151% export PYTHONPATH=~/tmp/bustrac hrunkner:~/tmp/bustrac/scripts 18:15 :-) 1152% python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from classes import model >>> -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From rshepard at appl-ecosys.com Sat May 18 12:43:34 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sat, 18 May 2019 09:43:34 -0700 (PDT) Subject: Import module from a different subdirectory In-Reply-To: <20190518162219.wzzrgxk7m7ntl4ei@hjp.at> References: <87imu8gybr.fsf@handshake.de> <20190518162219.wzzrgxk7m7ntl4ei@hjp.at> Message-ID: On Sat, 18 May 2019, Peter J. Holzer wrote: > "" is in sys.path, so "classes" and classes.model are found. > > Now lets go to a different subdirectory: > This doesn't work, since there is no classes/model.py in "", only in "..". > > But if I add a PYTHONPATH, it works again: Peter, The project layout, briefly, is: ~/development/business-tracker/ classes/ gui/ All subdirectories contain a __init__.py file to identify them as packages. 'classes/' contains model.py; 'gui/' contains test_act_de.py. The project root directory is present in both PYTHONPATH and sys.path: $ echo $PYTHONPATH /home/rshepard/development/bustrac/ $ python3 Python 3.7.3 (default, Mar 26 2019, 06:40:28) [GCC 5.5.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/lib/python3.7/site-packages'] When the gui/ subdirectory is the current working directory and I try to run text_act_de.py I get the error that model.py is not found in the classes subdirectory. I don't see how my directory structure, file locations, and paths differ from your examples. Regards, Rich From piet-l at vanoostrum.org Sat May 18 18:20:55 2019 From: piet-l at vanoostrum.org (Piet van Oostrum) Date: Sun, 19 May 2019 00:20:55 +0200 Subject: Import module from a different subdirectory References: <87imu8gybr.fsf@handshake.de> <20190518162219.wzzrgxk7m7ntl4ei@hjp.at> Message-ID: Rich Shepard writes: > > $ python3 > Python 3.7.3 (default, Mar 26 2019, 06:40:28) [GCC 5.5.0] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import sys >>>> sys.path > ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', > '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', > '/usr/lib/python3.7/site-packages'] > > When the gui/ subdirectory is the current working directory and I try to run > text_act_de.py I get the error that model.py is not found in the classes > subdirectory. I don't see how my directory structure, file locations, and > paths differ from your examples. In a previous message the error was that 'classes' wasn't found, not that model.py wasn't found in classes, i.e. it was the same error as Peter got. So to get this working you must make sure 'classes' is inside a directory that is in sys.path, for example by adding: sys.path.insert(0, '..') -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From hjp-python at hjp.at Sat May 18 18:47:34 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 19 May 2019 00:47:34 +0200 Subject: Import module from a different subdirectory In-Reply-To: References: <87imu8gybr.fsf@handshake.de> <20190518162219.wzzrgxk7m7ntl4ei@hjp.at> Message-ID: <20190518224734.p3mseeusf5h5ihk4@hjp.at> On 2019-05-18 09:43:34 -0700, Rich Shepard wrote: > The project layout, briefly, is: > > ~/development/business-tracker/ ^^^^^^^^^^^^^^^^ > classes/ > gui/ > > All subdirectories contain a __init__.py file to identify them as packages. > 'classes/' contains model.py; 'gui/' contains test_act_de.py. > > The project root directory is present in both PYTHONPATH and sys.path: > > $ echo $PYTHONPATH > /home/rshepard/development/bustrac/ ^^^^^^^ This won't help much if your directory named "business-tracker" (see above). hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From rshepard at appl-ecosys.com Sat May 18 19:15:34 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sat, 18 May 2019 16:15:34 -0700 (PDT) Subject: Import module from a different subdirectory In-Reply-To: <20190518224734.p3mseeusf5h5ihk4@hjp.at> References: <87imu8gybr.fsf@handshake.de> <20190518162219.wzzrgxk7m7ntl4ei@hjp.at> <20190518224734.p3mseeusf5h5ihk4@hjp.at> Message-ID: On Sun, 19 May 2019, Peter J. Holzer wrote: > This won't help much if your directory named "business-tracker" (see > above). Peter, et al.: Yep. User error. The directory is actually 'business_tracker' and I used the application name, 'bustrac', instead when I set PYTHONPATH. Discovered this a bit ago when I looked over the messages in the thread and realized that I had a major brain cramp when setting up PYTHONPATH. Having corrected this, the problem has gone away. My apologies to all who patiently tried to get me to see what I kept missing. My thanks to all, Rich From Markus.Elfring at web.de Sun May 19 02:37:02 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Sun, 19 May 2019 08:37:02 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> Message-ID: > socketserver threading model is that the main server loops waiting for > connection requests, when it receives a request it creates a handler thread, This data processing style can be generally fine as long as you would like to work without a thread (or process) pool. > and then it completely forgets about the thread I have taken another look at the implementation of the corresponding methods. https://github.com/python/cpython/blob/3.7/Lib/socketserver.py#L656 I get an other impression from the statements ?self._threads.append(t)? (process_request) and ?thread.join()? (server_close). > -- the thread is independent and completes the handling of the request. Will a corresponding return value bet set? > If you need to ensure everything has finished before starting the next server instance, I am still looking for the support of software constraints in this direction. > you will have to write the extensions to socketserver. Will the development situation evolve any more here? Regards, Markus From cummins.192 at buckeyemail.osu.edu Sat May 18 10:40:41 2019 From: cummins.192 at buckeyemail.osu.edu (Cummins, Hayden) Date: Sat, 18 May 2019 14:40:41 +0000 Subject: Tkinter optionMenu Resize Message-ID: Hi! I've been having a lot of trouble resizing the Tkinter optionMenu feature due to my inexperience in Python. Is there a way to resize the option menu? If so, how? I've tried using the config function and it makes it so the program no longer executes. I also can't find any articles about this problem at all across the internet, so any help would be greatly appreciated. Source code to follow. From alfaomegarubi at gmail.com Sat May 18 12:22:36 2019 From: alfaomegarubi at gmail.com (nobelio) Date: Sat, 18 May 2019 13:22:36 -0300 Subject: The if is not working properly Message-ID: <5ce0314d.1c69fb81.19496.a12c@mx.google.com> When you print the variable ?a? it appears as True, but the program is it is not getting in the if a==True: Enviado do Email para Windows 10 --- Este e-mail foi verificado quanto a v?rus pelo AVG. http://www.avg.com From kaamranrizvi at gmail.com Sat May 18 12:41:39 2019 From: kaamranrizvi at gmail.com (Syed Rizvi) Date: Sat, 18 May 2019 21:41:39 +0500 Subject: PyCharm installation Message-ID: Hi, I tried to install PyCharm. First time when I installed it, it worked well. It developed some problem and when I reinstalled PyCharm, it gives me error. I have installed it several times but could not install it I am unable to install PyCharm. From eugalt at gmail.com Sat May 18 06:50:56 2019 From: eugalt at gmail.com (Eugene Alterman) Date: Sat, 18 May 2019 06:50:56 -0400 Subject: Why is augmented assignment of a tuple with iterable unpacking invalid syntax? Message-ID: <7784ff95-e836-ad18-3675-7164528f7185@gmail.com> a = 1, 2, 3 b = *a, # assignment - OK b += *a, # augmented assignment - syntax error Need to enclose in parenthesis: b += (*a,) Why isn't it allowed with an augmented assignment, while it is OK with a regular assignment? From cs at cskk.id.au Sun May 19 06:29:35 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sun, 19 May 2019 20:29:35 +1000 Subject: The if is not working properly In-Reply-To: <5ce0314d.1c69fb81.19496.a12c@mx.google.com> References: <5ce0314d.1c69fb81.19496.a12c@mx.google.com> Message-ID: <20190519102935.GA54362@cskk.homeip.net> On 18May2019 13:22, nobelio wrote: >When you print the variable ?a? it appears as True, but the program is >it is not getting in the if a==True: It may be that "a" is not the Boolean value True but something else. But that is just a guess. Please reply and paste in a small example programme showing this problem. Cheers, Cameron Simpson From alister.ware at ntlworld.com Sun May 19 12:24:55 2019 From: alister.ware at ntlworld.com (Alister) Date: Sun, 19 May 2019 16:24:55 GMT Subject: The if is not working properly References: <5ce0314d.1c69fb81.19496.a12c@mx.google.com> <20190519102935.GA54362@cskk.homeip.net> Message-ID: On Sun, 19 May 2019 20:29:35 +1000, Cameron Simpson wrote: > On 18May2019 13:22, nobelio wrote: >>When you print the variable ?a? it appears as True, but the program is >>it is not getting in the if a==True: > > It may be that "a" is not the Boolean value True but something else. But > that is just a guess. Please reply and paste in a small example > programme showing this problem. > > Cheers, > Cameron Simpson also if a==True is unnecessarily verbose if a: would suffice (unless you explicitly want True & not just a truthy value in which case use if a is True: From python at mrabarnett.plus.com Sun May 19 12:55:08 2019 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 May 2019 17:55:08 +0100 Subject: The if is not working properly In-Reply-To: <20190519102935.GA54362@cskk.homeip.net> References: <5ce0314d.1c69fb81.19496.a12c@mx.google.com> <20190519102935.GA54362@cskk.homeip.net> Message-ID: <78004bac-9164-a9c3-c634-9c97a58aa771@mrabarnett.plus.com> On 2019-05-19 11:29, Cameron Simpson wrote: > On 18May2019 13:22, nobelio wrote: >>When you print the variable ?a? it appears as True, but the program is >>it is not getting in the if a==True: > > It may be that "a" is not the Boolean value True but something else. But > that is just a guess. Please reply and paste in a small example > programme showing this problem. > My guess is that it's the string 'True'. From piet-l at vanoostrum.org Sun May 19 13:02:50 2019 From: piet-l at vanoostrum.org (Piet van Oostrum) Date: Sun, 19 May 2019 19:02:50 +0200 Subject: Why is augmented assignment of a tuple with iterable unpacking invalid syntax? References: <7784ff95-e836-ad18-3675-7164528f7185@gmail.com> Message-ID: Eugene Alterman writes: > a = 1, 2, 3 > > b = *a, # assignment - OK > b += *a, # augmented assignment - syntax error > > Need to enclose in parenthesis: > > b += (*a,) > > Why isn't it allowed with an augmented assignment, while it is OK with a > regular assignment? > Syntactically (i.e. according to the grammar): The right-hand side of an assignment has as one of the alternative a starred_expression, which includes starred and unstarred expressions. The right-hand side of an augmented assignment has an expression_list there. (The other option is both cases is a yield_expression.) And if it is a list (i.e. there is a comma in it), it is a tuple. Semantically: x += y is more or less equivalent to x = x + y, except that x is only evaluated once, and y is treated as a unity (think implicit parentheses around it). So the y is basically part of an expression. But starred expressions are not allowed in expressions, except within explicit parentheses. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From jlgimeno71 at gmail.com Sun May 19 13:24:46 2019 From: jlgimeno71 at gmail.com (Jorge Gimeno) Date: Sun, 19 May 2019 10:24:46 -0700 Subject: PyCharm installation In-Reply-To: References: Message-ID: On Sun, May 19, 2019, 3:27 AM Syed Rizvi wrote: > Hi, > > I tried to install PyCharm. First time when I installed it, it worked > well. It developed some problem and when I reinstalled PyCharm, it gives me > error. I have installed it several times but could not install it > > I am unable to install PyCharm. > -- > https://mail.python.org/mailman/listinfo/python-list Without the error message there isn't much we can do. Can you please copy and paste the error message? -Jorge > > From Markus.Elfring at web.de Sun May 19 13:26:51 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Sun, 19 May 2019 19:26:51 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <42u2eedsk4a07psiaenlb8p86hr5pe0gl9@4ax.com> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> <903a8fed-ba40-48ab-cc91-4bada6d5c81e@web.de> <8736lxsbii.fsf@handshake.de> <87y33o878r.fsf@handshake.de> <28e29cf7-e4e8-6130-ec3f-bd30a1f1fd69@web.de> <42u2eedsk4a07psiaenlb8p86hr5pe0gl9@4ax.com> Message-ID: <9dd9c0d2-568d-041a-6766-29d3a8ada1b3@web.de> >> I get an other impression from the statements ?self._threads.append(t)? (process_request) >> and ?thread.join()? (server_close). > > Okay -- v3.7 has added more logic that didn't exist in the v3.5 code > I was examining... (block_on_close is new). Thanks for such a version comparison. > However, I need to point out that this logic is part of server_close(), > which is not the same as shutdown(). You have been calling shutdown() which > only ends the loop accepting new connections, but leaves any in-process > threads to finish handling their requests. > > server_close() needs to be called by your code, I would expect AFTER > calling shutdown() to stop accepting new requests (and starting new threads > which may not be in the list that the close is trying to join). Should this aspect be taken into account by the code specification ?with server:?? > And after calling server_close() you will not be able to simply "restart" the server > -- you must go through the entire server initialization process > (ie: create a whole new server instance). This should be finally achieved by the implementation of my method ?perform_command?. I hope that corresponding data processing can be cleanly repeated then as desired for test purposes. Regards, Markus From hjp-python at hjp.at Sun May 19 14:06:36 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 19 May 2019 20:06:36 +0200 Subject: Import module from a different subdirectory In-Reply-To: References: <87imu8gybr.fsf@handshake.de> <20190518162219.wzzrgxk7m7ntl4ei@hjp.at> <20190518224734.p3mseeusf5h5ihk4@hjp.at> Message-ID: <20190519180636.i2k54g76c4omvwav@hjp.at> On 2019-05-18 16:15:34 -0700, Rich Shepard wrote: > My apologies to all who patiently tried to get me to see what I kept > missing. I've certainly made similar mistakes in the past (and probably will in the future). And I didn't see it when I read your mail the first time. But then I read Piet's reply and thought "But Rich already wrote that ..." and reread you message. And then I was like "Wait a minute ..."[1] hp [1] And now I've got Frank Zappa's "Valley Girl" stuck in my head. One shouldn't compose a reply while waiting for the coffee machine to boot - too much time to form weird associations. -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp at hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From tjreedy at udel.edu Sun May 19 15:34:41 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 May 2019 15:34:41 -0400 Subject: Tkinter optionMenu Resize In-Reply-To: References: Message-ID: On 5/18/2019 10:40 AM, Cummins, Hayden wrote: > Hi! I've been having a lot of trouble resizing the Tkinter optionMenu feature due to my inexperience in Python. Is there a way to resize the option menu? If so, how? I've tried using the config function and it makes it so the program no longer executes. I also can't find any articles about this problem at all across the internet, so any help would be greatly appreciated. Source code to follow. This is a no-attachment list. Put *minimal* code inline. An OptionMenu is a Menubutton subclass initialized with a default configuration and with a drop-down menu for which all items have the same callback. The following works for me to give the button a constant width regardless of the selection. from tkinter import * r = Tk() s = StringVar() om = OptionMenu(r, s, 'a', 'boat', 'cantilever') om.pack() om['width'] = 10 # len('cantilever') r.mainloop() # Omit this while developing in IDLE. If using IDLE with mainloop() disabled, you can experiment with configuration settings at the interactive prompt. Helpful (but not perfect) tkinter reference: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/menubutton.html shows the configuration settings for menubutton. http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/optionmenu.html shows how to set an initial value so that the button is not initially blank. -- Terry Jan Reedy From john_ladasky at sbcglobal.net Sun May 19 15:39:15 2019 From: john_ladasky at sbcglobal.net (John Ladasky) Date: Sun, 19 May 2019 12:39:15 -0700 (PDT) Subject: Amber Brown: Batteries Included, But They're Leaking In-Reply-To: <87ef4v31co.fsf@nightsong.com> References: <87ef4v31co.fsf@nightsong.com> Message-ID: <690ce823-ce9c-493d-b01f-dbe0039b4d1f@googlegroups.com> On Saturday, May 18, 2019 at 2:21:59 PM UTC-7, Paul Rubin wrote: > http://pyfound.blogspot.com/2019/05/amber-brown-batteries-included-but.html > > This was a controversial talk at the Python language summit, giving > various criticisms of Python's standard library, I will try to find some time to read through Amber Brown's remarks. For now, I just want to remind everyone that we had this exact discussion here, about two years ago. First post in the thread, if you want to see the source: https://groups.google.com/forum/#!original/comp.lang.python/B2ODmhMS-x4/KMpF4yuHBAAJ Here are a few excerpts from the thread: On Saturday, September 16, 2017 at 11:01:03 PM UTC-7, Terry Reedy wrote: > The particular crippler for CLBG [Computer Language Benchmark Game] > problems is the non-use of numpy in numerical calculations, such as the > n-body problem. Numerical python extensions are over two decades old > and give Python code access to optimized, compiled BLAS, LinPack, > FFTPack, and so on. The current one, numpy, is the third of the series. > It is both a historical accident and a continuing administrative > convenience that numpy is not part of the Python stdlib. On Monday, September 18, 2017 at 10:21:55 PM UTC+1, John Ladasky wrote: > OK, I found this statement intriguing. Honestly, I can't function without > Numpy, but I have always assumed that many Python programmers do so. > Meanwhile: most of the time, I have no use for urllib, but that module is > in the standard library. > > I noticed the adoption of the @ operation for matrix multiplication. I > have yet to use it myself. > > So is there a fraction of the Python community that thinks that Numpy > should in fact become part of the Python stdlib? What is the > "administrative convenience" to which you refer? On 2017-09-18 23:08, bream... at gmail.com wrote: > My very opinionated personnal opinion is that many third party libraries > are much better off outside of the stdlib, numpy particulary so as it's > one of the most used, if not the most used, such libraries. > > My rationale is simple, the authors of the libraries are not tied into > the (c)Python release cycle, the PEP process or anything else, they can > just get on with it. > > Consider my approach many blue moons ago when I was asking when the "new" > regex module was going to be incorporated into Python, and getting a bit > miffed in my normal XXXL size hat autistic way when it didn't happen. I > am now convinved that back then I was very firmly wrong, and that staying > out of the stdlib has been the best thing that could have happened to > regex. On Tuesday, September 19, 2017 at 12:11:58 AM UTC-7, Steven D'Aprano wrote: > On Tue, 19 Sep 2017 01:13:23 +0100, MRAB wrote: > > > I even have it on a Raspberry Pi. "pip install regex" is all it took. No > > need for it to be in the stdlib. :-) > > That's fine for those of us who can run pip and install software from the > web without being immediately fired, and for those who have installation > rights on the computers they use. And those with easy, cheap and fast > access to the internet. > > Not everyone is so lucky. I'm not offering an opinion, just some historical context FYI. From rosuav at gmail.com Sun May 19 16:48:09 2019 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 May 2019 06:48:09 +1000 Subject: Amber Brown: Batteries Included, But They're Leaking In-Reply-To: <690ce823-ce9c-493d-b01f-dbe0039b4d1f@googlegroups.com> References: <87ef4v31co.fsf@nightsong.com> <690ce823-ce9c-493d-b01f-dbe0039b4d1f@googlegroups.com> Message-ID: On Mon, May 20, 2019 at 5:41 AM John Ladasky wrote: > > On Saturday, May 18, 2019 at 2:21:59 PM UTC-7, Paul Rubin wrote: > > http://pyfound.blogspot.com/2019/05/amber-brown-batteries-included-but.html > > > > This was a controversial talk at the Python language summit, giving > > various criticisms of Python's standard library, > > I will try to find some time to read through Amber Brown's remarks. I'll make a few comments too. > Applications Need More Than The Standard Library > > For example, asyncio requires external libraries to connect to a database or to speak HTTP. Nothing in Python's standard library connects to a database (with the minor exception of sqlite3, which isn't so much "connecting to a database" as "reading a database file"). This is not a dependency of asyncio any more than psycopg2 (from PyPI) is a dependency of the socket module. HTTP might be a valid point, as many applications could restrict themselves to the stdlib if working synchronously or with threads, but to do so with asyncio would require manually crafting HTTP requests and parsing HTTP responses. Would have to confirm that, though; is it possible to use asyncio's socket services with other modules in the stdlib? > Brown asserted that there were many such dependencies from the standard > library to PyPI: No, that is not a dependency. A dependency is where something cannot run without something else. Nothing in the stdlib depends on anything from PyPI. Claiming that an application needs a library from PyPI is not the same as showing a dependency. > typing works best with mypy, The point of the typing module is to be the baseline that makes annotations legal and executable, without giving them actual meaning. Good use of mypy (or any other type checker - it's intentionally generic) can be by publishing something that depends only on the stdlib, but on your development computer, you install mypy. This is the entire point of the typing module - to be part of the stdlib and allow the code to run unmodified (but unchecked). > the sslmodule requires a monkeypatch to connect to non-ASCII domain names, Is that true? If confirmed, that should just be raised as an issue and dealt with. > datetime needs pytz, You can easily use datetime without timezone support, either just using naive datetimes, or using UTC. The stdlib includes support for fixed UTC offsets too, but not daylight saving time. Considering that the tzdata files get updated about ten times a year, baking that into the stdlib would be a bad idea. > and six is non-optional for writing code for Python 2 and 3. Absolutely false. I have written 2/3 spanning code without six. It's a convenience, and most assuredly not "non-optional". Also, writing Py3-only code is a completely reasonable choice, especially as 2020 approaches. > Other standard library modules are simply inferior to alternatives on PyPI. Honestly, not surprised. If the stdlib modules were superior to the PyPI ones, the latter wouldn't exist. There are plenty of reasons for superior options to be installable, and that's not a problem. The stdlib is there for people who want to be strict about deployment, which makes it easier for people to use a script. > The http.client documentation advises readers to use Requests, And that's a prime example; the requests module changes too frequently to be baked into the stdlib usefully. > and the datetime module is confusing compared to its competitors such as arrow, dateutil, and moment. I've never even heard of arrow. Not sure what the issue is with datetime; more details needed. > Standard Library Modules Crowd Out Innovation > > Brown?s most controversial opinion, in her own estimation, is that adding modules to > the standard library stifles innovation, by discouraging programmers from using > or contributing to competing PyPI packages. This opinion is in direct conflict with the prior complaint that there are stdlib modules inferior to third-party ones. > Van Rossum argued instead that if the Twisted team wants the ecosystem to > evolve, they should stop supporting older Python versions and force users to > upgrade. Brown acknowledged this point, but said half of Twisted users are > still on Python 2 and it is difficult to abandon them. The debate at this point > became personal for Van Rossum, and he left angrily. And this is what happens when you look at statistics to make your decisions. So long as you say "half of Twisted users are on Python 2, we have to support it", those users will say "Twisted still supports Python 2, we don't have to move". Maybe it's not about abandoning people but about drawing them onto a more recent Python. > Brown said her point was to move asyncio to PyPI, along with most new > feature development. ?We should embrace PyPI,? she exhorted. This is the only "action item" I've found in the entire rant. Quite aside from the backward incompatibility in the specific example of removing asyncio from the stdlib, there IS still a lot of value in keeping things in the core distribution. For large projects, it's easy and common to include a "requirements.txt" and depend on PyPI; but for small projects, it's much easier to distribute just a single .py file and expect it to be able to run on every Python system. Python *does* embrace PyPI. Thanks to ensurepip, most Python distributions are capable of installing third-party packages. There are some ongoing issues such as difficulties installing on Windows, but they don't seem to be the point of this rant. So what IS the point of this rant? What should be being fixed? It would be a bad thing for Python to remove things from the stdlib. It would also be a bad thing to adopt a policy of "no further stdlib packages, everyone needs to use PyPI". If that's the only suggested action, this is nothing more than a rant. Need more proposed solutions. ChrisA From mail.python.org at marco.sulla.e4ward.com Sun May 19 08:27:32 2019 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Sun, 19 May 2019 14:27:32 +0200 Subject: Why Python has no equivalent of JDBC of Java? Message-ID: I programmed in Python 2 and 3 for many years, and I find it a fantastic language. Now I'm programming in Java by m ore than 2 years, and even if I found its code much more boilerplate, I admit that JDBC is fantastic. One example over all: Oracle. If you want to access an Oracle DB from Python, you have to: 1. download the Oracle instantclient and install/unzip it 2. on Linux, you have also to install/unzip Development and Runtime package 3. on windows, you have to add the instantclient to PATH 4. on Linux, you have to create a script to source that sets PATH, ORACLE_HOME and LD_LIBRARY_PATH Finally, you can use cx_Oracle. Java? You have only to download ojdbcN.jar and add it to Maven/Gradle. Why Python has no equivalent to JDBC? From christian at python.org Sun May 19 17:34:30 2019 From: christian at python.org (Christian Heimes) Date: Sun, 19 May 2019 23:34:30 +0200 Subject: Amber Brown: Batteries Included, But They're Leaking In-Reply-To: References: <87ef4v31co.fsf@nightsong.com> <690ce823-ce9c-493d-b01f-dbe0039b4d1f@googlegroups.com> Message-ID: On 19/05/2019 22.48, Chris Angelico wrote: >> the sslmodule requires a monkeypatch to connect to non-ASCII domain names, It's not correct. There were some bugs in IDNA support in the SSL module. Nathaniel and I worked on the topic and fixed it in 3.7, see https://bugs.python.org/issue28414 Python stdlib in general does not support some non-ASCII domain names (German, Greek, and some Asian languages), because there is no IDNA 2008 encoding in the stdlib. The problem is not in the SSL module, but starts as low as host name encoding for DNS lookups. The solution here is to *add* more features to the stdlib, see https://bugs.python.org/issue17305 By the way, I'm working on removing some dead battieres since last year, see proto PEP https://github.com/tiran/peps/blob/oldbatteries/pep-9999.rst and LWN article https://lwn.net/Articles/755229/ Christian From rosuav at gmail.com Sun May 19 17:44:15 2019 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 May 2019 07:44:15 +1000 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: Message-ID: On Mon, May 20, 2019 at 7:34 AM Marco Sulla via Python-list wrote: > > I programmed in Python 2 and 3 for many years, and I find it a fantastic > language. > > Now I'm programming in Java by m ore than 2 years, and even if I found its > code much more boilerplate, I admit that JDBC is fantastic. > > One example over all: Oracle. If you want to access an Oracle DB from > Python, you have to: > > 1. download the Oracle instantclient and install/unzip it > 2. on Linux, you have also to install/unzip Development and Runtime package > 3. on windows, you have to add the instantclient to PATH > 4. on Linux, you have to create a script to source that sets PATH, > ORACLE_HOME and LD_LIBRARY_PATH > > Finally, you can use cx_Oracle. > > Java? You have only to download ojdbcN.jar and add it to Maven/Gradle. > > Why Python has no equivalent to JDBC? I've no idea what the hassles are with Oracle, as it's a database engine that I don't use. But with PostgreSQL, which I *do* use, I can assure you that it's much easier: $ pip install psycopg2 >>> import psycopg2 Job done. If Oracle is harder to use, it may be a specific issue with installing the Oracle client. Have you tried using pip to install cx_oracle? ChrisA From rosuav at gmail.com Sun May 19 17:48:10 2019 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 May 2019 07:48:10 +1000 Subject: Amber Brown: Batteries Included, But They're Leaking In-Reply-To: References: <87ef4v31co.fsf@nightsong.com> <690ce823-ce9c-493d-b01f-dbe0039b4d1f@googlegroups.com> Message-ID: On Mon, May 20, 2019 at 7:38 AM Christian Heimes wrote: > > On 19/05/2019 22.48, Chris Angelico wrote: > >> the sslmodule requires a monkeypatch to connect to non-ASCII domain names, > > It's not correct. There were some bugs in IDNA support in the SSL > module. Nathaniel and I worked on the topic and fixed it in 3.7, see > https://bugs.python.org/issue28414 > > Python stdlib in general does not support some non-ASCII domain names > (German, Greek, and some Asian languages), because there is no IDNA 2008 > encoding in the stdlib. The problem is not in the SSL module, but starts > as low as host name encoding for DNS lookups. The solution here is to > *add* more features to the stdlib, see > https://bugs.python.org/issue17305 > Thanks. And I agree; if there are limitations like this in the stdlib, the stdlib needs to be fixed. That's not a leaking battery. ChrisA From formisc at gmail.com Sun May 19 17:49:40 2019 From: formisc at gmail.com (Andrew Z) Date: Sun, 19 May 2019 17:49:40 -0400 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: Message-ID: Marco, You clearly know more about python/java universe than i do. But im infinitely thankful to cx team for putting out the package. Feature and performance wise , even with non supported oracle timesten, it was fantastic. Id always go after "native" vs jdbc. But i understand that most of apps have a very general workflow of " select some, insert some/delete" thus most of the native features are not required.. Sorry, its Sunday, float off the subject. On Sun, May 19, 2019, 17:33 Marco Sulla via Python-list < python-list at python.org> wrote: > I programmed in Python 2 and 3 for many years, and I find it a fantastic > language. > > Now I'm programming in Java by m ore than 2 years, and even if I found its > code much more boilerplate, I admit that JDBC is fantastic. > > One example over all: Oracle. If you want to access an Oracle DB from > Python, you have to: > > 1. download the Oracle instantclient and install/unzip it > 2. on Linux, you have also to install/unzip Development and Runtime package > 3. on windows, you have to add the instantclient to PATH > 4. on Linux, you have to create a script to source that sets PATH, > ORACLE_HOME and LD_LIBRARY_PATH > > Finally, you can use cx_Oracle. > > Java? You have only to download ojdbcN.jar and add it to Maven/Gradle. > > Why Python has no equivalent to JDBC? > -- > https://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Sun May 19 19:03:06 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 May 2019 19:03:06 -0400 Subject: Amber Brown: Batteries Included, But They're Leaking In-Reply-To: References: <87ef4v31co.fsf@nightsong.com> <690ce823-ce9c-493d-b01f-dbe0039b4d1f@googlegroups.com> Message-ID: On 5/19/2019 4:48 PM, Chris Angelico wrote: > On Mon, May 20, 2019 at 5:41 AM John Ladasky wrote: >> >> On Saturday, May 18, 2019 at 2:21:59 PM UTC-7, Paul Rubin wrote: >>> http://pyfound.blogspot.com/2019/05/amber-brown-batteries-included-but.html >>> >>> This was a controversial talk at the Python language summit, giving >>> various criticisms of Python's standard library, >> >> I will try to find some time to read through Amber Brown's remarks. > > I'll make a few comments too. I read them and the read what I concluded is yet another useless, contradictory, rant based partly on ignorance and mis-information. You corrected some of the latter. >> Brown said her point was to move asyncio to PyPI, along with most new >> feature development. ?We should embrace PyPI,? she exhorted. > > This is the only "action item" I've found in the entire rant. The disinformation is the implication that core developers have not embraced pypi. But anyone reading this list and python-ideas would know that it is mostly users pushing for new modules and some particular features in the stdlib and core developers saying "Whoo, we are already overloaded. Start something on pypi first and *maybe* we will consider it later." I think her main point is that she, a twisted developer, is mad and thinks it unfair that competitor asyncio was privileged by being allowed to be developed in the stdlib. Hence, "Ever since asyncio was announced she has had to explain why Twisted is still worthwhile". And hence her wish that it, in particular, be relegated to being one competitor among others on pypi. -- Terry Jan Reedy From formisc at gmail.com Sun May 19 19:24:22 2019 From: formisc at gmail.com (Andrew Z) Date: Sun, 19 May 2019 19:24:22 -0400 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: Message-ID: The pg python lib requires https://www.postgresql.org/docs/current/libpq.html pip pulls it as a part of the lib install, whereas in oracle case you install the driver yourself first.(suize matters) //for some reason i thought the driver libs come as part of cx . But it was a year ago and my memory may play tricks on me. On Sun, May 19, 2019, 17:44 Chris Angelico wrote: > On Mon, May 20, 2019 at 7:34 AM Marco Sulla via Python-list > wrote: > > > > I programmed in Python 2 and 3 for many years, and I find it a fantastic > > language. > > > > Now I'm programming in Java by m ore than 2 years, and even if I found > its > > code much more boilerplate, I admit that JDBC is fantastic. > > > > One example over all: Oracle. If you want to access an Oracle DB from > > Python, you have to: > > > > 1. download the Oracle instantclient and install/unzip it > > 2. on Linux, you have also to install/unzip Development and Runtime > package > > 3. on windows, you have to add the instantclient to PATH > > 4. on Linux, you have to create a script to source that sets PATH, > > ORACLE_HOME and LD_LIBRARY_PATH > > > > Finally, you can use cx_Oracle. > > > > Java? You have only to download ojdbcN.jar and add it to Maven/Gradle. > > > > Why Python has no equivalent to JDBC? > > I've no idea what the hassles are with Oracle, as it's a database > engine that I don't use. But with PostgreSQL, which I *do* use, I can > assure you that it's much easier: > > $ pip install psycopg2 > >>> import psycopg2 > > Job done. > > If Oracle is harder to use, it may be a specific issue with installing > the Oracle client. Have you tried using pip to install cx_oracle? > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Sun May 19 19:57:03 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 May 2019 19:57:03 -0400 Subject: Amber Brown: Batteries Included, But They're Leaking In-Reply-To: References: <87ef4v31co.fsf@nightsong.com> <690ce823-ce9c-493d-b01f-dbe0039b4d1f@googlegroups.com> Message-ID: <54f2ca41-6d78-9e34-bb0a-378b83be05a2@udel.edu> On 5/19/2019 5:34 PM, Christian Heimes wrote: > By the way, I'm working on removing some dead battieres since last year, > see proto PEP > https://github.com/tiran/peps/blob/oldbatteries/pep-9999.rst and LWN > article https://lwn.net/Articles/755229/ Hooray! I believe that there are other modules, other than distutils, that others have proposed for deletion after 2.7 expires. While deleting in 3.9 would be nice, I agree on waiting for 3.10. Track issues to fix/enhance could be deleted before that. For 3.8, I think deprecation in the docs and possibly PendingDeprecationWarning could be added anytime up to the .rc. colorsys, color conversion functions between RGB, YIQ, HLS, and HSV coordinate systems, seems like it should still be useful. Looking for substututes on pypi, I found pyrgb: color conversion functions - RGB, HSV, HSL, CMYK This needs YIQ to be a superset of colorsys. Py version unspecified. colorutils: among other things, conversions between RGB tuples, 6-character HEX strings, 3-character HEX strings, WEB, YIQ, and HSV. WEB is a 'well-known' color name, when available, such as 'SeaGreen'. (Tk names would be helpful for tkinter programming. HEX is used in Tk.) This needs HSL to be a superset. 2.7, last release 5/25/2015 Conclusion: colorsys could be pretty well replaced by an improved version of either package. In the Linux World comments, k8to says "For a silly data point, I still have code that I still run that process amiga data files that I use in an archival project. I'm a little sad about some of the modules I use being removed from python. I'm sure I can work around the problem though, as I only run the code locally." My thought: who better to maintain an atari date file library than someone who still processes such libraries? So publicize the PEP and encourage experts in old protocols to maintain the corresponding code. -- Terry Jan Reedy From pierrelouis.chevallier60 at gmail.com Sun May 19 21:54:16 2019 From: pierrelouis.chevallier60 at gmail.com (Becaree) Date: Sun, 19 May 2019 18:54:16 -0700 (PDT) Subject: The state of asyncio in 2019 Message-ID: <82b6eb98-b2f5-42d5-bc70-707f8c54627c@googlegroups.com> So i started to use asyncio some times ago. I see a lots of threads/forums which date back from 2015 or older. My question is what the state of asyncio in 2019? I guess, the major constrain of having async/await is quiet a drawback. I do love asyncio but reinventing the wheel using it is somehow complicated for a community. I mean i found disappointed that major scheduler don't use it as airflow/luigi/dask. Also pulsar is kind of unmaintained. So now i wonder, should i stick with asyncio or some async/await-freed coroutines as use tornado or gevent is the way to go? From rosuav at gmail.com Mon May 20 00:40:15 2019 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 May 2019 14:40:15 +1000 Subject: The state of asyncio in 2019 In-Reply-To: <82b6eb98-b2f5-42d5-bc70-707f8c54627c@googlegroups.com> References: <82b6eb98-b2f5-42d5-bc70-707f8c54627c@googlegroups.com> Message-ID: On Mon, May 20, 2019 at 11:56 AM Becaree wrote: > > So i started to use asyncio some times ago. I see a lots of threads/forums which date back from 2015 or older. My question is what the state of asyncio in 2019? I guess, the major constrain of having async/await is quiet a drawback. I do love asyncio but reinventing the wheel using it is somehow complicated for a community. I mean i found disappointed that major scheduler don't use it as airflow/luigi/dask. Also pulsar is kind of unmaintained. So now i wonder, should i stick with asyncio or some async/await-freed coroutines as use tornado or gevent is the way to go? > It depends a bit on what you're trying to do, but if you want a system that doesn't use async/await, you may want to first look at the built-in "threading" module. It doesn't scale to infinity the way asyncio can, but for workloads of up to a few thousand threads, it should be fine. In the context of an internet server, for instance, that would mean you can handle a few thousand concurrent requests by simply having that many threads, each one handling one request at a time. Otherwise, there's really not a lot that's fundamentally *bad* about using the await keyword everywhere that you need to block. Just keep an eye on your libraries' documentation, and if it says something's a coroutine, slap an await in front of it. I've used asyncio in several projects, and it doesn't feel all that onerous. For instance, this function: https://github.com/Rosuav/csgo_automute/blob/master/server.py#L47 responds to an HTTP request by saying "okay, wait till you have the whole body, and JSON-decode it", then does some synchronous work, and then says "ooh that was interesting, let's broadcast that to all clients". Pretty simple. The websocket handler above it is similar; although at the moment, it's very stubby, so it's probably not a great example. (All it does is listen for messages and then print them on the console. Mucho excitement.) That's using aiohttp. For vanilla socket services, you can do everything using the standard library directly - either start a server (to bind and listen), or connect a socket, and then await your reads and your writes. The past four years have definitely seen notable improvements to asyncio in Python. ChrisA From mal at europython.eu Mon May 20 03:18:44 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Mon, 20 May 2019 09:18:44 +0200 Subject: EuroPython 2019: Conference and training ticket sale opens today Message-ID: <77d87fbb-ed15-0af2-27f2-f677f6a02670@europython.eu> We will be starting the EuroPython 2019 conference and training ticket sales today (Monday) at 12:00 CEST * https://ep2019.europython.eu/registration/buy-tickets/ * Only 300 training tickets available ----------------------------------- After the rush to the early-bird tickets last week (we sold more than 290 tickets in 10 minutes), we expect a rush to the regular and training tickets this week as well. We only have 300 training tickets available, so if you want to attend the training days, please consider getting your ticket soon. Available ticket types ---------------------- We will have the following ticket types available: - regular conference tickets - admission to the conference days (July 10-12) and sprints (July 13-14) - training tickets - admission to the training days (July 8-9) - combined tickets - admission to training, conference and sprint days (July 8-14) Please see our registration page for full details on the available tickets. As reminder, here?s the conference layout: - Monday & Tuesday, July 8 & 9: Trainings, Beginners? Day and other workshops - Wednesday?Friday, July 10?12: Conference talks, keynotes & exhibition - Saturday & Sunday, July 13 & 14: Sprints Combined Tickets ---------------- These are a new ticket type we are introducing for EuroPython 2019, to simplify purchase and check-in at the conference for attendees who want to attend the complete EuroPython 2019 week with a single ticket. To make the ticket more attractive, we are granting a small discount compared to purchasing training and conference tickets separately. Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/185008362672/europython-2019-conference-and-training-ticket Tweet: https://twitter.com/europython/status/1130371157440512000 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From tjol at tjol.eu Mon May 20 11:23:59 2019 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 20 May 2019 17:23:59 +0200 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: Message-ID: <702b873c-ff57-d47f-3f4b-d16208b3fc67@tjol.eu> On 19/05/2019 14.27, Marco Sulla via Python-list wrote: > I programmed in Python 2 and 3 for many years, and I find it a fantastic > language. > > Now I'm programming in Java by m ore than 2 years, and even if I found its > code much more boilerplate, I admit that JDBC is fantastic. Python has a the "Python Database API" (DB API 2.0) https://www.python.org/dev/peps/pep-0249/ All SQL database modules that I know of use this API. It's more decentralized than JDBC (not that I know much about JDBC), but it does the trick: as long as the SQL syntax is sufficiently compatible, you can easily swap in one database for another. > > One example over all: Oracle. If you want to access an Oracle DB from > Python, you have to: If Oracle wants to be a pain in the arse, that's Oracle's doing. The open source databases aren't like that. -- Thomas From evans5551 at gmail.com Mon May 20 13:46:05 2019 From: evans5551 at gmail.com (Carolyn Evans) Date: Mon, 20 May 2019 13:46:05 -0400 Subject: Installation Problems with Python 3.7.3 Message-ID: I am having trouble with re-installing python 3.7.3. I keep getting the following message: Modify Repair Remove I have tried all three numerous times and can not complete the setup I am working on a Windows 8 system, 64 bit OS, 4GB ram. How can this be fixed? Thanks C. Evans From ikorot01 at gmail.com Mon May 20 15:17:10 2019 From: ikorot01 at gmail.com (Igor Korot) Date: Mon, 20 May 2019 14:17:10 -0500 Subject: Installation Problems with Python 3.7.3 In-Reply-To: References: Message-ID: Hi, On Mon, May 20, 2019 at 1:53 PM Carolyn Evans wrote: > > I am having trouble with re-installing python 3.7.3. Why do you need to reinstall? What seems to be the problem? Thank you. > > I keep getting the following message: > > Modify > Repair > Remove > > I have tried all three numerous times and can not complete the setup > > I am working on a Windows 8 system, 64 bit OS, 4GB ram. > > How can this be fixed? > > Thanks > > C. Evans > -- > https://mail.python.org/mailman/listinfo/python-list From mail.python.org at marco.sulla.e4ward.com Mon May 20 17:38:00 2019 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 20 May 2019 23:38:00 +0200 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: <702b873c-ff57-d47f-3f4b-d16208b3fc67@tjol.eu> References: <702b873c-ff57-d47f-3f4b-d16208b3fc67@tjol.eu> Message-ID: On Mon, 20 May 2019 at 17:32, Thomas Jollans wrote: > Python has a the "Python Database API" (DB API 2.0) > https://www.python.org/dev/peps/pep-0249/ > So why Oracle need instantclient for using cx_Oracle? They say they use DB-API: > *cx_Oracle* is a Python extension module that enables access to Oracle > Database. It conforms to the Python database API 2.0 specification with > a considerable number of additions and a couple of exclusions. https://oracle.github.io/python-cx_Oracle/ On Sun, 19 May 2019 at 23:47, Chris Angelico wrote: > I've no idea what the hassles are with Oracle, as it's a database > engine that I don't use. But with PostgreSQL, which I *do* use, I can > assure you that it's much easier > I use Postgres if I can choose, but companies uses Oracle unluckily. Oracle and MSSQL. And I must say that surprisingly, being a Microsoft product, I find MSSQL more simple to install than Oracle, like Postregres, and has an easier SQL syntax. Like Postgres. From formisc at gmail.com Mon May 20 18:23:55 2019 From: formisc at gmail.com (Andrew Z) Date: Mon, 20 May 2019 18:23:55 -0400 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: <702b873c-ff57-d47f-3f4b-d16208b3fc67@tjol.eu> Message-ID: What does 249 specification mention about drivers? On Mon, May 20, 2019, 17:39 Marco Sulla via Python-list < python-list at python.org> wrote: > On Mon, 20 May 2019 at 17:32, Thomas Jollans wrote: > > > Python has a the "Python Database API" (DB API 2.0) > > https://www.python.org/dev/peps/pep-0249/ > > > > So why Oracle need instantclient for using cx_Oracle? They say they use > DB-API: > > > *cx_Oracle* is a Python extension module that enables access to Oracle > > Database. It conforms to the Python database API 2.0 specification > with > > a considerable number of additions and a couple of exclusions. > > https://oracle.github.io/python-cx_Oracle/ > > > On Sun, 19 May 2019 at 23:47, Chris Angelico wrote: > > > I've no idea what the hassles are with Oracle, as it's a database > > engine that I don't use. But with PostgreSQL, which I *do* use, I can > > assure you that it's much easier > > > > I use Postgres if I can choose, but companies uses Oracle unluckily. Oracle > and MSSQL. And I must say that surprisingly, being a Microsoft product, I > find MSSQL more simple to install than Oracle, like Postregres, and has an > easier SQL syntax. Like Postgres. > -- > https://mail.python.org/mailman/listinfo/python-list > From torriem at gmail.com Mon May 20 19:17:31 2019 From: torriem at gmail.com (Michael Torrie) Date: Mon, 20 May 2019 17:17:31 -0600 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: <702b873c-ff57-d47f-3f4b-d16208b3fc67@tjol.eu> Message-ID: <29dc4973-72bc-723f-7a08-65a1d8246db2@gmail.com> On 05/20/2019 04:23 PM, Andrew Z wrote: > What does 249 specification mention about drivers? Nothing that I can see. But it stands to reason that at some point the Python code is going to have to interface with the SQL database server's API. And when the database in question is proprietary, the original poster should probably not be surprised that a special driver install is required. I assume it's also required for JDBC also, but since Java is owned by Oracle, they probably install such things automatically. > > On Mon, May 20, 2019, 17:39 Marco Sulla via Python-list < > python-list at python.org> wrote: > >> On Mon, 20 May 2019 at 17:32, Thomas Jollans wrote: >> >>> Python has a the "Python Database API" (DB API 2.0) >>> https://www.python.org/dev/peps/pep-0249/ >>> >> >> So why Oracle need instantclient for using cx_Oracle? They say they use >> DB-API: >> >>> *cx_Oracle* is a Python extension module that enables access to Oracle >>> Database. It conforms to the Python database API 2.0 specification >> with >>> a considerable number of additions and a couple of exclusions. >> >> https://oracle.github.io/python-cx_Oracle/ >> >> >> On Sun, 19 May 2019 at 23:47, Chris Angelico wrote: >> >>> I've no idea what the hassles are with Oracle, as it's a database >>> engine that I don't use. But with PostgreSQL, which I *do* use, I can >>> assure you that it's much easier >>> >> >> I use Postgres if I can choose, but companies uses Oracle unluckily. Oracle >> and MSSQL. And I must say that surprisingly, being a Microsoft product, I >> find MSSQL more simple to install than Oracle, like Postregres, and has an >> easier SQL syntax. Like Postgres. >> -- >> https://mail.python.org/mailman/listinfo/python-list >> From rosuav at gmail.com Mon May 20 20:41:31 2019 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 May 2019 10:41:31 +1000 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: <702b873c-ff57-d47f-3f4b-d16208b3fc67@tjol.eu> Message-ID: On Tue, May 21, 2019 at 8:25 AM Andrew Z wrote: > > What does 249 specification mention about drivers? > Nothing. PEP 249 defines how a Python app communicates with the database module. For instance: import psycopg2 db = psycopg2.connect("...") with db, db.cursor() as cur: cur.execute("select * from people where title = %s", [title]) for person in cur: print(person) You could replace the first two lines with, say, mysql.connector, or sqlite3, and the rest of the code doesn't need to care. The only part that needs to be database-engine-specific is the connection string passed to the connect() function. Some of these modules require lower level drivers, because they're simple wrappers around lower-level C APIs. Others are linked statically with the entire code required to make the connection (the sqlite3 module, I believe, is like that). Still others are pure Python implementations of wire protocols, which means they don't need anything more than the Python standard library and its socket services. In the case of Oracle, it sounds like it depends on a previously-installed Oracle client. ChrisA From formisc at gmail.com Mon May 20 21:08:49 2019 From: formisc at gmail.com (Andrew Z) Date: Mon, 20 May 2019 21:08:49 -0400 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: <29dc4973-72bc-723f-7a08-65a1d8246db2@gmail.com> References: <702b873c-ff57-d47f-3f4b-d16208b3fc67@tjol.eu> <29dc4973-72bc-723f-7a08-65a1d8246db2@gmail.com> Message-ID: Exactly right. Im not sure why Marco is wondering about native drivers not to be a part of python module (for oracle). Id be very unhappy, if a python module come with a native drivers for something as complex as a database. Cx guys gave you the power to install what and how your project requires. In Microsoft case .. that would be a different discussion :) On a flip side, if you dont need oracle specific features, then maybe u should use something basic for data storage. //but thats a different discussion On Mon, May 20, 2019, 19:18 Michael Torrie wrote: > On 05/20/2019 04:23 PM, Andrew Z wrote: > > What does 249 specification mention about drivers? > > Nothing that I can see. > > But it stands to reason that at some point the Python code is going to > have to interface with the SQL database server's API. And when the > database in question is proprietary, the original poster should probably > not be surprised that a special driver install is required. I assume > it's also required for JDBC also, but since Java is owned by Oracle, > they probably install such things automatically. > > > > > On Mon, May 20, 2019, 17:39 Marco Sulla via Python-list < > > python-list at python.org> wrote: > > > >> On Mon, 20 May 2019 at 17:32, Thomas Jollans wrote: > >> > >>> Python has a the "Python Database API" (DB API 2.0) > >>> https://www.python.org/dev/peps/pep-0249/ > >>> > >> > >> So why Oracle need instantclient for using cx_Oracle? They say they use > >> DB-API: > >> > >>> *cx_Oracle* is a Python extension module that enables access to Oracle > >>> Database. It conforms to the Python database API 2.0 specification > >> with > >>> a considerable number of additions and a couple of exclusions. > >> > >> https://oracle.github.io/python-cx_Oracle/ > >> > >> > >> On Sun, 19 May 2019 at 23:47, Chris Angelico wrote: > >> > >>> I've no idea what the hassles are with Oracle, as it's a database > >>> engine that I don't use. But with PostgreSQL, which I *do* use, I can > >>> assure you that it's much easier > >>> > >> > >> I use Postgres if I can choose, but companies uses Oracle unluckily. > Oracle > >> and MSSQL. And I must say that surprisingly, being a Microsoft product, > I > >> find MSSQL more simple to install than Oracle, like Postregres, and has > an > >> easier SQL syntax. Like Postgres. > >> -- > >> https://mail.python.org/mailman/listinfo/python-list > >> > > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Mon May 20 21:39:10 2019 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 May 2019 11:39:10 +1000 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: <702b873c-ff57-d47f-3f4b-d16208b3fc67@tjol.eu> <29dc4973-72bc-723f-7a08-65a1d8246db2@gmail.com> Message-ID: On Tue, May 21, 2019 at 11:10 AM Andrew Z wrote: > > Exactly right. Im not sure why Marco is wondering about native drivers not > to be a part of python module (for oracle). > Id be very unhappy, if a python module come with a native drivers for > something as complex as a database. I wouldn't be. It's just a client, and sometimes the clients are pretty simple (see, for instance, the mysql.connector module, which AIUI is a pure-python implementation of the MySQL wire protocol). The main reason Python doesn't include any database modules other than sqlite3 is that there are just way too many of them (PostgreSQL, MySQL, Oracle, MS SQL, IBM DB2, etc, etc, etc). > On a flip side, if you dont need oracle specific features, then maybe u > should use something basic for data storage. //but thats a different > discussion I rather doubt that this is open to discussion. From the sound of things, the choice of database back end has already been made, and the Python script just has to cope. Otherwise, PostgreSQL would be an entirely better alternative. ChrisA From blmadhavan at gmail.com Tue May 21 03:42:19 2019 From: blmadhavan at gmail.com (Madhavan Bomidi) Date: Tue, 21 May 2019 00:42:19 -0700 (PDT) Subject: How to concatenate strings with iteration in a loop? Message-ID: <6173af87-62e6-4c37-a5f2-a70619c040b9@googlegroups.com> Hi, I need to create an array as below: tempStr = year+','+mon+','+day+','+str("{:6.4f}".format(UTCHrs[k]))+','+ \ str("{:9.7f}".format(AExt[k,0]))+','+str({:9.7f}".format(AExt[k,1]))+','+ \ str("{:9.7f}".format(AExt[k,2]))+','+str("{:9.7f}".format(AExt[k,3]))+','+ \ str("{:9.7f}".format(AExt[k,4]))+','+str("{:9.7f}".format(AExt[k,5]))+','+ \ str("{:9.7f}".format(AExt[k,6]))+','+str("{:9.7f}".format(AExt[k,7]))+','+ \ str("{:9.7f}".format(AExt[k,8]))+','+str("{:9.7f}".format(AExt[k,9])) k is a row index Can some one suggest me how I can iterate the column index along with row index to concatenate the string as per the above format? Thanks in advance From frank at chagford.com Tue May 21 04:22:56 2019 From: frank at chagford.com (Frank Millman) Date: Tue, 21 May 2019 10:22:56 +0200 Subject: How to concatenate strings with iteration in a loop? In-Reply-To: <6173af87-62e6-4c37-a5f2-a70619c040b9@googlegroups.com> References: <6173af87-62e6-4c37-a5f2-a70619c040b9@googlegroups.com> Message-ID: <4c26feee-ff54-313c-9798-e99c32797139@chagford.com> On 2019-05-21 9:42 AM, Madhavan Bomidi wrote: > Hi, > > I need to create an array as below: > > tempStr = year+','+mon+','+day+','+str("{:6.4f}".format(UTCHrs[k]))+','+ \ > str("{:9.7f}".format(AExt[k,0]))+','+str({:9.7f}".format(AExt[k,1]))+','+ \ > str("{:9.7f}".format(AExt[k,2]))+','+str("{:9.7f}".format(AExt[k,3]))+','+ \ > str("{:9.7f}".format(AExt[k,4]))+','+str("{:9.7f}".format(AExt[k,5]))+','+ \ > str("{:9.7f}".format(AExt[k,6]))+','+str("{:9.7f}".format(AExt[k,7]))+','+ \ > str("{:9.7f}".format(AExt[k,8]))+','+str("{:9.7f}".format(AExt[k,9])) > > > k is a row index > > Can some one suggest me how I can iterate the column index along with row index to concatenate the string as per the above format? > > Thanks in advance > The following (untested) assumes that you are using a reasonably up-to-date Python that has the 'f' format operator. tempStr = f'{year},{mon},{day},{UTCHrs[k]:6.4f}' for col in range(10): tempStr += f',{AExt[k, col]:9.7f}' HTH Frank Millman From p.f.moore at gmail.com Tue May 21 04:40:38 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 21 May 2019 09:40:38 +0100 Subject: How to concatenate strings with iteration in a loop? In-Reply-To: <4c26feee-ff54-313c-9798-e99c32797139@chagford.com> References: <6173af87-62e6-4c37-a5f2-a70619c040b9@googlegroups.com> <4c26feee-ff54-313c-9798-e99c32797139@chagford.com> Message-ID: On Tue, 21 May 2019 at 09:25, Frank Millman wrote: > > On 2019-05-21 9:42 AM, Madhavan Bomidi wrote: > > Hi, > > > > I need to create an array as below: > > > > tempStr = year+','+mon+','+day+','+str("{:6.4f}".format(UTCHrs[k]))+','+ \ > > str("{:9.7f}".format(AExt[k,0]))+','+str({:9.7f}".format(AExt[k,1]))+','+ \ > > str("{:9.7f}".format(AExt[k,2]))+','+str("{:9.7f}".format(AExt[k,3]))+','+ \ > > str("{:9.7f}".format(AExt[k,4]))+','+str("{:9.7f}".format(AExt[k,5]))+','+ \ > > str("{:9.7f}".format(AExt[k,6]))+','+str("{:9.7f}".format(AExt[k,7]))+','+ \ > > str("{:9.7f}".format(AExt[k,8]))+','+str("{:9.7f}".format(AExt[k,9])) > > > > > > k is a row index > > > > Can some one suggest me how I can iterate the column index along with row index to concatenate the string as per the above format? > > > > Thanks in advance > > > > The following (untested) assumes that you are using a reasonably > up-to-date Python that has the 'f' format operator. > > tempStr = f'{year},{mon},{day},{UTCHrs[k]:6.4f}' > for col in range(10): > tempStr += f',{AExt[k, col]:9.7f}' > As a minor performance note (not really important with only 10 items, but better to get into good habits from the start): temp = [f'{year},{mon},{day},{UTCHrs[k]:6.4f}'] for col in range(10): temp.append(f',{AExt[k, col]:9.7f}') tempStr = ''.join(tempStr) Repeated concatenation of immutable strings (which is what Python has) is O(N**2) in the number of chunks added because of the need to repeatedly copy the string. Paul From blmadhavan at gmail.com Tue May 21 06:38:43 2019 From: blmadhavan at gmail.com (Madhavan Bomidi) Date: Tue, 21 May 2019 03:38:43 -0700 (PDT) Subject: How to split a list type array into float array? Message-ID: <97995a4a-764a-4aa3-bb0a-c8286180c820@googlegroups.com> Hi, I have the following list type data: [' 29.7963 29.6167 29.4371 29.2574 29.0778 28.8982 28.7185 28.5389 28.3593 28.1797 28.0000 27.8204 27.6408 27.4611 27.2815 27.1019 26.9223 26.7426 26.5630 26.3834 26.2037 26.0241 25.8445 25.6649 25.4852 25.3056 25.1260 24.9463 24.7667 24.5871 24.4075 24.2278 24.0482 -0.2616 -0.3215 -0.3813 -0.4412\n'] Can anyone help me split as a float array? Thanks in advance From alister.ware at ntlworld.com Tue May 21 06:58:58 2019 From: alister.ware at ntlworld.com (Alister) Date: Tue, 21 May 2019 10:58:58 GMT Subject: How to split a list type array into float array? References: <97995a4a-764a-4aa3-bb0a-c8286180c820@googlegroups.com> Message-ID: On Tue, 21 May 2019 03:38:43 -0700, Madhavan Bomidi wrote: > Hi, > > I have the following list type data: > > [' 29.7963 29.6167 29.4371 29.2574 29.0778 28.8982 28.7185 > 28.5389 28.3593 28.1797 28.0000 27.8204 27.6408 27.4611 > 27.2815 27.1019 26.9223 26.7426 26.5630 26.3834 26.2037 > 26.0241 25.8445 25.6649 25.4852 25.3056 25.1260 24.9463 > 24.7667 24.5871 24.4075 24.2278 24.0482 -0.2616 -0.3215 > -0.3813 -0.4412\n'] > > Can anyone help me split as a float array? > > Thanks in advance what have you tried ? (hint look up the docs on the spit method for strings) From airween at gmail.com Tue May 21 07:04:34 2019 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Tue, 21 May 2019 13:04:34 +0200 Subject: How to split a list type array into float array? In-Reply-To: <97995a4a-764a-4aa3-bb0a-c8286180c820@googlegroups.com> References: <97995a4a-764a-4aa3-bb0a-c8286180c820@googlegroups.com> Message-ID: <20190521110434.GA23658@arxnet.hu> On Tue, May 21, 2019 at 03:38:43AM -0700, Madhavan Bomidi wrote: > Hi, > > I have the following list type data: > > [' 29.7963 29.6167 29.4371 29.2574 29.0778 28.8982 28.7185 28.5389 28.3593 28.1797 28.0000 27.8204 27.6408 27.4611 27.2815 27.1019 26.9223 26.7426 26.5630 26.3834 26.2037 26.0241 25.8445 25.6649 25.4852 25.3056 25.1260 24.9463 24.7667 24.5871 24.4075 24.2278 24.0482 -0.2616 -0.3215 -0.3813 -0.4412\n'] > > Can anyone help me split as a float array? did you mean s = [' 29.79... ...\n'] f = [float(f) for f in s[0].strip().split()] and start to read the docs? https://docs.python.org/3/library/stdtypes.html?highlight=split#str.split https://docs.python.org/3/tutorial/datastructures.html?highlight=list and so on... a. From renting at astron.nl Tue May 21 08:27:33 2019 From: renting at astron.nl (Adriaan Renting) Date: Tue, 21 May 2019 14:27:33 +0200 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: Message-ID: <5CE3EEB50200001B0002C199@smtp1.astron.nl> I think it's partially a design philosophy difference. Java was meant to be generic, run anywhere and abstract and hide differences in its underlying infrastructure. This has led to the Java VM, and also JDBC I guess. Python was more of a script interpreted C-derivative, much closer to the bare metal, and thus much less effort was made to hide and abstract. It might also have to do with the different developer cultures. Java was much more Cathedral, and Python much more Bazaar. Bazaar type development seems to be much less able to come up with high level abstraction. At least that's my guess. Adriaan >>> On 19-5-2019 at 14:27, Marco Sulla via Python-list wrote: > I programmed in Python 2 and 3 for many years, and I find it a fantastic > language. > > Now I'm programming in Java by m ore than 2 years, and even if I found its > code much more boilerplate, I admit that JDBC is fantastic. > > One example over all: Oracle. If you want to access an Oracle DB from > Python, you have to: > > 1. download the Oracle instantclient and install/unzip it > 2. on Linux, you have also to install/unzip Development and Runtime package > 3. on windows, you have to add the instantclient to PATH > 4. on Linux, you have to create a script to source that sets PATH, > ORACLE_HOME and LD_LIBRARY_PATH > > Finally, you can use cx_Oracle. > > Java? You have only to download ojdbcN.jar and add it to Maven/Gradle. > > Why Python has no equivalent to JDBC? From p.f.moore at gmail.com Tue May 21 09:11:53 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 21 May 2019 14:11:53 +0100 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: <5CE3EEB50200001B0002C199@smtp1.astron.nl> References: <5CE3EEB50200001B0002C199@smtp1.astron.nl> Message-ID: On Tue, 21 May 2019 at 13:50, Adriaan Renting wrote: > > > I think it's partially a design philosophy difference. > > Java was meant to be generic, run anywhere and abstract and hide > differences in its underlying infrastructure. This has led to the Java > VM, and also JDBC I guess. > > Python was more of a script interpreted C-derivative, much closer to > the bare metal, and thus much less effort was made to hide and > abstract. In practice, I think it was more to do with the "Pure Java" philosophy/movement, which resulted in a lot of investment into reinventing/re-implementing code in Java - in this particular case, the network protocols that database clients and servers use to communicate. Because a commercial product like Oracle doesn't document those protocols, open-source reimplementations are hard, if not impossible. The Java drivers for Oracle are supplied by Oracle themselves - Oracle could also provide pure-Python implementations of the protocols, but they don't - so Python interfaces have to rely on the libraries Oracle *do* provide. The same is true of other database interfaces - although in the case of open source databases it *is* possible to implement the protocol in pure Python. It's just far less convenient when interfacing to the existing C libraries is pretty straightforward. For Java interfaces, linking to "native" libraries is more complex, and generally frowned on, so there's pressure to implement a "pure Java" solution. Not having to manage native binaries is a big advantage Java has, certainly. But conversely, it's meant that building the Java ecosystem required a massive amount of effort. Luckily, commercial interests have paid for much of that effort and have made the resulting libraries freely available. Who knows where we would be if Python had received a similar level of investment :-) Paul From frank at chagford.com Tue May 21 04:22:56 2019 From: frank at chagford.com (Frank Millman) Date: Tue, 21 May 2019 10:22:56 +0200 Subject: How to concatenate strings with iteration in a loop? In-Reply-To: <6173af87-62e6-4c37-a5f2-a70619c040b9@googlegroups.com> References: <6173af87-62e6-4c37-a5f2-a70619c040b9@googlegroups.com> Message-ID: <4c26feee-ff54-313c-9798-e99c32797139@chagford.com> On 2019-05-21 9:42 AM, Madhavan Bomidi wrote: > Hi, > > I need to create an array as below: > > tempStr = year+','+mon+','+day+','+str("{:6.4f}".format(UTCHrs[k]))+','+ \ > str("{:9.7f}".format(AExt[k,0]))+','+str({:9.7f}".format(AExt[k,1]))+','+ \ > str("{:9.7f}".format(AExt[k,2]))+','+str("{:9.7f}".format(AExt[k,3]))+','+ \ > str("{:9.7f}".format(AExt[k,4]))+','+str("{:9.7f}".format(AExt[k,5]))+','+ \ > str("{:9.7f}".format(AExt[k,6]))+','+str("{:9.7f}".format(AExt[k,7]))+','+ \ > str("{:9.7f}".format(AExt[k,8]))+','+str("{:9.7f}".format(AExt[k,9])) > > > k is a row index > > Can some one suggest me how I can iterate the column index along with row index to concatenate the string as per the above format? > > Thanks in advance > The following (untested) assumes that you are using a reasonably up-to-date Python that has the 'f' format operator. tempStr = f'{year},{mon},{day},{UTCHrs[k]:6.4f}' for col in range(10): tempStr += f',{AExt[k, col]:9.7f}' HTH Frank Millman From robin at reportlab.com Tue May 21 11:51:01 2019 From: robin at reportlab.com (Robin Becker) Date: Tue, 21 May 2019 16:51:01 +0100 Subject: Python 3.8 new deprecations Message-ID: Marius Gedminas has kindly been doing some work with reportlab and python 3.8a1 He reports this new deprecation warning from a c extension build DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats Currently we build the extensions for 2.7 3.4-3.7 Windows 32 & 64 MacOS and linux. His patch is changing several ints to Py_ssize_t after defining PY_SSIZE_T_CLEAN. Can anyone say which versions/runtimes this is needed for or can I just assume it has no effect in early versions. -- Robin Becker From songofacandy at gmail.com Tue May 21 12:04:04 2019 From: songofacandy at gmail.com (Inada Naoki) Date: Wed, 22 May 2019 01:04:04 +0900 Subject: Python 3.8 new deprecations In-Reply-To: References: Message-ID: I plan to remove int support in Python 3.10. If this warning is ignored, the extension module will be broken silently from 3.10. It is because C is not typesafe here. Regards, 2019?5?22?(?) 0:56 Robin Becker : > Marius Gedminas has kindly been doing some work with reportlab and python > 3.8a1 > > He reports this new deprecation warning from a c extension build > > DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats > > Currently we build the extensions for 2.7 3.4-3.7 Windows 32 & 64 MacOS > and linux. > > His patch is changing several ints to Py_ssize_t after defining > PY_SSIZE_T_CLEAN. > > Can anyone say which versions/runtimes this is needed for or can I just > assume it has no effect in early versions. > -- > Robin Becker > > -- > https://mail.python.org/mailman/listinfo/python-list > From ethan at stoneleaf.us Tue May 21 12:01:35 2019 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 21 May 2019 09:01:35 -0700 Subject: Python 3.8 new deprecations In-Reply-To: References: Message-ID: <88e6e035-5efd-4d8a-0ade-5f6c4166fe87@stoneleaf.us> On 05/21/2019 08:51 AM, Robin Becker wrote: > Marius Gedminas has kindly been doing some work with reportlab and python 3.8a1 > > He reports this new deprecation warning from a c extension build > > DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats > > Currently we build the extensions for 2.7 3.4-3.7 Windows 32 & 64 MacOS and linux. > > His patch is changing several ints to Py_ssize_t after defining PY_SSIZE_T_CLEAN. > > Can anyone say which versions/runtimes this is needed for or can I just assume it has no effect in early versions. This would be a good question for Python Dev. -- ~Ethan~ From robin at reportlab.com Tue May 21 12:56:03 2019 From: robin at reportlab.com (Robin Becker) Date: Tue, 21 May 2019 17:56:03 +0100 Subject: Python 3.8 new deprecations In-Reply-To: References: Message-ID: Thanks for letting me know. On Tue, 21 May 2019, 17:04 Inada Naoki, wrote: > I plan to remove int support in Python 3.10. > > If this warning is ignored, the extension module will be broken silently > from 3.10. > It is because C is not typesafe here. > > Regards, > > > 2019?5?22?(?) 0:56 Robin Becker : > >> Marius Gedminas has kindly been doing some work with reportlab and python >> 3.8a1 >> >> He reports this new deprecation warning from a c extension build >> >> DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats >> >> Currently we build the extensions for 2.7 3.4-3.7 Windows 32 & 64 MacOS >> and linux. >> >> His patch is changing several ints to Py_ssize_t after defining >> PY_SSIZE_T_CLEAN. >> >> Can anyone say which versions/runtimes this is needed for or can I just >> assume it has no effect in early versions. >> -- >> Robin Becker >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From me at simonbiggs.net Tue May 21 15:28:48 2019 From: me at simonbiggs.net (Simon Biggs) Date: Wed, 22 May 2019 05:28:48 +1000 Subject: Python WebApp where Python runs on the client's machine using Pyodide Message-ID: It's still a massive work in progress, but I though people here might be interested in the progress made thus far: https://app.pymedphys.com/ It is a file processing application. It has input files and output files. Users select input files from their computer, select a script to run (or edit a script to create their own) and then it produces the output files which can be downloaded. At the moment when Python is running the user interface freezes but to fix that I am told I just need to get my head around web workers ( https://github.com/iodide-project/pyodide/issues/435#issuecomment-493928297 ). It's been quite fun! Also, adding new scripts to the web app should be as simple as following the steps laid out over here: https://github.com/pymedphys/pymedphys/issues/312 I'm keen for feedback, please let me know what you think! I'll likely post this again in the near future once I fix up the freezing and I have also provided a few more example scripts. Cheers, Simon From jasonanyilian at gmail.com Tue May 21 21:11:02 2019 From: jasonanyilian at gmail.com (CrazyVideoGamez) Date: Tue, 21 May 2019 18:11:02 -0700 (PDT) Subject: What does at 0x0402C7B0> mean? Message-ID: I tried doing a list comprehension. I typed: favorite_fruits = ['watermelon', 'blackberries'] print(fruit for fruit in favorite_fruits) And I got: at 0x0402C7B0> What does this mean and what do I have to fix? From rosuav at gmail.com Tue May 21 21:26:22 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 May 2019 11:26:22 +1000 Subject: What does at 0x0402C7B0> mean? In-Reply-To: References: Message-ID: On Wed, May 22, 2019 at 11:16 AM CrazyVideoGamez wrote: > > I tried doing a list comprehension. I typed: > > favorite_fruits = ['watermelon', 'blackberries'] > print(fruit for fruit in favorite_fruits) > > And I got: > > at 0x0402C7B0> > > What does this mean and what do I have to fix? It means that you just printed out a generator object. But to "fix" this, you first have to explain what you wanted. ChrisA From tjreedy at udel.edu Tue May 21 21:42:07 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 21 May 2019 21:42:07 -0400 Subject: What does at 0x0402C7B0> mean? In-Reply-To: References: Message-ID: On 5/21/2019 9:11 PM, CrazyVideoGamez wrote: > I tried doing a list comprehension. I typed: > > favorite_fruits = ['watermelon', 'blackberries'] > print(fruit for fruit in favorite_fruits) > > And I got: > at 0x0402C7B0> > What does this mean It means that the expression (fruit for fruit in favorite_fruits) evaluates to a generator object. > and what do I have to fix? Perhaps you wanted to run the generator, perhaps like this: >>> favorite_fruits = ['watermelon', 'blackberries'] >>> print(*(fruit for fruit in favorite_fruits)) watermelon blackberries -- Terry Jan Reedy From cs at cskk.id.au Tue May 21 21:51:07 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 22 May 2019 11:51:07 +1000 Subject: What does at 0x0402C7B0> mean? In-Reply-To: References: Message-ID: <20190522015107.GA45221@cskk.homeip.net> On 21May2019 18:11, CrazyVideoGamez wrote: >I tried doing a list comprehension. I typed: > >favorite_fruits = ['watermelon', 'blackberries'] >print(fruit for fruit in favorite_fruits) > >And I got: > > at 0x0402C7B0> > >What does this mean and what do I have to fix? It means you didn't make a list comprehension. You've discovered a similar thing though. A list comprehension includes square brackets: [ fruit for fruit in favorite_fruits ] The result of that expression is literally a list, in this case effectively a copy of your favorite_fruits list. However, what you wrote was this: fruit for fruit in favorite_fruits and that is a generator expression. It is effectively an object that you can iterate over, and it will yield the elements from favourite_fruits. Importantly, it doesn't construct a list. It constructs a tiny function. Why might we want such a thing? Because it is "lazy": it only computes values which are actually asked for (consumed). The list comprehension computes all the values, _and_ allocates a list and stores them! This consumes more memory (except for small lists) and stalls your programme while that work takes place. It is equivalent to this function: def elements_of(some_list): for element in some_list: yield element That is a "generator function", and when you call it eg "elements_of(favorite_fruits)" it doesn't run. Instead it returns you a generator object which is effectively a call to the function frozen in time. The generator object is iterable, and when you iterate over it if fires up the frozen function. The function runs until it hits a yield statement, where it yields a value and that is the next value for the iteration; the function freezes again then. Consider this loop: stop_at = 'watermelon' for value in [ fruit for fruit in favorite_fruits ]: print(value) if value == stop_at: break This (a) constructs a list containing all the elements of favorite_fruits then (b) iterates over the elements of that list. When it hits a particular one of those elements it exits the loop. If we unfold the "for" line a little: elements = [ fruit for fruit in favorite_fruits ] for value in elements: The same amount of work is done, it just makes clear that the list construction is a whole distinct step. Now compare (generator expression in brackets, for clarity.: stop_at = 'watermelon' elements = fruit for fruit in favorite_fruits for value in elements: print(value) if value == stop_at: break Now "elements" is not a list, it is a generator expression. You can still iterate over this, and the printed output will be the same. However, before the "for", _no_ elements of favorite_fruits have been iterated over - almost no work has happened at all. Then as the for loop iterates, it fetches values from "elements", which yields them as needed. So that when the loop stops early, no effort (or memory storage) is wasted looking at the tail of the list. Your list is very small, but for large lists this is a significant win. Some lists are (notionally) infinitely large. Cheers, Cameron Simpson From wiwindson at gmail.com Tue May 21 22:46:28 2019 From: wiwindson at gmail.com (Windson Yang) Date: Wed, 22 May 2019 10:46:28 +0800 Subject: CPython compiled failed in macOS In-Reply-To: References: Message-ID: version: macOS 10.14.4, Apple LLVM version 10.0.1 (clang-1001.0.46.4). I cloned the CPython source code from GitHub then compiled it which used to work quite well. However, I messed up my terminal a few days ago for installing gdb. Now when I try to compile the latest CPython source code with ./configure --with-pydebug && make -j I always get the error messages: ld: warning: ld: warning: ignoring file libpython3.8d.a, file was built for archive which is not the architecture being linked (x86_64): libpython3.8d.aignoring file libpython3.8d.a, file was built for archive which is not the architecture being linked (x86_64): libpython3.8d.a Undefined symbols for architecture x86_64: "__Py_UnixMain", referenced from: _main in python.o ld: symbol(s) not found for architecture x86_64Undefined symbols for architecture x86_64: "_PyEval_InitThreads", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o "_PyEval_ReleaseThread", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o "_PyEval_RestoreThread", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o _test_bpo20891 in _testembed.o "_PyEval_SaveThread", referenced from: _test_bpo20891 in _testembed.o "_PyGILState_Check", referenced from: _bpo20891_thread in _testembed.o "_PyGILState_Ensure", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o _bpo20891_thread in _testembed.o "_PyGILState_Release", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o _bpo20891_thread in _testembed.o "_PyInterpreterState_GetID", referenced from: _print_subinterp in _testembed.o "_PyMem_RawFree", referenced from: _test_pre_initialization_api in _testembed.o "_PyRun_SimpleStringFlags", referenced from: _test_pre_initialization_api in _testembed.o _test_pre_initialization_sys_options in _testembed.o _test_init_main in _testembed.o _check_stdio_details in _testembed.o _print_subinterp in _testembed.o _dump_config in _testembed.o "_PySys_AddWarnOption", referenced from: _test_pre_initialization_sys_options in _testembed.o "_PySys_AddXOption", referenced from: _test_pre_initialization_sys_options in _testembed.o "_PySys_ResetWarnOptions", referenced from: _test_pre_initialization_sys_options in _testembed.o "_PyThreadState_Get", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o _print_subinterp in _testembed.o "_PyThreadState_Swap", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o "_PyThread_acquire_lock", referenced from: _test_bpo20891 in _testembed.o "_PyThread_allocate_lock", referenced from: _test_bpo20891 in _testembed.o "_PyThread_exit_thread", referenced from: _bpo20891_thread in _testembed.o "_PyThread_free_lock", referenced from: _test_bpo20891 in _testembed.o "_PyThread_release_lock", referenced from: _bpo20891_thread in _testembed.o "_PyThread_start_new_thread", referenced from: _test_bpo20891 in _testembed.o "_Py_BytesWarningFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o "_Py_DebugFlag", referenced from: _set_all_global_config_variables in _testembed.o "_Py_DecodeLocale", referenced from: _test_pre_initialization_api in _testembed.o "_Py_DontWriteBytecodeFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o _check_init_python_config in _testembed.o "_Py_EndInterpreter", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o "_Py_Finalize", referenced from: _test_forced_io_encoding in _testembed.o _test_repeated_init_and_subinterpreters in _testembed.o _test_pre_initialization_api in _testembed.o _test_pre_initialization_sys_options in _testembed.o _test_initialize_twice in _testembed.o _test_initialize_pymain in _testembed.o _test_init_default_config in _testembed.o ... "_Py_FrozenFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o _check_init_python_config in _testembed.o "_Py_IgnoreEnvironmentFlag", referenced from: _test_init_env in _testembed.o _test_init_env_dev_mode in _testembed.o _test_init_env_dev_mode_alloc in _testembed.o _set_all_global_config_variables in _testembed.o _check_init_python_config in _testembed.o "_Py_Initialize", referenced from: _test_forced_io_encoding in _testembed.o _test_pre_initialization_api in _testembed.o _test_initialize_twice in _testembed.o _test_init_global_config in _testembed.o __testembed_Py_Initialize in _testembed.o "_Py_InspectFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o "_Py_InteractiveFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o "_Py_IsolatedFlag", referenced from: _test_init_isolated_flag in _testembed.o _test_preinit_isolated2 in _testembed.o _set_all_global_config_variables in _testembed.o _check_init_python_config in _testembed.o "_Py_Main", referenced from: _test_initialize_pymain in _testembed.o "_Py_NewInterpreter", referenced from: _test_repeated_init_and_subinterpreters in _testembed.o "_Py_NoSiteFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o _check_init_python_config in _testembed.o "_Py_NoUserSiteDirectory", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o _check_init_python_config in _testembed.o "_Py_OptimizeFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o "_Py_QuietFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o "_Py_SetProgramName", referenced from: _test_pre_initialization_api in _testembed.o _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o __testembed_Py_Initialize in _testembed.o "_Py_SetStandardStreamEncoding", referenced from: _test_forced_io_encoding in _testembed.o _test_init_from_config in _testembed.o _check_stdio_details in _testembed.o "_Py_UTF8Mode", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o "_Py_UnbufferedStdioFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o _check_init_python_config in _testembed.o "_Py_VerboseFlag", referenced from: _test_init_global_config in _testembed.o _test_init_from_config in _testembed.o _set_all_global_config_variables in _testembed.o "__PyCoreConfig_Clear", referenced from: _test_preinit_parse_argv in _testembed.o _test_preinit_dont_parse_argv in _testembed.o _test_init_read_set in _testembed.o _test_run_main in _testembed.o "__PyCoreConfig_DecodeLocale", referenced from: _test_init_read_set in _testembed.o "__PyCoreConfig_Init", referenced from: _test_init_from_config in _testembed.o _test_preinit_isolated1 in _testembed.o _test_preinit_isolated2 in _testembed.o "__PyCoreConfig_InitIsolatedConfig", referenced from: _test_preinit_dont_parse_argv in _testembed.o _check_preinit_isolated_config in _testembed.o "__PyCoreConfig_InitPythonConfig", referenced from: _test_init_dont_configure_locale in _testembed.o _test_init_dev_mode in _testembed.o _test_init_isolated_flag in _testembed.o _test_preinit_parse_argv in _testembed.o _test_init_read_set in _testembed.o _test_init_run_main in _testembed.o _test_init_main in _testembed.o ... "__PyCoreConfig_Read", referenced from: _test_init_read_set in _testembed.o "__PyCoreConfig_SetString", referenced from: _test_preinit_parse_argv in _testembed.o _test_preinit_dont_parse_argv in _testembed.o _test_init_read_set in _testembed.o _test_run_main in _testembed.o "__PyCoreConfig_SetWideArgv", referenced from: _test_preinit_parse_argv in _testembed.o _test_preinit_dont_parse_argv in _testembed.o _test_run_main in _testembed.o "__PyInitError_Failed", referenced from: _test_init_from_config in _testembed.o _test_init_dont_configure_locale in _testembed.o _test_init_dev_mode in _testembed.o _test_init_isolated_flag in _testembed.o _test_preinit_isolated1 in _testembed.o _test_preinit_isolated2 in _testembed.o _test_preinit_parse_argv in _testembed.o ... "__PyInitError_NoMemory", referenced from: _test_init_read_set in _testembed.o "__PyPreConfig_Init", referenced from: _test_init_from_config in _testembed.o _test_preinit_isolated1 in _testembed.o _test_preinit_isolated2 in _testembed.o "__PyPreConfig_InitIsolatedConfig", referenced from: _test_preinit_dont_parse_argv in _testembed.o _check_preinit_isolated_config in _testembed.o "__PyPreConfig_InitPythonConfig", referenced from: _test_init_dont_configure_locale in _testembed.o _check_init_python_config in _testembed.o "__PyRuntime", referenced from: _check_preinit_isolated_config in _testembed.o "__PyWstrList_Append", referenced from: _test_init_read_set in _testembed.o "__Py_ExitInitError", referenced from: _test_init_from_config in _testembed.o _test_init_dont_configure_locale in _testembed.o _test_init_dev_mode in _testembed.o _test_init_isolated_flag in _testembed.o _test_preinit_isolated1 in _testembed.o _test_preinit_isolated2 in _testembed.o _test_preinit_parse_argv in _testembed.o ... "__Py_InitializeFromConfig", referenced from: _test_init_from_config in _testembed.o _test_init_dont_configure_locale in _testembed.o _test_init_dev_mode in _testembed.o _test_init_isolated_flag in _testembed.o _test_preinit_isolated1 in _testembed.o _test_preinit_isolated2 in _testembed.o _test_preinit_parse_argv in _testembed.o ... "__Py_InitializeMain", referenced from: _test_init_main in _testembed.o "__Py_PreInitialize", referenced from: _test_init_from_config in _testembed.o _test_init_dont_configure_locale in _testembed.o _test_preinit_isolated1 in _testembed.o _test_preinit_isolated2 in _testembed.o _check_preinit_isolated_config in _testembed.o _check_init_python_config in _testembed.o "__Py_PreInitializeFromWideArgs", referenced from: _test_preinit_dont_parse_argv in _testembed.o "__Py_RunMain", referenced from: _test_init_run_main in _testembed.o _test_init_main in _testembed.o _test_run_main in _testembed.o ld: symbol(s) not found for architecture x86_64 clangclang: : errorerror: : linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation) make: *** [Programs/_testembed] Error 1 make: *** Waiting for unfinished jobs.... make: *** [python.exe] Error 1 I tried run *make distclean* and reset my terminal but still not working. Thank you for helping. From songofacandy at gmail.com Wed May 22 00:37:09 2019 From: songofacandy at gmail.com (Inada Naoki) Date: Wed, 22 May 2019 13:37:09 +0900 Subject: CPython compiled failed in macOS In-Reply-To: References: Message-ID: You may need to clean your source tree. "make distclean" or "git clean -fx". 2019?5?22?(?) 13:34 Windson Yang : > > version: macOS 10.14.4, Apple LLVM version 10.0.1 (clang-1001.0.46.4). > > I cloned the CPython source code from GitHub then compiled it which used to > work quite well. However, I messed up my terminal a few days ago for > installing gdb. Now when I try to compile the latest CPython source code > with ./configure --with-pydebug && make -j I always get the error messages: > > ld: warning: ld: warning: ignoring file libpython3.8d.a, file was > built for archive which is not the architecture being linked (x86_64): > libpython3.8d.aignoring file libpython3.8d.a, file was built for > archive which is not the architecture being linked (x86_64): > libpython3.8d.a > Undefined symbols for architecture x86_64: > "__Py_UnixMain", referenced from: > _main in python.o > ld: symbol(s) not found for architecture x86_64Undefined symbols for > architecture x86_64: > "_PyEval_InitThreads", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > "_PyEval_ReleaseThread", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > "_PyEval_RestoreThread", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > _test_bpo20891 in _testembed.o > "_PyEval_SaveThread", referenced from: > _test_bpo20891 in _testembed.o > "_PyGILState_Check", referenced from: > _bpo20891_thread in _testembed.o > "_PyGILState_Ensure", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > _bpo20891_thread in _testembed.o > "_PyGILState_Release", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > _bpo20891_thread in _testembed.o > "_PyInterpreterState_GetID", referenced from: > _print_subinterp in _testembed.o > "_PyMem_RawFree", referenced from: > _test_pre_initialization_api in _testembed.o > "_PyRun_SimpleStringFlags", referenced from: > _test_pre_initialization_api in _testembed.o > _test_pre_initialization_sys_options in _testembed.o > _test_init_main in _testembed.o > _check_stdio_details in _testembed.o > _print_subinterp in _testembed.o > _dump_config in _testembed.o > "_PySys_AddWarnOption", referenced from: > _test_pre_initialization_sys_options in _testembed.o > "_PySys_AddXOption", referenced from: > _test_pre_initialization_sys_options in _testembed.o > "_PySys_ResetWarnOptions", referenced from: > _test_pre_initialization_sys_options in _testembed.o > "_PyThreadState_Get", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > _print_subinterp in _testembed.o > "_PyThreadState_Swap", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > "_PyThread_acquire_lock", referenced from: > _test_bpo20891 in _testembed.o > "_PyThread_allocate_lock", referenced from: > _test_bpo20891 in _testembed.o > "_PyThread_exit_thread", referenced from: > _bpo20891_thread in _testembed.o > "_PyThread_free_lock", referenced from: > _test_bpo20891 in _testembed.o > "_PyThread_release_lock", referenced from: > _bpo20891_thread in _testembed.o > "_PyThread_start_new_thread", referenced from: > _test_bpo20891 in _testembed.o > "_Py_BytesWarningFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > "_Py_DebugFlag", referenced from: > _set_all_global_config_variables in _testembed.o > "_Py_DecodeLocale", referenced from: > _test_pre_initialization_api in _testembed.o > "_Py_DontWriteBytecodeFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > _check_init_python_config in _testembed.o > "_Py_EndInterpreter", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > "_Py_Finalize", referenced from: > _test_forced_io_encoding in _testembed.o > _test_repeated_init_and_subinterpreters in _testembed.o > _test_pre_initialization_api in _testembed.o > _test_pre_initialization_sys_options in _testembed.o > _test_initialize_twice in _testembed.o > _test_initialize_pymain in _testembed.o > _test_init_default_config in _testembed.o > ... > "_Py_FrozenFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > _check_init_python_config in _testembed.o > "_Py_IgnoreEnvironmentFlag", referenced from: > _test_init_env in _testembed.o > _test_init_env_dev_mode in _testembed.o > _test_init_env_dev_mode_alloc in _testembed.o > _set_all_global_config_variables in _testembed.o > _check_init_python_config in _testembed.o > "_Py_Initialize", referenced from: > _test_forced_io_encoding in _testembed.o > _test_pre_initialization_api in _testembed.o > _test_initialize_twice in _testembed.o > _test_init_global_config in _testembed.o > __testembed_Py_Initialize in _testembed.o > "_Py_InspectFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > "_Py_InteractiveFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > "_Py_IsolatedFlag", referenced from: > _test_init_isolated_flag in _testembed.o > _test_preinit_isolated2 in _testembed.o > _set_all_global_config_variables in _testembed.o > _check_init_python_config in _testembed.o > "_Py_Main", referenced from: > _test_initialize_pymain in _testembed.o > "_Py_NewInterpreter", referenced from: > _test_repeated_init_and_subinterpreters in _testembed.o > "_Py_NoSiteFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > _check_init_python_config in _testembed.o > "_Py_NoUserSiteDirectory", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > _check_init_python_config in _testembed.o > "_Py_OptimizeFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > "_Py_QuietFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > "_Py_SetProgramName", referenced from: > _test_pre_initialization_api in _testembed.o > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > __testembed_Py_Initialize in _testembed.o > "_Py_SetStandardStreamEncoding", referenced from: > _test_forced_io_encoding in _testembed.o > _test_init_from_config in _testembed.o > _check_stdio_details in _testembed.o > "_Py_UTF8Mode", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > "_Py_UnbufferedStdioFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > _check_init_python_config in _testembed.o > "_Py_VerboseFlag", referenced from: > _test_init_global_config in _testembed.o > _test_init_from_config in _testembed.o > _set_all_global_config_variables in _testembed.o > "__PyCoreConfig_Clear", referenced from: > _test_preinit_parse_argv in _testembed.o > _test_preinit_dont_parse_argv in _testembed.o > _test_init_read_set in _testembed.o > _test_run_main in _testembed.o > "__PyCoreConfig_DecodeLocale", referenced from: > _test_init_read_set in _testembed.o > "__PyCoreConfig_Init", referenced from: > _test_init_from_config in _testembed.o > _test_preinit_isolated1 in _testembed.o > _test_preinit_isolated2 in _testembed.o > "__PyCoreConfig_InitIsolatedConfig", referenced from: > _test_preinit_dont_parse_argv in _testembed.o > _check_preinit_isolated_config in _testembed.o > "__PyCoreConfig_InitPythonConfig", referenced from: > _test_init_dont_configure_locale in _testembed.o > _test_init_dev_mode in _testembed.o > _test_init_isolated_flag in _testembed.o > _test_preinit_parse_argv in _testembed.o > _test_init_read_set in _testembed.o > _test_init_run_main in _testembed.o > _test_init_main in _testembed.o > ... > "__PyCoreConfig_Read", referenced from: > _test_init_read_set in _testembed.o > "__PyCoreConfig_SetString", referenced from: > _test_preinit_parse_argv in _testembed.o > _test_preinit_dont_parse_argv in _testembed.o > _test_init_read_set in _testembed.o > _test_run_main in _testembed.o > "__PyCoreConfig_SetWideArgv", referenced from: > _test_preinit_parse_argv in _testembed.o > _test_preinit_dont_parse_argv in _testembed.o > _test_run_main in _testembed.o > "__PyInitError_Failed", referenced from: > _test_init_from_config in _testembed.o > _test_init_dont_configure_locale in _testembed.o > _test_init_dev_mode in _testembed.o > _test_init_isolated_flag in _testembed.o > _test_preinit_isolated1 in _testembed.o > _test_preinit_isolated2 in _testembed.o > _test_preinit_parse_argv in _testembed.o > ... > "__PyInitError_NoMemory", referenced from: > _test_init_read_set in _testembed.o > "__PyPreConfig_Init", referenced from: > _test_init_from_config in _testembed.o > _test_preinit_isolated1 in _testembed.o > _test_preinit_isolated2 in _testembed.o > "__PyPreConfig_InitIsolatedConfig", referenced from: > _test_preinit_dont_parse_argv in _testembed.o > _check_preinit_isolated_config in _testembed.o > "__PyPreConfig_InitPythonConfig", referenced from: > _test_init_dont_configure_locale in _testembed.o > _check_init_python_config in _testembed.o > "__PyRuntime", referenced from: > _check_preinit_isolated_config in _testembed.o > "__PyWstrList_Append", referenced from: > _test_init_read_set in _testembed.o > "__Py_ExitInitError", referenced from: > _test_init_from_config in _testembed.o > _test_init_dont_configure_locale in _testembed.o > _test_init_dev_mode in _testembed.o > _test_init_isolated_flag in _testembed.o > _test_preinit_isolated1 in _testembed.o > _test_preinit_isolated2 in _testembed.o > _test_preinit_parse_argv in _testembed.o > ... > "__Py_InitializeFromConfig", referenced from: > _test_init_from_config in _testembed.o > _test_init_dont_configure_locale in _testembed.o > _test_init_dev_mode in _testembed.o > _test_init_isolated_flag in _testembed.o > _test_preinit_isolated1 in _testembed.o > _test_preinit_isolated2 in _testembed.o > _test_preinit_parse_argv in _testembed.o > ... > "__Py_InitializeMain", referenced from: > _test_init_main in _testembed.o > "__Py_PreInitialize", referenced from: > _test_init_from_config in _testembed.o > _test_init_dont_configure_locale in _testembed.o > _test_preinit_isolated1 in _testembed.o > _test_preinit_isolated2 in _testembed.o > _check_preinit_isolated_config in _testembed.o > _check_init_python_config in _testembed.o > "__Py_PreInitializeFromWideArgs", referenced from: > _test_preinit_dont_parse_argv in _testembed.o > "__Py_RunMain", referenced from: > _test_init_run_main in _testembed.o > _test_init_main in _testembed.o > _test_run_main in _testembed.o > ld: symbol(s) not found for architecture x86_64 > clangclang: : errorerror: : linker command failed with exit code 1 > (use -v to see invocation)linker command failed with exit code 1 (use > -v to see invocation) > > make: *** [Programs/_testembed] Error 1 > make: *** Waiting for unfinished jobs.... > make: *** [python.exe] Error 1 > > I tried run *make distclean* and reset my terminal but still not working. > Thank you for helping. > -- > https://mail.python.org/mailman/listinfo/python-list -- Inada Naoki From blmadhavan at gmail.com Wed May 22 02:48:43 2019 From: blmadhavan at gmail.com (Madhavan Bomidi) Date: Tue, 21 May 2019 23:48:43 -0700 (PDT) Subject: How to access metadata fields in HDF4 files in Python? Message-ID: <87fa1d2e-1215-42f2-8a49-642bbd96e802@googlegroups.com> Hi, I have imported the following libraries to access the data sets from a HDF4 file in Python 2.7 from pyhdf.SD import SD, SDC hdf = SD(FILE_NAME, SDC.READ) hdf.datasets() While I don't have any issues in accessing the contents of the data sets, I am unable to access the metadata. I have earlier accessed the metadata in MATLAB using the following commands: metadata = hdfread(infile, '/metadata', 'Fields', 'Lidar_Data_Altitudes', 'FirstRecord',1 ,'NumRecords',1) alts = metadata{1} What are the equivalent commands in Python for accessing the metadata fields from a HDF file in Python? Thanks in advance From robin at reportlab.com Wed May 22 03:51:30 2019 From: robin at reportlab.com (Robin Becker) Date: Wed, 22 May 2019 08:51:30 +0100 Subject: PEP 594 cgi & cgitb removal Message-ID: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> In PEP 594 t has been proposed that cgi & cgitb should be removed. I suspect I am not the only person in the world that likes using cgi and cgitb. One of the nice features in cgitb is the ability to get a nice traceback with variable values etc etc etc. I have used the underlying mechanism to produce better traceback information on several occasions and not only in cgi applications. I filed a bug against cgitb in 2004 with (apparently unacceptable patches) that is still unfixed. Although cgi is claimed to be dead it is still one of the easiest ways to get a web service to operate; it is also stateless and robust. If cgi and similar are removed from the stdlib python will become significantly less charged. These batteries are not dead they are pining. There is some discussion on the python-dev list of moving these allegedly dead packages to pypi, but of course that means issues of control, where do the sources reside and other politics. Django has a similar feature to cgitb's output for tracebacks, but is too deeply embedded for use elsewhere; is there anything suitable elsewhere? -- Robin Becker From sirso81 at gmail.com Wed May 22 04:44:37 2019 From: sirso81 at gmail.com (Sirso Bhatto) Date: Wed, 22 May 2019 14:14:37 +0530 Subject: Installation problem with python 3.7 in windows 7 ultimate p.c(32 bit) showing unspecified error 0x80072ee7... Message-ID: Hi.. I am Shirsendu. I encountered a problem while installing python 3.7 in my windows 7 ultimate p.c(32 bit) . It is showing an unspecified error of 0x80072ee7 when i am trying to initialize it in my pc. Please help me. From mal at europython.eu Wed May 22 06:24:11 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Wed, 22 May 2019 12:24:11 +0200 Subject: EuroPython 2019: First batch of accepted sessions Message-ID: <4ffc7d45-0776-7e51-c975-77341b82faa2@europython.eu> Our program work group (WG) has been working hard over the weekend to select the sessions for EuroPython 2019. * https://ep2019.europython.eu/events/sessions/ * We?re now happy to announce the first batch with: - 112 talks, - 12 trainings, - 6 posters, - 1 interactive session and - 5 helpdesks brought to you by 129 speakers: * https://ep2019.europython.eu/events/speakers/ * More advanced talks than in previous EuroPython editions -------------------------------------------------------- We are glad that the Python community has heard our call to submit more advanced talks this year. This will make EuroPython 2019 even more interesting than our previous editions. Waiting List ------------ Some talks are still in the waiting list. We will inform all speakers who have submitted talks about the selection status by email. PyData EuroPython 2019 ---------------------- As in previous years, we will have lots of PyData talks and trainings: - 4 trainings on Monday and Tuesday (July 8-9) - 34 talks on Wednesday and Thursday (July 10-11) - no PyData talks on Friday (July 12) Full Schedule ------------- The full schedule will be available early in June. Training Tickets & Combined Tickets ----------------------------------- If you want to attend the trainings offered on the training days (July 8-9), please head over to the registration page in the next couple of days. Sales are going strong and we only have 300 tickets available. Combined tickets are new this year and allow attending both training and conference days with a single ticket. Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). Tickets can be purchased on our registration page: https://ep2019.europython.eu/registration/buy-tickets/ For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/185058369732/europython-2019-first-batch-of-accepted-sessions Tweet: https://twitter.com/europython/status/1131140414910750720 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From p.f.moore at gmail.com Wed May 22 06:25:59 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 22 May 2019 11:25:59 +0100 Subject: What does at 0x0402C7B0> mean? In-Reply-To: References: Message-ID: On Wed, 22 May 2019 at 02:45, Terry Reedy wrote: > > On 5/21/2019 9:11 PM, CrazyVideoGamez wrote: > > I tried doing a list comprehension. I typed: > > > > favorite_fruits = ['watermelon', 'blackberries'] > > print(fruit for fruit in favorite_fruits) > > > > And I got: > > at 0x0402C7B0> > > What does this mean > > It means that the expression (fruit for fruit in favorite_fruits) > evaluates to a generator object. > > > and what do I have to fix? > > Perhaps you wanted to run the generator, perhaps like this: > > >>> favorite_fruits = ['watermelon', 'blackberries'] > >>> print(*(fruit for fruit in favorite_fruits)) > watermelon blackberries Or maybe you just wanted a loop? for fruit in favorite_fruits: print(fruit) Generator and list comprehension syntax is a somewhat more advanced feature of Python (not *very* advanced, particularly in the case of list comprehensions, but enough so to be tricky for a newcomer). I don't know how much experience the OP has with Python, but as a general rule, it's always better to stick with the simplest approach that does what you want, and statements like loops are simpler than complex one-line expressions (even if the complex one liners make you look cool ;-)) Paul From inhahe at gmail.com Wed May 22 07:16:55 2019 From: inhahe at gmail.com (inhahe) Date: Wed, 22 May 2019 07:16:55 -0400 Subject: What does at 0x0402C7B0> mean? In-Reply-To: References: Message-ID: Short answer: (some generator expression) is for iterating over, as others have said. try this: print([fruit for fruit in favorite_fruits]) a loop would work too, as someone mentioned, but the result would be different. you'd get your fruits separated by line breaks (or something else if you specify that), and with no quotation marks, instead of in list form. also note: print(favorite_fruits) will do the same thing as print([fruit for fruit in favorite_fruits]) so there's no need to put a list comprehension there. On Tue, May 21, 2019 at 9:16 PM CrazyVideoGamez wrote: > I tried doing a list comprehension. I typed: > > favorite_fruits = ['watermelon', 'blackberries'] > print(fruit for fruit in favorite_fruits) > > And I got: > > at 0x0402C7B0> > > What does this mean and what do I have to fix? > -- > https://mail.python.org/mailman/listinfo/python-list > From eryksun at gmail.com Wed May 22 08:14:37 2019 From: eryksun at gmail.com (eryk sun) Date: Wed, 22 May 2019 07:14:37 -0500 Subject: Installation problem with python 3.7 in windows 7 ultimate p.c(32 bit) showing unspecified error 0x80072ee7... In-Reply-To: References: Message-ID: On 5/22/19, Sirso Bhatto wrote: > > I am Shirsendu. I encountered a problem while installing python 3.7 > in my windows 7 ultimate p.c(32 bit) . It is showing an unspecified error > of 0x80072ee7 when i am trying to initialize it in my pc. Please help me. A status code with only the high bit set in the high nibble (e.g. 0x8) is likely a failure code in the HRESULT [1] domain. 0x007 in the next 3 nibbles (i.e. the facility code) is the Windows API facility (i.e. FACILITY_WIN32). This tells us that the lower 4 nibbles (16-bit word) is a Windows system error code [2]. In this case, 0x2EE7 (12007) is the WinINet error code [3] ERROR_INTERNET_NAME_NOT_RESOLVED, i.e. the server name could not be resolved. It appears there's an issue with your network connection or DNS configuration in this context. Try using the offline executable installer [4], and make sure to clear the option to install the debug binaries and symbols since those have to be downloaded. [1]: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a [2]: https://docs.microsoft.com/en-us/windows/desktop/Debug/system-error-codes [3]: https://docs.microsoft.com/en-us/windows/desktop/WinInet/wininet-errors [4]: https://www.python.org/ftp/python/3.7.3/python-3.7.3.exe From rhodri at kynesim.co.uk Wed May 22 07:47:33 2019 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 22 May 2019 12:47:33 +0100 Subject: PEP 594 cgi & cgitb removal In-Reply-To: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> Message-ID: <6e9ba04a-a501-d6ee-ef72-632a9384c2f5@kynesim.co.uk> On 22/05/2019 08:51, Robin Becker wrote: > In PEP 594 t has been proposed that cgi & cgitb should be removed. I > suspect I am not the only person in the world that likes using cgi and > cgitb. Can I second this? I just started writing a small CGI application in Python, and if cgi and cgitb were going to disappear I would have to rewrite it in C or similar. (No, using something more complex than CGI is not an option. I'm working on an embedded system, and we're watching our RAM usage nervously enough already.) -- Rhodri James *-* Kynesim Ltd From inhahe at gmail.com Wed May 22 09:48:58 2019 From: inhahe at gmail.com (inhahe) Date: Wed, 22 May 2019 09:48:58 -0400 Subject: PEP 594 cgi & cgitb removal In-Reply-To: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> Message-ID: Re cgitb, not sure if this is what you want, but I just came across this this week: https://github.com/cknd/stackprinter On Wed, May 22, 2019 at 3:52 AM Robin Becker wrote: > In PEP 594 t has been proposed that cgi & cgitb should be removed. I > suspect I am not the only person in the world that likes > using cgi and cgitb. > > One of the nice features in cgitb is the ability to get a nice traceback > with variable values etc etc etc. I have used the > underlying mechanism to produce better traceback information on several > occasions and not only in cgi applications. > > I filed a bug against cgitb in 2004 with (apparently unacceptable patches) > that is still unfixed. > > Although cgi is claimed to be dead it is still one of the easiest ways to > get a web service to operate; it is also stateless and > robust. If cgi and similar are removed from the stdlib python will become > significantly less charged. These batteries are not dead > they are pining. > > There is some discussion on the python-dev list of moving these allegedly > dead packages to pypi, but of course that means issues > of control, where do the sources reside and other politics. > > Django has a similar feature to cgitb's output for tracebacks, but is too > deeply embedded for use elsewhere; is there anything > suitable elsewhere? > -- > Robin Becker > > -- > https://mail.python.org/mailman/listinfo/python-list > From python.list at tim.thechases.com Wed May 22 10:52:23 2019 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 22 May 2019 09:52:23 -0500 Subject: PEP 594 cgi & cgitb removal In-Reply-To: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> Message-ID: <20190522095223.46755e48@bigbox.christie.dr> On 2019-05-22 08:51, Robin Becker wrote: > In PEP 594 t has been proposed that cgi & cgitb should be removed. > I suspect I am not the only person in the world that likes using > cgi and cgitb. /me waves from the the back row as another cgi/cgitb user... -tkc From tjreedy at udel.edu Wed May 22 14:29:17 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 22 May 2019 14:29:17 -0400 Subject: PEP 594 cgi & cgitb removal In-Reply-To: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> Message-ID: On 5/22/2019 3:51 AM, Robin Becker wrote: > In PEP 594 t has been proposed that cgi & cgitb should be removed. I > suspect I am not the only person in the world that likes using cgi and > cgitb. I suspect that there will be at least one person objecting to each removal. But the underlying issue, at least to me, is that the number and complexity of stdlib modules has grown significantly faster than the number of active core developers. One of the factors being considered in removal decisions is the absence of anyone willing to list themselves in the expert's list https://devguide.python.org/experts/ as a maintainer for a module. At the moment, 3 other people have objected to the removal of these modules. I suspect that at least 2 of you 4 are at least as technically qualified to be a core developer as I am. A request to become the maintainer of cgi and cgitb *might* affect the decision. > I filed a bug against cgitb in 2004 with (apparently unacceptable > patches) that is still unfixed. I cannot say much without a link. 'Apparently' suggests that it was not explicitly rejected. Was there any review? Lack of reviews is a current bottleneck in merging issues. Most people are much more willing to submit their own code than review that of others. If you were to submit a new, and likely better patch (PR), perhaps others who want to keep the modules would review it. -- Terry Jan Reedy From dieter at handshake.de Thu May 23 01:11:50 2019 From: dieter at handshake.de (dieter) Date: Thu, 23 May 2019 07:11:50 +0200 Subject: PEP 594 cgi & cgitb removal References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> Message-ID: <87d0k9iwkp.fsf@handshake.de> Robin Becker writes: > In PEP 594 t has been proposed that cgi & cgitb should be removed. I > suspect I am not the only person in the world that likes using cgi and > cgitb. Currently, "Zope" is using "cgi"; it uses "zExceptions" (--> PyPI) for tracebacks. Should "cgi" disappear from the standard library, I am quite confident that "Zope" will get a replacement. "Zope" is known to be build out of components (i.e. individual packages) which can be used independently from "Zope" itself (e.g. "zope.interface", "ZODB", "transaction", ...). Thus, there is a good chance that there will be an open source, maintained module supporting core features of the current "cgi" module. From mal at europython.eu Thu May 23 04:03:47 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Thu, 23 May 2019 10:03:47 +0200 Subject: EuroPython 2019: Monday and Tuesday activities for main conference attendees Message-ID: <70ad5f20-fb06-44f5-9149-8a7246d090b6@europython.eu> Although the main conference starts on Wednesday, July 10th, there?s already so much to do for attendees with the main conference ticket on Monday 8th and Tuesday 9th. Beginners? Day and Sponsored Trainings -------------------------------------- You can come to the workshops and trainings venue at FHNW Campus Muttenz and: - pick up your conference badge - attend the Beginners? Day workshop - attend the sponsored trainings If you want to attend other workshops and trainings, you?ll need a separate training ticket or combined ticket. Details on the Beginners? Day workshop and the sponsored trainings will be announced separately. Catering on training days not included -------------------------------------- Since we have to budget carefully, the lunch and coffee breaks are not included, if you don?t have a training or combined ticket. To not keep you hungry, we have arranged that you can buy lunch coupons (price to be announced later). You can also go to the grocery store at the ground floor. For coffee breaks you can go to the ground floor, to the 12th floor of the FHNW building, or outside at the beach bar (nice weather only) and buy drinks. * https://ep2019.europython.eu/registration/buy-tickets/ * Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). Tickets can be purchased on our registration page: https://ep2019.europython.eu/registration/buy-tickets/ For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/185080400427/europython-2019-monday-and-tuesday-activities-for Tweet: https://twitter.com/europython/status/1131470223205445632 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From jon+usenet at unequivocal.eu Thu May 23 08:33:27 2019 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Thu, 23 May 2019 12:33:27 -0000 (UTC) Subject: PEP 594 cgi & cgitb removal References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <87d0k9iwkp.fsf@handshake.de> <871s0peoio.fsf@nightsong.com> Message-ID: On 2019-05-23, Paul Rubin wrote: > dieter writes: >> Should "cgi" disappear from the standard library > > It's also a concern that cgi may be disappearing from web servers. Last > I heard, nginx didn't support it. That's part of why I still use > apache, or (local only) even CGIHTTPServer.py. I don't know what the > current hotness in httpd's is though. nginx is the current hotness. CGI has not been hotness since the mid 90s. From rhodri at kynesim.co.uk Thu May 23 08:23:09 2019 From: rhodri at kynesim.co.uk (Rhodri James) Date: Thu, 23 May 2019 13:23:09 +0100 Subject: PEP 594 cgi & cgitb removal In-Reply-To: References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> Message-ID: <6ce73371-862e-50c9-425b-189d7f27e595@kynesim.co.uk> On 22/05/2019 19:29, Terry Reedy wrote: > One of the factors being considered in removal decisions is the absence > of anyone willing to list themselves in the expert's list > https://devguide.python.org/experts/ > as a maintainer for a module. > > At the moment, 3 other people have objected to the removal of these > modules.? I suspect that at least 2 of you 4 are at least as technically > qualified to be a core developer as I am.? A request to become the > maintainer of cgi and cgitb *might* affect the decision. A quick read-through of the modules (I am supposed to be working right now) suggests that maintaining them wouldn't be a massive effort. Definitely something to think about. -- Rhodri James *-* Kynesim Ltd From Cecil at decebal.nl Thu May 23 09:17:20 2019 From: Cecil at decebal.nl (Cecil Westerhof) Date: Thu, 23 May 2019 15:17:20 +0200 Subject: Handling an connection error with Twython Message-ID: <8736l5qpi7.fsf@munus.decebal.nl> I am using Twython to post updates on Twitter. Lately there is now and then a problem with my internet connection. I am using: posted = twitter.update_status(status = message, in_reply_to_status_id = message_id, trim_user = True) What would be the best way to catch a connection error and try it (for example) again maximum three times with a delay of one minute? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From skip.montanaro at gmail.com Thu May 23 10:39:59 2019 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 23 May 2019 09:39:59 -0500 Subject: How do you organize your virtual environments? Message-ID: Perhaps the subject isn't quite correct, but here's what I'm after. Suppose you have five applications, each going through a series of dev, test and prod phases. I will assume without further explanation or justification, that the dev phase is wholly within the purview of the developers who gets to organize their environments as they see fit. The test and prod phases involve actual deployment though, and so require a defined virtual environment. The five applications need not be terribly closely related. How do you organize those environments? The two extremes would seem to be: * per-application virtual environments, so ten in all * a common virtual environment for all applications, so just test and prod, two in all My way of thinking about virtual environments has always leaned in the direction of a per-application setup, as that requires less coordination (particularly when deploying to production), but I'm willing to be convinced to move in fewer-environments-is-better direction. Here's a concrete question for people who favor fewer environments: Suppose application #4 requires an update to some package used by all five applications. What's your protocol for deployment to test and prod? Thanks, Skip From rosuav at gmail.com Thu May 23 10:57:08 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 May 2019 00:57:08 +1000 Subject: How do you organize your virtual environments? In-Reply-To: References: Message-ID: On Fri, May 24, 2019 at 12:42 AM Skip Montanaro wrote: > My way of thinking about virtual environments has always leaned in the > direction of a per-application setup, as that requires less > coordination (particularly when deploying to production), but I'm > willing to be convinced to move in fewer-environments-is-better > direction. Here's a concrete question for people who favor fewer > environments: Suppose application #4 requires an update to some > package used by all five applications. What's your protocol for > deployment to test and prod? > If the applications are separate (such that you could logically and sanely install app #2 on one computer and app #5 on another), separate venvs for each. That does mean that a security or other crucial update will need to be applied to each, but it also keeps everything self-contained; app #1 has a requirements.txt that names only the packages that app #1 needs, and it's running in a venv that has only the packages that its requirements.txt lists. OTOH, if the applications are more closely related, such that you really can't take them separately, then they're really one application with multiple components. In that case, I'd have them all in a single venv (and probably a single git repository for the source code), with multiple entry points within that. That keeps common dependencies together, makes it easier to import modules from one into another, etc. Generally speaking, I would have a single git repo correspond to a single venv, linked via the requirements.txt file(s). Versioning of the source code is thus tied to the versioning of your dependencies and vice versa. ChrisA From evans5551 at gmail.com Thu May 23 13:48:47 2019 From: evans5551 at gmail.com (Carolyn Evans) Date: Thu, 23 May 2019 13:48:47 -0400 Subject: Installation Problems with Python 3.7.3 In-Reply-To: References: Message-ID: I got it working. Thanks On Mon, May 20, 2019 at 3:17 PM Igor Korot wrote: > Hi, > > On Mon, May 20, 2019 at 1:53 PM Carolyn Evans wrote: > > > > I am having trouble with re-installing python 3.7.3. > > Why do you need to reinstall? > What seems to be the problem? > > Thank you. > > > > > I keep getting the following message: > > > > Modify > > Repair > > Remove > > > > I have tried all three numerous times and can not complete the setup > > > > I am working on a Windows 8 system, 64 bit OS, 4GB ram. > > > > How can this be fixed? > > > > Thanks > > > > C. Evans > > -- > > https://mail.python.org/mailman/listinfo/python-list > From bob at mellowood.ca Thu May 23 14:39:41 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Thu, 23 May 2019 11:39:41 -0700 Subject: More CPUs doen't equal more speed Message-ID: I've got a short script that loops though a number of files and processes them one at a time. I had a bit of time today and figured I'd rewrite the script to process the files 4 at a time by using 4 different instances of python. My basic loop is: for i in range(0, len(filelist), CPU_COUNT): for z in range(i, i+CPU_COUNT): doit( filelist[z]) With the function doit() calling up the program to do the lifting. Setting CPU_COUNT to 1 or 5 (I have 6 cores) makes no difference in total speed. I'm processing about 1200 files and my total duration is around 2 minutes. No matter how many cores I use the total is within a 5 second range. This is not a big deal ... but I really thought that throwing more processors at a problem was a wonderful thing :) I figure that the cost of loading the python libraries and my source file and writing it out are pretty much i/o bound, but that is just a guess. Maybe I need to set my sights on bigger, slower programs to see a difference :) -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca From rosuav at gmail.com Thu May 23 15:39:09 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 May 2019 05:39:09 +1000 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: On Fri, May 24, 2019 at 5:37 AM Bob van der Poel wrote: > > I've got a short script that loops though a number of files and processes > them one at a time. I had a bit of time today and figured I'd rewrite the > script to process the files 4 at a time by using 4 different instances of > python. My basic loop is: > > for i in range(0, len(filelist), CPU_COUNT): > for z in range(i, i+CPU_COUNT): > doit( filelist[z]) > > With the function doit() calling up the program to do the lifting. Setting > CPU_COUNT to 1 or 5 (I have 6 cores) makes no difference in total speed. > I'm processing about 1200 files and my total duration is around 2 minutes. > No matter how many cores I use the total is within a 5 second range. Where's the part of the code that actually runs them across multiple CPUs? Also, are you spending your time waiting on the disk, the CPU, IPC, or something else? ChrisA From David.Raymond at tomtom.com Thu May 23 16:18:08 2019 From: David.Raymond at tomtom.com (David Raymond) Date: Thu, 23 May 2019 20:18:08 +0000 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: You really need to give more info on what you're doing in doit() to know what's going on. Are you using subprocess, threading, multiprocessing, etc? Going off of what you've put there those nested for loops are being run in the 1 main thread. If doit() kicks off a program and doesn't wait for it to finish, then you're just instantly starting 1,200 versions of the external program. If doit() _does_ wait for it to finish then you're not doing anything different than 1,200 one-at-a-time calls with no parallelization. How are you making sure you have CPU_COUNT versions running, only that many running, and kicking off the next one once any of those completes? -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Bob van der Poel Sent: Thursday, May 23, 2019 2:40 PM To: Python Subject: More CPUs doen't equal more speed I've got a short script that loops though a number of files and processes them one at a time. I had a bit of time today and figured I'd rewrite the script to process the files 4 at a time by using 4 different instances of python. My basic loop is: for i in range(0, len(filelist), CPU_COUNT): for z in range(i, i+CPU_COUNT): doit( filelist[z]) With the function doit() calling up the program to do the lifting. Setting CPU_COUNT to 1 or 5 (I have 6 cores) makes no difference in total speed. I'm processing about 1200 files and my total duration is around 2 minutes. No matter how many cores I use the total is within a 5 second range. This is not a big deal ... but I really thought that throwing more processors at a problem was a wonderful thing :) I figure that the cost of loading the python libraries and my source file and writing it out are pretty much i/o bound, but that is just a guess. Maybe I need to set my sights on bigger, slower programs to see a difference :) -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list From gunnar at magnusson.io Thu May 23 08:46:35 2019 From: gunnar at magnusson.io (Gunnar =?utf-8?B?w57Ds3IgTWFnbsO6c3Nvbg==?=) Date: Thu, 23 May 2019 14:46:35 +0200 Subject: PEP 594 cgi & cgitb removal In-Reply-To: References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <87d0k9iwkp.fsf@handshake.de> <871s0peoio.fsf@nightsong.com> Message-ID: <20190523124635.hphiagslwrbdjnz7@gthmcloud> > nginx is the current hotness. CGI has not been hotness since the mid 90s. Serverless is the new hotness, and serverless is CGI. Technology is cyclical. From avigross at verizon.net Thu May 23 17:41:36 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 23 May 2019 17:41:36 -0400 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: <010f01d511b0$4c995090$e5cbf1b0$@verizon.net> Bob, As others have noted, you have not made it clear how what you are doing is running "in parallel." I have a similar need where I have thousands of folders and need to do an analysis based on the contents of one at a time and have 8 cores available but the process may run for months if run linearly. The results are placed within the same folder so each part can run independently as long as shared resources like memory are not abused. Your need is conceptually simple. Break up the list of filenames into N batches of about equal length. A simple approach might be to open N terminal or command windows and in each one start a python interpreter by hand running the same program which gets one of the file lists and works on it. Some may finish way ahead of others, of course. If anything they do writes to shared resources such as log files, you may want to be careful. And there is no guarantee that several will not run on the same CPU. There is also plenty of overhead associated with running full processes. I am not suggesting this but it is fairly easy to do and may get you enough speedup. But since you only seem to need a few minutes, this won't be much. Quite a few other solutions involve using some form of threads running within a process perhaps using a queue manager. Python has multiple ways to do this. You would simply feed all the info needed (file names in your case) to a thread that manages a queue. It would allow up to N threads to be started and whenever one finishes, would be woken to start a replacement till done. Unless one such thread takes very long, they should all finish reasonably close to each other. Again, lots of details to make sure the threads do not conflict with each other. But, no guarantee which core they get unless you use an underlying package that manages that. So you might want to research available packages that do much of the work for you and provide some guarantees. An interesting question is how to set the chosen value of N. Just because you have N cores, you do not necessarily choose N. There are other things happening on the same machine with sometimes thousands of processes or threads in the queue even when the machine is sitting there effectively doing nothing. If you will also keep multiple things open (mailer, WORD, browsers, ...) you need some bandwidth so everything else gets enough attention. So is N-1 or N-2 better? Then again, if your task has a mix of CPU and I/O activities then it may make sense to run more than N in parallel even if several of them end up on the same CORE as they may interleave with each other and one make use of the CPU while the others are waiting on I/O or anything slower. I am curious to hear what you end up with. I will be reading to see if others can point to modules that already support something like this with you supplying just a function to use for each thread. I suggest you consider your architecture carefully. Sometimes it is better to run program A (in Python or anything else) that sets up what is needed including saving various data structures on disk needed for each individual run. Then you start the program that reads from the above and does the parallel computations and again writes out what is needed such as log entries, or data in a CSV. Finally, when it is all done, another program can gather in the various outputs and produce a consolidated set of info. That may be extra work but minimizes the chance of the processes interfering with each other. It also may allow you to run or re-run smaller batches or even to farm out the work to other machines. If you create a few thousand directories (or just files) with names like do0001 then you can copy them to another machine where you ask it to work on do0* and yet another on do1* and so on, using the same script. This makes more sense for my project which literally may take months or years if run exhaustively on something like a grid search trying huge numbers of combinations. Good luck. Avi -----Original Message----- From: Python-list On Behalf Of Bob van der Poel Sent: Thursday, May 23, 2019 2:40 PM To: Python Subject: More CPUs doen't equal more speed I've got a short script that loops though a number of files and processes them one at a time. I had a bit of time today and figured I'd rewrite the script to process the files 4 at a time by using 4 different instances of python. My basic loop is: for i in range(0, len(filelist), CPU_COUNT): for z in range(i, i+CPU_COUNT): doit( filelist[z]) With the function doit() calling up the program to do the lifting. Setting CPU_COUNT to 1 or 5 (I have 6 cores) makes no difference in total speed. I'm processing about 1200 files and my total duration is around 2 minutes. No matter how many cores I use the total is within a 5 second range. This is not a big deal ... but I really thought that throwing more processors at a problem was a wonderful thing :) I figure that the cost of loading the python libraries and my source file and writing it out are pretty much i/o bound, but that is just a guess. Maybe I need to set my sights on bigger, slower programs to see a difference :) -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list From Cecil at decebal.nl Thu May 23 17:55:52 2019 From: Cecil at decebal.nl (Cecil Westerhof) Date: Thu, 23 May 2019 23:55:52 +0200 Subject: Handling an connection error with Twython References: <8736l5qpi7.fsf@munus.decebal.nl> Message-ID: <87y32wq1hz.fsf@munus.decebal.nl> Cecil Westerhof writes: > I am using Twython to post updates on Twitter. Lately there is now and > then a problem with my internet connection. I am using: > posted = twitter.update_status(status = message, > in_reply_to_status_id = message_id, > trim_user = True) > > What would be the best way to catch a connection error and try it (for > example) again maximum three times with a delay of one minute? At the moment I solved it with the following: max_tries = 3 current_try = 1 while True: try: posted = twitter.update_status(status = message, in_reply_to_status_id = message_id, trim_user = True) return posted['id'] except TwythonError as e: print('Failed on try: {0}'.format(current_try)) if not 'Temporary failure in name resolution' in e.msg: raise if current_try == max_tries: raise current_try += 1 time.sleep(60) Is this a good way to do it, or can it be improved on? When it goes OK I just return from the function. If it goes wrong for something else as failure in the name resolution I re-raise the exception. When the maximum tries are done I re-raise the exception. Otherwise I wait a minute to try it again. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From python at mrabarnett.plus.com Thu May 23 19:24:11 2019 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 24 May 2019 00:24:11 +0100 Subject: More CPUs doen't equal more speed In-Reply-To: <010f01d511b0$4c995090$e5cbf1b0$@verizon.net> References: <010f01d511b0$4c995090$e5cbf1b0$@verizon.net> Message-ID: <6faad968-0faa-0d81-c1e7-264425211e6e@mrabarnett.plus.com> On 2019-05-23 22:41, Avi Gross via Python-list wrote: > Bob, > > As others have noted, you have not made it clear how what you are doing is > running "in parallel." > > I have a similar need where I have thousands of folders and need to do an > analysis based on the contents of one at a time and have 8 cores available > but the process may run for months if run linearly. The results are placed > within the same folder so each part can run independently as long as shared > resources like memory are not abused. > > Your need is conceptually simple. Break up the list of filenames into N > batches of about equal length. A simple approach might be to open N terminal > or command windows and in each one start a python interpreter by hand > running the same program which gets one of the file lists and works on it. > Some may finish way ahead of others, of course. If anything they do writes > to shared resources such as log files, you may want to be careful. And there > is no guarantee that several will not run on the same CPU. There is also > plenty of overhead associated with running full processes. I am not > suggesting this but it is fairly easy to do and may get you enough speedup. > But since you only seem to need a few minutes, this won't be much. > > Quite a few other solutions involve using some form of threads running > within a process perhaps using a queue manager. Python has multiple ways to > do this. You would simply feed all the info needed (file names in your case) > to a thread that manages a queue. It would allow up to N threads to be > started and whenever one finishes, would be woken to start a replacement > till done. Unless one such thread takes very long, they should all finish > reasonably close to each other. Again, lots of details to make sure the > threads do not conflict with each other. But, no guarantee which core they > get unless you use an underlying package that manages that. > [snip] Because of the GIL, only 1 Python thread will actually be running at any time, so if it's processor-intensive, it's better to use multiprocessing. Of course, if it's already maxing out the disk, then using more cores won't make it faster. From python at mrabarnett.plus.com Thu May 23 19:26:04 2019 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 24 May 2019 00:26:04 +0100 Subject: Handling an connection error with Twython In-Reply-To: <87y32wq1hz.fsf@munus.decebal.nl> References: <8736l5qpi7.fsf@munus.decebal.nl> <87y32wq1hz.fsf@munus.decebal.nl> Message-ID: <2e4f24a1-0806-96a9-3cc9-0f418043f82a@mrabarnett.plus.com> On 2019-05-23 22:55, Cecil Westerhof wrote: > Cecil Westerhof writes: > >> I am using Twython to post updates on Twitter. Lately there is now and >> then a problem with my internet connection. I am using: >> posted = twitter.update_status(status = message, >> in_reply_to_status_id = message_id, >> trim_user = True) >> >> What would be the best way to catch a connection error and try it (for >> example) again maximum three times with a delay of one minute? > > At the moment I solved it with the following: > max_tries = 3 > current_try = 1 > while True: > try: > posted = twitter.update_status(status = message, > in_reply_to_status_id = message_id, > trim_user = True) > return posted['id'] > except TwythonError as e: > print('Failed on try: {0}'.format(current_try)) > if not 'Temporary failure in name resolution' in e.msg: > raise > if current_try == max_tries: > raise > current_try += 1 > time.sleep(60) > > Is this a good way to do it, or can it be improved on? > > When it goes OK I just return from the function. > If it goes wrong for something else as failure in the name resolution > I re-raise the exception. > When the maximum tries are done I re-raise the exception. > Otherwise I wait a minute to try it again. > You have a 'while' loop with a counter; you can replace that with a 'for' loop. From bob at mellowood.ca Thu May 23 20:04:49 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Thu, 23 May 2019 17:04:49 -0700 Subject: More CPUs doen't equal more speed In-Reply-To: <6faad968-0faa-0d81-c1e7-264425211e6e@mrabarnett.plus.com> References: <010f01d511b0$4c995090$e5cbf1b0$@verizon.net> <6faad968-0faa-0d81-c1e7-264425211e6e@mrabarnett.plus.com> Message-ID: Thanks all! The sound you are hearing is my head smacking against my hand! Or is it my hand against my head? Anyway, yes the problem is that I was naively using command.getoutput() which blocks until the command is finished. So, of course, only one process was being run at one time! Bad me! I guess I should be looking at subprocess.Popen(). Now, a more relevant question ... if I do it this way I then need to poll though a list of saved process IDs to see which have finished? Right? My initial thought is to batch them up in small groups (say CPU_COUNT-1) and wait for that batch to finish, etc. Would it be foolish to send send a large number (1200 in this case since this is the number of files) and let the OS worry about scheduling and have my program poll 1200 IDs? Someone mentioned the GIL. If I launch separate processes then I don't encounter this issue? Right? On Thu, May 23, 2019 at 4:24 PM MRAB wrote: > On 2019-05-23 22:41, Avi Gross via Python-list wrote: > > Bob, > > > > As others have noted, you have not made it clear how what you are doing > is > > running "in parallel." > > > > I have a similar need where I have thousands of folders and need to do an > > analysis based on the contents of one at a time and have 8 cores > available > > but the process may run for months if run linearly. The results are > placed > > within the same folder so each part can run independently as long as > shared > > resources like memory are not abused. > > > > Your need is conceptually simple. Break up the list of filenames into N > > batches of about equal length. A simple approach might be to open N > terminal > > or command windows and in each one start a python interpreter by hand > > running the same program which gets one of the file lists and works on > it. > > Some may finish way ahead of others, of course. If anything they do > writes > > to shared resources such as log files, you may want to be careful. And > there > > is no guarantee that several will not run on the same CPU. There is also > > plenty of overhead associated with running full processes. I am not > > suggesting this but it is fairly easy to do and may get you enough > speedup. > > But since you only seem to need a few minutes, this won't be much. > > > > Quite a few other solutions involve using some form of threads running > > within a process perhaps using a queue manager. Python has multiple ways > to > > do this. You would simply feed all the info needed (file names in your > case) > > to a thread that manages a queue. It would allow up to N threads to be > > started and whenever one finishes, would be woken to start a replacement > > till done. Unless one such thread takes very long, they should all finish > > reasonably close to each other. Again, lots of details to make sure the > > threads do not conflict with each other. But, no guarantee which core > they > > get unless you use an underlying package that manages that. > > > [snip] > > Because of the GIL, only 1 Python thread will actually be running at any > time, so if it's processor-intensive, it's better to use multiprocessing. > > Of course, if it's already maxing out the disk, then using more cores > won't make it faster. > -- > https://mail.python.org/mailman/listinfo/python-list > -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca From rosuav at gmail.com Thu May 23 20:22:40 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 May 2019 10:22:40 +1000 Subject: More CPUs doen't equal more speed In-Reply-To: References: <010f01d511b0$4c995090$e5cbf1b0$@verizon.net> <6faad968-0faa-0d81-c1e7-264425211e6e@mrabarnett.plus.com> Message-ID: On Fri, May 24, 2019 at 10:07 AM Bob van der Poel wrote: > > Thanks all! The sound you are hearing is my head smacking against my hand! > Or is it my hand against my head? > > Anyway, yes the problem is that I was naively using command.getoutput() > which blocks until the command is finished. So, of course, only one process > was being run at one time! Bad me! > > I guess I should be looking at subprocess.Popen(). Now, a more relevant > question ... if I do it this way I then need to poll though a list of saved > process IDs to see which have finished? Right? My initial thought is to > batch them up in small groups (say CPU_COUNT-1) and wait for that batch to > finish, etc. Would it be foolish to send send a large number (1200 in this > case since this is the number of files) and let the OS worry about > scheduling and have my program poll 1200 IDs? That might create a lot of contention, resulting in poor performance. But depending on what your tasks saturate on, that might not matter all that much, and it _would_ be a simple and straight-forward technique. In fact, you could basically just write your code like this: for job in jobs: start_process() for process in processes: wait_for_process() Once they're all started, you just wait for the first one to finish. Then when that's finished, wait for the next, and the next, and the next. If the first process started is actually the slowest to run, all the others will be in the "done" state for a while, but that's not a big deal. > Someone mentioned the GIL. If I launch separate processes then I don't > encounter this issue? Right? The GIL is basically irrelevant here. Most of the work is being done in subprocesses, so your code is spending all its time waiting. What I'd recommend is a thread pool. Broadly speaking, it would look something like this: jobs = [...] def run_jobs(): while jobs: try: job = jobs.pop() except IndexError: break # deal with race start_subprocess() wait_for_subprocess() threads = [threading.Thread(target=run_jobs).start() for _ in THREAD_COUNT] for thread in threads: thread.join() Note that this has the same "start them all, then wait on them in order" model. In this case, though, there won't be 1200 threads - there'll be THREAD_COUNT of them (which may not be the same as your CPU count, but you could use that same figure as an initial estimate). Within each thread, the logic is also quite simple: take a job, do the job, repeat till you run out of jobs. The GIL ensures that "job = jobs.pop()" is a safe atomic operation that can't possibly corrupt internal state, and will always retrieve a unique job every time. The run_jobs function simply runs one job at a time, waiting for its completion. This kind of pattern keeps everything clean and simple, and is easy to tweak for performance. ChrisA From python at mrabarnett.plus.com Thu May 23 20:46:05 2019 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 24 May 2019 01:46:05 +0100 Subject: More CPUs doen't equal more speed In-Reply-To: References: <010f01d511b0$4c995090$e5cbf1b0$@verizon.net> <6faad968-0faa-0d81-c1e7-264425211e6e@mrabarnett.plus.com> Message-ID: <96ec33a6-cb83-009b-939e-51c0d3f0efc2@mrabarnett.plus.com> On 2019-05-24 01:22, Chris Angelico wrote: > On Fri, May 24, 2019 at 10:07 AM Bob van der Poel wrote: >> >> Thanks all! The sound you are hearing is my head smacking against my hand! >> Or is it my hand against my head? >> >> Anyway, yes the problem is that I was naively using command.getoutput() >> which blocks until the command is finished. So, of course, only one process >> was being run at one time! Bad me! >> >> I guess I should be looking at subprocess.Popen(). Now, a more relevant >> question ... if I do it this way I then need to poll though a list of saved >> process IDs to see which have finished? Right? My initial thought is to >> batch them up in small groups (say CPU_COUNT-1) and wait for that batch to >> finish, etc. Would it be foolish to send send a large number (1200 in this >> case since this is the number of files) and let the OS worry about >> scheduling and have my program poll 1200 IDs? > > That might create a lot of contention, resulting in poor performance. > But depending on what your tasks saturate on, that might not matter > all that much, and it _would_ be a simple and straight-forward > technique. In fact, you could basically just write your code like > this: > > for job in jobs: > start_process() > for process in processes: > wait_for_process() > > Once they're all started, you just wait for the first one to finish. > Then when that's finished, wait for the next, and the next, and the > next. If the first process started is actually the slowest to run, all > the others will be in the "done" state for a while, but that's not a > big deal. > >> Someone mentioned the GIL. If I launch separate processes then I don't >> encounter this issue? Right? > > The GIL is basically irrelevant here. Most of the work is being done > in subprocesses, so your code is spending all its time waiting. > > What I'd recommend is a thread pool. Broadly speaking, it would look > something like this: > > jobs = [...] > > def run_jobs(): > while jobs: > try: job = jobs.pop() > except IndexError: break # deal with race > start_subprocess() > wait_for_subprocess() > > threads = [threading.Thread(target=run_jobs).start() > for _ in THREAD_COUNT] > for thread in threads: > thread.join() > > Note that this has the same "start them all, then wait on them in > order" model. In this case, though, there won't be 1200 threads - > there'll be THREAD_COUNT of them (which may not be the same as your > CPU count, but you could use that same figure as an initial estimate). > > Within each thread, the logic is also quite simple: take a job, do the > job, repeat till you run out of jobs. The GIL ensures that "job = > jobs.pop()" is a safe atomic operation that can't possibly corrupt > internal state, and will always retrieve a unique job every time. The > run_jobs function simply runs one job at a time, waiting for its > completion. > > This kind of pattern keeps everything clean and simple, and is easy to > tweak for performance. > Personally, I'd use a queue (from the 'queue' module), instead of a list, for the job pool. From rosuav at gmail.com Thu May 23 20:52:45 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 May 2019 10:52:45 +1000 Subject: More CPUs doen't equal more speed In-Reply-To: <96ec33a6-cb83-009b-939e-51c0d3f0efc2@mrabarnett.plus.com> References: <010f01d511b0$4c995090$e5cbf1b0$@verizon.net> <6faad968-0faa-0d81-c1e7-264425211e6e@mrabarnett.plus.com> <96ec33a6-cb83-009b-939e-51c0d3f0efc2@mrabarnett.plus.com> Message-ID: On Fri, May 24, 2019 at 10:48 AM MRAB wrote: > > On 2019-05-24 01:22, Chris Angelico wrote: > > What I'd recommend is a thread pool. Broadly speaking, it would look > > something like this: > > > > jobs = [...] > > > > def run_jobs(): > > while jobs: > > try: job = jobs.pop() > > except IndexError: break # deal with race > > > Personally, I'd use a queue (from the 'queue' module), instead of a > list, for the job pool. It's not going to be materially different, since there's nothing adding more jobs part way. Either way works, and for the sake of a simple demo, I stuck to a core data type that any Python programmer will know, rather than potentially introducing another module :) But yes, the queue is a common choice here. ChrisA From cs at cskk.id.au Thu May 23 21:32:13 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 24 May 2019 11:32:13 +1000 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: <20190524013213.GA45653@cskk.homeip.net> On 23May2019 17:04, bvdp wrote: >Anyway, yes the problem is that I was naively using command.getoutput() >which blocks until the command is finished. So, of course, only one process >was being run at one time! Bad me! > >I guess I should be looking at subprocess.Popen(). Now, a more relevant >question ... if I do it this way I then need to poll though a list of saved >process IDs to see which have finished? Right? My initial thought is to >batch them up in small groups (say CPU_COUNT-1) and wait for that batch to >finish, etc. Would it be foolish to send send a large number (1200 in this >case since this is the number of files) and let the OS worry about >scheduling and have my program poll 1200 IDs? > >Someone mentioned the GIL. If I launch separate processes then I don't >encounter this issue? Right? Yes, but it becomes more painful to manage. If you're issues distinct separate commands anyway, dispatch many or all and then wait for them as a distinct step. If the commands start thrashing the rest of the OS resources (such as the disc) then you may want to do some capacity limitation, such as a counter or semaphore to limit how many go at once. Now, waiting for a subcommand can be done in a few ways. If you're then parent of all the processes you can keep a set() of the issued process ids and then call os.wait() repeatedly, which returns the pid of a completed child process. Check it against your set. If you need to act on the specific process, use a dict to map pids to some record of the subprocess. Alternatively, you can spawn a Python Thread for each subcommand, have the Thread dispatch the subcommand _and_ wait for it (i.e. keep your command.getoutput() method, but in a Thread). Main programme waits for the Threads by join()ing them. Because a thread waiting for something external (the subprocess) doesn't hold the GIL, other stuff can proceed. Basicly, if something is handed off the to OS and then Python waits for that (via an os.* call or a Popen.wait() call etc etc) then it will release the GIL while it is blocked, so other Threads _will_ get to work. This is all efficient, and there's any number of variations on the wait step depending what your needs are. The GIL isn't the disaster most people seem think. It can be a bottleneck for pure Python compute intensive work. But Python's interpreted - if you _really_ want performance the core compute will be compiled to something more efficient (eg a C extension) or handed to another process (transcode video in pure Python - argh! - but call the ffmpeg command as a subprocess - yes!); handed off, the GIL should be released, allowing other Python side work to continue. Cheers, Cameron Simpson From tjreedy at udel.edu Fri May 24 01:27:10 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 24 May 2019 01:27:10 -0400 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: On 5/23/2019 2:39 PM, Bob van der Poel wrote: > I've got a short script that loops though a number of files and processes > them one at a time. I had a bit of time today and figured I'd rewrite the > script to process the files 4 at a time by using 4 different instances of > python. As others have said, you give no evidence that you are doing that. The python test suite runner has an argument to use multiple cores. For me, 'python -m test -j0' runs about 6 times faster than 'python -m test'. The speedup would be faster except than there is one test file that takes over two minutes, and may run at least a minute after all other processes have quit. (I have suggested than long running files be split to even out the load, but that has not gained favor yet.) For this use, more CPUs *does* equal more speed. -- Terry Jan Reedy From tjreedy at udel.edu Fri May 24 01:32:32 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 24 May 2019 01:32:32 -0400 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: On 5/23/2019 2:39 PM, Bob van der Poel wrote: > I'm processing about 1200 files and my total duration is around 2 minutes. A followup to my previous response, which has not shown up yet. The python test suite is over 400 files. You might look at how test.regrtest runs them in parallel when -j? is passed. -- Terry Jan Reedy From Cecil at decebal.nl Fri May 24 01:49:23 2019 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 24 May 2019 07:49:23 +0200 Subject: Handling an connection error with Twython References: <8736l5qpi7.fsf@munus.decebal.nl> <87y32wq1hz.fsf@munus.decebal.nl> <2e4f24a1-0806-96a9-3cc9-0f418043f82a@mrabarnett.plus.com> Message-ID: <87tvdkpfks.fsf@munus.decebal.nl> MRAB writes: > On 2019-05-23 22:55, Cecil Westerhof wrote: >> Cecil Westerhof writes: >> >>> I am using Twython to post updates on Twitter. Lately there is now and >>> then a problem with my internet connection. I am using: >>> posted = twitter.update_status(status = message, >>> in_reply_to_status_id = message_id, >>> trim_user = True) >>> >>> What would be the best way to catch a connection error and try it (for >>> example) again maximum three times with a delay of one minute? >> >> At the moment I solved it with the following: >> max_tries = 3 >> current_try = 1 >> while True: >> try: >> posted = twitter.update_status(status = message, >> in_reply_to_status_id = message_id, >> trim_user = True) >> return posted['id'] >> except TwythonError as e: >> print('Failed on try: {0}'.format(current_try)) >> if not 'Temporary failure in name resolution' in e.msg: >> raise >> if current_try == max_tries: >> raise >> current_try += 1 >> time.sleep(60) >> >> Is this a good way to do it, or can it be improved on? >> >> When it goes OK I just return from the function. >> If it goes wrong for something else as failure in the name resolution >> I re-raise the exception. >> When the maximum tries are done I re-raise the exception. >> Otherwise I wait a minute to try it again. >> > You have a 'while' loop with a counter; you can replace that with a > 'for' loop. I did not do that consciously, because I have to try until it is successful an I return, or I reached the max tries and re-raise the exception. With a for loop I could exit the loop and cannot re-raise the exception. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From auriocus at gmx.de Fri May 24 03:02:33 2019 From: auriocus at gmx.de (Christian Gollwitzer) Date: Fri, 24 May 2019 09:02:33 +0200 Subject: More CPUs doen't equal more speed In-Reply-To: <87woigdex5.fsf@nightsong.com> References: <87woigdex5.fsf@nightsong.com> Message-ID: Am 23.05.19 um 23:44 schrieb Paul Rubin: > Bob van der Poel writes: >> for i in range(0, len(filelist), CPU_COUNT): >> for z in range(i, i+CPU_COUNT): >> doit( filelist[z]) > > Write your program to just process one file, then use GNU Parallel > to run the program on your 1200 files, 6 at a time. > This is a very sensible suggestion. GNU parallel on a list of files is relatively easy, for instance I use it to resize many images in parallel like this: parallel convert {} -resize 1600 small_{} ::: *.JPG The {} is replaced for each file in turn. Another way with an external tool is a Makefile. GNU make can run in parallel, by setting the flag "-j", so "make -j6" will run 6 processes i parallel. It is more work to set up the Makefile, but it might pay off if you have a dependency graph or if the process is interrupted. "make" can figure out which files need to be processed and therefore continue a stopped job. Maybe rewriting all of this from scratch in Python is not worth it. Christian From mal at europython.eu Fri May 24 04:09:26 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Fri, 24 May 2019 10:09:26 +0200 Subject: EuroPython 2019: Financial Aid Program starts today Message-ID: We are happy to announce the start of our financial aid program for this year?s EuroPython. As part of our commitment to the Python community, we are pleased to announce that we offer special grants for people in need of a financial aid to attend EuroPython. * https://ep2019.europython.eu/registration/financial-aid/ * Financial Aid Sponsor for EuroPython 2019 ----------------------------------------- EuroPython Society: https://www.europython-society.org/ The EuroPython Society (EPS) is sponsoring financial aid with 15,000 EUR this year. We offer financial aid conference grants in these 2 categories: - Free ticket. Get a standard ticket for the conference for free (including access to conference days (Wed-Fri), Beginners? Day workshop and sprints.). Note: training passes are NOT included in the free conference ticket. - Travel / Accommodation. We will cover the travel costs pro rata, depending on what you are applying for. You can get partial refund for the accommodation. Grant Eligibility ----------------- EuroPython is a wonderful place to meet and share your experience with other Python developers from Europe and all around the world. Our goal is support people which want to make Python community better: conference speakers and tutorial presenters, active people from small Python communities and open source contributors. Our grants are open to all people in need of financial aid. We will specifically take into account the following criteria in the selection process: - Contributors: potential speakers/trainers of EuroPython (people who submitted a proposal) and all who contribute to EuroPython and/or Python community projects. - Economic factors: we want everybody to have a chance to come to EuroPython, regardless of economic situation or income level. - Diversity: we seek the most diverse and inclusive event possible. How to apply ------------ Please see our financial aid page for all details: https://ep2019.europython.eu/registration/financial-aid/ Become a Financial Aid Sponsor ! -------------------------------- Even though the EPS is already sponsoring finaid, we can always use more budget to increase the number of people who can benefit from the program. You or your company can support our diversity and finaid initiative by becoming a sponsor. We have a special options ?Financial aid sponsor? and ?Financial aid donation? in the list of sponsor options, that can be booked separately or be included in the sponsor package. Please check our sponsor brochure for more information and contact finaid at europython.eu or the sponsor work group directly sponsoring at europython.eu. Bring new sponsor and get free ticket for EuroPython 2019 ! Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). Tickets can be purchased on our registration page: https://ep2019.europython.eu/registration/buy-tickets/ For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/185103282697/europython-2019-financial-aid-program-starts Tweet: https://twitter.com/europython/status/1131833024079892480 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From Cecil at decebal.nl Fri May 24 04:25:09 2019 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 24 May 2019 10:25:09 +0200 Subject: Handling an connection error with Twython References: <8736l5qpi7.fsf@munus.decebal.nl> <87y32wq1hz.fsf@munus.decebal.nl> <2e4f24a1-0806-96a9-3cc9-0f418043f82a@mrabarnett.plus.com> <87tvdkpfks.fsf@munus.decebal.nl> <346feeprknvm8225vugcm01nm2th7ncvgh@4ax.com> Message-ID: <87mujcp8d6.fsf@munus.decebal.nl> Dennis Lee Bieber writes: > On Fri, 24 May 2019 07:49:23 +0200, Cecil Westerhof > declaimed the following: > >> >>I did not do that consciously, because I have to try until it is >>successful an I return, or I reached the max tries and re-raise the >>exception. With a for loop I could exit the loop and cannot re-raise >>the exception. > > Your /success/ branch exits the loop by executing a "return" statement. > > Your /fail/ branch exits the loop by "raise" on the third failure. > > A "for" loop would have the same behavior; you just replace the manual > initialization and increment of the loop counter. > > for tries in range(max_try): > try: > do something > return successful > except stuff: > if tries+1 == max_try: #since range is 0..max_try-1 > raise > > You never "fall off the end" of the loop. That is true, but by using a 'while?True:' loop it is clear you never fall off the end of the loop. I find this much clearer. And when there is a bug you get into an endless loop instead of fall of the end. Which in my opinion is easier to spot and mend. And endless loop is noticed the moment it goes wrong. Falling of the end could go without an error and will be spotted much later. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From jon+usenet at unequivocal.eu Fri May 24 06:27:51 2019 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Fri, 24 May 2019 10:27:51 -0000 (UTC) Subject: PEP 594 cgi & cgitb removal References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <87d0k9iwkp.fsf@handshake.de> <871s0peoio.fsf@nightsong.com> <20190523124635.hphiagslwrbdjnz7@gthmcloud> Message-ID: On 2019-05-23, Gunnar ??r Magn?sson wrote: >> nginx is the current hotness. CGI has not been hotness since the >> mid 90s. > > Serverless is the new hotness, and serverless is CGI. Technology is > cyclical. Sorry, in what sense do you mean "Serverless is CGI"? As far as I can tell, it's just a script to automatically upload bits of code into various cloud providers, none of which use CGI. From stephane at wirtel.be Fri May 24 09:00:17 2019 From: stephane at wirtel.be (=?utf-8?B?U3TDqXBoYW5l?= Wirtel) Date: Fri, 24 May 2019 15:00:17 +0200 Subject: PEP 594 cgi & cgitb removal In-Reply-To: <6ce73371-862e-50c9-425b-189d7f27e595@kynesim.co.uk> References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <6ce73371-862e-50c9-425b-189d7f27e595@kynesim.co.uk> Message-ID: <20190524130017.sz7bfzvft7a33iql@xps> On 05/23, Rhodri James wrote: >On 22/05/2019 19:29, Terry Reedy wrote: >>One of the factors being considered in removal decisions is the >>absence of anyone willing to list themselves in the expert's list >>https://devguide.python.org/experts/ >>as a maintainer for a module. >> >>At the moment, 3 other people have objected to the removal of these >>modules.? I suspect that at least 2 of you 4 are at least as >>technically qualified to be a core developer as I am.? A request to >>become the maintainer of cgi and cgitb *might* affect the decision. > >A quick read-through of the modules (I am supposed to be working right >now) suggests that maintaining them wouldn't be a massive effort. >Definitely something to think about. Not a massive effort, but we are limited with the resources. -- St?phane Wirtel - https://wirtel.be - @matrixise From darcy at vex.net Fri May 24 09:25:35 2019 From: darcy at vex.net (D'Arcy Cain) Date: Fri, 24 May 2019 09:25:35 -0400 Subject: PEP 594 cgi & cgitb removal In-Reply-To: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> Message-ID: <235628e8-4c5b-6e21-b021-9dbe31f792f6@vex.net> On 2019-05-22 03:51, Robin Becker wrote: > In PEP 594 t has been proposed that cgi & cgitb should be removed. I > suspect I am not the only person in the world that likes using cgi and > cgitb. I use both heavily. Just another data point. I wasn't going to respond with a "Me too" except that I saw posts suggesting that few people are chiming in. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:darcy at Vex.Net VoIP: sip:darcy at Vex.Net From python at mrabarnett.plus.com Fri May 24 11:51:26 2019 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 24 May 2019 16:51:26 +0100 Subject: Handling an connection error with Twython In-Reply-To: <87mujcp8d6.fsf@munus.decebal.nl> References: <8736l5qpi7.fsf@munus.decebal.nl> <87y32wq1hz.fsf@munus.decebal.nl> <2e4f24a1-0806-96a9-3cc9-0f418043f82a@mrabarnett.plus.com> <87tvdkpfks.fsf@munus.decebal.nl> <346feeprknvm8225vugcm01nm2th7ncvgh@4ax.com> <87mujcp8d6.fsf@munus.decebal.nl> Message-ID: On 2019-05-24 09:25, Cecil Westerhof wrote: > Dennis Lee Bieber writes: > >> On Fri, 24 May 2019 07:49:23 +0200, Cecil Westerhof >> declaimed the following: >> >>> >>>I did not do that consciously, because I have to try until it is >>>successful an I return, or I reached the max tries and re-raise the >>>exception. With a for loop I could exit the loop and cannot re-raise >>>the exception. >> >> Your /success/ branch exits the loop by executing a "return" statement. >> >> Your /fail/ branch exits the loop by "raise" on the third failure. >> >> A "for" loop would have the same behavior; you just replace the manual >> initialization and increment of the loop counter. >> >> for tries in range(max_try): >> try: >> do something >> return successful >> except stuff: >> if tries+1 == max_try: #since range is 0..max_try-1 >> raise >> >> You never "fall off the end" of the loop. > > That is true, but by using a 'while?True:' loop it is clear you never > fall off the end of the loop. I find this much clearer. And when there > is a bug you get into an endless loop instead of fall of the end. > Which in my opinion is easier to spot and mend. And endless loop is > noticed the moment it goes wrong. Falling of the end could go without > an error and will be spotted much later. > You could print a message or raise an exception after the 'for' loop so that if it ever falls off the end of the loop you'll get a nice message instead of it just looping forever! :-) From Markus.Elfring at web.de Fri May 24 12:00:38 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Fri, 24 May 2019 18:00:38 +0200 Subject: Checking network input processing by Python for a multi-threaded server In-Reply-To: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> References: <443b0bf4-e2f1-5eb3-2bf6-5f09704dc269@web.de> Message-ID: > The file name for the client script is passed by a parameter to a command > which is repeated by this server in a loop. > It is evaluated then how often a known record set count was sent. In which time ranges would you expect the receiving of the complete JSON data which were sent by the child process (on the local host during my test)? Can the program termination be taken into account for waiting on still incoming data from the server socket? Regards, Markus From bob at mellowood.ca Fri May 24 12:04:30 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Fri, 24 May 2019 09:04:30 -0700 Subject: More CPUs doen't equal more speed In-Reply-To: References: <87woigdex5.fsf@nightsong.com> Message-ID: Ahh, 2 really excellent ideas! I'm reading about parallel right now. And, I know how to use make, so I really should have thought of -j as well. Thanks for the ideas. On Fri, May 24, 2019 at 12:02 AM Christian Gollwitzer wrote: > Am 23.05.19 um 23:44 schrieb Paul Rubin: > > Bob van der Poel writes: > >> for i in range(0, len(filelist), CPU_COUNT): > >> for z in range(i, i+CPU_COUNT): > >> doit( filelist[z]) > > > > Write your program to just process one file, then use GNU Parallel > > to run the program on your 1200 files, 6 at a time. > > > > This is a very sensible suggestion. GNU parallel on a list of files is > relatively easy, for instance I use it to resize many images in parallel > like this: > > parallel convert {} -resize 1600 small_{} ::: *.JPG > > The {} is replaced for each file in turn. > > Another way with an external tool is a Makefile. GNU make can run in > parallel, by setting the flag "-j", so "make -j6" will run 6 processes i > parallel. It is more work to set up the Makefile, but it might pay off > if you have a dependency graph or if the process is interrupted. > "make" can figure out which files need to be processed and therefore > continue a stopped job. > > Maybe rewriting all of this from scratch in Python is not worth it. > > Christian > -- > https://mail.python.org/mailman/listinfo/python-list > -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca From rgaddi at highlandtechnology.invalid Fri May 24 12:28:18 2019 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Fri, 24 May 2019 09:28:18 -0700 Subject: More CPUs doen't equal more speed In-Reply-To: References: <20190524013213.GA45653@cskk.homeip.net> Message-ID: On 5/23/19 6:32 PM, Cameron Simpson wrote: > On 23May2019 17:04, bvdp wrote: >> Anyway, yes the problem is that I was naively using command.getoutput() >> which blocks until the command is finished. So, of course, only one >> process >> was being run at one time! Bad me! >> >> I guess I should be looking at subprocess.Popen(). Now, a more relevant >> question ... if I do it this way I then need to poll though a list of >> saved >> process IDs to see which have finished? Right? My initial thought is to >> batch them up in small groups (say CPU_COUNT-1) and wait for that >> batch to >> finish, etc. Would it be foolish to send send a large number (1200 in >> this >> case since this is the number of files) and let the OS worry about >> scheduling and have my program poll 1200 IDs? >> >> Someone mentioned the GIL. If I launch separate processes then I don't >> encounter this issue? Right? > > Yes, but it becomes more painful to manage. If you're issues distinct > separate commands anyway, dispatch many or all and then wait for them as > a distinct step.? If the commands start thrashing the rest of the OS > resources (such as the disc) then you may want to do some capacity > limitation, such as a counter or semaphore to limit how many go at once. > > Now, waiting for a subcommand can be done in a few ways. > > If you're then parent of all the processes you can keep a set() of the > issued process ids and then call os.wait() repeatedly, which returns the > pid of a completed child process. Check it against your set. If you need > to act on the specific process, use a dict to map pids to some record of > the subprocess. > > Alternatively, you can spawn a Python Thread for each subcommand, have > the Thread dispatch the subcommand _and_ wait for it (i.e. keep your > command.getoutput() method, but in a Thread). Main programme waits for > the Threads by join()ing them. > I'll just note, because no one else has brought it up yet, that rather than manually creating threads and/or process pools for all these things, this is exactly what the standard concurrent.futures module is for. It's a fairly brilliant wrapper around all this stuff, and I feel like it often doesn't get enough love. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From bob at mellowood.ca Fri May 24 14:40:19 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Fri, 24 May 2019 11:40:19 -0700 Subject: More CPUs doen't equal more speed In-Reply-To: References: <20190524013213.GA45653@cskk.homeip.net> Message-ID: Just got a 1 liner working with parallel. Super! All I ended up doing is: parallel mma {} ::: *mma which whizzed through my files in less than 1/4 of the time of my one-at-a-time script. (In case anyone is wondering, or cares, this is a bunch of Musical Midi Accompaniment files: https://mellowood.ca/mma/index.html). On Fri, May 24, 2019 at 9:28 AM Rob Gaddi wrote: > On 5/23/19 6:32 PM, Cameron Simpson wrote: > > On 23May2019 17:04, bvdp wrote: > >> Anyway, yes the problem is that I was naively using command.getoutput() > >> which blocks until the command is finished. So, of course, only one > >> process > >> was being run at one time! Bad me! > >> > >> I guess I should be looking at subprocess.Popen(). Now, a more relevant > >> question ... if I do it this way I then need to poll though a list of > >> saved > >> process IDs to see which have finished? Right? My initial thought is to > >> batch them up in small groups (say CPU_COUNT-1) and wait for that > >> batch to > >> finish, etc. Would it be foolish to send send a large number (1200 in > >> this > >> case since this is the number of files) and let the OS worry about > >> scheduling and have my program poll 1200 IDs? > >> > >> Someone mentioned the GIL. If I launch separate processes then I don't > >> encounter this issue? Right? > > > > Yes, but it becomes more painful to manage. If you're issues distinct > > separate commands anyway, dispatch many or all and then wait for them as > > a distinct step. If the commands start thrashing the rest of the OS > > resources (such as the disc) then you may want to do some capacity > > limitation, such as a counter or semaphore to limit how many go at once. > > > > Now, waiting for a subcommand can be done in a few ways. > > > > If you're then parent of all the processes you can keep a set() of the > > issued process ids and then call os.wait() repeatedly, which returns the > > pid of a completed child process. Check it against your set. If you need > > to act on the specific process, use a dict to map pids to some record of > > the subprocess. > > > > Alternatively, you can spawn a Python Thread for each subcommand, have > > the Thread dispatch the subcommand _and_ wait for it (i.e. keep your > > command.getoutput() method, but in a Thread). Main programme waits for > > the Threads by join()ing them. > > > > I'll just note, because no one else has brought it up yet, that rather > than manually creating threads and/or process pools for all these > things, this is exactly what the standard concurrent.futures module is > for. It's a fairly brilliant wrapper around all this stuff, and I feel > like it often doesn't get enough love. > > > -- > Rob Gaddi, Highland Technology -- www.highlandtechnology.com > Email address domain is currently out of order. See above to fix. > -- > https://mail.python.org/mailman/listinfo/python-list > -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca From marko at pacujo.net Fri May 24 15:24:32 2019 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 24 May 2019 22:24:32 +0300 Subject: PEP 594 cgi & cgitb removal References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <6ce73371-862e-50c9-425b-189d7f27e595@kynesim.co.uk> <20190524130017.sz7bfzvft7a33iql@xps> <8736l3vjgo.fsf@nightsong.com> Message-ID: <871s0n3bbj.fsf@elektro.pacujo.net> Paul Rubin : > St?phane Wirtel writes: >> Not a massive effort, but we are limited with the resources. > > I keep hearing that but it makes it sound like Python itself is in > decline. That is despite the reports that it is now the most popular > language in the world. It also makes me ask why the Python team keeps > adding new stuff if it can't even keep the old stuff running. I'd urge > a more conservative approach to this stuff. Generally, my feelings are the same as yours, and I'm saddened by the steady decline of one of my all-time favorite programming languages. However, the Python developers can do whatever they want with their free time. Of course, it's much more exciting to add new bells and whistles to a language than maintain some 1980's legacy. So I can't make any demands for Python. > People who want bleeding edge advances in language technology should > use Haskell. People who want amorphous crap-laden ecosystems that keep > changing and breaking should use Javascript/NPM. Those who want to be > assimilated by the Borg and get aboard an entire micromanaged > environment have Goland or (even worse) Java. Python for a while > filled the niche of being a not too cumbersome, reasonably stable > system for people trying to get real-world tasks done and wanted a > language that worked and stayed out of the way. There's a programming language arms race. Python wants to beat Java, C# and go in the everything-for-everybody game. Python developers seem to take the popularity of the language as proof of success. Pride goes before the fall. > Please don't abandon that. I'm afraid the damage is already done. Marko From tjreedy at udel.edu Fri May 24 16:23:51 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 24 May 2019 16:23:51 -0400 Subject: PEP 594 cgi & cgitb removal In-Reply-To: <871s0n3bbj.fsf@elektro.pacujo.net> References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <6ce73371-862e-50c9-425b-189d7f27e595@kynesim.co.uk> <20190524130017.sz7bfzvft7a33iql@xps> <8736l3vjgo.fsf@nightsong.com> <871s0n3bbj.fsf@elektro.pacujo.net> Message-ID: I am responding to Paul indirectly because his post did not show up on the gmane mirror. > Paul Rubin : >> It also makes me ask why the Python team keeps >> adding new stuff if it can't even keep the old stuff running. Because the new stuff is expected to be more useful to more people than some of the old modules. The module proposed for deletion are all or most all more than 20 years old, before there was a PyPI. Some, like cgi and cgitb were legitimately put in the stdlib. Others were specialist modules that today would not go in the stdlib. Does anyone really think that gopherlib should still be in the stdlib, and that core developers should have to update its docs to explain it to newbies today? My question is why people who value and understand old modules don't volunteer more to help keep them up to date. -- Terry Jan Reedy From cs at cskk.id.au Fri May 24 19:02:50 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 25 May 2019 09:02:50 +1000 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: <20190524230250.GA90699@cskk.homeip.net> On 24May2019 11:40, bvdp wrote: >Just got a 1 liner working with parallel. Super! All I ended up doing is: > > parallel mma {} ::: *mma +1 Glad to see a nice simple approach. Cheers, Cameron Simpson (formerly ) From torriem at gmail.com Fri May 24 23:00:12 2019 From: torriem at gmail.com (Michael Torrie) Date: Fri, 24 May 2019 21:00:12 -0600 Subject: PEP 594 cgi & cgitb removal In-Reply-To: <871s0n3bbj.fsf@elektro.pacujo.net> References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <6ce73371-862e-50c9-425b-189d7f27e595@kynesim.co.uk> <20190524130017.sz7bfzvft7a33iql@xps> <8736l3vjgo.fsf@nightsong.com> <871s0n3bbj.fsf@elektro.pacujo.net> Message-ID: <3a08ed51-83e9-7328-5c96-14cfe00ea7c9@gmail.com> On 05/24/2019 01:24 PM, Marko Rauhamaa wrote: > There's a programming language arms race. Python wants to beat Java, C# > and go in the everything-for-everybody game. Python developers seem to > take the popularity of the language as proof of success. Pride goes > before the fall. I don't see this at all. Python is useful. Period. And it may be popular too. I don't actually think the core devs are focused much at all on winning a popularity contest. Besides, who cares about C# or Java. It's not a zero sum game. Features are being added that people who use Python require, or that the core devs think are useful or cool. Other languages are also evolving similar features. Async stuff is not simply to compete with C#. It's seen as a necessary feature for certain types of development that are popular (needed?) right now. The only thing that worries me is that open source and free software projects in general seem to be in decline as their core developers age out and generally get tired or change their priorities. We don't seem to be attracting replacement talent. Perhaps the next generations are less idealistic, or more likely they have less money and thus less time to donate. I could maybe fall into that category. I'm older now than when I was first exposed to Linux, and I have a lot less time. Corporate open source software seems to be a growing phenomenon. While I welcome companies being open and liberal with their source code and projects, it does worry me just a bit. From torriem at gmail.com Fri May 24 23:03:55 2019 From: torriem at gmail.com (Michael Torrie) Date: Fri, 24 May 2019 21:03:55 -0600 Subject: PEP 594 cgi & cgitb removal In-Reply-To: References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <87d0k9iwkp.fsf@handshake.de> <871s0peoio.fsf@nightsong.com> <20190523124635.hphiagslwrbdjnz7@gthmcloud> Message-ID: <09e6f2c4-e8d3-903f-630f-b1803ca55b6c@gmail.com> On 05/24/2019 04:27 AM, Jon Ribbens via Python-list wrote: > On 2019-05-23, Gunnar ??r Magn?sson wrote: >>> nginx is the current hotness. CGI has not been hotness since the >>> mid 90s. >> >> Serverless is the new hotness, and serverless is CGI. Technology is >> cyclical. > > Sorry, in what sense do you mean "Serverless is CGI"? > > As far as I can tell, it's just a script to automatically upload > bits of code into various cloud providers, none of which use CGI. Not really. Serverless just means stateless web-based remote procedure calls. This is by definition what CGI is. Only now you can click a button and put your cgi script on any cloud provider you want and get billed by how much cpu and network bandwidth your little cgi script uses. So basically the cool kids have reinvented CGI. And instead of calling them scripts, they call them functions. Serverless is an unfortunate name. From binoythomas1108 at gmail.com Sat May 25 07:05:58 2019 From: binoythomas1108 at gmail.com (binoythomas1108 at gmail.com) Date: Sat, 25 May 2019 04:05:58 -0700 (PDT) Subject: Implementing C++'s getch() in Python Message-ID: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> I'm working on Python 3.7 under Windows. I need a way to input characters without echoing them on screen, something that getch() did effectively in C++. I read about the unicurses, ncurses and curses modules, which I was not able to install using pip. Is there any way of getting this done? From shakti.shrivastava13 at gmail.com Sat May 25 07:27:15 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Sat, 25 May 2019 16:57:15 +0530 Subject: Implementing C++'s getch() in Python In-Reply-To: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> References: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> Message-ID: On Sat, 25 May 2019 at 4:43 PM wrote: > I'm working on Python 3.7 under Windows. I need a way to input characters > without echoing them on screen, something that getch() did effectively in > C++. try getpass module. Typically this would be, import getpass variable = getpass.getpass('your prompt') > https://mail.python.org/mailman/listinfo/python-list > -- Sent from Shakti?s iPhone From Cecil at decebal.nl Sat May 25 07:46:40 2019 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sat, 25 May 2019 13:46:40 +0200 Subject: Handling an connection error with Twython References: <8736l5qpi7.fsf@munus.decebal.nl> <87y32wq1hz.fsf@munus.decebal.nl> <2e4f24a1-0806-96a9-3cc9-0f418043f82a@mrabarnett.plus.com> <87tvdkpfks.fsf@munus.decebal.nl> <346feeprknvm8225vugcm01nm2th7ncvgh@4ax.com> <87mujcp8d6.fsf@munus.decebal.nl> Message-ID: <87imtypxi7.fsf@munus.decebal.nl> MRAB writes: > On 2019-05-24 09:25, Cecil Westerhof wrote: >> Dennis Lee Bieber writes: >> >>> On Fri, 24 May 2019 07:49:23 +0200, Cecil Westerhof >>> declaimed the following: >>> >>>> >>>>I did not do that consciously, because I have to try until it is >>>>successful an I return, or I reached the max tries and re-raise the >>>>exception. With a for loop I could exit the loop and cannot re-raise >>>>the exception. >>> >>> Your /success/ branch exits the loop by executing a "return" statement. >>> >>> Your /fail/ branch exits the loop by "raise" on the third failure. >>> >>> A "for" loop would have the same behavior; you just replace the manual >>> initialization and increment of the loop counter. >>> >>> for tries in range(max_try): >>> try: >>> do something >>> return successful >>> except stuff: >>> if tries+1 == max_try: #since range is 0..max_try-1 >>> raise >>> >>> You never "fall off the end" of the loop. >> >> That is true, but by using a 'while?True:' loop it is clear you never >> fall off the end of the loop. I find this much clearer. And when there >> is a bug you get into an endless loop instead of fall of the end. >> Which in my opinion is easier to spot and mend. And endless loop is >> noticed the moment it goes wrong. Falling of the end could go without >> an error and will be spotted much later. >> > You could print a message or raise an exception after the 'for' loop so > that if it ever falls off the end of the loop you'll get a nice message > instead of it just looping forever! :-) > Just changing the while loop to a for loop did not make sense to me, but this does. I now have: max_tries = 5 for current_try in range(1, max_tries): try: posted = twitter.update_status(status = message, in_reply_to_status_id = message_id, trim_user = True) return posted['id'] except TwythonError as e: if not 'Temporary failure in name resolution' in e.msg: raise timed_message('Failed on try: {0} of {1}'.format(current_try, max_tries)) if current_try == max_tries: print('Could not get a connection to the internet: exiting') deinit(2) time.sleep(60) raise RuntimeError('Should not get here') When I do not get an internet connection, I do not do a re-raise anymore, but just give a message. The proc deinit does a sys.exit after some cleanup. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From binoythomas1108 at gmail.com Sat May 25 10:00:43 2019 From: binoythomas1108 at gmail.com (binoythomas1108 at gmail.com) Date: Sat, 25 May 2019 07:00:43 -0700 (PDT) Subject: Implementing C++'s getch() in Python In-Reply-To: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> References: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> Message-ID: <2f42b95f-57fb-43f1-8e5d-aa8d29870732@googlegroups.com> Hi Shakti! Thanks for your response. I have tried getpass() but got the following warning: Warning (from warnings module): File "C:\Users\Binoy\AppData\Local\Programs\Python\Python37-32\lib\getpass.py", line 100 return fallback_getpass(prompt, stream) GetPassWarning: Can not control echo on the terminal. Warning: Password input may be echoed. And true enough, the input string is echoed. I saw a video where getpass() worked on Linux. So, probably, its a Windows thing. Still looking for a solution to the same on Windows. From p.f.moore at gmail.com Sat May 25 10:14:46 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Sat, 25 May 2019 15:14:46 +0100 Subject: Implementing C++'s getch() in Python In-Reply-To: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> References: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> Message-ID: On Sat, 25 May 2019 at 12:12, wrote: > > I'm working on Python 3.7 under Windows. I need a way to input characters without echoing them on screen, something that getch() did effectively in C++. I read about the unicurses, ncurses and curses modules, which I was not able to install using pip. > > Is there any way of getting this done? On Windows, the msvcrt module exposes getch: https://docs.python.org/3.7/library/msvcrt.html#msvcrt.getch From jon+usenet at unequivocal.eu Sat May 25 15:00:07 2019 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sat, 25 May 2019 19:00:07 -0000 (UTC) Subject: PEP 594 cgi & cgitb removal References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <87d0k9iwkp.fsf@handshake.de> <871s0peoio.fsf@nightsong.com> <20190523124635.hphiagslwrbdjnz7@gthmcloud> <09e6f2c4-e8d3-903f-630f-b1803ca55b6c@gmail.com> Message-ID: On 2019-05-25, Michael Torrie wrote: > On 05/24/2019 04:27 AM, Jon Ribbens via Python-list wrote: >> Sorry, in what sense do you mean "Serverless is CGI"? >> >> As far as I can tell, it's just a script to automatically upload >> bits of code into various cloud providers, none of which use CGI. > > Not really. Serverless just means stateless web-based remote procedure > calls. This is by definition what CGI is. No, it isn't. CGI is a specific API and method of calling a program in order to serve a web request. It isn't a shorthand for "any web-based remote procedure call". From random832 at fastmail.com Sat May 25 15:37:16 2019 From: random832 at fastmail.com (Random832) Date: Sat, 25 May 2019 15:37:16 -0400 Subject: Implementing C++'s getch() in Python In-Reply-To: <2f42b95f-57fb-43f1-8e5d-aa8d29870732@googlegroups.com> References: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> <2f42b95f-57fb-43f1-8e5d-aa8d29870732@googlegroups.com> Message-ID: <89af90b2-bd4d-407b-a4b2-54c27e20d5e1@www.fastmail.com> On Sat, May 25, 2019, at 10:07, binoythomas1108 at gmail.com wrote: > Hi Shakti! > > Thanks for your response. I have tried getpass() but got the following warning: > > Warning (from warnings module): > File > "C:\Users\Binoy\AppData\Local\Programs\Python\Python37-32\lib\getpass.py", line 100 > return fallback_getpass(prompt, stream) > GetPassWarning: Can not control echo on the terminal. > Warning: Password input may be echoed. > > And true enough, the input string is echoed. I saw a video where > getpass() worked on Linux. So, probably, its a Windows thing. getpass works fine on the windows console. Are you running the script in an IDE such as IDLE, PyCharm, etc? From marko at pacujo.net Sat May 25 16:24:13 2019 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 25 May 2019 23:24:13 +0300 Subject: PEP 594 cgi & cgitb removal References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <87d0k9iwkp.fsf@handshake.de> <871s0peoio.fsf@nightsong.com> <20190523124635.hphiagslwrbdjnz7@gthmcloud> <09e6f2c4-e8d3-903f-630f-b1803ca55b6c@gmail.com> Message-ID: <87ftp21dw2.fsf@elektro.pacujo.net> Jon Ribbens : > On 2019-05-25, Michael Torrie wrote: >> Not really. Serverless just means stateless web-based remote >> procedure calls. This is by definition what CGI is. > > No, it isn't. CGI is a specific API and method of calling a program in > order to serve a web request. It isn't a shorthand for "any web-based > remote procedure call". Both of you make relevant and insightful statements. Marko From roel at roelschroeven.net Sat May 25 17:45:06 2019 From: roel at roelschroeven.net (Roel Schroeven) Date: Sat, 25 May 2019 23:45:06 +0200 Subject: PEP 594 cgi & cgitb removal In-Reply-To: References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <87d0k9iwkp.fsf@handshake.de> <871s0peoio.fsf@nightsong.com> <20190523124635.hphiagslwrbdjnz7@gthmcloud> <09e6f2c4-e8d3-903f-630f-b1803ca55b6c@gmail.com> Message-ID: Jon Ribbens via Python-list schreef op 25/05/2019 om 21:00: > On 2019-05-25, Michael Torrie wrote: >> On 05/24/2019 04:27 AM, Jon Ribbens via Python-list wrote: >>> Sorry, in what sense do you mean "Serverless is CGI"? >>> >>> As far as I can tell, it's just a script to automatically upload >>> bits of code into various cloud providers, none of which use CGI. >> >> Not really. Serverless just means stateless web-based remote procedure >> calls. This is by definition what CGI is. > > No, it isn't. CGI is a specific API and method of calling a program > in order to serve a web request. It isn't a shorthand for "any > web-based remote procedure call". More specifically, with CGI the webserver starts a new process for every single request. That's bad enough for a light C program, but it's certainly not a good idea to start a whole new Python process for every request. At least not for any production website or web service that serves any real amount of traffic. That is, for those who didn't know, the reason why CGI fell out of use quite some time ago. -- "Honest criticism is hard to take, particularly from a relative, a friend, an acquaintance, or a stranger." -- Franklin P. Jones Roel Schroeven From Bischoop at bischoop.uk Sun May 26 09:34:37 2019 From: Bischoop at bischoop.uk (Bischoop) Date: Sun, 26 May 2019 13:34:37 -0000 (UTC) Subject: Why Python has no equivalent of JDBC of Java? References: Message-ID: On 2019-05-19, Marco Sulla wrote: >blablabla >blablablalbla >blablalblalbalblabla There's no perfect language mate, in some one is easier in other not, normal surprised you notice it so late. From binoythomas1108 at gmail.com Sun May 26 10:47:06 2019 From: binoythomas1108 at gmail.com (binoythomas1108 at gmail.com) Date: Sun, 26 May 2019 07:47:06 -0700 (PDT) Subject: Implementing C++'s getch() in Python In-Reply-To: References: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> <2f42b95f-57fb-43f1-8e5d-aa8d29870732@googlegroups.com> <89af90b2-bd4d-407b-a4b2-54c27e20d5e1@www.fastmail.com> Message-ID: I've run getpass() on IDLE, Spyder, PyCharm and Mu. All with negative results. From fczwtyds at gmail.com Sun May 26 10:55:04 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Sun, 26 May 2019 22:55:04 +0800 Subject: How to use ssh-agent in windows in python? Message-ID: Hi, I am using cygwin on Windows 8.1. These two commands work fine in cygwin: ssh-agent -s ssh-add ~/.ssh /id_rsa I tried to use them on windows cmd and it worked fine. Now I am going to use python to write code to implement the above command. os.system('ssh-agent -s') os.system('ssh-add id_rsa') There was an error: Could not open a connection to your authentication agent. Thank you and your time. From shakti.shrivastava13 at gmail.com Sun May 26 11:01:44 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Sun, 26 May 2019 20:31:44 +0530 Subject: Implementing C++'s getch() in Python In-Reply-To: References: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> <2f42b95f-57fb-43f1-8e5d-aa8d29870732@googlegroups.com> <89af90b2-bd4d-407b-a4b2-54c27e20d5e1@www.fastmail.com> Message-ID: On Sun, 26 May 2019 at 20:23, wrote: > > I've run getpass() on IDLE, Spyder, PyCharm and Mu. All with negative results. > > As Random832 pointed out, these IDEs cannot handle the stdout/stdin with getpass You should use a normal terminal (command prompt) on your windows for running this program. You can read more here, https://docs.python.org/3.1/library/getpass.html From eryksun at gmail.com Sun May 26 11:17:44 2019 From: eryksun at gmail.com (eryk sun) Date: Sun, 26 May 2019 10:17:44 -0500 Subject: Implementing C++'s getch() in Python In-Reply-To: References: <213d1127-0b43-49d7-8973-a1d172b0d02b@googlegroups.com> Message-ID: On 5/25/19, Paul Moore wrote: > > On Windows, the msvcrt module exposes getch: > https://docs.python.org/3.7/library/msvcrt.html#msvcrt.getch I suggest using msvcrt.getwch instead of msvcrt.getch. Both functions are limited to the basic multilingual plane (BMP, i.e. U+0000 -- U+FFFF), but getch is additionally limited to the console input codepage. In Windows, getpass.getpass is based on msvcrt.getwch and msvcrt.putwch. If you use getch and need the full BMP range, you can temporarily change the console input codepage to UTF-8 (65001). It's a multibyte encoding (i.e. 1-3 bytes per BMP code), so the initial getch call has to be followed by a loop that calls it again while the sequence can't be decoded and kbhit() is true. From python at mrabarnett.plus.com Sun May 26 12:27:24 2019 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 26 May 2019 17:27:24 +0100 Subject: How to use ssh-agent in windows in python? In-Reply-To: References: Message-ID: On 2019-05-26 15:55, Fc Zwtyds wrote: > Hi, > I am using cygwin on Windows 8.1. These two commands work fine in cygwin: > ssh-agent -s > ssh-add ~/.ssh /id_rsa > I tried to use them on windows cmd and it worked fine. Now I am going > to use python to write code to implement the above command. > os.system('ssh-agent -s') > os.system('ssh-add id_rsa') > There was an error: > Could not open a connection to your authentication agent. > > Thank you and your time. > The string that you passed to the second os.system differs from the second command on the command line. Is that the cause? From auriocus at gmx.de Sun May 26 13:48:44 2019 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sun, 26 May 2019 19:48:44 +0200 Subject: Why Python has no equivalent of JDBC of Java? In-Reply-To: References: <5CE3EEB50200001B0002C199@smtp1.astron.nl> Message-ID: Am 21.05.19 um 14:27 schrieb Adriaan Renting: > Java was meant to be generic, run anywhere and abstract and hide > differences in its underlying infrastructure. This has led to the Java > VM, and also JDBC I guess. > > Python was more of a script interpreted C-derivative, much closer to > the bare metal, and thus much less effort was made to hide and > abstract. Python closer to the metal than Java? This is nonsense. It is exactly the opposite. As a simple empirical proof, there are compilers which compile Java to native code (gcj) with comparable performance than C code, while such a thing is almost not doable for Python, only for restricted subsets. Java code can be "manually compiled" into C++ code with only a few tweaks, most notably you need a garbage collector, but that's it - apart from a huge library, maybe. Python code with dynamic typing cannot be statically compiled in the same way, which you pay for by a factor of 100 in execution speed. Christian From grant.b.edwards at gmail.com Sun May 26 14:05:02 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 26 May 2019 18:05:02 -0000 (UTC) Subject: More CPUs doen't equal more speed References: Message-ID: On 2019-05-23, Chris Angelico wrote: > On Fri, May 24, 2019 at 5:37 AM Bob van der Poel wrote: >> >> I've got a short script that loops though a number of files and >> processes them one at a time. I had a bit of time today and figured >> I'd rewrite the script to process the files 4 at a time by using 4 >> different instances of python. My basic loop is: >> >> for i in range(0, len(filelist), CPU_COUNT): >> for z in range(i, i+CPU_COUNT): >> doit( filelist[z]) >> >> With the function doit() calling up the program to do the >> lifting. Setting CPU_COUNT to 1 or 5 (I have 6 cores) makes no >> difference in total speed. I'm processing about 1200 files and my >> total duration is around 2 minutes. No matter how many cores I use >> the total is within a 5 second range. > > Where's the part of the code that actually runs them across multiple > CPUs? Also, are you spending your time waiting on the disk, the CPU, > IPC, or something else? He said he's using N differenct Python instances, and he even provided the code that runs in each instance which is obviously processesing 1/Nth of the files. It's a pretty good bet that I/O is the limiting factor. -- Grant From rosuav at gmail.com Sun May 26 14:11:22 2019 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 May 2019 04:11:22 +1000 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: On Mon, May 27, 2019 at 4:06 AM Grant Edwards wrote: > > On 2019-05-23, Chris Angelico wrote: > > On Fri, May 24, 2019 at 5:37 AM Bob van der Poel wrote: > >> > >> I've got a short script that loops though a number of files and > >> processes them one at a time. I had a bit of time today and figured > >> I'd rewrite the script to process the files 4 at a time by using 4 > >> different instances of python. My basic loop is: > >> > >> for i in range(0, len(filelist), CPU_COUNT): > >> for z in range(i, i+CPU_COUNT): > >> doit( filelist[z]) > >> > >> With the function doit() calling up the program to do the > >> lifting. Setting CPU_COUNT to 1 or 5 (I have 6 cores) makes no > >> difference in total speed. I'm processing about 1200 files and my > >> total duration is around 2 minutes. No matter how many cores I use > >> the total is within a 5 second range. > > > > Where's the part of the code that actually runs them across multiple > > CPUs? Also, are you spending your time waiting on the disk, the CPU, > > IPC, or something else? > > He said he's using N differenct Python instances, and he even provided > the code that runs in each instance which is obviously processesing > 1/Nth of the files. > > It's a pretty good bet that I/O is the limiting factor. > Sometimes, the "simple" and "obvious" code, the part that clearly has no bugs in it, is the part that has the problem. :) ChrisA From grant.b.edwards at gmail.com Sun May 26 14:22:27 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 26 May 2019 18:22:27 -0000 (UTC) Subject: More CPUs doen't equal more speed References: Message-ID: On 2019-05-26, Chris Angelico wrote: > Sometimes, the "simple" and "obvious" code, the part that clearly has > no bugs in it, is the part that has the problem. :) And in this case, the critical part of the code that was actually serializing everything wasn't shown. One strives to post problem descriptions that are as simple as possible, but in this case the description was even simpler than that. -- Grant From rosuav at gmail.com Sun May 26 14:24:54 2019 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 May 2019 04:24:54 +1000 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: On Mon, May 27, 2019 at 4:24 AM Grant Edwards wrote: > > On 2019-05-26, Chris Angelico wrote: > > > Sometimes, the "simple" and "obvious" code, the part that clearly has > > no bugs in it, is the part that has the problem. :) > > And in this case, the critical part of the code that was actually > serializing everything wasn't shown. One strives to post problem > descriptions that are as simple as possible, but in this case the > description was even simpler than that. > Indeed, which is why I asked the question. ChrisA From bob at mellowood.ca Sun May 26 14:56:00 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Sun, 26 May 2019 11:56:00 -0700 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: On Sun, May 26, 2019 at 11:05 AM Grant Edwards wrote: > On 2019-05-23, Chris Angelico wrote: > > On Fri, May 24, 2019 at 5:37 AM Bob van der Poel > wrote: > >> > >> I've got a short script that loops though a number of files and > >> processes them one at a time. I had a bit of time today and figured > >> I'd rewrite the script to process the files 4 at a time by using 4 > >> different instances of python. My basic loop is: > >> > >> for i in range(0, len(filelist), CPU_COUNT): > >> for z in range(i, i+CPU_COUNT): > >> doit( filelist[z]) > >> > >> With the function doit() calling up the program to do the > >> lifting. Setting CPU_COUNT to 1 or 5 (I have 6 cores) makes no > >> difference in total speed. I'm processing about 1200 files and my > >> total duration is around 2 minutes. No matter how many cores I use > >> the total is within a 5 second range. > > > > Where's the part of the code that actually runs them across multiple > > CPUs? Also, are you spending your time waiting on the disk, the CPU, > > IPC, or something else? > > He said he's using N differenct Python instances, and he even provided > the code that runs in each instance which is obviously processesing > 1/Nth of the files. > > It's a pretty good bet that I/O is the limiting factor. > > I did say that ... I also retracted it. In my first eg. I was still running one process at a time ... no multi-task at all. Parallel is up and running and is very, very fast ... loads my CPUs to 100% > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bob at mellowood.ca WWW: http://www.mellowood.ca From cs at cskk.id.au Sun May 26 19:13:20 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 27 May 2019 09:13:20 +1000 Subject: How to use ssh-agent in windows in python? In-Reply-To: References: Message-ID: <20190526231320.GA98887@cskk.homeip.net> On 26May2019 22:55, Fc Zwtyds wrote: > I am using cygwin on Windows 8.1. These two commands work fine in > cygwin: >ssh-agent -s >ssh-add ~/.ssh /id_rsa No, they run without error (apparently). That is an entirely different thing. In particular, "ssh-agent -s" starts an agent but unless you make use of its output, your subsequent commands will have no idea how to access it. Since ssh-add (apparently) works, then I would guess you _already_ had an agent, and it is adding to that agent's keys. And, importantly, _ignoring_ the new agent you started. Try running your commands above again, but _before_ them, run "ssh-add -l". If that works then there's already an agent known to the shell and your subsequent "ssh-add" is likely adding to that, not to the new agent you dispatched. > I tried to use them on windows cmd and it worked fine. Now I am >going to use python to write code to implement the above command. >os.system('ssh-agent -s') >os.system('ssh-add id_rsa') >There was an error: >Could not open a connection to your authentication agent. I'm presuming that as with UNIXy systems, os.system() on Windows issues its commands to a distinct shell ( instance of cmd.exe or the like). As such, since you've made no effort to catch and parse the output of "ssh-agent -s" you don't know how to talk to the agent you started, and further since you don't pass any information to the shell running "ssh-add" then it doesn't know how to do that either. Cheers, Cameron Simpson From fczwtyds at gmail.com Sun May 26 19:56:56 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Mon, 27 May 2019 07:56:56 +0800 Subject: How to use ssh-agent in windows in python? References: Message-ID: ? 2019-05-27 0:27, MRAB ??: > On 2019-05-26 15:55, Fc Zwtyds wrote: >> Hi, >> ??? I am using cygwin on Windows 8.1. These two commands work fine in >> cygwin: >> ssh-agent -s >> ssh-add ~/.ssh /id_rsa >> ??? I tried to use them on windows cmd and it worked fine. Now I am going >> to use python to write code to implement the above command. >> os.system('ssh-agent -s') >> os.system('ssh-add id_rsa') >> There was an error: >> Could not open a connection to your authentication agent. >> >> Thank you and your time. >> > The string that you passed to the second os.system differs from the > second command on the command line. Is that the cause? Hi, At the beginning string is like this ssh-add ~/.ssh/id_rsa In order to facilitate the test, multiple quick input, I copied id_rsa into the program directory, the string was changed to ssh-add id_rsa Whether in cygwin or cmd, manually entering these two commands will execute correctly. As far as I know, the problem seems to be that a subshell is opened after 'ssh-agent -s' execution, and I don't know how to use python to implement this process. Thank you for your help From fczwtyds at gmail.com Sun May 26 20:22:48 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Mon, 27 May 2019 08:22:48 +0800 Subject: How to use ssh-agent in windows in python? References: <20190526231320.GA98887@cskk.homeip.net> Message-ID: ? 2019-05-27 7:13, Cameron Simpson ??: > On 26May2019 22:55, Fc Zwtyds wrote: >> ?I am using cygwin on Windows 8.1. These two commands work fine in >> ?cygwin: >> ssh-agent -s >> ssh-add ~/.ssh /id_rsa > > No, they run without error (apparently). That is? an entirely different > thing. > > In particular, "ssh-agent -s" starts an agent but unless you make use of > its output, your subsequent commands will have no idea how to access it. > > Since ssh-add (apparently) works, then I would guess you _already_ had > an agent, and it is adding to that agent's keys. And, importantly, > _ignoring_ the new agent you started. > > Try running your commands above again, but _before_ them, run "ssh-add > -l". If that works then there's already an agent known to the shell and > your subsequent "ssh-add" is likely adding to that, not to the new agent > you dispatched. > >> ?I tried to use them on windows cmd and it worked fine. Now I am going >> to use python to write code to implement the above command. >> os.system('ssh-agent -s') >> os.system('ssh-add id_rsa') >> There was an error: >> Could not open a connection to your authentication agent. > > I'm presuming that as with UNIXy systems, os.system() on Windows issues > its commands to a distinct shell ( instance of cmd.exe or the like). > > As such, since you've made no effort to catch and parse the output of > "ssh-agent -s" you don't know how to talk to the agent you started, and > further since you don't pass any information to the shell running > "ssh-add" then it doesn't know how to do that either. > > Cheers, > Cameron Simpson Thank you very much for your detailed answer. I will try to learn how to capture and parse the output of "ssh-agent -s" and learn how to talk to the agent. From cs at cskk.id.au Sun May 26 23:19:28 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 27 May 2019 13:19:28 +1000 Subject: How to use ssh-agent in windows in python? In-Reply-To: References: Message-ID: <20190527031928.GA47778@cskk.homeip.net> On 27May2019 08:22, Fc Zwtyds wrote: >Thank you very much for your detailed answer. >I will try to learn how to capture and parse the output of "ssh-agent >-s" and learn how to talk to the agent. The output of "ssh-agent -s" is Bourne shell variable assignment syntax. You need to parse that and then install those values in so.environ before calling the second command. The subprocess module has methods for collecting the output of a command (see the communicate method). Cheers, Cameron Simpson From mturner865 at gmail.com Sun May 26 14:33:24 2019 From: mturner865 at gmail.com (Mark Turner) Date: Sun, 26 May 2019 14:33:24 -0400 Subject: Undefined symbols for Mac OS 10.14.4 build Message-ID: <4A72BF66-7C78-4A2E-A301-F44F15758505@gmail.com> Hi, I?m trying to build CPython 3.8 from source on Mac OS 10.14.4 and running into undefined symbols problem at the linker stage.The commands I?m using are: ./configure --with-pydebug make -s -j2 The undefined symbols are listed below. I?ve found that if I modify pyconfig.h by changing #define HAVE_LIBINTL_H 1 to #undef HAVE_LIBINTL_H the build completes. This is my first time trying this so I?m not very familiar with the build process. It seems like I must be missing something since I don't think modifying pyconfig.h is a normal part of the process. Any suggestions? Thanks, Mark Undefined symbols for architecture x86_64: Undefined symbols for architecture x86_64: "_libintl_bindtextdomain", referenced from: "_libintl_bindtextdomain", referenced from: _PyIntl_bindtextdomain in libpython3.8d.a(_localemodule.o) _PyIntl_bindtextdomain in libpython3.8d.a(_localemodule.o) "_libintl_dcgettext", referenced from: "_libintl_dcgettext", referenced from: _PyIntl_dcgettext in libpython3.8d.a(_localemodule.o) _PyIntl_dcgettext in libpython3.8d.a(_localemodule.o) "_libintl_dgettext", referenced from: "_libintl_dgettext", referenced from: _PyIntl_dgettext in libpython3.8d.a(_localemodule.o) _PyIntl_dgettext in libpython3.8d.a(_localemodule.o) "_libintl_gettext", referenced from: "_libintl_gettext", referenced from: _PyIntl_gettext in libpython3.8d.a(_localemodule.o) _PyIntl_gettext in libpython3.8d.a(_localemodule.o) "_libintl_setlocale", referenced from: "_libintl_setlocale", referenced from: _PyLocale_setlocale in libpython3.8d.a(_localemodule.o) _PyLocale_setlocale in libpython3.8d.a(_localemodule.o) _locale_decode_monetary in libpython3.8d.a(_localemodule.o) _locale_decode_monetary in libpython3.8d.a(_localemodule.o) "_libintl_textdomain", referenced from: "_libintl_textdomain", referenced from: _PyIntl_textdomain in libpython3.8d.a(_localemodule.o) _PyIntl_textdomain in libpython3.8d.a(_localemodule.o) ld: symbol(s) not found for architecture x86_64 ld: symbol(s) not found for architecture x86_64 From vriolk at gmail.com Mon May 27 06:59:35 2019 From: vriolk at gmail.com (coldpizza) Date: Mon, 27 May 2019 03:59:35 -0700 (PDT) Subject: How to use ssh-agent in windows in python? In-Reply-To: References: Message-ID: <28e1af72-d428-452f-a2ab-e56a93f5a573@googlegroups.com> example code for doing it in pure python: http://code.activestate.com/recipes/576810-copy-files-over-ssh-using-paramiko/ From fczwtyds at gmail.com Mon May 27 11:50:12 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Mon, 27 May 2019 23:50:12 +0800 Subject: How to use ssh-agent in windows in python? References: <20190527031928.GA47778@cskk.homeip.net> Message-ID: ? 2019-05-27 11:19, Cameron Simpson ??: > On 27May2019 08:22, Fc Zwtyds wrote: >> Thank you very much for your detailed answer. >> I will try to learn how to capture and parse the output of "ssh-agent >> -s" and learn how to talk to the agent. > > The output of "ssh-agent -s" is Bourne shell variable assignment syntax. > You need to parse that and then install those values in so.environ > before calling the second command. The subprocess module has methods for > collecting the output of a command (see the communicate method). > > Cheers, > Cameron Simpson Yes, today, I also found subprocess and are learning related materials. https://docs.python.org/3.7/library/subprocess.html It's hard to me, but I will try my best. I need time to learn all of these information. Thank you very much and your recommended materials. From fczwtyds at gmail.com Mon May 27 12:01:55 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Tue, 28 May 2019 00:01:55 +0800 Subject: How to use ssh-agent in windows in python? References: <28e1af72-d428-452f-a2ab-e56a93f5a573@googlegroups.com> Message-ID: ? 2019-05-27 18:59, coldpizza ??: > example code for doing it in pure python: http://code.activestate.com/recipes/576810-copy-files-over-ssh-using-paramiko/ > Thank you very much and the information you recommended, I will take the time to learn it: paramiko From wiwindson at gmail.com Mon May 27 23:56:40 2019 From: wiwindson at gmail.com (Windson Yang) Date: Tue, 28 May 2019 11:56:40 +0800 Subject: Duplicate function in thread_pthread.h Message-ID: When I try to understand the code about the thread. I found the thread_pthread.h file has some duplicate functions. Like `PyThread_free_lock`, `PyThread_release_lock`, `PyThread_acquire_lock_timed`. IIUC, C doesn't support function overload. So why we have functions with the same name and args? From songofacandy at gmail.com Tue May 28 00:11:58 2019 From: songofacandy at gmail.com (Inada Naoki) Date: Tue, 28 May 2019 13:11:58 +0900 Subject: Duplicate function in thread_pthread.h In-Reply-To: References: Message-ID: Do you know C macros? Two implementations is switched by USE_SEMAPHORES. #ifdef USE_SEMAPHORES ... void PyThread_free_lock(PyThread_type_lock lock) ... #else /* USE_SEMAPHORES */ ... void PyThread_free_lock(PyThread_type_lock lock) ... #endif /* USE_SEMAPHORES */ On Tue, May 28, 2019 at 12:58 PM Windson Yang wrote: > > When I try to understand the code about the thread. I found > the thread_pthread.h file has some duplicate functions. Like > `PyThread_free_lock`, `PyThread_release_lock`, > `PyThread_acquire_lock_timed`. IIUC, C doesn't support function overload. > So why we have functions with the same name and args? > -- > https://mail.python.org/mailman/listinfo/python-list -- Inada Naoki From mal at europython.eu Tue May 28 03:26:34 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Tue, 28 May 2019 09:26:34 +0200 Subject: EuroPython 2019 Django Girls Workshop Message-ID: <84624248-c364-d22b-58a5-73428752baca@europython.eu> Would you like to know about how to build websites, how the internet works and would you like to try programming your own first blog, but don?t know where to start? We have good news for you: we are holding a one-day Django Girls workshop for beginners ! * https://ep2019.europython.eu/events/django-girls/ * Where and when -------------- The workshop will be held on Monday, July 8th in the EuroPython 2019 conference venue FHNW Campus Muttenz from 09:30 ? 17:00. What to expect -------------- During the workshop you will work through a tutorial in a small group of three attendees and one coach. Our coaches are software developers who contribute their time, knowledge and energy for you and Django Girls. All you need is a working laptop, and we?ll help you with the rest. You can attend the workshop for free! Your motivation counts, let us know about it in your application. Registering for the workshop ---------------------------- The workshop is aimed at women with little or no programming experience, but may also be useful if you?ve learned a different discipline (like data science) and would like to learn how to build websites with Django. The workshop is free to attend, but you have to apply and be accepted. We only have 30 seats available for the workshop, and we?ll pick the best applicants based on the information you provide you provide on the form. If you?d like to attend: apply here: https://djangogirls.org/basel/ Workshop coaches ---------------- We can?t run this workshop without coaches! A coach will be assigned to each group of 3 attendees. Their job is to support and encourage their team as they work through the Django Girls tutorial at their own pace. If you?d like to apply to be a coach, please sign up here: https://djangogirls.org/basel/ Sponsors of EuroPython 2019 Django Girls Workshop ------------------------------------------------- - The EuroPython Society is providing the room and catering in our training venue, the FHNW Campus Muttenz. - Nexmo will provide the Django Girls workshop box. - EntwicklerHeld will provide t-shirts for our coaches. More information is available on our Django Girls page: https://ep2019.europython.eu/events/django-girls/ Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (BCC) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). Tickets can be purchased on our registration page: https://ep2019.europython.eu/registration/buy-tickets/ For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/185195491022/europython-2019-django-girls-workshop Tweet: https://twitter.com/europython/status/1133271891974615046 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From mal at europython.eu Tue May 28 06:30:15 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Tue, 28 May 2019 12:30:15 +0200 Subject: EuroPython 2019: Please configure your tickets Message-ID: Since our website was updated this year, we would like to remind you how you can configure your tickets and profiles, so that we get the right information for printing badges and adjusting catering counts. We also had a few issues with the ticket configuration and assignments last week. As a result, some of the ticket name changes you may have made were lost. Please do consider assigning tickets to other rather than just changing the name on the ticket, since that way, we receive information about the new ticket owner?s preferences as well. Please see our blog post for full details ----------------------------------------- https://blog.europython.eu/post/185197692557/europython-2019-please-configure-your-tickets It covers these topics: - Assigning tickets to other people - Configuring your ticket - Printing your invoice - Configuring your EuroPython account - profile - privacy settings Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (CCB) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). Tickets can be purchased on our registration page: https://ep2019.europython.eu/registration/buy-tickets/ For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/185197692557/europython-2019-please-configure-your-tickets Tweet: https://twitter.com/europython/status/1133318559776608256 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From rhodri at kynesim.co.uk Tue May 28 09:29:07 2019 From: rhodri at kynesim.co.uk (Rhodri James) Date: Tue, 28 May 2019 14:29:07 +0100 Subject: PEP 594 cgi & cgitb removal In-Reply-To: References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <6ce73371-862e-50c9-425b-189d7f27e595@kynesim.co.uk> <20190524130017.sz7bfzvft7a33iql@xps> <8736l3vjgo.fsf@nightsong.com> <871s0n3bbj.fsf@elektro.pacujo.net> Message-ID: On 24/05/2019 21:23, Terry Reedy wrote: > I am responding to Paul indirectly because his post did not show up on > the gmane mirror. > >> Paul Rubin : > >>> It also makes me ask why the Python team keeps >>> adding new stuff if it can't even keep the old stuff running. > > Because the new stuff is expected to be more useful to more people than > some of the old modules.? The module proposed for deletion are all or > most all more than 20 years old, before there was a PyPI.? Some, like > cgi and cgitb were legitimately put in the stdlib.? Others were > specialist modules that today would not go in the stdlib. > > Does anyone really think that gopherlib should still be in the stdlib, > and that core developers should have to update its docs to explain it to > newbies today? I would want a better reason than "I don't wanna" to remove something from stdlib, much as I would want a better reason than "I want it" to add something. I agree that case is pretty much self-evident with gopherlib, which honestly would had trouble convincing me it should be included in the first place. I don't think it is at all self-evident for cgi and cgitb, even if I wouldn't have written them like that myself ;-) > My question is why people who value and understand old modules don't > volunteer more to help keep them up to date. As I said (and was apparently misinterpreted), I am considering it. -- Rhodri James *-* Kynesim Ltd From marek.mosiewicz at jotel.com.pl Tue May 28 14:05:48 2019 From: marek.mosiewicz at jotel.com.pl (Marek Mosiewicz) Date: Tue, 28 May 2019 20:05:48 +0200 Subject: More CPUs doen't equal more speed In-Reply-To: References: Message-ID: <8a17bc45-1b4a-1048-d496-a3ef48f068fa@jotel.com.pl> Do you do it as separate process or thread. There is https://wiki.python.org/moin/GlobalInterpreterLock so you need to spawn many processes Best regards, ??????? Marek Mosiewicz ??????? http://marekmosiewicz.pl W dniu 23.05.2019 o?20:39, Bob van der Poel pisze: > I've got a short script that loops though a number of files and processes > them one at a time. I had a bit of time today and figured I'd rewrite the > script to process the files 4 at a time by using 4 different instances of > python. My basic loop is: > > for i in range(0, len(filelist), CPU_COUNT): > for z in range(i, i+CPU_COUNT): > doit( filelist[z]) > > With the function doit() calling up the program to do the lifting. Setting > CPU_COUNT to 1 or 5 (I have 6 cores) makes no difference in total speed. > I'm processing about 1200 files and my total duration is around 2 minutes. > No matter how many cores I use the total is within a 5 second range. > > This is not a big deal ... but I really thought that throwing more > processors at a problem was a wonderful thing :) I figure that the cost of > loading the python libraries and my source file and writing it out are > pretty much i/o bound, but that is just a guess. > > Maybe I need to set my sights on bigger, slower programs to see a > difference :) > From sritharun4477 at gmail.com Tue May 28 22:37:06 2019 From: sritharun4477 at gmail.com (Sri Tharun) Date: Wed, 29 May 2019 08:07:06 +0530 Subject: No subject Message-ID: Why I am unable to install packages From sritharun4477 at gmail.com Tue May 28 22:38:05 2019 From: sritharun4477 at gmail.com (Sri Tharun) Date: Wed, 29 May 2019 08:08:05 +0530 Subject: problem in installing packages In-Reply-To: <5ceddbd9.1c69fb81.c42e4.6195@mx.google.com> References: <5ceddbd9.1c69fb81.c42e4.6195@mx.google.com> Message-ID: Problem not resolved. Yet On Wed 29 May, 2019, 6:39 AM Tharun, wrote: > > > >>> sudo apt-get update > > File "", line 1 > > sudo apt-get update > > ^ > > SyntaxError: invalid syntax > > > > > > This was the problem > > Sent from Mail for > Windows 10 > > > From joel.goldstick at gmail.com Wed May 29 01:26:11 2019 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Wed, 29 May 2019 01:26:11 -0400 Subject: problem in installing packages In-Reply-To: References: <5ceddbd9.1c69fb81.c42e4.6195@mx.google.com> Message-ID: On Wed, May 29, 2019 at 1:17 AM Sri Tharun wrote: > > Problem not resolved. Yet > > On Wed 29 May, 2019, 6:39 AM Tharun, wrote: > > > > > > > >>> sudo apt-get update > > > > File "", line 1 > > > > sudo apt-get update > > > > ^ > > > > SyntaxError: invalid syntax > > > > > > > > > > > > This was the problem > > > > Sent from Mail for > > Windows 10 > > > > > > > -- > https://mail.python.org/mailman/listinfo/python-list It appears you are trying to execute a linux shell command while in the python repl. exit python, and try again -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From robin at reportlab.com Wed May 29 03:17:57 2019 From: robin at reportlab.com (Robin Becker) Date: Wed, 29 May 2019 08:17:57 +0100 Subject: PEP 594 cgi & cgitb removal In-Reply-To: References: <79ae3322-34cd-316b-288e-e2420a2d2ab5@chamonix.reportlab.co.uk> <87d0k9iwkp.fsf@handshake.de> <871s0peoio.fsf@nightsong.com> <20190523124635.hphiagslwrbdjnz7@gthmcloud> <09e6f2c4-e8d3-903f-630f-b1803ca55b6c@gmail.com> Message-ID: ........... > > More specifically, with CGI the webserver starts a new process for every single request. That's bad enough for a light C program, > but it's certainly not a good idea to start a whole new Python process for every request. At least not for any production website > or web service that serves any real amount of traffic. > > That is, for those who didn't know, the reason why CGI fell out of use quite some time ago. > Well I'm afraid I cannot agree with that reasoning. ReportLab used cgi exactly because it starts a new process; most of the reports that are generated take more than a second to generate so the startup time is of less importance. Starting up in a clean state is of importance because the sharing of resources across different reports often leads to buggy report code such as relying on an earlier report to load fonts, define colours etc etc. This could perhaps have been done with multiple interpreters eg mod_python, but I think the isolation there is not perfect especially with C extensions. It might be that the new 'cgi' doesn't use the older api and in that sense we could just use wsgi or whatever the new interface is, but I would still use cgitb to provide nicely formatted traceback html. -- Robin Becker From fczwtyds at gmail.com Wed May 29 10:37:00 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Wed, 29 May 2019 22:37:00 +0800 Subject: How to use ssh-agent in windows in python? References: <20190527031928.GA47778@cskk.homeip.net> Message-ID: ? 2019-05-27 11:19, Cameron Simpson ??: > The output of "ssh-agent -s" is Bourne shell variable assignment syntax. > You need to parse that and then install those values in so.environ > before calling the second command. The subprocess module has methods for > collecting the output of a command (see the communicate method). Hi, I want to rewrite the shell script to python script so I have had changed the "ssh-agent -s" to 'ssh-agent cmd' in python script for the consistence on windows. There are two inputs in the two commands. I tried code use communicate method and write method and got errors: Cannot send input after starting communication and ValueError: write to closed file I found the communicate method just run one times. The manual input process is as follows: 1. run cmd.exe 2. input 'ssh-agent cmd' press return, the window display a new prompt. 3. input 'ssh-add id_rsa' and press return, it will ask the id_rsa password. After input correctly password, it will display 'Identity added: id_rsa (id_rsa)' and a new prompt. import subprocess p = subprocess.Popen('cmd', stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True, universal_newlines = True) outinfo, errinfo = p.communicate('ssh-agent cmd\n') #p.stdin.write('ssh-add id_rsa\n') #p.stdin.flush() print('outinfo is \n %s' % stdoutinfo) print('errinfo is \n %s' % stderrinfo) After a lot of searching and learning I still do not know how to code it, I realy need help. Thanks a lot. From pfeiffer at cs.nmsu.edu Wed May 29 10:37:46 2019 From: pfeiffer at cs.nmsu.edu (Joe Pfeiffer) Date: Wed, 29 May 2019 08:37:46 -0600 Subject: problem in installing packages References: <5ceddbd9.1c69fb81.c42e4.6195@mx.google.com> Message-ID: <1bo93lz5qd.fsf@pfeifferfamily.net> Joel Goldstick writes: > On Wed, May 29, 2019 at 1:17 AM Sri Tharun wrote: >> >> Problem not resolved. Yet >> >> On Wed 29 May, 2019, 6:39 AM Tharun, wrote: >> >> > >> > >>> sudo apt-get update >> > >> > File "", line 1 >> > >> > sudo apt-get update >> > ^ >> > SyntaxError: invalid syntax >> > >> > This was the problem >> > >> > Sent from Mail for >> > Windows 10 > > It appears you are trying to execute a linux shell command while in > the python repl. exit python, and try again And, if he is posting from the same computer as he is seeing the problem on, it's a Windows box so neither "sudo" nor "apt-get" is going to work anyway. From tsu.yubo at gmail.com Wed May 29 03:37:01 2019 From: tsu.yubo at gmail.com (Bo YU) Date: Wed, 29 May 2019 15:37:01 +0800 Subject: No subject In-Reply-To: References: Message-ID: On Wed, May 29, 2019 at 1:19 PM Sri Tharun wrote: > Why I am unable to install packages > If you really want to get help from the list,please give us more info. > -- > https://mail.python.org/mailman/listinfo/python-list > From niharmodi712 at gmail.com Wed May 29 04:38:51 2019 From: niharmodi712 at gmail.com (nihar Modi) Date: Wed, 29 May 2019 10:38:51 +0200 Subject: Threading Keyboard Interrupt issue Message-ID: I have written a simple code that involves threading, but it does not go to except clause after Keyboard interrupt. Can you suggest a way out. I have pasted the code below. It does not print 'hi' after keyboard interrupt and just stops. import threading def loop(): while true: print('hello') time.sleep(5) if __name__ == '__main__': try: y = threading.Thread(target = loop, args = ()) y.start() except KeyboardInterrupt: print('hi') The program does not print hi and terminates immediately after ctrl+c From rosuav at gmail.com Wed May 29 11:47:20 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 30 May 2019 01:47:20 +1000 Subject: Threading Keyboard Interrupt issue In-Reply-To: References: Message-ID: On Thu, May 30, 2019 at 1:45 AM nihar Modi wrote: > > I have written a simple code that involves threading, but it does not go to > except clause after Keyboard interrupt. Can you suggest a way out. I have > pasted the code below. It does not print 'hi' after keyboard interrupt and > just stops. Threads allow multiple things to run at once. The entire *point* of spinning off a new thread is that the main code keeps going even while the thread runs. They are independent. ChrisA From bcontreras7 at gatech.edu Wed May 29 11:53:25 2019 From: bcontreras7 at gatech.edu (Contreras, Brian J) Date: Wed, 29 May 2019 15:53:25 +0000 Subject: Trouble Downloading Python and Numpy Message-ID: Good Morning, I am a research student at the Georgia Institute of Technology. I have made multiple attempts to download different versions of Python with Numpy on my Microsoft Surface Book with no success. I ensured that I have space for the program and the latest windows 10 update, I still am unable to open any python files or write code within the program. I was told by a colleague that I may need a python path environmental variable, but I have not found asite that provides this. If I could get some support with the download I would greatly appreciate it. Warm Regards, Brian Contreras From shakti.shrivastava13 at gmail.com Wed May 29 12:08:26 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Wed, 29 May 2019 21:38:26 +0530 Subject: Trouble Downloading Python and Numpy In-Reply-To: References: Message-ID: On Wed, 29 May 2019 at 9:29 PM Contreras, Brian J wrote: > Good Morning, > > I am a research student at the Georgia Institute of Technology. I have > made multiple attempts to download different versions of Python with Numpy > on my Microsoft Surface Book with no success. > Since you need numpy and as a grad student too, I'll strongly suggest you to look for "installing anaconda on Windows". It's GUI based installation would be a good start especially for people who are struggling with python installations on windows. > (Clipped for brevity) > -- > https://mail.python.org/mailman/listinfo/python-list > -- Sent from Shakti?s iPhone From shakti.shrivastava13 at gmail.com Wed May 29 12:10:32 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Wed, 29 May 2019 21:40:32 +0530 Subject: Trouble Downloading Python and Numpy In-Reply-To: References: Message-ID: On Wed, 29 May 2019 at 9:38 PM Shakti Kumar wrote: > > > On Wed, 29 May 2019 at 9:29 PM Contreras, Brian J > wrote: > >> Good Morning, >> >> I am a research student at the Georgia Institute of Technology. I have >> made multiple attempts to download different versions of Python with Numpy >> on my Microsoft Surface Book with no success. >> > > Since you need numpy and as a grad student too, I'll strongly suggest you > to look for "installing anaconda on Windows". It's GUI based installation > would be a good start especially for people who are struggling with python > installations on windows. > Forgot to mention this, Anaconda comes prepackaged with numpy, pandas, scripy and other data analysis libs. So you won't need to pip/conda install them separately > >> (Clipped for brevity) > > >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > -- > Sent from Shakti?s iPhone > -- Sent from Shakti?s iPhone From David.Raymond at tomtom.com Wed May 29 12:16:08 2019 From: David.Raymond at tomtom.com (David Raymond) Date: Wed, 29 May 2019 16:16:08 +0000 Subject: Threading Keyboard Interrupt issue In-Reply-To: References: Message-ID: That's a little weird, and my running it works slightly differently. Please paste exactly what you're running (no time import and true being lowercase for example means we couldn't copy and paste it and have it immediately run) In your script, the main thread hits y.start() which completes successfully as soon as the new thread gets going, so it exits the try/except block as a success. Then since there's no more code, the main thread completes. The loop thread you started inherits the daemon-ness of the thread that called it, so by default it's started as a regular thread, and not a daemon thread. As a regular thread it will keep going even when the main thread completes. Keyboard interrupts are only received by the main thread, which in this case completes real quick. So what happens for me is that the main thread runs to completion instantly and leaves nothing alive to receive the keyboard interrupt, which means the loop thread will run forever until killed externally. (Task manager, ctrl-break, etc) In this case, even if the main thread _was_ still alive to catch the keyboard interrupt, that exception does not get automatically passed to all threads, only the main one. So the main thread would have to catch the exception, then use one of the available signaling mechanisms to let the other threads know, and each of those other threads would have to consciously check for your signal of choice to see if the main thread wanted them to shut down. Or, the other threads would have to be declared as demonic before they were started, in which case they would be killed automatically once all non-daemonic threads had ended. -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of nihar Modi Sent: Wednesday, May 29, 2019 4:39 AM To: python-list at python.org Subject: Threading Keyboard Interrupt issue I have written a simple code that involves threading, but it does not go to except clause after Keyboard interrupt. Can you suggest a way out. I have pasted the code below. It does not print 'hi' after keyboard interrupt and just stops. import threading def loop(): while true: print('hello') time.sleep(5) if __name__ == '__main__': try: y = threading.Thread(target = loop, args = ()) y.start() except KeyboardInterrupt: print('hi') The program does not print hi and terminates immediately after ctrl+c -- https://mail.python.org/mailman/listinfo/python-list From eryksun at gmail.com Wed May 29 14:03:55 2019 From: eryksun at gmail.com (eryk sun) Date: Wed, 29 May 2019 13:03:55 -0500 Subject: Threading Keyboard Interrupt issue In-Reply-To: References: Message-ID: On 5/29/19, David Raymond wrote: > > Keyboard interrupts are only received by the main thread, which in this case > completes real quick. > > So what happens for me is that the main thread runs to completion instantly > and leaves nothing alive to receive the keyboard interrupt, which means the > loop thread will run forever until killed externally. (Task manager, > ctrl-break, etc) The main thread is still running in order to join non-daemon threads. In Windows, the internal wait used to join a thread can't be interrupted by Ctrl+C, unlike POSIX platforms. The Windows build could be modified to support Ctrl+C in this case, but I'm only certain about the current build that uses emulated condition variables. When I run the OP's script in Linux, acquiring the internal thread-state lock (which normally waits until the lock is reset when the thread exits) gets interrupted by the SIGINT signal, and KeyboardInterrupt is raised: Exception ignored in: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 1294, in _shutdown t.join() File "/usr/lib/python3.6/threading.py", line 1056, in join self._wait_for_tstate_lock() File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock elif lock.acquire(block, timeout): KeyboardInterrupt From cs at cskk.id.au Wed May 29 18:41:25 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Thu, 30 May 2019 08:41:25 +1000 Subject: How to use ssh-agent in windows in python? In-Reply-To: References: Message-ID: <20190529224125.GA46825@cskk.homeip.net> On 29May2019 22:37, Fc Zwtyds wrote: >? 2019-05-27 11:19, Cameron Simpson ??: >>The output of "ssh-agent -s" is Bourne shell variable assignment >>syntax. You need to parse that [...] > > I want to rewrite the shell script to python script so I have had >changed the "ssh-agent -s" to 'ssh-agent cmd' in python script for the >consistence on windows. I'm not sure you need to do that. In fact, I'm fairly sure you don't. When you run "ssh-agent cmd" the agent starts as before, but instead of reporting its communication socket and process id it dispatches command and runs for the duration of that command, then exits. Before ssh-agent dispatches "cmd" (here I mean a generic command, though that command might well be "cmd.exe"), it first puts the necessary environment variables into the command's environment. There are two such values: the communication socket and the ssh-agent process id. The socket is so that the other ssh commands can talk to it, and the process id is so that it can be terminated when no longer wanted. For the "ssh-agent cmd" form there's no need to use the process id, since ssh-agent itself will exit after "cmd" finishes. Let's look at what "ssh-agent -s" produces. This is on a UNIX system (my Mac): [~]fleet*> ssh-agent -s SSH_AUTH_SOCK=/Users/cameron/tmp/ssh-vuvXU6vrCAxz/agent.50746; export SSH_AUTH_SOCK; SSH_AGENT_PID=50754; export SSH_AGENT_PID; echo Agent pid 50754; You can see the socket path and the process id there. The paths will be a bit different on Windows. So if I do a process listing (this is a UNIX "ps" command, you will need to do the equivalent Windows thing) and search for that process id we see: [~]fleet*1> ps ax | grep 62928 62928 ?? Ss 0:00.00 ssh-agent -s 66204 s027 S+ 0:00.00 grep 62928 So there's the ssh-agent process and also the "grep" command itself because the process id is present on its command line. Note that at this point my shell (cmd.exe equivalent in Windows) does not know about the new ssh-agent. This is because I haven't put those environment values into the shell environment: the output above is just written to the display. So when I go: [~]fleet*> ssh-add -l it shows me 4 ssh keys. This is because I already have an agent which has some keys loaded. If my shell were talking to the new agent the list would be empty. Let's do that. [~]fleet*> SSH_AUTH_SOCK=/Users/cameron/tmp/ssh-vuvXU6vrCAxz/agent.50746 [~]fleet*> SSH_AGENT_PID=50754 [~]fleet*> export SSH_AUTH_SOCK SSH_AGENT_PID [~]fleet*> ssh-add -l The agent has no identities. So now this shell is using the new agent. You see there's no magic here: other commands do not know about the agent until we tell then about it using these environment variables. What I was suggesting is that you perform this process from Python, which I believe was your original plan. So let's adapt the the comand you presented below, and also dig into why what you've tried hasn't worked. So, your subprocess call: import subprocess p = subprocess.Popen('cmd', stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True, universal_newlines = True) outinfo, errinfo = p.communicate('ssh-agent cmd\n') print('outinfo is \n %s' % stdoutinfo) print('errinfo is \n %s' % stderrinfo) This does the follow things: 1: Start a subprocess running "cmd". You get back a Popen object "p" for use with that process. 2: Run p.communicate("ssh-agent cmd\n"). This sends that to the input of the "cmd" subprocess and collects the output. An important thing to know here is the .communicate is a complete interaction with the subprocess. The subprocess' _entire_ input is the string you've supplied, and the entire output of the subprocess until it completes is collected. So, what's going on is this: 1: start "cmd" 2: send "ssh-agent cmd\n" to it. 3: collect output and wait for it to exit. From "cmd"'s point of view: 1: Receive "ssh-agent cmd\n", causing it to run the "ssh-=agent cmd" command and then wait for it to exit. 2: ssh-agent starts and then runs another "cmd" and waits for _that_ to exit. 3: The second "cmd" processes its input, then exits. Note that becuase the input to the entire subprocess was "ssh-agent cmd\n", and the first "cmd" consumed that, there is no no more input data. So the second cmd exits immediately because there is no input. 4: The ssh-agent exist because the second "cmd" exited. 5: The first "cmd" sees the "ssh-agent cmd" command exit and looks for another command to run from its input. 6: As before, there are no more input data. So the first "cmd" also exits. And at that point .communicate sees the end of the output and returns it. Because the subprocess is complete, your commented out "p.write" call fails. You can't do things that way with .communicate. There are complicated (and error prone) ways to do more incremental input, not using .communicate. Let us not go there for now. Instead, let's consider using communicate with your original plan, which was to reproduce a script when went: ssh-agent -s ssh-add id_rsa ... more ssh based commands here ... You were using os.system(), which just dispatches a command and doesn't do anything about its input or output. We want to use .communicate because it lets us collect the agent information. The important thing to note here is that the _only_ extra information the commands after "ssh-agent" require is the environment variables. So you can go: 1: Dispatch "ssh-agent -s" with subprocess and use .communicate to collect the output. 2: Parse the environment values out of the output and install them in Python's os.environ dictionary. 3: Run your other ssh commands. because os.environ has the necessary values in it, they will communicate with the agent, which is still sitting around. 4: When finished, kill the agent to tidy up. So start with this: p = subprocess.Popen('ssh-agent -s', stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True, universal_newlines = True) outinfo, errinfo = p.communicate('ssh-agent cmd\n') You should get the output from ssh-agent in "outinfo". Remember, it is a single string looking like this: SSH_AUTH_SOCK=/Users/cameron/tmp/ssh-vuvXU6vrCAxz/agent.50746; export SSH_AUTH_SOCK; SSH_AGENT_PID=50754; export SSH_AGENT_PID; echo Agent pid 50754; Obviously the specific paths and numbers will vary. So you want to parse that. Untested code: import os # break the output data into lines lines = outinfo.split('\n') for line in lines: # trim leading and trailing whitespace line = line.strip() # ignore blank/empty lines if not line: continue # break off the part before the semicolon left, right = line.split(';', 1) if '=' in left: # get variable and value, put into os.environ varname, varvalue = left.split('=', 1) print("got", varname, "=', "varvalue) os.environ[varname]=varvalue The you could just use os.system() to run the other commands, because the environment now has the necessary environment settings. See how you go. Cheers, Cameron Simpson (formerly cs at zip.com.au) From fczwtyds at gmail.com Wed May 29 20:22:17 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Thu, 30 May 2019 08:22:17 +0800 Subject: How to use ssh-agent in windows in python? References: <20190529224125.GA46825@cskk.homeip.net> Message-ID: ? 2019-05-30 6:41, Cameron Simpson ??: > On 29May2019 22:37, Fc Zwtyds wrote: >> ? 2019-05-27 11:19, Cameron Simpson ??: >>> The output of "ssh-agent -s" is Bourne shell variable assignment >>> syntax. You need to parse that [...] >> >> ?I want to rewrite the shell script to python script so I have had >> changed the "ssh-agent -s" to 'ssh-agent cmd' in python script for the >> consistence on windows. > > I'm not sure you need to do that. In fact, I'm fairly sure you don't. > ... ... ... > The you could just use os.system() to run the other commands, because > the environment now has the necessary environment settings. > > See how you go. > > Cheers, > Cameron Simpson (formerly cs at zip.com.au) Thank you very very much and your time. I need a time to learn what you write to me. Thank you again. From eryksun at gmail.com Wed May 29 21:08:28 2019 From: eryksun at gmail.com (eryk sun) Date: Wed, 29 May 2019 20:08:28 -0500 Subject: Threading Keyboard Interrupt issue In-Reply-To: References: Message-ID: On 5/29/19, Dennis Lee Bieber wrote: > > In the OP's example code, with just one thread started, the easiest > solution is to use > > y.start() > y.join() > > to block the main thread. That will, at least, let the try/except catch the > interrupt. It does not, however, kill the sub-thread. join() can't be interrupted by Ctrl+C in Windows. To work around this, we can join a thread with a short timeout in a loop. If we're managing queued work items with a thread pool, note that Queue.join doesn't support a timeout. In this case we need to poll empty() in a loop with a short time.sleep(). Or we can let the main thread block and use ctypes to install a console control handler that sets a flag that tells child threads to exit. Windows calls the control handler in a new thread. From wiwindson at gmail.com Wed May 29 23:01:51 2019 From: wiwindson at gmail.com (Windson Yang) Date: Thu, 30 May 2019 11:01:51 +0800 Subject: write function call _io_BufferedWriter_write_impl twice? Message-ID: My script looks like this: f = open('myfile', 'a+b') f.write(b'abcde') And I also add a `printf` statement in the _io_BufferedWriter_write_impl function. static PyObject * _io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer) /*[clinic end generated code: output=7f8d1365759bfc6b input=dd87dd85fc7f8850]*/ { printf("call write_impl\n"); PyObject *res = NULL; Py_ssize_t written, avail, remaining; Py_off_t offset; ... After I compiled then run my script. I found _io_BufferedWriter_write_impl had been called twice which I expected only once. The second time it changed self->pos to an unexpected value too. From eryksun at gmail.com Thu May 30 01:18:07 2019 From: eryksun at gmail.com (eryk sun) Date: Thu, 30 May 2019 00:18:07 -0500 Subject: How to use ssh-agent in windows in python? In-Reply-To: <20190529224125.GA46825@cskk.homeip.net> References: <20190529224125.GA46825@cskk.homeip.net> Message-ID: On 5/29/19, Cameron Simpson wrote: > > So start with this: > > p = subprocess.Popen('ssh-agent -s', stdin = subprocess.PIPE, stdout = > subprocess.PIPE, stderr = subprocess.PIPE, shell = True, universal_newlines > = True) I'm wary of relying on the default encoding here. ssh-agent probably writes ASCII or ANSI text to the pipe, and Python defaults to decoding as ANSI ('mbcs'). However, Windows filesystem paths can use any Unicode characters. (A filename is a string of up to 255 16-bit wchar_t values, sans reserved characters, regardless of whether it's valid UTF-16LE, but let's assume it's valid Unicode text for the sake of everyone's sanity.) This is a problem when a user name can't be encoded with the system ANSI codepage. In particular, it's a concern for the user's %temp% directory (i.e. "C:/Users//AppData/Local/Temp") in the SSH_AUTH_SOCK environment variable. That said, at least for the MSYS2 build of ssh-agent.exe that's included with Git, the user's %temp% directory is mapped to "/tmp" in its emulated POSIX namespace, so this should be okay. Make sure the Cygwin build behaves the same. Otherwise check whether there's a way to force it to use UTF-8. MSYS2 apparently respects the LC_CTYPE environment variable. Without LC_CTYPE set, it fails to even parse the command line properly: >>> bash = r'C:\Program Files\Git\usr\bin\bash.exe' >>> command = 'echo ?????' >>> subprocess.call([bash, '-c', command]) /usr/bin/bash: echo ?????: command not found 127 With it set, it parses the command correctly and writes UTF-8 encoded text to stdout when it's a pipe or disk file: >>> environ = os.environ.copy() >>> environ['LC_CTYPE'] = 'en_US.utf8' >>> subprocess.check_output([bash, '-c', command], ... env=environ, encoding='utf-8') '?????\n' From abhinav1205 at gmail.com Thu May 30 02:33:24 2019 From: abhinav1205 at gmail.com (abhinav1205 at gmail.com) Date: Wed, 29 May 2019 23:33:24 -0700 (PDT) Subject: compiling 3.7.0 from source with custom libffi path In-Reply-To: References: <22a379ae-9385-cfbc-643f-26a111bea333@tjol.eu> <38a15e71-b655-3500-94f4-65d00c174ca5@tjol.eu> <2c614ce1-8c52-6e7d-e861-c6347ec6d4be@tjol.eu> Message-ID: <10928cc3-5749-4ca1-8ece-9e14da5a986e@googlegroups.com> Exactly same issue.. ctypes wont build .. pkg-config finds libffi, headers are located in configure and still INFO: Could not locate ffi libs and/or headers python is getting really annoying to install .. not everyone has root privileges to install system-wide dependencies. On Tuesday, September 25, 2018 at 12:11:51 AM UTC+5:30, Fetchinson . wrote: > On 9/24/18, Thomas Jollans wrote: > > On 2018-09-24 16:30, Fetchinson . via Python-list wrote: > >> [fetch at fetch]$ grep LIBFFI_INCLUDE Makefile > >> LIBFFI_INCLUDEDIR= /opt/custom/lib/libffi-3.2.1/include > >> > >> So I'd say everything should work but it doesn't, I reran ./configure > >> and also make of course. > > > > I'm confused. ./configure succeeds? Then where's the error? > > Yes, ./configure succeeds, also make succeeds in general, so it > produces a usable python executable but _ctypes is not compiled so > _ctypes is not usable and can not be imported, libffi is only needed > for _ctypes AFAIK. The error, or better said INFO message, comes from > make: > > INFO: Could not locate ffi libs and/or headers > > Failed to build these modules: > _ctypes > > But nevertheless make install also succeeds, the only thing is that > _ctypes does not work. > > Cheers, > Daniel > > -- > Psss, psss, put it down! - http://www.cafepress.com/putitdown From songofacandy at gmail.com Thu May 30 07:26:48 2019 From: songofacandy at gmail.com (Inada Naoki) Date: Thu, 30 May 2019 20:26:48 +0900 Subject: write function call _io_BufferedWriter_write_impl twice? In-Reply-To: References: Message-ID: The second _io_BufferedWriter_write_impl call is for show warning like "ResourceWarning: unclosed file <_io.BufferedRandom name='myfile'>" Try `f.close()`, or `with open(...)`. On Thu, May 30, 2019 at 12:03 PM Windson Yang wrote: > > My script looks like this: > > f = open('myfile', 'a+b') > f.write(b'abcde') > > And I also add a `printf` statement in the _io_BufferedWriter_write_impl > > function. > > static PyObject * _io_BufferedWriter_write_impl(buffered *self, > Py_buffer *buffer) > /*[clinic end generated code: output=7f8d1365759bfc6b > input=dd87dd85fc7f8850]*/ > { > printf("call write_impl\n"); > PyObject *res = NULL; > Py_ssize_t written, avail, remaining; > Py_off_t offset; > ... > > After I compiled then run my script. I found _io_BufferedWriter_write_impl > > had > been called twice which I expected only once. The second time it changed > self->pos to an unexpected value too. > -- > https://mail.python.org/mailman/listinfo/python-list -- Inada Naoki From mal at europython.eu Fri May 31 03:24:36 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Fri, 31 May 2019 09:24:36 +0200 Subject: EuroPython 2019: PyData EuroPython 2019 Message-ID: <1442c04d-a087-cd88-0392-8b5027272daf@europython.eu> We are happy to announce a complete PyData track at EuroPython 2019: * PyData EuroPython 2019 * https://ep2019.europython.eu/events/pydata-europython-2019/ The PyData track will be part of EuroPython 2019, so you won?t need to buy an extra ticket to attend. The PyData track is run in cooperation with NumFocus. There are two full tracks featuring more than 30 talks and 4 trainings: - 4 trainings on Monday and Tuesday (July 8-9) - 34 talks on Wednesday and Thursday (July 10-11) - no PyData talks on Friday (July 12) The full program is available on our PyData EuroPython 2019 page. https://ep2019.europython.eu/events/pydata-europython-2019/ If you?d like to attend PyData EuroPython 2019, please register for EuroPython 2019 soon: https://ep2019.europython.eu/registration/buy-tickets/ Dates and Venues ---------------- EuroPython will be held from July 8-14 2019 in Basel, Switzerland, at the Congress Center Basel (CCB) for the main conference days (Wed-Fri) and the FHNW Muttenz for the workshops/trainings/sprints days (Mon-Tue, Sat-Sun). Tickets can be purchased on our registration page: https://ep2019.europython.eu/registration/buy-tickets/ For more details, please have a look at our website and the FAQ: https://ep2019.europython.eu/faq 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/185265747827/pydata-europython-2019 Tweet: https://twitter.com/europython/status/1134358461335199749 Enjoy, -- EuroPython 2019 Team https://ep2019.europython.eu/ https://www.europython-society.org/ From fczwtyds at gmail.com Fri May 31 09:51:09 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Fri, 31 May 2019 21:51:09 +0800 Subject: How to use ssh-agent in windows in python? References: <20190529224125.GA46825@cskk.homeip.net> Message-ID: > ? 2019-05-30 6:41, Cameron Simpson ??: > ... > ... > ... >> The you could just use os.system() to run the other commands, because >> the environment now has the necessary environment settings. >> >> See how you go. >> >> Cheers, >> Cameron Simpson (formerly cs at zip.com.au) Hi, Under your guidance, the python code using ssh-agent ssh-add has been running successfully. In addition to the code you wrote to me, I also refer to man ssh-agent and subprocess: Subprocess management. I now know the importance of environment variables. This problem has puzzled me for nearly two weeks and solved this problem with your help. With your guidance and help, I have learned a lot. You are a very good teacher. You are my teacher. BTW, this program is for visit youtube. Cheers! Thanks so much. From fczwtyds at gmail.com Fri May 31 09:54:27 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Fri, 31 May 2019 21:54:27 +0800 Subject: How to use ssh-agent in windows in python? References: <20190529224125.GA46825@cskk.homeip.net> Message-ID: ? 2019-05-31 21:51, Fc Zwtyds ??: >> ? 2019-05-30 6:41, Cameron Simpson ??: >> ... >> ... >> ... >>> The you could just use os.system() to run the other commands, because >>> the environment now has the necessary environment settings. >>> >>> See how you go. >>> >>> Cheers, >>> Cameron Simpson (formerly cs at zip.com.au) > > Hi, > ? Under your guidance, the python code using ssh-agent ssh-add has been > running successfully. In addition to the code you wrote to me, I also > refer to man ssh-agent and subprocess: Subprocess management. I now know > the importance of environment variables. > ? This problem has puzzled me for nearly two weeks and solved this > problem with your help. > ? With your guidance and help, I have learned a lot. You are a very > good teacher. You are my teacher. > > BTW, this program is for visit youtube. > > Cheers! > > Thanks so much. > import subprocess import os p = subprocess.Popen('ssh-agent -s', stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True, universal_newlines = True) outinfo, errinfo = p.communicate() lines = outinfo.split('\n') for line in lines[:-1]: left, right = line.split(';', 1) if '=' in left: varname, varvalue = left.split('=', 1) print("got" + varname + "=" + varvalue) os.environ[varname] = varvalue os.system(r'ssh-add id_rsa') os.system(r'ssh-add -l') From fczwtyds at gmail.com Fri May 31 09:57:29 2019 From: fczwtyds at gmail.com (Fc Zwtyds) Date: Fri, 31 May 2019 21:57:29 +0800 Subject: How to use ssh-agent in windows in python? References: <20190529224125.GA46825@cskk.homeip.net> Message-ID: ? 2019-05-31 21:51, Fc Zwtyds ??: >> ? 2019-05-30 6:41, Cameron Simpson ??: >> ... >> ... >> ... >>> The you could just use os.system() to run the other commands, because >>> the environment now has the necessary environment settings. >>> >>> See how you go. >>> >>> Cheers, >>> Cameron Simpson (formerly cs at zip.com.au) > > Hi, > ? Under your guidance, the python code using ssh-agent ssh-add has been > running successfully. In addition to the code you wrote to me, I also > refer to man ssh-agent and subprocess: Subprocess management. I now know > the importance of environment variables. > ? This problem has puzzled me for nearly two weeks and solved this > problem with your help. > ? With your guidance and help, I have learned a lot. You are a very > good teacher. You are my teacher. > > BTW, this program is for visit youtube. > > Cheers! > > Thanks so much. > import subprocess import os p = subprocess.Popen('ssh-agent -s', stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True, universal_newlines = True) outinfo, errinfo = p.communicate() lines = outinfo.split('\n') for line in lines[:-1]: left, right = line.split(';', 1) if '=' in left: varname, varvalue = left.split('=', 1) print(varname + "=" + varvalue) os.environ[varname] = varvalue os.system('ssh-add id_rsa') os.system('ssh-add -l') run ok! From alister.ware at ntlworld.com Fri May 31 10:46:29 2019 From: alister.ware at ntlworld.com (Alister) Date: Fri, 31 May 2019 14:46:29 GMT Subject: (no subject) Message-ID: <97bIE.1872910$iiB1.1491908@fx08.am4> On Wed, 29 May 2019 08:07:06 +0530, Sri Tharun wrote: > Why I am unable to install packages because you are doing it wrong From Markus.Elfring at web.de Fri May 31 11:35:42 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Fri, 31 May 2019 17:35:42 +0200 Subject: Checking refusal of a network connection Message-ID: <274a7e1f-fc0d-0744-af06-bb861af8e30c@web.de> Hello, I can start a service as desired. elfring at Sonne:~/Projekte/Bau/C++/test-statistic-server1/local> ./test-statistic-server2 & /usr/bin/ss -t -l -p -H|grep test [1] 8961 waiting for connections server_id: localhost server_port: 35529 LISTEN 0 123 [::1]:35529 [::]:* users:(("test-statistic-",pid=8961,fd=3)) elfring at Sonne:~/Projekte/Bau/C++/test-statistic-server1/local> 0 connections were handled. But I wonder about the following error message then. elfring at Sonne:~/Projekte/Python> /usr/bin/python3 ~/Projekte/Python/socket-send_json_data.py --server_id localhost --server_port 35529 Using Python version: 3.7.2 ? Traceback ?: ? File "/home/elfring/Projekte/Python/socket-send_json_data.py", line 17, in send_data so.connect((args.server_id, args.server_port)) ConnectionRefusedError: [Errno 111] Connection refused How should this inter-process communication difficulty be resolved? Regards, Markus From Markus.Elfring at web.de Fri May 31 13:39:59 2019 From: Markus.Elfring at web.de (Markus Elfring) Date: Fri, 31 May 2019 19:39:59 +0200 Subject: Checking refusal of a network connection In-Reply-To: <9fn2fepn69vcvcu5qe235fe20s7c0elrmn@4ax.com> References: <274a7e1f-fc0d-0744-af06-bb861af8e30c@web.de> <9fn2fepn69vcvcu5qe235fe20s7c0elrmn@4ax.com> Message-ID: <98fdc3e6-d8e3-fa2d-c183-f84a11e02fbe@web.de> > Well, providing minimal code samples that produce the problem would be a start. I prefer an other approach to clarify relevant software configuration differences. > Otherwise we are just guessing... I can offer other data before. > Maybe you have a firewall problem. I hope not. I can try another server variant out as expected. elfring at Sonne:~/Projekte/Python> /usr/bin/python3 test-server2.py & [1] 14067 elfring at Sonne:~/Projekte/Python> /usr/bin/ss -t -l -p -H|grep python LISTEN 0 5 127.0.0.1:search-agent 0.0.0.0:* users:(("python3",pid=14067,fd=3)) elfring at Sonne:~/Projekte/Python> /usr/bin/python3 socket-send_json_data.py --server_id localhost --server_port 1234 Using Python version: 3.7.2 (default, Dec 30 2018, 16:18:15) [GCC] elfring at Sonne:~/Projekte/Python> Result: ? Can connections work also with a network service address like ?[::1]:35529? (which would be used by the C++ server implementation so far)? How does the software situation look like for the support of the IPv6 loopback address? Regards, Markus From sakshamraheja11 at gmail.com Fri May 31 15:04:32 2019 From: sakshamraheja11 at gmail.com (sakshamraheja11 at gmail.com) Date: Fri, 31 May 2019 12:04:32 -0700 (PDT) Subject: Hide text in entry box when i click on it.(GUI using Tkinter in python) In-Reply-To: <01419236-7cb8-498e-b3bb-9f209b1db53e@googlegroups.com> References: <01419236-7cb8-498e-b3bb-9f209b1db53e@googlegroups.com> Message-ID: Not happening in mine From sakshamraheja11 at gmail.com Fri May 31 15:08:19 2019 From: sakshamraheja11 at gmail.com (sakshamraheja11 at gmail.com) Date: Fri, 31 May 2019 12:08:19 -0700 (PDT) Subject: Hide text in entry box when i click on it.(GUI using Tkinter in python) In-Reply-To: <01419236-7cb8-498e-b3bb-9f209b1db53e@googlegroups.com> References: <01419236-7cb8-498e-b3bb-9f209b1db53e@googlegroups.com> Message-ID: NOT WORKING IN MINE PLZ HELP from tkinter import * g=Tk() g.geometry("{0}x{1}+0+0".format(g.winfo_screenwidth(), g.winfo_screenheight())) g.title("Check") g.configure(background='powder blue') def clear_search(event): e1.delete(0, tk.END) e1=Entry(g) e1.insert(0,'username') e1.pack() e1.bind("", clear_search) e1.bind("", clear_search) g.mainloop() From rosuav at gmail.com Fri May 31 15:23:53 2019 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 1 Jun 2019 05:23:53 +1000 Subject: Hide text in entry box when i click on it.(GUI using Tkinter in python) In-Reply-To: References: <01419236-7cb8-498e-b3bb-9f209b1db53e@googlegroups.com> Message-ID: On Sat, Jun 1, 2019 at 5:11 AM wrote: > > NOT WORKING IN MINE PLZ HELP > > > > from tkinter import * > g=Tk() > g.geometry("{0}x{1}+0+0".format(g.winfo_screenwidth(), g.winfo_screenheight())) > g.title("Check") > g.configure(background='powder blue') > > > def clear_search(event): > e1.delete(0, tk.END) > > e1=Entry(g) > e1.insert(0,'username') > e1.pack() > e1.bind("", clear_search) > e1.bind("", clear_search) > > g.mainloop() Did you look at the exception you get when this runs? It might possibly be able to point you to the problem, and maybe suggest how you could resolve it (by importing something, perhaps). ChrisA From rhodri at kynesim.co.uk Fri May 31 15:24:17 2019 From: rhodri at kynesim.co.uk (Rhodri James) Date: Fri, 31 May 2019 20:24:17 +0100 Subject: Hide text in entry box when i click on it.(GUI using Tkinter in python) In-Reply-To: References: <01419236-7cb8-498e-b3bb-9f209b1db53e@googlegroups.com> Message-ID: <9cf5aa7c-1dec-b0a6-b07c-0ae209c0c9b9@kynesim.co.uk> On 31/05/2019 20:08, sakshamraheja11 at gmail.com wrote: > NOT WORKING IN MINE PLZ HELP > > > > from tkinter import * > g=Tk() ^^ > g.geometry("{0}x{1}+0+0".format(g.winfo_screenwidth(), g.winfo_screenheight())) > g.title("Check") > g.configure(background='powder blue') > > > def clear_search(event): > e1.delete(0, tk.END) ^^ > > e1=Entry(g) > e1.insert(0,'username') > e1.pack() > e1.bind("", clear_search) > e1.bind("", clear_search) > > g.mainloop() Spot the difference between the identifiers I underlined. If you run this from the command line, the traceback tells you exactly what is going on. -- Rhodri James *-* Kynesim Ltd From cs at cskk.id.au Fri May 31 19:01:33 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 1 Jun 2019 09:01:33 +1000 Subject: How to use ssh-agent in windows in python? In-Reply-To: References: Message-ID: <20190531230133.GA67454@cskk.homeip.net> On 31May2019 21:51, Fc Zwtyds wrote: >>? 2019-05-30 6:41, Cameron Simpson ??: >>>The you could just use os.system() to run the other commands, because >>>the environment now has the necessary environment settings. [...] > > Under your guidance, the python code using ssh-agent ssh-add has >been running successfully. In addition to the code you wrote to me, I >also refer to man ssh-agent and subprocess: Subprocess management. I >now know the importance of environment variables. Excellent. I'm glad to hear it. >BTW, this program is for visit youtube. I am curious, how do you use the ssh commands to access youtube? I though it was an HTTP only service. Cheers, Cameron Simpson From cs at cskk.id.au Fri May 31 19:17:38 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 1 Jun 2019 09:17:38 +1000 Subject: Checking refusal of a network connection In-Reply-To: <274a7e1f-fc0d-0744-af06-bb861af8e30c@web.de> References: <274a7e1f-fc0d-0744-af06-bb861af8e30c@web.de> Message-ID: <20190531231738.GA92303@cskk.homeip.net> On 31May2019 17:35, Markus Elfring wrote: >I can start a service as desired. > >elfring at Sonne:~/Projekte/Bau/C++/test-statistic-server1/local> ./test-statistic-server2 & /usr/bin/ss -t -l -p -H|grep test >[1] 8961 >waiting for connections >server_id: localhost >server_port: 35529 >LISTEN 0 123 [::1]:35529 [::]:* users:(("test-statistic-",pid=8961,fd=3)) >elfring at Sonne:~/Projekte/Bau/C++/test-statistic-server1/local> 0 connections were handled. > > >But I wonder about the following error message then. > >elfring at Sonne:~/Projekte/Python> /usr/bin/python3 >~/Projekte/Python/socket-send_json_data.py --server_id localhost >--server_port 35529 >Using Python version: >3.7.2 ? >Traceback ?: >? > File "/home/elfring/Projekte/Python/socket-send_json_data.py", line 17, in send_data > so.connect((args.server_id, args.server_port)) >ConnectionRefusedError: [Errno 111] Connection refused > >How should this inter-process communication difficulty be resolved? It looks like the service isn't listening at the time the so.connect is called. Are you doing it before the service is ready? Otherwise you need to print out the server_id and port, and examine the system to see if that address/port is in LISTEN state. Running "netstat -an" on the system running the service is a useful way to do this. Hmm, look like your "ss" command effectively does that. I'd fall back to the connect then: check that it really is using the correct address/port. Print them out. Also, it can be very useful to strace the client process, eg: strace -e trace=network /usr/bin/python3 ~/Projekte/Python/socket-send_json_data.py --server_id localhost --server_port 35529 You can also strace the running service process: strace -e trace=network -p pid-of-service-process-here to see if it is responding in any way to the client connect. Also, on the service side it isn't enough to create the service socket, you also need to do an accept IIRC. If you're using Python's socket library the service classes do that for you. Cheers, Cameron Simpson