From beliavsky at aol.com Tue Jan 1 09:22:25 2019 From: beliavsky at aol.com (beliavsky at aol.com) Date: Tue, 1 Jan 2019 06:22:25 -0800 (PST) Subject: Python Humble Bundle from Packt Message-ID: For about the next two weeks, Humble Bundle https://www.humblebundle.com/books/python-packt-2019-books offers the following 18 books and 7 videos on Python for $15. BOOKS: Python Interviews OpenCV 3 Computer Vision with Python Cookbook Mastering Flask Web Development Python Automation Cookbook Python Machine Learning By Example Qt5 Python GUI Programming Cookbook. Python Microservices Development Hands-On Data Structures and Algorithms with Python Python High Performance Hands-On Software Engineering with Python Django 2 by Example Python Deep Learning Projects Mastering Python Networking Clean Code in Python Modern Python Cookbook Python 3 Object-Oriented Programming. Raspberry Pi 3 Cookbook for Python Programmers Django 2 Web Development Cookbook VIDEOS: Learn Python 3 from Scratch Data Visualization with Python: The Complete Guide REST APIs with Flask and Python Data Analysis with Pandas and Python Learn Python by Building a Blockchain and Cryptocurrency Python for Finance: Investment Fundamentals and Data Analytics Python For Offensive PenTest: A Complete Practical Course From siddha2305 at gmail.com Tue Jan 1 12:08:43 2019 From: siddha2305 at gmail.com (Siddha 2305) Date: Tue, 1 Jan 2019 09:08:43 -0800 (PST) Subject: mouse click automation Message-ID: <79f52528-8cfb-4613-ba99-7629322599eb@googlegroups.com> Hello All, I am trying to write a script to emulate mouse clicks. The script launches Google chrome, navigates to the website. But after that the script does not go to the specified coordinates. Also, I noticed that the screen coordinate is different every time I tried to check it. Could someone please help me fix this? PS : I am a complete beginner and this is my first attempt at this from pynput.mouse import Button, Controller import webbrowser mouse = Controller() chromedir= 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' webbrowser.get(chromedir).open("https://lnkd.in/fT4AKq8") time.sleep(30) # to let the link load mouse.position = (43, 483) # everytime I tried to check the coordinates of the pace I wanted to do a left click, it was different. mouse.click(Button.left, 1) Thank you in advance. From brian.j.oney at googlemail.com Tue Jan 1 14:06:54 2019 From: brian.j.oney at googlemail.com (Brian Oney) Date: Tue, 01 Jan 2019 20:06:54 +0100 Subject: mouse click automation In-Reply-To: <79f52528-8cfb-4613-ba99-7629322599eb@googlegroups.com> References: <79f52528-8cfb-4613-ba99-7629322599eb@googlegroups.com> Message-ID: I am unfamiliar with pynput. I have had good experience with pyautogui. As your script isn't yet advanced, you may consider it. https://pyautogui.readthedocs.io/en/latest/introduction.html From larry.martell at gmail.com Tue Jan 1 14:36:46 2019 From: larry.martell at gmail.com (Larry Martell) Date: Tue, 1 Jan 2019 14:36:46 -0500 Subject: mouse click automation In-Reply-To: <79f52528-8cfb-4613-ba99-7629322599eb@googlegroups.com> References: <79f52528-8cfb-4613-ba99-7629322599eb@googlegroups.com> Message-ID: On Tue, Jan 1, 2019 at 12:10 PM Siddha 2305 wrote: > > Hello All, > > I am trying to write a script to emulate mouse clicks. > The script launches Google chrome, navigates to the website. But after that the script does not go to the specified coordinates. > > Also, I noticed that the screen coordinate is different every time I tried to check it. > > Could someone please help me fix this? > > PS : I am a complete beginner and this is my first attempt at this > > from pynput.mouse import Button, Controller > > import webbrowser > > mouse = Controller() > > chromedir= 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' > > webbrowser.get(chromedir).open("https://lnkd.in/fT4AKq8") > > time.sleep(30) # to let the link load > > mouse.position = (43, 483) # everytime I tried to check the coordinates of the pace I wanted to do a left click, it was different. > > mouse.click(Button.left, 1) I have done this work both Selenium and Cypress. Check those out. From bill at baddogconsulting.com Tue Jan 1 16:08:37 2019 From: bill at baddogconsulting.com (Bill Deegan) Date: Tue, 1 Jan 2019 13:08:37 -0800 Subject: SCons 3.0.2 Release Message-ID: A new SCons release, 3.0.2, is now available on the SCons download page: https://scons.org/pages/download.html Here is a summary of the changes since 3.0.1: NEW FUNCTIONALITY - Properly support versioned shared libraries for MacOS. We've also introduced two new env variables APPLELINK_CURRENT_VERSION and APPLELINK_COMPATIBILITY_VERSION which will specify what is passed to the linkers -current_version and -compatibility_version flags. If not specified they will be derived from SHLIBVERSION as such: - APPLELINK_CURRENT_VERSION = SHLIBVERSION - APPLELINK_COMPATIBILITY_VERSION = all but the last digit in SHLIBVERSION with .0 appended. Note that the values of the above will be validated. Valid format for either APPLELINK variable is X[.Y[.Z]] where 0 <= X <= 65535, 0 <= Y <= 255, 0 <= Z <= 255. - Add flag must_exist to SConscript() call to fail on missing script. Not failing on missing script is now considered deprecated, and the first instance will print a deprecation message. - Add xz compression format to packaging choices. - Add Textfile/Substfile to default environment. (issue #3147) - Added virtualenv support. A new function Virtualenv() determines whether SCons runs in a virtualenv. The search PATH may also be extended to prefer executables from the current virtualenv over the ones provided by base environment. New option --enable-virtualenv provided to import some virtualenv-related variables to SCons and extend every env['ENV']['PATH'] automatically. New option --ignore-virtualenv disables this. Two environment variables, SCONS_ENABLE_VIRTUALENV and SCONS_IGNORE_VIRTUALENV are supported for the same purpose. DEPRECATED FUNCTIONALITY - Going forward calling SConscript on a non-existing SConscript file will issue a warning. Currently it will issue a deprecation notice. CHANGED/ENHANCED EXISTING FUNCTIONALITY - Recognize new java 9, 10, 11 (as 9.0 and 10.0, 11.0) FIXES - Fix issue #2980 with credit to Piotr Bartosik (and William Blevins). This is an issue where using TimeStamp-MD5 Decider and CacheDir can yield incorrect md5's being written into the .sconsign. The difference between Piotr Bartosik's patch and the current code is that the more complicated creation of file to csig map is only done when the count of children for the current node doesn't match the previous count which is loaded from the sconsign. Thanks to Bernard Blackham, William Deegan, Ray Donnelly, Andrew Featherstone, Arda Fu, Philipp Maierh?fer, Matthew Marinets, Fredrik Medley, Daniel Moody, Gary Oberbrunner, Jonathon Reinhart, Zachary Tessler, Pawe? Tomulik, Richard West, Mats Wichmann, Bernhard M. Wiedemann, and Hao Wu for their contributions to this release. Contributors are listed alphabetically by their last name. git shortlog --no-merges -ns 3.0.1..HEAD 226 William Deegan 79 Daniel Moody 72 Mats Wichmann 17 Pawe? Tomulik 16 Andrew Featherstone 8 grbd 7 maiphi 6 Gary Oberbrunner 6 Daniel 4 Hao Wu 3 Gabriel Russell 2 MatthewMarinets 2 Jonathon Reinhart 2 ArdaFu 1 Bernhard M. Wiedemann 1 Isaac Pascual Monells 1 Fredrik Medley 1 Philipp Maierhoefer 1 Piotr Kasprzyk 1 Ray Donnelly 1 Zachary Tessler 1 cclauss From pritanshsahsani at gmail.com Tue Jan 1 01:39:04 2019 From: pritanshsahsani at gmail.com (pritanshsahsani at gmail.com) Date: Mon, 31 Dec 2018 22:39:04 -0800 (PST) Subject: the python name Message-ID: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> why did you kept this name? i want to know the history behind this and the name of this snake python. From none at invalid.com Wed Jan 2 04:16:45 2019 From: none at invalid.com (mm0fmf) Date: Wed, 02 Jan 2019 09:16:45 +0000 Subject: From Ben Dean about C++ In-Reply-To: References: Message-ID: On 02/01/2019 04:29, Stefan Ram wrote: > A slide from Ben Deane's talk about C++: > > -------------------------------------------------------. > | | > | ODD THING #1: ASSIGNMENTS ARE EXPRESSIONS | > | | > | Assignment as an expression is a historical choice. | > | It's doing us no favours today. | > | Assignment should be a statement. | > | | > '-------------------------------------------------------' > > "Easy To Use, Hard to Misuse: Declarative Style In C++" (talk), > Ben Deane (2018-05) > > (Yes, he wrote "favours" in this way.) > > Probably because he speaks English and not American. From frank at chagford.com Wed Jan 2 05:11:14 2019 From: frank at chagford.com (Frank Millman) Date: Wed, 2 Jan 2019 12:11:14 +0200 Subject: the python name In-Reply-To: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> Message-ID: wrote in message news:05ff6fbc-69d5-4d3c-9073-67e774bd3c0a at googlegroups.com... > why did you kept this name? i want to know the history behind this and the > name of this snake python. I asked google the same question, and this is what it found - https://docs.python.org/3/faq/general.html#why-is-it-called-python HTH Frank Millman From xapwing at gmail.com Wed Jan 2 09:17:23 2019 From: xapwing at gmail.com (Arie van Wingerden) Date: Wed, 2 Jan 2019 06:17:23 -0800 (PST) Subject: How to display video files (mkv, wav, mp4 etc) within a TKinter widget? Message-ID: <852c770c-b80f-4d22-a8e0-6b4cb3108819@googlegroups.com> I found (mostly fairly old stuff) some questions and a lot of (apparently often not working) Python code. 1. does TKinter offer such thing out of the box? 2. or is there another way using TKinter? 3. or do I need another GUI tool (e.g. QT) for this? TIA From ben at bfoliver.com Wed Jan 2 04:50:20 2019 From: ben at bfoliver.com (Ben Oliver) Date: Wed, 2 Jan 2019 09:50:20 +0000 Subject: the python name In-Reply-To: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> Message-ID: <20190102095020.GA6954@boregenerys> On 18-12-31 22:39:04, pritanshsahsani at gmail.com wrote: >why did you kept this name? i want to know the history behind this and >the name of this snake python. It's named after Monty Python [0]. [0] https://docs.python.org/3/tutorial/appetite.html -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: not available URL: From huseyin at piramit.com.tr Wed Jan 2 07:14:23 2019 From: huseyin at piramit.com.tr (=?iso-8859-9?Q?H=FCseyin_Ertu=F0rul?=) Date: Wed, 2 Jan 2019 12:14:23 +0000 Subject: Recommendations for a novice user. Message-ID: I don't know the software language at all. What do you recommend to beginners to learn Python. What should be the working systematic? How much time should I spend every day or how much time should I spend on a daily basis. Is there any such systematic implementation and success? ?yi ?al??malar... H?seyin ERTUGRUL Teknik Servis M?d?r? Piramit Bilgisayar & Teknoloji Sis. San. Tic. Ltd. ?ti TEL: 212-480 0 660 FAX: 212-544 66 95 MOBILE: 543-328 68 15 E-MA?L: huseyin at piramit.com.tr HTTP: www.piramit.com.tr Topkap?-Maltepe cad. Canayak?n ?? Merkezi B/Blok No:11 Bayrampa?a/ ?stanbul 34030 TURKIYE P Bu dok?man? yaz?c?ya g?ndermeden ?nce l?tfen ka??t ?retimi i?in kesilen a?a?lar? bir kez daha d???n?n! From vincent.vande.vyvre at telenet.be Wed Jan 2 10:39:14 2019 From: vincent.vande.vyvre at telenet.be (Vincent Vande Vyvre) Date: Wed, 2 Jan 2019 16:39:14 +0100 Subject: How to display video files (mkv, wav, mp4 etc) within a TKinter widget? In-Reply-To: <852c770c-b80f-4d22-a8e0-6b4cb3108819@googlegroups.com> References: <852c770c-b80f-4d22-a8e0-6b4cb3108819@googlegroups.com> Message-ID: <1efbd1a6-ecc6-d6ae-4e12-0a45a8ef56b0@telenet.be> Le 2/01/19 ? 15:17, Arie van Wingerden a ?crit?: > I found (mostly fairly old stuff) some questions and a lot of (apparently often not working) Python code. > > 1. does TKinter offer such thing out of the box? > 2. or is there another way using TKinter? > 3. or do I need another GUI tool (e.g. QT) for this? > > TIA With Qt it's very easy to implement a video player. See this example: https://bazaar.launchpad.net/~vincent-vandevyvre/qarte/qarte-4/view/head:/gui/videoplayer.py It is implemented into this window: https://bazaar.launchpad.net/~vincent-vandevyvre/qarte/qarte-4/view/head:/gui/uiconcerts.py Vincent From rshepard at appl-ecosys.com Wed Jan 2 13:25:38 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 2 Jan 2019 10:25:38 -0800 (PST) Subject: Recommendations for a novice user. In-Reply-To: References: Message-ID: On Wed, 2 Jan 2019, H?seyin Ertu?rul wrote: > I don't know the software language at all. What do you recommend to > beginners to learn Python. What should be the working systematic? How much > time should I spend every day or how much time should I spend on a daily > basis. H?seyin, First, there's the World Wide Web accessible via duckduckgo.com. Search there for 'learning python' as a start. Second, go to www.python.org and look under 'getting started.' There's a link to this page: . Third, you'll find more help here when you first look for solutions yourself and report what you've done and the results. Rich From Joseph.Schachner at Teledyne.com Wed Jan 2 14:41:36 2019 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Wed, 2 Jan 2019 19:41:36 +0000 Subject: the python name In-Reply-To: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> Message-ID: Python was started in the late 1980s by Guido Van Rossum, who (until quite recently) was the Benevolent Dictator for Life of Python. His recent strong support of Type Annotation was what got it passed - and having to fight for it was what convinced him retire from the role of BDFL. Anyway, at the time, he picked the name because he liked Monty Python's Flying Circus. At least, so I have read. If you don't know what Monty Python's Flying Circus was, I recommend looking for YouTube video snippets of it. (You'll know you've found enough when you know the answer to "What's on the telly?" is "There's a penguin on the telly".) The name "Python" may not make sense, but what sense does the name Java make, or even C (unless you know that it was the successor to B), or Haskell or Pascal or even BASIC? Or Caml or Kotlin or Scratch? Or Oberon or R? Or Smalltalk, or SNOBOL? By the way, C was 50 years old in 2018. And C++ is still mostly backward compatible to C. int, float, double and char are (still) not objects. Strings and arrays are not classes (and so do not have iterators, unless you create them). Until C++ 2014, there was no threading library as part of C++ standard. Even though now there is, it's seems to be to be old school. Look at Go (language) to see how concurrency can be built into the language instead of made available for optional use. ---- Joseph S. -----Original Message----- From: pritanshsahsani at gmail.com Sent: Tuesday, January 1, 2019 1:39 AM To: python-list at python.org Subject: the python name why did you kept this name? i want to know the history behind this and the name of this snake python. From h.goebel at goebel-consult.de Wed Jan 2 14:39:22 2019 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Wed, 2 Jan 2019 20:39:22 +0100 Subject: conda/anaconda and pip3 (pip) In-Reply-To: References: Message-ID: <596264ff-2a0c-8f14-e1c0-a46059fa7f3f@goebel-consult.de> Am 03.12.18 um 18:39 schrieb Paulo da Silva: > This also has a bad side effect! It reinstalls there some depedencies > already installed in the conda created environment! > > Is there a way to avoid this situation? Try whether? `pyvenv --system-site-packages` suites you. -- Sch?nen Gru? Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: https://www.goe-con.de/blog/das-fass-ist-voll-grunde-linux-201asystemd2018-zu-meiden Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-10-aus-der-schublade-in-die-koepfe From python at mrabarnett.plus.com Wed Jan 2 14:54:35 2019 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 2 Jan 2019 19:54:35 +0000 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> Message-ID: <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> On 2019-01-02 19:41, Schachner, Joseph wrote: > Python was started in the late 1980s by Guido Van Rossum, who (until quite recently) was the Benevolent Dictator for Life of Python. His recent strong support of Type Annotation was what got it passed - and having to fight for it was what convinced him retire from the role of BDFL. Anyway, at the time, he picked the name because he liked Monty Python's Flying Circus. At least, so I have read. > [snip] It was the resistance to assignment expressions, even after his pronouncement on the matter, that lead him to retire. From rshepard at appl-ecosys.com Wed Jan 2 19:22:57 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 2 Jan 2019 16:22:57 -0800 (PST) Subject: the python name In-Reply-To: <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> Message-ID: On Wed, 2 Jan 2019, Dennis Lee Bieber wrote: > Which was a derivative of BCPL (so one could claim a successor of C > should be named P), ?, mathematician, beginners all-purpose symbolic > instruction code. R? maybe a subtle implication to be better/in-front-of > S. SNOBOL is the ugly one, since the SN come from "string", and the BO > from the middle of "symbolic". R is the open source implemention of the S statistical/data analysis language developed by Chambers at the AT&T Labs. S-Plus is the proprietary, windows-requiring implementation of S. Rich From avigross at verizon.net Wed Jan 2 20:03:04 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 2 Jan 2019 20:03:04 -0500 Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> Message-ID: <002701d4a300$1501bd30$3f053790$@verizon.net> Challenge: Can we name any computer language whose name really would suggest it was a computer language? Oh, if you say C is named as being the successor to some form of B, then R (as you mentioned) is the successor by some form of backwards reasoning to S as it started as not quite S or at least not as expensive. FWIW, T was already in use as a dialect of Scheme which was a dialect of LISP ... And I was there when we were naming C++ as a slightly improved and incremented C. Yes, D was considered as well as odd names like Add-One-To-C. Oddly C# was not considered. ? So, Ada. First female programmer, at least on paper? A Programming Language? APL. The endless list goes on. I looked at one such list below and I thought I had learned quite a few but apparently a small fraction of what was. https://en.wikipedia.org/wiki/List_of_programming_languages I think the name is the least important aspect of a computer language. -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Wednesday, January 2, 2019 7:02 PM To: python-list at python.org Subject: Re: the python name On Wed, 2 Jan 2019 19:41:36 +0000, "Schachner, Joseph" declaimed the following: >The name "Python" may not make sense, but what sense does the name Java make, or even C (unless you know that it was the successor to B), or Haskell or Pascal or even BASIC? Or Caml or Kotlin or Scratch? Or Oberon or R? Or Smalltalk, or SNOBOL? > Which was a derivative of BCPL (so one could claim a successor of C should be named P), ?, mathematician, beginners all-purpose symbolic instruction code. R? maybe a subtle implication to be better/in-front-of S. SNOBOL is the ugly one, since the SN come from "string", and the BO from the middle of "symbolic". -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- https://mail.python.org/mailman/listinfo/python-list From larry.martell at gmail.com Wed Jan 2 20:08:04 2019 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 2 Jan 2019 20:08:04 -0500 Subject: the python name In-Reply-To: <002701d4a300$1501bd30$3f053790$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> Message-ID: On Wed, Jan 2, 2019 at 8:04 PM Avi Gross wrote: > > Challenge: Can we name any computer language whose name really would suggest it was a computer language? COBOL (Common Business-Oriented Language) FORTRAN (Formula Translation) PL/1 (Programming Language 1) ALGOL (Algorithmic Language) From songbird at anthive.com Thu Jan 3 01:06:33 2019 From: songbird at anthive.com (songbird) Date: Thu, 3 Jan 2019 01:06:33 -0500 Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> Message-ID: <9cl0gf-5r5.ln1@anthive.com> Dennis Lee Bieber wrote: > On Wed, 2 Jan 2019 19:41:36 +0000, "Schachner, Joseph" > declaimed the following: > > >>The name "Python" may not make sense, but what sense does the name Java make, or even C (unless you know that it was the successor to B), or Haskell or Pascal or even BASIC? Or Caml or Kotlin or Scratch? Or Oberon or R? Or Smalltalk, or SNOBOL? >> > > Which was a derivative of BCPL (so one could claim a successor of C > should be named P), ?, mathematician, beginners all-purpose symbolic > instruction code. R? maybe a subtle implication to be better/in-front-of S. > SNOBOL is the ugly one, since the SN come from "string", and the BO from > the middle of "symbolic". i can only claim to have written one program in SNOBOL and that was over 30yrs ago... being new to Python i'm not concerned about the name of it as much as having fun in figuring out what to do with it. songbird From songbird at anthive.com Thu Jan 3 01:11:22 2019 From: songbird at anthive.com (songbird) Date: Thu, 3 Jan 2019 01:11:22 -0500 Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> Message-ID: Rick Johnson wrote: ... > Of course, no one can predict the consequences of every action. Not even GvR, in is almost infinite wisdom, and his access to a semi-dependable time machine, could predict such a tragedy of epic proportions. > > To say i'm saddened by the whole experience, would be an understatement. > > If python dies, then not only will a huge portion of my efforts be wasted on a dead language, but my heart will truly be broken. To me, Python was the "little language that could". Chugging-a-lugging up that hill and overcoming every obstacle with nothing but raw youthful enthusiasm. The underdog that you cheered for. Or the runt, being the most cute and cuddly of them all. > > If this language _can_ be saved, it certainly won't be easy. > > I'm unsure about the current leadership. And even *IF* GvR made some sort of "triumphant return", if he maintains the previous coarse, then the language is doomed. Hmm... Which means, the only path out of this mess is a total re-investment in the community; by every single person involved. if FORTRAN and COBOL aren't dead i don't see Python going away any time soon. if you want to know the perspective of a new person to the language and to help out make it better i have a few suggestions for where to spend your time in a way that will help out people a great deal. songbird From rosuav at gmail.com Thu Jan 3 01:41:36 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 3 Jan 2019 17:41:36 +1100 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> Message-ID: On Thu, Jan 3, 2019 at 5:26 PM songbird wrote: > > Rick Johnson wrote: > > [ a bunch of irrelevant drivel ] > > if FORTRAN and COBOL aren't dead i don't see Python > going away any time soon. > > if you want to know the perspective of a new person > to the language and to help out make it better i have > a few suggestions for where to spend your time in a > way that will help out people a great deal. > Don't bother replying to Ranting Rick. He's a known troll and his posts are blocked from the mailing list. ChrisA From tdldev at gmail.com Thu Jan 3 09:59:43 2019 From: tdldev at gmail.com (Jack Dangler) Date: Thu, 3 Jan 2019 09:59:43 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> Message-ID: <0697fd9f-3695-9331-fcf0-a91092465899@gmail.com> Odd that COBOL (Common Business Oriented Language)? and DIBOL (Digital Business Oriented Language) follow the paradigm, but SNOBOL went with "symBOlic"... On 1/2/19 7:22 PM, Rich Shepard wrote: > On Wed, 2 Jan 2019, Dennis Lee Bieber wrote: > >> ????Which was a derivative of BCPL (so one could claim a successor of C >> should be named P), ?, mathematician, beginners all-purpose symbolic >> instruction code. R? maybe a subtle implication to be better/in-front-of >> S. SNOBOL is the ugly one, since the SN come from "string", and the BO >> from the middle of "symbolic". > > ? R is the open source implemention of the S statistical/data analysis > language developed by Chambers at the AT&T Labs. S-Plus is the > proprietary, > windows-requiring implementation of S. > > Rich > From xapwing at gmail.com Thu Jan 3 10:57:11 2019 From: xapwing at gmail.com (Arie van Wingerden) Date: Thu, 3 Jan 2019 07:57:11 -0800 (PST) Subject: How to display video files (mkv, wav, mp4 etc) within a TKinter widget? In-Reply-To: References: <852c770c-b80f-4d22-a8e0-6b4cb3108819@googlegroups.com> <1efbd1a6-ecc6-d6ae-4e12-0a45a8ef56b0@telenet.be> Message-ID: <758b7dda-04cf-4dbb-88f6-a4560143012b@googlegroups.com> Hi, in the meantime I am trying out what I found (after my question) here: https://solarianprogrammer.com/2018/04/21/python-opencv-show-video-tkinter-window/ If that doesn't play well, I'll try your suggestion. Many thanks! Op woensdag 2 januari 2019 19:06:05 UTC+1 schreef Vincent Vande Vyvre: > Le 2/01/19 ? 15:17, Arie van Wingerden a ?crit?: > > I found (mostly fairly old stuff) some questions and a lot of (apparently often not working) Python code. > > > > 1. does TKinter offer such thing out of the box? > > 2. or is there another way using TKinter? > > 3. or do I need another GUI tool (e.g. QT) for this? > > > > TIA > > With Qt it's very easy to implement a video player. > > See this example: > > https://bazaar.launchpad.net/~vincent-vandevyvre/qarte/qarte-4/view/head:/gui/videoplayer.py > > It is implemented into this window: > > https://bazaar.launchpad.net/~vincent-vandevyvre/qarte/qarte-4/view/head:/gui/uiconcerts.py > > > Vincent From avigross at verizon.net Thu Jan 3 11:53:34 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 3 Jan 2019 11:53:34 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> Message-ID: <006d01d4a384$dd687cd0$98397670$@verizon.net> [NOTE: Not a serious post, just a response to a complaint about python as a name and computer language names in general.] On further thought, it seems that a name that reminds some people that it is a computer language would be in hexadecimal and start with 0X. But that restricts the remainder of the name to numerals plus {A,B,C,D,E,F} so something like 0XFACE or 0XDEAF or 0XFADE so how about: 0XFACADE Clearly the language is just a fa?ade behind whose face are other representations we are normally deaf to heading down towards binary. You can, of course, use the usual password tricks where zero can stand for oh, one for el and so on. That extends the words you can make. And of course some digits can expand with 2 becoming two or even to/too and 4 becoming fore. PYTHON by this weird measure is horrible as every single letter is above F. AnAC0nDA is much better. ADA works! And the cure for JAVA might be DECAF in a CAF?. Better suggestions about what a computer language name should look like are welcome. I am thinking a bit outside the box that a solution might be in a box. I am thinking of a binary matrix containing 0/1 in a 2d-pattern that spells out something or perhaps has two sections side by side where the background letters on each side are all of the same digit while the foreground using the other digit spells out itself, or perhaps the opposite. This is an ASCII message environment so I won't show a sample. Not THAT would be a name, albeit a long one. Back to seriousness. I do not understand any suggestions that the python language will go away any time soon. It will continue to evolve and sometimes that evolution may introduce incompatibilities so earlier versions may have to stop being supported. In many recent polls I keep seeing Python getting an increasing share of programs written for all kinds of purposes. Of course, there will be competition from other languages and new ones will arise. I also see no reason any one person needs to steer the evolution indefinitely. Unrestricted growth is bad but as the world advances, some growth is a good idea. Bad analogy, but snakes do tend to shed their skin periodically as they grow. -----Original Message----- From: Larry Martell Sent: Wednesday, January 2, 2019 8:08 PM To: Avi Gross Cc: Python Subject: Re: the python name On Wed, Jan 2, 2019 at 8:04 PM Avi Gross wrote: > > Challenge: Can we name any computer language whose name really would suggest it was a computer language? COBOL (Common Business-Oriented Language) FORTRAN (Formula Translation) PL/1 (Programming Language 1) ALGOL (Algorithmic Language) From mswaroop11 at gmail.com Thu Jan 3 12:51:04 2019 From: mswaroop11 at gmail.com (Swaroop Mohapatra) Date: Thu, 3 Jan 2019 09:51:04 -0800 (PST) Subject: Python Developer - Boulder,CO Message-ID: <2e0ae55a-5899-4958-a698-d5bbd325050c@googlegroups.com> Hi All, Please go through with the below JD and let me know your interest. Role: Python Developer Location: Boulder, CO Duration: Long Term Job Description: 5+ years of experience in Python programming Test automation skills ? exposure to automation framework, writing automation scripts and execution Protocols (NFS/CIFS) Linux Debugging skills SW Test cycle understanding Client - HCL Thanks, Swaroop Mohapatra Technical Recruiter, Panacea Direct Inc. Office - 201-589-5723 swaroop.mohapatra at panaceadirect.com From rosuav at gmail.com Thu Jan 3 12:00:55 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jan 2019 04:00:55 +1100 Subject: the python name In-Reply-To: <006d01d4a384$dd687cd0$98397670$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <006d01d4a384$dd687cd0$98397670$@verizon.net> Message-ID: On Fri, Jan 4, 2019 at 3:55 AM Avi Gross wrote: > Back to seriousness. I do not understand any suggestions that the python language will go away any time soon. It will continue to evolve and sometimes that evolution may introduce incompatibilities so earlier versions may have to stop being supported. In many recent polls I keep seeing Python getting an increasing share of programs written for all kinds of purposes. Of course, there will be competition from other languages and new ones will arise. I also see no reason any one person needs to steer the evolution indefinitely. Unrestricted growth is bad but as the world advances, some growth is a good idea. Bad analogy, but snakes do tend to shed their skin periodically as they grow. > Python tried to shed its skin, but I don't think the project really got anywhere, and I think it's been shelved (last commit was in March 2017). https://en.wikipedia.org/wiki/Shed_Skin https://github.com/shedskin/shedskin ChrisA From arj.python at gmail.com Thu Jan 3 14:31:21 2019 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 3 Jan 2019 23:31:21 +0400 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <006d01d4a384$dd687cd0$98397670$@verizon.net> Message-ID: i think leaving py2 is in the shed-skin process Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ Mauritius From mohan.mohta at gmail.com Thu Jan 3 14:44:07 2019 From: mohan.mohta at gmail.com (Mohan Mohta) Date: Thu, 3 Jan 2019 11:44:07 -0800 (PST) Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' Message-ID: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> Hello, I am trying to grep the keyword (which I got from report_file ) from report_file I tried multiple ways but am unable to get it to work. Below are the methods I tried. fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() g_info=subprocess.Popen('cat report_file| grep -i '+var1, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error: AttributeError: 'Popen' object has no attribute 'read' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error: AttributeError: 'Popen' object has no attribute 'read' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=os.command(cmd) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Result : The Code executes but the output is in screen and does not get stored in a variable. I am interested if I can achieve the same result with subprocess calls +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True). g_info=g_info.stdout.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error AttributeError: 'Popen' object has no attribute 'read' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd=['cat','report_file','|','grep','-i',serv_name] g_info=subprocess.Popen(cmd) g_info.wait() try : g_info=g_info.stdout.readlines() print g_info except AttributeError : pass g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Result : Nothing gets printed out ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From rosuav at gmail.com Thu Jan 3 14:49:04 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jan 2019 06:49:04 +1100 Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' In-Reply-To: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> References: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> Message-ID: On Fri, Jan 4, 2019 at 6:46 AM Mohan Mohta wrote: > > Hello, > I am trying to grep the keyword (which I got from report_file ) from report_file > > I tried multiple ways but am unable to get it to work. How about, instead, you simply open the file and iterate through it, looking for the keyword? 'grep' is irrelevant, and definitely 'cat' is a waste of effort. Python code doesn't have to be written as a less terse form of bash. ChrisA From gheskett at shentel.net Thu Jan 3 14:40:09 2019 From: gheskett at shentel.net (Gene Heskett) Date: Thu, 3 Jan 2019 14:40:09 -0500 Subject: the python name In-Reply-To: <006d01d4a384$dd687cd0$98397670$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <006d01d4a384$dd687cd0$98397670$@verizon.net> Message-ID: <201901031440.09090.gheskett@shentel.net> On Thursday 03 January 2019 11:53:34 Avi Gross wrote: > [NOTE: Not a serious post, just a response to a complaint about python > as a name and computer language names in general.] > > On further thought, it seems that a name that reminds some people that > it is a computer language would be in hexadecimal and start with 0X. > But that restricts the remainder of the name to numerals plus > {A,B,C,D,E,F} so something like 0XFACE or 0XDEAF or 0XFADE so how > about: > > 0XFACADE > > Clearly the language is just a fa?ade behind whose face are other > representations we are normally deaf to heading down towards binary. > > You can, of course, use the usual password tricks where zero can stand > for oh, one for el and so on. That extends the words you can make. And > of course some digits can expand with 2 becoming two or even to/too > and 4 becoming fore. > > PYTHON by this weird measure is horrible as every single letter is > above F. AnAC0nDA is much better. > > ADA works! > > And the cure for JAVA might be DECAF in a CAF?. > > Better suggestions about what a computer language name should look > like are welcome. I am thinking a bit outside the box that a solution > might be in a box. I am thinking of a binary matrix containing 0/1 in > a 2d-pattern that spells out something or perhaps has two sections > side by side where the background letters on each side are all of the > same digit while the foreground using the other digit spells out > itself, or perhaps the opposite. This is an ASCII message environment > so I won't show a sample. Not THAT would be a name, albeit a long one. > > Back to seriousness. I do not understand any suggestions that the > python language will go away any time soon. It will continue to evolve > and sometimes that evolution may introduce incompatibilities so > earlier versions may have to stop being supported. In many recent > polls I keep seeing Python getting an increasing share of programs > written for all kinds of purposes. Of course, there will be > competition from other languages and new ones will arise. I also see > no reason any one person needs to steer the evolution indefinitely. > Unrestricted growth is bad but as the world advances, some growth is a > good idea. Bad analogy, but snakes do tend to shed their skin > periodically as they grow. > Do I miss-remember that there was an anaconda language at sometime in the past? Not long after python made its debute? I've not see it mentioned in a decade so maybe its died? > > > > > > -----Original Message----- > From: Larry Martell > Sent: Wednesday, January 2, 2019 8:08 PM > To: Avi Gross > Cc: Python > Subject: Re: the python name > > On Wed, Jan 2, 2019 at 8:04 PM Avi Gross wrote: > > Challenge: Can we name any computer language whose name really would > > suggest it was a computer language? > > COBOL (Common Business-Oriented Language) FORTRAN (Formula > Translation) PL/1 (Programming Language 1) > ALGOL (Algorithmic Language) 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 rosuav at gmail.com Thu Jan 3 15:08:44 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jan 2019 07:08:44 +1100 Subject: the python name In-Reply-To: <201901031440.09090.gheskett@shentel.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <006d01d4a384$dd687cd0$98397670$@verizon.net> <201901031440.09090.gheskett@shentel.net> Message-ID: On Fri, Jan 4, 2019 at 7:01 AM Gene Heskett wrote: > > Do I miss-remember that there was an anaconda language at sometime in the > past? Not long after python made its debute? I've not see it mentioned > in a decade so maybe its died? Hmm, I don't know about a *language* per se. There is a *distribution* called Anaconda, aimed at data science users. It has its own package manager and a ton of easily installable packages. Personally, I don't think Anaconda is particularly important to typical users, but perhaps it's easier to say "hey, I need to use Anaconda" than "hey, I need to use Python, and numpy, and pandas, and X, and Y, and Z...", so that might give it a significant edge in certain contexts. ChrisA From grant.b.edwards at gmail.com Thu Jan 3 15:28:49 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 3 Jan 2019 20:28:49 +0000 (UTC) Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <006d01d4a384$dd687cd0$98397670$@verizon.net> <201901031440.09090.gheskett@shentel.net> Message-ID: On 2019-01-03, Gene Heskett wrote: > Do I miss-remember that there was an anaconda language at sometime in the > past? Not long after python made its debute? I've not see it mentioned > in a decade so maybe its died? About 20 years ago, the RedHat Linux (way before RHEL) installer (which was written in Python) was called Anaconda. -- Grant Edwards grant.b.edwards Yow! What UNIVERSE is this, at please?? gmail.com From David.Raymond at tomtom.com Thu Jan 3 15:34:34 2019 From: David.Raymond at tomtom.com (David Raymond) Date: Thu, 3 Jan 2019 20:34:34 +0000 Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' In-Reply-To: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> References: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> Message-ID: Agreeing with the other poster that it's probably not the best way to handle it. But for the sake of helping with subprocess: https://docs.python.org/3.7/library/subprocess.html#popen-objects Popen Objects don't have read() as the error says. That's on their .stdout and .stderr streams. So you'd want g_info.stdout.read() Or .stderr maybe, depending on what you're running and how it does its output. If you want them both to go to the same thing you can use stderr = subprocess.STDOUT instead of subprocess.PIPE, then both will end up in your .stdout stream. And while it is indeed gonna be a quick thing that you're running, you have nothing in there that makes sure your subprocess actually runs and finishes before you're trying to read the results, which will bite you on anything more complicated. -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Mohan Mohta Sent: Thursday, January 03, 2019 2:44 PM To: python-list at python.org Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' Hello, I am trying to grep the keyword (which I got from report_file ) from report_file I tried multiple ways but am unable to get it to work. Below are the methods I tried. fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() g_info=subprocess.Popen('cat report_file| grep -i '+var1, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error: AttributeError: 'Popen' object has no attribute 'read' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error: AttributeError: 'Popen' object has no attribute 'read' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=os.command(cmd) g_info=g_info.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Result : The Code executes but the output is in screen and does not get stored in a variable. I am interested if I can achieve the same result with subprocess calls +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd='cat report_file| grep -i '+var1 g_info=subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True). g_info=g_info.stdout.read() g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Error AttributeError: 'Popen' object has no attribute 'read' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fp=open(txt_file,'r') for line in fp : line=line.strip() var1=line.lower() cmd=['cat','report_file','|','grep','-i',serv_name] g_info=subprocess.Popen(cmd) g_info.wait() try : g_info=g_info.stdout.readlines() print g_info except AttributeError : pass g_info=g_info.strip() info=g_info.strip('||') print g_info print info fp.close() Result : Nothing gets printed out ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- https://mail.python.org/mailman/listinfo/python-list From mohan.mohta at gmail.com Thu Jan 3 15:32:48 2019 From: mohan.mohta at gmail.com (Mohan Mohta) Date: Thu, 3 Jan 2019 12:32:48 -0800 (PST) Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' In-Reply-To: References: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> Message-ID: <6aedf096-fe40-4cc7-9956-686d8f3e6c51@googlegroups.com> On Thursday, January 3, 2019 at 1:49:31 PM UTC-6, Chris Angelico wrote: > On Fri, Jan 4, 2019 at 6:46 AM Mohan Mohta wrote: > > > > Hello, > > I am trying to grep the keyword (which I got from report_file ) from report_file > > > > I tried multiple ways but am unable to get it to work. > > How about, instead, you simply open the file and iterate through it, > looking for the keyword? 'grep' is irrelevant, and definitely 'cat' is > a waste of effort. Python code doesn't have to be written as a less > terse form of bash. > > ChrisA I am no expert in python but I found grep is lot faster in than the methods of reading files from python.... point me to direction if you know of anything faster I would appreciate it. From rosuav at gmail.com Thu Jan 3 15:40:15 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jan 2019 07:40:15 +1100 Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' In-Reply-To: <6aedf096-fe40-4cc7-9956-686d8f3e6c51@googlegroups.com> References: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> <6aedf096-fe40-4cc7-9956-686d8f3e6c51@googlegroups.com> Message-ID: On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > I am no expert in python but I found grep is lot faster in than the methods of reading files from python.... point me to direction if you know of anything faster I would appreciate it. > Try doing things the simple and easy way in Python, then figure out if it's too slow. Only THEN should you worry about "faster". ChrisA From grant.b.edwards at gmail.com Thu Jan 3 15:41:27 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 3 Jan 2019 20:41:27 +0000 (UTC) Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <006d01d4a384$dd687cd0$98397670$@verizon.net> <201901031440.09090.gheskett@shentel.net> Message-ID: On 2019-01-03, Grant Edwards wrote: > On 2019-01-03, Gene Heskett wrote: > >> Do I miss-remember that there was an anaconda language at sometime in the >> past? Not long after python made its debute? I've not see it mentioned >> in a decade so maybe its died? > > About 20 years ago, the RedHat Linux (way before RHEL) installer > (which was written in Python) was called Anaconda. Apparently it's still called that... https://en.wikipedia.org/wiki/Anaconda_(installer) -- Grant Edwards grant.b.edwards Yow! I'm also pre-POURED at pre-MEDITATED and gmail.com pre-RAPHAELITE!! From avigross at verizon.net Thu Jan 3 19:31:18 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 3 Jan 2019 19:31:18 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <006d01d4a384$dd687cd0$98397670$@verizon.net> <201901031440.09090.gheskett@shentel.net> Message-ID: <003301d4a3c4$cf738940$6e5a9bc0$@verizon.net> Ok, this gives me a chance to say something actually python related. Why did I mention Anaconda? Because python is also the name of a snake and some people considered it appropriate to name their pet project that includes python, as the name of another snake: https://www.anaconda.com/ For people with my interests, this distribution of python is bundled with other optional components with some focus, as I see Chris mentioned, on Data Science users. I like having lots of tools available and included are many modules I would otherwise download as much of my interest is in science and statistical tools and especially on machine learning. Also thrown in is the R environment which I have been using for years as these seem to be the two major languages used by many, often both together. I am not here to evangelize but there are some other nifty tools and in particular, the Jupiter notebook allows my style of interactive programming that I was used to doing in ways through functionality in R Studio. Every language generally needs a purpose and python was designed to do many things well but initially was not equipped with data structures and methods that were designed early into R. Over the years, I have seen much convergence as python added the modules like numpy and pandas and sklearn and so on that allow much simpler manipulation than creating lists of lists of lists to hold data. R has added much, including way too many different ways to do object-oriented. I want to be able to do some of both using their strengths including both at the same time. Python has modules like rpy2 that allow a slaved R interpreter to work with programs back and forth. R has a package called reticulate that allows a different way to intersperse code using anaconda python. And, there are other ways where a third party such as a markdown processor allows both in chunks. No need to say more as it is of little interest to many. So back to the silly topic about names, just briefly. I am sure there are many other puns of sorts used in naming conventions among python users. There are seemingly endless uses of phrases from the Month Python comedies such as "shrubbery" and clearly also snake analogies. Chris one-upped me with an excellent riposte on some others making a bit of a joke about snakes shedding skin. Not clear on what python would shed when being replaced by C++ but I can live with that. As I see it, python is a very sophisticated backbone with lots of flexibility that you may need to graft arms and legs to if you want to rise above the ground level. [[Please forget I said that, whatever it means.]] -----Original Message----- From: Python-list On Behalf Of Grant Edwards Sent: Thursday, January 3, 2019 3:29 PM To: python-list at python.org Subject: Re: the python name On 2019-01-03, Gene Heskett wrote: > Do I miss-remember that there was an anaconda language at sometime in > the past? Not long after python made its debute? I've not see it > mentioned in a decade so maybe its died? About 20 years ago, the RedHat Linux (way before RHEL) installer (which was written in Python) was called Anaconda. -- Grant Edwards grant.b.edwards Yow! What UNIVERSE is this, at please?? gmail.com -- https://mail.python.org/mailman/listinfo/python-list From PythonList at danceswithmice.info Thu Jan 3 23:53:45 2019 From: PythonList at danceswithmice.info (DL Neil) Date: Fri, 4 Jan 2019 17:53:45 +1300 Subject: the python name In-Reply-To: <002701d4a300$1501bd30$3f053790$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> Message-ID: <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> On 3/01/19 2:03 PM, Avi Gross wrote: > Challenge: Can we name any computer language whose name really would suggest it was a computer language? > > I think the name is the least important aspect of a computer language. Perhaps not. If you subscribe to the wider StackOverflow Driven Design philosophy (SODD), then it would be a kindness to choose the language's name so as to be (close to) unique when entered as a search key. Thus the OP's original assumption/confusion between a programming language and a serpent; Java and a large island; right down to C, R, etc which are too short to be usable search terms in most engines. -- Regards =dn From avigross at verizon.net Fri Jan 4 01:12:42 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 4 Jan 2019 01:12:42 -0500 Subject: the python name In-Reply-To: <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> Message-ID: <002801d4a3f4$808eb1d0$81ac1570$@verizon.net> Neil, You convinced me. I meant the content and usefulness of a programming language need not be correlated strongly with the name given and especially not the shortened name it commonly goes by. But if you mean how hard is it to use a web search engine to find things, indeed. The perfect name would be something so unique nobody else would use it. By that standard, searching for R or C is a tad excruciating. The choice of other keywords can help as well as tricks like searching for [R] instead of plain R. So, yes, python also finds snakes. Guess what pandas finds? [Before anyone asks, it is not a programming language but is a part of extended python.] You start wondering if you are searching in a zoo. But I suspect a name like X69Y-22C might be a great name to search for but not very interesting. When I look at names of computer languages I see a few patterns. Some pick a name to honor Blaise PASCAL, Haskell Curry, Alan Turing or Ada Lovelace. Many are a condensation of a phrase with some computational meaning like List Processing, Algorithmic Language, Common Business Oriented language, Formula Translator? (I recall using the What For version). Programming Language 1, A Programming Language, Program Logic and so on. Some have the creator(s) names embedded, such as AWK with one letter per author. Quite a few seem to be terse enough for a single letter. Besides C, R and S, and their variants such as C++ and C# and S+, there was a D, an E and a T and a J and an M and another musical note in F# and of course the Q from its own dimension. I used to think I had studied and even used quite a few programming languages over the years but staring at these lists makes me realize I never even heard of so many of them. -----Original Message----- From: Python-list On Behalf Of DL Neil Sent: Thursday, January 3, 2019 11:54 PM To: 'Python' Subject: Re: the python name On 3/01/19 2:03 PM, Avi Gross wrote: > Challenge: Can we name any computer language whose name really would suggest it was a computer language? > > I think the name is the least important aspect of a computer language. Perhaps not. If you subscribe to the wider StackOverflow Driven Design philosophy (SODD), then it would be a kindness to choose the language's name so as to be (close to) unique when entered as a search key. Thus the OP's original assumption/confusion between a programming language and a serpent; Java and a large island; right down to C, R, etc which are too short to be usable search terms in most engines. -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list From avigross at verizon.net Fri Jan 4 01:27:17 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 4 Jan 2019 01:27:17 -0500 Subject: What can python replace? Message-ID: <002901d4a3f6$8a9b8fc0$9fd2af40$@verizon.net> All this talk about language names makes me ask what can evolved languages like python replace? I mean clearly a language like ancient BASIC which had GOTO and GOSUB verbs may not be anything worth considering. But if there was a language that broke though as a functional programming language, could it easily be replaced by a multi-purpose language like python that arguably does that well too? What about one that focused on an object-oriented approach? Note that these are just buzz words and the implementation choices are often far from the same. But I suspect there are languages with a fairly simple and narrow toolset, that could be easily translated into fairly equivalent python if you also supplied some modules/libraries that could be linked in to supply functionality and translate some protocols that differ such as wrapping a function call with arguments that are in a different order so they call properly. The above is far from easy in some ways, of course. I won?t supply my endless examples, but will say that some features are different enough like whether you short-circuit ?A or B and C? where A,B,C are arbitrary expressions with potential side effects, so a translation from another language that does not might require: resultA = A resultB = B resultC = C And now that you have forced all three to be evaluated, you can do ?resultA or result and result? where not re-evaluating some does not matter. I know there is no way to vote any languages off the team. I suspect in real life many companies, projects, etc., have already migrated to new development environments over the years. Do we know of examples that have literally migrated to python including not just new code but existing code? One interesting side to this might be part of a consideration of how a language like python can decide on changes and new features. If told that users of some language just need a few more tweaks and python would then meet their needs, is that a good reason? I really would not want to see features like GOTO restored ? From songbird at anthive.com Fri Jan 4 02:04:14 2019 From: songbird at anthive.com (songbird) Date: Fri, 4 Jan 2019 02:04:14 -0500 Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> Message-ID: Rick Johnson wrote: > songbird wrote: > ... >> if you want to know the perspective of a new person >> to the language and to help out make it better i have >> a few suggestions for where to spend your time in a >> way that will help out people a great deal. > > I'm listening... i only get so many units of time to work on something. the more rabbit holes i need to go down to figure out a basic issue the less likely progress actually happens. detecting which type of system you are on and setting up your package to install to the right location(s). after [x] years this shouldn't be too hard and fairly easy to find. ugh. add to that yet another layer for which linux distribution... double ugh. the recommended solutions are not really complete and they end up leading you down even more rabbit holes. platform, os, sys, pathlib, distro (looks like they need help). a test of any change to the setup involves an upload which may take a half hour or more to show up, by then i can be interrupted and not get back to it for days. there must be a more local way to do the same thing but as of yet the develop option doesn't seem to work how i would expect. i'm not sure what my error is. i'll have to go back and look at documents. finding out all the caches and how to verify they are either in sync or if you should clear them and how. i do have testers for Mac and Windows that can give me feedback, but only the Mac person is a techie where i don't feel like i'd have to be there in person (and also i see some indication that Mac and Linux are both Posix so perhaps nothing else needs to be done there anyways once i figure out to get the manual page installed in the right spot). since i don't have a Windows machine it will take me longer to figure that out and the few people i have for that testing are not techies so i'd want to be there when they did the install just to see how it went. songbird From iamybj at icloud.com Fri Jan 4 03:04:59 2019 From: iamybj at icloud.com (iamybj at icloud.com) Date: Fri, 4 Jan 2019 00:04:59 -0800 (PST) Subject: Type hinting of Python is just a toy ? Message-ID: I read that pep 484 type hinting of python has no effect of performance, then what?s the purpose of it? Just a toy ? Python is an old programming language, but not better than other programming languages, then what are you all dong for so many times ? Pep484 is too complex. Typle should not a seperate type, in fact it should be just a class. Like this in other programming language Python: Tuple(id: int, name: string, age: int) Other: class someClass { public int id; public string name; public int age; } Design of OOP of python is too bad, so it treat Tuple as a seperate type. Why looks different than others? afraid of cannot been watched by others? From rosuav at gmail.com Fri Jan 4 03:17:51 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jan 2019 19:17:51 +1100 Subject: Type hinting of Python is just a toy ? In-Reply-To: References: Message-ID: On Fri, Jan 4, 2019 at 7:06 PM iamybj--- via Python-list wrote: > > I read that pep 484 type hinting of python has no effect of performance, then what?s the purpose of it? Just a toy ? Yep, it's just a toy. There's absolutely no reference anywhere in the PEP to "rationale and goals", or any mention of use-cases, or anything like that. The Python core devs just felt like making the language more complicated for no reason. It definitely doesn't have anything to do with making it easier to find bugs, or giving IDEs and linters more tools to work with. > Python is an old programming language, but not better than other programming languages, then what are you all dong for so many times ? Old by what definition? Most good programming languages have been around since the 1990s or earlier. Some date back to the 70s. Fortran has its origins in the 50s. > Pep484 is too complex. Typle should not a seperate type, in fact it should be just a class. Like this in other programming language > Python: Tuple(id: int, name: string, age: int) > Other: class someClass { > public int id; > public string name; > public int age; > } In other words, you want typing to be as restrictive as it is in C++ or Java. How would you define the type "JSON-encodable"? You can encode a string, an integer, a float, an array of JSON-encodable objects, and a mapping from strings to JSON-encodable objects. Can you represent that as a class? > Design of OOP of python is too bad, so it treat Tuple as a seperate type. > > Why looks different than others? afraid of cannot been watched by others? And this is the bit where I go, yep, troll, bye bye. Except for the part where I delete your message without bothering to reply, which is probably a mistake on my part. ChrisA From ian.g.kelly at gmail.com Fri Jan 4 03:52:09 2019 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 4 Jan 2019 01:52:09 -0700 Subject: Type hinting of Python is just a toy ? In-Reply-To: References: Message-ID: On Fri, Jan 4, 2019 at 1:20 AM Chris Angelico wrote: > > Pep484 is too complex. Typle should not a seperate type, in fact it should be just a class. Like this in other programming language > > Python: Tuple(id: int, name: string, age: int) > > Other: class someClass { > > public int id; > > public string name; > > public int age; > > } > > In other words, you want typing to be as restrictive as it is in C++ > or Java. How would you define the type "JSON-encodable"? You can > encode a string, an integer, a float, an array of JSON-encodable > objects, and a mapping from strings to JSON-encodable objects. Can you > represent that as a class? I'm not sure the OP is saying that at all. It kind of sounds like he thinks that tuples are Python's version of classes, which is pretty hilarious. From rosuav at gmail.com Fri Jan 4 03:55:23 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jan 2019 19:55:23 +1100 Subject: Type hinting of Python is just a toy ? In-Reply-To: References: Message-ID: On Fri, Jan 4, 2019 at 7:54 PM Ian Kelly wrote: > > On Fri, Jan 4, 2019 at 1:20 AM Chris Angelico wrote: > > > Pep484 is too complex. Typle should not a seperate type, in fact it should be just a class. Like this in other programming language > > > Python: Tuple(id: int, name: string, age: int) > > > Other: class someClass { > > > public int id; > > > public string name; > > > public int age; > > > } > > > > In other words, you want typing to be as restrictive as it is in C++ > > or Java. How would you define the type "JSON-encodable"? You can > > encode a string, an integer, a float, an array of JSON-encodable > > objects, and a mapping from strings to JSON-encodable objects. Can you > > represent that as a class? > > I'm not sure the OP is saying that at all. It kind of sounds like he > thinks that tuples are Python's version of classes, which is pretty > hilarious. Ohhhh. And here I thought that *closures* were Python's version of C++ classes. My bad. ChrisA From iamybj at icloud.com Fri Jan 4 04:04:26 2019 From: iamybj at icloud.com (iamybj at icloud.com) Date: Fri, 4 Jan 2019 01:04:26 -0800 (PST) Subject: Type hinting of Python is just a toy ? In-Reply-To: References: Message-ID: <40f1163b-af2a-4fa1-b86f-4f6eb6b01676@googlegroups.com> In fact, there is only 3 types in all prigramming languages. Primitive type: int, string, bool, char.... Complex type: struct or class Array Type: int[10], string[100], struct[1000] These 3 type can represent all thins in the world. From hjp-python at hjp.at Fri Jan 4 04:58:28 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Fri, 4 Jan 2019 10:58:28 +0100 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> Message-ID: <20190104095828.awbiqty6ekhenz53@hjp.at> On 2019-01-04 02:04:14 -0500, songbird wrote: > Rick Johnson wrote: > > songbird wrote: > > > ... > >> if you want to know the perspective of a new person > >> to the language and to help out make it better i have > >> a few suggestions for where to spend your time in a > >> way that will help out people a great deal. > > > > I'm listening... > > i only get so many units of time to work on something. > the more rabbit holes i need to go down to figure out > a basic issue the less likely progress actually happens. > > setting > up your package to install to the right location(s). [...] > platform, os, sys, pathlib, distro (looks like they need > help). > > a test of any change to the setup involves an upload > which may take a half hour or more to show up, by then > i can be interrupted and not get back to it for days. [...] > finding out all the caches and how to verify they are > either in sync or if you should clear them and how. [...] > i do have testers for Mac and Windows that can give me > feedback, [...] Almost all of these points don't seem to be related to the language, but to your environment. > there must be a more local way to do the same thing but I do some of my Python development locally and and some remotely, but that's mostly because to me it doesn't make much difference (vim in a terminal works the same when I'm ssh'd into a server as when I work locally) and not having to replicate the environment is a plus for me. If my tools worked only locally, I could do all development locally. > as of yet the develop option doesn't seem to work how i > would expect. What is "the develop option"? Again, it seems like you are talking about a specific environment, not Python the language. 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 marco.nawijn at colosso.nl Fri Jan 4 06:10:40 2019 From: marco.nawijn at colosso.nl (marco.nawijn at colosso.nl) Date: Fri, 4 Jan 2019 03:10:40 -0800 (PST) Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' In-Reply-To: References: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> <6aedf096-fe40-4cc7-9956-686d8f3e6c51@googlegroups.com> Message-ID: On Thursday, January 3, 2019 at 9:40:43 PM UTC+1, Chris Angelico wrote: > On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > > I am no expert in python but I found grep is lot faster in than the methods of reading files from python.... point me to direction if you know of anything faster I would appreciate it. > > > > Try doing things the simple and easy way in Python, then figure out if > it's too slow. Only THEN should you worry about "faster". > > ChrisA Yeah, and once you find out you need to go faster and subsequently start looking into ways you *can* go faster, you finally end up with code similar to what is implemented in the grep family of tools. From rosuav at gmail.com Fri Jan 4 07:48:46 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jan 2019 23:48:46 +1100 Subject: Type hinting of Python is just a toy ? In-Reply-To: <40f1163b-af2a-4fa1-b86f-4f6eb6b01676@googlegroups.com> References: <40f1163b-af2a-4fa1-b86f-4f6eb6b01676@googlegroups.com> Message-ID: On Fri, Jan 4, 2019 at 8:06 PM iamybj--- via Python-list wrote: > > In fact, there is only 3 types in all prigramming languages. > Primitive type: int, string, bool, char.... > Complex type: struct or class > Array Type: int[10], string[100], struct[1000] > > These 3 type can represent all thins in the world. Why do you need three types? REXX has just one type: the string. Structures, classes, arrays, mappings, etc are all implemented with a special type of variable, the "stem". ChrisA From rosuav at gmail.com Fri Jan 4 07:52:48 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jan 2019 23:52:48 +1100 Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' In-Reply-To: References: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> <6aedf096-fe40-4cc7-9956-686d8f3e6c51@googlegroups.com> Message-ID: On Fri, Jan 4, 2019 at 10:16 PM wrote: > > On Thursday, January 3, 2019 at 9:40:43 PM UTC+1, Chris Angelico wrote: > > On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > > > I am no expert in python but I found grep is lot faster in than the methods of reading files from python.... point me to direction if you know of anything faster I would appreciate it. > > > > > > > Try doing things the simple and easy way in Python, then figure out if > > it's too slow. Only THEN should you worry about "faster". > > > > ChrisA > > Yeah, and once you find out you need to go faster and subsequently start looking into ways you *can* go faster, you finally end up with code similar to what is implemented in the grep family of tools. > Maybe... but most likely not using a subprocess. But it's still premature to worry about performance when you don't have any evidence that your code is too slow. ChrisA From joel.goldstick at gmail.com Fri Jan 4 09:04:08 2019 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Fri, 4 Jan 2019 09:04:08 -0500 Subject: Type hinting of Python is just a toy ? In-Reply-To: References: <40f1163b-af2a-4fa1-b86f-4f6eb6b01676@googlegroups.com> Message-ID: On Fri, Jan 4, 2019 at 7:50 AM Chris Angelico wrote: > > On Fri, Jan 4, 2019 at 8:06 PM iamybj--- via Python-list > wrote: > > > > In fact, there is only 3 types in all prigramming languages. > > Primitive type: int, string, bool, char.... > > Complex type: struct or class > > Array Type: int[10], string[100], struct[1000] > > > > These 3 type can represent all thins in the world. > > Why do you need three types? REXX has just one type: the string. > Structures, classes, arrays, mappings, etc are all implemented with a > special type of variable, the "stem". > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list I don't normally comment on this type of thread, but I believe the OP is showing an example of the dunning-kruger effect https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect Not teasing, really. -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From __peter__ at web.de Fri Jan 4 09:05:26 2019 From: __peter__ at web.de (Peter Otten) Date: Fri, 04 Jan 2019 15:05:26 +0100 Subject: subprocess : AttributeError: 'Popen' object has no attribute 'read' References: <4e8924ce-b137-4ca3-b149-5faadd7bfadc@googlegroups.com> Message-ID: Mohan Mohta wrote: > Hello, > I am trying to grep the keyword (which I got from report_file ) from > report_file > > I tried multiple ways but am unable to get it to work. > > Below are the methods I tried. > > > fp=open(txt_file,'r') > for line in fp : > line=line.strip() > var1=line.lower() > g_info=subprocess.Popen('cat report_file| grep -i '+var1, > stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) > g_info=g_info.read() g_info=g_info.strip() > info=g_info.strip('||') > print g_info > print info > fp.close() > Error: > AttributeError: 'Popen' object has no attribute 'read' You have to specify the stream/file, e. g. g_info.stdout.read() but when want both stdout and stderr your reading attempts may produce a deadlock as the fine manual warns. So with basic error checks: import subprocess def grep(file, wanted): p = subprocess.Popen( ["grep", "-i", wanted, file], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) stdout, stderr = p.communicate() if p.returncode: raise Exception(stderr) return stdout txt_file = "wanted.txt" report_file = "report.txt" with open(txt_file) as fp: for line in fp : wanted = line.strip().lower() print "Looking for:", wanted print "Found:" print grep(report_file, wanted) > info=g_info.strip('||') This does not do what you think it does -- it will remove all "|" chars from the beginning and the end of the string, just like g_info.strip("|") and g_info.strip("||||||||||||||||") would, i. e. the str.strip() argument is treated like a set of chars. From arj.python at gmail.com Fri Jan 4 09:11:22 2019 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 4 Jan 2019 18:11:22 +0400 Subject: Type hinting of Python is just a toy ? In-Reply-To: References: Message-ID: it will have it's uses ... for people who want to make some hacks like ... source-to-source compilers Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ Mauritius From wrw at mac.com Fri Jan 4 11:06:06 2019 From: wrw at mac.com (William Ray Wing) Date: Fri, 4 Jan 2019 11:06:06 -0500 Subject: the python name In-Reply-To: <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> Message-ID: <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> On 3/01/19 2:03 PM, Avi Gross wrote: > Challenge: Can we name any computer language whose name really would suggest it was a computer language? > I think the name is the least important aspect of a computer language. I?d like to propose that classic FORTRAN (FORmulaTRANslator) came/comes close. Bill From tjreedy at udel.edu Fri Jan 4 11:25:56 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 4 Jan 2019 11:25:56 -0500 Subject: Type hinting of Python is just a toy ? In-Reply-To: <40f1163b-af2a-4fa1-b86f-4f6eb6b01676@googlegroups.com> References: <40f1163b-af2a-4fa1-b86f-4f6eb6b01676@googlegroups.com> Message-ID: On 1/4/2019 4:04 AM, iamybj--- via Python-list wrote: > In fact, there is only 3 types in all prigramming languages. 'Category' would be a better term. Better said might be: "One can usefully group types/classes of values/objects into 3 categories." > Primitive type: int, string, bool, char.... > Complex type: struct or class > Array Type: int[10], string[100], struct[1000] And tuples are an array class, in particular an immutable and and therefore hashable array, and therefore possible members of sets and dict keys. -- Terry Jan Reedy From avigross at verizon.net Fri Jan 4 11:34:24 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 4 Jan 2019 11:34:24 -0500 Subject: the python name In-Reply-To: <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> Message-ID: <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> William, Although I used FORTRAN ages ago and it still seems to be in active use, I am not clear on why the name FORMULA TRANSLATOR was chosen. I do agree it does sound more like a computer language based on both the sound and feel of FORTRAN as well as the expanded version. It seems to have been designed as a mathematical extension of sorts that allowed you to evaluate a mathematical formula efficiently. I mean things like quadratic equations. But there is overlap with what other languages like COBOL or BASIC did at the time. What gets me is the vagueness of the words looked at by ME today. Any modern computing language can do what standard FORTRAN does, albeit perhaps more slowly as I know some languages do some of their math using libraries from FORTRAN. But do we use the word TRANSLATOR quite that way much anymore? Heck, do we use FORMULA in the same way? My most recent use of formula has been in the R language where there is a distinct object type called a formula that can be used to specify models when doing things like a regression on data. I am more likely to call the other kind using words like "equation". Python has an add-on that does symbolic manipulation. Did FORTRAN have any of these enhanced objects back when created, or even now? As I joked in an earlier message, I remember using a version of FORTRAN called WATFOR. Yes, there was a WATFIV. -----Original Message----- From: Python-list On Behalf Of William Ray Wing via Python-list Sent: Friday, January 4, 2019 11:06 AM To: Python Cc: William R. Wing Subject: Re: the python name On 3/01/19 2:03 PM, Avi Gross wrote: > Challenge: Can we name any computer language whose name really would suggest it was a computer language? > I think the name is the least important aspect of a computer language. I?d like to propose that classic FORTRAN (FORmulaTRANslator) came/comes close. Bill -- https://mail.python.org/mailman/listinfo/python-list From lorenzo.gatti at gmail.com Fri Jan 4 11:47:29 2019 From: lorenzo.gatti at gmail.com (lorenzo.gatti at gmail.com) Date: Fri, 4 Jan 2019 08:47:29 -0800 (PST) Subject: Type hinting of Python is just a toy ? In-Reply-To: References: Message-ID: On Friday, January 4, 2019 at 9:05:11 AM UTC+1, iam... at icloud.com wrote: > I read that pep 484 type hinting of python has no effect of performance, then what?s the purpose of it? Just a toy ? Having no effect on performance is a good thing; Python is already slowish, additional runtime type checking would be a problem. The purpose of type hinting is helping tools, for example ones that look for type errors in source code (e.g. a function parameter is supposed to be a string, but an integer is being passed). > > Python is an old programming language, but not better than other programming languages, then what are you all dong for so many times ? Being nice in general, and not too aggressive with trolls in particular, is also a good thing. > > Pep484 is too complex. Typle should not a seperate type, in fact it should be just a class. Like this in other programming language > Python: Tuple(id: int, name: string, age: int) > Other: class someClass { > public int id; > public string name; > public int age; > } But tuple (not Tuple) is already is a class. Are you missing the difference between declaring a type and invoking a constructor? Try to work out complete examples. > Design of OOP of python is too bad, so it treat Tuple as a seperate type. If you mean that defining classes could be replaced by uniformly using tuples, it is not the case because classes can have a lot of significant behaviour, including encapsulation. If you mean that the specific tuple class shouldn't exist and all classes should be in some way like tuple, it is not the case because many classes have to behave differently and above that tuple has special syntax support. It's about as special as the dict class and the list class, and clearly different. > Why looks different than others? afraid of cannot been watched by others? Like most programming languages, Python was deliberately designed to be different from existing programming languages in order to make an experiment (which could be summarized as interpreted, with a lot of convenient syntax in order to be brief and readable, strictly object oriented, strongly but dynamically typed) and to gain adoption (by offering an advantage to users who wouldn't bother trying a language that is only marginally different from existing ones). By all means, use other programming languages if you think they are better, but don't expect Python to change in radical ways. From feiler at uni-hohenheim.de Thu Jan 3 19:51:45 2019 From: feiler at uni-hohenheim.de (Mathias Feiler) Date: Fri, 4 Jan 2019 01:51:45 +0100 Subject: How to get rid of 3.7.2 (32-bit) in favour of 3.7.2 (64-bit) Message-ID: <385dfdb5-3f3b-fa79-4914-e04202423cca@uni-hohenheim.de> Hello, I'm as new to this mailinglist as I'm to Win10 (actually les than 24 hour). Just installed both on my new Thinkpad. Well, accidently I also just installed Python 3.7.2 (32-bit). Now I have trouble to get rid of it (in favour of the 64-bit version). I tried to "uninstall the App" more6 times now by Window :: ?settings? :: Apps :: Select "Python 3.7.2 (32-bit)" Klick Uninstall ... Admin-Password ... The "Python 3.7.2 (32-bit) Setup" sayes "Uninstall was successful" An hint me to this mailinglist if I encounter problems. Well, here I am. Thus my Question are: Does I try to uninstall the wrong way (New to Windows)? Does the Package got some pitfalls stiking back? What can I do to get rid of the "wrong" package? Thank You for Your Answer in ahead. Sincerely Mat -- Mathias Feiler - Universit?t Hohenheim Stabsstelle f?r Datenschutz Raum 04.35/-150 Schloss, ?u?erer Osthof-S?d Schwerzstra?e 46 | 70599 Stuttgart Tel. +49 711 459 23949 | Fax +49 711 459 22432 From gheskett at shentel.net Thu Jan 3 20:35:14 2019 From: gheskett at shentel.net (Gene Heskett) Date: Thu, 3 Jan 2019 20:35:14 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <201901031440.09090.gheskett@shentel.net> Message-ID: <201901032035.14940.gheskett@shentel.net> On Thursday 03 January 2019 15:28:49 Grant Edwards wrote: > On 2019-01-03, Gene Heskett wrote: > > Do I miss-remember that there was an anaconda language at sometime > > in the past? Not long after python made its debute? I've not see it > > mentioned in a decade so maybe its died? > > About 20 years ago, the RedHat Linux (way before RHEL) installer > (which was written in Python) was called Anaconda. > > -- > Grant Edwards grant.b.edwards Yow! What UNIVERSE > is this, at please?? > gmail.com Thanks for rescuing my old wet ram Grant, thats exactly what I was thinking of. AIR, it wasn't anywhere near a "real installer" and I spent a decent amount of time turning perfectly good air blue. Have a fine 2019 Grant, and thanks again. 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 iamybj at icloud.com Fri Jan 4 03:26:26 2019 From: iamybj at icloud.com (iamybj at icloud.com) Date: Fri, 4 Jan 2019 00:26:26 -0800 (PST) Subject: Type hinting of Python is just a toy ? In-Reply-To: References: Message-ID: <3645fdec-040a-45b8-a9f7-039c5fcb3032@googlegroups.com> { id: 1, name:?abc?, age:99, address:{province:?CA?, city:?SA?}} Can be represent by: Class Address { public string province; public string city; } Class Person { public int id; public string name; public int age; public Address address; } From songbird at anthive.com Fri Jan 4 02:17:19 2019 From: songbird at anthive.com (songbird) Date: Fri, 4 Jan 2019 02:17:19 -0500 Subject: What can python replace? References: <002901d4a3f6$8a9b8fc0$9fd2af40$@verizon.net> Message-ID: Avi Gross wrote: ... this is really a computation theory question and for the most part you'll find that all languages of suitable power can replace each other. arguably some languages seem more expressive or easier to read than others. but the most popular languages will often have translators for other languages as a part of their larger ecosystem. songbird From hjp-python at hjp.at Fri Jan 4 12:45:03 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Fri, 4 Jan 2019 18:45:03 +0100 Subject: the python name In-Reply-To: <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> Message-ID: <20190104174503.xqypyeuihftyyogv@hjp.at> On 2019-01-04 11:34:24 -0500, Avi Gross wrote: > Although I used FORTRAN ages ago and it still seems to be in active > use, I am not clear on why the name FORMULA TRANSLATOR was chosen. Keep in mind that FORTRAN was one of the very first languages which didn't have a 1:1 mapping to machine code. A programmer could actually write a formula (instead of a sequence of machine instructions), and the compiler would translate it into machine code. So I guess "formula translator" was an apt description of what was seen as the main benefit over earlier systems. > I do agree it does sound more like a computer language based on both > the sound and feel of FORTRAN as well as the expanded version. FORTRAN is older than most of us. So it influenced what we think a computer language should sound like. > It seems to have been designed as a mathematical extension of sorts > that allowed you to evaluate a mathematical formula efficiently. I > mean things like quadratic equations. But there is overlap with what > other languages like COBOL or BASIC did at the time. Both COBOL and BASIC were invented after FORTRAN. And I'm not sure whether COBOL's COMPUTE statement was in the language from the beginning or a later addition. > > What gets me is the vagueness of the words looked at by ME today. Any > modern computing language can do what standard FORTRAN does, The shoulders of giants and all that. > albeit perhaps more slowly as I know some languages do some of their > math using libraries from FORTRAN. But do we use the word TRANSLATOR > quite that way much anymore? No. Today we use the word "compiler". Jargon has evolved. > Heck, do we use FORMULA in the same way? Probably yes, but we don't think automatically translating formulas into machine code is in any way remarkable any more. After all, that problem was solved 60+ years ago. Today's buzzword is "algorithm" (usually used incorrectly by the media). > My most recent use of formula has been in the R language where there > is a distinct object type called a formula that can be used to specify > models when doing things like a regression on data. I am more likely > to call the other kind using words like "equation". Python has an > add-on that does symbolic manipulation. Did FORTRAN have any of these > enhanced objects back when created, or even now? Certainly not then. Probably not now. Fortran isn't about symbolic manipulation. It's about number crunching. And in the beginning it was mostly about not having to write assembler. 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 rosuav at gmail.com Fri Jan 4 12:58:13 2019 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Jan 2019 04:58:13 +1100 Subject: Type hinting of Python is just a toy ? In-Reply-To: <3645fdec-040a-45b8-a9f7-039c5fcb3032@googlegroups.com> References: <3645fdec-040a-45b8-a9f7-039c5fcb3032@googlegroups.com> Message-ID: On Sat, Jan 5, 2019 at 4:43 AM iamybj--- via Python-list wrote: > > { id: 1, name:?abc?, age:99, address:{province:?CA?, city:?SA?}} > > Can be represent by: > > Class Address { > public string province; > public string city; > } > > Class Person { > public int id; > public string name; > public int age; > public Address address; > } http://wiki.c2.com/?BlubParadox ChrisA From ian.g.kelly at gmail.com Fri Jan 4 13:06:14 2019 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 4 Jan 2019 11:06:14 -0700 Subject: Type hinting of Python is just a toy ? In-Reply-To: <3645fdec-040a-45b8-a9f7-039c5fcb3032@googlegroups.com> References: <3645fdec-040a-45b8-a9f7-039c5fcb3032@googlegroups.com> Message-ID: On Fri, Jan 4, 2019 at 10:44 AM iamybj--- via Python-list wrote: > > { id: 1, name:?abc?, age:99, address:{province:?CA?, city:?SA?}} Those are nested dicts, not tuples, which leaves your argument really unclear. A dict is essentially a hash map. Java and C# (it's unclear what language you're comparing to, but it looks like one of those) also have hash maps. So why are you complaining that Python has hash maps by comparing it to a language that also has hash maps? From ian.g.kelly at gmail.com Fri Jan 4 13:22:03 2019 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 4 Jan 2019 11:22:03 -0700 Subject: the python name In-Reply-To: <8e7v2ep322pv5a54e2j3u2k4ehig8auq3s@4ax.com> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <002801d4a3f4$808eb1d0$81ac1570$@verizon.net> <8e7v2ep322pv5a54e2j3u2k4ehig8auq3s@4ax.com> Message-ID: On Fri, Jan 4, 2019 at 10:59 AM Dennis Lee Bieber wrote: > > On Fri, 4 Jan 2019 01:12:42 -0500, "Avi Gross" > declaimed the following: > > > >language, Formula Translator? (I recall using the What For version). > > WATFOR => WATerloo FORtran And then there was WATFIV, which stands for WATerloo Fortran IV. Because 5 == IV. From wrw at mac.com Fri Jan 4 14:11:55 2019 From: wrw at mac.com (William Ray Wing) Date: Fri, 4 Jan 2019 14:11:55 -0500 Subject: the python name In-Reply-To: <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> Message-ID: > On Jan 4, 2019, at 11:34 AM, Avi Gross wrote: > > [BYTE] > As I joked in an earlier message, I remember using a version of FORTRAN called WATFOR. Yes, there was a WATFIV. > > Yah - WATFOR was Waterloo FORTRAN, an interpreted FORTRAN that was used a lot in intro classes. No matter what the student did (negative indexes in early FORTRAN would get you down into the OS), under WATFOR the mainframe (yup) wouldn?t crash. Bill PS: I, for one will drop this now as it is getting further off topic. From songbird at anthive.com Fri Jan 4 12:56:56 2019 From: songbird at anthive.com (songbird) Date: Fri, 4 Jan 2019 12:56:56 -0500 Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> <20190104095828.awbiqty6ekhenz53@hjp.at> Message-ID: <8cj4gf-2ai.ln1@anthive.com> Peter J. Holzer wrote: > songbird wrote: hi, thank you for your reply. ... > Almost all of these points don't seem to be related to the language, but > to your environment. an application isn't useful unless it actually can be deployed and used in an environment. the easier it is for me to stay within the language itself using whatever modules and features it provides. and more the the better because every time i have to go outside to investigate or debug other things that adds complexity and more points of failure and more issues that get in the way of me actually working on the program (it also interferes with my goals if i'm having to deal with beaurocracy issues instead of fixing bugs or learning Python better). at least these make sense: https://packaging.python.org/tutorials/installing-packages/ https://docs.python.org/3/installing/index.html#installing-index and this helps answer a lot of my questions that have been hovering around: https://pip.pypa.io/en/stable/reference/pip_install/#caching >> there must be a more local way to do the same thing but=20 > > I do some of my Python development locally and and some remotely, but > that's mostly because to me it doesn't make much difference (vim in a > terminal works the same when I'm ssh'd into a server as when I work > locally) and not having to replicate the environment is a plus for me. > If my tools worked only locally, I could do all development locally. i'm always working on my local machine first and foremost. i always need a quick method for testing the whole chain from code to install and running tests that doesn't involve a large turn around in time. as an example, the program hugo which lets me generate a static web site. it is great that i can do all of my local development and testing without having to upload it to the web server and then when i finally do upload it and test it out it almost always works the same way and there isn't a half hour delay between me finding out something didn't work. >> as of yet the develop option doesn't seem to work how i >> would expect. > > What is "the develop option"? Again, it seems like you are talking about > a specific environment, not Python the language. i hope my comments above are sufficient to get my points across about "environment". i use this command to put my project into a local virtual environment: (env)$ pip3 install -e $NGFP_SRC_HOME/ --no-cache-dir --force-reinstall where: -e,--editable Install a project in editable mode (i.e. setuptools "develop mode") from a local project path or a VCS url. it doesn't seem to work how i expect, but that could be my own bug someplace. haven't tracked it down yet. i'm also trying to get back more to what my initial goals were with this project (to learn the language and to learn OOP concepts better). when i can get back to the code itself and whack it into better shape then i'll feel a lot better. i admit it is a mess now. songbird From p_s_d_a_s_i_l_v_a_ns at netcabo.pt Fri Jan 4 13:06:25 2019 From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva) Date: Fri, 4 Jan 2019 18:06:25 +0000 Subject: conda/anaconda and pip3 (pip) References: <0de9498f-0cc9-46bc-867c-0cecdd7ad0b0@googlegroups.com> Message-ID: ?s 19:54 de 09/12/18, Tim Williams escreveu: > On Saturday, December 8, 2018 at 10:13:14 PM UTC-5, Monte Milanuk wrote: >> Did you find any solution(s)? > > I usually just lurk and read on this list. I don't reply since there's usually more competent people that regularly post helpful answers. (I lurk to learn from them!) > > If no one's replied yet, I'll give it my 2 cents ... > > Without being a pip expert, I see from 'pip install -h' that you can specify where you want the package to be installed. > > Install Options: ... > path or a VCS url. > -t, --target Install packages into . By default this will not replace existing files/folders in > . Use --upgrade to replace existing packages in with new versions. ... > > I'm thinking the the --target option may be the solution. > I don't think this is a solution. It seems that there is no really solutions at all. (ana)conda has its own dependencies management. Playing with pip just seems to cause dependencies problems, eventually. So far, I have not found any problems, probably because the newer modules are backwards compatible. Thanks for responding. From p_s_d_a_s_i_l_v_a_ns at netcabo.pt Fri Jan 4 13:13:35 2019 From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva) Date: Fri, 4 Jan 2019 18:13:35 +0000 Subject: conda/anaconda and pip3 (pip) References: <596264ff-2a0c-8f14-e1c0-a46059fa7f3f@goebel-consult.de> Message-ID: ?s 19:39 de 02/01/19, Hartmut Goebel escreveu: > Am 03.12.18 um 18:39 schrieb Paulo da Silva: >> This also has a bad side effect! It reinstalls there some depedencies >> already installed in the conda created environment! >> >> Is there a way to avoid this situation? > > Try whether? `pyvenv --system-site-packages` suites you. > I need to use conda for this. I need anaconda because it has all stuff to work with GPUs. Otherwise I'd need to install lots of SW. One package, for example, requires registration at Nvidia. It also difficult to determine a common base of compatible versions. Thanks for responding. From gheskett at shentel.net Fri Jan 4 16:19:46 2019 From: gheskett at shentel.net (Gene Heskett) Date: Fri, 4 Jan 2019 16:19:46 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <8e7v2ep322pv5a54e2j3u2k4ehig8auq3s@4ax.com> Message-ID: <201901041619.46643.gheskett@shentel.net> On Friday 04 January 2019 13:22:03 Ian Kelly wrote: > On Fri, Jan 4, 2019 at 10:59 AM Dennis Lee Bieber wrote: > > On Fri, 4 Jan 2019 01:12:42 -0500, "Avi Gross" > > > > > > declaimed the following: > > >language, Formula Translator? (I recall using the What For > > > version). > > > > WATFOR => WATerloo FORtran > > And then there was WATFIV, which stands for WATerloo Fortran IV. > Because 5 == IV. Not what I was taught 75 years ago. Thats a brand new definition of fuzzy logic. :( 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 rosuav at gmail.com Fri Jan 4 16:37:49 2019 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Jan 2019 08:37:49 +1100 Subject: the python name In-Reply-To: <201901041619.46643.gheskett@shentel.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <8e7v2ep322pv5a54e2j3u2k4ehig8auq3s@4ax.com> <201901041619.46643.gheskett@shentel.net> Message-ID: On Sat, Jan 5, 2019 at 8:31 AM Gene Heskett wrote: > > On Friday 04 January 2019 13:22:03 Ian Kelly wrote: > > And then there was WATFIV, which stands for WATerloo Fortran IV. > > Because 5 == IV. > > Not what I was taught 75 years ago. Thats a brand new definition of fuzzy > logic. :( Maybe it's different if you went to an IV league school? ChrisA From avigross at verizon.net Fri Jan 4 17:40:11 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 4 Jan 2019 17:40:11 -0500 Subject: Type hinting of Python is just a toy ? In-Reply-To: References: <40f1163b-af2a-4fa1-b86f-4f6eb6b01676@googlegroups.com> Message-ID: <004b01d4a47e$74251990$5c6f4cb0$@verizon.net> You can play mathematical reduction games and declare the only type of variable needed is a memory location but who cares? The reality is that well designed data structure can allow you to think about a problem in a way that leads to easy solutions. True, you can store something like an employee record with N fields in an amazing number of ways. It can be a simple or nested list construct, or an instance of some class or a dictionary, perhaps nested, or it can be a newly minted object like a NamedTuple or it can even be stored in N unrelated variables. But some representations appeal to some people and some perhaps to others and some depend on the situation. There tends to be room for multiple ways. Anyone ever use a version of LISP where the dominant or even only data structure was nested lists. I shudder at memories of having to use weird functions like CAADDR which effectively did the equivalent of multiple instances of CAR and CDR to dig deeply into such a mess. Why would anyone want to use that representation on a regular basis. Python thought it had all the primitive data types in the base. What more do you need than strings, numbers, and several variants on a list? Throw in dictionaries, and clearly you can write anything? Heck, throw in classes/objects and you can make anything else? Well, it seems that over the years people have felt the need to make so much more and then set it aside for reuse. I use what amounts to a restricted list all the time. A numpy array forces all entries to be of the same type. Not necessarily pythonic but when you are used to a language where there is no simpler data type consisting of a single int or a single character and everything is of indefinite length so the above is just a vector of length 1, you start wanting that to represent things like columns of data. When you are used to something that is a 2D representation, you may want something like a matrix or DataFrame and so on. True, these can be built easily using 1D components in a list along with algorithms on how to calculate where the nth item will be stored. But to program more the way you think and be able to ignore lower-level details, more is needed. And, in the same vein, you may want to add a layer of logic or restrictions around those basic types such as requiring them to be non-negative. You may want to handle a concept like infinity which simply cannot be an aspect in a truly primitive type. It takes some Gaul to say all variables can be divided into three parts (just kidding.) Of course having too many choices can freeze new learners and old ones alike. Research on human psychology shows that people in a 401K plan or IRA (several of many U.S. tax-advantaged plans) that offers too many choices often results in people making no choice (getting a low interest account by default perhaps) or putting a small amount I MANY of them since they have no idea what makes sense and have trouble with decisions. But any good programming language needs a decent number of choices. Arguments that a tuple is just a restricted list so why do you need it are more reductionist than practical. There are quite a few reasons to have both and repercussions of your choice. -----Original Message----- From: Python-list On Behalf Of Joel Goldstick Sent: Friday, January 4, 2019 9:04 AM Cc: Python Subject: Re: Type hinting of Python is just a toy ? On Fri, Jan 4, 2019 at 7:50 AM Chris Angelico wrote: > > On Fri, Jan 4, 2019 at 8:06 PM iamybj--- via Python-list > wrote: > > > > In fact, there is only 3 types in all prigramming languages. > > Primitive type: int, string, bool, char.... > > Complex type: struct or class > > Array Type: int[10], string[100], struct[1000] > > > > These 3 type can represent all thins in the world. > > Why do you need three types? REXX has just one type: the string. > Structures, classes, arrays, mappings, etc are all implemented with a > special type of variable, the "stem". > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list I don't normally comment on this type of thread, but I believe the OP is showing an example of the dunning-kruger effect https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect Not teasing, really. -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays -- https://mail.python.org/mailman/listinfo/python-list From songbird at anthive.com Fri Jan 4 17:32:20 2019 From: songbird at anthive.com (songbird) Date: Fri, 4 Jan 2019 17:32:20 -0500 Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> <1ef18a03-4609-493c-bafa-8272ba540058@googlegroups.com> Message-ID: Rick Johnson wrote: ... > You're singing a sad tune songbird, but i feel your pain... like all things, this too shall pass... :) songbird From gheskett at shentel.net Fri Jan 4 17:41:36 2019 From: gheskett at shentel.net (Gene Heskett) Date: Fri, 4 Jan 2019 17:41:36 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <201901041619.46643.gheskett@shentel.net> Message-ID: <201901041741.36395.gheskett@shentel.net> On Friday 04 January 2019 16:37:49 Chris Angelico wrote: > On Sat, Jan 5, 2019 at 8:31 AM Gene Heskett wrote: > > On Friday 04 January 2019 13:22:03 Ian Kelly wrote: > > > And then there was WATFIV, which stands for WATerloo Fortran IV. > > > Because 5 == IV. > > > > Not what I was taught 75 years ago. Thats a brand new definition of > > fuzzy logic. :( > > Maybe it's different if you went to an IV league school? Dunno Chris, but I'd swear that was morning glory's blooming on the fences surrounding that rural schoolhouse, rubble and mortered walls about 3 feet thick, as long as we had coal for the warm morning stove, we were fine. Its sans roof now as it was thatched then, but that building still stands with well over 100 years worth of Iowa winters on its log now. Near a ghost town called Pitzer in Madison County IA. Yeah, the subject of the Eastwood and Streep movie called The Bridges of Madison County. Many of them covered, been over most of them as a 5 year old. And I remember the evening of Dec 7th, 1941. Listening to the news on a battery radio, and watching my grandfather crying because he knew lots of men would give their all before the as yet undeclared war was over. There was never any doubt that we would win it, but for the city folks, hard times were ahead with the rationing. Lots of fat folks got in shape by 1945-46 whether they wanted to or not. Out on a farm, with a good team of horses, we were somehat insulated from the hardships of the war as we raised our own food. But I remember it well. > > ChrisA Cheers, Gene Heskett -- From avigross at verizon.net Fri Jan 4 18:55:00 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 4 Jan 2019 18:55:00 -0500 Subject: the python name In-Reply-To: <201901041619.46643.gheskett@shentel.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <8e7v2ep322pv5a54e2j3u2k4ehig8auq3s@4ax.com> <201901041619.46643.gheskett@shentel.net> Message-ID: <007801d4a488$e7e46700$b7ad3500$@verizon.net> Gene, It is simple in Python: if "IV" in "FIVE": print("Roman 4 is 5!") prints: Roman 4 is 5! Just a stupid coincidence that the spelling in current English for the numeral Five happens to have the silly one-less than 5 notation of the Roman numerals IV. Maybe someone with my perverted sense of humor found it amusing to change the nomenclature so WAT remains the same in WATFOR and in WATFIV but they did not retain the FOR and make WATFORIV which might be harder to pronounce. Now if they had named the language pithon or python instead of python, we might be having marathon sessions evaluating digits of pi or eating dessert. Time to stop posting before ... -----Original Message----- From: Python-list On Behalf Of Gene Heskett Sent: Friday, January 4, 2019 4:20 PM To: python-list at python.org Subject: Re: the python name On Friday 04 January 2019 13:22:03 Ian Kelly wrote: > On Fri, Jan 4, 2019 at 10:59 AM Dennis Lee Bieber wrote: > > On Fri, 4 Jan 2019 01:12:42 -0500, "Avi Gross" > > > > > > declaimed the following: > > >language, Formula Translator? (I recall using the What For > > >version). > > > > WATFOR => WATerloo FORtran > > And then there was WATFIV, which stands for WATerloo Fortran IV. > Because 5 == IV. Not what I was taught 75 years ago. Thats a brand new definition of fuzzy logic. :( 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 -- https://mail.python.org/mailman/listinfo/python-list From avigross at verizon.net Fri Jan 4 19:18:46 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 4 Jan 2019 19:18:46 -0500 Subject: the python name In-Reply-To: <007801d4a488$e7e46700$b7ad3500$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <8e7v2ep322pv5a54e2j3u2k4ehig8auq3s@4ax.com> <201901041619.46643.gheskett@shentel.net> <007801d4a488$e7e46700$b7ad3500$@verizon.net> Message-ID: <009701d4a48c$39abbcc0$ad033640$@verizon.net> Oops. They autocorrected the word piethon below so it makes no sense. I meant a pie-eating-marathon or whatever. -----Original Message----- From: Python-list On Behalf Of Avi Gross Sent: Friday, January 4, 2019 6:55 PM To: python-list at python.org Subject: RE: the python name Gene, It is simple in Python: if "IV" in "FIVE": print("Roman 4 is 5!") prints: Roman 4 is 5! Just a stupid coincidence that the spelling in current English for the numeral Five happens to have the silly one-less than 5 notation of the Roman numerals IV. Maybe someone with my perverted sense of humor found it amusing to change the nomenclature so WAT remains the same in WATFOR and in WATFIV but they did not retain the FOR and make WATFORIV which might be harder to pronounce. Now if they had named the language pithon or python instead of python, we might be having marathon sessions evaluating digits of pi or eating dessert. Time to stop posting before ... -----Original Message----- From: Python-list On Behalf Of Gene Heskett Sent: Friday, January 4, 2019 4:20 PM To: python-list at python.org Subject: Re: the python name On Friday 04 January 2019 13:22:03 Ian Kelly wrote: > On Fri, Jan 4, 2019 at 10:59 AM Dennis Lee Bieber wrote: > > On Fri, 4 Jan 2019 01:12:42 -0500, "Avi Gross" > > > > > > declaimed the following: > > >language, Formula Translator? (I recall using the What For > > >version). > > > > WATFOR => WATerloo FORtran > > And then there was WATFIV, which stands for WATerloo Fortran IV. > Because 5 == IV. Not what I was taught 75 years ago. Thats a brand new definition of fuzzy logic. :( 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 -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list From torriem at gmail.com Fri Jan 4 20:27:44 2019 From: torriem at gmail.com (Michael Torrie) Date: Fri, 4 Jan 2019 18:27:44 -0700 Subject: the python name In-Reply-To: <201901032035.14940.gheskett@shentel.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <201901031440.09090.gheskett@shentel.net> <201901032035.14940.gheskett@shentel.net> Message-ID: On 01/03/2019 06:35 PM, Gene Heskett wrote: > On Thursday 03 January 2019 15:28:49 Grant Edwards wrote: >> About 20 years ago, the RedHat Linux (way before RHEL) installer >> (which was written in Python) was called Anaconda. > Thanks for rescuing my old wet ram Grant, thats exactly what I was > thinking of. AIR, it wasn't anywhere near a "real installer" and I spent > a decent amount of time turning perfectly good air blue. On the other hand I never had any troubles with it, nor have I had any problems with it recently. Not sure what you mean about it not being anywhere near a "real installer." The non-linear redesign that came out a few years ago really threw me, and I still don't like it. From avigross at verizon.net Fri Jan 4 22:59:40 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 4 Jan 2019 22:59:40 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> Message-ID: <00d701d4a4ab$15c4f820$414ee860$@verizon.net> I don't go back to the beginning of FORTRAN. My comment was not that FORTRAN was badly named when it was among the first to do such things. I am saying that in retrospect, almost any language can do a basic subset of arithmetic operations. And there is nothing in principle that necessarily stops any modern language code from being optimized by translators to be even more rapid than the original versions of FORTRAN. If anything, I can well imagine algorithms using parallel architectures from performing some operations way faster. True, many languages tend to add overhead but that is not necessarily required. As some have said here, many things these days are fast enough not to need ultimate optimization. Having said that, there is no reason why code used over and over should not be optimized. Functions in higher-level languages can be written using the language and then can be replaced if there is a great enough improvement and they do not need some of the interactive features the language might offer. Someone mentioned that in principle all data types can be stored in a string. Python does have a concept of converting many, but not all data structures into a byte form that can be written to files and restored or sent to other processes including on other machines. Of course entire programs written in text can be shipped this way to some extent. But when your data is a long list of real numbers that you want to find the standard deviation of, then converting it into a compact C/C++ array (or something similar in Fortran) and calling a function in that language that works fast on that, may be a good way to go. Why interpret a step at a time when one pass generates the data that can be processed in tighter loops and a result returned? -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Friday, January 4, 2019 1:17 PM To: python-list at python.org Subject: Re: the python name On Fri, 4 Jan 2019 11:34:24 -0500, "Avi Gross" declaimed the following: > >Although I used FORTRAN ages ago and it still seems to be in active use, I am not clear on why the name FORMULA TRANSLATOR was chosen. I do agree it does sound more like a computer language based on both the sound and feel of FORTRAN as well as the expanded version. > >It seems to have been designed as a mathematical extension of sorts that allowed you to evaluate a mathematical formula efficiently. I mean things like quadratic equations. But there is overlap with what other languages like COBOL or BASIC did at the time. > FORTRAN predates BASIC by a decade. COBOL was never meant to be an in-depth number cruncher language (original data type is packed BCD). Writing a quadratic equation in it probably takes two or three pages (as I recall, the COMPUTE verb was a later addition, so everything would have been long sentences: DIVIDE C BY B GIVING TMP1. MULTIPLY TMP1 BY 2. SUBTRACT TMP1 FROM A GIVING RESULT1. ADD TMP1 TO A GIVING RESULT2. vs COMPUTE TMP1 = (C / B) * 2. COMPUTE RESULT1 = A - TMP1. COMPUTE RESULT2 = A + TMP1. ) >What gets me is the vagueness of the words looked at by ME today. Any modern computing language can do what standard FORTRAN does, albeit perhaps more slowly as I know some languages do some of their math using libraries from FORTRAN. But do we use the word TRANSLATOR quite that way much anymore? Heck, do we use FORMULA in the same way? Meanings change... "COMPUTER" means "one who computes" -- those poor overworked engineers with slide-rules creating ballistic tables for battleships. "Translator" still applies -- in the sense of taking one language (source) and producing the equivalent meaning in another language (assembler, and then translating that to pure machine binary). "Formula" has likely been superceded by "algorithm" (cf ALGOL) > >My most recent use of formula has been in the R language where there is a distinct object type called a formula that can be used to specify models when doing things like a regression on data. I am more likely to call the other kind using words like "equation". Python has an add-on that does symbolic manipulation. Did FORTRAN have any of these enhanced objects back when created, or even now? No body had symbolic manipulation when FORTRAN was created. At the time, the goal was to produce a higher order language that the scientists could write without having to /know/ the computer assembly/machine code, with the hope that it could be portable at the source level. Users were charged by the minute for CPU time, and operating systems were lucky to be able to handle more than one program in parallel. Batch systems were the norm -- where a program would run until it either finished, or it ran out of CPU time (as specified on a LIMIT in the job control deck). One would turn in a deck of cards to be spooled in the job queue, and come back some hours later to get the printout from the job. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- https://mail.python.org/mailman/listinfo/python-list From gheskett at shentel.net Fri Jan 4 23:50:52 2019 From: gheskett at shentel.net (Gene Heskett) Date: Fri, 4 Jan 2019 23:50:52 -0500 Subject: the python name In-Reply-To: <009701d4a48c$39abbcc0$ad033640$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <007801d4a488$e7e46700$b7ad3500$@verizon.net> <009701d4a48c$39abbcc0$ad033640$@verizon.net> Message-ID: <201901042350.52794.gheskett@shentel.net> On Friday 04 January 2019 19:18:46 Avi Gross wrote: > Oops. They autocorrected the word piethon below so it makes no sense. > I meant a pie-eating-marathon or whatever. > I did wonder about that, damn the spiel chucker's anyway. > -----Original Message----- > From: Python-list > On Behalf Of Avi > Gross > Sent: Friday, January 4, 2019 6:55 PM > To: python-list at python.org > Subject: RE: the python name > > Gene, > > It is simple in Python: > > if "IV" in "FIVE": > print("Roman 4 is 5!") > > prints: > > Roman 4 is 5! > > Just a stupid coincidence that the spelling in current English for the > numeral Five happens to have the silly one-less than 5 notation of the > Roman numerals IV. > > Maybe someone with my perverted sense of humor found it amusing to > change the nomenclature so WAT remains the same in WATFOR and in > WATFIV but they did not retain the FOR and make WATFORIV which might > be harder to pronounce. > > Now if they had named the language pithon or python instead of python, > we might be having marathon sessions evaluating digits of pi or eating > dessert. > > Time to stop posting before ... > > -----Original Message----- > From: Python-list > On Behalf Of > Gene Heskett > Sent: Friday, January 4, 2019 4:20 PM > To: python-list at python.org > Subject: Re: the python name > > On Friday 04 January 2019 13:22:03 Ian Kelly wrote: > > On Fri, Jan 4, 2019 at 10:59 AM Dennis Lee Bieber > > wrote: > > > On Fri, 4 Jan 2019 01:12:42 -0500, "Avi Gross" > > > > > > > > > declaimed the following: > > > >language, Formula Translator? (I recall using the What For > > > >version). > > > > > > WATFOR => WATerloo FORtran > > > > And then there was WATFIV, which stands for WATerloo Fortran IV. > > Because 5 == IV. > > Not what I was taught 75 years ago. Thats a brand new definition of > fuzzy logic. :( > > 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 > -- > https://mail.python.org/mailman/listinfo/python-list > > -- > https://mail.python.org/mailman/listinfo/python-list Cheers, Gene Heskett -- From bhagvanarch at gmail.com Sat Jan 5 06:20:50 2019 From: bhagvanarch at gmail.com (Bhagvan Kommadi) Date: Sat, 5 Jan 2019 03:20:50 -0800 (PST) Subject: Hands-On Quantum Computing with Python Message-ID: <6fbe8e81-22d9-49c2-bd75-a7be7dd8b06f@googlegroups.com> I am coauthoring a packt book : Hands-On Quantum Computing with Python. The book will be published around Aug 2019 The book will introduce quantum computing and a comprehensive overview of the quantum programming languages currently available, such as QCL, QASM, QUIL, and the differences between them. It will have examples and teach the reader how to write popular quantum algorithms in some of these languages, such as Grover?s search and Shor?s factorization algorithm. #python #quantumcomputing #cryptography From jon+usenet at unequivocal.eu Sat Jan 5 09:44:57 2019 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sat, 5 Jan 2019 14:44:57 -0000 (UTC) Subject: chr - what's this? References: Message-ID: On 2019-01-05, Stefan Ram wrote: > ram at zedat.fu-berlin.de (Stefan Ram) writes: >> print( chr( 0x231E )) # Unicode Character 'BOTTOM LEFT CORNER' (U+231E) >> File "~~~\Python\Python37\lib\encodings\cp1252.py", line 19, in encode > > I also have: > > print(chr) > > > . Don't see how the call gets to cp1252.py. I see: > > bltinmodule.c.h > > #define BUILTIN_CHR_METHODDEF \ > {"chr", (PyCFunction)builtin_chr, METH_O, builtin_chr__doc__}, It isn't chr() that's throwing the exception, it's print(). chr(0x231e) is returning a unicode string, print() is trying to display that string on stdout, and apparently on your machine Python thinks stdout is encoded as cp1252. From formisc at gmail.com Sat Jan 5 10:21:02 2019 From: formisc at gmail.com (Andrew Z) Date: Sat, 5 Jan 2019 10:21:02 -0500 Subject: Hands-On Quantum Computing with Python In-Reply-To: <6fbe8e81-22d9-49c2-bd75-a7be7dd8b06f@googlegroups.com> References: <6fbe8e81-22d9-49c2-bd75-a7be7dd8b06f@googlegroups.com> Message-ID: Good for you. On Sat, Jan 5, 2019, 06:25 Bhagvan Kommadi I am coauthoring a packt book : Hands-On Quantum Computing with Python. > The book will be published around Aug 2019 > > > > The book will introduce quantum computing and a comprehensive overview of > the quantum programming languages currently available, such as QCL, QASM, > QUIL, and the differences between them. It will have examples and teach the > reader how to write popular quantum algorithms in some of these languages, > such as Grover?s search and Shor?s factorization algorithm. > > > > #python #quantumcomputing #cryptography > -- > https://mail.python.org/mailman/listinfo/python-list > From grant.b.edwards at gmail.com Sat Jan 5 11:54:15 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 5 Jan 2019 16:54:15 +0000 (UTC) Subject: the python name References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <201901031440.09090.gheskett@shentel.net> <201901032035.14940.gheskett@shentel.net> Message-ID: On 2019-01-05, Michael Torrie wrote: > On 01/03/2019 06:35 PM, Gene Heskett wrote: >> On Thursday 03 January 2019 15:28:49 Grant Edwards wrote: >>> About 20 years ago, the RedHat Linux (way before RHEL) installer >>> (which was written in Python) was called Anaconda. > >> Thanks for rescuing my old wet ram Grant, thats exactly what I was >> thinking of. AIR, it wasn't anywhere near a "real installer" and I spent >> a decent amount of time turning perfectly good air blue. > > On the other hand I never had any troubles with it, nor have I had any > problems with it recently. Not sure what you mean about it not being > anywhere near a "real installer." > > The non-linear redesign that came out a few years ago really threw me, > and I still don't like it. Yea, same yere. I do several dozen Linux installs every year (of various distros). About half of the installs are with Anaconda (CentOS and Fedora). I find the new Anaconda far more confusing and difficult than any of the others. -- Grant From p_s_d_a_s_i_l_v_a_ns at netcabo.pt Fri Jan 4 21:50:50 2019 From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva) Date: Sat, 5 Jan 2019 02:50:50 +0000 Subject: conda/anaconda and pip3 (pip) In-Reply-To: References: Message-ID: ?s 17:39 de 03/12/18, Paulo da Silva escreveu: Well ... further clarification ... > Hi! > > I have an environment created with conda (anaconda3). > There is a package that is unavailable in conda. The package is sklearn (import sklearn). - Look below before comment pls. > Installing it with pip3, with conda env activated, the installation goes > to .local/bin and .local/lib in my home dir (BTW I'm running linux > kubuntu 18.04). This is because I used pip3. pip3 is from the system. Inside conda MyPy (my conda environment) only pip is available. This "pip" works with python3. So: - I uninstalled sklearn using pip3 and installed it with pip. - This sucessfully installed sklearn (a very small bunch of small files). import sklearn didn't work! I uninstalled sklearn with pip. Then I searched for sklearn from the top level of anaconda3 dir. I find few of them, all global to anaconda3 but out of the environment. This means that these packages are not seen from the environment. Besides sklearn was inside the scikit-learn package. So I activated MyPy (my environment) and did conda install scikit-learn Now everything is working and coherent. Still confused, however ... Thank you all. Regards. --- news://freenews.netfront.net/ - complaints: news at netfront.net --- From gheskett at shentel.net Fri Jan 4 23:47:02 2019 From: gheskett at shentel.net (Gene Heskett) Date: Fri, 4 Jan 2019 23:47:02 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <201901032035.14940.gheskett@shentel.net> Message-ID: <201901042347.02101.gheskett@shentel.net> On Friday 04 January 2019 20:27:44 Michael Torrie wrote: > On 01/03/2019 06:35 PM, Gene Heskett wrote: > > On Thursday 03 January 2019 15:28:49 Grant Edwards wrote: > >> About 20 years ago, the RedHat Linux (way before RHEL) installer > >> (which was written in Python) was called Anaconda. > > > > Thanks for rescuing my old wet ram Grant, thats exactly what I was > > thinking of. AIR, it wasn't anywhere near a "real installer" and I > > spent a decent amount of time turning perfectly good air blue. > > On the other hand I never had any troubles with it, nor have I had any > problems with it recently. Not sure what you mean about it not being > anywhere near a "real installer." It never felt like it was doing things in a logical order to me, so if you wanted partitions, you made then before hand, and then turned the air blue as it formatted your home partition, destroying a 5 year corpus of emails you had saved to help you get thru an upgrade. And the only backups I had at the time were on dds2 tapes, but the drive was as usual, spending the winter in Oklahoma city in seagates crappy shop. By then I'd about outgrown the dds2's, and amanda had just grown the ability to use vtapes on a big hard drive which were at least 1000 times more dependable than affordable tapes ever thought of being, so I converted my backup setup to use them and I've never looked back. The drive I just took out, a 1T I replaced with a 2T, has over 80,000 head flying hours on it, and is still as usable as ever. Now thats what I call Dependability. > > The non-linear redesign that came out a few years ago really threw me, > and I still don't like it. Whatever debian has used for the last few years has just worked, except as usual, the partitioner has a mind of its own. So the last install I just let it do what it thought was right, and its actually not given me an excuse to fuss. I've always got amanda to bail me out. But I always install to a bigger fresh drive, so I can just mount the old drive and 4 hours or less later a 15 year corpus of email has been moved to the new drive and I'm a happy camper. Now smaller ssd's are affordable, prices are in free fall. And their speed makes a 10 year old dell fly like a 787! Love it. Take care Michael. Cheers, Gene Heskett -- From python at bdurham.com Sat Jan 5 16:19:54 2019 From: python at bdurham.com (Malcolm Greene) Date: Sat, 05 Jan 2019 14:19:54 -0700 Subject: Best practice for upgrading SQLite C library (DLL, SO, etc) that ships with Python Message-ID: <1546723194.1501226.1626474960.7AC72BD8@webmail.messagingengine.com> I noticed that there's a rather big gap between the latest version of SQLite and the version of SQLite that ships with Python 3.6/3.7. Is there best practice advice for upgrading the SQLlite C library that ships with Python ... without causing havoc and mayhem on my system? Options Don't do it - the universe will split Do it - just replace the DLL/SO library in your Python installation's folderDo it - but rename the updated version so as not to overwrite the default SQLlite library?Do it - using some type of virtual environment magic so your change is truly isolated Other? Are there OS specific issues to be concerned with or is there a general pattern here? I work across Windows, Linux, and macOS. Thank you, Malcolm From avigross at verizon.net Sat Jan 5 17:32:40 2019 From: avigross at verizon.net (Avi Gross) Date: Sat, 5 Jan 2019 17:32:40 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> Message-ID: <001501d4a546$91abb4b0$b5031e10$@verizon.net> Dennis, Yes, I remember seeing proofs that a bare-bones Turing Machine with an infinite bidirectional tape can solve anything done by a classical computer. I also suggest that in many cases, such a device is a way to transform any problem that can be solved decently into one that can now be solved in indefinite and sometimes effectively infinite, time. I wrote my thesis on a variant of such an automaton. But many things that are theoretically doable remain far from practical. There are often shortcuts both in hardware and software that allow simpler solutions using finite resources for reasonable amounts of data processed. I recall an example from a version of mathematical LISP that I will rewrite in python for illustration: def is_greater(left, right): if left <= 0 : return False if right <= 0 : return True return is_greater(left - 1, right - 1) That is a beautiful mathematical way of looking at it. Given two non-negative numbers, keep subtracting one from both sides until one is 0 or less. At that point, you know. The original version did not use subtraction but rather an abstract function to return a predecessor. Nice and abstract. Too abstract. Yes, this does not handle equality well. Easy enough to amend. But the POINT is that comparing a trillion to a quadrillion may take some time and without tail recursion may exhaust the stack long before it completes. Yet for an amazing number of case, a shorter solution is as simple as placing left in register A and right in register B and issuing a command that compares them bitwise or something and returns a True/False in register A as a bit, or whatever the details. Or, for big numbers, many other techniques that are still simple and fast enough can be done such as converting the number into a long string of decimals and comparing one at a time till they diverge. So for practical matters, Turing machines are no more than a debating point. Yes, a language without exponentiation can solve a large set of problems using repeated multiplication but how easily with it raise the transcendental number e to the [product of the transcendental number pi times the odd square root of -1] and get a result of -1? Heck, who needs multiplication? Repeated addition might do, to a point? Or, go back to the Turing machine where you, well, why bother? In the real world, the path to progress in the PRESENT often uses improvements that let you program at increasing levels of abstraction and allows underlying details to be handled for you with some confidence. So even though many programming constructs do an implicit goto when viewed at machine language levels, they are usually somewhat hidden when viewed as loops or exception handling. Heck, we now often hide loops. -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Saturday, January 5, 2019 1:46 PM To: python-list at python.org Subject: Re: the python name On Fri, 4 Jan 2019 22:59:40 -0500, "Avi Gross" declaimed the following: >was badly named when it was among the first to do such things. I am >saying that in retrospect, almost any language can do a basic subset of >arithmetic operations. And there is nothing in principle that >necessarily stops any CF: https://en.wikipedia.org/wiki/Turing_completeness Pretty much ANY computer language can be used to do any computation -- it may be more difficult in some, but it won't be impossible. The hypothetical Turing machine would, in one way, be the ultimate in symbolic manipulation given the basics consist of test/move/store... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Sat Jan 5 17:42:46 2019 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 6 Jan 2019 09:42:46 +1100 Subject: the python name In-Reply-To: <001501d4a546$91abb4b0$b5031e10$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <001501d4a546$91abb4b0$b5031e10$@verizon.net> Message-ID: On Sun, Jan 6, 2019 at 9:34 AM Avi Gross wrote: > I recall an example from a version of mathematical LISP that I will rewrite > in python for illustration: > > def is_greater(left, right): > if left <= 0 : return False > if right <= 0 : return True > return is_greater(left - 1, right - 1) Possibly: if left <= 0: return is_greater(-right, -left) Otherwise it will give incorrect results for, eg, is_greater(-10, -11) But your point is taken. ChrisA From avigross at verizon.net Sat Jan 5 22:09:22 2019 From: avigross at verizon.net (Avi Gross) Date: Sat, 5 Jan 2019 22:09:22 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <001501d4a546$91abb4b0$b5031e10$@verizon.net> Message-ID: <002301d4a56d$3928f1f0$ab7ad5d0$@verizon.net> Chris, As you noticed, I wanted to focus on a point and simplified the code. The point was of an example that struck me as both mathematically beautiful and completely impractical when it comes to decent programming given the languages and tools available today. What follows is really off topic so anyone not interested may wish to abort here. It helps explain my chosen example. The reality I am behind that function definition was quite a bit weirder. It was part of an exercise in a world where arithmetic as we know it did not exist and had to be bootstrapped into existence. Numbers had to be crafted from nothing starting with the special number zero and a vague function called successor() that created sort of an ordering on what became a set of integers. So ONE (1) was DEFINED as successor(0) and TWO (2) was successor(1) and so on. Of course, they then had to create a function called predecessor() with the abstract and vague concept that it was a sort of inverse of successor() so that for all elements x of the set created from 0 onward, there existed a function called predecessor() such that: predecessor(successor(x)) == x and of course: successor(predecessor(x)) == x So, at this point, negative integers are not quite in existence as nothing defines predecessor(0), at least not yet. The progression was first to create functions comparing any two entities (i.e. integers) sort of like the one I mention above and calling it something like greater_than(a,b) and so on till you built up a logical structure that included set theory and eventually all of arithmetic and beyond. As a philosophical or logical exercise, it indeed is true to suggest that the lesser of a trillion and a quadrillion is whichever is in a sense closer to zero. Closer here is defined as fewer calls to predecessor() before hitting the one known number in this scheme. At that point in the book, expressions like "5 - 3" are not yet defined. Now such attempts to do a step by step building of a mathematical structure from some minimal number of postulates is frequent in mathematics. Think Euclidean Geometry where if don't take the fifth, you may end up in other geometries like Riemannian and Lobachevskian. But in programming, we have other definitions of number and the meaning of "+" uses such definitions. We do not require multiple steps to add things. (Well, we sort of do by adding columns and carrying, but relatively few and often hidden.) We not only do not need multiple additions to do a multiplication, but have extended arithmetic so you can multiple by real numbers instead of just by integers as well as by negative ones or even by complex numbers and other extensions. Ditto for raising numbers to powers not being restricted to an integral number of multiplications. My point is that the Turing tape with a head that can maintain states is a fantasy that can be set up to very laboriously do the simplest things. Just adding two numbers can require something tedious where two areas of the tape contain N and M squares in a row that represent each of the two numbers. The head must march back and forth and copy one square at a time, perhaps to a new place, while marking the old one in a way that guides it to take the next one when it returns, or something equally silly and if you count how many times the head moves one square to the left or right in trying to add a million to a million by making a third region containing 2 million identical squares, good luck. Back to python. One feature I like in python is how flexible some things are. Specifically as an example, an integer can grow as large as you want without special arrangements being made. A dictionary similarly can grow or a list or many things that normally start with a smaller amount of space reserved for it. A dictionary may be created with space for a hundred entries but as it fills, magically, a larger amount of space is created and things are migrated over but everything already pointing to entries does not notice or care. When I used to write programs in languages like C or PASCAL some things that work fine in PYTHON would simply fail. Or, my code would be full of places where I had to check if space was used up, allocate new contiguous space and migrate things and try to sew up any loose ends. Do I want to go backward on many similar aspects where modern computing does a better job? How much time need I waste using a limited language that can, with tons of work, potentially do everything possible if I have to consciously allocate space, mange my own tables keeping track of what is in use, returning resources when no longer using them and so on. Languages with strong typing sometimes got so restrictive and hard to write realistic programs in that they had to be amended with gimmicks allowing you to go around them. Languages where nothing was mutable wasted resources by constantly copying things. It works, but there can be ways to make a different tradeoff. Python is a mixture of new and old. Some argue a few decades is not old given hold FORTRAN is. True. But people considering building a completely new language today might make different choices. But it might take decades before that language had a chance to be as widely used as python and clearly python periodically adjusts to new ideas and evolves. But as we see in the way version 2.x is being gradually let go, not all change can be done without some sacrifice of the old way which was not designed in ways that are quite easy to keep alongside the new. Python is not alone. PERL also has a schism and clearly C has many offspring that are in some ways above C-level. END OF DIGRESSION. -----Original Message----- From: Python-list On Behalf Of Chris Angelico Sent: Saturday, January 5, 2019 5:43 PM To: Python Subject: Re: the python name On Sun, Jan 6, 2019 at 9:34 AM Avi Gross wrote: > I recall an example from a version of mathematical LISP that I will > rewrite in python for illustration: > > def is_greater(left, right): > if left <= 0 : return False > if right <= 0 : return True > return is_greater(left - 1, right - 1) Possibly: if left <= 0: return is_greater(-right, -left) Otherwise it will give incorrect results for, eg, is_greater(-10, -11) But your point is taken. ChrisA -- https://mail.python.org/mailman/listinfo/python-list From frank at chagford.com Sun Jan 6 00:01:23 2019 From: frank at chagford.com (Frank Millman) Date: Sun, 6 Jan 2019 07:01:23 +0200 Subject: Best practice for upgrading SQLite C library (DLL, SO, etc) that ships with Python In-Reply-To: <1546723194.1501226.1626474960.7AC72BD8@webmail.messagingengine.com> References: <1546723194.1501226.1626474960.7AC72BD8@webmail.messagingengine.com> Message-ID: "Malcolm Greene" wrote in message news:1546723194.1501226.1626474960.7AC72BD8 at webmail.messagingengine.com... > > I noticed that there's a rather big gap between the latest version of SQLite and the version of SQLite that ships with Python 3.6/3.7. Is there best practice advice for upgrading the SQLlite C library that ships with Python ... without causing havoc and mayhem on my system? > Options > Don't do it - the universe will split > Do it - just replace the DLL/SO library in your Python installation's folderDo it - but rename the updated version so as not to overwrite the default SQLlite library?Do it - using some type of virtual environment magic so your change is truly isolated Other? > Are there OS specific issues to be concerned with or is there a general pattern here? I work across Windows, Linux, and macOS. I have done this a few times on Windows. I download the latest zip file from www.sqlite.org/download, unpack it, and replace the dll in the Python DLLs folder. I do back up the existing one first, just in case, but I have never had a problem. I also download the 'tools' zip file, which contains sqlite3.exe, a command-line program for executing sql statements. I actually had a problem once when things that worked with sqlite3.exe did not work when I ran the same command from python. I eventually realised that the two underlying versions of sqlite3 were different, so now I make sure I always keep them in sync. I can't comment about Linux or macOS, sorry. Frank Millman From uri at speedy.net Sun Jan 6 00:47:52 2019 From: uri at speedy.net (=?UTF-8?B?15DXldeo15k=?=) Date: Sun, 6 Jan 2019 07:47:52 +0200 Subject: Is distutils deprecated? Message-ID: Is `distutils` deprecated or about to be deprecated? https://github.com/python-pillow/Pillow/issues/3547 ???? (Uri) uri at speedy.net From hjp-python at hjp.at Sun Jan 6 07:26:15 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 6 Jan 2019 13:26:15 +0100 Subject: the python name In-Reply-To: <8cj4gf-2ai.ln1@anthive.com> References: <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> Message-ID: <20190106122615.dchsvji7t3qw4kbr@hjp.at> On 2019-01-04 12:56:56 -0500, songbird wrote: > Peter J. Holzer wrote: > > Almost all of these points don't seem to be related to the language, but > > to your environment. > > an application isn't useful unless it actually can > be deployed and used in an environment. True. But environments are different. And many factors of the environment are completely independent of the language. For example, about 10 years ago I built a continuous integration pipeline for a project I was working on (we didn't call it that - I'm not sure the name had been invented at that time, but the concept is much older). It checked every minute if something had been committed into the master branch of the repository, checked it out, ran the test suite, and if all the tests succeeded, deployed the application on the test server. I also revoked the developer's privileges to install anything directly on the test server. The result was that any change took about half an hour to show up on the server. The software was written in Perl and Java. Was it Perl's fault that the Change-Deploy-Test cycle was so slow? Was it Java's fault? No. It wasn't the fault of either of the languages. It was a combination of the system I've built (which always ran the complete test suite and didn't try to skip irrelevant tests), the size of the project (the test suite was huge and some tests were slow), the components I used (for example, cron can only run a job every minute) and of organizational measures (revoking privileges) I took. Somebody who never used Perl before and encountered our system might say "Perl is bad because it takes half an hour to deploy an application", but that wouldn't be correct. Similarly, when you write that it takes half an hour for your changes to show up, and that you have to clear some caches, that doesn't seem related to the language but to your specific environment. I write mostly web-applications and programs intended to be run from the command line or cron. With Django or Flask, changes usually show up within a second or so in the development environment (I don't even have to restart the server, it restarts automatically when I save a file). CLI scripts are of course also ready to run as soon as I save them. And caches may or may not be a problem but that is application-specific. To deploy my changes (to the test or production environment), a "git pull" plus maybe some other actions is sufficient - again that completes in seconds, not minutes. So we are both using the same language, but I see my changes immediately and you have to wait half an hour. The difference is that we are working in different environments. Now it may be that the tools that Python provides are ill-suited to your environment, and that improving those tools (or providing additional ones) may help you and possibly others. Or it may be that you have to change something in your environment which is completely outside of the control of the Python developers. I'm not able to figure out from your vague and general descriptions whether a change in the Python tool-chain or a change in your environment would help, much less a specific change. > at least these make sense: > > https://packaging.python.org/tutorials/installing-packages/ > https://docs.python.org/3/installing/index.html#installing-index So your problem is packaging? I didn't even figure that out from your previous mail. (Though now I remember vaguely that you may have complained about packaging before. Hint: On a busy mailinglist, don't assume that everybody remembers everything you have written before. Provide enough context in every mail that people know what you are talking about.) I haven't packaged anything yet. I have looked at the documentation several times and I agree that it looks somewhat daunting (I am not unfamiliar with packaging systems: I have built rpm and deb packages, and used both the Makefile.PL and Module::Builder systems for Perl, but the Python docs left me somewhat at a loss - and since I didn't actually need it I postponed learning how to do it). 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 hjp-python at hjp.at Sun Jan 6 07:56:18 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 6 Jan 2019 13:56:18 +0100 Subject: the python name In-Reply-To: <00d701d4a4ab$15c4f820$414ee860$@verizon.net> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> Message-ID: <20190106125618.46xqs6s73a3vg7m5@hjp.at> On 2019-01-04 22:59:40 -0500, Avi Gross wrote: > I don't go back to the beginning of FORTRAN. My comment was not that FORTRAN > was badly named when it was among the first to do such things. I am saying > that in retrospect, almost any language can do a basic subset of arithmetic > operations. So this is something that Fortran did right. In hindsight we might be tempted to say that this was obvious and no great achievement, but I'm not sure it felt that way at the time. There were certainly other languages like Lisp (1958, a bit after Fortran) and Forth (1970 - quite a bit later) whose inventors thought that the way mathematicians write expressions isn't the best way to program computers. But as you say almost all programming languages still in wide use today do it like Fortran (whether they copied it from Fortran or invented it independently), so it is now the "natural" way to do it. > And there is nothing in principle that necessarily stops any > modern language code from being optimized by translators to be even more > rapid than the original versions of FORTRAN. I'm sure many current languages are much faster than the *original* versions of FORTRAN. Those were among the very first compilers and people hadn't figured out how to generate efficient code yet. *Modern* Fortran compilers however are quite good and continue to get better. > If anything, I can well imagine algorithms using parallel > architectures from performing some operations way faster. One advantage of Fortran over C is indeed that it is easier to exploit parallelism in Fortran programs than in C programs. If you implement the same algorithm in naive Fortran and naive C, the Fortan compiler might figure out that the algorithm can be parallelized while the C compiler can't be sure. (Both languages have constructs (some native, some as extensions) to specify that explicitely, but the programmer has to use them (and use them correctly)) 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 hjp-python at hjp.at Sun Jan 6 13:30:52 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 6 Jan 2019 19:30:52 +0100 Subject: Python packaging (was: the python name) In-Reply-To: <20190106122615.dchsvji7t3qw4kbr@hjp.at> References: <1ed2d407-1486-e2d3-3095-4b3d92ad9fd7@mrabarnett.plus.com> <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> <20190106122615.dchsvji7t3qw4kbr@hjp.at> Message-ID: <20190106183052.2ijlaldazkyly62t@hjp.at> On 2019-01-06 13:26:15 +0100, Peter J. Holzer wrote: > I haven't packaged anything yet. I have looked at the documentation > several times and I agree that it looks somewhat daunting (I am not > unfamiliar with packaging systems: I have built rpm and deb packages, > and used both the Makefile.PL and Module::Builder systems for Perl, but > the Python docs left me somewhat at a loss - and since I didn't actually > need it I postponed learning how to do it). I take that back. I just worked through https://packaging.python.org/tutorials/packaging-projects/ and it seems pretty simple and straightforward. I don't think I've seen this tutorial last time I looked. Either it didn't exist then (in its current form) or I was looking in the wrong place. 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 hjp-python at hjp.at Sun Jan 6 14:32:19 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 6 Jan 2019 20:32:19 +0100 Subject: the python name In-Reply-To: <7mi43etjvc1s3fiebt7csenu8elcnqjeii@4ax.com> References: <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> <20190106122615.dchsvji7t3qw4kbr@hjp.at> <7mi43etjvc1s3fiebt7csenu8elcnqjeii@4ax.com> Message-ID: <20190106193219.6afzmvkeii2e52hv@hjp.at> On 2019-01-06 13:43:02 -0500, Dennis Lee Bieber wrote: > On Sun, 6 Jan 2019 13:26:15 +0100, "Peter J. Holzer" > declaimed the following: > > >For example, about 10 years ago I built a continuous integration > >pipeline for a project I was working on [...] > >The result was that any change took about half an hour to show up on > >the server. > > Lucky you... In 1981 I was tasked with porting an application (FORTRAN > IV) to a minicomputer (CDC MP60 ruggedized for military field drops). [...] > It took three HOURS to compile the application. Yes, I've been lucky to never be involved in a really large project. Computers have become much faster since the 1980's, but programs also have become much larger, so multi-hour compiles still exist. Hoever, this is the Python list and one of the advantages of Python is that we don't have to compile our code. So we need a different excuse for fencing on office chairs ;-). 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 olousseh at yahoo.fr Sun Jan 6 10:20:08 2019 From: olousseh at yahoo.fr (Olivier Oussou) Date: Sun, 6 Jan 2019 15:20:08 +0000 (UTC) Subject: Encounter issues to install Python In-Reply-To: References: <1715165778.8897506.1539026476320.ref@mail.yahoo.com> <1715165778.8897506.1539026476320@mail.yahoo.com> Message-ID: <648909725.21498006.1546788008045@mail.yahoo.com> Hi dear Anthony,I am using Windows systeme. I have download the set up uf?python 3.6.4 (32-bit) and I can not install the software on my computer.?I need your technical assistance to solve this matter and I will be glad if you do so. Best regard! OlivierMedical entomologist, Benin Le samedi 13 octobre 2018 ? 19:24:28 UTC+2, Anthony Flury a ?crit : Olivier, Welcome to the list - before we can help you, we need some more information : - What Operating system are you using - Windows/Mac/Linux/Raspberry Pi/Android for something else ? - What command or installer did you use to try to install Python. - What issues did you have during installation - if any ? - What interface are you trying to access, and how are you doing that ? - Do you get error messages? Unless you tell us what the problem is we can't possibly help. On 08/10/18 20:21, Olivier Oussou via Python-list wrote: Hi!I downloaded and installed python 3.6.4 (32-bit) on my computer but I have problems and can not access the python interface. I need your technical assistance to solve this matter.? Best regard! Olivier OUSSOUMedical entomologist, Benin -- Anthony Flury Email : anthony.flury at btinternet.com Twitter : @TonyFlury From avigross at verizon.net Sun Jan 6 15:09:40 2019 From: avigross at verizon.net (Avi Gross) Date: Sun, 6 Jan 2019 15:09:40 -0500 Subject: the python name In-Reply-To: <20190106193219.6afzmvkeii2e52hv@hjp.at> References: <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> <20190106122615.dchsvji7t3qw4kbr@hjp.at> <7mi43etjvc1s3fiebt7csenu8elcnqjeii@4ax.com> <20190106193219.6afzmvkeii2e52hv@hjp.at> Message-ID: <005c01d4a5fb$c232a3e0$4697eba0$@verizon.net> [Can we ever change the subject line?] {REAL SUBJECT: degrees of compilation.} Peter wrote: "... Hoever, this is the Python list and one of the advantages of Python is that we don't have to compile our code. So we need a different excuse for fencing on office chairs ;-). ..." I understand what he means, but python does sometimes do a half-compilation to byte code if the compiled version does not exist or the file being read is newer. And, if it cannot write a file, it compiles it in memory each and every time. This half-digested format may not be considered a compile down to the level of machine code, obviously. I have no idea of relative run times for the compiles as so much depends on the contents of files and their sizes and the underlying language/compilers. Compiling a project with an endless numbers of pieces can take a very long time. When you are just doing one file now and then, not so much. I suspect that the common method of spreading out a program into many small files can have an impact on the time it takes. I won't share my own war stories of how to compile in what now seem primitive environments on overloaded machines where you often figured out your mistakes on paper before the compiler quit and showed you officially ? What is the purpose of compiling? Superficially, it is to catch serious errors. So if there are serious errors, or perhaps to put it mildly, places where the compiler can't figure out exactly what you, the programmer, meant, it often can quit early. Only when it finds nothing wrong does it need to finish to the end. Sometimes parts of what you may not necessarily consider the compiler can be done selectively or even externally. I mean you can use tools to tune up your code in ways that search not so much for obvious errors but for potential errors or possibly poor technique that generate warnings or hints. If you add some of this functionality in the normal compile, you slow it down. Similarly, there are aspects that optimize the code in some ways that are good to have in final production code ready to ship but may not be needed every time you compile. From grant.b.edwards at gmail.com Sun Jan 6 15:13:23 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 6 Jan 2019 20:13:23 +0000 (UTC) Subject: the python name References: <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> <20190106122615.dchsvji7t3qw4kbr@hjp.at> <7mi43etjvc1s3fiebt7csenu8elcnqjeii@4ax.com> <20190106193219.6afzmvkeii2e52hv@hjp.at> Message-ID: On 2019-01-06, Peter J. Holzer wrote: > On 2019-01-06 13:43:02 -0500, Dennis Lee Bieber wrote: >> On Sun, 6 Jan 2019 13:26:15 +0100, "Peter J. Holzer" >> declaimed the following: >> >> >For example, about 10 years ago I built a continuous integration >> >pipeline for a project I was working on > [...] >> >The result was that any change took about half an hour to show up on >> >the server. >> >> Lucky you... In 1981 I was tasked with porting an application (FORTRAN >> IV) to a minicomputer (CDC MP60 ruggedized for military field drops). > [...] >> It took three HOURS to compile the application. > > Yes, I've been lucky to never be involved in a really large project. > Computers have become much faster since the 1980's, but programs also > have become much larger, so multi-hour compiles still exist. On some of my (not _that_ old) machines, it takes about 1.5 days to compile the Chrome browser. -- Grant From hjp-python at hjp.at Sun Jan 6 17:25:08 2019 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 6 Jan 2019 23:25:08 +0100 Subject: Compilation (was: the python name) In-Reply-To: <005c01d4a5fb$c232a3e0$4697eba0$@verizon.net> References: <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> <20190106122615.dchsvji7t3qw4kbr@hjp.at> <7mi43etjvc1s3fiebt7csenu8elcnqjeii@4ax.com> <20190106193219.6afzmvkeii2e52hv@hjp.at> <005c01d4a5fb$c232a3e0$4697eba0$@verizon.net> Message-ID: <20190106222508.e7c4572wpwze7ord@hjp.at> On 2019-01-06 15:09:40 -0500, Avi Gross wrote: > [Can we ever change the subject line?] Feel free. > {REAL SUBJECT: degrees of compilation.} > Peter wrote: > > "... Hoever, this is the Python list and one of the advantages of > Python is that we don't have to compile our code. So we need a > different excuse for fencing on office chairs ;-). ..." > > I understand what he means, but python does sometimes do a > half-compilation to byte code if the compiled version does not exist > or the file being read is newer. This is compilation, but it isn't a separate phase. We don't invoke a "python compiler" to produce an "executable" which we then "execute". We invoke the interpreter on the source code, which compiles the source code as needed (so in the literal sense it is a just in time compiler, although this isn't what we usually mean by that term). And because this happens in principle every time we start a python program (yes, there is a cache, but that is incidental) the compiler must be fast and primitive and basically unnoticable. > What is the purpose of compiling? Superficially, it is to catch > serious errors. I strongly disagree with this. The purpose of compiling is to translate from one language into another. Typically, the source language is more programmer-friendly, higher level and the target language is more machine-friendly, lower level. But there are exceptions. Finding errors is mostly a consequence of this function. If the compiler cannot parse the source code or doesn't have enough information to generate code in the target language, it cannot fulfill its function and has to bail out. There are programs with the primary purpose of finding errors: We call these linters, static analysers, etc. (From your other mails I guess that you almost certainly remember the Unix distinction between cc and lint.) Of course sometimes these are functions are conflated. Since an optimizing compiler has to analyse variable usage anyway for efficient register allocation it can also warn you about unused variables at (almost) no extra cost. So it makes sense to put that warning into the compiler (I'm less sure if it's a good idea to make this an error, as in Go). Or the compiler might even get quite expensive checking capabilities, as the authors think that programmers are more likely to look at the output of the tool they have to use than to invoke a separate, optional tool. 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 skip.montanaro at gmail.com Sun Jan 6 17:29:26 2019 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Sun, 6 Jan 2019 16:29:26 -0600 Subject: Transparently treating tar files and zip archives as directories Message-ID: I find it useful in some of the work I do to treat Zip archives as if they were directories. I don't think it would be too difficult to make it pretty much transparent, so that you could execute something like: fileobj = magic_open("/path/to/some/archive.zip/some/internal/path/magic.txt") or equivalent for writing and other list-y, glob-y sorts of things. (In fact, I'd be mildly surprised if I couldn't find something on PyPI if I spent a few minutes searching.) As I considered that idea the other day, I thought, "Hmmm... might be useful for tar files as well." Alas, the tarfile module API didn't seem like it would support such a higher level API anywhere near as easily. Is that a fundamental property/shortcoming of the tarfile format, or is it just a function of the tarfile module's API? Skip From p.f.moore at gmail.com Sun Jan 6 17:38:27 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Sun, 6 Jan 2019 22:38:27 +0000 Subject: Transparently treating tar files and zip archives as directories In-Reply-To: References: Message-ID: Pyfilesystem (https://pypi.org/project/fs/) does something like this - it might be what you're after, Paul On Sun, 6 Jan 2019 at 22:32, Skip Montanaro wrote: > > I find it useful in some of the work I do to treat Zip archives as if > they were directories. I don't think it would be too difficult to make > it pretty much transparent, so that you could execute something like: > > fileobj = magic_open("/path/to/some/archive.zip/some/internal/path/magic.txt") > > or equivalent for writing and other list-y, glob-y sorts of things. > (In fact, I'd be mildly surprised if I couldn't find something on PyPI > if I spent a few minutes searching.) > > As I considered that idea the other day, I thought, "Hmmm... might be > useful for tar files as well." Alas, the tarfile module API didn't > seem like it would support such a higher level API anywhere near as > easily. Is that a fundamental property/shortcoming of the tarfile > format, or is it just a function of the tarfile module's API? > > Skip > -- > https://mail.python.org/mailman/listinfo/python-list From skip.montanaro at gmail.com Sun Jan 6 18:05:36 2019 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Sun, 6 Jan 2019 17:05:36 -0600 Subject: Transparently treating tar files and zip archives as directories In-Reply-To: References: Message-ID: > Pyfilesystem (https://pypi.org/project/fs/) does something like this - > it might be what you're after, Thanks, Paul. That would seem to check all my boxes and more. S From avigross at verizon.net Sun Jan 6 18:20:55 2019 From: avigross at verizon.net (Avi Gross) Date: Sun, 6 Jan 2019 18:20:55 -0500 Subject: Compilation (was: the python name) In-Reply-To: <20190106222508.e7c4572wpwze7ord@hjp.at> References: <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> <20190106122615.dchsvji7t3qw4kbr@hjp.at> <7mi43etjvc1s3fiebt7csenu8elcnqjeii@4ax.com> <20190106193219.6afzmvkeii2e52hv@hjp.at> <005c01d4a5fb$c232a3e0$4697eba0$@verizon.net> <20190106222508.e7c4572wpwze7ord@hjp.at> Message-ID: <009401d4a616$7990efa0$6cb2cee0$@verizon.net> Peter, I suspect there is some python tool that can go through a directory structure of python code and produce appropriate byte code files in one sweep. That would not be at run time. And, in any system where the average user does not have write permission on those folders, that would be a good idea or every use would be slower. I don't want to keep dwelling on the past and would like to hear more about the current and perhaps near-future state of python and perhaps new added functionality and upgrades in some modules outside the built-in variety. So I would rather not get into detailed discussions of the differences between translation and compilation and other such words. I will grant your points. I did not intend what you may have read into it. As you suggest, I am very aware of generations of tools including lint versus cc as I did programming back for more years using more languages and operating systems and machine types than I care to remember. There is though a subtle distinction between what programmers and organizations are supposed to do and what individual programmers do. The rules normally suggest getting something to be syntactically correct then testing units and larger groupings and then entire projects. It used to mean spending 90% of your time writing documents and attending endless review meetings. People tend to find ways around some of that. It is amazing how often they write the code first then write a document describing how they will do it! My point was that many developers used a compilation as a way to partially debug their code. Typically you got some errors or at least warnings and no proper result. You would try to fix and resubmit until it compiled properly. That may not be the PURPOSE but it often was how things got done. Leaving out a comma or semicolon or calling a function with the wrong number of arguments or having unbalanced parentheses or a variable name spelled wrong and so on were often caught only by the compiler. Nowadays we often have tools that check for lint without actually making an executable and in the case of python, there really is no executable as even the byte code version is run live. Worse, I have seen how you can change a function to take an additional argument and wonder what other code calls that function. The lazy way is to recompile everything and see what fails! Is this the PURPOSE of the compiler? Of course not. The purpose is to finish the process and deliver the goods. But when developing code, some people decided to be lazy about proofreading their own code and let the compiler take a stab at it. As I said, when the process took long enough, they often read the code or had a friend look at it and found the errors and KILLED the compile and resubmitted it on the upgraded code. This speeded their own work a bit but meant the computer was overloaded for little purpose. Now when I import a bunch of code to my machine and run the compiler to make executables, the purpose may be closer to the intended purpose if all goes well. Unfortunately, sometimes it is a way to find out if your setup is in some way flawed or you have the wrong version of something ... Let me ask a question. Switch to a word processing concept. When writing something, do you write a first draft mostly to completion and then do various forms of checking and revision or do you pause after each sentence or paragraph and run tools to check spelling and grammar and tell you what grade level readers need to understand it? In the earlier days this was not even a question. Then we got spell checkers that ran on their own and then other tools that gave lots of (often useless) advice about writing too much in a passive voice or that the document used long sentences and big (meaning technical) words so the person needed to have a college education. Well, most of us had a Masters or two or a Ph.D. and besides we tended to be highly technical and much of the jargon in the documents was REQUIRED for the purpose. So, after a while, people ran these lint-style programs less often, maybe mostly in the final phase. But, similarly, before the What You See is What You get days, people would use a markup language like nroff/troff and PRINT the darn thing to be picked up hours later downstairs. You could say we compiled it, sort of. We would then read the hard copy to find all our errors like turning on bold and not turning it off or not starting a new paragraph or noting the sentence made no sense when seen all at once without intervening formatting commands. So we edited the code and printed it again! Worse were things you really could not see properly on screen. Parts of our documents were little programs of sorts that produced equations, tables, and computer graphics where we told it to connect a line from the northwest corner of object 1 to ... Sound like compilation to you? It was. You had to pipe the document through filters like tbl and eqn and pic that expanded the language of that component into reams of hard to penetrate troff including lots of variables and arithmetical calculations. As you describe, there was a sort of translation from a higher-level language to somewhat lower-level and then to even lower levels down to something like the printer language that applied. When we finally got screens with pixels and programs that generated a decent (not perfect) WYSIWYG, we started printing less often. Nowadays, some people using Word Processing never actually need to print. Well, the imperfect analogy ends. Moving on. -----Original Message----- From: Python-list On Behalf Of Peter J. Holzer Sent: Sunday, January 6, 2019 5:25 PM To: python-list at python.org Subject: Compilation (was: the python name) On 2019-01-06 15:09:40 -0500, Avi Gross wrote: > [Can we ever change the subject line?] Feel free. > {REAL SUBJECT: degrees of compilation.} Peter wrote: > > "... Hoever, this is the Python list and one of the advantages of > Python is that we don't have to compile our code. So we need a > different excuse for fencing on office chairs ;-). ..." > > I understand what he means, but python does sometimes do a > half-compilation to byte code if the compiled version does not exist > or the file being read is newer. This is compilation, but it isn't a separate phase. We don't invoke a "python compiler" to produce an "executable" which we then "execute". We invoke the interpreter on the source code, which compiles the source code as needed (so in the literal sense it is a just in time compiler, although this isn't what we usually mean by that term). And because this happens in principle every time we start a python program (yes, there is a cache, but that is incidental) the compiler must be fast and primitive and basically unnoticable. > What is the purpose of compiling? Superficially, it is to catch > serious errors. I strongly disagree with this. The purpose of compiling is to translate from one language into another. Typically, the source language is more programmer-friendly, higher level and the target language is more machine-friendly, lower level. But there are exceptions. Finding errors is mostly a consequence of this function. If the compiler cannot parse the source code or doesn't have enough information to generate code in the target language, it cannot fulfill its function and has to bail out. There are programs with the primary purpose of finding errors: We call these linters, static analysers, etc. (From your other mails I guess that you almost certainly remember the Unix distinction between cc and lint.) Of course sometimes these are functions are conflated. Since an optimizing compiler has to analyse variable usage anyway for efficient register allocation it can also warn you about unused variables at (almost) no extra cost. So it makes sense to put that warning into the compiler (I'm less sure if it's a good idea to make this an error, as in Go). Or the compiler might even get quite expensive checking capabilities, as the authors think that programmers are more likely to look at the output of the tool they have to use than to invoke a separate, optional tool. 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 From bowman at montana.com Sun Jan 6 19:26:46 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 17:26:46 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> Message-ID: On 01/02/2019 12:41 PM, Schachner, Joseph wrote: > The name "Python" may not make sense, but what sense does the name Java make, or even C (unless you know that it was the successor to B), or Haskell or Pascal or even BASIC? Or Caml or Kotlin or Scratch? Or Oberon or R? Or Smalltalk, or SNOBOL? BASIC is an acronym.. http://bitsavers.trailing-edge.com/pdf/dartmouth/BASIC_Oct64.pdf Beginner's All purpose Symbolic Instruction Code It was Dartmouth University's didactic language for non-engineers and probably nobody imagined it would ever go anyplace. I went to an engineering school and learned FORTRAN in '65, the same time period, and never heard of BASIC until much later. My wife went to a liberal arts college where they also had a didactic language that ran on CDC systems. I can't remember the name of the language but both it and CDC are dusty footnotes now, SNOBOL was sort of a tortured acronym, StriNg Oriented symBOlic Language. I don't know if that was a play on COmmon Business Oriented Language. FORTRAN came from FORmula TRANslation. My favorite is a weird little language mainly useful for matrix operations that IBM modestly named APL - A Programming Language. Of course they also had PL/I, Programming Language One. From bowman at montana.com Sun Jan 6 19:27:45 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 17:27:45 -0700 Subject: the python name In-Reply-To: <9cl0gf-5r5.ln1@anthive.com> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <9cl0gf-5r5.ln1@anthive.com> Message-ID: On 01/02/2019 11:06 PM, songbird wrote: > i can only claim to have written one program in > SNOBOL and that was over 30yrs ago... My sympathies... From bowman at montana.com Sun Jan 6 19:33:22 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 17:33:22 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> Message-ID: On 01/02/2019 06:03 PM, Avi Gross wrote: > A Programming Language? APL. A company I worked for bought an IBM 5120, not to be confused with the later 51xx PC's. It shipped with BASIC and APL in the ROM, had a toggle switch to select between the two, and the weird characters on the keyboard. That is as close as I ever got to that one. From bowman at montana.com Sun Jan 6 19:35:09 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 17:35:09 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <0697fd9f-3695-9331-fcf0-a91092465899@gmail.com> Message-ID: On 01/03/2019 07:59 AM, Jack Dangler wrote: > Odd that COBOL (Common Business Oriented Language) and DIBOL (Digital > Business Oriented Language) follow the paradigm, but SNOBOL went with > "symBOlic"... I vaguely remember it as being sort of an inside joke vis a vis COBOL. From bowman at montana.com Sun Jan 6 19:45:10 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 17:45:10 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <006d01d4a384$dd687cd0$98397670$@verizon.net> Message-ID: On 01/03/2019 09:53 AM, Avi Gross wrote: > Bad analogy, but snakes do tend to shed their skin periodically as they grow. 3.x certainly was a snake shedding its skin. ESRI moved to 3 for the cloud oriented products but their non-cloud products are still 2.7 and that's the world I live in. Some of the changes seem a bit gratuitous. From bowman at montana.com Sun Jan 6 19:56:56 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 17:56:56 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <006d01d4a384$dd687cd0$98397670$@verizon.net> <201901031440.09090.gheskett@shentel.net> Message-ID: On 01/03/2019 12:40 PM, Gene Heskett wrote: > Do I miss-remember that there was an anaconda language at sometime in the > past? Not long after python made its debute? I've not see it mentioned > in a decade so maybe its died? Very alive and well... https://www.anaconda.com/what-is-anaconda/ It's not a separate language but is a Python/R combo. From bowman at montana.com Sun Jan 6 20:12:21 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 18:12:21 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <006d01d4a384$dd687cd0$98397670$@verizon.net> <201901031440.09090.gheskett@shentel.net> Message-ID: On 01/03/2019 01:28 PM, Grant Edwards wrote: > On 2019-01-03, Gene Heskett wrote: > >> Do I miss-remember that there was an anaconda language at sometime in the >> past? Not long after python made its debute? I've not see it mentioned >> in a decade so maybe its died? > > About 20 years ago, the RedHat Linux (way before RHEL) installer > (which was written in Python) was called Anaconda. > That would have been about the time I switched from RH to SuSE. I forget the details but RH 'enhanced' Python for their own ends and broke some of our standard Python. That was the same era when they released gcc 2.96 that wasn't a FSF release and had problems. Bleeding edge is fine if that's what you've signed up for but I prefer a little stability. From bowman at montana.com Sun Jan 6 20:30:00 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 18:30:00 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> Message-ID: On 01/03/2019 10:08 PM, Stefan Ram wrote: > DL Neil writes: >> Thus the OP's original assumption/confusion between a programming >> language and a serpent; Java and a large island; right down to C, R, etc >> which are too short to be usable search terms in most engines. > > And still, you enter "Ant" into a good Web search engine, > and you get exactly the sensible first hit: > > Apache Ant - Welcome > https://ant.apache.org/ Depending on what you call a good search engine... It's third on DuckDuckGo, second on Bing. From bowman at montana.com Sun Jan 6 20:34:18 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 18:34:18 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> Message-ID: On 01/04/2019 09:06 AM, William Ray Wing wrote: > On 3/01/19 2:03 PM, Avi Gross wrote: >> Challenge: Can we name any computer language whose name really would suggest it was a computer language? >> I think the name is the least important aspect of a computer language. > > I?d like to propose that classic FORTRAN (FORmulaTRANslator) came/comes close. While that was the first language I learned, I'll have to give the nod to PL/I -- Programming Language One and its child PL/M, Programming Language for Microrocessors as well as the somewhat strange APL A Programming Language From bowman at montana.com Sun Jan 6 20:52:54 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 18:52:54 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> Message-ID: On 01/04/2019 09:34 AM, Avi Gross wrote: > Although I used FORTRAN ages ago and it still seems to be in active use, I am not clear on why the name FORMULA TRANSLATOR was chosen. I do agree it does sound more like a computer language based on both the sound and feel of FORTRAN as well as the expanded version. It made sense at the time. I first learned FORTRAN in 1965 in engineering school. At that time 'computer science' was in its infancy and our everyday tool was a slide rule. The computer, an IBM System 360/30, was seen as another useful tool and engineers should learn to translate their formulas into a form acceptable to it. You wrote your efforts on coding forms, laboriously transferred those to punch cards, and offered your deck up to the priests who fed it to the god visible behind plate glass in his air conditioned lair. http://www.lib.rpi.edu/dept/library/html/Archives//buildings/chapel.html When I was there the chapel was still the library and the computer was in a modern building but finally the new god was moved to a suitable house. From bowman at montana.com Sun Jan 6 21:31:29 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 19:31:29 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> Message-ID: On 01/04/2019 11:17 AM, Dennis Lee Bieber wrote: > One would > turn in a deck of cards to be spooled in the job queue, and come back some > hours later to get the printout from the job. Or, in most cases, obscure compiler errors because you forget the continuation punch in column 6. Back to the keypunch room and resubmit. From loganvogelsong at gmail.com Sun Jan 6 21:56:57 2019 From: loganvogelsong at gmail.com (Logan Vogelsong) Date: Sun, 6 Jan 2019 21:56:57 -0500 Subject: Deletion of Environmental Variables Message-ID: Hello- I think I subscribed now. I planned on using python to simulate different cipher to challenge myself, but I kinda deleted my environmental variables to python. I run Windows 10 and wanted to get NumPy and MatPlotLib modules imported to python. Basically, I downloaded python 3.7.1 first, but when I realized it was not compatible with TensorFlow (I wanted to make a machine learning algorithm at a point in time), I uninstalled it to get python 3.6.1. Somehow, maybe I misread a stack overflow post, but I deleted all my path files to python36 for whatever reason. I still have no idea why I did this. Then, I thought, if I could uninstall python 3.6.1 and reinstall it pip would come back and I could use python from the cmd. I uninstalled it and tried reinstalling (with chocolatey this time) it for no avail. I tried searching for all the correct environment variables to put them back in manually, but I cannot seem to find most of them since python is still ?not recognized as an internal or external command, operable program or batch file.? In my cmd. I really want pip to work so I can download modules. I may follow: https://stackoverflow.com/questions/4750806/how-do-i-install-pip-on-windows to try and help reinstall pip and I may redownload it through: https://pypi.org/project/pip/#files with help from: https://pypi.org/project/setuptools/#files As an aside, I have so far taught myself everything I know about python, and I am willing to learn even more. Thank you for any help, Logan Vogelsong From bowman at montana.com Sun Jan 6 20:25:06 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 18:25:06 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <006d01d4a384$dd687cd0$98397670$@verizon.net> <201901031440.09090.gheskett@shentel.net> <003301d4a3c4$cf738940$6e5a9bc0$@verizon.net> Message-ID: On 01/03/2019 05:31 PM, Avi Gross wrote: > Why did I mention Anaconda? Because python is also the name of a snake and > some people considered it appropriate to name their pet project that > includes python, as the name of another snake: Probably not politically correct to mention but Colt had seven snake revolvers if you count the specialty Boa. The Anaconda was the last one but the Python was the most popular and fetches ridiculous prices today. Cobra and Boa are programming languages and there was an abandoned attempt at Viper, but I don't think anyone has grabbed Diamondback yet. (King Cobra is the 7th Colt snake but I'll count plain Cobra as close enough) From bowman at montana.com Sun Jan 6 20:27:17 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 18:27:17 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> Message-ID: On 01/03/2019 09:53 PM, DL Neil wrote: > Thus the OP's original assumption/confusion between a programming > language and a serpent; Java and a large island; right down to C, R, etc > which are too short to be usable search terms in most engines. C# wins the prize for not getting what you expect in a search engine. From bowman at montana.com Sun Jan 6 21:25:10 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 19:25:10 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> Message-ID: On 01/04/2019 10:45 AM, Peter J. Holzer wrote: > FORTRAN is older than most of us. So it influenced what we think a > computer language should sound like. Sadly, not for all of us... FORTRAN seeded later languages with terms that are obscure, like rewind(). A blazing powerhouse like the IBM System 360/30 had at most 64k of core, and by that I mean real magnetic core knit by little old ladies. It also had massive tape drives. By massive I mean 1/2" tape on 10" spools, not that they could hold that much data. Anyway for something like a Fast Fourier you wrote a partial products to tape, rewound the tape, took another pass, rinse and repeat. It was a joy. While FORTRAN definitely had some influence, particularly on BASIC, don't give it too much credit. It had little gems like the computed goto. It took until Fortran 90 to allow such novelties as lower case and free form input. Prior to that it still assumed you were using Hollerith cards. I don't think it ever moved beyond the DO loop. From bowman at montana.com Sun Jan 6 21:35:50 2019 From: bowman at montana.com (rbowman) Date: Sun, 6 Jan 2019 19:35:50 -0700 Subject: Recommendations for a novice user. In-Reply-To: References: Message-ID: On 01/02/2019 05:14 AM, H?seyin Ertu?rul wrote: > I don't know the software language at all. What do you recommend to beginners to learn Python. > What should be the working systematic? How much time should I spend every day or how much time should I spend on a daily basis. As much time as you can stand. If you want to make a career of software you will be studying for the rest of your life. Get used to it. From tjreedy at udel.edu Mon Jan 7 01:18:04 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Jan 2019 01:18:04 -0500 Subject: Compilation In-Reply-To: <009401d4a616$7990efa0$6cb2cee0$@verizon.net> References: <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> <20190106122615.dchsvji7t3qw4kbr@hjp.at> <7mi43etjvc1s3fiebt7csenu8elcnqjeii@4ax.com> <20190106193219.6afzmvkeii2e52hv@hjp.at> <005c01d4a5fb$c232a3e0$4697eba0$@verizon.net> <20190106222508.e7c4572wpwze7ord@hjp.at> <009401d4a616$7990efa0$6cb2cee0$@verizon.net> Message-ID: On 1/6/2019 6:20 PM, Avi Gross wrote: > I suspect there is some python tool that can go through a directory > structure of python code and produce appropriate byte code files in one > sweep. import compileall help(compileall) The Windows installer optionally runs it. It is usually needed if one does an all-users install into Program Files, as non-admin users cannot cause .pyc files to be writen therein. -- Terry Jan Reedy From tjreedy at udel.edu Mon Jan 7 01:34:36 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Jan 2019 01:34:36 -0500 Subject: Deletion of Environmental Variables In-Reply-To: References: Message-ID: On 1/6/2019 9:56 PM, Logan Vogelsong wrote: > I planned on using python to simulate different cipher to challenge myself, > but I kinda deleted my environmental variables to python. I run Windows 10 > and wanted to get NumPy and MatPlotLib modules imported to python. > > Basically, I downloaded python 3.7.1 first, but when I realized it was not > compatible with TensorFlow (I wanted to make a machine learning algorithm > at a point in time), I uninstalled it to get python 3.6.1. Windows easily allows multiple versions to be installed. The py launcher lets you easily pick which to run (from a command console). For 3.6, use the latest release, now 3.6.8, which has hundreds of fixes since 3.6.1. If you have multiple versions, you must install 3rd party modules for each version you want to import them into. Somehow, maybe I > misread a stack overflow post, but I deleted all my path files to python36 > for whatever reason. I still have no idea why I did this. Then, I thought, > if I could uninstall python 3.6.1 and reinstall it pip would come back and > I could use python from the cmd. I uninstalled it and tried reinstalling > (with chocolatey this time) it for no avail. I tried searching for all the > correct environment variables to put them back in manually, but I cannot > seem to find most of them since python is still ?not recognized as an > internal or external command, operable program or batch file.? There is, or at least used to be, an option to add the python directly to PATH. But using py instead python is needed anyway to select from multiple versions. > In my cmd. I really want pip to work so I can download modules. By default, the PSF Windows installer installs pip, using the ensurepip module. If this did not happen, you can run it yourself. See https://docs.python.org/3/library/ensurepip.html The pydev recommended way to run pip on windows is > py -x.y pip as this installs the package requested into the x.y site-packages directory. -- Terry Jan Reedy From p.f.moore at gmail.com Mon Jan 7 02:47:11 2019 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 7 Jan 2019 07:47:11 +0000 Subject: Deletion of Environmental Variables In-Reply-To: References: Message-ID: On Mon, 7 Jan 2019 at 06:37, Terry Reedy wrote: > The pydev recommended way to run pip on windows is > > py -x.y pip > as this installs the package requested into the x.y site-packages > directory. py -3.7 -m pip ... Note the extra -m). Paul From PythonList at DancesWithMice.info Mon Jan 7 02:32:18 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 7 Jan 2019 20:32:18 +1300 Subject: Recommendations for a novice user. In-Reply-To: References: Message-ID: <1cc164d3-859f-dbb5-4e92-3317168a287c@DancesWithMice.info> H?seyin, On 7/01/19 3:35 PM, rbowman wrote: > On 01/02/2019 05:14 AM, H?seyin Ertu?rul wrote: >> I don't know the software language at all. What do you recommend to >> beginners to learn Python. >> What should be the working systematic? How much time should I spend >> every day or how much time should I spend on a daily basis. > > As much time as you can stand. If you want to make a career of software > you will be studying for the rest of your life. Get used to it. That comment is correct. Python has many facets and is used in many application-areas - some of which are quite different from any of the others. Professionals in each area use Python, but they use the same language in quite a different way from others. To answer your question: it depends a little upon how you learn! Some people prefer books, others go to in-person classes. You might like to check-out Coursera.com for on-line courses. There are a couple of ($free) basic Python courses available from U.Mich, including one from the venerable "Dr Chuck". You will also find plenty of web-sites and other organisations offering Python training or discussing particular facilities of the language. Your search engine is your friend. If you (first) choose one, others here may be able to advise you, based upon their personal experience. Returning to your previous respondent: the ONLY method of learning Python is to write Python code - so don't rush any course or reading, take the time to prove that you can perform every single step. (even if only proving to yourself!) All the best... -- Regards =dn From info at egenix.com Mon Jan 7 08:16:40 2019 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Mon, 7 Jan 2019 14:16:40 +0100 Subject: =?UTF-8?Q?ANN:_Python_Meeting_D=c3=bcsseldorf_-_09.01.2019?= Message-ID: <25df66a0-21d5-8b3c-776c-a48129a29f95@egenix.com> [This announcement is in German since it targets a local user group meeting in D?sseldorf, Germany] ________________________________________________________________________ ANK?NDIGUNG Python Meeting D?sseldorf http://pyddf.de/ Ein Treffen von Python Enthusiasten und Interessierten in ungezwungener Atmosph?re. Mittwoch, 09.01.2019, 18:00 Uhr Raum 1, 2.OG im B?rgerhaus Stadtteilzentrum Bilk D?sseldorfer Arcaden, Bachstr. 145, 40217 D?sseldorf Diese Nachricht ist auch online verf?gbar: https://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2019-01-09 ________________________________________________________________________ NEUIGKEITEN * Bereits angemeldete Vortr?ge: Ulf Morys "Stack und Unstack mit Pandas Dataframes" Detlef Lannert "Data classes in Python 3.7" Charlie Clark "Using Bitbucket Pipelines for your projects" Charlie Clark "Performance: Doing even more nothing & Cythonize" Dominic Geldmacher "Buchrezension: Data Science Handbook" Weitere Vortr?ge k?nnen gerne noch angemeldet werden: info at pyddf.de * Startzeit und Ort: Wir treffen uns um 18:00 Uhr im B?rgerhaus in den D?sseldorfer Arcaden. Das B?rgerhaus teilt sich den Eingang mit dem Schwimmbad und befindet sich an der Seite der Tiefgarageneinfahrt der D?sseldorfer Arcaden. ?ber dem Eingang steht ein gro?es "Schwimm' in Bilk" Logo. Hinter der T?r direkt links zu den zwei Aufz?gen, dann in den 2. Stock hochfahren. Der Eingang zum Raum 1 liegt direkt links, wenn man aus dem Aufzug kommt. Google Street View: http://bit.ly/11sCfiw ________________________________________________________________________ EINLEITUNG Das Python Meeting D?sseldorf ist eine regelm??ige Veranstaltung in D?sseldorf, die sich an Python Begeisterte aus der Region wendet: * http://pyddf.de/ Einen guten ?berblick ?ber die Vortr?ge bietet unser YouTube-Kanal, auf dem wir die Vortr?ge nach den Meetings ver?ffentlichen: * http://www.youtube.com/pyddf/ Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting & Research, D?sseldorf: * http://www.egenix.com/ * http://www.clark-consulting.eu/ ________________________________________________________________________ PROGRAMM Das Python Meeting D?sseldorf nutzt eine Mischung aus (Lightning) Talks und offener Diskussion. Vortr?ge k?nnen vorher angemeldet werden, oder auch spontan w?hrend des Treffens eingebracht werden. Ein Beamer mit XGA Aufl?sung steht zur Verf?gung. (Lightning) Talk Anmeldung bitte formlos per EMail an info at pyddf.de ________________________________________________________________________ KOSTENBETEILIGUNG Das Python Meeting D?sseldorf wird von Python Nutzern f?r Python Nutzer veranstaltet. Um die Kosten zumindest teilweise zu refinanzieren, bitten wir die Teilnehmer um einen Beitrag in H?he von EUR 10,00 inkl. 19% Mwst, Sch?ler und Studenten zahlen EUR 5,00 inkl. 19% Mwst. Wir m?chten alle Teilnehmer bitten, den Betrag in bar mitzubringen. ________________________________________________________________________ ANMELDUNG Da wir nur f?r ca. 20 Personen Sitzpl?tze haben, m?chten wir bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung eingegangen. Es erleichtert uns allerdings die Planung. Meeting Anmeldung bitte formlos per EMail an info at pyddf.de ________________________________________________________________________ WEITERE INFORMATIONEN Weitere Informationen finden Sie auf der Webseite des Meetings: http://pyddf.de/ Mit freundlichen Gr??en, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, Jan 07 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 dboland9 at offilive.com Mon Jan 7 09:51:49 2019 From: dboland9 at offilive.com (Dave) Date: Mon, 7 Jan 2019 09:51:49 -0500 Subject: Kivy native GUI examples Message-ID: I need to select a Python GUI. It needs to cover all of the desktops (Linux, Windows, Apple) and hopefully mobile (Android and Ios). I'm looking at Kivy, but have yet to find an example app. that has a native looking GUI (Windows, Mac, Linux/Gnome/KDE). Is that possible and anyone know of some examples? Thanks, Dave From tjol at tjol.eu Mon Jan 7 11:14:23 2019 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 7 Jan 2019 17:14:23 +0100 Subject: Kivy native GUI examples In-Reply-To: References: Message-ID: On 07/01/2019 15.51, Dave wrote: > I need to select a Python GUI.? It needs to cover all of the desktops > (Linux, Windows, Apple) and hopefully mobile (Android and Ios).? I'm > looking at Kivy, but have yet to find an example app. that has a native > looking GUI (Windows, Mac, Linux/Gnome/KDE).? Is that possible and > anyone know of some examples? AFAIK looking like a native app is quite simply not something Kivy helps you with. If that's important, you should look into other options such as Qt (PyQt5 or PySide2). -- Thomas From tjol at tjol.eu Mon Jan 7 11:14:23 2019 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 7 Jan 2019 17:14:23 +0100 Subject: Kivy native GUI examples In-Reply-To: References: Message-ID: <9aa167a3-1e82-4f5d-dcd5-cd8c9399222b@tjol.eu> On 07/01/2019 15.51, Dave wrote: > I need to select a Python GUI.? It needs to cover all of the desktops > (Linux, Windows, Apple) and hopefully mobile (Android and Ios).? I'm > looking at Kivy, but have yet to find an example app. that has a native > looking GUI (Windows, Mac, Linux/Gnome/KDE).? Is that possible and > anyone know of some examples? AFAIK looking like a native app is quite simply not something Kivy helps you with. If that's important, you should look into other options such as Qt (PyQt5 or PySide2). -- Thomas From dboland9 at offilive.com Mon Jan 7 13:13:08 2019 From: dboland9 at offilive.com (Dave) Date: Mon, 7 Jan 2019 13:13:08 -0500 Subject: Kivy native GUI examples References: <9aa167a3-1e82-4f5d-dcd5-cd8c9399222b@tjol.eu> Message-ID: On 1/7/19 11:14 AM, Thomas Jollans wrote: > On 07/01/2019 15.51, Dave wrote: >> I need to select a Python GUI.? It needs to cover all of the desktops >> (Linux, Windows, Apple) and hopefully mobile (Android and Ios).? I'm >> looking at Kivy, but have yet to find an example app. that has a native >> looking GUI (Windows, Mac, Linux/Gnome/KDE).? Is that possible and >> anyone know of some examples? > > AFAIK looking like a native app is quite simply not something Kivy helps > you with. If that's important, you should look into other options such > as Qt (PyQt5 or PySide2). > > > -- Thomas > Thanks Thomas. From python at bdurham.com Mon Jan 7 13:51:30 2019 From: python at bdurham.com (Malcolm Greene) Date: Mon, 07 Jan 2019 11:51:30 -0700 Subject: Normalizing path strings and separators in cross-platform unit test scripts Message-ID: <1546887090.1165131.1627958456.3F172B66@webmail.messagingengine.com> Any recommendations on normalizing path strings in cross platform (Windows, Linux, macOS) for unit tests? Our goal is to normalize path strings to use forward slash separators so that we can consistently reference path strings in our unit tests in a cross platform way. Example: Under Windows we have two paths that are logically the same but fail to match for test purposes. assert str(full_path(f'{test_folder_path}/readonly.txt')) == 'C:/udp-app- master/dev/tmp/readonly.txt'E AssertionError: assert 'C:\\udp-app-...\readonly.txt' == 'C:/udp-app- ma.../readonly.txt' Is there a best practice way to convert Windows style paths (with backslash path separators) to Linux style paths with forward slash path separators? I've looked at the os and pathlib libraries without seeing anything that describes our need. Any downsides to this approach? Thank you From rosuav at gmail.com Mon Jan 7 13:56:37 2019 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jan 2019 05:56:37 +1100 Subject: Normalizing path strings and separators in cross-platform unit test scripts In-Reply-To: <1546887090.1165131.1627958456.3F172B66@webmail.messagingengine.com> References: <1546887090.1165131.1627958456.3F172B66@webmail.messagingengine.com> Message-ID: On Tue, Jan 8, 2019 at 5:52 AM Malcolm Greene wrote: > > Any recommendations on normalizing path strings in cross platform > (Windows, Linux, macOS) for unit tests? > Our goal is to normalize path strings to use forward slash separators so > that we can consistently reference path strings in our unit tests in a > cross platform way. > Example: Under Windows we have two paths that are logically the same but fail to match for test purposes. > assert str(full_path(f'{test_folder_path}/readonly.txt')) == 'C:/udp-app- > master/dev/tmp/readonly.txt'E AssertionError: assert 'C:\\udp-app-...\readonly.txt' == 'C:/udp-app- > ma.../readonly.txt' > Is there a best practice way to convert Windows style paths (with > backslash path separators) to Linux style paths with forward slash path > separators? I've looked at the os and pathlib libraries without seeing > anything that describes our need. > Any downsides to this approach? If you are confident you'll never have an actual backslash in a path name (which would be a requirement if they're cross-platform anyway), you could just p.replace("\\", "/") to convert them. I don't think that will break anything on any Windows-based or Unix-based OS (could be wrong of course). ChrisA From PythonList at DancesWithMice.info Mon Jan 7 15:07:18 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 8 Jan 2019 09:07:18 +1300 Subject: the python name In-Reply-To: <005c01d4a5fb$c232a3e0$4697eba0$@verizon.net> References: <20190104095828.awbiqty6ekhenz53@hjp.at> <8cj4gf-2ai.ln1@anthive.com> <20190106122615.dchsvji7t3qw4kbr@hjp.at> <7mi43etjvc1s3fiebt7csenu8elcnqjeii@4ax.com> <20190106193219.6afzmvkeii2e52hv@hjp.at> <005c01d4a5fb$c232a3e0$4697eba0$@verizon.net> Message-ID: <8a4bd975-66cf-03ff-12a8-a57b28f2673a@DancesWithMice.info> On 7/01/19 9:09 AM, Avi Gross wrote: > [Can we ever change the subject line?] > {REAL SUBJECT: degrees of compilation.} > Peter wrote: > > "... > Hoever, this is the Python list and one of the advantages of Python is that we don't have to compile our code. So we need a different excuse for fencing on office chairs ;-). > ..." You had time for that? We had to move to working on program-B whilst awaiting the compile-print-return of program-A - sometimes even system/application-B! In some respects I think the imposed compartmentalisation of one's work was a positive aspect. We concentrated on ensuring that solid progress was made, run by run - whereas the ease and simplicity of making small changes (one after the other) can easily consume tracts of time. (at some risk) We would try to foresee problems, and ensure that the code would 'continue to work' rather than falling at the first hurdle. On the other hand, once the batch was "submitted", we could completely drop that program's concerns from our minds. At times a massive stress reduction (hence the sword play?), and a good way to approach the next task with a constructive (?and less-cluttered) mind. YMMV! > I won't share my own war stories of how to compile in what now seem primitive environments on overloaded machines where you often figured out your mistakes on paper before the compiler quit and showed you officially ? Ah yes, the ?good, old days when computers were powered by dinosaurs running in treadmills... It wasn't that the machine was overloaded so much, more that the Ops staff were charged with 'making efficient use of the machine' - that is to say, the 40~45% of CPU time that IBM didn't take to run the OpSys. Accordingly, our batch-compile jobs went into a long queue, just so that the machine could attend to them when it had some 'spare' capacity. Since then, Moore's law etc, the economics have changed and the cost of programmer time is prioritised over computing costs. This became a paradigm-shift for me, because my (?junior) colleagues enacted a philosophy of 'throw it at the machine and let the real-time/time-sharing mini-computer/PC test it for you' (if only). Initially this seemed a scandalous waste of resources, but was also 'the way of the future'. However, with large programs and poor test methods, using the above 'machine as tester' idea, the costs of running a series of 'long' tests with only minor changes between soon exposes economic limits! So, I've never quite lost that habit of <<>>. That said, the tenets of Test-driven development continue to erode my conservatism/appeal to my inherent laziness... Conversely, I have been (admittedly, rather quickly) auditing a Coursera MOOC series (Python 3 Programming Specialisation = five courses, out of U.Mich). Without commenting on their pedagogical success or otherwise, I was struck by their presenting the idea of a 'paper computer'* - even having an 'intelligent text book' tool to demonstrate step-wise execution of code. (without having to introduce the complexities of a debugger) It is a good way to help new-comers understand the relationships between a variable's name, its value, its type, its mutability, etc, etc - which (IIRC) is where they introduced the idea. However, later lessons have included exhortations to review that new work, using the 'paper computer' technique. * apologies: this is the term I learned (all those years ago, mumble, mumble) and I'm quite sure they have a different name. The essence is the same. I'm only about 40% through the courses, and will be interested to see if they continue to refer to the technique as code-complexity builds... -- Regards =dn From PythonList at DancesWithMice.info Mon Jan 7 15:36:01 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 8 Jan 2019 09:36:01 +1300 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> Message-ID: On 7/01/19 2:52 PM, rbowman wrote: > On 01/04/2019 09:34 AM, Avi Gross wrote: >> Although I used FORTRAN ages ago and it still seems to be in active >> use, I am not clear on why the name FORMULA TRANSLATOR was chosen. I >> do agree it does sound more like a computer language based on both the >> sound and feel of FORTRAN as well as the expanded version. > > It made sense at the time. I first learned FORTRAN in 1965 in > engineering school. At that time 'computer science' was in its infancy > and our everyday tool was a slide rule. The computer, an IBM System > 360/30, was seen as another useful tool and engineers should learn to > translate their formulas into a form acceptable to it. You wrote your > efforts on coding forms, laboriously transferred those to punch cards, > and offered your deck up to the priests who fed it to the god visible > behind plate glass in his air conditioned lair. Prior to FORTRAN, particularly in the pre-360 IBM mainframe world, the only choice was Assembler - a 'language' which was merely a one-to-one restatement of machine instructions in an acronym-like form. The issue was that every machine type's instruction set was different and consequently every Assembly language was different, ie there was no ONE Assembler 'language'. System/360 changed all that. (Brooks's book "The Mythical Man-Month" is still a recommended text and a salutary tale) Now we had a series of machines, at different sizes (the 360-30 was towards the bottom-end, or one of the early sales - depending upon when in the time-line you look), but as far as software was concerned, one machine behaved like the next. (and IBM very much hoped that we would 'grow' and thus regularly need to upgrade the processor - as well as adding peripherals... An IBM salesman was not just for Christmas, he was for life!) This practicality fuelled the (international) standards effort. It became possible to have a (single understanding of) FORTRAN (others have noted that there were in fact, implementational differences and matters of scale), CODASYL went nuts with COBOL, and so-on (Ada anyone?). Also, we had manufacturers attempting to impose, um, create a de-facto 'standard', eg IBM and PL/1 - nothing like the behaviors of today's Googles, Microsofts, Apples, etc; of course... Back to software, languages, and specifically Assembler: every computation had to be broken down and coded as individual "low-level" instructions: load 2 into register-A load 3 into register-B add register-B into register-A (note the lack of variable names, also pre-dating the ideas of stack-architecture and modern/Intel CPUs!) After Assembler, FORTRAN 'made all our dreams came true', because we were able to write the likes of: PI = 3.14159 AREA = PI * RADIUS * RADIUS Can you see the step 'up' to the *formula* part! Then, we would run our FORTRAN source-code through the *translator* (later the generic term became "compiler"). It would translate our code into assembler/machine code (varying by machine), saving us from the more laborious and pedantic task of expressing ourselves at that level. Oh the relief! -- Regards =dn From PythonList at DancesWithMice.info Mon Jan 7 16:10:13 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 8 Jan 2019 10:10:13 +1300 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> Message-ID: <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> On 7/01/19 3:25 PM, rbowman wrote: > On 01/04/2019 10:45 AM, Peter J. Holzer wrote: >> FORTRAN is older than most of us. So it influenced what we think a >> computer language should sound like. > > Sadly, not for all of us...? FORTRAN seeded later languages with terms > that are obscure, like rewind().? A blazing powerhouse like the IBM Why is that obscure? It makes perfect sense - to those of us who have used tape/serial storage! Perhaps less-so to [bobble-heads], sorry I mean people who grew-up with 'bubble memory' (Memory sticks, 'flash drives', SSDs). In point-of-fact, Python Context Managers Whilst Python docs and tutorials usually make the opposite point: that once a file/context has been read, it is "exhausted" and to continue is illogical; don't forget that there is still seek() which does indeed enable a "rewind"! By the same token what thoughts does this sort of code induce? print( f'The magic number is {result}. So there!' ) Why "print"? I thought I was displaying something on the screen (indeed STDIO might go to a file, eg log-like). Whither print? Reminds me of the person who upon being told to move his mouse to the top of the screen, picking-up the device and raised it from the desk surface. Made sense to him! Similarly, one team I joined used Sublime Text for coding. I was happy to adapt until I wanted to 'print' my source-code (even though "line-flow" stationery is harder to source these days). There is no print function in that package! ... > free form input. Prior to that it still assumed you were using Hollerith > cards. I don't think it ever moved beyond the DO loop. ...and yet PEP-8 and countless 'style guides' maintain the 80 (actually 72 and 79 to be hob-goblin-ish) which I'm quite sure has nothing to do with machine-sizes or relationships to a (single/one, US) dollar bill! Refs: https://en.wikipedia.org/wiki/Bobblehead https://en.wikipedia.org/wiki/Punched_card https://www.python.org/dev/peps/pep-0008/#maximum-line-length https://docs.python.org/3.6/tutorial/inputoutput.html -- Regards =dn From dboland9 at offilive.com Mon Jan 7 17:17:37 2019 From: dboland9 at offilive.com (Dave) Date: Mon, 7 Jan 2019 17:17:37 -0500 Subject: System printer object Message-ID: I need to print to one or both of my system printers. I have not found a printer object in Python or in Tkinter. This needs to work with Linux, Window, and Mac. Can someone point me in the right direction? Ultimately, I want to have a File/Print in the menu that lets me select the printer and properties. Thanks, Dave From python at mrabarnett.plus.com Mon Jan 7 18:33:55 2019 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 7 Jan 2019 23:33:55 +0000 Subject: the python name In-Reply-To: References: <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> Message-ID: <09acc58f-9d66-0a8f-b3c9-31c5dbb382cd@mrabarnett.plus.com> On 2019-01-07 23:04, Dennis Lee Bieber wrote: > On Tue, 8 Jan 2019 10:10:13 +1300, DL Neil > declaimed the following: > >> >>Why is that obscure? It makes perfect sense - to those of us who have >>used tape/serial storage! Perhaps less-so to [bobble-heads], sorry I >>mean people who grew-up with 'bubble memory' (Memory sticks, 'flash >>drives', SSDs). In point-of-fact, Python Context Managers >> > Apologies, but "bubble memory" is something completely different -- > using movable magnetic domains rather than capacitive charged bits. > > https://en.wikipedia.org/wiki/Bubble_memory > >> >>Why "print"? I thought I was displaying something on the screen (indeed >>STDIO might go to a file, eg log-like). Whither print? >> > Using the wrong language then... COBOL has DISPLAY > > Why "print" -- least surprise! Languages back to FORTRAN (and predating > terminals) had "print" as the quick&dirty output statement (vs the more > complex formatted output). FORTRAN, BASIC, Pascal, probably Modula-2. > [snip] Pascal has Write and WriteLn, and Modula 2 has variations on Write*, such as WriteString and WriteInt. From cspealma at redhat.com Mon Jan 7 18:21:16 2019 From: cspealma at redhat.com (Calvin Spealman) Date: Mon, 7 Jan 2019 18:21:16 -0500 Subject: System printer object In-Reply-To: References: Message-ID: Neither Python nor Tkinter include interface libraries to talk to hardware printers out of the box, but a number of libraries and methods exist depending on your platform. Both Wx and Qt, UI toolkits with great Python bindings, do support printers to one degree or another, although I don't know how difficult these are to work with. Either may offer good options, or at least a starting point, if you look at the wxPython and/or PyQt libraries. On Mon, Jan 7, 2019 at 5:20 PM Dave wrote: > I need to print to one or both of my system printers. I have not found > a printer object in Python or in Tkinter. This needs to work with > Linux, Window, and Mac. Can someone point me in the right direction? > Ultimately, I want to have a File/Print in the menu that lets me select > the printer and properties. > > Thanks, > Dave > -- > https://mail.python.org/mailman/listinfo/python-list > -- CALVIN SPEALMAN SENIOR QUALITY ENGINEER cspealma at redhat.com M: +1.336.210.5107 TRIED. TESTED. TRUSTED. From bob at mellowood.ca Mon Jan 7 19:14:14 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Mon, 7 Jan 2019 17:14:14 -0700 Subject: Are all items in list the same? Message-ID: I need to see if all the items in my list are the same. I was using set() for this, but that doesn't work if items are themselves lists. So, assuming that a is a list of some things, the best I've been able to come up with it: if a.count( targ ) == len(a): I'm somewhat afraid that this won't scale all that well. Am I missing something? -- **** 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 python at mrabarnett.plus.com Mon Jan 7 19:52:59 2019 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 8 Jan 2019 00:52:59 +0000 Subject: Are all items in list the same? In-Reply-To: References: Message-ID: On 2019-01-08 00:14, Bob van der Poel wrote: > I need to see if all the items in my list are the same. I was using set() > for this, but that doesn't work if items are themselves lists. So, assuming > that a is a list of some things, the best I've been able to come up with it: > > if a.count( targ ) == len(a): > > I'm somewhat afraid that this won't scale all that well. Am I missing > something? > How about this: all(item == my_list[0] for item in my_list) From ike at koeln.ccc.de Mon Jan 7 19:47:04 2019 From: ike at koeln.ccc.de (ike at koeln.ccc.de) Date: Tue, 8 Jan 2019 01:47:04 +0100 Subject: Are all items in list the same? In-Reply-To: References: Message-ID: <20190108004704.GA8694@ma.tura-home.de> You might do something like if len(a) == 0 or all(i == a[0] for i in a[1:]): This should be linear complexity and short circuiting and in general it doesn't get much better than this. Though I wouldn't bet there isn't a better (faster/clearer/more readable) solution. On Mon, Jan 07, 2019 at 05:14:14PM -0700, Bob van der Poel wrote: > I need to see if all the items in my list are the same. I was using set() > for this, but that doesn't work if items are themselves lists. So, assuming > that a is a list of some things, the best I've been able to come up with it: > > if a.count( targ ) == len(a): > > I'm somewhat afraid that this won't scale all that well. Am I missing > something? From cs at cskk.id.au Mon Jan 7 20:10:14 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 8 Jan 2019 12:10:14 +1100 Subject: Are all items in list the same? In-Reply-To: References: Message-ID: <20190108011014.GA54808@cskk.homeip.net> On 07Jan2019 17:14, bvdp wrote: >I need to see if all the items in my list are the same. I was using set() >for this, but that doesn't work if items are themselves lists. So, assuming >that a is a list of some things, the best I've been able to come up with it: > > if a.count( targ ) == len(a): > >I'm somewhat afraid that this won't scale all that well. Am I missing >something? This can be inefficient and probably will be in real life. For the "true" case (all elements == targ), this is ok - you cannot know they are all equal without examining every element. But it is very inefficient for the false case (not all items == targ) because it compares all the items, even if some items have already compared unequal. (It compares them all because it must _count_ the later equal items, regardless of how many earlier items are unequal). Because this feels like a homework exercise, we generally offer advice and suggestions, thus the nature of the discussion which follows. The immediate approach is to not use .count and instead just write a "for" look which compares each array item in turn, and importantly _breaks out of the loop_ as soon as it sees an unequal value. You might set a flag (Boolean value) to True, then test the elements: when one is unequal, set the flag to False and break from the loop. After the loop, the flag will indicate whether all were equal. Give that a try. _After_ that, once you understand the logic, you could consider the built functions Python comes with. You might look at the builtin "all" function; its help is like this: >>> help(all) Help on built-in function all in module builtins: all(iterable, /) Return True if bool(x) is True for all values x in the iterable. If the iterable is empty, return True. It doesn't say so, but it will return as soon as it hits a false item from the iterable. So you need to take your list "a" and produce an iterable of True or False depending on whether the element is equal to your test argument. The tricky bit is to make "iterable" lazy: an actual iterator which only yields values as required. For example, this list comprehension: [ elem == targ for elem in a ] computes the _complete_ list of true/false values and returns a list. So passing that to all() does not improve efficiency because for a long list it still examines every element even if an early element is unequal. Instead you should look at writing a generator expression or function, which all() can iterate over: these things only advance as they are asked for a value, and so if all() stops early, the generator also does not run to completion and so does not uselessly examine the entire list. Cheers, Cameron Simpson From python.list at tim.thechases.com Mon Jan 7 20:03:07 2019 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 7 Jan 2019 19:03:07 -0600 Subject: Are all items in list the same? In-Reply-To: References: Message-ID: <20190107190307.459cb3db@bigbox.christie.dr> On 2019-01-07 17:14, Bob van der Poel wrote: > I need to see if all the items in my list are the same. I was using > set() for this, but that doesn't work if items are themselves > lists. So, assuming that a is a list of some things, the best I've > been able to come up with it: > > if a.count( targ ) == len(a): > > I'm somewhat afraid that this won't scale all that well. Am I > missing something? Since python2.5 you've had any() and all() functions that make this pretty tidy and they bail early if proven to not be the case (so if you have hundreds of thousands of items in the list and you know by the 2nd one that they're not equal, you don't have to touch hundreds of thousands of items; just the first two). So I'd do something like def all_equal(iterable): i = iter(iterable) first = next(i) return all(x == first for x in i) It's undefined for an empty list (well, it throws a StopIteration but you can special-case that), but should hand the cases with 1 element and 2+ elements (both matching and where any item is not the same). It should work on an iterator as well but will consume the items in the process. And I even like how nicely it reads :-) -tkc From rosuav at gmail.com Mon Jan 7 20:28:46 2019 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jan 2019 12:28:46 +1100 Subject: Are all items in list the same? In-Reply-To: <20190107190307.459cb3db@bigbox.christie.dr> References: <20190107190307.459cb3db@bigbox.christie.dr> Message-ID: On Tue, Jan 8, 2019 at 12:26 PM Tim Chase wrote: > def all_equal(iterable): > i = iter(iterable) > first = next(i) > return all(x == first for x in i) > > And I even like how nicely it reads :-) Yes, there's something beautiful about writing "first = next" :-) ChrisA From python at mrabarnett.plus.com Mon Jan 7 20:45:51 2019 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 8 Jan 2019 01:45:51 +0000 Subject: Are all items in list the same? In-Reply-To: <20190108004704.GA8694@ma.tura-home.de> References: <20190108004704.GA8694@ma.tura-home.de> Message-ID: On 2019-01-08 00:47, ike at koeln.ccc.de wrote: > You might do something like > > if len(a) == 0 or all(i == a[0] for i in a[1:]): > You don't need to check the length of the list because if the list is empty, 'all' will return True anyway. > This should be linear complexity and short circuiting and in general it > doesn't get much better than this. Though I wouldn't bet there isn't a > better (faster/clearer/more readable) solution. > > On Mon, Jan 07, 2019 at 05:14:14PM -0700, Bob van der Poel wrote: >> I need to see if all the items in my list are the same. I was using set() >> for this, but that doesn't work if items are themselves lists. So, assuming >> that a is a list of some things, the best I've been able to come up with it: >> >> if a.count( targ ) == len(a): >> >> I'm somewhat afraid that this won't scale all that well. Am I missing >> something? > From skip.montanaro at gmail.com Mon Jan 7 21:01:39 2019 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Mon, 7 Jan 2019 20:01:39 -0600 Subject: Are all items in list the same? In-Reply-To: References: <20190108004704.GA8694@ma.tura-home.de> Message-ID: > > > if len(a) == 0 or all(i == a[0] for i in a[1:]): > > > You don't need to check the length of the list because if the list is > empty, 'all' will return True anyway. > Given the structure of the expression passed as an argument to all(), won't you get an IndexError if a is empty without the guard? (Would try it out if I had an interpreter on my phone...) S From rosuav at gmail.com Mon Jan 7 21:05:09 2019 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jan 2019 13:05:09 +1100 Subject: Are all items in list the same? In-Reply-To: References: <20190108004704.GA8694@ma.tura-home.de> Message-ID: On Tue, Jan 8, 2019 at 1:03 PM Skip Montanaro wrote: > > > > > > if len(a) == 0 or all(i == a[0] for i in a[1:]): > > > > > You don't need to check the length of the list because if the list is > > empty, 'all' will return True anyway. > > > > Given the structure of the expression passed as an argument to all(), won't > you get an IndexError if a is empty without the guard? > > (Would try it out if I had an interpreter on my phone...) No, because the iteration would never happen. If the list is empty, a[1:] is also empty, and i==a[0] will never be evaluated. So it is safe. (But I agree that it's not instantly obvious.) ChrisA From bill at baddogconsulting.com Mon Jan 7 22:26:25 2019 From: bill at baddogconsulting.com (Bill Deegan) Date: Mon, 7 Jan 2019 22:26:25 -0500 Subject: SCons Version 3.0.3 Released Message-ID: A new SCons release, 3.0.3, is now available on the SCons download page: https://scons.org/pages/download.html Here is a summary of the changes since 3.0.1: NEW FUNCTIONALITY - Properly support versioned shared libraries for MacOS. We've also introduced two new env variables APPLELINK_CURRENT_VERSION and APPLELINK_COMPATIBILITY_VERSION which will specify what is passed to the linkers -current_version and -compatibility_version flags. If not specified they will be derived from SHLIBVERSION as such: - APPLELINK_CURRENT_VERSION = SHLIBVERSION - APPLELINK_COMPATIBILITY_VERSION = all but the last digit in SHLIBVERSION with .0 appended. Note that the values of the above will be validated. Valid format for either APPLELINK variable is X[.Y[.Z]] where 0 <= X <= 65535, 0 <= Y <= 255, 0 <= Z <= 255. - Add flag must_exist to SConscript() call to fail on missing script. Not failing on missing script is now considered deprecated, and the first instance will print a deprecation message. - Add xz compression format to packaging choices. - Add Textfile/Substfile to default environment. (issue #3147) - Added virtualenv support. A new function Virtualenv() determines whether SCons runs in a virtualenv. The search PATH may also be extended to prefer executables from the current virtualenv over the ones provided by base environment. New option --enable-virtualenv provided to import some virtualenv-related variables to SCons and extend every env['ENV']['PATH'] automatically. New option --ignore-virtualenv disables this. Two environment variables, SCONS_ENABLE_VIRTUALENV and SCONS_IGNORE_VIRTUALENV are supported for the same purpose. DEPRECATED FUNCTIONALITY - Going forward calling SConscript on a non-existing SConscript file will issue a warning. Currently it will issue a deprecation notice. CHANGED/ENHANCED EXISTING FUNCTIONALITY - Recognize new java 9, 10, 11 (as 9.0 and 10.0, 11.0) DOCUMENTATION - Update some doc examples for Py3: map() now returns an iterable instead of a list. FIXES - Fix issue #2980 with credit to Piotr Bartosik (and William Blevins). This is an issue where using TimeStamp-MD5 Decider and CacheDir can yield incorrect md5's being written into the .sconsign. The difference between Piotr Bartosik's patch and the current code is that the more complicated creation of file to csig map is only done when the count of children for the current node doesn't match the previous count which is loaded from the sconsign. Thanks to Bernard Blackham, William Deegan, Ray Donnelly, Andrew Featherstone, Arda Fu, Philipp Maierh?fer, Matthew Marinets, Fredrik Medley, Daniel Moody, Gary Oberbrunner, Jonathon Reinhart, Zachary Tessler, Pawe? Tomulik, Richard West, Mats Wichmann, Bernhard M. Wiedemann, and Hao Wu for their contributions to this release. Contributors are listed alphabetically by their last name. git shortlog --no-merges -ns 3.0.1..HEAD 254 William Deegan 79 Daniel Moody 73 Mats Wichmann 17 Pawe? Tomulik 16 Andrew Featherstone 8 grbd 7 maiphi 6 Gary Oberbrunner 6 Daniel 4 Hao Wu 3 Gabriel Russell 2 MatthewMarinets 2 Jonathon Reinhart 2 ArdaFu 1 Bernhard M. Wiedemann 1 Isaac Pascual Monells 1 Fredrik Medley 1 Philipp Maierhoefer 1 Piotr Kasprzyk 1 Ray Donnelly 1 Zachary Tessler 1 cclauss From eryksun at gmail.com Mon Jan 7 22:31:10 2019 From: eryksun at gmail.com (eryk sun) Date: Mon, 7 Jan 2019 21:31:10 -0600 Subject: Normalizing path strings and separators in cross-platform unit test scripts In-Reply-To: References: <1546887090.1165131.1627958456.3F172B66@webmail.messagingengine.com> Message-ID: On 1/7/19, Chris Angelico wrote: > On Tue, Jan 8, 2019 at 5:52 AM Malcolm Greene wrote: >> >> Is there a best practice way to convert Windows style paths (with >> backslash path separators) to Linux style paths with forward slash path >> separators? I've looked at the os and pathlib libraries without seeing >> anything that describes our need. >> Any downsides to this approach? Use os.path.normpath to compare apples to apples, as was mentioned in another post. > If you are confident you'll never have an actual backslash in a path > name (which would be a requirement if they're cross-platform anyway), > you could just p.replace("\\", "/") to convert them. I don't think > that will break anything on any Windows-based or Unix-based OS (could > be wrong of course). Windows Trivia The only 'file system' I know of that allows slashes (forward or back) in names is the named-pipe file system. This is stretching of course because it's not a general-purpose file system, and in particular it doesn't support directories. Some system components and applications create named pipes with backslash in the name. For example: >>> print(*sorted(n for n in os.listdir('//./pipe') if '\\' in n), sep='\n') GoogleCrashServices\S-1-5-18 GoogleCrashServices\S-1-5-18-x64 PIPE_EVENTROOT\CIMV2SCM EVENT PROVIDER Winsock2\CatalogChangeListener-178-0 Winsock2\CatalogChangeListener-210-0 Winsock2\CatalogChangeListener-214-0 Winsock2\CatalogChangeListener-2a4-0 Winsock2\CatalogChangeListener-2ac-0 Winsock2\CatalogChangeListener-3c0-0 Winsock2\CatalogChangeListener-7fc-0 (The CIMV2SCM pipe is created by the Windows Management Instrumentation system service. The Winsock pipes are created by processes that call WSAProviderConfigChange to wait for Winsock provider configuration changes. The template for the variable suffix is "-{process_id:x}-{sequence_number}". On this system I also have pipes created by GoogleCrashHandler[64].exe, which is running as the SYSTEM account, with SID S-1-5-18.) A regular '\\\\.\\' device path gets normalized to translate forward slashes to backslashes, so in practice we don't see pipes with forward slash in the name. To show that's it's possible, we can use a '\\\\?\\' extended device path to prevent normalizing the path. For example: >>> h = CreateNamedPipe(r'\\?\pipe\name/with/slashes', 3, 0, 1, 0, 0, 0, None) >>> print(*(n for n in os.listdir('//./pipe') if '/' in n), sep='\n') name/with/slashes From bowman at montana.com Mon Jan 7 22:59:52 2019 From: bowman at montana.com (rbowman) Date: Mon, 7 Jan 2019 20:59:52 -0700 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> Message-ID: On 01/07/2019 02:10 PM, DL Neil wrote: > Why is that obscure? It makes perfect sense - to those of us who have > used tape/serial storage! Perhaps less-so to [bobble-heads], sorry I > mean people who grew-up with 'bubble memory' (Memory sticks, 'flash > drives', SSDs). In point-of-fact, Python Context Managers Bubble memory, now there is a blast from the past... From tjreedy at udel.edu Tue Jan 8 01:16:37 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 8 Jan 2019 01:16:37 -0500 Subject: System printer object In-Reply-To: References: Message-ID: On 1/7/2019 5:17 PM, Dave wrote: > I need to print to one or both of my system printers.? I have not found > a printer object in Python or in Tkinter.? This needs to work with > Linux, Window, and Mac.? Can someone point me in the right direction? > Ultimately, I want to have a File/Print in the menu that lets me select > the printer and properties. IDLE can print editor contents to the default printer. The code is in idlelib.iomenu. The subprocess commands used are print-command-posix=lpr %%s print-command-win=start /min notepad /p %%s I believe %%s becomes the name of the saved file. -- Terry Jan Reedy From arshadzamaaz at gmail.com Tue Jan 8 03:29:03 2019 From: arshadzamaaz at gmail.com (Arshad Zama) Date: Tue, 8 Jan 2019 13:59:03 +0530 Subject: Fwd: PROBLEM IN LAUNCHING PYTHON... In-Reply-To: References: Message-ID: ---------- Forwarded message --------- From: Arshad Zama Date: Thu, Jan 3, 2019 at 10:27 PM Subject: PROBLEM IN LAUNCHING PYTHON... To: HELLO SIR, I'm facing some issue while launching the python ide on windows 8.1 pro. Kindly help me!!... From __peter__ at web.de Tue Jan 8 03:52:12 2019 From: __peter__ at web.de (Peter Otten) Date: Tue, 08 Jan 2019 09:52:12 +0100 Subject: Are all items in list the same? References: <20190107190307.459cb3db@bigbox.christie.dr> Message-ID: Tim Chase wrote: > def all_equal(iterable): > i = iter(iterable) > first = next(i) > return all(x == first for x in i) > > It's undefined for an empty list (well, it throws a StopIteration > but you can special-case that), but should hand the cases with > 1 element and 2+ elements (both matching and where any item is not > the same). It should work on an iterator as well but will consume the > items in the process. > > And I even like how nicely it reads :-) If that's why you omitted the try...except use first = next(i, None) From __peter__ at web.de Tue Jan 8 04:07:06 2019 From: __peter__ at web.de (Peter Otten) Date: Tue, 08 Jan 2019 10:07:06 +0100 Subject: Are all items in list the same? References: Message-ID: Bob van der Poel wrote: > I need to see if all the items in my list are the same. I was using set() > for this, but that doesn't work if items are themselves lists. So, > assuming that a is a list of some things, the best I've been able to come > up with it: > > if a.count( targ ) == len(a): > > I'm somewhat afraid that this won't scale all that well. Am I missing > something? a[1:] == a[:-1] :) From mal at europython.eu Tue Jan 8 04:19:44 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Tue, 8 Jan 2019 10:19:44 +0100 Subject: EuroPython 2019: Kicking off the organization Message-ID: <68877da4-0ef9-7be2-9133-f7179e649cbf@europython.eu> Today, we?re happy to announce our pre-launch website under the official EuroPython 2019 URL: * https://ep2019.europython.eu/ * 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): https://www.congress.ch/en-US.aspx https://www.fhnw.ch/de/die-fhnw/standorte/muttenz We will continue to list information on the FAQ & Info page as it becomes available: 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://www.europython-society.org/post/181832657135/europython-2019-kicking-off-the-organization Tweet: https://twitter.com/europythons/status/1082564855188602880 Thank you, -- EuroPython Society https://www.europython-society.org/ From dude.jimbo at gmail.com Tue Jan 8 05:38:16 2019 From: dude.jimbo at gmail.com (dude.jimbo at gmail.com) Date: Tue, 8 Jan 2019 02:38:16 -0800 (PST) Subject: The following modules appear to be missing ['_sysconfigdata'] Message-ID: Hello, first time using python groups (and long time since using any other group for that matter). This might not be the right group due to wx being involved. Long story as short as possible. I have an old python script that I did ~10 years ago, and have forgotten basically everything about Python since then (sorry!). Converted it to EXE way back when, and have kept using the EXE ever since then (on XP, and on Win7). I've just gotten a new PC, Windows10 (!), needed to update the script, so needed to recompile the EXE, and now it no longer compiles/works. It was fine on Windows7 (I'm not specifically stating that the problem is with windows10 - I simply don't remember all the hoops I jumped through on my previous machine). Here is the compile error: The following modules appear to be missing ['_sysconfigdata'] And here is the runtime error: Traceback (most recent call last): File "AutoArchive.py", line 3, in File "wx\__init__.pyc", line 45, in File "wx\_core.pyc", line 4, in File "wx\_core_.pyc", line 12, in File "wx\_core_.pyc", line 10, in __load ImportError: DLL load failed: %1 is not a valid Win32 application. Here is how I compile: python setup.py py2exe And this is my setup.py: from distutils.core import setup import py2exe setup(console=['AutoArchive.py']) Yes, that says 'console' for a Windows EXE, but swapping it to 'window' didn't help. Besides which, the setup.py file is straight from the old computer, so 'it used to work'. What I have installed: . python 2.7.13 (this in itself may be a problem - I don't even remember which version I was using earlier, other than knowing for sure it wasn't a 3.x release) . wxpython (since I also got an error that wx module was missing - that rang some bells, since the script uses a Windows pop-up window to inform me about its progress, and I remember using wx for that, so I installed it, but don't know how to get its' version. using "python -c "import wx;print wx.__version__" just gives runtime errors). Any help would be appreciated. And yes, I googled, but can't really find anything (well, d'Uh!, I wouldn?t be here then would I?) - there's ~some~ references, but usually it's about similar issues on Linux, with solutions that are not applicable at all. Except one I thought: I found some link stating that _sysconfigdata is part of sysconfig, and that this needed to be installed with pip, so I used the pip that came with my python distro and did 'pip install [[_]sys]config[data]' (all possible combo's) but pip claims it can't find said module, and TBH, I can't seem to find anything myself about said module. Thx, Jimbo From rhodri at kynesim.co.uk Tue Jan 8 06:33:07 2019 From: rhodri at kynesim.co.uk (Rhodri James) Date: Tue, 8 Jan 2019 11:33:07 +0000 Subject: Fwd: PROBLEM IN LAUNCHING PYTHON... In-Reply-To: References: Message-ID: On 08/01/2019 08:29, Arshad Zama wrote: > ---------- Forwarded message --------- > From: Arshad Zama > Date: Thu, Jan 3, 2019 at 10:27 PM > Subject: PROBLEM IN LAUNCHING PYTHON... > To: > > > HELLO SIR, > I'm facing some issue while launching the python ide on windows 8.1 pro. > Kindly help me!!... What exactly is the problem? If you sent a screenshot or similar attachment, I'm afraid the mailing list will have stripped that off. Please describe what you have done and what is going wrong, preferably cutting and pasting error messages rather than retyping them. I'm not a Windows expert, but others here may be able to help if you give them enough information. (The temptation to say "Installing Linux will fix most of your problems" is strong :-) -- Rhodri James *-* Kynesim Ltd From storchaka at gmail.com Tue Jan 8 09:48:58 2019 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 8 Jan 2019 16:48:58 +0200 Subject: Are all items in list the same? In-Reply-To: References: Message-ID: 08.01.19 11:07, Peter Otten ????: > Bob van der Poel wrote: > >> I need to see if all the items in my list are the same. I was using set() >> for this, but that doesn't work if items are themselves lists. So, >> assuming that a is a list of some things, the best I've been able to come >> up with it: >> >> if a.count( targ ) == len(a): >> >> I'm somewhat afraid that this won't scale all that well. Am I missing >> something? > > a[1:] == a[:-1] > > :) > Very clever! It is definitely the shortest solution. From nimbiotics at gmail.com Tue Jan 8 10:00:39 2019 From: nimbiotics at gmail.com (Mario R. Osorio) Date: Tue, 8 Jan 2019 07:00:39 -0800 (PST) Subject: Kivy native GUI examples In-Reply-To: References: Message-ID: <93f6b3db-c8c5-425c-895f-b68e73ec02d0@googlegroups.com> On Monday, January 7, 2019 at 9:52:03 AM UTC-5, Dave wrote: > I need to select a Python GUI. It needs to cover all of the desktops > (Linux, Windows, Apple) and hopefully mobile (Android and Ios). I'm > looking at Kivy, but have yet to find an example app. that has a native > looking GUI (Windows, Mac, Linux/Gnome/KDE). Is that possible and > anyone know of some examples? > > Thanks, > Dave You might want to take a look into this project: BeeWare (https://pybee.org/) From scons at ryandesign.com Tue Jan 8 09:27:05 2019 From: scons at ryandesign.com (Ryan Schmidt) Date: Tue, 8 Jan 2019 08:27:05 -0600 Subject: [Scons-users] SCons Version 3.0.3 Released In-Reply-To: References: Message-ID: On Jan 7, 2019, at 21:26, Bill Deegan wrote: > A new SCons release, 3.0.3, is now available on the SCons download page: > > https://scons.org/pages/download.html > > > Here is a summary of the changes since 3.0.1: It would have been good to mention the changes since 3.0.2, which are: RELEASE 3.0.3 - Mon, 07 Jan 2019 20:05:22 -0400 NOTE: 3.0.2 release was dropped because there was a packaging bug. Please consider all 3.0.2 content. From William Deegan: - Fixes to packaging logic. Ensuring the SCons.Tool.clangCommon module is added to the release packages. - Modify scons.bat script to check for scons python script without .py extension if no file scons.py exists. This enables an all platform wheel to work. From Mats Wichmann: - Update doc examples to work with Python 3.5+: map() now returns an iterable instead of a list. See https://github.com/SCons/scons/blob/rel_3.0.3/src/CHANGES.txt From neilc at norwich.edu Tue Jan 8 11:31:19 2019 From: neilc at norwich.edu (Neil Cerutti) Date: 8 Jan 2019 16:31:19 GMT Subject: Are all items in list the same? References: <20190108004704.GA8694@ma.tura-home.de> Message-ID: On 2019-01-08, MRAB wrote: > On 2019-01-08 00:47, ike at koeln.ccc.de wrote: >> You might do something like >> >> if len(a) == 0 or all(i == a[0] for i in a[1:]): >> > You don't need to check the length of the list because if the list is > empty, 'all' will return True anyway. Neat! I expected that a[0] would be executed in that case, but it is not. -- Neil Cerutti From bob at mellowood.ca Tue Jan 8 11:54:14 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Tue, 8 Jan 2019 09:54:14 -0700 Subject: Are all items in list the same? In-Reply-To: References: <20190108004704.GA8694@ma.tura-home.de> Message-ID: Thanks guys for the help on this. As it turns out I have learned new commands as a result of the question: all() and any() will work perfectly! The other solutions, as always, are enlightening. And, no, Chris, this is not homework :) On Tue, Jan 8, 2019 at 9:31 AM Neil Cerutti wrote: > On 2019-01-08, MRAB wrote: > > On 2019-01-08 00:47, ike at koeln.ccc.de wrote: > >> You might do something like > >> > >> if len(a) == 0 or all(i == a[0] for i in a[1:]): > >> > > You don't need to check the length of the list because if the list is > > empty, 'all' will return True anyway. > > Neat! I expected that a[0] would be executed in that case, > but it is not. > > -- > Neil Cerutti > -- > 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 alister.ware at ntlworld.com Tue Jan 8 12:15:17 2019 From: alister.ware at ntlworld.com (Alister) Date: Tue, 08 Jan 2019 17:15:17 GMT Subject: Are all items in list the same? Message-ID: On Tue, 08 Jan 2019 16:48:58 +0200, Serhiy Storchaka wrote: > 08.01.19 11:07, Peter Otten ????: >> Bob van der Poel wrote: >> >>> I need to see if all the items in my list are the same. I was using >>> set() >>> for this, but that doesn't work if items are themselves lists. So, >>> assuming that a is a list of some things, the best I've been able to >>> come up with it: >>> >>> if a.count( targ ) == len(a): >>> >>> I'm somewhat afraid that this won't scale all that well. Am I missing >>> something? >> >> a[1:] == a[:-1] >> >> :) >> >> > Very clever! It is definitely the shortest solution. would that still not return true if the list was a palindrome? -- Every young man should have a hobby: learning how to handle money is the best one. -- Jack Hurley From alister.ware at ntlworld.com Tue Jan 8 12:20:05 2019 From: alister.ware at ntlworld.com (Alister) Date: Tue, 08 Jan 2019 17:20:05 GMT Subject: Are all items in list the same? References: Message-ID: <9Z4ZD.66743$DF1.37272@fx34.am4> On Tue, 08 Jan 2019 17:15:17 +0000, Alister wrote: > On Tue, 08 Jan 2019 16:48:58 +0200, Serhiy Storchaka wrote: > >> 08.01.19 11:07, Peter Otten ????: >>> Bob van der Poel wrote: >>> >>>> I need to see if all the items in my list are the same. I was using >>>> set() >>>> for this, but that doesn't work if items are themselves lists. So, >>>> assuming that a is a list of some things, the best I've been able to >>>> come up with it: >>>> >>>> if a.count( targ ) == len(a): >>>> >>>> I'm somewhat afraid that this won't scale all that well. Am I missing >>>> something? >>> >>> a[1:] == a[:-1] >>> >>> :) >>> >>> >> Very clever! It is definitely the shortest solution. > > would that still not return true if the list was a palindrome? ignore me, just tried & ok -- I'm not proud. From nimbiotics at gmail.com Tue Jan 8 10:11:29 2019 From: nimbiotics at gmail.com (Mario R. Osorio) Date: Tue, 8 Jan 2019 07:11:29 -0800 (PST) Subject: Recommendations for a novice user. In-Reply-To: References: Message-ID: <9047db20-09c8-4118-aa4d-e2e72794f526@googlegroups.com> On Wednesday, January 2, 2019 at 1:05:44 PM UTC-5, H?seyin Ertu?rul wrote: > I don't know the software language at all. What do you recommend to beginners to learn Python. > What should be the working systematic? How much time should I spend every day or how much time should I spend on a daily basis. > > Is there any such systematic implementation and success? > > ?yi ?al??malar... > H?seyin ERTUGRUL > Teknik Servis M?d?r? > Piramit Bilgisayar & Teknoloji > Sis. San. Tic. Ltd. ?ti > > > > TEL: 212-480 0 660 > FAX: 212-544 66 95 > MOBILE: 543-328 68 15 > E-MA?L: huseyin at piramit.com.tr > HTTP: www.piramit.com.tr > > Topkap?-Maltepe cad. > Canayak?n ?? Merkezi > B/Blok No:11 > Bayrampa?a/ ?stanbul 34030 TURKIYE > > P Bu dok?man? yaz?c?ya g?ndermeden ?nce l?tfen ka??t ?retimi i?in kesilen a?a?lar? bir kez daha d???n?n! I have bought a few courses from udemy (https://www.udemy.com/) on different matters. They are not necessarily the best but for $10 a course you are really getting your money's worth and in my experience, some of these courses are a great start. In reviewing this courses, those by Jose Portilla are the best. The guy is a python professional. Of course, there are others. Once you get acquainted with the language and the community (which is not perfect but still the best I've ever found); you will be able to discern your next steps Good luck! P.D.: I have not relationship or connection to udemy, other than being a satisfied customer From ike at koeln.ccc.de Tue Jan 8 14:15:03 2019 From: ike at koeln.ccc.de (ike at koeln.ccc.de) Date: Tue, 8 Jan 2019 20:15:03 +0100 Subject: Are all items in list the same? In-Reply-To: References: <20190108004704.GA8694@ma.tura-home.de> Message-ID: <20190108191503.GA12832@ma.tura-home.de> On Tue, Jan 08, 2019 at 01:05:09PM +1100, Chris Angelico wrote: > No, because the iteration would never happen. If the list is empty, > a[1:] is also empty, and i==a[0] will never be evaluated. So it is > safe. (But I agree that it's not instantly obvious.) Oh yeah, you're right. I overthought it too much. :) From toby at tobiah.org Tue Jan 8 15:31:24 2019 From: toby at tobiah.org (Tobiah) Date: Tue, 8 Jan 2019 12:31:24 -0800 Subject: Are all items in list the same? References: <9Z4ZD.66743$DF1.37272@fx34.am4> Message-ID: On 1/8/19 9:20 AM, Alister wrote: > On Tue, 08 Jan 2019 17:15:17 +0000, Alister wrote: > >> On Tue, 08 Jan 2019 16:48:58 +0200, Serhiy Storchaka wrote: >> >>> 08.01.19 11:07, Peter Otten ????: >>>> Bob van der Poel wrote: >>>> >>>>> I need to see if all the items in my list are the same. I was using >>>>> set() >>>>> for this, but that doesn't work if items are themselves lists. So, >>>>> assuming that a is a list of some things, the best I've been able to >>>>> come up with it: >>>>> >>>>> if a.count( targ ) == len(a): >>>>> >>>>> I'm somewhat afraid that this won't scale all that well. Am I missing >>>>> something? >>>> >>>> a[1:] == a[:-1] >>>> >>>> :) >>>> >>>> >>> Very clever! It is definitely the shortest solution. >> >> would that still not return true if the list was a palindrome? > ignore me, just tried & ok > > > > You were right the first time. The above comparison should have been a == a[::-1] A palindrome will pass. From 2QdxY4RzWzUUiLuE at potatochowder.com Tue Jan 8 16:28:32 2019 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Tue, 8 Jan 2019 15:28:32 -0600 Subject: Are all items in list the same? In-Reply-To: References: <9Z4ZD.66743$DF1.37272@fx34.am4> Message-ID: On 1/8/19 2:31 PM, Tobiah wrote:> On 1/8/19 9:20 AM, Alister wrote: >> On Tue, 08 Jan 2019 17:15:17 +0000, Alister wrote: >> >>> On Tue, 08 Jan 2019 16:48:58 +0200, Serhiy Storchaka wrote: >>> >>>> 08.01.19 11:07, Peter Otten ????: >>>>> Bob van der Poel wrote: >>>>> >>>>>> I need to see if all the items in my list are the same. I was using >>>>>> set() >>>>>> for this, but that doesn't work if items are themselves lists. So, >>>>>> assuming that a is a list of some things, the best I've been able to >>>>>> come up with it: >>>>>> >>>>>> if a.count( targ ) == len(a): >>>>>> >>>>>> I'm somewhat afraid that this won't scale all that well. Am I missing >>>>>> something? >>>>> >>>>> a[1:] == a[:-1] >>>>> >>>>> :) >>>>> >>>>> >>>> Very clever! It is definitely the shortest solution. >>> >>> would that still not return true if the list was a palindrome? >> ignore me, just tried & ok >> > > You were right the first time. The above comparison should have been > > a == a[::-1] > > A palindrome will pass. Let's find out (vertical space added for clarity): Python 3.7.2 (default, Dec 29 2018, 21:15:15) [GCC 8.2.1 20181127] on linux Type "help", "copyright", "credits" or "license" for more information. >>> a = [1, 1, 1, 1, 1] >>> a[1:] == a[:-1] True >>> a == a[::-1] True >>> a = [1, 2, 3, 4, 3, 2, 1] >>> a[1:] == a[:-1] False >>> a == a[::-1] True Looks like Peter's pretty clever after all. :-) Dan From cs at cskk.id.au Tue Jan 8 17:44:45 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 9 Jan 2019 09:44:45 +1100 Subject: Are all items in list the same? In-Reply-To: References: Message-ID: <20190108224445.GA44660@cskk.homeip.net> On 08Jan2019 15:28, Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > >>> a = [1, 1, 1, 1, 1] > >>> a[1:] == a[:-1] > True > >>> a == a[::-1] > True > > >>> a = [1, 2, 3, 4, 3, 2, 1] > >>> a[1:] == a[:-1] > False > >>> a == a[::-1] > True > >Looks like Peter's pretty clever after all. :-) Except that his solution always scans then entire list. Twice. For large dissimilar lists this gets needlessly expensive in a linear fashion with the length of the list. It is succinct, but wasteful. Cheers, Cameron Simpson From klsshaeffer at gmail.com Tue Jan 8 18:11:52 2019 From: klsshaeffer at gmail.com (Karen Shaeffer) Date: Tue, 8 Jan 2019 15:11:52 -0800 Subject: Are all items in list the same? Message-ID: On 08Jan2019 15:28, Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: >> >>> a = [1, 1, 1, 1, 1] >> >>> a[1:] == a[:-1] >> True >> >>> a == a[::-1] >> True >> >> >>> a = [1, 2, 3, 4, 3, 2, 1] >> >>> a[1:] == a[:-1] >> False >> >>> a == a[::-1] >> True >> >> Looks like Peter's pretty clever after all. :-) > > Except that his solution always scans then entire list. Twice. > > For large dissimilar lists this gets needlessly expensive in a linear fashion > with the length of the list. > > It is succinct, but wasteful. > I ran it with the timeit module for the specific case of a list: tlst = [True for _j in range(int(1e8))] # Very fast. # all_equal(tlst) times = [9.820610110182315e-07, 9.798338289838284e-07, 9.83037088997662e-07, # 9.824190249200911e-07] seconds. def all_equal(alist) -> bool: if len(alist) == 0 or all(i == a[0] for i in a[1:]): return True return False # The variant: if alist == alist[::-1]: # actually has a memory leak. And I eventually killed the process after waiting about # ten minutes, while watching the memory leak. # # This variant doesn't have a memory leak. I'm still waiting after 15 minutes. Might give up # on it. The other solution is the way to go. def all_equal_array_list(alist) -> bool: if alist == alist[:-1]: return True return False if __name__ == '__main__': tae = timeit.repeat(timeit_all_equal,repeat=4,number=1000000,globals=globals()) print(f"all_equal(tlst) times = {[_t/1e6 for _t in tae]} seconds.\n") taeal = timeit.repeat(timeit_all_equal_array_list,repeat=4,number=1000000,globals=globals()) print(f"all_equal_array_list(tlst) times = {[_t/1e6 for _t in taeal]} seconds.\n") From klsshaeffer at gmail.com Wed Jan 9 00:01:33 2019 From: klsshaeffer at gmail.com (Karen Shaeffer) Date: Tue, 8 Jan 2019 21:01:33 -0800 Subject: Are all items in list the same? In-Reply-To: References: Message-ID: There were some issues with my test. After sending the email, I thought those times couldn't be real. Here are better results: all_equal(tlst) times = [6.719925760501064e-05] seconds. all_equal_array_list(tlst) times = [4.2184268278069794e-06] seconds. import timeit def all_equal(alist) -> bool: if len(alist) == 0 or all(i == alist[0] for i in alist[1:]): return True return False def all_equal_array_list(alist) -> bool: if alist == alist[:-1]: return True return False tlst = [42 for _j in range(5000)] def timeit_all_equal() -> bool: return all_equal(tlst) def timeit_all_equal_array_list() -> bool: return all_equal_array_list(tlst) if __name__ == '__main__': tae = timeit.repeat(timeit_all_equal,repeat=2,number=1000000,globals=globals()) print(f"all_equal(tlst) times = {[_t/1e6 for _t in tae]} seconds.\n") taeal = timeit.repeat(timeit_all_equal_array_list,repeat=2,number=1000000,globals=globals()) print(f"all_equal_array_list(tlst) times = {[_t/1e6 for _t in taeal]} seconds.\n") On Tue, Jan 8, 2019 at 3:11 PM Karen Shaeffer wrote: > On 08Jan2019 15:28, Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com> > wrote: > > >> >>> a = [1, 1, 1, 1, 1] > > >> >>> a[1:] == a[:-1] > > >> True > > >> >>> a == a[::-1] > > >> True > > >> > > >> >>> a = [1, 2, 3, 4, 3, 2, 1] > > >> >>> a[1:] == a[:-1] > > >> False > > >> >>> a == a[::-1] > > >> True > > >> > > >> Looks like Peter's pretty clever after all. :-) > > > > > > Except that his solution always scans then entire list. Twice. > > > > > > For large dissimilar lists this gets needlessly expensive in a linear > fashion > > > with the length of the list. > > > > > > It is succinct, but wasteful. > > > > > I ran it with the timeit module for the specific case of a list: > > > tlst = [True for _j in range(int(1e8))] > > > # Very fast. > > # all_equal(tlst) times = [9.820610110182315e-07, 9.798338289838284e-07, > 9.83037088997662e-07, > > # 9.824190249200911e-07] seconds. > > def all_equal(alist) -> bool: > > if len(alist) == 0 or all(i == a[0] for i in a[1:]): > > return True > > return False > > > # The variant: if alist == alist[::-1]: > > # actually has a memory leak. And I eventually killed the process after > waiting about > > # ten minutes, while watching the memory leak. > > # > > # This variant doesn't have a memory leak. I'm still waiting after 15 > minutes. Might give up > > # on it. The other solution is the way to go. > > def all_equal_array_list(alist) -> bool: > > if alist == alist[:-1]: > > return True > > return False > > > if __name__ == '__main__': > > tae = > timeit.repeat(timeit_all_equal,repeat=4,number=1000000,globals=globals()) > > print(f"all_equal(tlst) times = {[_t/1e6 for _t in tae]} seconds.\n") > > > taeal = > timeit.repeat(timeit_all_equal_array_list,repeat=4,number=1000000,globals=globals()) > > print(f"all_equal_array_list(tlst) times = {[_t/1e6 for _t in taeal]} > seconds.\n") > From matt at matthewlemon.com Tue Jan 8 23:54:24 2019 From: matt at matthewlemon.com (Matthew Lemon) Date: Wed, 09 Jan 2019 04:54:24 +0000 Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: Message-ID: Hi, I would start from scratch with this. 1. You have latest Python 2 version. 2. Use virtualenv to create and activate a new virtual environment. 3. pip install wxPython and other dependencies. 4. Get your application running from the command line first and follow up any DLL exceptions. 5. Use pyinstaller (https://pyinstaller.readthedocs.io/en/stable/) to create a new exe file once you know everything works. Matt On 8 January 2019 10:38:16 GMT, dude.jimbo at gmail.com wrote: >Hello, > >first time using python groups (and long time since using any other >group for that matter). This might not be the right group due to wx >being involved. > >Long story as short as possible. I have an old python script that I did >~10 years ago, and have forgotten basically everything about Python >since then (sorry!). Converted it to EXE way back when, and have kept >using the EXE ever since then (on XP, and on Win7). > >I've just gotten a new PC, Windows10 (!), needed to update the script, >so needed to recompile the EXE, and now it no longer compiles/works. It >was fine on Windows7 (I'm not specifically stating that the problem is >with windows10 - I simply don't remember all the hoops I jumped through >on my previous machine). > >Here is the compile error: >The following modules appear to be missing >['_sysconfigdata'] > >And here is the runtime error: >Traceback (most recent call last): > File "AutoArchive.py", line 3, in > File "wx\__init__.pyc", line 45, in > File "wx\_core.pyc", line 4, in > File "wx\_core_.pyc", line 12, in > File "wx\_core_.pyc", line 10, in __load >ImportError: DLL load failed: %1 is not a valid Win32 application. > >Here is how I compile: python setup.py py2exe > >And this is my setup.py: >from distutils.core import setup >import py2exe > >setup(console=['AutoArchive.py']) > >Yes, that says 'console' for a Windows EXE, but swapping it to 'window' >didn't help. Besides which, the setup.py file is straight from the old >computer, so 'it used to work'. > >What I have installed: >. python 2.7.13 (this in itself may be a problem - I don't even >remember which version I was using earlier, other than knowing for sure >it wasn't a 3.x release) >. wxpython (since I also got an error that wx module was missing - >that rang some bells, since the script uses a Windows pop-up window to >inform me about its progress, and I remember using wx for that, so I >installed it, but don't know how to get its' version. using "python -c >"import wx;print wx.__version__" just gives runtime errors). > >Any help would be appreciated. > >And yes, I googled, but can't really find anything (well, d'Uh!, I >wouldn?t be here then would I?) - there's ~some~ references, but >usually it's about similar issues on Linux, with solutions that are not >applicable at all. Except one I thought: I found some link stating that >_sysconfigdata is part of sysconfig, and that this needed to be >installed with pip, so I used the pip that came with my python distro >and did 'pip install [[_]sys]config[data]' (all possible combo's) but >pip claims it can't find said module, and TBH, I can't seem to find >anything myself about said module. > >Thx, >Jimbo >-- >https://mail.python.org/mailman/listinfo/python-list -- Sent from my Android device From klsshaeffer at gmail.com Wed Jan 9 00:57:28 2019 From: klsshaeffer at gmail.com (Karen Shaeffer) Date: Tue, 8 Jan 2019 21:57:28 -0800 Subject: Are all items in list the same? In-Reply-To: References: Message-ID: There was one more error. (smiles ;) Fixed below def all_equal_array_list(alist) -> bool: if alist[1:] == alist[:-1]: return True return False def all_equal(alist) -> bool: if len(alist) == 0 or all(i == alist[0] for i in alist[1:]): return True return False all_equal(tlst) times = [1.3971288939937949e-05] seconds. all_equal_array_list(tlst) times = [2.3801841149106623e-06] seconds. Karen. On Tue, Jan 8, 2019 at 9:01 PM Karen Shaeffer wrote: > There were some issues with my test. After sending the email, I thought > > those times couldn't be real. Here are better results: > > > all_equal(tlst) times = [6.719925760501064e-05] seconds. > > > all_equal_array_list(tlst) times = [4.2184268278069794e-06] seconds. > > > import timeit > > > def all_equal(alist) -> bool: > > if len(alist) == 0 or all(i == alist[0] for i in alist[1:]): > > return True > > return False > > > def all_equal_array_list(alist) -> bool: > > if alist == alist[:-1]: > > return True > > return False > > > tlst = [42 for _j in range(5000)] > > > def timeit_all_equal() -> bool: > > return all_equal(tlst) > > > def timeit_all_equal_array_list() -> bool: > > return all_equal_array_list(tlst) > > > if __name__ == '__main__': > > tae = > timeit.repeat(timeit_all_equal,repeat=2,number=1000000,globals=globals()) > > print(f"all_equal(tlst) times = {[_t/1e6 for _t in tae]} seconds.\n") > > > taeal = > timeit.repeat(timeit_all_equal_array_list,repeat=2,number=1000000,globals=globals()) > > print(f"all_equal_array_list(tlst) times = {[_t/1e6 for _t in taeal]} > seconds.\n") > > On Tue, Jan 8, 2019 at 3:11 PM Karen Shaeffer > wrote: > >> On 08Jan2019 15:28, Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com> >> wrote: >> >> >> >>> a = [1, 1, 1, 1, 1] >> >> >> >>> a[1:] == a[:-1] >> >> >> True >> >> >> >>> a == a[::-1] >> >> >> True >> >> >> >> >> >> >>> a = [1, 2, 3, 4, 3, 2, 1] >> >> >> >>> a[1:] == a[:-1] >> >> >> False >> >> >> >>> a == a[::-1] >> >> >> True >> >> >> >> >> >> Looks like Peter's pretty clever after all. :-) >> >> > >> >> > Except that his solution always scans then entire list. Twice. >> >> > >> >> > For large dissimilar lists this gets needlessly expensive in a linear >> fashion >> >> > with the length of the list. >> >> > >> >> > It is succinct, but wasteful. >> >> > >> >> I ran it with the timeit module for the specific case of a list: >> >> >> tlst = [True for _j in range(int(1e8))] >> >> >> # Very fast. >> >> # all_equal(tlst) times = [9.820610110182315e-07, 9.798338289838284e-07, >> 9.83037088997662e-07, >> >> # 9.824190249200911e-07] seconds. >> >> def all_equal(alist) -> bool: >> >> if len(alist) == 0 or all(i == a[0] for i in a[1:]): >> >> return True >> >> return False >> >> >> # The variant: if alist == alist[::-1]: >> >> # actually has a memory leak. And I eventually killed the process after >> waiting about >> >> # ten minutes, while watching the memory leak. >> >> # >> >> # This variant doesn't have a memory leak. I'm still waiting after 15 >> minutes. Might give up >> >> # on it. The other solution is the way to go. >> >> def all_equal_array_list(alist) -> bool: >> >> if alist == alist[:-1]: >> >> return True >> >> return False >> >> >> if __name__ == '__main__': >> >> tae = >> timeit.repeat(timeit_all_equal,repeat=4,number=1000000,globals=globals()) >> >> print(f"all_equal(tlst) times = {[_t/1e6 for _t in tae]} seconds.\n") >> >> >> taeal = >> timeit.repeat(timeit_all_equal_array_list,repeat=4,number=1000000,globals=globals()) >> >> print(f"all_equal_array_list(tlst) times = {[_t/1e6 for _t in taeal]} >> seconds.\n") >> > From jskako at gmail.com Wed Jan 9 04:53:53 2019 From: jskako at gmail.com (jskako at gmail.com) Date: Wed, 9 Jan 2019 01:53:53 -0800 (PST) Subject: Working with graphs - Kevin Bacon game Message-ID: I am working on Kevin Bacon game. I have "movies.txt" text file that looks like: Apollo 13 (1995);Bill Paxton;Tom Hanks;Kevin Bacon Begyndte ombord, Det (1937);Aage Schmidt;Valso Holm Bersaglio mobile (1967);Dana Young;Bebe Drake Bezottsovshchina (1976);Yelena Maksimova;Lev Prygunov Dark, The (1979);Angelo Rossitto;William Devane etc,... So in first row we have movie name, and in other rows we have actors for that movie. I am trying to make Kevin Bacon game with breath-first search. My source code (Python 3.X): class cvor: __slots__ = ('ime','susjed') def kreiranjeCvora(ime): n = cvor() n.ime = ime n.susjed = [] return n def pronadiCvor(cvorlist, ime): for n in cvorlist: if n.ime == ime: return n def ucitajGraf(file): graph = [] for line in file: imeGlumaca = [] mojaLinija = line.split(";") imeFilma = mojaLinija[0] for i in range (1,len(mojaLinija)): imeGlumaca.insert(len(imeGlumaca), mojaLinija[i]) cvorFilm = pronadiCvor(graph, imeFilma) if cvorFilm == None: cvorFilm = kreiranjeCvora(imeFilma) graph.append(cvorFilm) for glumac in imeGlumaca: glumacCvor = pronadiCvor(graph,glumac) if glumacCvor == None: glumacCvor = kreiranjeCvora(glumac) graph.append(glumacCvor) glumacCvor.susjed.append(cvorFilm) cvorFilm.susjed.append(glumacCvor) return graph def main(): f = open("movies.txt") graf = ucitajGraf(f) print (graf) main() My problem is that when I print graph with "print (graph)" I am getting: "[<__main__.cvor object at 0x000001475275EBE0>, <__main__.cvor object at 0x000001475275EEF0>, <__main__.cvor object at 0x000001475275EFD0>, <__main__.cvor object at 0x000001475275EE80>, <__main__.cvor object at 0x000001475275EB70>, <__main__.cvor object at 0x000001475275ED68>,..." And I know why but I don't know how to fix it and get "name" there. What would be the best way to perform breath-first search between two entered names? From rosuav at gmail.com Wed Jan 9 05:00:12 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jan 2019 21:00:12 +1100 Subject: Working with graphs - Kevin Bacon game In-Reply-To: References: Message-ID: On Wed, Jan 9, 2019 at 8:56 PM wrote: > class cvor: > __slots__ = ('ime','susjed') > > My problem is that when I print graph with "print (graph)" I am getting: > > "[<__main__.cvor object at 0x000001475275EBE0>, <__main__.cvor object at 0x000001475275EEF0>, <__main__.cvor object at 0x000001475275EFD0>, <__main__.cvor object at 0x000001475275EE80>, <__main__.cvor object at 0x000001475275EB70>, <__main__.cvor object at 0x000001475275ED68>,..." > When you print out a collection of arbitrary objects, Python shows you the *repr* ("representation") of each one. The default repr for a custom class just shows the class name and the object's unique ID, which isn't terribly useful. Create your own custom representation by adding a method to your cvor class: def __repr__(self): return "some nice descriptive string" It's up to you to decide how to build that string, but that's what will be shown. Incidentally, you may want to consider the namedtuple type; it might be more what you want. ChrisA From python at mrabarnett.plus.com Wed Jan 9 06:00:33 2019 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 9 Jan 2019 11:00:33 +0000 Subject: Working with graphs - Kevin Bacon game In-Reply-To: References: Message-ID: On 2019-01-09 09:53, jskako at gmail.com wrote: > I am working on Kevin Bacon game. > > I have "movies.txt" text file that looks like: > > Apollo 13 (1995);Bill Paxton;Tom Hanks;Kevin Bacon > Begyndte ombord, Det (1937);Aage Schmidt;Valso Holm > Bersaglio mobile (1967);Dana Young;Bebe Drake > Bezottsovshchina (1976);Yelena Maksimova;Lev Prygunov > Dark, The (1979);Angelo Rossitto;William Devane > etc,... > > So in first row we have movie name, and in other rows we have actors for that movie. > > I am trying to make Kevin Bacon game with breath-first search. > > My source code (Python 3.X): > > > > class cvor: > __slots__ = ('ime','susjed') > > > def kreiranjeCvora(ime): > n = cvor() > n.ime = ime > n.susjed = [] > return n > > def pronadiCvor(cvorlist, ime): > for n in cvorlist: > if n.ime == ime: > return n > It would be better if a function that returns a value _always_ explicitly returns a value: return None > > def ucitajGraf(file): > graph = [] > for line in file: These lines: > imeGlumaca = [] > mojaLinija = line.split(";") > imeFilma = mojaLinija[0] > for i in range (1,len(mojaLinija)): > imeGlumaca.insert(len(imeGlumaca), mojaLinija[i]) > do the same as: mojaLinija = line.split(";") imeFilma = mojaLinija[0] imeGlumaca = mojaLinija[1 : ] > cvorFilm = pronadiCvor(graph, imeFilma) > if cvorFilm == None: > cvorFilm = kreiranjeCvora(imeFilma) > graph.append(cvorFilm) > for glumac in imeGlumaca: > glumacCvor = pronadiCvor(graph,glumac) > if glumacCvor == None: > glumacCvor = kreiranjeCvora(glumac) > graph.append(glumacCvor) > glumacCvor.susjed.append(cvorFilm) > cvorFilm.susjed.append(glumacCvor) > return graph > > > def main(): > f = open("movies.txt") > graf = ucitajGraf(f) It's recommended to use 'with': with open("movies.txt") as f: graf = ucitajGraf(f) because it'll close the file immediately. > print (graf) > > main() > > > My problem is that when I print graph with "print (graph)" I am getting: > > "[<__main__.cvor object at 0x000001475275EBE0>, <__main__.cvor object at 0x000001475275EEF0>, <__main__.cvor object at 0x000001475275EFD0>, <__main__.cvor object at 0x000001475275EE80>, <__main__.cvor object at 0x000001475275EB70>, <__main__.cvor object at 0x000001475275ED68>,..." > > And I know why but I don't know how to fix it and get "name" there. > > What would be the best way to perform breath-first search between two entered names? > From jskako at gmail.com Wed Jan 9 06:23:11 2019 From: jskako at gmail.com (Josip Skako) Date: Wed, 9 Jan 2019 03:23:11 -0800 (PST) Subject: Working with graphs - Kevin Bacon game In-Reply-To: References: Message-ID: <5d91b3b1-c643-4729-bb93-03d4c329d8ff@googlegroups.com> Thank You for your answer, I fixed everything as You said. From jskako at gmail.com Wed Jan 9 07:46:03 2019 From: jskako at gmail.com (Josip Skako) Date: Wed, 9 Jan 2019 04:46:03 -0800 (PST) Subject: Working with graphs - Kevin Bacon game In-Reply-To: References: Message-ID: <4a314562-5a1f-4901-a73e-b9f35cef10dc@googlegroups.com> Thank You for Your answer, I am not sure what to try anymore, I guess I have to return "ime" from __slots__ at cvor() class to show proper strings and I am not able to do it. Now I am not sure that I am going at right direction to do Kevin Bacon game and will I be able to load this data into graph and find shortest way? From python at mrabarnett.plus.com Wed Jan 9 08:14:37 2019 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 9 Jan 2019 13:14:37 +0000 Subject: Working with graphs - Kevin Bacon game In-Reply-To: <4a314562-5a1f-4901-a73e-b9f35cef10dc@googlegroups.com> References: <4a314562-5a1f-4901-a73e-b9f35cef10dc@googlegroups.com> Message-ID: <5344c9a9-57e2-45a6-c707-2dbf74918f5e@mrabarnett.plus.com> On 2019-01-09 12:46, Josip Skako wrote: > Thank You for Your answer, > > I am not sure what to try anymore, I guess I have to return "ime" from __slots__ at cvor() class to show proper strings and I am not able to do it. > With: class cvor: __slots__ = ('ime','susjed') def __repr__(self): return self.ime if you say: print(kreiranjeCvora('Kevin Bacon')) you get: Kevin Bacon However, that might not be desirable because it means that: print([kreiranjeCvora('Kevin Bacon')]) gives you: [Kevin Bacon] so it might be better with: class cvor: __slots__ = ('ime','susjed') def __repr__(self): return ascii(self.ime) so that you get: ['Kevin Bacon'] > Now I am not sure that I am going at right direction to do Kevin Bacon game and will I be able to load this data into graph and find shortest way? > From dude.jimbo at gmail.com Wed Jan 9 08:42:20 2019 From: dude.jimbo at gmail.com (dude.jimbo at gmail.com) Date: Wed, 9 Jan 2019 05:42:20 -0800 (PST) Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: Message-ID: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> On Wednesday, January 9, 2019 at 6:06:35 AM UTC+1, Matthew Lemon wrote: > Hi, > > I would start from scratch with this. > > 1. You have latest Python 2 version. > 2. Use virtualenv to create and activate a new virtual environment. > 3. pip install wxPython and other dependencies. > 4. Get your application running from the command line first and follow up any DLL exceptions. > 5. Use pyinstaller (https://pyinstaller.readthedocs.io/en/stable/) to create a new exe file once you know everything works. > > Matt > > On 8 January 2019 10:38:16 GMT, I wrote: > >Hello, > > > >first time using python groups (and long time since using any other > >group for that matter). This might not be the right group due to wx > >being involved. > > > >Long story as short as possible. I have an old python script that I did > >~10 years ago, and have forgotten basically everything about Python > >since then (sorry!). Converted it to EXE way back when, and have kept > >using the EXE ever since then (on XP, and on Win7). > > > >I've just gotten a new PC, Windows10 (!), needed to update the script, > >so needed to recompile the EXE, and now it no longer compiles/works. It > >was fine on Windows7 (I'm not specifically stating that the problem is > >with windows10 - I simply don't remember all the hoops I jumped through > >on my previous machine). > > > >Here is the compile error: > >The following modules appear to be missing > >['_sysconfigdata'] > > > >And here is the runtime error: > >Traceback (most recent call last): > > File "AutoArchive.py", line 3, in > > File "wx\__init__.pyc", line 45, in > > File "wx\_core.pyc", line 4, in > > File "wx\_core_.pyc", line 12, in > > File "wx\_core_.pyc", line 10, in __load > >ImportError: DLL load failed: %1 is not a valid Win32 application. > > > >Here is how I compile: python setup.py py2exe > > > >And this is my setup.py: > >from distutils.core import setup > >import py2exe > > > >setup(console=['AutoArchive.py']) > > > >Yes, that says 'console' for a Windows EXE, but swapping it to 'window' > >didn't help. Besides which, the setup.py file is straight from the old > >computer, so 'it used to work'. > > > >What I have installed: > >. python 2.7.13 (this in itself may be a problem - I don't even > >remember which version I was using earlier, other than knowing for sure > >it wasn't a 3.x release) > >. wxpython (since I also got an error that wx module was missing - > >that rang some bells, since the script uses a Windows pop-up window to > >inform me about its progress, and I remember using wx for that, so I > >installed it, but don't know how to get its' version. using "python -c > >"import wx;print wx.__version__" just gives runtime errors). > > > >Any help would be appreciated. > > > >And yes, I googled, but can't really find anything (well, d'Uh!, I > >wouldn?t be here then would I?) - there's ~some~ references, but > >usually it's about similar issues on Linux, with solutions that are not > >applicable at all. Except one I thought: I found some link stating that > >_sysconfigdata is part of sysconfig, and that this needed to be > >installed with pip, so I used the pip that came with my python distro > >and did 'pip install [[_]sys]config[data]' (all possible combo's) but > >pip claims it can't find said module, and TBH, I can't seem to find > >anything myself about said module. > > > >Thx, > >Jimbo > >-- > >https://mail.python.org/mailman/listinfo/python-list > > -- > Sent from my Android device Thx for your feedback. I am a tad afraid you're giving me a bit too much credit though; it's all a bit Chinese to me. (I'm not Chinese, BTW, but I'm not making up these expressions myself so there's that). Step 2 you've lost me already. What is virtualenv, and why do I need it (this time round, not last time when I got it to work)? You don?t really need to respond, this is more of a rethorical question :). Step 3 is I think the real issue. At first I was missing 'wx' and '_sysconfigdata', so I installed wxPhyton (via a windows installer that I found, not with pip), and that made the compile error go away (though it still throws runtime errors, of course). But what is '_sysconfigdata', and how do I install it? I - and pip :) - can't find a repo with that name!? step 5, pyinstaller, is yet another hurdle I hope to avoid. It worked with py2exe, and it should still work with py2exe (within the efforts I'm prepared to put into this). Of course py2exe might be ancient and horrible and a bunch of other things that pyinstaller is not (I woulnd't know either way), but, to be honest, as well a tad cocky, I am not interested nor prepared to find out. Sorry about that, but hopefully one can understand. I'm not trying to 'get back into Python' , I just want something from the past back working again with minimal effort. Trying to get it to work in console sounds like a (backup) plan though. I don't really need the 'progress' popup window, so I could keep the script in console only. That would potentially circumvent the issues, but I would have preferred if I simply got it back to work as is, like I managed to do - when I was still a bit more 'fluent' in Python - way back when on my previous machine? From rosuav at gmail.com Wed Jan 9 08:58:39 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Jan 2019 00:58:39 +1100 Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> Message-ID: On Thu, Jan 10, 2019 at 12:46 AM wrote: > step 5, pyinstaller, is yet another hurdle I hope to avoid. It worked with py2exe, and it should still work with py2exe (within the efforts I'm prepared to put into this). Of course py2exe might be ancient and horrible and a bunch of other things that pyinstaller is not (I woulnd't know either way), but, to be honest, as well a tad cocky, I am not interested nor prepared to find out. Sorry about that, but hopefully one can understand. I'm not trying to 'get back into Python' , I just want something from the past back working again with minimal effort. > You want it to work with minimal effort? Then forget about py2exe and just distribute your .py files. WAY easier. ChrisA From jskako at gmail.com Wed Jan 9 09:09:38 2019 From: jskako at gmail.com (Josip Skako) Date: Wed, 9 Jan 2019 06:09:38 -0800 (PST) Subject: Working with graphs - Kevin Bacon game In-Reply-To: References: <4a314562-5a1f-4901-a73e-b9f35cef10dc@googlegroups.com> <5344c9a9-57e2-45a6-c707-2dbf74918f5e@mrabarnett.plus.com> Message-ID: I get it now, basically you are accessing class atributes with "self.something", thank You. So now I get this: "['Apollo 13 (1995)', 'Bill Paxton', 'Tom Hanks', 'Kevin Bacon\n', 'Begyndte ombord, Det (1937)', 'Aage Schmidt', 'Valso Holm\n', 'Bersaglio mobile (1967)', 'Dana Young', 'Bebe Drake\n', 'Bezottsovshchina (1976)', 'Yelena Maksimova', 'Lev Prygunov\n', 'Dark, The (1979)', 'Angelo Rossitto', 'William Devane\n', 'Death to Smoochy (2002)',..." That is great. What would be the best way now to find shortest path between ex. Tom Hanks and ex. William Devane? I should get something like: https://oracleofbacon.org/ Should I insert this data into networkx somehow, would it be easier? From grant.b.edwards at gmail.com Wed Jan 9 09:56:17 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 9 Jan 2019 14:56:17 +0000 (UTC) Subject: The following modules appear to be missing ['_sysconfigdata'] References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> Message-ID: On 2019-01-09, Chris Angelico wrote: > On Thu, Jan 10, 2019 at 12:46 AM wrote: >> step 5, pyinstaller, is yet another hurdle I hope to avoid. It worked with py2exe, and it should still work with py2exe (within the efforts I'm prepared to put into this). Of course py2exe might be ancient and horrible and a bunch of other things that pyinstaller is not (I woulnd't know either way), but, to be honest, as well a tad cocky, I am not interested nor prepared to find out. Sorry about that, but hopefully one can understand. I'm not trying to 'get back into Python' , I just want something from the past back working again with minimal effort. >> > > You want it to work with minimal effort? Then forget about py2exe and > just distribute your .py files. WAY easier. It may be easier, but it may not be feasible. That depends on what dependencies are involved and whether your target audience is capable of installing Python and those dependencies. Distributing .py files to my Windows customers is absolutely out of the question. There's no way I can expect them to install Python and whatever other dependenceis are required by my applications. That said, I've recently switched from py2exe to cx_freeze. However, even that isn't simple enough for my users, and I bundle the output from those with Inno Setup. -- Grant Edwards grant.b.edwards Yow! I'll show you MY at telex number if you show me gmail.com YOURS ... From songbird at anthive.com Wed Jan 9 09:56:03 2019 From: songbird at anthive.com (songbird) Date: Wed, 9 Jan 2019 09:56:03 -0500 Subject: The following modules appear to be missing ['_sysconfigdata'] References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> Message-ID: <3lehgf-mr5.ln1@anthive.com> Chris Angelico wrote: ... > You want it to work with minimal effort? Then forget about py2exe and > just distribute your .py files. WAY easier. which then forces the work onto every other person who might install it, if they are on a different architecture or system it even gets worse if you add in that they may need to figure out how to get a C compiler installed and available (if a bdist/wheel isn't available because the developer couldn't figure out how to generate one). for a novice user who just wants to get something done this isn't a very good solution. a build farm for common architectures would help a lot of developers avoid all this thrashing. songbird From python at mrabarnett.plus.com Wed Jan 9 10:22:52 2019 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 9 Jan 2019 15:22:52 +0000 Subject: Working with graphs - Kevin Bacon game In-Reply-To: References: <4a314562-5a1f-4901-a73e-b9f35cef10dc@googlegroups.com> <5344c9a9-57e2-45a6-c707-2dbf74918f5e@mrabarnett.plus.com> Message-ID: <94de9bc5-d3f6-ccee-5422-8d583935815a@mrabarnett.plus.com> On 2019-01-09 14:09, Josip Skako wrote: > I get it now, basically you are accessing class atributes with "self.something", thank You. > > So now I get this: > > "['Apollo 13 (1995)', 'Bill Paxton', 'Tom Hanks', 'Kevin Bacon\n', 'Begyndte ombord, Det (1937)', 'Aage Schmidt', 'Valso Holm\n', 'Bersaglio mobile (1967)', 'Dana Young', 'Bebe Drake\n', 'Bezottsovshchina (1976)', 'Yelena Maksimova', 'Lev Prygunov\n', 'Dark, The (1979)', 'Angelo Rossitto', 'William Devane\n', 'Death to Smoochy (2002)',..." > I notice that some of the strings end with '\n'. The best way to deal with that is to use .rstrip() on the line before splitting it. > That is great. > What would be the best way now to find shortest path between ex. Tom Hanks and ex. William Devane? > > I should get something like: https://oracleofbacon.org/ > > Should I insert this data into networkx somehow, would it be easier? > No, I wouldn't bother. You have 2 dicts: person_dict: the key is a person and the value is a list of films that contained that person. film_dict: the key is a film and the value is a list of persons in that film. You're looking for a list of links. Let's call that a "chain". You're working breadth-first, so you have a multiple chains, i.e. a list of lists. Start with a person. Initially you have a list that contains a list that in turn contains the starting person. [[person]] For each chain, look in person_dict for all of the films that the last person is in and duplicate the chain however many times you need, putting a film at the end of each. [[person, film], [person, film], ...] Then, for each chain, look in film_dict for all of the people who are in the last film and duplicate the chain however many times you need, putting a person at the end of each. [[person, film, person], [person, film, person], ...] Repeat until the last person in a chain is the target person (success!) or there are no chains remaining (no chain possible with the available information). Also, remove cycles, e.g. ['Bill Paxton', 'Apollo 13', 'Tom Hanks', 'Apollo 13', 'Bill Paxton']. From python at mrabarnett.plus.com Wed Jan 9 10:27:28 2019 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 9 Jan 2019 15:27:28 +0000 Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: <3lehgf-mr5.ln1@anthive.com> References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> <3lehgf-mr5.ln1@anthive.com> Message-ID: <64267304-bd22-dc78-f9aa-236adbaacc1b@mrabarnett.plus.com> On 2019-01-09 14:56, songbird wrote: > Chris Angelico wrote: > ... >> You want it to work with minimal effort? Then forget about py2exe and >> just distribute your .py files. WAY easier. > > which then forces the work onto every other > person who might install it, if they are on a > different architecture or system it even gets > worse if you add in that they may need to figure > out how to get a C compiler installed and > available (if a bdist/wheel isn't available > because the developer couldn't figure out how > to generate one). > > for a novice user who just wants to get > something done this isn't a very good solution. > > a build farm for common architectures would > help a lot of developers avoid all this thrashing. > .py files work on any platform that supports Python: Windows, Linux, MacOs, ... How many platforms support .exe files that were compiled for Windows? From grant.b.edwards at gmail.com Wed Jan 9 10:33:26 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 9 Jan 2019 15:33:26 +0000 (UTC) Subject: The following modules appear to be missing ['_sysconfigdata'] References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> <3lehgf-mr5.ln1@anthive.com> <64267304-bd22-dc78-f9aa-236adbaacc1b@mrabarnett.plus.com> Message-ID: On 2019-01-09, MRAB wrote: > .py files work on any platform that supports Python: Windows, Linux, > MacOs, ... Only after python has been installed along with any other required libraries. > How many platforms support .exe files that were compiled for Windows? None. But when your requirement is to support Windows users who are not capable of installing Python, WxWindows, and a half-dozen other libraries, you can't simply hand out .py files, push your fingers into your ears, close your eyes, and start yelling "your problem now, not mine, na, na, na, na, na, ...." -- Grant Edwards grant.b.edwards Yow! YOU PICKED KARL at MALDEN'S NOSE!! gmail.com From anton.gridushko at gmail.com Wed Jan 9 11:29:30 2019 From: anton.gridushko at gmail.com (anton.gridushko at gmail.com) Date: Wed, 9 Jan 2019 08:29:30 -0800 (PST) Subject: How to find files with a string Message-ID: <7583e54a-ac7c-4c04-a3a2-f7d518888d42@googlegroups.com> Hello everyone! I need to find a file, that contains a string TeNum I try to import os import sys def find_value(fname): value = 0 with open(fname, encoding='cp866') as fn: try: for i in fn: if 'TeNam' in i: print(fname) except IndexError: pass return {fname} def main(): dirname = ('H:\\1\\3') os.chdir(dirname) res = {} for i in os.listdir(dirname): res.update(find_value(i)) print('Filename is: ') if __name__ == "__main__": main() But there are mistakes like C:\Users\Anton\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py" Traceback (most recent call last): File "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py", line 21, in main() File "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py", line 18, in main res.update(find_value(i)) ValueError: dictionary update sequence element #0 has length 35; 2 is required Process finished with exit code 1 Could you help me to solve this thread? From __peter__ at web.de Wed Jan 9 11:53:26 2019 From: __peter__ at web.de (Peter Otten) Date: Wed, 09 Jan 2019 17:53:26 +0100 Subject: How to find files with a string References: <7583e54a-ac7c-4c04-a3a2-f7d518888d42@googlegroups.com> Message-ID: anton.gridushko at gmail.com wrote: > Hello everyone! > > I need to find a file, that contains a string TeNum > > I try to > > import os > import sys > def find_value(fname): > value = 0 > with open(fname, encoding='cp866') as fn: > try: > for i in fn: > if 'TeNam' in i: > print(fname) > except IndexError: > pass What's the purpose of that try...except? > return {fname} > def main(): > dirname = ('H:\\1\\3') > os.chdir(dirname) > res = {} For historical reasons {} is the literal for an empty dict; you probably want a set: res = set() > for i in os.listdir(dirname): > res.update(find_value(i)) > print('Filename is: ') > if __name__ == "__main__": > main() > > But there are mistakes like > C:\Users\Anton\AppData\Local\Programs\Python\Python36-32\python.exe > "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? > ?? ?????.py" Traceback (most recent call last): > File "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? > ?????? ?? ?????.py", line 21, in > main() > File "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? > ?????? ?? ?????.py", line 18, in main > res.update(find_value(i)) > ValueError: dictionary update sequence element #0 has length 35; 2 is > required You get the error because the dict.update() methods expects pairs: >>> d = {} >>> d.update({(1, 2)}) >>> d {1: 2} A string of length 2 will be taken as a pair, >>> d.update({"xy"}) >>> d {1: 2, 'x': 'y'} but a string of any other length will not: >>> d.update({"xyz"}) Traceback (most recent call last): File "", line 1, in ValueError: dictionary update sequence element #0 has length 3; 2 is required > > Process finished with exit code 1 > > Could you help me to solve this thread? From brian.j.oney at googlemail.com Wed Jan 9 12:08:47 2019 From: brian.j.oney at googlemail.com (Brian Oney) Date: Wed, 09 Jan 2019 18:08:47 +0100 Subject: How to find files with a string In-Reply-To: <7583e54a-ac7c-4c04-a3a2-f7d518888d42@googlegroups.com> References: <7583e54a-ac7c-4c04-a3a2-f7d518888d42@googlegroups.com> Message-ID: <1547053727.8922.6.camel@gmail.com> On Wed, 2019-01-09 at 08:29 -0800, anton.gridushko at gmail.com wrote: > Hello everyone! > > I need to find a file, that contains a string TeNum > > I try to > > import os > import sys > def find_value(fname): > value = 0 > with open(fname, encoding='cp866') as fn: > try: > for i in fn: > if 'TeNam' in i: > print(fname) > except IndexError: > pass > return {fname} > def main(): > dirname = ('H:\\1\\3') > os.chdir(dirname) > res = {} > for i in os.listdir(dirname): > res.update(find_value(i)) > print('Filename is: ') > if __name__ == "__main__": > main() > > But there are mistakes like > C:\Users\Anton\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py" > Traceback (most recent call last): > File "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py", line 21, in > main() > File "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py", line 18, in main > res.update(find_value(i)) > ValueError: dictionary update sequence element #0 has length 35; 2 is required > > Process finished with exit code 1 > > Could you help me to solve this thread? the error message is somewhat clear. You need to add a key-value pair to a dictionary. You may consider changing 'res' to a 'list'. You then need to 'append'. Either way, 'find_value' will return the filename regardless of whether the value is present or not. That should get you started. From toby at tobiah.org Wed Jan 9 12:13:54 2019 From: toby at tobiah.org (Tobiah) Date: Wed, 9 Jan 2019 09:13:54 -0800 Subject: Email blast management? Message-ID: I'm tasked with adding the ability for users of a website to send bulk emails out to their customers. Before I write it all from scratch, are there any good tools that will allow me to provide: * A place to compose their email, with images and links * A way to manage their list of recipients Perhaps most important: * A way to verify emails, track (as much as possible) receipt of the email, and track bounce-backs, click-throughs, etc. The solution could be anywhere from close to an entire solution, like some free, light CRM package, down to recommendations on some good supporting libraries that will help me with any of these tasks. Thanks, Tobiah From rosuav at gmail.com Wed Jan 9 12:57:47 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Jan 2019 04:57:47 +1100 Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> <3lehgf-mr5.ln1@anthive.com> <64267304-bd22-dc78-f9aa-236adbaacc1b@mrabarnett.plus.com> Message-ID: On Thu, Jan 10, 2019 at 2:37 AM Grant Edwards wrote: > > On 2019-01-09, MRAB wrote: > > > .py files work on any platform that supports Python: Windows, Linux, > > MacOs, ... > > Only after python has been installed along with any other required > libraries. > > > How many platforms support .exe files that were compiled for Windows? > > None. > > But when your requirement is to support Windows users who are not > capable of installing Python, WxWindows, and a half-dozen other > libraries, you can't simply hand out .py files, push your fingers into > your ears, close your eyes, and start yelling "your problem now, not > mine, na, na, na, na, na, ...." This is true - but on the flip side, it's a bit unfair to say "blah blah Python sucks because py2exe is hard". That's not Python's fault. You have an additional requirement ("support people who can't install Python"), and that's going to have extra hassles. LOTS of them, in this case. ChrisA From avigross at verizon.net Wed Jan 9 12:59:07 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 9 Jan 2019 12:59:07 -0500 Subject: Working with graphs - Kevin Bacon game - WOT Message-ID: <006801d4a845$049d6260$0dd82720$@verizon.net> [HUMOR ALERT] Others have given answers that are on topic so mine is not needed. I was amused by the understandable spelling error about doing the unusual variant of a Breath First Search when it is clear they meant Breadth. But it may apply in this case. The Keven Bacon Game is a variation on calculating the Erd?s number. It relates to finding people who were in a film alongside Kevin Bacon and presumably were at some point in close enough proximity to share some component of Breath. They are the closest degree you can get to Kevin without being him. Anyone in a film with one of those people but not directly in a film with Kevin is of a second degree and so on. Still others get the third degree and I won't question that. There are several problems with an approach based on breath. The first is that movies are often made in which the participants work in different areas and never meet. Simply being in the same film does not guarantee that level of closeness. And, I have seen convincing arguments that suggest the likelihood we have all shared the recycled breath of historical figures and very possibly have incorporated atoms that once resided within their bodies into our own. I will spare you the calculations except to say that in some ways we are all one. We have all breathed air that includes minor amounts once in not only a particular Pharaoh in Egypt but also from just about anyone in his kingdom that lived a moderately long life -- no matter where on earth we live. A modern figure like Kevin Bacon gets around and certainly if you live in an area like parts of California he lived in, you may be very close in a Breath First search but without much Depth. And, yes, pythons breathe the same air we do, as do python programmers, just to bring this back to whatever it is we are supposed to waste our breath "talking" about here. -----Original Message----- From: Python-list On Behalf Of jskako at gmail.com Sent: Wednesday, January 9, 2019 4:54 AM To: python-list at python.org Subject: Working with graphs - Kevin Bacon game I am working on Kevin Bacon game. I have "movies.txt" text file that looks like: Apollo 13 (1995);Bill Paxton;Tom Hanks;Kevin Bacon Begyndte ombord, Det (1937);Aage Schmidt;Valso Holm Bersaglio mobile (1967);Dana Young;Bebe Drake Bezottsovshchina (1976);Yelena Maksimova;Lev Prygunov Dark, The (1979);Angelo Rossitto;William Devane etc,... So in first row we have movie name, and in other rows we have actors for that movie. I am trying to make Kevin Bacon game with breath-first search. My source code (Python 3.X): class cvor: __slots__ = ('ime','susjed') def kreiranjeCvora(ime): n = cvor() n.ime = ime n.susjed = [] return n def pronadiCvor(cvorlist, ime): for n in cvorlist: if n.ime == ime: return n def ucitajGraf(file): graph = [] for line in file: imeGlumaca = [] mojaLinija = line.split(";") imeFilma = mojaLinija[0] for i in range (1,len(mojaLinija)): imeGlumaca.insert(len(imeGlumaca), mojaLinija[i]) cvorFilm = pronadiCvor(graph, imeFilma) if cvorFilm == None: cvorFilm = kreiranjeCvora(imeFilma) graph.append(cvorFilm) for glumac in imeGlumaca: glumacCvor = pronadiCvor(graph,glumac) if glumacCvor == None: glumacCvor = kreiranjeCvora(glumac) graph.append(glumacCvor) glumacCvor.susjed.append(cvorFilm) cvorFilm.susjed.append(glumacCvor) return graph def main(): f = open("movies.txt") graf = ucitajGraf(f) print (graf) main() My problem is that when I print graph with "print (graph)" I am getting: "[<__main__.cvor object at 0x000001475275EBE0>, <__main__.cvor object at 0x000001475275EEF0>, <__main__.cvor object at 0x000001475275EFD0>, <__main__.cvor object at 0x000001475275EE80>, <__main__.cvor object at 0x000001475275EB70>, <__main__.cvor object at 0x000001475275ED68>,..." And I know why but I don't know how to fix it and get "name" there. What would be the best way to perform breath-first search between two entered names? -- https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Wed Jan 9 12:59:07 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Jan 2019 04:59:07 +1100 Subject: Email blast management? In-Reply-To: References: Message-ID: On Thu, Jan 10, 2019 at 4:19 AM Tobiah wrote: > > I'm tasked with adding the ability for users of a website to > send bulk emails out to their customers. Before I write it all > from scratch, are there any good tools that will allow me to provide: > > > * A place to compose their email, with images and links > > * A way to manage their list of recipients > > Perhaps most important: > > * A way to verify emails, track (as much as possible) receipt > of the email, and track bounce-backs, click-throughs, etc. > > The solution could be anywhere from close to an entire solution, like > some free, light CRM package, down to recommendations on some good supporting > libraries that will help me with any of these tasks. TBH, I'd recommend using a service like MailChimp, avoiding the entire Python question at all. Though if you want to use Python specifically, Mailman (the mailing list software) can be used for announcements. Wouldn't help you with composing the email, but it covers a lot of the rest. ChrisA From matt at matthewlemon.com Wed Jan 9 13:07:18 2019 From: matt at matthewlemon.com (Matthew Lemon) Date: Wed, 09 Jan 2019 18:07:18 +0000 Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> <3lehgf-mr5.ln1@anthive.com> <64267304-bd22-dc78-f9aa-236adbaacc1b@mrabarnett.plus.com> Message-ID: If the OP was able to take the time to familiarise himself with the technologies, rather than bemoan the difficulty of deploying a ten year old code-base without mininal effort, he might have some success. Code rot is an issue after weeks sometimes, never mind ten years, and Python deployment is a weakness. However the tools do exist if you are prepared to give it a go. I've had most successful with pyinstaller, which is why I linked to it. Good luck! On 9 January 2019 17:57:47 GMT, Chris Angelico wrote: >On Thu, Jan 10, 2019 at 2:37 AM Grant Edwards > wrote: >> >> On 2019-01-09, MRAB wrote: >> >> > .py files work on any platform that supports Python: Windows, >Linux, >> > MacOs, ... >> >> Only after python has been installed along with any other required >> libraries. >> >> > How many platforms support .exe files that were compiled for >Windows? >> >> None. >> >> But when your requirement is to support Windows users who are not >> capable of installing Python, WxWindows, and a half-dozen other >> libraries, you can't simply hand out .py files, push your fingers >into >> your ears, close your eyes, and start yelling "your problem now, not >> mine, na, na, na, na, na, ...." > >This is true - but on the flip side, it's a bit unfair to say "blah >blah Python sucks because py2exe is hard". That's not Python's fault. >You have an additional requirement ("support people who can't install >Python"), and that's going to have extra hassles. LOTS of them, in >this case. > >ChrisA >-- >https://mail.python.org/mailman/listinfo/python-list -- Sent from my Android device From avigross at verizon.net Wed Jan 9 13:33:17 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 9 Jan 2019 13:33:17 -0500 Subject: How to find files with a string In-Reply-To: <7583e54a-ac7c-4c04-a3a2-f7d518888d42@googlegroups.com> References: <7583e54a-ac7c-4c04-a3a2-f7d518888d42@googlegroups.com> Message-ID: <007701d4a849$ca241bb0$5e6c5310$@verizon.net> Anton, OVERVIEW: SET vs DICT Some of us have less experience decoding Cyrillic error messages. The part we can read suggests the program objected to the way a dictionary was being updated. ValueError: dictionary update sequence element #0 has length 35; 2 is required (The Russian said something like: Working with the file system / Searching files from the .py folder) The normal method is to provide something that evaluates to a key/value combination. You made an empty dictionary with {} NOT an empty set which is only created using the notation set(). Your find_value() function returns a SET containg the filename unconditionally this way: return {fname} That is not a dictionary entry. It is a set and this is not something you can add to a dictionary as it has no key. Why the 35 above? I would guess it may be seen as a list of 35 charcaters or something. Two more points. Your text says searching for TeNum but the function searches for TeNam. Worse, the function seems to be wrong for the purpose intended. If the goal is to search line by line and if found any number of times, return the filename, it does not do that. It seems to print the filename when any line matches. No idea why you do some other things but the return is unconditional so it should return every filename it finds. -----Original Message----- From: Python-list On Behalf Of anton.gridushko at gmail.com Sent: Wednesday, January 9, 2019 11:30 AM To: python-list at python.org Subject: How to find files with a string Hello everyone! I need to find a file, that contains a string TeNum I try to import os import sys def find_value(fname): value = 0 with open(fname, encoding='cp866') as fn: try: for i in fn: if 'TeNam' in i: print(fname) except IndexError: pass return {fname} def main(): dirname = ('H:\\1\\3') os.chdir(dirname) res = {} for i in os.listdir(dirname): res.update(find_value(i)) print('Filename is: ') if __name__ == "__main__": main() But there are mistakes like C:\Users\Anton\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py" Traceback (most recent call last): File "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py", line 21, in main() File "C:/Users/Anton/PycharmProjects/?????? ? ???????? ????????/??????? ?????? ?? ?????.py", line 18, in main res.update(find_value(i)) ValueError: dictionary update sequence element #0 has length 35; 2 is required Process finished with exit code 1 Could you help me to solve this thread? -- https://mail.python.org/mailman/listinfo/python-list From grant.b.edwards at gmail.com Wed Jan 9 13:44:17 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 9 Jan 2019 18:44:17 +0000 (UTC) Subject: The following modules appear to be missing ['_sysconfigdata'] References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> <3lehgf-mr5.ln1@anthive.com> <64267304-bd22-dc78-f9aa-236adbaacc1b@mrabarnett.plus.com> Message-ID: On 2019-01-09, Chris Angelico wrote: > On Thu, Jan 10, 2019 at 2:37 AM Grant Edwards wrote: > >> > How many platforms support .exe files that were compiled for Windows? >> >> None. >> >> But when your requirement is to support Windows users who are not >> capable of installing Python, WxWindows, and a half-dozen other >> libraries, you can't simply hand out .py files, push your fingers into >> your ears, close your eyes, and start yelling "your problem now, not >> mine, na, na, na, na, na, ...." > > This is true - but on the flip side, it's a bit unfair to say "blah > blah Python sucks because py2exe is hard". That's not Python's fault. Of course not. > You have an additional requirement ("support people who can't install > Python"), and that's going to have extra hassles. LOTS of them, in > this case. Supporting distribution of any "real-world" application in any language on Microsoft Windows involves most of the same problems. It's slightly easier for some languages than it is for others. Just handing out .exe files built with nothing but the global default C run-time library is possible -- but, when was the last time you saw an application distributed like that? -- Grant Edwards grant.b.edwards Yow! People humiliating at a salami! gmail.com From tjreedy at udel.edu Wed Jan 9 16:01:30 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Jan 2019 16:01:30 -0500 Subject: How to find files with a string In-Reply-To: <7583e54a-ac7c-4c04-a3a2-f7d518888d42@googlegroups.com> References: <7583e54a-ac7c-4c04-a3a2-f7d518888d42@googlegroups.com> Message-ID: On 1/9/2019 11:29 AM, anton.gridushko at gmail.com wrote: > I need to find a file, that contains a string TeNum IDLE's 'Find in Files' is a mid-level grep with GUI interface. The code is in idlelib/grep.py if you want to copy code. -- Terry Jan Reedy From eliran.gonen at gmail.com Wed Jan 9 16:00:18 2019 From: eliran.gonen at gmail.com (elig0n) Date: Wed, 9 Jan 2019 13:00:18 -0800 (PST) Subject: curses textpad.py UTF-8 support Message-ID: <90321155-5ec2-4783-a71e-3e04138d57ed@googlegroups.com> is non existent. Unicode input text won't show up. It probably needs to be rewritten with get_wch() as was suggested in the following SO question before get_wch() was implemented, together with proper key code parsing (in do_command()) and probably more as to prevent breakage [ https://stackoverflow.com/questions/42510606/python-curses-textpad-textbox-keyboard-input-not-working-with-german-umlauts ]. From songbird at anthive.com Wed Jan 9 15:55:49 2019 From: songbird at anthive.com (songbird) Date: Wed, 9 Jan 2019 15:55:49 -0500 Subject: The following modules appear to be missing ['_sysconfigdata'] References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> <3lehgf-mr5.ln1@anthive.com> <64267304-bd22-dc78-f9aa-236adbaacc1b@mrabarnett.plus.com> Message-ID: Chris Angelico wrote: ... > This is true - but on the flip side, it's a bit unfair to say "blah > blah Python sucks because py2exe is hard". That's not Python's fault. > You have an additional requirement ("support people who can't install > Python"), and that's going to have extra hassles. LOTS of them, in > this case. i'm not as much worried about the python 3 install as much as the C compiler that the graphics libs seem to want to use during install from source. that is likely not as easy to do. as i don't even have a Windows machine here at all i can only read up on it as much as i can and try to take some notes with me of things to check and try out and hope that is enough. i should be ok, but i'm not a Windows expert by far. so ... :) songbird From songbird at anthive.com Wed Jan 9 15:48:16 2019 From: songbird at anthive.com (songbird) Date: Wed, 9 Jan 2019 15:48:16 -0500 Subject: The following modules appear to be missing ['_sysconfigdata'] References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> <3lehgf-mr5.ln1@anthive.com> <64267304-bd22-dc78-f9aa-236adbaacc1b@mrabarnett.plus.com> Message-ID: MRAB wrote: > On 2019-01-09 14:56, songbird wrote: >> Chris Angelico wrote: >> ... >>> You want it to work with minimal effort? Then forget about py2exe and >>> just distribute your .py files. WAY easier. >> >> which then forces the work onto every other >> person who might install it, if they are on a >> different architecture or system it even gets >> worse if you add in that they may need to figure >> out how to get a C compiler installed and >> available (if a bdist/wheel isn't available >> because the developer couldn't figure out how >> to generate one). >> >> for a novice user who just wants to get >> something done this isn't a very good solution. >> >> a build farm for common architectures would >> help a lot of developers avoid all this thrashing. >> > .py files work on any platform that supports Python: Windows, Linux, > MacOs, ... .py isn't the point as somehow the modules i am using compile C code during the install. i'd be happier if they didn't, but i don't have a way to easily generate those files myself that i know of. > How many platforms support .exe files that were compiled for Windows? depends upon the versions... i have some pretty ancient Windows/DOS programs that work fine under dosbox in my Debian Linux testing setup. i haven't checked them out lately though to see if they're still runnable (good chance they're ok). been busy with other things and besides i finally moved the ancient spreadsheets from Multiplan to Libreoffice. songbird From songbird at anthive.com Wed Jan 9 16:04:13 2019 From: songbird at anthive.com (songbird) Date: Wed, 9 Jan 2019 16:04:13 -0500 Subject: The following modules appear to be missing ['_sysconfigdata'] References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> <3lehgf-mr5.ln1@anthive.com> <64267304-bd22-dc78-f9aa-236adbaacc1b@mrabarnett.plus.com> Message-ID: Matthew Lemon wrote: > If the OP was able to take the time to familiarise himself with the technologies, rather than bemoan the difficulty of deploying a ten year old code-base without mininal effort, he might have some success. Code rot is an issue after weeks sometimes, never mind ten years, and Python deployment is a weakness. However the tools do exist if you are prepared to give it a go. I've had most successful with pyinstaller, which is why I linked to it. Good luck! i looked at it, will require further reading/testing. i see part of my list of modules are supported but not sure all are without a test. will have to look into it further. tks. :) songbird (not the OP, but in a similar and perhaps more complicated boat... From songbird at anthive.com Wed Jan 9 15:39:54 2019 From: songbird at anthive.com (songbird) Date: Wed, 9 Jan 2019 15:39:54 -0500 Subject: The following modules appear to be missing ['_sysconfigdata'] References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> Message-ID: Grant Edwards wrote: ... > That said, I've recently switched from py2exe to cx_freeze. However, > even that isn't simple enough for my users, and I bundle the output > from those with Inno Setup. i looked at the one and stopped at that because alas, i have no Windows or MacOS machines to generate any binaries, though i would guess that the MacOS may have an easier path to getting a C compiler installed (but i don't know, my MacOS person hasn't said anything yet). in looking at the Python install for Windows it looks like i will probably want to do it to make sure that the paths are set up correctly. the C compiler, don't know how easy that might be until i do it, which i hate when sitting in someone else's house with them hovering. considering i haven't touched Windows since XP and really am not an expert these days it should be entertaining. my code is all python 3 so that at least should simplify some things. songbird From avigross at verizon.net Wed Jan 9 21:00:36 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 9 Jan 2019 21:00:36 -0500 Subject: How to find files with a string ++ Message-ID: <006c01d4a888$4746ade0$d5d409a0$@verizon.net> [This message comments on three different items being discussed and also on how to find out what kind of help is actually requested and warranted.] People don't usually provide enough context in their requests and I see wildly different attempts to help. When some code is supplied along with perhaps an error message, some people try to see what may be wrong and assume they want to use a slightly improved version of the code to solve whatever their goal is. Others point to where some other code does it perhaps a very different way such as the code in IDLE. Some tell you to go elsewhere and use a finished product as below. So, sure, you can just go and use grep. And some focus on things like efficiency or portability or how pythonic its is, whatever that means to THEM. What is missing at times is the question of what do you want to do next or even before. That may help guide what is wanted. It is not easy to guess especially since Anton may not be using the data structures he might if he was more experienced in python. He seems to be wanting to use a set which may not seem very focused if the file names are all unique already. Some might use something simpler and ordered like a list. If his purpose is to do something like show which files do NOT match, sure he could make a set of all files and subtract this set but that is not needed as it is quite simple to record just files that don't match in the first place. I am left with a few other anomalies that make me think it would be better to stop and ask what they want in clearer terms because their overall approach does not lead me to something obvious. When people post here, there is no way to enforce their telling us their general goals. It can be anything from a student trying to solve a problem using very basic methods they are supposed to have covered in class to someone just trying to get a task done just once and not caring much what tools is used and hoping someone on this forum has a quick answer. If someone says they want to code each one of dozens of algorithms they read about from SCRATCH, that means they are willing to reinvent the wheel. They may literally not want any comment on any aspect of their code except asking how to fix the one error they got. In this case, I am not clear if the answer is to initialize a set rather than a dictionary, or to use a list in the first place, or if using a dictionary, supply a key. Perhaps they do not (yet) want to hear their entire function always returns the filename or maybe it should return an item instead of a set containing an item or ... I am reading a book about Clean Code and I note that sometimes here we ignore fairly simple things and fall for a more gimmicky, if brilliant, attempt to make something non-obvious. The example was one that comes up regularly, how to see if two items are equal. In this case, the question was how to tell if a list of N items contained N identical items. A fairly straightforward answer would be to loop starting with a second item and keep comparing the current item to the withheld first. Optionally, quit as soon as a discrepancy was found. It would depend on using a binary "==" on two items at a time. Others offered more inline solutions that hide a loop, such as "any" ad many such variations are possible. I am not saying they are all good solutions, and many are fairly horrible such as trying to compare all permutations.. But one suggested solution was beautiful and elegant (as in short) and boiled down to comparing the list to its top-level reversal. It is true that anything with N identical copies will be shown that way but only as a special case as it is a palindrome. And, it begs the question of how python evaluates "list1 == list2" as that may be just syntactic sugar for a method similar or different to the straightforward ones. I am surprised nobody suggested this one. First in English. Take the original list. Assuming it is long enough, rotate it a notch so the former first item is now at the end and the former second item is in front. Compare the two versions of the list. A palindrome would be ruined by this simple manipulation assuming you started with three or more. Before I present the trivial code, I want to remind everyone this is NOT a suggested method. I do NOT want to get lectured at as if I suggested it. It is what I call an academic exercise. It is a minor variant designed to foil the darn palindrome case. For argument's sake, a list with no items or a single item would be solved without calling the function below. Something with two can harmlessly passed to the function but does not need to be. Only three and above need apply. I have no doubt there are better ways but this method would allow something small and nice like: a == sh(a) Anyway, here is the code followed by the output just for ILLUSTRATION. If you can show test cases where it fails, feel free. def shift_eq(listing): """Compare a list to a rotated version.""" """Returning True if they are identical.""" print("comparing:") print(listing) shifted = listing[1:] + listing[0:1] print(shifted) print("with Truth Value:") result = (listing == shifted) print(result) return result good, bad = [[1],[8]], [[666]] shift_eq([ good, good, good, good, good ]) shift_eq([ good, bad, good, bad, good ]) shift_eq([ bad, good, good, good, good ]) shift_eq([ good, bad, good, good, good ]) shift_eq([ good, good, good, good, bad ]) Output comparing: [[[1], [8]], [[1], [8]], [[1], [8]], [[1], [8]], [[1], [8]]] [[[1], [8]], [[1], [8]], [[1], [8]], [[1], [8]], [[1], [8]]] with Truth Value: True comparing: [[[1], [8]], [[666]], [[1], [8]], [[666]], [[1], [8]]] [[[666]], [[1], [8]], [[666]], [[1], [8]], [[1], [8]]] with Truth Value: False comparing: [[[666]], [[1], [8]], [[1], [8]], [[1], [8]], [[1], [8]]] [[[1], [8]], [[1], [8]], [[1], [8]], [[1], [8]], [[666]]] with Truth Value: False comparing: [[[1], [8]], [[666]], [[1], [8]], [[1], [8]], [[1], [8]]] [[[666]], [[1], [8]], [[1], [8]], [[1], [8]], [[1], [8]]] with Truth Value: False comparing: [[[1], [8]], [[1], [8]], [[1], [8]], [[1], [8]], [[666]]] [[[1], [8]], [[1], [8]], [[1], [8]], [[666]], [[1], [8]]] with Truth Value: False Note if still reading, there would be a loop version of this in which you zip together a list and the rotated version and compare each item in the loop, leaving when any don't match. Finally, on another forum for tutoring python that I no longer participate in, I saw a request that may explain my own quandary. After reading the request 9detail not that important) my first thought was how trivial it might be to solve as it looked like they could use packages that would read all the tabs in what looked like an EXCEL file into a list of DataFrame objects that could then easily be manipulated to their needs. But their code seemed to indicate they were trying to figure out how to do some of this using more primitive methods by somehow getting the numbers into two lists. There are oodles of tools to manipuIate a DataFrame and many more to manipulate each numpy array composing it but I did not get involved. That forum is for fairly new learners using base python and maybe the normally bundled modules, not for numpy and pandas and the machine learning and statistics modules I am focused on. On this forum, if someone asks for what to use to get a job done rapidly and accurately, I might be happy to chime in with what little I know. -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Wednesday, January 9, 2019 2:02 PM To: python-list at python.org Subject: Re: How to find files with a string On Wed, 9 Jan 2019 08:29:30 -0800 (PST), anton.gridushko at gmail.com declaimed the following: >Hello everyone! > >I need to find a file, that contains a string TeNum > Well... The easiest way would be to use the OS "find" or "findstr" command. You appear to be on Windows so: ... From avigross at verizon.net Wed Jan 9 22:22:23 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 9 Jan 2019 22:22:23 -0500 Subject: dangerous class neighborhood In-Reply-To: References: <005f01d49e2d$8ed49380$ac7dba80$@verizon.net> Message-ID: <007701d4a893$b4859820$1d90c860$@verizon.net> This message is a delayed reply to what Chris wrote late last year and I initially chose not to reply to. My fault, as I was having a few bad days and did not see the content as constructive. But as things are fine now and I have seen more of what Chris posts, I will reply, but not in-line as I want to make a few focused replies. And I note Chris has a sense of humor that oddly may align with mine so I regret the misunderstanding. No unending back and forth messages are needed. I think we may understand each other. Those not interested, feel free to escape. FOREPLAY: Like some of my posts, I wrote a fairly long message asking questions about choices people might want to make and offering perhaps uncommon solutions. I have no actual current interest in the specific problem for any actual programming I am doing. Just a discussion. As such, some of my questions in the original message should NOT have a definite answer as much as a range of opinions depending on the circumstance. The overall scenario, to remind some readers, was some unusual behavior when someone was doing calculations within the body of a class definition that involved evaluating constants into an assortment of class variables with some massaging. I asked this: > Question 2: Do you want the variables available at the class level or at the instance level? That again is a question to which I deny there is a specific answer. I was asking if the USER at that moment preferred or needed one or the other. I mean python allows you to do it quite a few ways. If you want a counter of how many objects have been instantiated that are descended from that class, for instance, then the counter makes perfect sense as being a variable stored in the single shared object representing the class. Constants also probably do not need to be defined and created in every single instance of a class. But there may be times you do want it there such as if you want to modify them or perhaps use them up with each instance starting with the same ones. CHRIS: For constants, definitely put them on the class. They'll be available on instances as well ("for free", if you like). For mutables, obviously you need to decide on a case-by-case basis. In that light, Chris answered well enough except I think I reacted to the word "definitely" as a suggestion that the question of what the user might want as being silly. A closer look now indicates that the second part allows different choices for something like mutables. So I have no disagreement. As always, I can think of other reasons why the lunch is not free as it takes extra work to search for variables higher up in the class chain and it gets ridiculous with multiple inheritance. My next question was focused on how to work within the rules to avoid this anomaly. If you need a reminder, it had something to do with the scope within a class definition and whether it was visible to functions deeper within the scope visually but not by the rules python currently has. > Question 3: Which python variations on syntactic sugar, such as list > comprehensions, get expanded invisibly in ways that make the problem > happen by asking for variables to be found when no longer in the visible range? CHRIS: The oddities with comprehensions were tackled partly during the discussion of PEP 572. If you want to know exactly why this isn't changing, go read a few hundred emails on the subject. A lot of the main points are summarized in the PEP itself: Now on the one hand, the reply was full of PEP but did not directly seem to address my point, at first. My first take was GO READ IT. HUNDREDS of emails? Reasonable but I had too much else to work on so a bit frustrating. What I had hoped for was a list of specific python varieties of code such as a list comprehension and so on. In later discussions with Chris I realize he was probably frustrated as he saw the ultimate cause of the original problem as rather artificial and not quite due to the scope rules "effect" I seemed to be asking about. In particular, I was looking (elsewhere in the post) for ways to find a more hospitable and reliable place where you could use ANY python functionality you wished and get a valid result and simply EXPORT the results to whatever place (class, instance, or something external) to be used when needed. Chris may have wondered what problem I was solving as there wasn't one. I won't copy all the rest, as it can be seen below, I presented some ways this could be done. One was to do it in an initializer and save the results in the instance, or if needed overwrite it in the class) or do it all in a single function (all local scope) and return multiple outputs that can be instantiated in the class. The comments Chris made were not focused in the direction I was trying to do as he did not necessarily see it as a problem to solve. Fair enough. I may be a bit poisoned in that my reading has shown that deeper aspects of python are riddled with anomalies and places where good people disagree about the wisdom of adding a feature like super() and assumed this was a bigger anomaly. Chris does not and I think is right. CHRIS: If you write simple and Pythonic code, these will almost always work perfectly. The recent thread citing an oddity worked just fine until it was written to iterate over range(len(x)) instead of iterating directly. That remark is reasonable to a point. Indeed, there was no reason to iterate over a range. However, it was VALID code that would work elsewhere and would work (presumably) in the safe havens I was describing. At no point did I suggest anything I was looking at was particularly efficient. It is perfectly fair to say that my methods are silly because of that but the attitude I thought I saw seemed sarcastic because I was presenting a solution to a different problem and efficiency was not really a concern. I have often seen code that I looked at as ridiculously inefficient as it passed over the data over and over to do calculations that could easily be combined. It might for example describe a data set by telling how many entries (n) there are, and the minimum and maximum and mean and median and variance and standard deviation and skew and kurtosis and more. Each item is calculated by calling a function that returns just that. But you could easily write a simple loop or two that would pass over the data maybe twice and do all that. But sometimes simple works too, and is easier to understand as it does one thing well. CHRIS: Lovely. Now you have to define your variables once inside the function, then name them a second time in that function's return statement, and finally name them all a *third* time in the class statement (at least, I presume "def Foo():" is meant to be "class Foo:"). A mismatch will create bizarre and hard-to-debug problems. What do you actually gain? Can you show me real-world code that would truly benefit from this? Well, clearly we spoke past each other. He is right I meant class, not def. Yes, it is not intended to be at all efficient. Now, after some discussion, it may be more easy to understand. Yes, all the copying of variables was indeed done. We can complain about a compiler that loads variables from memory into registers A and B, does a calculation then copies some back to memory as being wasteful but if the architecture works only in registers, it is not. Every time you do something simple by using a function you incur additional overhead and yet it often is seen as a better way for other reasons. So, yes, What I wrote was KNOWN to be less efficient. It was not THE point. I won't give lots of other examples when the code would benefit from this. The benefit was in doing the calculation in a place I knew would not show anomalies at a time when I thought the class context was the problem. I now know that there was not much of a need as it is generally a safe enough place and thus no gimmicks are normally needed. The remaining comments are now seen in this light and need no further replies from me. Many seem to be knocking down a strawman I did not think I had set up. CHRIS: Unified? No more so than the class statement itself. Safe? Definitely not, because of the mandatory duplication of names. CHRIS: Uhh..... nope, that's nothing but FUD. There is no reason to believe that some language features would be "unsafe". Another example of criticism follows when I made a general comment about how list comprehensions are really made into a while loop and he corrected my generalism as if I was saying this was all of it. My style can go from abstract to concrete and back and admittedly may be hard to follow. Still, I did say ' some parts may expand to calls to a "range" statement ' as an example but meant that if the list comprehension had a call within it to a range statement, that would then show up in the fully developed loop. I was not intending to say a list comprehension normally created a range statement. And I also mentioned it could include an 'if' which obviously it can but only if included in the comprehension in the first place. I saw the reply as nitpicking. I suspect that long before this, Chris developed an impression of me based on a misunderstanding or two and at this point was looking for anything to snap at and I FELT IT and reacted accordingly. I make no claims about relative abilities and have only recently focused on python but I doubt I am the boob these comments make it sound like. I am a bit more of a generalist who learns more and more until he knows nothing about everything ? This forum was supposed to be about reasonable and serious debates, not about whatever this reply started to look like. My views when viewed properly are rather close to what Chris says, except that I generally did not say what he is replying to here. In particular, I would NOT write the code the way I discuss unless everything else I tried failed. So, I am leaving it like that. I differentiate between what is valid use of the language and what is a 'best practice' and what works quickly when you hit a roadblock and need to get around it NOW using some kind of patch that may even be outside the box. Main point: I haver no beef with Chris, or anyone here. The neighborhood is safe again. -----Original Message----- From: Python-list On Behalf Of Chris Angelico Sent: Thursday, December 27, 2018 5:11 PM To: Python Subject: Re: dangerous class neighborhood On Fri, Dec 28, 2018 at 8:47 AM Avi Gross wrote: > Question 2: Do you want the variables available at the class level or > at the instance level? For constants, definitely put them on the class. They'll be available on instances as well ("for free", if you like). For mutables, obviously you need to decide on a case-by-case basis. > Question 3: Which python variations on syntactic sugar, such as list > comprehensions, get expanded invisibly in ways that make the problem > happen by asking for variables to be found when no longer in the visible range? The oddities with comprehensions were tackled partly during the discussion of PEP 572. If you want to know exactly why this isn't changing, go read a few hundred emails on the subject. A lot of the main points are summarized in the PEP itself: https://www.python.org/dev/peps/pep-0572/ > There may be matters of efficiency some would consider but some of the > examples seen recently seemed almost silly and easy to compute. The > people asking about this issue wanted to define a bunch of CONSTANTS, > or things that might as well be constants, like this: > > > > def Foo(): > > A = ("male", "female", "other") > > B = [ kind[0] for kind in A ] # First letters > only > > # And so on making more constants like a dictionary > mapping each string to a number or vice versa. > > > > All the above can be evaluated at the time the class is defined but > unintuitive scope rules make some operations fail as variables defined > in the scope become unavailable to other things that SEEM to be > embedded in the same scope. If you write simple and Pythonic code, these will almost always work perfectly. The recent thread citing an oddity worked just fine until it was written to iterate over range(len(x)) instead of iterating directly. > If they are ONLY to be used within an instance of Foo or invoked from > within there, there may be a fairly simple suggestion. If you already > have a __init__ method, then instantiate the variables there carefully > using the self object to reference those needed. But why? __init__ should initialize an instance, not class-level constants. A Python class is not restricted to just methods, and there's no reason to avoid class attributes. > Create a function either outside the class or defined within. Have it > do any internal calculations you need in which all internal variables > can play nicely with each other. Then let it return all the variables > in a tuple like > this: > > def make_sexual_constants(): > > A = . > > B = . > > C = f(A,B) > > D = . > > def Foo(): > > (A, B, C, D) = make_sexual_constants(): Lovely. Now you have to define your variables once inside the function, then name them a second time in that function's return statement, and finally name them all a *third* time in the class statement (at least, I presume "def Foo():" is meant to be "class Foo:"). A mismatch will create bizarre and hard-to-debug problems. What do you actually gain? Can you show me real-world code that would truly benefit from this? > Can we agree that the class Foo now has those 4 variables defined and > available at either the class level or sub-class or instance levels? > But the values are created, again, in a unified safe environment? Unified? No more so than the class statement itself. Safe? Definitely not, because of the mandatory duplication of names. > As noted in section 3, it would be good to know what python features > may be unsafe in this kind of context. I had an unrelated recent > discussion where it was mentioned that some proposed feature changes > might not be thread safe. Valid consideration when that may lead to hard-to-explain anomalies. Uhh..... nope, that's nothing but FUD. There is no reason to believe that some language features would be "unsafe". > We now hear that because a list comprehension can be unwound > internally into a "while" loop and an "if" statement and that some > parts may expand to calls to a "range" statement, perhaps some > variables are now in more deeply embedded contexts that have no access to any class variables. No idea what you're looking at. A comprehension can be unwound in a fairly straight-forward way, although there are some subtleties to them. B = [ kind[0] for kind in A ] # equivalent to, approximately: def listcomp(iter): result = [] for kind in iter: result.append(kind[0]) return result B = listcomp(A) For casual usage, you can describe a list comp very simply and neatly: B = [ kind[0] for kind in A ] # equivalent to, more approximately: B = [] for kind in A: B.append(kind[0]) Nothing here expands to a call to range(), nothing has a while loop. The only way you'll get an "if" is if you had one in the comprehension itself. > I think that > is quite reasonable; hence my suggestion we need to know which ones to > avoid, or use a workaround like expanding it out ourselves and perhaps > carefully import variables into other contexts such as by passing the > variable into the function that otherwise cannot access it from a > point it can still be seen. Sure. If the comprehension doesn't work for you, just put a for loop inside your class statement. This is not a problem. > Least, but at least last, I ask if the need really exists for these > variables as constants versus functions. If creating C this way runs > into problems, but A and B are fine, consider making a method with > some name like > Foo.get_C() that can see A and B and do the calculation and yet return > the value of C needed. Less efficient but . Definitely not. That would imply that the value of C might change, or might have significant cost, or in some other way actually merits a getter function. Python isn't built to encourage that. Class scope has edge cases, to be sure, but they're much more notable in carefully-crafted exploratory code than in actual real-world code. ChrisA -- https://mail.python.org/mailman/listinfo/python-list From lingmaaki at gmail.com Thu Jan 10 04:28:02 2019 From: lingmaaki at gmail.com (lingmaaki at gmail.com) Date: Thu, 10 Jan 2019 01:28:02 -0800 (PST) Subject: Python Interview Questions In-Reply-To: <1193768041.349129.26350@v3g2000hsg.googlegroups.com> References: <1193768041.349129.26350@v3g2000hsg.googlegroups.com> Message-ID: <965ea17e-fc74-423d-a482-003dc67bdd9f@googlegroups.com> Python Interview Questions and answers... http://net-informations.com/python/iq/default.htm From dude.jimbo at gmail.com Thu Jan 10 10:05:16 2019 From: dude.jimbo at gmail.com (dude.jimbo at gmail.com) Date: Thu, 10 Jan 2019 07:05:16 -0800 (PST) Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: <1c8c7dd6-933f-4507-b681-6f2ca0327c43@googlegroups.com> Message-ID: <3386f980-ab72-4ce2-8fdf-78328e51c03c@googlegroups.com> Well that escalated quickly :). So, no-one can tell me which component to pip to get rid of "missing ['_sysconfigdata']" error? From blmadhavan at gmail.com Thu Jan 10 12:00:50 2019 From: blmadhavan at gmail.com (Madhavan Bomidi) Date: Thu, 10 Jan 2019 09:00:50 -0800 (PST) Subject: How can I find the indices of an array with float values in python? Message-ID: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.00000000e+01, 6.00000000e+01, 9.00000000e+01, ..., 4.49400000e+04, 4.49700000e+04, 4.50000000e+04]) Now, I wanted to determine the indices of the x values between 0.0 and 15.0. While this is simple in MATLAB or IDL by using find or where functions, I was unable to find a best way to find the indices of all elements between 0.0 and 15.0 in the x array. Can you please suggest me a solution for the same? From blmadhavan at gmail.com Thu Jan 10 12:05:26 2019 From: blmadhavan at gmail.com (Madhavan Bomidi) Date: Thu, 10 Jan 2019 09:05:26 -0800 (PST) Subject: How can I find the indices of an array with float values in python? In-Reply-To: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> References: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> Message-ID: Sorry for re-posting with a correction. I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.00000000e+01, 6.00000000e+01, 9.00000000e+01, ..., 4.49400000e+04, 4.49700000e+04, 4.50000000e+04]) Now, I wanted to determine the indices of the x values between 0.0 and 15000.0. While this is simple in MATLAB or IDL by using find or where functions, I was unable to find a best way to find the indices of all elements between 0.0 and 15000.0 in the x array. Can you please suggest me a solution for the same? From David.Raymond at tomtom.com Thu Jan 10 12:23:50 2019 From: David.Raymond at tomtom.com (David Raymond) Date: Thu, 10 Jan 2019 17:23:50 +0000 Subject: How can I find the indices of an array with float values in python? In-Reply-To: References: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> Message-ID: Maybe something along the lines of... indices = [i for i, val in enumerate(x) where 0 <= val <= 15000] -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Madhavan Bomidi Sent: Thursday, January 10, 2019 12:05 PM To: python-list at python.org Subject: Re: How can I find the indices of an array with float values in python? Sorry for re-posting with a correction. I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.00000000e+01, 6.00000000e+01, 9.00000000e+01, ..., 4.49400000e+04, 4.49700000e+04, 4.50000000e+04]) Now, I wanted to determine the indices of the x values between 0.0 and 15000.0. While this is simple in MATLAB or IDL by using find or where functions, I was unable to find a best way to find the indices of all elements between 0.0 and 15000.0 in the x array. Can you please suggest me a solution for the same? -- https://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Thu Jan 10 12:25:34 2019 From: __peter__ at web.de (Peter Otten) Date: Thu, 10 Jan 2019 18:25:34 +0100 Subject: How can I find the indices of an array with float values in python? References: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> Message-ID: Madhavan Bomidi wrote: > I have an array (numpy.ndarray) with shape (1500L,) as below: > > x = array([ 3.00000000e+01, 6.00000000e+01, 9.00000000e+01, ..., > 4.49400000e+04, 4.49700000e+04, 4.50000000e+04]) > > Now, I wanted to determine the indices of the x values between 0.0 and > 15.0. While this is simple in MATLAB or IDL by using find or where > functions, I was unable to find a best way to find the indices of all > elements between 0.0 and 15.0 in the x array. Can you please suggest me a > solution for the same? Like this? >>> a = numpy.array([-1, 10, 100, 5, 1000.]) >>> numpy.where((a < 15) & (a > 0))[0] array([1, 3]) From rgaddi at highlandtechnology.invalid Thu Jan 10 13:09:53 2019 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Thu, 10 Jan 2019 10:09:53 -0800 Subject: How can I find the indices of an array with float values in python? In-Reply-To: References: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> Message-ID: On 1/10/19 9:25 AM, Peter Otten wrote: > Madhavan Bomidi wrote: > >> I have an array (numpy.ndarray) with shape (1500L,) as below: >> >> x = array([ 3.00000000e+01, 6.00000000e+01, 9.00000000e+01, ..., >> 4.49400000e+04, 4.49700000e+04, 4.50000000e+04]) >> >> Now, I wanted to determine the indices of the x values between 0.0 and >> 15.0. While this is simple in MATLAB or IDL by using find or where >> functions, I was unable to find a best way to find the indices of all >> elements between 0.0 and 15.0 in the x array. Can you please suggest me a >> solution for the same? > > Like this? > >>>> a = numpy.array([-1, 10, 100, 5, 1000.]) >>>> numpy.where((a < 15) & (a > 0))[0] > array([1, 3]) > I was going to suggest numpy.nonzero, which gives the same result as the simple case of numpy.where as above. In either case, the result is a tuple of indices per axis. >>> a = [[2, 7, 6], [9, 5, 1], [4, 3, 8]] >>> a = np.array([[2, 7, 6], [9, 5, 1], [4, 3, 8]]) >>> b = np.array([1, 5, 2, 6, 3, 7, 4, 8, 5, 9]) >>> (a > 5).nonzero() (array([0, 0, 1, 2]), array([1, 2, 0, 2])) >>> np.nonzero(b % 2) (array([0, 1, 4, 5, 8, 9]),) -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From python at mrabarnett.plus.com Thu Jan 10 13:39:30 2019 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 10 Jan 2019 18:39:30 +0000 Subject: How can I find the indices of an array with float values in python? In-Reply-To: References: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> Message-ID: <10e4c28e-0737-fc48-2744-12569736ba0d@mrabarnett.plus.com> On 2019-01-10 17:05, Madhavan Bomidi wrote: > Sorry for re-posting with a correction. > > I have an array (numpy.ndarray) with shape (1500L,) as below: > > x = array([ 3.00000000e+01, 6.00000000e+01, 9.00000000e+01, ..., > 4.49400000e+04, 4.49700000e+04, 4.50000000e+04]) > > Now, I wanted to determine the indices of the x values between 0.0 and 15000.0. While this is simple in MATLAB or IDL by using find or where functions, I was unable to find a best way to find the indices of all elements between 0.0 and 15000.0 in the x array. Can you please suggest me a solution for the same? > I don't know if there's a better way, but: >>> import numpy as np >>> x = np.array([ 3.00000000e+01, 6.00000000e+01, 9.00000000e+01, 4.49400000e+04, 4.49700000e+04, 4.50000000e+04]) Unfortunately, chained comparisons aren't supported by numpy, so: >>> np.logical_and(0.0 <= x, x <= 15000.0) array([ True, True, True, False, False, False]) Now for the indices: >>> np.arange(x.shape[0]) array([0, 1, 2, 3, 4, 5]) Extract the indices where the Boolean value is True: >>> np.extract(np.logical_and(0.0 <= x, x <= 15000.0), np.arange(x.shape[0])) array([0, 1, 2]) From PythonList at DancesWithMice.info Thu Jan 10 14:46:19 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 11 Jan 2019 08:46:19 +1300 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> Message-ID: <0051dc9e-7f4c-37c5-256e-e49afc1e217d@DancesWithMice.info> On 8/01/19 4:59 PM, rbowman wrote:> On 01/07/2019 02:10 PM, DL Neil wrote: >> Why is that obscure? It makes perfect sense - to those of us who have >> used tape/serial storage! Perhaps less-so to [bobble-heads], sorry I >> mean people who grew-up with 'bubble memory' (Memory sticks, 'flash >> drives', SSDs). In point-of-fact, Python Context Managers > > Bubble memory, now there is a blast from the past... More like a whimper... Working with a bunch of younger folk (who may technically be of the age of 'grand-children' - pardon me, I almost fell over my (long, grey) beard), I am frequently the butt of their gentle, if ageist, jokes. However, my sardonic amusement is to watch them wrestling with concepts 'we' readily recognise, perhaps from as long ago as mainframe-days. A similar observation relates to technologies which have come-and-gone, eg CCDs, and the bleeding-edge/crest-of-the-wave philosophies that it may not be worth rushing into every new technology - because it may not actually last the distance... (Santayana's "Those who cannot remember [learn from] the past are condemned to repeat it." - my addition in list-brackets*) * which was added only to be able to make tenuous claim of relevance to a Python discussion list! -- Regards =dn From rosuav at gmail.com Thu Jan 10 14:57:56 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Jan 2019 06:57:56 +1100 Subject: the python name In-Reply-To: <0051dc9e-7f4c-37c5-256e-e49afc1e217d@DancesWithMice.info> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> <0051dc9e-7f4c-37c5-256e-e49afc1e217d@DancesWithMice.info> Message-ID: On Fri, Jan 11, 2019 at 6:48 AM DL Neil wrote: > Working with a bunch of younger folk (who may technically be of the age > of 'grand-children' - pardon me, I almost fell over my (long, grey) > beard), I am frequently the butt of their gentle, if ageist, jokes. > However, my sardonic amusement is to watch them wrestling with concepts > 'we' readily recognise, perhaps from as long ago as mainframe-days. My Dad was in computing back in the mainframe days, and used to regale me with stories of holding a kilobyte of memory. But now I've started doing the same sorts of things - I can expound upon the wonders of engineering floppy disk boot sectors and finding that one spare byte that I could use for something unrelated, or writing MS-DOS TSRs, or *avoiding* writing a TSR by having it invoke another program and then clean up after itself when that program finished... I distinctly remember hooking the Print Screen interrupt to switch from one screen to another so that I could play Colossal Caves (aka "ADVENTUR") and keep track of which treasures I'd collected. Young folks these days would say "why couldn't you just alt-tab"... ChrisA From PythonList at DancesWithMice.info Thu Jan 10 15:47:44 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 11 Jan 2019 09:47:44 +1300 Subject: the python name In-Reply-To: References: <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> Message-ID: <67e484a6-3796-e38b-c903-a7786620c005@DancesWithMice.info> On 8/01/19 12:04 PM, Dennis Lee Bieber wrote: > On Tue, 8 Jan 2019 10:10:13 +1300, DL Neil > declaimed the following: > >> >> Why is that obscure? It makes perfect sense - to those of us who have >> used tape/serial storage! Perhaps less-so to [bobble-heads], sorry I >> mean people who grew-up with 'bubble memory' (Memory sticks, 'flash >> drives', SSDs). In point-of-fact, Python Context Managers >> > Apologies, but "bubble memory" is something completely different -- > using movable magnetic domains rather than capacitive charged bits. You are correct. Although, back in the days of such excitement: that we had a rapidly-approaching possibility of a cost-effective alternative to other forms of memory - particularly 'spinning rust'; only the electrical engineers worried too much about the underlying technologies. In fact, many of the early devices were too optimistic and didn't enjoy longevity. However, with persistence (hah!) here we are today, taking SSDs for granted... As mentioned 'elsewhere', that particular team I joined had their average-age considerably elevated when I arrived. As such an object of curiosity, one of the things noticed was that I ("pomodoro") take regular seat-breaks to stretch and move. Apparently, the arm and shoulder-loosening movements gained fans, so one tea-break I arrived to find them all lined-up around the room, with joined hands, doing a night-club dance version of the Brazilian Wave and giggling insanely. However, as some (already) suffer neck and head-aches, I was(seriously) asked for ideas to combat that common oppression. I taught them to rotate the head (slowly, but fully) sideways (in the fashion of a westerner saying "no") + three repeats, then to nod (westerner saying "yes") etc, and finally to 'waggle' the top of the head side-to-side (Indian "agreement"). Perhaps you can imagine the next tea-time, dance-floor routine! In between chuckles, I referred to them as a bunch of "bubble-heads". (with some dispute as to whether I actually said "bobble-heads", but the term took their fancy and entered into common parlance)... At about the same time, someone turned-up with a bust of Mozart, Beethoven, or some-such; making a point about having stiff necks that felt solid... The next thing I knew, someone else has added to the collection, a particularly ugly bobble-head doll. A day or so later, someone else 'improved' on it with a bobble-headed dog... Finally, during a meeting last week (just before this conversation on-list), someone made the mistake of describing an incomplete idea as "bubbling-up in my mind", which utterly brought the house down! With lightning wit (moving at a speed which belies my years) I took full advantage by claiming that not just he, but they all have having bobble/bubble memories! (you don't have to be mad to work here - but it helps!) OK, so that's more than you ever wanted to know about why I (erroneously or otherwise) used such a term... Refs: https://www.youtube.com/watch?v=v2E8f-_ERl0 http://www.bobbledad.com/man-in-mankini-bobblehead https://www.ebay.com/sch/i.html?LH_CAds=&_ex_kw=&_fpos=&_fspt=1&_mPrRngCbx=1&_nkw=bobble+head+dog&_sacat=&_sadis=&_sop=12&_udhi=&_udlo=&_fosrp=1 (here do we stumble upon the reason eBay's server is called "rover"?) >> Why "print"? I thought I was displaying something on the screen (indeed >> STDIO might go to a file, eg log-like). Whither print? >> > Using the wrong language then... COBOL has DISPLAY Indeed, and it survived into the CICS/terminal-based era! (although these days I recommend handing-off to HTML as a front-end - I guess then I should observe that HTML has no command to display/print!) > Why "print" -- least surprise! Languages back to FORTRAN (and predating > terminals) had "print" as the quick&dirty output statement (vs the more > complex formatted output). FORTRAN, BASIC, Pascal, probably Modula-2. "Print" only has "least-surprise" to those of us who can claim a history like yours/ours. When we used Teletype terminals and all user (human-readable) output went to a line printer, then the word was appropriate. To programming neophytes it makes no sense whatsoever, any more than would "type". From your own description, what about "output"? DISPLAY works for me. I've heard folk talk about "emit", there's "write"*, and "type", "present", "exhibit" - from photography "expose"... Going to an ink-jet printer could we say "spit" or to a laser, "burn"? Referring back to an earlier point, I don't "print" but have developed the habit of using another, specific function/method to "log"! * with the recent move to f-strings (Py3.3 was it? - haven't gone back to look it up) and the articles discussing their advantages over what-went-before, reminded me very much of the essential logic of FORTRAN's READ/WRITE and FORMAT statements! >> Reminds me of the person who upon being told to move his mouse to the >> top of the screen, picking-up the device and raised it from the desk >> surface. Made sense to him! >> > And with modern sensors, would make sense for a 3-D modeling program > +1 Yes, I use a Wacom drawing tablet to highlight and annotate screen text for presentations. Many times I have thought that the old light pens were a better idea, eg http://www.columbia.edu/cu/computinghistory/2250.html (PS the "2250" was a fore-runner of the venerable IBM 3270 terminal (and extant protocol of the same name) - an IBM 1130 was my first "PC") -- Regards =dn From PythonList at DancesWithMice.info Thu Jan 10 15:58:01 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 11 Jan 2019 09:58:01 +1300 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> <0051dc9e-7f4c-37c5-256e-e49afc1e217d@DancesWithMice.info> Message-ID: <3a28f241-97af-4a18-5c33-b327bb17e845@DancesWithMice.info> On 11/01/19 8:57 AM, Chris Angelico wrote: > On Fri, Jan 11, 2019 at 6:48 AM DL Neil wrote: >> Working with a bunch of younger folk (who may technically be of the age >> of 'grand-children' - pardon me, I almost fell over my (long, grey) >> beard), I am frequently the butt of their gentle, if ageist, jokes. >> However, my sardonic amusement is to watch them wrestling with concepts >> 'we' readily recognise, perhaps from as long ago as mainframe-days. > > My Dad was in computing back in the mainframe days, and used to regale > me with stories of holding a kilobyte of memory. But now I've started > doing the same sorts of things - I can expound upon the wonders of > engineering floppy disk boot sectors and finding that one spare byte > that I could use for something unrelated, or writing MS-DOS TSRs, or > *avoiding* writing a TSR by having it invoke another program and then > clean up after itself when that program finished... I distinctly > remember hooking the Print Screen interrupt to switch from one screen > to another so that I could play Colossal Caves (aka "ADVENTUR") and > keep track of which treasures I'd collected. Young folks these days > would say "why couldn't you just alt-tab"... Ah yes, the ?good, old, days! Things were so much better then, before 'young experts' came along and complicated 'everything'... However, as I rock my porch-chair and reminisce, I find that even nostalgia ain't as good as it once used to be... PS the smart reply: who do you think coded the Alt-Tab window-switching mechanism? or, whose shoulders' do you young, whipper-snappers think you're standing on? (and, "please get down, and go and wash your feet") ... -- Regards =dn From rosuav at gmail.com Thu Jan 10 16:06:21 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Jan 2019 08:06:21 +1100 Subject: the python name In-Reply-To: <3a28f241-97af-4a18-5c33-b327bb17e845@DancesWithMice.info> References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> <0051dc9e-7f4c-37c5-256e-e49afc1e217d@DancesWithMice.info> <3a28f241-97af-4a18-5c33-b327bb17e845@DancesWithMice.info> Message-ID: On Fri, Jan 11, 2019 at 8:01 AM DL Neil wrote: > PS the smart reply: who do you think coded the Alt-Tab window-switching > mechanism? > or, whose shoulders' do you young, whipper-snappers think you're > standing on? (and, "please get down, and go and wash your feet") Hold on hold on. "Window-switching mechanism"? That implies that you have windows to switch between. First, we have to have the concept of multiple programs running at once. Then the concept of each of those programs having its own isolated display, which you can then switch between... But yeah, "whose shoulders are you standing on" is the right way to look at it. Also: "are you offering YOUR shoulders to the next generation?" ChrisA From avigross at verizon.net Thu Jan 10 17:44:16 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 10 Jan 2019 17:44:16 -0500 Subject: How can I find the indices of an array with float values in python? In-Reply-To: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> References: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> Message-ID: <00d701d4a936$04dd09f0$0e971dd0$@verizon.net> Madhavan, Others have given you reasonable answers out of the ever so many many many ways you can do what you asked. I offer a question to consider in case your needs are different or you have not considered other more pythonic ways. What do you want to do with your data and is this the best way to do it? The pythonic way often is to minimize the use of features common in languages like C and use new paradigms like iteration where no index is needed. As others show, you can do many things like a list comprehension with an if, perhaps alongside an enumerate to catch the index too. So, you have an array of numbers. (numpy style) and you want a way to designate a subset of those numbers that meet your criterion. Your criterion is a compound criterion that needs refining. You want numbers between 0 and 15. Are you including one or both endpoints? Any answers you choose to use will need to be adjusted depending on your answer. And, you seem to want not the values, but instead the indices of the array where those values are stored. Are you sure that is what you need to go to the next step? Maybe you do under your currently conceived algorithm and the solutions provided will give you a second array of indices you can use in an unspecified way later. But if all you want to do is get a potentially smaller array containing just the values you want, and perhaps iterate on them or apply a function such as getting the standard deviation, there is another set of answers that just makes copies of the array in any way you want, sometimes in multiple steps. I choose to illustrate below with what some may consider a tutorial and ignore. If your needs are met, feel free. Is a numpy array the best data type for your needs. If you were using a pandas DataFrame where one column was your numpy array and you had other columns, then one could be an index of N numbers corresponding to your requested index. If you used commands to create a second DataFrame with only those rows that matched your criteria, the resulting DataFrame would automatically have the index numbers, and perhaps much more. I am NOT saying the added complications are needed, just that without knowing your goals, it may be other ways are a better fit. And note that in numpy (and pandas) there are other ways to index. Yes, you can provide an array of integers to index with like this: import numpy as np # Create an array to play with odd numbers. odds = np.array(range(1,20,2)) odds ==> array([ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) # Show indexing of the array using indices. three_in = [2, 4, 6] odds[three_in] ==> array([ 5, 9, 13]) But you can also index by a Boolean (True/False) list of the same size like: # Show Boolean indices three_bool = [False, False, True, False, True, False, True, False, False, False] odds[three_bool] ==> array([ 5, 9, 13]) Same result. Now you seem to want numbers in a range. I show a way in this example to get everything greater than one number but less than or equal to another. Since my numbers happen to be in order, ... # Show how to get numbers in a range. odds[(odds > 3) & (odds <= 15)] ==> array([ 5, 7, 9, 11, 13, 15]) So if you don't need indices, something like the above gives you the data itself to use. If your data must keep track of multiple sets of data, and you need an index to deal with them, I would suggest another data structure. Here for example, I combine the same vector as above along with a list of my favorite elements # Make a DataFrame with an additional field and index. import pandas as pd ind = np.array(range(len(odds))) elementals = np.array(["Hydrogen", "Lithium", "Boron", "Nitrogen", "Fluorine", "Sodium", "Aluminum", "Phosphorus", "Chlorine", "Potassium"]) dictate = { "indexed" : ind, "protons" : odds, "moniker": elementals } df = pd.DataFrame(dictate) df ==> indexed protons moniker 0 0 1 Hydrogen 1 1 3 Lithium 2 2 5 Boron 3 3 7 Nitrogen 4 4 9 Fluorine 5 5 11 Sodium 6 6 13 Aluminum 7 7 15 Phosphorus 8 8 17 Chlorine 9 9 19 Potassium In the above, note there is a default index that happens to match what I chose. The point is that if you wanted a subset including everything in a row, you do not really need the index: df[(df.protons > 5) & (df.protons <= 15)] ==> indexed protons moniker 3 3 7 Nitrogen 4 4 9 Fluorine 5 5 11 Sodium 6 6 13 Aluminum 7 7 15 Phosphorus But if you did not ever need the index, you can not include it or even suppress the default one. My point, as I stop here from giving the entire tutorial, is for you to think about what you want to do and consider which way to do it and then use reasonable tools. If you really want the index so you can use it later in various indexing ways, great. But if you just want to hold multiple items together by an index, consider other choices including some of the above. -----Original Message----- From: Python-list On Behalf Of Madhavan Bomidi Sent: Thursday, January 10, 2019 12:01 PM To: python-list at python.org Subject: How can I find the indices of an array with float values in python? I have an array (numpy.ndarray) with shape (1500L,) as below: x = array([ 3.00000000e+01, 6.00000000e+01, 9.00000000e+01, ..., 4.49400000e+04, 4.49700000e+04, 4.50000000e+04]) Now, I wanted to determine the indices of the x values between 0.0 and 15.0. While this is simple in MATLAB or IDL by using find or where functions, I was unable to find a best way to find the indices of all elements between 0.0 and 15.0 in the x array. Can you please suggest me a solution for the same? -- https://mail.python.org/mailman/listinfo/python-list From blmadhavan at gmail.com Thu Jan 10 22:55:05 2019 From: blmadhavan at gmail.com (Madhavan Bomidi) Date: Thu, 10 Jan 2019 19:55:05 -0800 (PST) Subject: How can I find the indices of an array with float values in python? In-Reply-To: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> References: <6484c02e-1dbc-434c-b68e-17bd530e68e4@googlegroups.com> Message-ID: <00dcf2fb-808e-4cf0-949b-dffce4bd419a@googlegroups.com> Thank you all for various ways of finding the indices. From PythonList at DancesWithMice.info Fri Jan 11 02:12:17 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 11 Jan 2019 20:12:17 +1300 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <20190104174503.xqypyeuihftyyogv@hjp.at> <7045883d-ef49-9357-98c3-9fecfdba7cf9@DancesWithMice.info> <0051dc9e-7f4c-37c5-256e-e49afc1e217d@DancesWithMice.info> <3a28f241-97af-4a18-5c33-b327bb17e845@DancesWithMice.info> Message-ID: Chris, On 11/01/19 10:06 AM, Chris Angelico wrote: > On Fri, Jan 11, 2019 at 8:01 AM DL Neil wrote: >> PS the smart reply: who do you think coded the Alt-Tab window-switching >> mechanism? >> or, whose shoulders' do you young, whipper-snappers think you're >> standing on? (and, "please get down, and go and wash your feet") > > Hold on hold on. "Window-switching mechanism"? That implies that you > have windows to switch between. First, we have to have the concept of > multiple programs running at once. Then the concept of each of those > programs having its own isolated display, which you can then switch > between... Before Windows or windows per-se, we had switching between Foreground and Background - but using those terms today encourages people to start raving about Themes and color choices... I had people 'on the hook' for quite a while talking about WIMPs. They thought I was into some long-winded, shaggy-dog style of joke. They had no concept that what they think of as MS-Windows, or indeed Linux windows managers; actually consists of a number of inter-related concepts... > But yeah, "whose shoulders are you standing on" is the right way to > look at it. Also: "are you offering YOUR shoulders to the next > generation?" +1 Excellent! (and no, in our 'get it done yesterday' environment I see plenty of collaboration but little meaningful 'training' or investment beyond 'the job') -- Regards =dn From dude.jimbo at gmail.com Fri Jan 11 09:35:50 2019 From: dude.jimbo at gmail.com (dude.jimbo at gmail.com) Date: Fri, 11 Jan 2019 06:35:50 -0800 (PST) Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: Message-ID: Really, no-one? OK, more purging then. I ~think~ I need said missing component because the script gets the system date (to run once on a Friday, in automatic mode). But I've never used it in automatic mode (since I came to my senses about having an infinite looping script in my autoexec.bat, doing nothing, except executing once on a friday, and wasting resources). So, if I scrap the automatic mode, I guess I might finally have something that 'works'. Still disappointed though that I can't get it to work again with the same 'tools' as previously. Especially since I also use the date to add to the name of the backup files that the script is making. Oh, as for 'distributing' this thing. It's a private/personal script, so I'm my only customer. In this sense, I don't even need the EXE now that I've scrapped automatic mode. I can just run the *.py straight from a console. Oh well. Would anyone be interested in seeing the - now infamous - script, to have a go yourself? From dude.jimbo at gmail.com Fri Jan 11 09:45:54 2019 From: dude.jimbo at gmail.com (dude.jimbo at gmail.com) Date: Fri, 11 Jan 2019 06:45:54 -0800 (PST) Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: Message-ID: <9d3a3dbf-c25d-45d0-8fff-8ac47d4c3d46@googlegroups.com> Oh, another thing. I installed WX via a windows installer that I found (can't find the link again, but fairly certain it was this one: https://sourceforge.net/projects/wxpython/ (*)), without giving it much thought (yesyes bad mistake). Since I get wx runtime errors, I'm assuming I have the wrong version. So, in all my 45-yo youthful ignorance, I ran 'pip install -U wxPython' hoping it would magically erase the previously installed version - whatever that is - and get me the newest one. What actually happens is the cmd-window freezing, and nothing else? (*) The 'proper' method to install it, I obviously found on "https://wiki.wxpython.org/How%20to%20install%20wxPython#Windows", but that led me to 'pip', which at that moment in time - 2 days ago LOL - I was not ready for yet (Hey, I'm doing this in between actual work, putting kids in bed, and passing out on the sofa) From dude.jimbo at gmail.com Fri Jan 11 11:10:02 2019 From: dude.jimbo at gmail.com (dude.jimbo at gmail.com) Date: Fri, 11 Jan 2019 08:10:02 -0800 (PST) Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: Message-ID: <51c0b821-aff4-4529-a061-0e85d5fcf0c8@googlegroups.com> OK, stop the presses. Or, rather, refresh your browser, I guess. In a 'what the !@#$ am I doing'-moment (I don't get those often) I uninstalled everything and went gardening. But it was raining so I installed everything again, this time using pip for wxpython. Lo and behond, this time it did not crash the cmd-window, but in stead it successfully installed it. Woot. Then I compiled again with same command and same setup-py and - stubbornly - with py2exe, and got? different errors! That's actually I good sign. No, really. Because this time, the error was about missing Windows DLLs and for these I got plenty of help from my best friend Google (don't tell JackD he's actually second best friend). So, after x iterations I ended up with the following cute setup.py: <- from distutils.core import setup import py2exe setup(console=['AutoArchive.py'], options={ 'py2exe': { 'dll_excludes': ['api-ms-win-core-string-l1-1-0.dll', 'api-ms-win-core-psapi-l1-1-0.dll', 'api-ms-win-core-registry-l1-1-0.dll', 'api-ms-win-core-localization-l1-2-0.dll', 'api-ms-win-security-base-l1-1-0.dll', 'api-ms-win-core-string-obsolete-l1-1-0.dll', 'api-ms-win-core-delayload-l1-1-0.dll', 'api-ms-win-core-handle-l1-1-0.dll', 'api-ms-win-crt-private-l1-1-0.dll', 'api-ms-win-core-libraryloader-l1-2-1.dll', 'api-ms-win-core-memory-l1-1-0.dll', 'api-ms-win-core-heap-obsolete-l1-1-0.dll', 'api-ms-win-core-atoms-l1-1-0.dll', 'api-ms-win-core-processthreads-l1-1-1.dll', 'api-ms-win-core-heap-l2-1-0.dll', 'api-ms-win-core-delayload-l1-1-1.dll', 'api-ms-win-core-processthreads-l1-1-0.dll', 'api-ms-win-core-com-midlproxystub-l1-1-0.dll', 'api-ms-win-crt-string-l1-1-0.dll', 'api-ms-win-crt-runtime-l1-1-0.dll', 'api-ms-win-core-libraryloader-l1-2-0.dll', 'api-ms-win-core-errorhandling-l1-1-0.dll', 'api-ms-win-core-string-l2-1-0.dll', 'api-ms-win-core-synch-l1-2-0.dll', 'api-ms-win-core-profile-l1-1-0.dll', 'api-ms-win-core-synch-l1-1-0.dll', 'api-ms-win-core-threadpool-legacy-l1-1-0.dll', 'api-ms-win-core-interlocked-l1-1-0.dll', 'api-ms-win-core-debug-l1-1-0.dll', 'api-ms-win-core-sysinfo-l1-1-0.dll'] } }, ) -> After which all the missing DLL errors were finally gone (and no, I don?t wanna know why all of the above is even necessary). Success!! Or not? Because I was now right back at: <- The following modules appear to be missing ['Carbon.Appearance', '_sysconfigdata'] -> You cannot possibly be serious!? _sysconfigdata is back? with a friend! Luckily it was still raining so my plan to blow up the PC in my garden fire pit (and dancing hysterically around the glorious resulting bonfire, while in the nude) got scrapped, which allowed me to notice that an actual dist folder had in fact been created, and not just that, there was an EXE inside! So I ran it. and it worked. It worked! It did exactly what it needed to do. Just like on my old machine. I even got the fancy progress popup and the date string in my file names. (At this point I ~did~ dance in the nude, albeit in front of the PC) So what lessons did I learn: 1) compile errors apparently mean Sweet-BLEEP-All; 2) close the curtains when dancing naked around the PC; 3) the back of modern day PCs, which typically sit at groin height on your desk, get really hot at the back. Avoid contact with exposed and/or dangling body parts; 4) there's clearly a reason why I 'gave up on Python' those 10 years ago, and perhaps I'm slowly starting to remember why? :| Jimbo. From dude.jimbo at gmail.com Fri Jan 11 11:13:24 2019 From: dude.jimbo at gmail.com (dude.jimbo at gmail.com) Date: Fri, 11 Jan 2019 08:13:24 -0800 (PST) Subject: The following modules appear to be missing ['_sysconfigdata'] In-Reply-To: References: Message-ID: <66f191be-c29c-4345-bbb2-4c3a507172f1@googlegroups.com> OK, stop the presses. Or, rather, refresh your browser, I guess. In a 'what the !@$$ am I doing'-moment (I don't get those often) I uninstalled everything and went gardening. But it was raining so I installed everything again, this time using pip for wxpython. Lo and behond, this time it did not crash the cmd-window, but in stead it successfully installed it. Woot. Then I compiled again with same command and same setup.py and - stubbornly - with py2exe, and got? different errors! That's actually a good sign. No, really. Because this time, the error was about missing Windows DLLs and here I got plenty of help from my best friend Google (don't tell JackD he's actually second best friend). So, after x iterations I ended up with the following cute setup.py: <- from distutils.core import setup import py2exe setup(console=['AutoArchive.py'], options={ 'py2exe': { 'dll_excludes': ['api-ms-win-core-string-l1-1-0.dll', 'api-ms-win-core-psapi-l1-1-0.dll', 'api-ms-win-core-registry-l1-1-0.dll', 'api-ms-win-core-localization-l1-2-0.dll', 'api-ms-win-security-base-l1-1-0.dll', 'api-ms-win-core-string-obsolete-l1-1-0.dll', 'api-ms-win-core-delayload-l1-1-0.dll', 'api-ms-win-core-handle-l1-1-0.dll', 'api-ms-win-crt-private-l1-1-0.dll', 'api-ms-win-core-libraryloader-l1-2-1.dll', 'api-ms-win-core-memory-l1-1-0.dll', 'api-ms-win-core-heap-obsolete-l1-1-0.dll', 'api-ms-win-core-atoms-l1-1-0.dll', 'api-ms-win-core-processthreads-l1-1-1.dll', 'api-ms-win-core-heap-l2-1-0.dll', 'api-ms-win-core-delayload-l1-1-1.dll', 'api-ms-win-core-processthreads-l1-1-0.dll', 'api-ms-win-core-com-midlproxystub-l1-1-0.dll', 'api-ms-win-crt-string-l1-1-0.dll', 'api-ms-win-crt-runtime-l1-1-0.dll', 'api-ms-win-core-libraryloader-l1-2-0.dll', 'api-ms-win-core-errorhandling-l1-1-0.dll', 'api-ms-win-core-string-l2-1-0.dll', 'api-ms-win-core-synch-l1-2-0.dll', 'api-ms-win-core-profile-l1-1-0.dll', 'api-ms-win-core-synch-l1-1-0.dll', 'api-ms-win-core-threadpool-legacy-l1-1-0.dll', 'api-ms-win-core-interlocked-l1-1-0.dll', 'api-ms-win-core-debug-l1-1-0.dll', 'api-ms-win-core-sysinfo-l1-1-0.dll'] } }, ) -> After which all the missing DLL errors were finally gone (and no, I don?t wanna know why all of the above is even necessary). Success!! Or not? Because I was now right back at: <- The following modules appear to be missing ['Carbon.Appearance', '_sysconfigdata'] -> You cannot possibly be serious!? _sysconfigdata is back? with a friend! Luckily it was still raining so my plan to blow up the PC in my garden fire pit (and dancing hysterically around the glorious resulting bonfire, while in the nude) got scrapped, which allowed me to notice that an actual dist folder had in fact been created, and not just that, there was an EXE inside! So I ran it. and it worked. It worked! It did exactly what it needed to do. Just like on my old machine. I even got the fancy progress popup and the date string in my file names. (At this point I ~did~ dance in the nude, albeit in front of the PC) So what lessons did I learn: 1) compile errors apparently mean Sweet-BLEEP-All; 2) close the curtains when dancing naked around the PC; 3) the back of modern day PCs, which typically sit at groin height on your desk, get really hot at the back. Avoid contact with exposed body parts; 4) there's clearly a reason why I 'gave up on Python' those 10 years ago, and perhaps I'm slowly starting to remember why? :| Jimbo. From ea116 at fayoum.edu.eg Fri Jan 11 11:11:49 2019 From: ea116 at fayoum.edu.eg (Enas Ahmed Zaki) Date: Fri, 11 Jan 2019 18:11:49 +0200 Subject: python setup problems In-Reply-To: References: Message-ID: I want help in solving this problem please thanks Enas On Fri, Jan 11, 2019 at 2:36 PM Enas Ahmed Zaki wrote: > Dear sir, > when I setup the python there is a problem in attached file. I hope I > found the solution of it. > thanks for attention > Eng. Enas Ahmed Zaky > > ??? ?????? ????????? www.avast.com > > > <#m_6099717795028892700_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > From shibashibani at gmail.com Fri Jan 11 15:43:24 2019 From: shibashibani at gmail.com (shibashibani at gmail.com) Date: Fri, 11 Jan 2019 12:43:24 -0800 (PST) Subject: Python read text file columnwise Message-ID: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> Hello, I'm very new in python. I have a file in the format: 2018-05-31 16:00:00 28.90 81.77 4.3 2018-05-31 20:32:00 28.17 84.89 4.1 2018-06-20 04:09:00 27.36 88.01 4.8 2018-06-20 04:15:00 27.31 87.09 4.7 2018-06-28 04.07:00 27.87 84.91 5.0 2018-06-29 00.42:00 32.20 104.61 4.8 From shibashibani at gmail.com Fri Jan 11 15:45:23 2019 From: shibashibani at gmail.com (shibashibani at gmail.com) Date: Fri, 11 Jan 2019 12:45:23 -0800 (PST) Subject: Python read text file columnwise In-Reply-To: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> Message-ID: <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Hello > > I'm very new in python. I have a file in the format: > > 2018-05-31 16:00:00 28.90 81.77 4.3 > 2018-05-31 20:32:00 28.17 84.89 4.1 > 2018-06-20 04:09:00 27.36 88.01 4.8 > 2018-06-20 04:15:00 27.31 87.09 4.7 > 2018-06-28 04.07:00 27.87 84.91 5.0 > 2018-06-29 00.42:00 32.20 104.61 4.8 I would like to read this file in python column-wise. I tried this way but not working .... event_list = open('seismicity_R023E.txt',"r") info_event = read(event_list,'%s %s %f %f %f %f\n'); From rshepard at appl-ecosys.com Fri Jan 11 18:16:43 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Fri, 11 Jan 2019 15:16:43 -0800 (PST) Subject: Python read text file columnwise In-Reply-To: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> Message-ID: On Fri, 11 Jan 2019, shibashibani at gmail.com wrote: > I'm very new in python. I have a file in the format: > > 2018-05-31 16:00:00 28.90 81.77 4.3 > 2018-05-31 20:32:00 28.17 84.89 4.1 > 2018-06-20 04:09:00 27.36 88.01 4.8 > 2018-06-20 04:15:00 27.31 87.09 4.7 > 2018-06-28 04.07:00 27.87 84.91 5.0 > 2018-06-29 00.42:00 32.20 104.61 4.8 So? What do you want to do with it? Are the fields fixed length? Tab-separated? Space-separated? Regardless of what you want to do, replace all whitespace with commas. Rich From sivan at vitakka.co Fri Jan 11 18:41:35 2019 From: sivan at vitakka.co (=?UTF-8?Q?Sivan_Gr=C3=BCnberg?=) Date: Sat, 12 Jan 2019 01:41:35 +0200 Subject: celery + mongodb + RMQ + Flower service/app skeleton Message-ID: Hi All, - - https://github.com/sivang/laten-fw After some extensive work with Celery over the last 2 years, I created this 'framework' skeleton with an example application, so anybody who wants to get up and running with Celery but gets confused from the tutorials and examples out there, can do so merely by running an ansible playbook. This was tested on Ubuntu 16.04 to 18.10 , and can be used out of the box to write and experiment with your own tasks. It can sure use more docs for the resulting setup, and operating it through flower and mongo-express. I have plans to turn this into something that can accept tasks over the wire, from document stores and offer some sorts of Web UI of its own. There's also slides at the root for a related talk I gave about my takeouts from working with the above setup for Audio file analysis and ETL (and this sort of example is also coming soon to a github near you..). Your feedback welcomed, -Sivan From piet-l at vanoostrum.org Fri Jan 11 19:03:56 2019 From: piet-l at vanoostrum.org (Piet van Oostrum) Date: Sat, 12 Jan 2019 01:03:56 +0100 Subject: Python read text file columnwise References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Message-ID: shibashibani at gmail.com writes: > Hello >> >> I'm very new in python. I have a file in the format: >> >> 2018-05-31 16:00:00 28.90 81.77 4.3 >> 2018-05-31 20:32:00 28.17 84.89 4.1 >> 2018-06-20 04:09:00 27.36 88.01 4.8 >> 2018-06-20 04:15:00 27.31 87.09 4.7 >> 2018-06-28 04.07:00 27.87 84.91 5.0 >> 2018-06-29 00.42:00 32.20 104.61 4.8 > > I would like to read this file in python column-wise. > > I tried this way but not working .... > event_list = open('seismicity_R023E.txt',"r") > info_event = read(event_list,'%s %s %f %f %f %f\n'); Why would you think that this would work? See https://docs.python.org/3/library/csv.html Something like: #!/usr/bin/env python3 import csv with open('testcsv.csv', newline='') as csvfile: reader = csv.reader(csvfile, delimiter='\t') for row in reader: for i in range(2, 5): row[i] = float(row[i]) print(row) You could convert the first two columns to datetime format if you wish. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From cs at cskk.id.au Fri Jan 11 20:54:30 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 12 Jan 2019 12:54:30 +1100 Subject: Python read text file columnwise In-Reply-To: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> Message-ID: <20190112015430.GA75859@cskk.homeip.net> On 11Jan2019 12:43, shibashibani at gmail.com wrote: >I'm very new in python. I have a file in the format: > >2018-05-31 16:00:00 28.90 81.77 4.3 >2018-05-31 20:32:00 28.17 84.89 4.1 >2018-06-20 04:09:00 27.36 88.01 4.8 >2018-06-20 04:15:00 27.31 87.09 4.7 >2018-06-28 04.07:00 27.87 84.91 5.0 >2018-06-29 00.42:00 32.20 104.61 4.8 It is unclear what delimits the columns, but it looks like whitespace: tabs and/or spaces. You could read the file a line at a time and call .split() on each line to get the nonwhitespace fields, which would seem to correspond to the columns above. That gets you an list of strings; then you could convert them for processing as required. Cheers, Cameron Simpson From __peter__ at web.de Sat Jan 12 04:19:24 2019 From: __peter__ at web.de (Peter Otten) Date: Sat, 12 Jan 2019 10:19:24 +0100 Subject: Python read text file columnwise References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Message-ID: shibashibani at gmail.com wrote: > Hello >> >> I'm very new in python. I have a file in the format: >> >> 2018-05-31 16:00:00 28.90 81.77 4.3 >> 2018-05-31 20:32:00 28.17 84.89 4.1 >> 2018-06-20 04:09:00 27.36 88.01 4.8 >> 2018-06-20 04:15:00 27.31 87.09 4.7 >> 2018-06-28 04.07:00 27.87 84.91 5.0 >> 2018-06-29 00.42:00 32.20 104.61 4.8 > > I would like to read this file in python column-wise. > > I tried this way but not working .... > event_list = open('seismicity_R023E.txt',"r") > info_event = read(event_list,'%s %s %f %f %f %f\n'); There is actually a library that implements a C-like scanf. You can install it with $ pip install scanf After that: $ cat read_table.py from scanf import scanf with open("seismicity_R023E.txt") as f: for line in f: print( scanf("%s %s %f %f %f\n", line) ) $ cat seismicity_R023E.txt 2018-05-31 16:00:00 28.90 81.77 4.3 2018-05-31 20:32:00 28.17 84.89 4.1 2018-06-20 04:09:00 27.36 88.01 4.8 2018-06-20 04:15:00 27.31 87.09 4.7 2018-06-28 04.07:00 27.87 84.91 5.0 2018-06-29 00.42:00 32.20 104.61 4.8 $ python read_table.py ('2018-05-31', '16:00:00', 28.9, 81.77, 4.3) ('2018-05-31', '20:32:00', 28.17, 84.89, 4.1) ('2018-06-20', '04:09:00', 27.36, 88.01, 4.8) ('2018-06-20', '04:15:00', 27.31, 87.09, 4.7) ('2018-06-28', '04.07:00', 27.87, 84.91, 5.0) ('2018-06-29', '00.42:00', 32.2, 104.61, 4.8) $ However, in the long term you may be better off with a tool like pandas: >>> import pandas >>> pandas.read_table( ... "seismicity_R023E.txt", sep=r"\s+", ... names=["date", "time", "foo", "bar", "baz"], ... parse_dates=[["date", "time"]] ... ) date_time foo bar baz 0 2018-05-31 16:00:00 28.90 81.77 4.3 1 2018-05-31 20:32:00 28.17 84.89 4.1 2 2018-06-20 04:09:00 27.36 88.01 4.8 3 2018-06-20 04:15:00 27.31 87.09 4.7 4 2018-06-28 04:00:00 27.87 84.91 5.0 5 2018-06-29 00:00:00 32.20 104.61 4.8 [6 rows x 4 columns] >>> It will be harder in the beginning, but if you work with tabular data regularly it will pay off. From __peter__ at web.de Sat Jan 12 05:12:43 2019 From: __peter__ at web.de (Peter Otten) Date: Sat, 12 Jan 2019 11:12:43 +0100 Subject: Silent data corruption in pandas, was Re: Python read text file columnwise References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Message-ID: Peter Otten wrote: > shibashibani at gmail.com wrote: > >> Hello >>> >>> I'm very new in python. I have a file in the format: >>> >>> 2018-05-31 16:00:00 28.90 81.77 4.3 >>> 2018-05-31 20:32:00 28.17 84.89 4.1 >>> 2018-06-20 04:09:00 27.36 88.01 4.8 >>> 2018-06-20 04:15:00 27.31 87.09 4.7 >>> 2018-06-28 04.07:00 27.87 84.91 5.0 >>> 2018-06-29 00.42:00 32.20 104.61 4.8 >> >> I would like to read this file in python column-wise. > However, in the long term you may be better off with a tool like pandas: > >>>> import pandas >>>> pandas.read_table( > ... "seismicity_R023E.txt", sep=r"\s+", > ... names=["date", "time", "foo", "bar", "baz"], > ... parse_dates=[["date", "time"]] > ... ) > date_time foo bar baz > 0 2018-05-31 16:00:00 28.90 81.77 4.3 > 1 2018-05-31 20:32:00 28.17 84.89 4.1 > 2 2018-06-20 04:09:00 27.36 88.01 4.8 > 3 2018-06-20 04:15:00 27.31 87.09 4.7 > 4 2018-06-28 04:00:00 27.87 84.91 5.0 > 5 2018-06-29 00:00:00 32.20 104.61 4.8 > > [6 rows x 4 columns] >>>> > > It will be harder in the beginning, but if you work with tabular data > regularly it will pay off. After posting the above I noted that the malformed time in the last two rows was silently botched. So I just spent an insane amount of time to try and fix this from within pandas: import datetime import numpy import pandas def parse_datetime(dt): return datetime.datetime.strptime( dt.replace(".", ":"), "%Y-%m-%d %H:%M:%S" ) def date_parser(dates, times): return numpy.array([ parse_datetime(date + " " + time) for date, time in zip(dates, times) ]) df = pandas.read_table( "seismicity_R023E.txt", sep=r"\s+", names=["date", "time", "foo", "bar", "baz"], parse_dates=[["date", "time"]], date_parser=date_parser ) print(df) There's probably a better way as I am only a determined amateur... From __peter__ at web.de Sat Jan 12 05:32:35 2019 From: __peter__ at web.de (Peter Otten) Date: Sat, 12 Jan 2019 11:32:35 +0100 Subject: Silent data corruption in pandas References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Message-ID: Peter Otten wrote: [Practising the bad habit of public soliloquy] > def parse_datetime(dt): > return datetime.datetime.strptime( > dt.replace(".", ":"), "%Y-%m-%d %H:%M:%S" > ) > > > def date_parser(dates, times): > return numpy.array([ > parse_datetime(date + " " + time) > for date, time in zip(dates, times) > ]) This can be rewritten: @numpy.vectorize def date_parser(date, time): return datetime.datetime.strptime( date + " " + time.replace(".", ":"), "%Y-%m-%d %H:%M:%S" ) From PythonList at DancesWithMice.info Sat Jan 12 16:47:38 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Sun, 13 Jan 2019 10:47:38 +1300 Subject: Python read text file columnwise In-Reply-To: References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Message-ID: <7cce1a71-7e01-0a54-fe5b-408b8cd75118@DancesWithMice.info> On 12/01/19 1:03 PM, Piet van Oostrum wrote: > shibashibani at gmail.com writes: > >> Hello >>> >>> I'm very new in python. I have a file in the format: >>> >>> 2018-05-31 16:00:00 28.90 81.77 4.3 >>> 2018-05-31 20:32:00 28.17 84.89 4.1 >>> 2018-06-20 04:09:00 27.36 88.01 4.8 >>> 2018-06-20 04:15:00 27.31 87.09 4.7 >>> 2018-06-28 04.07:00 27.87 84.91 5.0 >>> 2018-06-29 00.42:00 32.20 104.61 4.8 >> >> I would like to read this file in python column-wise. >> >> I tried this way but not working .... >> event_list = open('seismicity_R023E.txt',"r") >> info_event = read(event_list,'%s %s %f %f %f %f\n'); To the OP: Python's standard I/O is based around data "streams". Whilst there is a concept of "lines" and thus an end-of-line character, there is not the idea of a record, in the sense of fixed-length fields and thus a defining and distinction between data items based upon position. Accordingly, whilst the formatting specification of strings and floats might work for output, there is no equivalent for accepting input data. Please re-read refs on file, read, readline, etc. > Why would you think that this would work? To the PO: Because in languages/libraries built around fixed-length files this is how one specifies the composition of fields making up a record - a data structure which dates back to FORTRAN and Assembler on mainframes and other magtape-era machines. Whilst fixed-length records/files are, by definition, less flexible than the more free-form data input Python accepts, they are more efficient and faster in situations where the data (format) is entirely consistent - such as the OP is describing! -- Regards =dn From avigross at verizon.net Sat Jan 12 20:26:32 2019 From: avigross at verizon.net (Avi Gross) Date: Sat, 12 Jan 2019 20:26:32 -0500 Subject: Python read text file columnwise References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> <7cce1a71-7e01-0a54-fe5b-408b8cd75118@DancesWithMice.info> Message-ID: <00c701d4aadf$049c2d40$0dd487c0$@verizon.net> -----Original Message----- From: Avi Gross Sent: Saturday, January 12, 2019 8:26 PM To: 'DL Neil' Subject: RE: Python read text file columnwise I am not sure what the big deal is here. If the data is consistently formatted you can read in a string per line and use offsets as in line[0:8] and so on then call the right transformations to comvert them to dates and so on. If it is delimited by something consistent like spaces or table or commas, we have all kinds of solutions ranging from splitting the line on the delimiter to using the kind of functionality that reads in such files into a pandas DataFrame. In the latter case, you get the columns already. In the former, there are well known ways to extract the info such as: [row[0] for row in listofrows] And repeat for additional items. Or am I missing something and there is no end of line and you need to read in the entire file and split it into size N chunks first? Still fairly straightforward. -----Original Message----- From: Python-list On Behalf Of DL Neil Sent: Saturday, January 12, 2019 4:48 PM To: python-list at python.org Subject: Re: Python read text file columnwise On 12/01/19 1:03 PM, Piet van Oostrum wrote: > shibashibani at gmail.com writes: > >> Hello >>> >>> I'm very new in python. I have a file in the format: >>> >>> 2018-05-31 16:00:00 28.90 81.77 4.3 >>> 2018-05-31 20:32:00 28.17 84.89 4.1 >>> 2018-06-20 04:09:00 27.36 88.01 4.8 >>> 2018-06-20 04:15:00 27.31 87.09 4.7 >>> 2018-06-28 04.07:00 27.87 84.91 5.0 >>> 2018-06-29 00.42:00 32.20 104.61 4.8 >> >> I would like to read this file in python column-wise. >> >> I tried this way but not working .... >> event_list = open('seismicity_R023E.txt',"r") >> info_event = read(event_list,'%s %s %f %f %f %f\n'); To the OP: Python's standard I/O is based around data "streams". Whilst there is a concept of "lines" and thus an end-of-line character, there is not the idea of a record, in the sense of fixed-length fields and thus a defining and distinction between data items based upon position. Accordingly, whilst the formatting specification of strings and floats might work for output, there is no equivalent for accepting input data. Please re-read refs on file, read, readline, etc. > Why would you think that this would work? To the PO: Because in languages/libraries built around fixed-length files this is how one specifies the composition of fields making up a record - a data structure which dates back to FORTRAN and Assembler on mainframes and other magtape-era machines. Whilst fixed-length records/files are, by definition, less flexible than the more free-form data input Python accepts, they are more efficient and faster in situations where the data (format) is entirely consistent - such as the OP is describing! -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list From jfong at ms4.hinet.net Sun Jan 13 23:15:17 2019 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Sun, 13 Jan 2019 20:15:17 -0800 (PST) Subject: How to run a module before install? Message-ID: <57d0cadd-2b04-4024-bb2b-ead5fe9e732b@googlegroups.com> I had download a module which has the following directory structure: [XL-Sudoku-Solver_master] |__[tests] |__[xl_sudoku_solver] |__setup.py |__ __init__.py |__problem1.txt |__ __main__.py |__README.md |__ ... |__ ... The setup.py file has something like this: --------------------- ... setup( name="xl-sudoku-solver", version="0.0.1.post3", packages=['xl_sudoku_solver'], entry_points={ "console_scripts": [ "xl-sudoku-solver = xl_sudoku_solver.__main__:main" ] }, ... ---------------- and the __main__.py has: ---------------- ... from . import Solver, load_from_file, load_from_input, load_from_string def main(): ... if __name__ == '__main__': main() ---------------- The README.md suggest the way of running it: pip install xl-sudoku-solver $ xl-sudoku-solver --time -f problem1.txt But I like to run it before install. Is it possible? and how? I had try two ways below but niether works: 1) h:\Temp\XL-Sudoku-Solver-master>py xl_sudoku_solver --time -f problem1.txt Traceback (most recent call last): File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main "__main__", mod_spec) File "C:\Python34\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "xl_sudoku_solver\__main__.py", line 5, in from . import Solver, load_from_file, load_from_input, load_from_string SystemError: Parent module '' not loaded, cannot perform relative import 2) h:\Temp\XL-Sudoku-Solver-master>py Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import xl_sudoku_solver >>> Can't find the name "main", What to do? --Jach From __peter__ at web.de Mon Jan 14 03:04:04 2019 From: __peter__ at web.de (Peter Otten) Date: Mon, 14 Jan 2019 09:04:04 +0100 Subject: How to run a module before install? References: <57d0cadd-2b04-4024-bb2b-ead5fe9e732b@googlegroups.com> Message-ID: jfong at ms4.hinet.net wrote: > I had download a module which has the following directory structure: > > [XL-Sudoku-Solver_master] > |__[tests] > |__[xl_sudoku_solver] > |__setup.py |__ __init__.py > |__problem1.txt |__ __main__.py > |__README.md |__ ... > |__ ... > > The setup.py file has something like this: > --------------------- > ... > setup( > name="xl-sudoku-solver", > version="0.0.1.post3", > packages=['xl_sudoku_solver'], > entry_points={ > "console_scripts": [ > "xl-sudoku-solver = xl_sudoku_solver.__main__:main" > ] > }, > ... > ---------------- > > and the __main__.py has: > ---------------- > ... > from . import Solver, load_from_file, load_from_input, load_from_string > > def main(): > ... > > if __name__ == '__main__': > main() > ---------------- > > The README.md suggest the way of running it: > > pip install xl-sudoku-solver > $ xl-sudoku-solver --time -f problem1.txt > > But I like to run it before install. Is it possible? and how? I had try > two ways below but niether works: > > 1) h:\Temp\XL-Sudoku-Solver-master>py xl_sudoku_solver --time -f > problem1.txt Traceback (most recent call last): > File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main > "__main__", mod_spec) > File "C:\Python34\lib\runpy.py", line 85, in _run_code > exec(code, run_globals) > File "xl_sudoku_solver\__main__.py", line 5, in > from . import Solver, load_from_file, load_from_input, > load_from_string > SystemError: Parent module '' not loaded, cannot perform relative import > > 2) h:\Temp\XL-Sudoku-Solver-master>py > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 > bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for > more information. >>>> import xl_sudoku_solver >>>> > > Can't find the name "main", What to do? With h:\Temp\XL-Sudoku-Solver-master as the current working directory try h:\Temp\XL-Sudoku-Solver-master>py -m xl_sudoku_solver From jfong at ms4.hinet.net Mon Jan 14 04:18:23 2019 From: jfong at ms4.hinet.net (jfong at ms4.hinet.net) Date: Mon, 14 Jan 2019 01:18:23 -0800 (PST) Subject: How to run a module before install? In-Reply-To: References: <57d0cadd-2b04-4024-bb2b-ead5fe9e732b@googlegroups.com> Message-ID: <1369e332-ff8d-4ff7-a3b3-a24b0f8f73eb@googlegroups.com> Peter Otten? 2019?1?14???? UTC+8??4?04?33???? > jfong at ms4.hinet.net wrote: > > > I had download a module which has the following directory structure: > > > > [XL-Sudoku-Solver_master] > > |__[tests] > > |__[xl_sudoku_solver] > > |__setup.py |__ __init__.py > > |__problem1.txt |__ __main__.py > > |__README.md |__ ... > > |__ ... > > > > The setup.py file has something like this: > > --------------------- > > ... > > setup( > > name="xl-sudoku-solver", > > version="0.0.1.post3", > > packages=['xl_sudoku_solver'], > > entry_points={ > > "console_scripts": [ > > "xl-sudoku-solver = xl_sudoku_solver.__main__:main" > > ] > > }, > > ... > > ---------------- > > > > and the __main__.py has: > > ---------------- > > ... > > from . import Solver, load_from_file, load_from_input, load_from_string > > > > def main(): > > ... > > > > if __name__ == '__main__': > > main() > > ---------------- > > > > The README.md suggest the way of running it: > > > > pip install xl-sudoku-solver > > $ xl-sudoku-solver --time -f problem1.txt > > > > But I like to run it before install. Is it possible? and how? I had try > > two ways below but niether works: > > > > 1) h:\Temp\XL-Sudoku-Solver-master>py xl_sudoku_solver --time -f > > problem1.txt Traceback (most recent call last): > > File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main > > "__main__", mod_spec) > > File "C:\Python34\lib\runpy.py", line 85, in _run_code > > exec(code, run_globals) > > File "xl_sudoku_solver\__main__.py", line 5, in > > from . import Solver, load_from_file, load_from_input, > > load_from_string > > SystemError: Parent module '' not loaded, cannot perform relative import > > > > 2) h:\Temp\XL-Sudoku-Solver-master>py > > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 > > bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for > > more information. > >>>> import xl_sudoku_solver > >>>> > > > > Can't find the name "main", What to do? > > With h:\Temp\XL-Sudoku-Solver-master as the current working directory try > > h:\Temp\XL-Sudoku-Solver-master>py -m xl_sudoku_solver Great! it works. Thank you, peter. By the way, can you explain what these two command difference means? with or without a "-m". Or pointing where the document is. Thanks ahead:-) From h.goebel at goebel-consult.de Mon Jan 14 06:31:33 2019 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Mon, 14 Jan 2019 12:31:33 +0100 Subject: Email blast management? In-Reply-To: References: Message-ID: Am 09.01.19 um 18:59 schrieb Chris Angelico: > TBH, I'd recommend using a service like MailChimp, avoiding the entire > Python question at all. But for this you need to hand over the addresses to a third-party (the service provider). This does not respect the privacy of the customers. -- Sch?nen Gru? Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: https://www.goe-con.de/blog/deshalb-tr-069-ausschalten Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2010-01-hinterturen-allen-ortes From rosuav at gmail.com Mon Jan 14 06:47:34 2019 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Jan 2019 22:47:34 +1100 Subject: Email blast management? In-Reply-To: References: Message-ID: On Mon, Jan 14, 2019 at 10:39 PM Hartmut Goebel wrote: > > Am 09.01.19 um 18:59 schrieb Chris Angelico: > > TBH, I'd recommend using a service like MailChimp, avoiding the entire > > Python question at all. > > But for this you need to hand over the addresses to a third-party (the > service provider). This does not respect the privacy of the customers. > It's a whole lot more respectful than keeping your own database of email addresses and then having it compromised some day. MailChimp has a detailed privacy policy [1]; does your handrolled service offer the same? ChrisA [1] https://mailchimp.com/legal/privacy/ From alex at lussinan.invalid Mon Jan 14 06:57:33 2019 From: alex at lussinan.invalid (Alex Ternaute) Date: 14 Jan 2019 11:57:33 GMT Subject: get the terminal's size Message-ID: <5c3c792d$0$3711$426a74cc@news.free.fr> Hi there, I want to know the number of columns of the terminal where python2 writes it's outputs. In a terminal, I type $ echo $COLUMNS 100 But in Python, os.getenv("COLUMNS") gets nothing. It gets nothing as well if I try to read the output of "echo $COLUMNS" from a subprocess. I feel that I'm missing something but what ? Looking on the internet for a hint, I see that python3 has an os.get_terminal_size(). Please, is there something similar for python2 ? Cheers -- Alex From __peter__ at web.de Mon Jan 14 07:17:37 2019 From: __peter__ at web.de (Peter Otten) Date: Mon, 14 Jan 2019 13:17:37 +0100 Subject: How to run a module before install? References: <57d0cadd-2b04-4024-bb2b-ead5fe9e732b@googlegroups.com> <1369e332-ff8d-4ff7-a3b3-a24b0f8f73eb@googlegroups.com> Message-ID: jfong at ms4.hinet.net wrote: >> h:\Temp\XL-Sudoku-Solver-master>py -m xl_sudoku_solver > > Great! it works. Thank you, peter. > > By the way, can you explain what these two command difference means? with > or without a "-m". Or pointing where the document is. Thanks ahead:-) > https://docs.python.org/dev/using/cmdline.html#cmdoption-m From __peter__ at web.de Mon Jan 14 07:33:06 2019 From: __peter__ at web.de (Peter Otten) Date: Mon, 14 Jan 2019 13:33:06 +0100 Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: Alex Ternaute wrote: > Hi there, > > I want to know the number of columns of the terminal where python2 writes > it's outputs. > > In a terminal, I type > $ echo $COLUMNS > 100 > > But in Python, os.getenv("COLUMNS") gets nothing. > It gets nothing as well if I try to read the output of "echo $COLUMNS" > from a subprocess. > > I feel that I'm missing something but what ? $ python -c 'import os; print os.environ["COLUMNS"]' Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__ raise KeyError(key) KeyError: 'COLUMNS' $ export COLUMNS $ python -c 'import os; print os.environ["COLUMNS"]' 157 If you see similar output consider adding export COLUMNS LINES to your .bashrc or equivalent. > Looking on the internet for a hint, I see that python3 has an > os.get_terminal_size(). > Please, is there something similar for python2 ? > > Cheers From alex at lussinan.invalid Mon Jan 14 08:11:21 2019 From: alex at lussinan.invalid (Alex Ternaute) Date: 14 Jan 2019 13:11:21 GMT Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: <5c3c8a79$0$3725$426a74cc@news.free.fr> Hi, Peter Otten : >> In a terminal, I type $ echo $COLUMNS 100 >> But in Python, os.getenv("COLUMNS") gets nothing. >> I feel that I'm missing something but what ? > $ export COLUMNS Thank you very much ! -- Aelx From tjol at tjol.eu Mon Jan 14 08:27:13 2019 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 14 Jan 2019 14:27:13 +0100 Subject: get the terminal's size In-Reply-To: <5c3c792d$0$3711$426a74cc@news.free.fr> References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: <27930e12-1c24-7c77-5ca8-bac0fd2c400a@tjol.eu> On 14/01/2019 12.57, Alex Ternaute wrote: > Hi there, > > I want to know the number of columns of the terminal where python2 writes > it's outputs. > > In a terminal, I type > $ echo $COLUMNS > 100 > > But in Python, os.getenv("COLUMNS") gets nothing. > It gets nothing as well if I try to read the output of "echo $COLUMNS" > from a subprocess. > > I feel that I'm missing something but what ? > > Looking on the internet for a hint, I see that python3 has an > os.get_terminal_size(). Use that then. > Please, is there something similar for python2 ? I suspect there is some solution in the curses module... From h.goebel at goebel-consult.de Mon Jan 14 08:52:16 2019 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Mon, 14 Jan 2019 14:52:16 +0100 Subject: Email blast management? In-Reply-To: References: Message-ID: Am 14.01.19 um 12:47 schrieb Chris Angelico: > It's a whole lot more respectful than keeping your own database of > email addresses and then having it compromised some day. This assumes that one would not *keep* a list of customers in in company. -- Sch?nen Gru? Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: https://www.goe-con.de/blog/chatsecure-ist-tot-lang-lebe-chatsecure Kolumne: https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-02-fleisige-datensammler-fur-lukratives-geschaeftsmodell-gesucht From simonppears at googlemail.com Mon Jan 14 09:54:28 2019 From: simonppears at googlemail.com (dcs3spp) Date: Mon, 14 Jan 2019 06:54:28 -0800 (PST) Subject: python package management confusion Message-ID: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> Hi, I am a newbie completely confused with python package management. I have a setup.py file (listed below) and have setup pip and setup.cfg to install my own dependencies from a local devpi repository. Can setup.py reference a git repository so that I can install from that url? Is this possible in newer versions of setuptools? Does anyone have any examples? Completely confused with managing packages in python.... Kind regards dcs3spp *************** setup.py ****************** import os import sys from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(here, 'README.md')) as f: README = f.read() with open(os.path.join(here, 'CHANGES.md')) as f: CHANGES = f.read() requires = [ 'cryptography', 'odfpy', 'PyJWT', 'pycrypto', 'pyramid', 'pyramid_core', # currently installed from devpi...can setup.py use git+ssh url like pip requirements.txt file? 'pyramid_debugtoolbar', 'pyramid_tm', 'requests==2.18.4', 'SQLAlchemy', 'transaction', 'zope.sqlalchemy', 'waitress', 'psycopg2-binary', 'python-dateutil', 'uwsgi', 'marshmallow-sqlalchemy', ] setup_requires = [ 'pytest-runner', ] tests_require = [ 'boto3', 'lovely-pytest-docker', 'pytest', 'pytest-cov', 'tuspy', 'WebTest >= 1.3.1', ] setup(name='api', version='0.0', description='api', long_description=README + '\n\n' + CHANGES, classifiers=[ "Programming Language :: Python", "Framework :: Pyramid", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", ], author='simon pears', author_email='roughlea-music at outlook.com', url='', keywords='web wsgi bfg pylons pyramid', packages=find_packages('src'), package_dir={'': 'src'}, include_package_data=True, zip_safe=False, extras_require={ 'testing': tests_require, }, install_requires=requires, setup_requires=setup_requires, tests_require=tests_require, test_suite='tests', entry_points="""\ [paste.app_factory] main = api:main [console_scripts] initialize_api_db = api.scripts.initializedb:main """, ) From grant.b.edwards at gmail.com Mon Jan 14 10:19:51 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 14 Jan 2019 15:19:51 +0000 (UTC) Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: On 2019-01-14, Peter Otten <__peter__ at web.de> wrote: > >> I want to know the number of columns of the terminal where python2 writes >> it's outputs. >> >> In a terminal, I type >> $ echo $COLUMNS >> 100 >> >> But in Python, os.getenv("COLUMNS") gets nothing. >> It gets nothing as well if I try to read the output of "echo $COLUMNS" >> from a subprocess. [...] > If you see similar output consider adding > > export COLUMNS LINES > > to your .bashrc or equivalent. That will tell you the terminal size at the time Python was started. If the terminal size has changed while Python was running, those environment variables will be wrong. You need to use the TIOCGWINSZ ioctl call: http://www.delorie.com/djgpp/doc/libc/libc_495.html And to detect the size changes (so you know _when_ you need to do the above), you need to attach a signal handler for the WINCH signal. -- Grant Edwards grant.b.edwards Yow! Should I do my BOBBIE at VINTON medley? gmail.com From info at wingware.com Mon Jan 14 10:49:00 2019 From: info at wingware.com (Wingware) Date: Mon, 14 Jan 2019 10:49:00 -0500 Subject: ANN: Wing Python IDE 6.1.3 released Message-ID: <5C3CAF6C.60808@wingware.com> Hi, We've just released Wing 6.1.3 , which improves management of the Python Shell when the project environment changes, adds 2FA card selector capability in remote host configuration , improves support for virtualenv and PEP 8 reformatting , updates the How-To for Autodesk Maya , improves auto-completion in regex.py and some other third party modules, streamlines remote agent installation, and makes about 30 other improvements. See the change log for detailsFor details, see https://wingware.com/pub/wingide/6.1.3/CHANGELOG.txt Download Now About Wing Wingware's family of cross-platform Python IDEs make Python development easier, with powerful integrated editing, debugging, unit testing, and project management features. Wing runs on Windows, Linux, and OS X, and can be used to develop any kind of Python code for web, desktop, scientific, data analysis, embedded scripting, and other applications. Version 6 introduces many new features, including improved multi-selection , much easier remote development , debugging from the Python Shell , recursive debugging , PEP 484 and 526 type hinting , PEP 8 reformatting , support for Python 3.6 and 3.7, ability to create a new virtualenv from the New Project dialog, improved VI mode, support for Vagrant , Jupyter , Django 1.10+ and 2.0, and Windows Subsystem for Linux , improved support for matplotlib , easier Raspberry Pi development, optimized debugger, OS X full screen mode, One Dark color palette, Russian localization (thanks to Alexandr Dragukin), expanded free product line, and much more. For details, see What's New in Wing Version 6 . Wing 6 works with Python versions 2.5 through 2.7 and 3.2 through 3.7, including also Anaconda, ActivePython, EPD, Stackless, and others derived from the CPython implementation. Wing Pro requires purchasing or upgrading a license, or obtaining a 30-day trial at startup. Wing 101 and Wing Personal are free versions that omit some features . For more product information, please visit wingware.com Upgrading You can try Wing 6 without removing older versions. Wing 6 will read and convert your old preferences, settings, and projects. Projects should be saved to a new name since previous versions of Wing cannot read Wing 6 projects. See also Migrating from Older Versions and Upgrading . Links Release notice: https://wingware.com/news/2019-01-11 Downloads and Free Trial: https://wingware.com/downloads Buy: https://wingware.com/store/purchase Upgrade: https://wingware.com/store/upgrade Questions? Don't hesitate to email us at support at wingware.com. Thanks, -- Stephan Deibel Wingware | Python IDE The Intelligent Development Environment for Python Programmers wingware.com From Joseph.Schachner at Teledyne.com Mon Jan 14 11:00:06 2019 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Mon, 14 Jan 2019 16:00:06 +0000 Subject: Python read text file columnwise In-Reply-To: <7cce1a71-7e01-0a54-fe5b-408b8cd75118@DancesWithMice.info> References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> <7cce1a71-7e01-0a54-fe5b-408b8cd75118@DancesWithMice.info> Message-ID: About the original question: If I were you, I would put the 3 numbers into a list (or a tuple, if you don't need to modify them) and put this into a dictionary. The key would be the date & time string. Then, if you need to find a particular entry you can look it up by date and time. But I suspect, since you want column access, you won't need to do that. You can iterate through the entries in the dictionary easily and extract the data from a column, or from all the columns, if that?s what you want. for entry in mydict: value = entry.datalist[0] # I hope I have the syntax correct Now, what you do with value is up to you. I think personally rather than building a list I would make a generator function. A generator uses a "yield" statement to return a value, and it waits in that state. The next time you call it it continues and returns the next value. Kind of useful when the alternative is making and passing around huge lists. --- Joseph S. -----Original Message----- From: DL Neil Sent: Saturday, January 12, 2019 4:48 PM To: python-list at python.org Subject: Re: Python read text file columnwise On 12/01/19 1:03 PM, Piet van Oostrum wrote: > shibashibani at gmail.com writes: > >> Hello >>> >>> I'm very new in python. I have a file in the format: >>> >>> 2018-05-31 16:00:00 28.90 81.77 4.3 >>> 2018-05-31 20:32:00 28.17 84.89 4.1 >>> 2018-06-20 04:09:00 27.36 88.01 4.8 >>> 2018-06-20 04:15:00 27.31 87.09 4.7 >>> 2018-06-28 04.07:00 27.87 84.91 5.0 >>> 2018-06-29 00.42:00 32.20 104.61 4.8 >> >> I would like to read this file in python column-wise. >> >> I tried this way but not working .... >> event_list = open('seismicity_R023E.txt',"r") >> info_event = read(event_list,'%s %s %f %f %f %f\n'); To the OP: Python's standard I/O is based around data "streams". Whilst there is a concept of "lines" and thus an end-of-line character, there is not the idea of a record, in the sense of fixed-length fields and thus a defining and distinction between data items based upon position. Accordingly, whilst the formatting specification of strings and floats might work for output, there is no equivalent for accepting input data. Please re-read refs on file, read, readline, etc. > Why would you think that this would work? To the PO: Because in languages/libraries built around fixed-length files this is how one specifies the composition of fields making up a record - a data structure which dates back to FORTRAN and Assembler on mainframes and other magtape-era machines. Whilst fixed-length records/files are, by definition, less flexible than the more free-form data input Python accepts, they are more efficient and faster in situations where the data (format) is entirely consistent - such as the OP is describing! -- Regards =dn From __peter__ at web.de Mon Jan 14 11:52:06 2019 From: __peter__ at web.de (Peter Otten) Date: Mon, 14 Jan 2019 17:52:06 +0100 Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: Grant Edwards wrote: os.environ["COLUMNS"] > [...] will tell you the terminal size at the time Python was started. I admit that none of my scripts is ambitious enough to try and track changes in terminal size. But still, Grant's post prompted me to reread the doc and source of shutil.get_terminal_size(), and I think I should warn you that the environment variables take precedence over ioctl()-based detection in os.get_terminal_size(). I'll keep the exports for now because even for a pipe $ python3 -c 'import shutil; print(shutil.get_terminal_size())' | cat os.terminal_size(columns=80, lines=24) $ export LINES COLUMNS $ python3 -c 'import shutil; print(shutil.get_terminal_size())' | cat os.terminal_size(columns=137, lines=42) the current terminal is usually my final target. From grant.b.edwards at gmail.com Mon Jan 14 12:15:31 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 14 Jan 2019 17:15:31 +0000 (UTC) Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: On 2019-01-14, Peter Otten <__peter__ at web.de> wrote: > Grant Edwards wrote: > > os.environ["COLUMNS"] > >> [...] will tell you the terminal size at the time Python was started. > > I admit that none of my scripts is ambitious enough to try and track > changes in terminal size. > > But still, Grant's post prompted me to reread the doc and source of > shutil.get_terminal_size(), and I think I should warn you that the > environment variables take precedence over ioctl()-based detection > in os.get_terminal_size(). For non-interactive programs, the environment variable approach is usually good enough. For interactive programs you use ncurses, slang, newt, or somesuch library, and they deal with tracking the window size for you (mostly). -- Grant Edwards grant.b.edwards Yow! My haircut is totally at traditional! gmail.com From alex at lussinan.invalid Mon Jan 14 12:16:24 2019 From: alex at lussinan.invalid (Alex Ternaute) Date: 14 Jan 2019 17:16:24 GMT Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> <27930e12-1c24-7c77-5ca8-bac0fd2c400a@tjol.eu> Message-ID: <5c3cc3e8$0$15512$426a74cc@news.free.fr> Hi Thomas >> Looking on the internet for a hint, I see that python3 has an >> os.get_terminal_size(). > Use that then. Up to now I wanted to keep compatibility with a big bunch of code in Python2 that I do no maintain by myself. Well, I saw that get_terminal_size() follows the windows resizings. Whenever I consider forking to Python3, this would be my 1st step. >> Please, is there something similar for python2 ? > I suspect there is some solution in the curses module... I did dir(curse) but I could not see if something goes this way. Bye -- Alex From alex at lussinan.invalid Mon Jan 14 12:24:39 2019 From: alex at lussinan.invalid (Alex Ternaute) Date: 14 Jan 2019 17:24:39 GMT Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: <5c3cc5d7$0$15512$426a74cc@news.free.fr> Hi, Grant Edwards : >>export COLUMNS LINES > That will tell you the terminal size at the time Python was started. Ok, I think tracking these changes in real time is not worth the work to be done using Python2. I think at last I'll rewrite this (little) programe in Python3 in order to use get_terminal_size(). Bye -- Alex From Joseph.Schachner at Teledyne.com Mon Jan 14 12:24:40 2019 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Mon, 14 Jan 2019 17:24:40 +0000 Subject: get the terminal's size In-Reply-To: <5c3c792d$0$3711$426a74cc@news.free.fr> References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: <4ecfed99a6eb4eebb98ee3b8dced6569@Teledyne.com> Note sure why you couldn't capture $ echo $COLUMNS from a subprocess call. But, how about this (found on the web): from win32api import GetSystemMetrics print "Width =", GetSystemMetrics(0) print "Height =", GetSystemMetrics(1) -----Original Message----- From: Alex Ternaute Sent: Monday, January 14, 2019 6:58 AM To: python-list at python.org Subject: get the terminal's size Hi there, I want to know the number of columns of the terminal where python2 writes it's outputs. In a terminal, I type $ echo $COLUMNS 100 But in Python, os.getenv("COLUMNS") gets nothing. It gets nothing as well if I try to read the output of "echo $COLUMNS" from a subprocess. I feel that I'm missing something but what ? Looking on the internet for a hint, I see that python3 has an os.get_terminal_size(). Please, is there something similar for python2 ? Cheers -- Alex From grant.b.edwards at gmail.com Mon Jan 14 12:28:50 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 14 Jan 2019 17:28:50 +0000 (UTC) Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> <4ecfed99a6eb4eebb98ee3b8dced6569@Teledyne.com> Message-ID: On 2019-01-14, Schachner, Joseph wrote: > Note sure why you couldn't capture $ echo $COLUMNS from a subprocess > call. You can. But, the subprocess is going to inherit the value from the Python program's environment, so it's just pointless complexity. -- Grant Edwards grant.b.edwards Yow! I represent a at sardine!! gmail.com From Joseph.Schachner at Teledyne.com Mon Jan 14 12:35:37 2019 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Mon, 14 Jan 2019 17:35:37 +0000 Subject: get the terminal's size In-Reply-To: <5c3c792d$0$3711$426a74cc@news.free.fr> References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: <6da4cad5b8cc454b9f47be181e6f99a3@Teledyne.com> I just tested the fix I proposed, in Python 2.7.13 Code: from win32api import GetSystemMetrics def main(): print "Width =", GetSystemMetrics(0) print "Height =", GetSystemMetrics(1) if __name__ == '__main__': main() Result: Width = 1536 Height = 864 -----Original Message----- From: Alex Ternaute Sent: Monday, January 14, 2019 6:58 AM To: python-list at python.org Subject: get the terminal's size Hi there, I want to know the number of columns of the terminal where python2 writes it's outputs. In a terminal, I type $ echo $COLUMNS 100 But in Python, os.getenv("COLUMNS") gets nothing. It gets nothing as well if I try to read the output of "echo $COLUMNS" from a subprocess. I feel that I'm missing something but what ? Looking on the internet for a hint, I see that python3 has an os.get_terminal_size(). Please, is there something similar for python2 ? Cheers -- Alex From bob at mellowood.ca Mon Jan 14 13:08:06 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Mon, 14 Jan 2019 11:08:06 -0700 Subject: get the terminal's size In-Reply-To: <5c3c792d$0$3711$426a74cc@news.free.fr> References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: On Mon, Jan 14, 2019 at 4:57 AM Alex Ternaute wrote: > Hi there, > > I want to know the number of columns of the terminal where python2 writes > it's outputs. > > In a terminal, I type > $ echo $COLUMNS > 100 > > But in Python, os.getenv("COLUMNS") gets nothing. > It gets nothing as well if I try to read the output of "echo $COLUMNS" > from a subprocess. > > I feel that I'm missing something but what ? > > Looking on the internet for a hint, I see that python3 has an > os.get_terminal_size(). > Please, is there something similar for python2 ? > > Cheers > -- > Alex > -- > https://mail.python.org/mailman/listinfo/python-list > try this: http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python -- **** 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 dev_20192019 at outlook.com Mon Jan 14 11:19:45 2019 From: dev_20192019 at outlook.com (Juris __) Date: Mon, 14 Jan 2019 16:19:45 +0000 Subject: Tracemalloc overhead when profiling Message-ID: Hi, I was looking for a way to profile memory usage for some script which deals with log message parsing. Looking through Python's stdlib I stumbled upon tracemalloc module. So I tried my hand on profiling my script. A few things I noticed that I am not 100% sure I can explain. Tracemalloc memory overhead when tracing seems somewhere 3x-4x. Is that expected? The dumb example that demonstrates behavior: ---8<--- # memprof.py import tracemalloc def expensive(): return [str(x) for x in range(1_000_000)] if __name__ == '__main__': if not tracemalloc.is_tracing(): tracemalloc.start() snapshot1 = tracemalloc.take_snapshot() _ = expensive() snapshot2 = tracemalloc.take_snapshot() tracemalloc.stop() for stat in snapshot2.compare_to(snapshot1, key_type="lineno"): print(stat) ---8<--- Script output with naive GNU time program profiling: $ /usr/bin/time python3.7 memprof.py memprof.py:6: size=60.6 MiB (+60.6 MiB), count=1000001 (+1000001), average=64 B ...snip... 1.40user 0.10system 0:01.51elapsed 99%CPU (0avgtext+0avgdata 280284maxresident)k 0inputs+0outputs (0major+62801minor)pagefaults 0swaps Same script but without actually tracing with tracemalloc: $ /usr/bin/time python3.7 memprof.py 0.26user 0.03system 0:00.29elapsed 100%CPU (0avgtext+0avgdata 72316maxresident)k 0inputs+0outputs (0major+17046minor)pagefaults 0swaps So, when not tracing with tracemalloc memory used by script is 72MiB (credible since tracemalloc reports 60.6MiB allocated in hot spot). But then when tracemalloc is tracing script uses almost 4x memory e.g. 280MiB. Is this expected? Any other tools for memory profiling you can recommend? Running Python 3.7.2 on x86_64 Linux system. BR, Juris From rosuav at gmail.com Mon Jan 14 10:24:44 2019 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jan 2019 02:24:44 +1100 Subject: Email blast management? In-Reply-To: References: Message-ID: On Tue, Jan 15, 2019 at 12:53 AM Hartmut Goebel wrote: > > Am 14.01.19 um 12:47 schrieb Chris Angelico: > > It's a whole lot more respectful than keeping your own database of > > email addresses and then having it compromised some day. > > This assumes that one would not *keep* a list of customers in in company. > Honestly, I have no idea what you're moaning about. We don't have nearly enough details here to say what would be _the best_ way to do things, but I stand by my statement that services like MailChimp and Mailman are worth looking into. ChrisA From kyosohma at gmail.com Mon Jan 14 14:08:05 2019 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 14 Jan 2019 11:08:05 -0800 (PST) Subject: ANN: Creating GUI Applications with wxPython Message-ID: Hi, I just thought I would let you all know that I am working on my 2nd wxPython book, "Creating GUI Applications with wxPython". This one will be about actually creating small runnable applications instead of just recipes like my Cookbook did. I hope to have 8-10 working applications included with the book. You can read more about it here if you are interested: https://www.blog.pythonlibrary.org/2019/01/14/creating-gui-applications-with-wxpython-kickstarter/ Feel free to ask me questions about it too. Thanks, Mike From ibrewster at flyravn.com Mon Jan 14 14:42:55 2019 From: ibrewster at flyravn.com (Israel Brewster) Date: Mon, 14 Jan 2019 19:42:55 +0000 Subject: AssertionError without traceback? Message-ID: I have a flask application deployed on CentOS 7 using Python 3.6.7 and uwsgi 2.0.17.1, proxied behind nginx. uwsgi is configured to listed on a socket in /tmp. The app uses gevent and the flask_uwsgi_websockets plugin as well as various other third-party modules, all installed via pip in a virtualenv. The environment was set up using pip just a couple of days ago, so everything should be fully up-to-date. The application *appears* to be running properly (it is in moderate use and there have been no reports of issues, nor has my testing turned up any problems), however I keep getting entries like the following in the error log: AssertionError 2019-01-14T19:16:32Z failed with AssertionError There is no additional information provided, just that. I was running the same app (checked out from a GIT repository, so exact same code) on CentOS 6 for years without issue, it was only since I moved to CentOS 7 that I've seen the errors. I have not so far been able to correlate this error with any specific request. Has anyone seen anything like this before such that you can give me some pointers to fixing this? As the application *appears* to be functioning normally, it may not be a big issue, but it has locked up once since the move (no errors in the log, just not responding on the socket), so I am a bit concerned. ----------------------------------------------- Israel Brewster Systems Analyst II 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- [cid:05a3a602-0c27-4749-91b8-096a5857d984 at flyravn.com] [cid:bbc82752-6db4-44cf-b919-421ed304e1d1 at flyravn.com] From duncan at invalid.invalid Mon Jan 14 15:11:56 2019 From: duncan at invalid.invalid (duncan smith) Date: Mon, 14 Jan 2019 20:11:56 +0000 Subject: sampling from frequency distribution / histogram without replacement Message-ID: Hello, Just checking to see if anyone has attacked this problem before for cases where the population size is unfeasibly large. i.e. The number of categories is manageable, but the sum of the frequencies, N, precludes simple solutions such as creating a list, shuffling it and using the first n items to populate the sample (frequency distribution / histogram). I note that numpy.random.hypergeometric will allow me to generate a sample when I only have two categories, and that I could probably implement some kind of iterative / partitioning approach calling this repeatedly. But before I do I thought I'd ask if anyone has tackled this before. Can't find much on the web. Cheers. Duncan From cs at cskk.id.au Mon Jan 14 17:43:42 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 15 Jan 2019 09:43:42 +1100 Subject: get the terminal's size In-Reply-To: <5c3cc3e8$0$15512$426a74cc@news.free.fr> References: <5c3cc3e8$0$15512$426a74cc@news.free.fr> Message-ID: <20190114224342.GA61664@cskk.homeip.net> On 14Jan2019 17:16, Alex Ternaute wrote: >>> Looking on the internet for a hint, I see that python3 has an >>> os.get_terminal_size(). >> Use that then. > >Up to now I wanted to keep compatibility with a big bunch of code in >Python2 that I do no maintain by myself. > >Well, I saw that get_terminal_size() follows the windows resizings. >Whenever I consider forking to Python3, this would be my 1st step. > >>> Please, is there something similar for python2 ? >> I suspect there is some solution in the curses module... > >I did dir(curse) but I could not see if something goes this way. My cs.tty module (on PyPI) has a ttysize function: https://pypi.org/project/cs.tty/ which just parses the output of the stty command. Personally I resist using the environment variables; they're (a) not exports by default because they're "live" and (b) then don't track changes if they are exported and (c) rely on the shell providing them. I just don't trust them. If you don't want the cs.tty module, the ttysize code is just this: WinSize = namedtuple('WinSize', 'rows columns') def ttysize(fd): ''' Return a (rows, columns) tuple for the specified file descriptor. If the window size cannot be determined, None will be returned for either or both of rows and columns. This function relies on the UNIX `stty` command. ''' if not isinstance(fd, int): fd = fd.fileno() P = Popen(['stty', '-a'], stdin=fd, stdout=PIPE, universal_newlines=True) stty = P.stdout.read() xit = P.wait() if xit != 0: return None m = re.compile(r' rows (\d+); columns (\d+)').search(stty) if m: rows, columns = int(m.group(1)), int(m.group(2)) else: m = re.compile(r' (\d+) rows; (\d+) columns').search(stty) if m: rows, columns = int(m.group(1)), int(m.group(2)) else: rows, columns = None, None return WinSize(rows, columns) Hope this helps. Cheers, Cameron Simpson From greg.ewing at canterbury.ac.nz Mon Jan 14 17:59:38 2019 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 15 Jan 2019 11:59:38 +1300 Subject: sampling from frequency distribution / histogram without replacement In-Reply-To: References: Message-ID: duncan smith wrote: > Hello, > Just checking to see if anyone has attacked this problem before > for cases where the population size is unfeasibly large. The fastest way I know of is to create a list of cumulative frequencies, then generate uniformly distributed numbers and use a binary search to find where they fall in the list. That's O(log n) per sample in the size of the list once it's been set up. -- Greg From john at doe.com Mon Jan 14 18:03:53 2019 From: john at doe.com (John Doe) Date: Mon, 14 Jan 2019 23:03:53 -0000 (UTC) Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: On 2019-01-14, Bob van der Poel wrote: > try this: > > > http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python > and have a look at this one too: https://stackoverflow.com/questions/1396820/apt-like-column-output-python-library/1446973#1446973 > From avigross at verizon.net Mon Jan 14 16:55:54 2019 From: avigross at verizon.net (Avi Gross) Date: Mon, 14 Jan 2019 16:55:54 -0500 Subject: Email blast management? In-Reply-To: References: Message-ID: <004001d4ac53$ecb70f30$c6252d90$@verizon.net> There is an old saying about getting what you paid for. Python can be free but applications have costs. Chris makes some valid points when saying there are existing solutions that may be worth considering. If someone wants to know about commercial products that do approximately what they need and provide some level of service, they can buy it. If they want it for free, they can create whatever they want using their own code augmented by any free code they are legally allowed to incorporate. But free is often not quite free. Look at the complaints about Google and Facebook who try to make a buck (or a billion) by looking at the data you generate and helping target advertisers or worse? Look at how the data sometimes gets out, legally or otherwise? Some people now choose to switch browsers after they keep seeing ads follow them everywhere for items they once LOOKED AT and did not even buy. Is there absolute security if you roll your own app, using python or anything else? I seriously doubt it. Python probably is not ideal in the sense that your source code is often readable if someone breaks into your machine. If you were to say encrypt/decrypt some things so items are never in plaintext on disk, your code may allow them to see what methods are used and, if you are careless enough, may even expose the key you use. I was involved in creating and maintaining a fairly early email product targeted at businesses quite a few years ago. Part of my responsibility at one point was to READ a subclass of the mail. Messages that made it into the system but ran into problems would often end up in a junkmail category and we needed to examine them to find out what went wrong and file modification requests. In addition, if we could figure out how to "fix" a message and sent it onward for delivery, we tried. An example of such an error was when we added a heterogeneous set of machines in the worldwide network of different types, a message that fit in memory on one might fail when passed to/through another kind. We had to adjust the maximum size allowed to what would fit anywhere. The point is that someone like me with the root password could read ANYTHING. All logs were equally available so making a list of all email addresses or a graph showing communication chains was possible. Many applications may be vulnerable to just one bad employee given such access. Some may be vulnerable if just one machine in an intranet is corrupted in some way. Again, this is not just about email but credit card use, browsing history, etc. But I suggest that unless you hire very experienced people to roll your own, you risk being even less secure than with a more trusted commercial product. Of course, if you want truly unique features, that may be a reason to have your own. The above is some thoughts and is not to be attacked as a suggestion to waste money buying specific products. I am not selling anything just reflecting on a wider issue. There seems to be very little absolute safety in the cyber world just as there really isn't in the physical world. You take your chances but hopefully with some idea of the risks. Someday anything you encrypt today may become easily readable unless you use fairly elaborate one-time pads. -----Original Message----- From: Python-list On Behalf Of Chris Angelico Sent: Monday, January 14, 2019 10:25 AM To: Python Subject: Re: Email blast management? On Tue, Jan 15, 2019 at 12:53 AM Hartmut Goebel wrote: > > Am 14.01.19 um 12:47 schrieb Chris Angelico: > > It's a whole lot more respectful than keeping your own database of > > email addresses and then having it compromised some day. > > This assumes that one would not *keep* a list of customers in in company. > Honestly, I have no idea what you're moaning about. We don't have nearly enough details here to say what would be _the best_ way to do things, but I stand by my statement that services like MailChimp and Mailman are worth looking into. ChrisA -- https://mail.python.org/mailman/listinfo/python-list From duncan at invalid.invalid Mon Jan 14 19:40:25 2019 From: duncan at invalid.invalid (duncan smith) Date: Tue, 15 Jan 2019 00:40:25 +0000 Subject: sampling from frequency distribution / histogram without replacement In-Reply-To: References: Message-ID: <_Z9%D.62653$n85.12814@fx38.iad> On 14/01/2019 22:59, Gregory Ewing wrote: > duncan smith wrote: >> Hello, >> ????? Just checking to see if anyone has attacked this problem before >> for cases where the population size is unfeasibly large. > > The fastest way I know of is to create a list of cumulative > frequencies, then generate uniformly distributed numbers and > use a binary search to find where they fall in the list. > That's O(log n) per sample in the size of the list once it's > been set up. > That's the sort of thing I've been thinking about. But once I'd found the relevant category I'd need to reduce its frequency by 1 and correspondingly update the cumulative frequencies. Alternatively, I could add an extra step where I selected a unit from the relevant category with probability equal to the proportion of non-sampled units from the category. I could maybe set up an alias table and do something similar. The other thing I was thinking about was iterating through the categories (ideally from largest frequency to smallest frequency), generating the numbers to be sampled from the current category and the remaining categories (using numpy.random.hypergeometric). With a few large frequencies and lots of small frequencies that could be quite quick (on average). Alternatively I could partition the categories into two sets, generate the number to be sampled from each partition, then partition the partitions etc. binary search style. I suppose I'll try the both the alias table + rejection step and the recursive partitioning approach and see how they turn out. Cheers. Duncan From eryksun at gmail.com Mon Jan 14 21:35:15 2019 From: eryksun at gmail.com (eryk sun) Date: Mon, 14 Jan 2019 20:35:15 -0600 Subject: get the terminal's size In-Reply-To: <6da4cad5b8cc454b9f47be181e6f99a3@Teledyne.com> References: <5c3c792d$0$3711$426a74cc@news.free.fr> <6da4cad5b8cc454b9f47be181e6f99a3@Teledyne.com> Message-ID: On 1/14/19, Schachner, Joseph wrote: > I just tested the fix I proposed, in Python 2.7.13 > > Code: > from win32api import GetSystemMetrics > > def main(): > print "Width =", GetSystemMetrics(0) > print "Height =", GetSystemMetrics(1) That gets the monitor size, i.e: SM_CXSCREEN (0) The width of the screen of the primary display monitor, in pixels. SM_CYSCREEN (1) The height of the screen of the primary display monitor, in pixels. The console's visible window is a rectangular view on its active screen buffer. We have to query the screen-buffer information to obtain the coordinates of this rectangle (right, left, bottom, top). Python's os.get_terminal_size does this, but I dislike the fact that it uses the process standard handles instead of C file descriptors and only supports 0, 1, and 2. Here's a version that defaults to opening the console's active screen buffer, "CONOUT$". Otherwise it uses msvcrt.get_osfhandle to get the handle for the fd argument instead of hard-mapping 0, 1, and 2 to the process standard handles. For symmetry, I've also added POSIX code that switches the default to opening "/dev/tty" instead of using stdout. import os import ctypes from collections import namedtuple terminal_size = namedtuple('terminal_size', 'columns lines') if os.name == 'posix': import tty import fcntl class winsize(ctypes.Structure): _fields_ = (('ws_row', ctypes.c_ushort), ('ws_col', ctypes.c_ushort), ('ws_xpixel', ctypes.c_ushort), ('ws_ypixel', ctypes.c_ushort)) def get_terminal_size(fd=None): """Return the size of the terminal window as (columns, lines). The optional argument fd specifies which file descriptor should be queried. An OSError is raised if the file descriptor is not connected to a terminal (Unix) or a console screen buffer (Windows). The default behavior is to open and query the process controlling terminal (i.e. Unix "/dev/tty") or active console screen buffer (i.e. Windows "CONOUT$"). """ w = winsize() if fd is None: fd_used = os.open('/dev/tty', os.O_RDWR) else: fd_used = fd try: fcntl.ioctl(fd_used, tty.TIOCGWINSZ, w) finally: if fd is None: os.close(fd_used) return terminal_size(w.ws_col, w.ws_row) elif os.name == 'nt': import msvcrt from ctypes import wintypes kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) class CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): _fields_ = (('dwSize', wintypes._COORD), ('dwCursorPosition', wintypes._COORD), ('wAttributes', wintypes.WORD), ('srWindow', wintypes.SMALL_RECT), ('dwMaximumWindowSize', wintypes._COORD)) kernel32.GetConsoleScreenBufferInfo.argtypes = ( wintypes.HANDLE, ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO)) def get_terminal_size(fd=None): """Return the size of the terminal window as (columns, lines). The optional argument fd specifies which file descriptor should be queried. An OSError is raised if the file descriptor is not connected to a terminal (Unix) or a console screen buffer (Windows). The default behavior is to open and query the process controlling terminal (i.e. Unix "/dev/tty") or active console screen buffer (i.e. Windows "CONOUT$"). """ csbi = CONSOLE_SCREEN_BUFFER_INFO() w = csbi.srWindow if fd is None: fd_used = os.open('CONOUT$', os.O_RDWR) else: fd_used = fd try: h = msvcrt.get_osfhandle(fd_used) if not kernel32.GetConsoleScreenBufferInfo(h, ctypes.byref(csbi)): raise ctypes.WinError(ctypes.get_last_error()) finally: if fd is None: os.close(fd_used) return terminal_size(w.Right - w.Left + 1, w.Bottom - w.Top + 1) From spencer.graves at effectivedefense.org Mon Jan 14 21:41:05 2019 From: spencer.graves at effectivedefense.org (Spencer Graves) Date: Mon, 14 Jan 2019 20:41:05 -0600 Subject: sampling from frequency distribution / histogram without replacement In-Reply-To: <_Z9%D.62653$n85.12814@fx38.iad> References: <_Z9%D.62653$n85.12814@fx38.iad> Message-ID: <6c2f6541-ce5a-b2cc-dd9a-1cb45741be6d@effectivedefense.org> On 2019-01-14 18:40, duncan smith wrote: > On 14/01/2019 22:59, Gregory Ewing wrote: >> duncan smith wrote: >>> Hello, >>> ????? Just checking to see if anyone has attacked this problem before >>> for cases where the population size is unfeasibly large. >> The fastest way I know of is to create a list of cumulative >> frequencies, then generate uniformly distributed numbers and >> use a binary search to find where they fall in the list. >> That's O(log n) per sample in the size of the list once it's >> been set up. >> > That's the sort of thing I've been thinking about. But once I'd found > the relevant category I'd need to reduce its frequency by 1 and > correspondingly update the cumulative frequencies. Alternatively, I > could add an extra step where I selected a unit from the relevant > category with probability equal to the proportion of non-sampled units > from the category. I could maybe set up an alias table and do something > similar. > > The other thing I was thinking about was iterating through the > categories (ideally from largest frequency to smallest frequency), > generating the numbers to be sampled from the current category and the > remaining categories (using numpy.random.hypergeometric). With a few > large frequencies and lots of small frequencies that could be quite > quick (on average). Alternatively I could partition the categories into > two sets, generate the number to be sampled from each partition, then > partition the partitions etc. binary search style. > > I suppose I'll try the both the alias table + rejection step and the > recursive partitioning approach and see how they turn out. Cheers. ????? R has functions "sample" and "sample.int";? see "https://www.rdocumentation.org/packages/base/versions/3.5.2/topics/sample". You can call R from Python, "https://sites.google.com/site/aslugsguidetopython/data-analysis/pandas/calling-r-from-python". ????? These are in the "base" package.? I believe they have been an important part of the base R language almost since its inception and have been used extensively.? You'd have to work really hard to do better, in my judgment. ??? ? Spencer Graves DISCLAIMER:? I'm primarily an R guy and only use Python when I can't find a sensible way to do what I want in R. > > Duncan From caigy84 at gmail.com Tue Jan 15 00:29:36 2019 From: caigy84 at gmail.com (caigy84 at gmail.com) Date: Mon, 14 Jan 2019 21:29:36 -0800 (PST) Subject: 3 random numbers Message-ID: <6a9dcf99-cb55-4bb7-a22f-1c54480c05a3@googlegroups.com> So I was given this question to be solved in Python 3 : Pick any 3 random ascending numbers and write out a loop function that prints out all 3 numbers. This was the code and solution presented to me. Can anyone understand it and explain it to me please ? I have looked at it but cannot see how it was derived and why the correct solution was printed. Thanks alot ! # any 3 ascending numbers , counter must start at 0. # 400 467 851 i = 0 x = 400 while x < 852: print(x) if i > 0: x = x + ((i + 4) * 67) + (i * 49) else: x = x + 67 i = i + 1 From spencer.graves at effectivedefense.org Tue Jan 15 00:46:04 2019 From: spencer.graves at effectivedefense.org (Spencer Graves) Date: Mon, 14 Jan 2019 23:46:04 -0600 Subject: 3 random numbers In-Reply-To: <6a9dcf99-cb55-4bb7-a22f-1c54480c05a3@googlegroups.com> References: <6a9dcf99-cb55-4bb7-a22f-1c54480c05a3@googlegroups.com> Message-ID: <9ab2b489-08f5-22e7-f3a0-39c5e451f1f1@effectivedefense.org> On 2019-01-14 23:29, caigy84 at gmail.com wrote: > So I was given this question to be solved in Python 3 : Pick any 3 random ascending numbers and write out a loop function that prints out all 3 numbers. This was the code and solution presented to me. Can anyone understand it and explain it to me please ? I have looked at it but cannot see how it was derived and why the correct solution was printed. Thanks alot ! > > # any 3 ascending numbers , counter must start at 0. > # 400 467 851 > i = 0 > x = 400 > while x < 852: > print(x) > if i > 0: > x = x + ((i + 4) * 67) + (i * 49) > else: > x = x + 67 > i = i + 1 ????? This sounds like a homework problem for a class.? I don't know how this list treats such questions, but I suspect answering such questions may be discouraged. ????? Hint:? Read the documentation on "while" and then trace the iterations. ??? ? Spencer From cs at cskk.id.au Tue Jan 15 00:57:52 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 15 Jan 2019 16:57:52 +1100 Subject: 3 random numbers In-Reply-To: <6a9dcf99-cb55-4bb7-a22f-1c54480c05a3@googlegroups.com> References: <6a9dcf99-cb55-4bb7-a22f-1c54480c05a3@googlegroups.com> Message-ID: <20190115055752.GA45711@cskk.homeip.net> On 14Jan2019 21:29, caigy84 at gmail.com wrote: >So I was given this question to be solved in Python 3 : Pick any > 3 random ascending numbers and write out a loop function that prints > out all 3 numbers. This was the code and solution presented to me. > Can anyone understand it and explain it to me please ? I have looked > at it but cannot see how it was derived and why the correct solution > was printed. Thanks alot ! Indentation is vital in Python; it is used to delineate the start and end of loops and control structures etc (where other languages might use curly braces). So because your pasted code has no indentation we must guess. I'm going to reindent to express what I'm guessing: # any 3 ascending numbers , counter must start at 0. # 400 467 851 i = 0 x = 400 while x < 852: print(x) if i > 0: x = x + ((i + 4) * 67) + (i * 49) else: x = x + 67 i = i + 1 The other thing is that I do not think you have described the problem correctly, or if that _is_ how it was expressed to you then it is a terrible terrible problem description. All the code above does is (a) start "x" at 400, which is your first arbitrary value and (b) stop the loop when "x" >= 852, which _prevents_ it printing any numbers above your last arbitrary value (851). The bit in the middle is just contrived. The important things about the code seem to be: "x" is always increased. This ensures that the loop will finish, because "x" starts below the limit (852) and always gets closer to it, and eventually exceeds it ==> loop exits. The first pass through the loop when "x" == 0 just adds 67 to it, getting from 400 to 467, your second arbitrary number. So this isn't some clever bit of code that does something to generate 3 values, it is a loop that runs three times to get exactly the 3 values in your comment. I suspect we're missing the larger picture here. Cheers, Cameron Simpson From dieter at handshake.de Tue Jan 15 02:17:07 2019 From: dieter at handshake.de (dieter) Date: Tue, 15 Jan 2019 08:17:07 +0100 Subject: python package management confusion References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> Message-ID: <878szm75l8.fsf@handshake.de> dcs3spp via Python-list writes: > I am a newbie completely confused with python package management. > > I have a setup.py file (listed below) and have setup pip and setup.cfg to install my own dependencies from a local devpi repository. > > Can setup.py reference a git repository so that I can install from that url? I doubt it: A primary goal of the Python package management is to allow users to easily install prepackaged components (published in a repository like PyPI) - not to integrate transparently with source code control systems. I approach development of Python components by checking them out of the source code control system and then use "setuptool"'s "python setup.py develop" in their source tree to integrate the component in a virtual env for testing and developping purposes. Another option (I also use occasioanally) would be to use "zc.buildout". By itself, it does not integrate with "git" but there is an extension (I think "mr.developer" or similarly spelled) which allows to directly reference "git" repositories as source for so called "development eggs"). From dieter at handshake.de Tue Jan 15 02:32:25 2019 From: dieter at handshake.de (dieter) Date: Tue, 15 Jan 2019 08:32:25 +0100 Subject: Tracemalloc overhead when profiling References: Message-ID: <874laa74vq.fsf@handshake.de> Juris __ writes: > I was looking for a way to profile memory usage for some script which > deals with log message parsing. Looking through Python's stdlib I > stumbled upon tracemalloc module. So I tried my hand on profiling my > script. A few things I noticed that I am not 100% sure I can explain. > > Tracemalloc memory overhead when tracing seems somewhere 3x-4x. Is that > expected? Yes. One of the API functions of "tracemalloc" is "get_object_traceback" which allows you to ask for each allocated Python object where is has been allocated. Your example below constructs a large number of small objects and the "where allocated" information for each of those objects is far bigger than the object itself. > The dumb example that demonstrates behavior: > > ---8<--- > # memprof.py > import tracemalloc > > def expensive(): > return [str(x) for x in range(1_000_000)] > > if __name__ == '__main__': > > if not tracemalloc.is_tracing(): > tracemalloc.start() > > snapshot1 = tracemalloc.take_snapshot() > > _ = expensive() > > snapshot2 = tracemalloc.take_snapshot() > tracemalloc.stop() > > for stat in snapshot2.compare_to(snapshot1, key_type="lineno"): > print(stat) > ---8<--- > > > Script output with naive GNU time program profiling: > > $ /usr/bin/time python3.7 memprof.py > memprof.py:6: size=60.6 MiB (+60.6 MiB), count=1000001 (+1000001), > average=64 B > ...snip... > 1.40user 0.10system 0:01.51elapsed 99%CPU (0avgtext+0avgdata > 280284maxresident)k > 0inputs+0outputs (0major+62801minor)pagefaults 0swaps > > > Same script but without actually tracing with tracemalloc: > > $ /usr/bin/time python3.7 memprof.py > 0.26user 0.03system 0:00.29elapsed 100%CPU (0avgtext+0avgdata > 72316maxresident)k > 0inputs+0outputs (0major+17046minor)pagefaults 0swaps > > > So, when not tracing with tracemalloc memory used by script is 72MiB > (credible since tracemalloc reports 60.6MiB allocated in hot spot). But > then when tracemalloc is tracing script uses almost 4x memory e.g. 280MiB. > > Is this expected? Any other tools for memory profiling you can recommend? > > Running Python 3.7.2 on x86_64 Linux system. > > BR, > Juris From dieter at handshake.de Tue Jan 15 02:40:58 2019 From: dieter at handshake.de (dieter) Date: Tue, 15 Jan 2019 08:40:58 +0100 Subject: AssertionError without traceback? References: Message-ID: <87zhs25px1.fsf@handshake.de> Israel Brewster writes: > I have a flask application deployed on CentOS 7 using Python 3.6.7 and uwsgi 2.0.17.1, proxied behind nginx. uwsgi is configured to listed on a socket in /tmp. The app uses gevent and the flask_uwsgi_websockets plugin as well as various other third-party modules, all installed via pip in a virtualenv. The environment was set up using pip just a couple of days ago, so everything should be fully up-to-date. The application *appears* to be running properly (it is in moderate use and there have been no reports of issues, nor has my testing turned up any problems), however I keep getting entries like the following in the error log: > > AssertionError > 2019-01-14T19:16:32Z failed with AssertionError I would try to find out where the log message above has been generated and ensure it does not only log the information above but also the associated traceback. I assume that the log comes from some framework -- maybe "uwsgi" or "gevent". It is a weakness to log exceptions without the associated traceback. > There is no additional information provided, just that. I was running the same app (checked out from a GIT repository, so exact same code) on CentOS 6 for years without issue, it was only since I moved to CentOS 7 that I've seen the errors. I have not so far been able to correlate this error with any specific request. Has anyone seen anything like this before such that you can give me some pointers to fixing this? As the application *appears* to be functioning normally, it may not be a big issue, but it has locked up once since the move (no errors in the log, just not responding on the socket), so I am a bit concerned. > ----------------------------------------------- > Israel Brewster > Systems Analyst II > 5245 Airport Industrial Rd > Fairbanks, AK 99709 > (907) 450-7293 > ----------------------------------------------- > > [cid:05a3a602-0c27-4749-91b8-096a5857d984 at flyravn.com] > > > > [cid:bbc82752-6db4-44cf-b919-421ed304e1d1 at flyravn.com] From rosuav at gmail.com Tue Jan 15 02:48:29 2019 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jan 2019 18:48:29 +1100 Subject: python package management confusion In-Reply-To: <878szm75l8.fsf@handshake.de> References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> Message-ID: On Tue, Jan 15, 2019 at 6:18 PM dieter wrote: > > dcs3spp via Python-list writes: > > I am a newbie completely confused with python package management. > > > > I have a setup.py file (listed below) and have setup pip and setup.cfg to install my own dependencies from a local devpi repository. > > > > Can setup.py reference a git repository so that I can install from that url? > > I doubt it: > A primary goal of the Python package management is to allow users > to easily install prepackaged components (published in a repository > like PyPI) - not to integrate transparently with source code control > systems. You can use pip to install from a git repo, but I don't know the details. ChrisA From alex at lussinan.invalid Tue Jan 15 05:26:46 2019 From: alex at lussinan.invalid (Alex Ternaute) Date: 15 Jan 2019 10:26:46 GMT Subject: get the terminal's size References: <5c3cc3e8$0$15512$426a74cc@news.free.fr> <20190114224342.GA61664@cskk.homeip.net> Message-ID: <5c3db566$0$31400$426a74cc@news.free.fr> Hi Cameron, > My cs.tty module (on PyPI) has a ttysize function: > https://pypi.org/project/cs.tty/ > which just parses the output of the stty command. > If you don't want the cs.tty module, the ttysize code is just this: > > WinSize = namedtuple('WinSize', 'rows columns') > > def ttysize(fd): > ''' Return a (rows, columns) tuple for the specified file > descriptor. > [...] Fine, indeed ! I've installed cs.ttyy. I just don't understand the reason why it takes "fd" as an argument. I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE, universal_newlines=True) and it runs fine too, so the output seems not really related to that fd. Btw I did not know about namedtuple, thanks for that too. > Hope this helps. Greatly. Cheers, -- Alex From simonppears at googlemail.com Tue Jan 15 05:42:11 2019 From: simonppears at googlemail.com (dcs3spp) Date: Tue, 15 Jan 2019 02:42:11 -0800 (PST) Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> Message-ID: On Tuesday, 15 January 2019 07:48:57 UTC, Chris Angelico wrote: > On Tue, Jan 15, 2019 at 6:18 PM dieter wrote: > > > > dcs3spp via Python-list writes: > > > I am a newbie completely confused with python package management. > > > > > > I have a setup.py file (listed below) and have setup pip and setup.cfg to install my own dependencies from a local devpi repository. > > > > > > Can setup.py reference a git repository so that I can install from that url? > > > > I doubt it: > > A primary goal of the Python package management is to allow users > > to easily install prepackaged components (published in a repository > > like PyPI) - not to integrate transparently with source code control > > systems. > > You can use pip to install from a git repo, but I don't know the details. > > ChrisA Ok cheers all for responding, appreciated.... So to manage the development of private packages, e.g. wheels, I would have to use my own private repository (something like devpi or a an alternative cloud pypi subscription service) to store each private dependency that I have written. Alternatively, I would rely on pip requirement files. Will have to investigate zbuildout... The package source for each dependency package could be managed in source control (git, gitlab etc.) and tested in CI build .... gitlab-runner/Jenkins. In the local development environment, packages that use the dependency package could use the local devpi repository. This would work in a private bare metal environment. However, if I wanted to take a step further and run a CI build using cloud services(e.g. in a private gitlab.com repository) for a package that uses the private packages, then presumably there is no access to the devpi repository on my local system? So, alternatively when developing private Python packages I either use requirements.txt or pay subscription for a private pypi cloud repository and configure pip, setup.cfg on gitlab.com CI to reference it in config files. When the CI build completes it pushes the package to the private pypi repository. Alternatively: 1. Avoid cloud CI services when developing private Python packages and use private bare metal CI server, e.g. gitlab, Jenkins etc. ? 2. Use one monolithic package. From alex at lussinan.invalid Tue Jan 15 05:43:32 2019 From: alex at lussinan.invalid (Alex Ternaute) Date: 15 Jan 2019 10:43:32 GMT Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: <5c3db954$0$31400$426a74cc@news.free.fr> Hi there?: > On 2019-01-14, Bob van der Poel wrote: >> http://stackoverflow.com/questions/566746/how-to-get-console-window- width-in-python Simple and direct, I think I'll use this one. Thanks a lot. John Doe : > and have a look at this one too: > https://stackoverflow.com/questions/1396820/apt-like-column-output- python-library/1446973#1446973 Fine, but It meets much more needs than my present one. But thanks too. Bye -- Alex From cs at cskk.id.au Tue Jan 15 07:01:16 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 15 Jan 2019 23:01:16 +1100 Subject: get the terminal's size In-Reply-To: <5c3db566$0$31400$426a74cc@news.free.fr> References: <5c3db566$0$31400$426a74cc@news.free.fr> Message-ID: <20190115120116.GA91295@cskk.homeip.net> On 15Jan2019 10:26, Alex Ternaute wrote: >> My cs.tty module (on PyPI) has a ttysize function: >> https://pypi.org/project/cs.tty/ >> which just parses the output of the stty command. [...] >Fine, indeed ! I've installed cs.ttyy. > >I just don't understand the reason why it takes "fd" as an argument. "fd" may be a file descriptor or a file (from which it gets the underlying fd). >I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE, >universal_newlines=True) and it runs fine too, so the output seems not >really related to that fd. But it is! stty(1) fetches the terminal settings from its standard input, so "fd" is used to supply this. In your Popen test case you simply don't set the stdin parameter, so it is the Python process' input. Which is usually what you want. But I want to be able to ask this of any terminal file, thus the parameter. Just pass 0 to ttysize, or sys.stdin. Arguably that should be a default value. >Btw I did not know about namedtuple, thanks for that too. Yes, it is very handy. Cheers, Cameron Simpson From stefano at stalksoftINVALID.com Tue Jan 15 07:23:47 2019 From: stefano at stalksoftINVALID.com (steve) Date: Tue, 15 Jan 2019 12:23:47 +0000 Subject: [tkinter] question about correct use of validation Message-ID: for determine the maximum number of characters in an entry I have read several interpretations for the solution of the problem, but I wanted to find an alternative way (for convenience of the code) I kindly ask for an opinion on the use of validation in this way. ----- problem: limit number of characters in different entries of a form. code: #!/usr/bin/python # -*- coding: utf-8 -* from Tkinter import * class View(): def __init__(self, parent): self.parent = parent self.make_ui() def make_ui(self): ''' create user interface ''' self.id_entry = Entry(self.parent, width=6) # take out the properties for understanding vcmd = (self.parent.register(self.maxlength_validate), '%P', 4) # 4 is my question self.id_entry.configure(validate="key", validatecommand=vcmd) self.id_entry.pack() self.name_entry = Entry(self.parent, width=30) # take out the properties for understanding vcmd = (self.parent.register(self.maxlength_validate), '%P', 20) # 20 is my question self.name_entry.configure(validate="key", validatecommand=vcmd) self.name_entry.pack() def maxlength_validate(self, value, maxlength): ''' function validated for maximum number of characters ''' maxlength = int(maxlength) if len(value) > maxlength: value = value[:maxlength] return (value == ' ') return True def run(): root = Tk() root.title('test') View(root) root.mainloop() if __name__ == "__main__": run() The code works well :-) but... in vcmd i use this: vcmd = (self.parent.register(self.maxlength_validate), '%P', 20) # '20' argument is my question, is not default value (is max length of char, different for each entry... very comfortable for me) is it all right, according to you, to pass a non-default argument? (no error from the interpreter) Without this way I would not know how to pass the maximum number of characters to the validation function, I can not use one variable self.--- for each entry ... it would become aesthetically unattractive. I would not even like to add a textvariable variable because anyway then I should always pass the comparison value. thank you in advance Steve From alex at lussinan.invalid Tue Jan 15 08:08:38 2019 From: alex at lussinan.invalid (Alex Ternaute) Date: 15 Jan 2019 13:08:38 GMT Subject: get the terminal's size References: <5c3db566$0$31400$426a74cc@news.free.fr> <20190115120116.GA91295@cskk.homeip.net> Message-ID: <5c3ddb56$0$20311$426a74cc@news.free.fr> Hi Cameron, >>I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE, >>universal_newlines=True) and it runs fine too, so the output seems not >>really related to that fd. > But it is! stty(1) fetches the terminal settings from its standard > input, so "fd" is used to supply this. In your Popen test case you > simply don't set the stdin parameter, so it is the Python process' > input. Which is usually what you want. > But I want to be able to ask this > of any terminal file, thus the parameter. Ah, Ok; smthlike: cs.tty.ttysize(0) WinSize(rows=50, columns=100) anotherTty=open('/dev/pts/3', 'rw') cs.tty.ttysize(anotherTty) WinSize(rows=43, columns=199) It runs :) I do not need that today but one day orother it could help. Cheers -- Alex From stefano at stalksoftINVALID.com Tue Jan 15 08:37:10 2019 From: stefano at stalksoftINVALID.com (steve) Date: Tue, 15 Jan 2019 14:37:10 +0100 Subject: [tkinter] question about correct use of validation References: <3dbcb1f3-bf0b-43ec-a75b-4f6a796859a4@googlegroups.com> Message-ID: On 15/01/2019 14:16, Rick Johnson wrote: > steve wrote: > > Then it's just a matter of passing a keyword argument: > > myEntry = MyEntry(master, maxlen=20) > > What you have above is a tightly coiled, steaming dogpile that will litter your code base. Encapsulate that stench, would ya? > sure, everything will go into a "label_entry" function It's similar to this: def __label_entry (self, frame, text_label, width_label, width_entry, maxlen): '' 'Private utility function for a couple of labels + entry. Return istance of entry itself. '' ' Label (frame, padx=10, pady=10, width=width_label, text=text_label) .Pack (side=LEFT) entry = Entry (frame, width=width_entry) entry.configure (highlightcolor='blue') entry.pack (side=LEFT) ...... return entry I wrote voluntarily in order to better understand the question From achyuta2017 at gmail.com Tue Jan 15 09:07:01 2019 From: achyuta2017 at gmail.com (achyuta2017 at gmail.com) Date: Tue, 15 Jan 2019 06:07:01 -0800 (PST) Subject: help with python difference between number Message-ID: <06d4b8a8-a471-4310-9634-e2cf9755c790@googlegroups.com> M <01/14/2019 08:07:01> Count:0 Total:50 Free: 20 A B M <01/14/2019 08:07:04> Count:1 Total:5 Free:10 A B M <01/14/2019 08:07:07> Count:2 Total:5 Free:3 A B I am trying to make a output like where it prints the free and then the difference between the current free and previous free For e.g M <01/14/2019 08:07:01> Count:0 Free: 20 M <01/14/2019 08:07:04> Count:1 Free: 10 absolute difference between time and prev time is -10 M <01/14/2019 08:07:07> Count:2 Free: 3 absolute difference between time and prev time is -7 And then later on i need to determine the time when we had the most negative free value. I tried a code like this Which printed with open("summ4.txt") as f: # get first line/number nxt = int(next(f)) for n in f: print("absolute difference between {} and {} = {}" .format(n.rstrip(), nxt, abs(int(nxt) - int(n)))) # set nxt equal to the next number nxt = int(next(f,0)) a=open('summ1.txt','r').readlines() b=open('summ3.txt','r').readlines() with open('summ.txt','w') as out: for i in range(0,365): print>>out,a[i].rstrip(),b[i] I hit error as Traceback (most recent call last): File "3.py", line 39, in .format(n.rstrip(), nxt, abs(int(nxt) - int(n)))) ValueError: zero length field name in format I guess my input file has a tab in the start and not able to get a difference rightly. . Any pointers on how to achieve the desired result? Thanks, Hare From caigy84 at gmail.com Tue Jan 15 09:13:00 2019 From: caigy84 at gmail.com (Gengyang Cai) Date: Tue, 15 Jan 2019 06:13:00 -0800 (PST) Subject: 3 random numbers In-Reply-To: <79333775-cd49-4e47-bfb6-660b64633f17@googlegroups.com> References: <6a9dcf99-cb55-4bb7-a22f-1c54480c05a3@googlegroups.com> <79333775-cd49-4e47-bfb6-660b64633f17@googlegroups.com> Message-ID: I managed to solve the problem and also another problem with different 3 random numbers. But it wasn't a very good question in the first place, i admit .... On Tuesday, January 15, 2019 at 9:55:00 PM UTC+8, Rick Johnson wrote: > Gengyang Cai wrote: > > Can anyone understand it and explain it to me please ? > > Instead of attempting to read source code that you obviously have no qualification to read, why don't you try _thinking_ like a programmer? > > "But Rick! How will i think like a programmer if i cannot even read source code?!" > > Forget about reading source code, kid! Reading source code is only a small part of being a programmer. Are you any less intelligent because you can't speak every language on the freakin' planet including Klingon, Elvish and the black tongue of the Mordor Orc? No. Of course not! You can still tie you tennis shoes, yes? Okay... Thus, programming languages are like natural language, in that they are merely a means to communicate. Tools. That's all. So, if you can become competent with a rake, then you can probably do the same with a shovel, and a hoe. All of these tools will help you build a garden. Or bury a skeleton in the backyard -- after dark, when the nosy neighbors are sleeping! > > <_< > > >_> > > "Okay Rick... i sorta understand your point here, but... i'm not having that ah-hah! moment. How do i think like a programmer?" > > Simple! You look at a problem, and then you ask yourself: "What are the fundamental steps required to solve this problem?" And sometimes scratching the head helps... > > ASSIGNMENT: "Pick any 3 random ascending numbers and write out a loop function that prints out all 3 numbers""" > > Looking at this sentence, i see two specific problems: > > > > So, in the case of your assignment, the first step would be to pick three numbers. > > STEP_1. Pick three numbers. > > numbers = [400, 467, 851] From neilc at norwich.edu Tue Jan 15 10:04:51 2019 From: neilc at norwich.edu (Neil Cerutti) Date: 15 Jan 2019 15:04:51 GMT Subject: Python read text file columnwise References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Message-ID: On 2019-01-11, shibashibani at gmail.com wrote: > Hello >> >> I'm very new in python. I have a file in the format: >> >> 2018-05-31 16:00:00 28.90 81.77 4.3 >> 2018-05-31 20:32:00 28.17 84.89 4.1 >> 2018-06-20 04:09:00 27.36 88.01 4.8 >> 2018-06-20 04:15:00 27.31 87.09 4.7 >> 2018-06-28 04.07:00 27.87 84.91 5.0 >> 2018-06-29 00.42:00 32.20 104.61 4.8 > > I would like to read this file in python column-wise. > > I tried this way but not working .... > event_list = open('seismicity_R023E.txt',"r") > info_event = read(event_list,'%s %s %f %f %f %f\n'); If it's really tabular data in fixed-width columns you can read it that way with Python. records = [] for line in file: record = [] i = 0 for width in (30, 8, 7, 5): # approximations item = line[i:i+width] record.append(item) i += width records.append(record) This leaves them all strings, which in my experience is more convenient in practice. You can convert as you go if you want,though it won't look nice and simple any longer. -- Neil Cerutti From dev_20192019 at outlook.com Tue Jan 15 10:43:20 2019 From: dev_20192019 at outlook.com (Juris __) Date: Tue, 15 Jan 2019 15:43:20 +0000 Subject: Python read text file columnwise In-Reply-To: References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Message-ID: Hi! On 15/01/2019 17:04, Neil Cerutti wrote: > On 2019-01-11, shibashibani at gmail.com wrote: >> Hello >>> >>> I'm very new in python. I have a file in the format: >>> >>> 2018-05-31 16:00:00 28.90 81.77 4.3 >>> 2018-05-31 20:32:00 28.17 84.89 4.1 >>> 2018-06-20 04:09:00 27.36 88.01 4.8 >>> 2018-06-20 04:15:00 27.31 87.09 4.7 >>> 2018-06-28 04.07:00 27.87 84.91 5.0 >>> 2018-06-29 00.42:00 32.20 104.61 4.8 >> >> I would like to read this file in python column-wise. >> >> I tried this way but not working .... >> event_list = open('seismicity_R023E.txt',"r") >> info_event = read(event_list,'%s %s %f %f %f %f\n'); > > If it's really tabular data in fixed-width columns you can read > it that way with Python. > > records = [] > for line in file: > record = [] > i = 0 > for width in (30, 8, 7, 5): # approximations > item = line[i:i+width] > record.append(item) > i += width > records.append(record) > > This leaves them all strings, which in my experience is more > convenient in practice. You can convert as you go if you > want,though it won't look nice and simple any longer. > Perhaps even better approach is to use csv module from standard library: import csv csv_reader = csv.reader(file, dialect="excel-tab") for row in csv_reader: # do something with record data which is conveniently parsed to list print(row) ['2018-05-31', '16:00:00', '28.90', '81.77', '4.3'] ... ['2018-06-29', '00.42:00', '32.20', '104.61', '4.8'] BR, Juris From neilc at norwich.edu Tue Jan 15 10:45:22 2019 From: neilc at norwich.edu (Neil Cerutti) Date: 15 Jan 2019 15:45:22 GMT Subject: Python read text file columnwise References: <4b30e7a5-5c87-4014-828e-2f96adf4fad6@googlegroups.com> <78060832-1081-4663-9b34-7757cbfac99e@googlegroups.com> Message-ID: On 2019-01-15, Juris __ wrote: > Hi! > > On 15/01/2019 17:04, Neil Cerutti wrote: >> On 2019-01-11, shibashibani at gmail.com wrote: >>> Hello >>>> >>>> I'm very new in python. I have a file in the format: >>>> >>>> 2018-05-31 16:00:00 28.90 81.77 4.3 >>>> 2018-05-31 20:32:00 28.17 84.89 4.1 >>>> 2018-06-20 04:09:00 27.36 88.01 4.8 >>>> 2018-06-20 04:15:00 27.31 87.09 4.7 >>>> 2018-06-28 04.07:00 27.87 84.91 5.0 >>>> 2018-06-29 00.42:00 32.20 104.61 4.8 >>> >>> I would like to read this file in python column-wise. >>> >>> I tried this way but not working .... >>> event_list = open('seismicity_R023E.txt',"r") >>> info_event = read(event_list,'%s %s %f %f %f %f\n'); >> >> If it's really tabular data in fixed-width columns you can read >> it that way with Python. >> >> records = [] >> for line in file: >> record = [] >> i = 0 >> for width in (30, 8, 7, 5): # approximations >> item = line[i:i+width] >> record.append(item) >> i += width >> records.append(record) >> >> This leaves them all strings, which in my experience is more >> convenient in practice. You can convert as you go if you >> want,though it won't look nice and simple any longer. >> > > Perhaps even better approach is to use csv module from standard library: > > import csv > > csv_reader = csv.reader(file, dialect="excel-tab") > for row in csv_reader: > # do something with record data which is conveniently parsed to list > print(row) > > ['2018-05-31', '16:00:00', '28.90', '81.77', '4.3'] > ... > ['2018-06-29', '00.42:00', '32.20', '104.61', '4.8'] Yes, if applicable it is awesome! -- Neil Cerutti From alister.ware at ntlworld.com Tue Jan 15 12:07:37 2019 From: alister.ware at ntlworld.com (Alister) Date: Tue, 15 Jan 2019 17:07:37 GMT Subject: 3 random numbers References: <6a9dcf99-cb55-4bb7-a22f-1c54480c05a3@googlegroups.com> <79333775-cd49-4e47-bfb6-660b64633f17@googlegroups.com> Message-ID: On Tue, 15 Jan 2019 06:13:00 -0800, Gengyang Cai wrote: > I managed to solve the problem and also another problem with different 3 > random numbers. But it wasn't a very good question in the first place, i > admit .... > > Indeed it is a poorly write exercise & I suspect it has been misinterpreted. unless i am very much mistaken the tutor expects the program to pick the 3 random numbers each time it is run, not the programmer -- We've picked COBOL as the language of choice. From anthony.flury at btinternet.com Tue Jan 15 12:17:30 2019 From: anthony.flury at btinternet.com (Anthony Flury) Date: Tue, 15 Jan 2019 17:17:30 +0000 Subject: Encounter issues to install Python In-Reply-To: <648909725.21498006.1546788008045@mail.yahoo.com> References: <1715165778.8897506.1539026476320.ref@mail.yahoo.com> <1715165778.8897506.1539026476320@mail.yahoo.com> <648909725.21498006.1546788008045@mail.yahoo.com> Message-ID: <39085bdd-87ca-974a-e0f7-d102eae4c8e3@btinternet.com> What error are you getting ? 'Can not install the software' isn't enough information for me to assist in detail In the mean time - things to check : * Does your user have permission to install to the directory you are trying to install to ? * Does the disk have enough disk space to install Python ? * have you actually got a 32 bit windows installation - many modern PCs are actually 64 bit now. On 06/01/2019 15:20, Olivier Oussou wrote: > Hi dear Anthony, > I am using Windows systeme. I have download the set up uf python 3.6.4 > (32-bit) and I can not install the software on my computer. > I need your technical assistance to solve this matter and I will be > glad if you do so. > Best regard! > Olivier > Medical entomologist, Benin > > > > Le samedi 13 octobre 2018 ? 19:24:28 UTC+2, Anthony Flury > a ?crit : > > > Olivier, > > Welcome to the list - before we can help you, we need some more > information : > > * What Operating system are you using - Windows/Mac/Linux/Raspberry > Pi/Android for something else ? > * What command or installer did you use to try to install Python. > * What issues did you have during installation - if any ? > * What interface are you trying to access, and how are you doing that ? > * Do you get error messages? > > Unless you tell us what the problem is we can't possibly help. > > On 08/10/18 20:21, Olivier Oussou via Python-list wrote: >> Hi!I downloaded and installed python 3.6.4 (32-bit) on my computer but I have problems and can not access the python interface. >> I need your technical assistance to solve this matter. >> >> Best regard! >> >> Olivier OUSSOUMedical entomologist, Benin > > -- > Anthony Flury > *Email* : anthony.flury at btinternet.com > > *Twitter* : @TonyFlury -- Anthony Flury *Email* : anthony.flury at btinternet.com *Twitter* : @TonyFlury From duncan at invalid.invalid Tue Jan 15 12:34:04 2019 From: duncan at invalid.invalid (duncan smith) Date: Tue, 15 Jan 2019 17:34:04 +0000 Subject: sampling from frequency distribution / histogram without replacement In-Reply-To: References: <_Z9%D.62653$n85.12814@fx38.iad> <6c2f6541-ce5a-b2cc-dd9a-1cb45741be6d@effectivedefense.org> Message-ID: On 15/01/2019 02:41, Spencer Graves wrote: > > > On 2019-01-14 18:40, duncan smith wrote: >> On 14/01/2019 22:59, Gregory Ewing wrote: >>> duncan smith wrote: >>>> Hello, >>>> ?????? Just checking to see if anyone has attacked this problem before >>>> for cases where the population size is unfeasibly large. >>> The fastest way I know of is to create a list of cumulative >>> frequencies, then generate uniformly distributed numbers and >>> use a binary search to find where they fall in the list. >>> That's O(log n) per sample in the size of the list once it's >>> been set up. >>> >> That's the sort of thing I've been thinking about. But once I'd found >> the relevant category I'd need to reduce its frequency by 1 and >> correspondingly update the cumulative frequencies. Alternatively, I >> could add an extra step where I selected a unit from the relevant >> category with probability equal to the proportion of non-sampled units >> from the category. I could maybe set up an alias table and do something >> similar. >> >> The other thing I was thinking about was iterating through the >> categories (ideally from largest frequency to smallest frequency), >> generating the numbers to be sampled from the current category and the >> remaining categories (using numpy.random.hypergeometric). With a few >> large frequencies and lots of small frequencies that could be quite >> quick (on average). Alternatively I could partition the categories into >> two sets, generate the number to be sampled from each partition, then >> partition the partitions etc. binary search style. >> >> I suppose I'll try the both the alias table + rejection step and the >> recursive partitioning approach and see how they turn out. Cheers. > > > ????? R has functions "sample" and "sample.int";? see > "https://www.rdocumentation.org/packages/base/versions/3.5.2/topics/sample". > You can call R from Python, > "https://sites.google.com/site/aslugsguidetopython/data-analysis/pandas/calling-r-from-python". > > > > ????? These are in the "base" package.? I believe they have been an > important part of the base R language almost since its inception and > have been used extensively.? You'd have to work really hard to do > better, in my judgment. > > > ??? ? Spencer Graves > > > DISCLAIMER:? I'm primarily an R guy and only use Python when I can't > find a sensible way to do what I want in R. >> >> Duncan > Despite being a statistician I'm primarily a Python guy and only use R when I can't find a sensible way to do what I want in Python :-). The problem with the R solution is that it doesn't seem to get round the issue of having an unfeasibly large population size, but a reasonable number of categories. It turns out I've already coded up a few reservoir based algorithms for sampling without replacement that work with data streams. So I can get round the space issues, but it still means processing each data point rather than generating the sample frequencies directly. After much searching all I've been able to find is the approach I suggested above, iterating through the frequencies. My implementation: import numpy def hypgeom_variate(freqs, n): sample = [0] * len(freqs) nbad = sum(freqs) hypergeometric = numpy.random.hypergeometric for i, ngood in enumerate(freqs): nbad -= ngood x = hypergeometric(ngood, nbad, n, 1)[0] if x: sample[i] = x n -= x if not n: break return sample Duncan From hobson42 at gmail.com Tue Jan 15 12:59:32 2019 From: hobson42 at gmail.com (Ian Hobson) Date: Tue, 15 Jan 2019 17:59:32 +0000 Subject: sampling from frequency distribution / histogram without replacement In-Reply-To: References: Message-ID: Hi, If I understand your problem you can do it in two passes through the population. First, however, lets work through taking a sample of 2 from 7 to demonstrate the method. Take the first element with a probability of 2/7. (Note 1). If you took it, you only want 1 more, so the probability drops to 1/6. If you didn't take it you want 2 from 6, so probability goes to 2/6. Take the next in the population with probability 1/6 or 2/6 as appropriate. Continue in similar manner until the probability drops to 0 (when you have your whole sample). When the denominator drops to zero the population is expired. Your first pass has to categorise the population and create your histogram, (index N) of frequencies Y(N). Then divide up the sample size you wish to take into the histogram, giving array X(N) of sample sizes. X(N) need not be integer. Then pass through the population again, for each entry: Compute the N it falls in the histogram. Take this entry as a sample with a probability of X(N)/Y(N). Note 2. If the element was taken, decrement X(N). Decrement Y(N). step to next element. Note 1 - In most languages you can generate a pseudo-random number with a uniform distribution from 0 to Y(N)-1. Take the element if it is in range 0 to floor(X(N))-1. Note 2 - X(N) need not be integer, but you can't actually take a sample of 6.5 out of 1000. You will either run out of population having taken 6, or, if you take 7, the probability will go negative, and no more should be taken (treat as zero). The number taken in slot N will be floor(X(N)) or ceiling(X(N)). The average over many tries will however be X(N). Sorry I did not come back to you sooner. It took a while to drag the method out of my memory from some 35 years ago when I was working on an audit package. That was where I learned two things you may be interested in. 1) Auditors significantly under sample. Our Auditors actually took samples that were between 10% and 25% of what was necessary to support their claims. 2) Very very few standard pseudo-random number generators are actually any good. Regards Ian On 14/01/2019 20:11, duncan smith wrote: > Hello, > Just checking to see if anyone has attacked this problem before > for cases where the population size is unfeasibly large. i.e. The number > of categories is manageable, but the sum of the frequencies, N, > precludes simple solutions such as creating a list, shuffling it and > using the first n items to populate the sample (frequency distribution / > histogram). > > I note that numpy.random.hypergeometric will allow me to generate a > sample when I only have two categories, and that I could probably > implement some kind of iterative / partitioning approach calling this > repeatedly. But before I do I thought I'd ask if anyone has tackled this > before. Can't find much on the web. Cheers. > > Duncan > -- Ian Hobson Tel (+351) 910 418 473 From python at mrabarnett.plus.com Tue Jan 15 13:02:21 2019 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 15 Jan 2019 18:02:21 +0000 Subject: help with python difference between number In-Reply-To: <06d4b8a8-a471-4310-9634-e2cf9755c790@googlegroups.com> References: <06d4b8a8-a471-4310-9634-e2cf9755c790@googlegroups.com> Message-ID: On 2019-01-15 14:07, achyuta2017 at gmail.com wrote: > > M <01/14/2019 08:07:01> Count:0 > Total:50 > Free: 20 > A > B > M <01/14/2019 08:07:04> Count:1 > Total:5 > Free:10 > A > B > M <01/14/2019 08:07:07> Count:2 > Total:5 > Free:3 > A > B > > > I am trying to make a output like where it prints the free and then the difference between the current free and previous free > For e.g > > M <01/14/2019 08:07:01> Count:0 Free: 20 > M <01/14/2019 08:07:04> Count:1 Free: 10 absolute difference between time and prev time is -10 > M <01/14/2019 08:07:07> Count:2 Free: 3 absolute difference between time and prev time is -7 > > > And then later on i need to determine the time when we had the most negative free value. > > > I tried a code like this > Which printed > with open("summ4.txt") as f: > # get first line/number > nxt = int(next(f)) > for n in f: > print("absolute difference between {} and {} = {}" > .format(n.rstrip(), nxt, abs(int(nxt) - int(n)))) > # set nxt equal to the next number > nxt = int(next(f,0)) > a=open('summ1.txt','r').readlines() > b=open('summ3.txt','r').readlines() > with open('summ.txt','w') as out: > for i in range(0,365): > print>>out,a[i].rstrip(),b[i] > > > I hit error as > Traceback (most recent call last): > File "3.py", line 39, in > .format(n.rstrip(), nxt, abs(int(nxt) - int(n)))) > ValueError: zero length field name in format > > I guess my input file has a tab in the start and not able to get a difference rightly. > . > Any pointers on how to achieve the desired result? > You didn't say Which version of Python you're using. The "print>>" tells me that it's Python 2. It's complaining about the '{}' in the format string. Format strings were introduced in Python 2.6 and auto-numbering ('{}' allowed instead of '{0}') was introduced in Python 2.7. As it's complaining about a missing field name in '{}', it must be Python 2.6, which is ancient! And Python 2.7 reaches its end of life soon. You should switch to Python 3 unless you have a very good reason for staying on Python 2, and, if you must use Python 2, use Python 2.7. From cs at cskk.id.au Tue Jan 15 16:52:36 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 16 Jan 2019 08:52:36 +1100 Subject: get the terminal's size In-Reply-To: <5c3ddb56$0$20311$426a74cc@news.free.fr> References: <5c3ddb56$0$20311$426a74cc@news.free.fr> Message-ID: <20190115215236.GA89772@cskk.homeip.net> On 15Jan2019 13:08, Alex Ternaute wrote: >>>I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE, >>>universal_newlines=True) and it runs fine too, so the output seems not >>>really related to that fd. > >> But it is! stty(1) fetches the terminal settings from its standard >> input, so "fd" is used to supply this. In your Popen test case you >> simply don't set the stdin parameter, so it is the Python process' >> input. Which is usually what you want. > >> But I want to be able to ask this >> of any terminal file, thus the parameter. > >Ah, Ok; smthlike: > cs.tty.ttysize(0) > WinSize(rows=50, columns=100) > anotherTty=open('/dev/pts/3', 'rw') > cs.tty.ttysize(anotherTty) > WinSize(rows=43, columns=199) > >It runs :) Exactly so. BTW, you're aware of: from cs.tty import ttysize ... ttysize(0) I presume, and the above is just your testing? Cheers, Cameron Simpson From duncan at invalid.invalid Tue Jan 15 21:12:58 2019 From: duncan at invalid.invalid (duncan smith) Date: Wed, 16 Jan 2019 02:12:58 +0000 Subject: sampling from frequency distribution / histogram without replacement In-Reply-To: References: Message-ID: On 15/01/2019 17:59, Ian Hobson wrote: > Hi, > > If I understand your problem you can do it in two passes through the > population. > The thing is that I start with the population histogram and I want to generate a sample histogram. The population itself is too large to deal with each population member individually. > First, however, lets work through taking a sample of 2 from 7 to > demonstrate the method. > > Take the first element with a probability of 2/7. (Note 1). > If you took it, you only want 1 more, so the probability drops to 1/6. > If you didn't take it you want 2 from 6, so probability goes to 2/6. > Take the next in the population with probability 1/6 or 2/6 as appropriate. > Continue in similar manner until the probability > drops to 0 (when you have your whole sample). When the > denominator drops to zero the population is expired. > Yes, based on the chain rule. > Your first pass has to categorise the population and create your > histogram, (index N) of frequencies Y(N). > > Then divide up the sample size you wish to take into the histogram, > giving array X(N) of sample sizes. X(N) need not be integer. > > Then pass through the population again, for each entry: > ?? Compute the N it falls in the histogram. > ?? Take this entry as a sample with a probability of X(N)/Y(N).? Note 2. > ?? If the element was taken, decrement X(N). > ?? Decrement Y(N). > ?? step to next element. > Ah, I'm not quota sampling. I want a simple random sample without replacement. I just happen to have the data in the form of categories and frequencies, and that's the form of output that I want. > Note 1 - In most languages you can generate a pseudo-random number > with a uniform distribution from 0 to Y(N)-1. Take the element if it is > in range 0 to floor(X(N))-1. > > Note 2 - X(N) need not be integer, but you can't actually take a sample > of 6.5 out of 1000. You will either run out of population having taken > 6, or, if you take 7, the probability will go negative, and no more > should be taken (treat as zero). The number taken in slot N will be > floor(X(N)) or ceiling(X(N)). The average over many tries will however > be X(N). > Sorry I did not come back to you sooner. It took a while to drag the > method out of my memory from some 35 years ago when I was working on an > audit package. Well I'd already forgotten that I'd coded up something for srs without replacement only a few years ago. In fact I coded up a few algorithms (that I can't take credit for) that allowed weighted sampling with replacement, and at least one that didn't require a priori knowledge of the population size (a single pass algorithm). The problem is that they also (mostly) require scanning the whole population. That was where I learned two things you may be interested > in. > 1) Auditors significantly under sample. Our Auditors actually took > samples that were between 10% and 25% of what was necessary to support > their claims. > It's not just auditors :-(. The journals are full of claims based on positive results from low powered tests or from "null fields". i.e. A very high proportion are likely to be false positives (like 99% when it comes to foodstuffs and the risks of various diseases). A while ago a mate of mine (Prof. of statistics in Oz) told me about a student who engineered a statistically significant result by copying and pasting her data to double her sample size. That's no worse than some of the stuff I've come across in the (usually medical) journals. > 2) Very very few standard pseudo-random number generators are actually > any good. > > Regards > > Ian [snip] BTW, the approach I'm currently using is also based on the chain rule. Generate the number of sample units for the first category by sampling from a (bivariate) hypergeometric. The number of sample units for the second category (conditional on the number sampled for the first) is another hypergeometric. Iterate until the full sample is obtained. It helps to order the categories from largest to smallest. But I think I'll get better performance by recursive partitioning (when I have the time to try it). Cheers. Duncan From klsshaeffer at gmail.com Tue Jan 15 23:37:39 2019 From: klsshaeffer at gmail.com (Karen Shaeffer) Date: Tue, 15 Jan 2019 20:37:39 -0800 Subject: get the terminal's size Message-ID: That will tell you the terminal size at the time Python was started. If the terminal size has changed while Python was running, those environment variables will be wrong. You need to use the TIOCGWINSZ ioctl call: http://www.delorie.com/djgpp/doc/libc/libc_495.html And to detect the size changes (so you know _when_ you need to do the above), you need to attach a signal handler for the WINCH signal. Hi, I'm running a python 3 interpreter on linux. I'm actually ssh'd into the terminal on a headless server. And so my terminal is my local laptop terminal window, with the python interpreter running on the remote linux box terminal, communicating over an ssh connection. $ python3 Python 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import shutil >>> print(f"{shutil.get_terminal_size()}\n") os.terminal_size(columns=118, lines=63) >>> print(f"{shutil.get_terminal_size()}\n") os.terminal_size(columns=133, lines=63) >>> print(f"{shutil.get_terminal_size()}\n") os.terminal_size(columns=118, lines=65) >>> print(f"{shutil.get_terminal_size()}\n") os.terminal_size(columns=118, lines=63) With the python interpreter running on the remote terminal, I have resized the terminal window on my local laptop several times. And each time, the remote python interpreter knows about the change, correctly printing the new size. I have done nothing with environment variables. I have not used a signal handler for the WINCH signal. It just works. Karen. From dieter at handshake.de Wed Jan 16 02:06:57 2019 From: dieter at handshake.de (dieter) Date: Wed, 16 Jan 2019 08:06:57 +0100 Subject: python package management confusion References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> Message-ID: <87imypqdwu.fsf@handshake.de> dcs3spp via Python-list writes: > ... > So to manage the development of private packages, e.g. wheels, I would have to use my own private repository (something like devpi or a an alternative cloud pypi subscription service) to store each private dependency that I have written. No, you do not need something like "devpi" (or similar). Instead, you can set up a "virtualenv" (there is a Python package which can build "virtualenv"s), and use "setuptool"'s "develop" "setup" command to "install" links to the package sources you currently have under development. "develop" will automatically install external requirements via "pypi". > ... > However, if I wanted to take a step further and run a CI build using cloud services(e.g. in a private gitlab.com repository) for a package that uses the private packages, then presumably there is no access to the devpi repository on my local system? So, alternatively when developing private Python packages I either use requirements.txt or pay subscription for a private pypi cloud repository and configure pip, setup.cfg on gitlab.com CI to reference it in config files. When the CI build completes it pushes the package to the private pypi repository. I assume that you will be able to build an appropriate "virtualenv" in a CI build setup. From __peter__ at web.de Wed Jan 16 03:51:40 2019 From: __peter__ at web.de (Peter Otten) Date: Wed, 16 Jan 2019 09:51:40 +0100 Subject: [tkinter] question about correct use of validation References: Message-ID: steve wrote: > for determine the maximum number of characters in an entry > > I have read several interpretations for the solution of the problem, but > I wanted to find an alternative way (for convenience of the code) > > I kindly ask for an opinion on the use of validation in this way. > > ----- > > problem: limit number of characters in different entries of a form. > > code: > > #!/usr/bin/python > # -*- coding: utf-8 -* > > from Tkinter import * > > > class View(): > > def __init__(self, parent): > self.parent = parent > self.make_ui() > > def make_ui(self): > ''' create user interface ''' > self.id_entry = Entry(self.parent, width=6) > # take out the properties for understanding > > vcmd = (self.parent.register(self.maxlength_validate), '%P', 4) > # 4 is my question > > self.id_entry.configure(validate="key", validatecommand=vcmd) > self.id_entry.pack() > > self.name_entry = Entry(self.parent, width=30) > # take out the properties for understanding > > vcmd = (self.parent.register(self.maxlength_validate), '%P', 20) > # 20 is my question > > self.name_entry.configure(validate="key", validatecommand=vcmd) > self.name_entry.pack() > > def maxlength_validate(self, value, maxlength): > ''' function validated for maximum number of characters ''' > maxlength = int(maxlength) > if len(value) > maxlength: > value = value[:maxlength] > return (value == ' ') > return True > > > def run(): > root = Tk() > root.title('test') > View(root) > root.mainloop() > > if __name__ == "__main__": > run() > > The code works well :-) but... > > in vcmd i use this: > > vcmd = (self.parent.register(self.maxlength_validate), '%P', 20) > # '20' argument is my question, is not default value (is max length of > char, different for each entry... very comfortable for me) > > is it all right, according to you, to pass a non-default argument? (no > error from the interpreter) > > Without this way I would not know how to pass the maximum number of > characters to the validation function, I can not use one variable > self.--- for each entry ... it would become aesthetically unattractive. > > I would not even like to add a textvariable variable because anyway then > > I should always pass the comparison value. > > thank you in advance A viable alternative may be to use functools.partial() to pass the maxlength: from Tkinter import * from functools import partial class View(): def __init__(self, parent): self.parent = parent self.make_ui() def make_ui(self): ''' create user interface ''' def vcmd(maxlength): return self.parent.register( partial(self.maxlength_validate, maxlength=maxlength) ), "%P" self.id_entry = Entry(self.parent, width=6) # take out the properties for understanding self.id_entry.configure(validate="key", validatecommand=vcmd(4)) self.id_entry.pack() self.name_entry = Entry(self.parent, width=30) # take out the properties for understanding self.name_entry.configure(validate="key", validatecommand=vcmd(20)) self.name_entry.pack() def maxlength_validate(self, value, maxlength): return len(value) <= maxlength From arj.python at gmail.com Wed Jan 16 04:06:54 2019 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 16 Jan 2019 13:06:54 +0400 Subject: Email blast management? In-Reply-To: <004001d4ac53$ecb70f30$c6252d90$@verizon.net> References: <004001d4ac53$ecb70f30$c6252d90$@verizon.net> Message-ID: unless there's a solid python solution out there ready to plug in Abdur-Rahmaan Janhangeer http://www.pythonmembers.club Mauritius From simonppears at googlemail.com Wed Jan 16 04:18:18 2019 From: simonppears at googlemail.com (dcs3spp) Date: Wed, 16 Jan 2019 01:18:18 -0800 (PST) Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> Message-ID: <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> On Wednesday, 16 January 2019 07:07:29 UTC, dieter wrote: > dcs3spp via Python-list writes: > > ... > > So to manage the development of private packages, e.g. wheels, I would have to use my own private repository (something like devpi or a an alternative cloud pypi subscription service) to store each private dependency that I have written. > > No, you do not need something like "devpi" (or similar). > Instead, you can set up a "virtualenv" (there is a Python package > which can build "virtualenv"s), and use "setuptool"'s "develop" > "setup" command to "install" links to the package sources you > currently have under development. "develop" will automatically > install external requirements via "pypi". > > > ... > > However, if I wanted to take a step further and run a CI build using cloud services(e.g. in a private gitlab.com repository) for a package that uses the private packages, then presumably there is no access to the devpi repository on my local system? So, alternatively when developing private Python packages I either use requirements.txt or pay subscription for a private pypi cloud repository and configure pip, setup.cfg on gitlab.com CI to reference it in config files. When the CI build completes it pushes the package to the private pypi repository. > > I assume that you will be able to build an appropriate "virtualenv" > in a CI build setup. Thankyou for responding and thanks for your patience with this newbie dieter.... Ahhhh, so it is possible to use a virtualenv to pull in dependencies from setup.py .... I have the setup.py below and the pyramid_core package surrounded by * in the requires list has own setup.py and virtual environment. I currently have pip.conf and setup.cfg etc. setup to pull this dependency from devpi repository. How do I configure python setup.py develop to pull the pyramid_core dependent packages using virtualenv? *************** setup.py ****************** import os import sys from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(here, 'README.md')) as f: README = f.read() with open(os.path.join(here, 'CHANGES.md')) as f: CHANGES = f.read() requires = [ 'cryptography', 'odfpy', 'PyJWT', 'pycrypto', 'pyramid', ***** 'pyramid_core', ******* requirements.txt file? 'pyramid_debugtoolbar', 'pyramid_tm', 'requests==2.18.4', 'SQLAlchemy', 'transaction', 'zope.sqlalchemy', 'waitress', 'psycopg2-binary', 'python-dateutil', 'uwsgi', 'marshmallow-sqlalchemy', ] setup_requires = [ 'pytest-runner', ] tests_require = [ 'boto3', 'lovely-pytest-docker', 'pytest', 'pytest-cov', 'tuspy', 'WebTest >= 1.3.1', ] setup(name='api', version='0.0', description='api', long_description=README + '\n\n' + CHANGES, classifiers=[ "Programming Language :: Python", "Framework :: Pyramid", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", ], author='simon pears', author_email='roughlea-music at outlook.com', url='', keywords='web wsgi bfg pylons pyramid', packages=find_packages('src'), package_dir={'': 'src'}, include_package_data=True, zip_safe=False, extras_require={ 'testing': tests_require, }, install_requires=requires, setup_requires=setup_requires, tests_require=tests_require, test_suite='tests', entry_points="""\ [paste.app_factory] main = api:main [console_scripts] initialize_api_db = api.scripts.initializedb:main """, ) From grant.b.edwards at gmail.com Wed Jan 16 10:45:56 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 16 Jan 2019 15:45:56 +0000 (UTC) Subject: get the terminal's size References: Message-ID: On 2019-01-16, Karen Shaeffer wrote: [fixed quoting and formatting] >> That will tell you the terminal size at the time Python was started. >> >> If the terminal size has changed while Python was running, those >> environment variables will be wrong. You need to use the TIOCGWINSZ >> ioctl call: >> >> http://www.delorie.com/djgpp/doc/libc/libc_495.html >> >> And to detect the size changes (so you know _when_ you need to do the >> above), you need to attach a signal handler for the WINCH signal. > > I'm running a python 3 interpreter on linux. I'm actually ssh'd into > the terminal on a headless server. [...] > [...] > With the python interpreter running on the remote terminal, I have > resized the terminal window on my local laptop several times. And > each time, the remote python interpreter knows about the change, > correctly printing the new size. I have done nothing with > environment variables. I have not used a signal handler for the > WINCH signal. It just works. Yes, we know that works on Python3. The discussion was about what to do on Python2. $ python2 Python 2.7.15 (default, Sep 12 2018, 15:19:18) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import shutil >>> shutil.get_terminal_size() Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'get_terminal_size' >>> -- Grant Edwards grant.b.edwards Yow! I'm having a BIG BANG at THEORY!! gmail.com From ganwell at fangorn.ch Wed Jan 16 07:13:44 2019 From: ganwell at fangorn.ch (Jean-Louis Fuchs) Date: Wed, 16 Jan 2019 07:13:44 -0500 Subject: ANN: libchirp (Message-passing for everyone) Message-ID: <41e38c5c-52f8-43aa-884a-3a66b92ab7f9@www.fastmail.com> ==================== Announcing libchirp ==================== Message-passing for everyone. I proudly announce libchirp [0]. I believe queues, message-routers and patterns like pub-sub are the way message-passing should be done. However, I also believe they should be optional and tweak-able. libchirp does only one thing: message-passing with encryption. All other building-blocks should be implemented in upper-layer modules or daemons. libchirp is the basis for modular message-passing and actor-based programming. I want to thank Adfinis-SyGroup [1] who have supported me and allowed me to develop libchirp. [0] https://github.com/concretecloud/python-chirp [1] https://adfinis-sygroup.ch/ Here the mandatory echo-server example: import asyncio from libchirp.asyncio import Chirp, Config, Loop class EchoChirp(Chirp): async def handler(self, msg): await self.send(msg) loop = Loop(); config = Config() config.DISABLE_ENCRYPTION = True # Workers are usually asynchronous config.SYNCHRONOUS = False aio_loop = asyncio.get_event_loop() try: chirp = EchoChirp(loop, config, aio_loop) try: aio_loop.run_forever() finally: chirp.stop() finally: loop.stop() There is also a ThreadPoolExecutor- [2] and a Queue-based [3] interface. By the way libchirp for python are bindings to my C99-implementation [4]. My secondary goal is to build a polyglot message-passing toolkit. Please be welcome to contribute bindings for your favorite language. [2] https://docs.adfinis-sygroup.ch/public/python-chirp/pool.html [3] https://docs.adfinis-sygroup.ch/public/python-chirp/queue.html [4] https://github.com/concretecloud/chirp Project links * python-chirp: https://github.com/concretecloud/python-chirp * C99-chirp: https://github.com/concretecloud/chirp * Other chirp related software: https://github.com/concretecloud Best, Jean-Louis Fuchs From avigross at verizon.net Wed Jan 16 13:46:29 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 16 Jan 2019 13:46:29 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> Message-ID: <00a101d4adcb$cb457480$61d05d80$@verizon.net> [HUMOR for the ALERT] The question that seems to come up too often about the python name is a distraction. In particular, it is answered fairly prominently in many places as just being a nonsensical name because a founder once liked a comedic entity that chose an oddball name, so they did too. But as languages develop and evolve, sometimes a name change may be a decent idea. Perhaps version 4.0 should be renamed Guido so we can get more silly questions. There once was a trend to name languages after alphabetic symbols like C and R. I shudder to think of the possibilities opened up as python embraced Unicode and we now can select from many thousands of such singletons, most of which nobody knows how to pronounce. Imagine people developing languages like X and Y and over the years enhancing them. An Enhanced or Extended X, naturally, might be renamed EX. With further Super new features (think super-symmetry in Physics) we would have a Super Extended X, or SEX in brief. Naturally, there may be a tendency to suggest that Y has some really neat features and perhaps you should extend X in the direction of Y in a sort of merger you might call SEXY. OK, enough kidding around. But realistically, as I study the history of Python including not just new features but deprecating and even removing old features, and sometimes doing major rewrites of internal implementations and adding brand new methods and ideas and endless modules and so on, I wonder if my analogy is stretchable. Python may have begun as a snake of sorts able to do a simple form of locomotion but over the years, it seems to have re-grown 4 legs to be more like other reptiles and perhaps become like some ancient dinosaurs and then kept changing as it started to walk on hind legs and then the front legs morphed into wings so that modern python is not limited to low-lying ground movement but can run and swim and even fly and is now more of a bird. Given my current name, dare I say it seems sort of AVIan? Nah! From avigross at verizon.net Wed Jan 16 14:02:39 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 16 Jan 2019 14:02:39 -0500 Subject: Pythonic Y2K Message-ID: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> I see messages like the following where someone is still asking how to do something in some version of python 2.X. I recall the days before the year 2000 with the Y2K scare when people worried that legacy software might stop working or do horrible things once the clock turned. It may even have been scary enough for some companies to rewrite key applications and even switch from languages like COBOL. What is happening in the python community, and especially in places where broken software may be a serious problem? I assume versions of python 2.X will continue to be available for some time but without any further support and without features being back-ported. Conversion of some features seems simple enough but as I have been studying, I keep running into many areas where the pythons differ and often in subtle ways that many may not know to change. I won't go into detail, but fixing the print statement to become the print function is far from enough. Some things can be made to work in the last versions of 2.7 where the back-porting allows a smoother transition. So, is there info out there on what may be problem areas? Are there modules, for example, that have not been ported and are not available for 3.X and don't have some similar enough other module that might be used? This is not just a python problem, of course. PERL is an example where there seem to be a new and incompatible old version running around. As a note, I am not complaining that python has evolved in incompatible ways. Not easy to avoid unless you like stasis. But if enough people keep avoiding the hints and outright warnings to get more up-to-date, this Y2-->3K event may be a problem. -----Original Message----- From: Python-list On Behalf Of Grant Edwards Sent: Wednesday, January 16, 2019 10:46 AM To: python-list at python.org Subject: Re: get the terminal's size On 2019-01-16, Karen Shaeffer wrote: [fixed quoting and formatting] >> That will tell you the terminal size at the time Python was started. >> >> If the terminal size has changed while Python was running, those >> environment variables will be wrong. You need to use the TIOCGWINSZ >> ioctl call: >> >> http://www.delorie.com/djgpp/doc/libc/libc_495.html >> >> And to detect the size changes (so you know _when_ you need to do the >> above), you need to attach a signal handler for the WINCH signal. > > I'm running a python 3 interpreter on linux. I'm actually ssh'd into > the terminal on a headless server. [...] [...] With the python > interpreter running on the remote terminal, I have resized the > terminal window on my local laptop several times. And each time, the > remote python interpreter knows about the change, correctly printing > the new size. I have done nothing with environment variables. I have > not used a signal handler for the WINCH signal. It just works. Yes, we know that works on Python3. The discussion was about what to do on Python2. $ python2 Python 2.7.15 (default, Sep 12 2018, 15:19:18) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import shutil >>> shutil.get_terminal_size() Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'get_terminal_size' >>> -- Grant Edwards grant.b.edwards Yow! I'm having a BIG BANG at THEORY!! gmail.com -- https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Wed Jan 16 14:14:36 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jan 2019 06:14:36 +1100 Subject: Pythonic Y2K In-Reply-To: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> Message-ID: On Thu, Jan 17, 2019 at 6:04 AM Avi Gross wrote: > > I see messages like the following where someone is still asking how to do > something in some version of python 2.X. > > I recall the days before the year 2000 with the Y2K scare when people > worried that legacy software might stop working or do horrible things once > the clock turned. It may even have been scary enough for some companies to > rewrite key applications and even switch from languages like COBOL. > > What is happening in the python community, and especially in places where > broken software may be a serious problem? > > I assume versions of python 2.X will continue to be available for some time > but without any further support and without features being back-ported. Commercial support for Python 2 will probably continue for a while, in the same way that support for versions older than 2.7 is still available to Red Hat customers today (if I'm not mistaken). Otherwise, well, the software will continue without updates or security patches until it breaks. Companies will have to weigh up five costs against each other: 1) The cost of the status quo: the risk of critical failures or external attacks against unsupported and unpatched software 2) The cost of migrating to Python 3 3) The cost of migrating to a completely different language 4) The cost of maintaining their own local fork of Python 2 5) The cost of using a supported commercial platform such as RHEL. For most small to medium projects, it's probably going to come down to #1 or #2, where #1 has the laziness bonus. For many larger companies, #1 is an unpayable cost. Everyone has to make that choice, and remember that "cost" doesn't just mean money (for instance, the cost of moving to Linux might be quite considerable for a Windows shop, and even within a Linux ecosystem, switching to Red Hat may have consequences to other programs you might need). ChrisA From rosuav at gmail.com Wed Jan 16 16:46:12 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jan 2019 08:46:12 +1100 Subject: the python name In-Reply-To: <5p8v3ep4rijg8u0kki9t8jr9ebnbjggkjv@4ax.com> References: <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <00a101d4adcb$cb457480$61d05d80$@verizon.net> <5p8v3ep4rijg8u0kki9t8jr9ebnbjggkjv@4ax.com> Message-ID: On Thu, Jan 17, 2019 at 8:37 AM Dennis Lee Bieber wrote: > > On Wed, 16 Jan 2019 13:46:29 -0500, "Avi Gross" > declaimed the following: > > >Imagine people developing languages like X and Y and over the years > >enhancing them. > > > >An Enhanced or Extended X, naturally, might be renamed EX. > > Getting too close to REXX (which was something like Restructured > EXtended eXecutor). > I assumed that that's what Avi was referencing. ChrisA From best_lay at yahoo.com Wed Jan 16 20:59:49 2019 From: best_lay at yahoo.com (Wildman) Date: Wed, 16 Jan 2019 19:59:49 -0600 Subject: get the terminal's size References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: On Mon, 14 Jan 2019 11:57:33 +0000, Alex Ternaute wrote: > Hi there, > > I want to know the number of columns of the terminal where python2 writes > it's outputs. > > In a terminal, I type > $ echo $COLUMNS > 100 > > But in Python, os.getenv("COLUMNS") gets nothing. > It gets nothing as well if I try to read the output of "echo $COLUMNS" > from a subprocess. > > I feel that I'm missing something but what ? > > Looking on the internet for a hint, I see that python3 has an > os.get_terminal_size(). > Please, is there something similar for python2 ? > > Cheers I have used this Python2 code with success in Linux... #!/usr/bin/env python import fcntl import os import struct import termios tty = os.open(os.ctermid(), os.O_RDONLY) ts = struct.unpack("hh", fcntl.ioctl(tty, termios.TIOCGWINSZ, "1234")) os.close(tty) print str(ts[1]) + "x" + str(ts[0]) -- GNU/Linux user #557453 "There are only 10 types of people in the world... those who understand Binary and those who don't." -Spike From akkana at shallowsky.com Wed Jan 16 21:16:25 2019 From: akkana at shallowsky.com (Akkana Peck) Date: Wed, 16 Jan 2019 19:16:25 -0700 Subject: get the terminal's size In-Reply-To: References: <5c3c792d$0$3711$426a74cc@news.free.fr> Message-ID: <20190117021625.GD1247@shallowsky.com> > On Mon, 14 Jan 2019 11:57:33 +0000, Alex Ternaute wrote: > > > Hi there, > > > > I want to know the number of columns of the terminal where python2 writes > > it's outputs. A couple days late to the party, a discussion of several ways I tried: http://shallowsky.com/blog/hardware/serial-24-line-terminals.html and the script I ended up with: https://github.com/akkana/scripts/blob/master/termsize (I've only tested these on Linux). ...Akkana From avigross at verizon.net Wed Jan 16 21:34:01 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 16 Jan 2019 21:34:01 -0500 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> Message-ID: <003801d4ae0d$1b6356d0$522a0470$@verizon.net> Chris, The comparison to Y2K was not a great one. I am not sure what people did in advance, but all it took was to set the clock forward on a test system and look for anomalies. Not everything would be found but it gave some hints. Similarly, it is trivial today to take a machine and install only the new python version and try it, albeit many programs may have effects far away across the internet in some apps and harder to isolate. But Y2K was going to happen guaranteed. The split between 2.X has been fairly slow in some ways and with crutches designed to make a transition smoother. As long as there are people willing to remain behind in what they consider safe territory, there will be those happy to sell them some things and probably raise their prices. I recall what happened with TELEX some years ago. It was awfully slow compared to other methods such as email or FAX but it had legal standing and clients who had to be reached in places that had less access and so on. I recall how despite huge drops in message volume year after year, it remained a very profitable item for my AT&T unit and continued to be supported as we just kept raising the price for those still wanting to use it. I was working on newer stuff and just watched several such parts in amazement including others using what I considered obsolete protocols. Not obsolete to those customers though. I empathize with people using software that already works. You know, if it isn't broken, .... But to continue making it work may require supplying complete solutions as customers cannot be expected to have older python interpreters sitting around on their machine. If your application resides within your servers and only communicates with others of the same ilk, you probably can continue using it indefinitely. There may be someone still using an ancient PC from the 80's running Windows 1.0 with a similarly old copy of WordPerfect and a serial printer attached. But if they want to load a recent version of Microsoft Office, forget it. Heck, it would not fit on their 20MEG hard disk. I assume there must be tools out there that can look over your code and point out places where it may not be compatible. But the more I learn, the more I realize how subtle a problem may be. Some of the back-ported features for example are not exactly identical in effect. Close, maybe. Things like changes in Unicode functionality often are papered over and then a valid statement in one may print a character while in the other it may print a short int. If you ran such a program and it showed minimal issues like just needing to change print statements into print functions, it might be easier to convince your boss to upgrade. If the effort looks massive, they may even opt for a complete rewrite or move to another language that is less likely to keep changing, or maybe just buy a solution that is not quite tailored to their needs. I did have an experience along these lines years ago when a new variation of C came across. Years ago I worked on a project at Bell Labs that was mostly in C. As C++ was coming out, I volunteered to do my part using it as I could show why my application would be object-oriented. I was shocked when they approved and I set up make files that recognized what code was in C or C++ and compiled and linked them properly and so on. It worked beautifully and guess what? We tossed the entire project! This was back in the days when AT&T cared less about wasting money. Our project had been canceled at higher levels and the management spent half a year deciding what our next project would be but felt no need to tell us! So when I offered to do something experimental, they figured why not! And, yes, eventually we did our new development in C++. But had they considered it, it would have made more sense to stop developing something and take the time to retrain the staff with courses that were available and have us use up some vacation days and be ready for a new project. Bottom line here is I should not be surprised if some people want an answer on how to keep projects in 2.X going. But, unless there is a reason, I see little reason in going along or teaching new programmers on what is in a sense the less useful version going forward. The main reason to study 2.X, FOR ME, is to be able to understand it if I encounter it and perhaps be able to rewrite it. -----Original Message----- From: Python-list On Behalf Of Chris Angelico Sent: Wednesday, January 16, 2019 2:15 PM To: Python Subject: Re: Pythonic Y2K On Thu, Jan 17, 2019 at 6:04 AM Avi Gross wrote: > > I see messages like the following where someone is still asking how to > do something in some version of python 2.X. > > I recall the days before the year 2000 with the Y2K scare when people > worried that legacy software might stop working or do horrible things > once the clock turned. It may even have been scary enough for some > companies to rewrite key applications and even switch from languages like COBOL. > > What is happening in the python community, and especially in places > where broken software may be a serious problem? > > I assume versions of python 2.X will continue to be available for some > time but without any further support and without features being back-ported. Commercial support for Python 2 will probably continue for a while, in the same way that support for versions older than 2.7 is still available to Red Hat customers today (if I'm not mistaken). Otherwise, well, the software will continue without updates or security patches until it breaks. Companies will have to weigh up five costs against each other: 1) The cost of the status quo: the risk of critical failures or external attacks against unsupported and unpatched software 2) The cost of migrating to Python 3 3) The cost of migrating to a completely different language 4) The cost of maintaining their own local fork of Python 2 5) The cost of using a supported commercial platform such as RHEL. For most small to medium projects, it's probably going to come down to #1 or #2, where #1 has the laziness bonus. For many larger companies, #1 is an unpayable cost. Everyone has to make that choice, and remember that "cost" doesn't just mean money (for instance, the cost of moving to Linux might be quite considerable for a Windows shop, and even within a Linux ecosystem, switching to Red Hat may have consequences to other programs you might need). ChrisA -- https://mail.python.org/mailman/listinfo/python-list From avigross at verizon.net Wed Jan 16 21:48:44 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 16 Jan 2019 21:48:44 -0500 Subject: Guido (Sarducci) Message-ID: <003901d4ae0f$29d64e00$7d82ea00$@verizon.net> Dennis, I wish to apologize for introducing any suggestion to name anything as Guido, let alone any language that springs from a python. Yes, it may be a stereotypic Italian name related to what you hint at. You probably recognized it as an allusion to someone who is clearly Dutch and has some finite relationship with python. The name is ultimately Germanic and used in many countries. I, in a Monty Python Spirit, insist I was thinking about the Saturday Night Live comedic character from generations ago, Father Guido Sarducci, who does indeed appear to be Italian. That is the pythonic way to choose a name although 3.X might well have been named after the Three Stooges. Again, my apologies. I will try to resume being serious and maybe talk about mission creep. Avi -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Wednesday, January 16, 2019 4:36 PM To: python-list at python.org Subject: Re: the python name On Wed, 16 Jan 2019 13:46:29 -0500, "Avi Gross" declaimed the following: >[HUMOR for the ALERT] > >But as languages develop and evolve, sometimes a name change may be a >decent idea. Perhaps version 4.0 should be renamed Guido so we can get >more silly questions. > So we can make jokes about a mafia hitman (which is where many might go with the name) > >Imagine people developing languages like X and Y and over the years >enhancing them. > >An Enhanced or Extended X, naturally, might be renamed EX. Getting too close to REXX (which was something like Restructured EXtended eXecutor). > >With further Super new features (think super-symmetry in Physics) we >would have a Super Extended X, or SEX in brief. > Computer science already has sexpr https://en.wikipedia.org/wiki/S-expression -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- https://mail.python.org/mailman/listinfo/python-list From larry.martell at gmail.com Wed Jan 16 22:45:37 2019 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 16 Jan 2019 22:45:37 -0500 Subject: Pythonic Y2K In-Reply-To: <003801d4ae0d$1b6356d0$522a0470$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> Message-ID: On Wed, Jan 16, 2019 at 9:35 PM Avi Gross wrote: > > Chris, > > The comparison to Y2K was not a great one. I am not sure what people did in > advance, but all it took was to set the clock forward on a test system and > look for anomalies. Not everything would be found but it gave some hints. Clearly you did not live through that. I did and I got over 2 years of real work from it. Companies hired me to check their code and find their Y2K exposures. Things like a hard coded '19' being added to a 2 digit year. Or code that only allocated 2 bytes for the year. I could go on and on. At one client I had I found over 4,000 places in their code that needed to be modified. And there was no widespread use of VMs that you could easily and quickly spin up for testing. It was a real problem but because of many people like me, it was dealt with. Now the next thing to deal with is the Jan. 19, 2038 problem. I'll be 80 then, but probably still writing code. Call me if you need me. From PythonList at DancesWithMice.info Wed Jan 16 23:03:58 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 17 Jan 2019 17:03:58 +1300 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> Message-ID: <6306832c-9e31-7a8a-90e8-7016f552b779@DancesWithMice.info> On 17/01/19 4:45 PM, Larry Martell wrote: > On Wed, Jan 16, 2019 at 9:35 PM Avi Gross wrote: >> >> Chris, >> >> The comparison to Y2K was not a great one. I am not sure what people did in >> advance, but all it took was to set the clock forward on a test system and >> look for anomalies. Not everything would be found but it gave some hints. > > Clearly you did not live through that. I did and I got over 2 years of > real work from it. Companies hired me to check their code and find > their Y2K exposures. Things like a hard coded '19' being added to a 2 > digit year. Or code that only allocated 2 bytes for the year. I could > go on and on. At one client I had I found over 4,000 places in their > code that needed to be modified. And there was no widespread use of > VMs that you could easily and quickly spin up for testing. It was a > real problem but because of many people like me, it was dealt with. > Now the next thing to deal with is the Jan. 19, 2038 problem. I'll be > 80 then, but probably still writing code. Call me if you need me. Same. The easy part was finding the hardware, configuring identical systems, and changing the date-era. Remember that we pre-dated TDD, so we pretty much re-designed entire testing suites! The most difficult work was with the oldest systems - for which there was no/little/worthless documentation, and usually no dev staff with 'memory'. Then there were the faults in OpSys and systems programs on which we could supposedly rely - I still have a couple of certificates somewhere, for diagnosing faults which MSFT had not found... The difficulty of multi-layer fault-finding is an order of magnitude more difficult than Python debugging alone! I'm told there are fewer and fewer COBOL programmers around, and those that survive can command higher rates as a consequence. Would going 'back' to that be regarded as "up" skilling? Does this imply that there might one day be a premium chargeable by Py2.n coders? -- Regards =dn From avigross at verizon.net Wed Jan 16 23:54:14 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 16 Jan 2019 23:54:14 -0500 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> Message-ID: <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> Larry, I was not belittling the effort it took to make sure Y2K was not a disaster. I was making the comparison of how you could start to emulate the problem in advance just as you can easily test older python code with newer ones. My work those days was in places where we did not do much of what you point out such as a hardcoded 19 or using a condensed date format. I had a cousin die recently at 105 and his brother is now 103 and clearly they would not fit well in a 2-digit date field as they might be placed in kindergarten. Weird assumptions were often made because saving space in memory or on tape was considered essential. The forthcoming UNIX 2038 problem will, paradoxically happen on January 19. I wonder what they will do long before then. Will they just add a byte or four or 256 and then make a date measurable in picoseconds? Or will they start using a number format that can easily deal with 1 Million B.C. and 5 Billion A.D. just in case we escape earth before it co-locates with the expanding sun. This may be a place where the unlimited integer in python may be useful but with some hidden gotchas as I can think of places where longer ints are not trivially supported. You actually are sort of making my point clearer. The Y2K problem was "partially" due to the fact that code people wrote was not expected to be around very long and yet some sort of inertia kept plenty around and even when new code came along, it tried to emulate the old. I can well understand people holding on to what they know, especially when the new stuff is likely to keep changing. Some of that legacy code probably is very un-pythonic and a relatively minimal translation from how it was done in C, when that is possible. Arguably such code might be easier to port as it may use just 2% of what python makes available. No functional programming, no classes/objects, just ASCII text and while loops. ? Remember when file names were very limited? DOS was 8 by 3. UNIX was once 14 with the optional period anywhere including at the beginning. People often made somewhat compressed names and a two-character year was all you had room for. I have data I sometimes work with containing hundreds of variables with 8-character names that drive me nuts as they are not meaningful to me. I often read them in and rename them. How would you encode say a test score taken on December 22, 2013? "12222013" would use up the entire allotment. Back to python, I see lots of mission creep mixed in with nice features to the point where it stopped being a particularly simple language many releases ago. Some of that may be part of what makes upgrading some code harder. Many additions include seemingly endless dunder variables that enable some protocols. I mean __ADD_ may seem a reasonable way to define what happens when a binary "+" operation is defined, but then you have left/right versions of it as well as autoincrement as well as symbols with similar and sometimes confusing meanings and many that do not correspond to symbols in the language such as __ITER__ and __NEXT__ whose presence drives an added iteration protocol. The zoo can be confusing and new stuff keeps being added including in modules outside the formal language. It is great and can separate the women from the girls, so to speak. Lots of nice, convenient and powerful functionality can be added by placing such methods or variables in objects directly or in associated objects. But I see it as a tad clearer in a language like R where you can name an operator in some form of quotes. I do not recommend redefining the plus operator as I am about to do but note base R does not add using "+" and you generally use the paste() function. (Ignore the prompt of "> " in the example below.) > "hello" + "world" Error in "hello" + "world" : non-numeric argument to binary operator > '+' <- function(x, y) paste(x, y, sep="+++") > "hello" + "world" [1] "hello+++world" > "one" + "two" + "three" [1] "one+++two+++three" The point is you know what is being changed rather than having to identify what a "word" like __iadd__ means or that when it is absent, the regular __add__ is used. And you can extend the language this way quite a bit like by making operators between percent signs like "%*%" or "%matrixmult%" or whatever. Heck, there are many versions of pipes made using "%>%" or other such invented symbols that make writing some code easier and clearer. Not saying the language is overall better or that some features would be a good idea to graft on now. Just that some things may be more intuitive and as python keeps adding to a namespace, the meaning of a class keeps getting more amorphous and sometimes has so much loaded into it that it fills multiple pages. I would not show most beginners too much of python at first, or just ask them to take some things on faith for a while. A language that initially claimed to be designed to do things pretty much ONE way has miserably failed as I can do almost anything a dozen ways. That is NOT a bad thing. As long as the goal is for someone to learn how to do something in any one way, it is great. If you want them to be able to read existing code and modify it, it can be a headache especially when people abuse language features. And yes, I am an abuser in that sense. -----Original Message----- From: Python-list On Behalf Of Larry Martell Sent: Wednesday, January 16, 2019 10:46 PM To: Python Subject: Re: Pythonic Y2K On Wed, Jan 16, 2019 at 9:35 PM Avi Gross wrote: > > Chris, > > The comparison to Y2K was not a great one. I am not sure what people > did in advance, but all it took was to set the clock forward on a test > system and look for anomalies. Not everything would be found but it gave some hints. Clearly you did not live through that. I did and I got over 2 years of real work from it. Companies hired me to check their code and find their Y2K exposures. Things like a hard coded '19' being added to a 2 digit year. Or code that only allocated 2 bytes for the year. I could go on and on. At one client I had I found over 4,000 places in their code that needed to be modified. And there was no widespread use of VMs that you could easily and quickly spin up for testing. It was a real problem but because of many people like me, it was dealt with. Now the next thing to deal with is the Jan. 19, 2038 problem. I'll be 80 then, but probably still writing code. Call me if you need me. -- https://mail.python.org/mailman/listinfo/python-list From greg.ewing at canterbury.ac.nz Thu Jan 17 00:10:29 2019 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 17 Jan 2019 18:10:29 +1300 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <00a101d4adcb$cb457480$61d05d80$@verizon.net> Message-ID: Avi Gross wrote: > The question that seems to come up too often about the python name is a > distraction. In particular, it is answered fairly prominently in many places > as just being a nonsensical name because a founder once liked a comedic > entity that chose an oddball name, so they did too. That may be how it started, but I don't think Python is a silly name for a programming language at all. There's a long tradition of naming things after animals that have some of the qualities you want people to associate with them. In the case of Python, it's not a particularly fast animal, but it is sleek and powerful, and its minimal design has a certain elegance to it. So, I think it's very appropriate. -- Greg From greg.ewing at canterbury.ac.nz Thu Jan 17 00:12:33 2019 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 17 Jan 2019 18:12:33 +1300 Subject: the python name In-Reply-To: References: <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <00a101d4adcb$cb457480$61d05d80$@verizon.net> <5p8v3ep4rijg8u0kki9t8jr9ebnbjggkjv@4ax.com> Message-ID: Dennis Lee Bieber wrote: > Getting too close to REXX (which was something like Restructured > EXtended eXecutor). And if we continue the theme of dinosaur evolution, we end up with Tyrannosaurus REXX. -- Greg From avigross at verizon.net Thu Jan 17 00:22:17 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 17 Jan 2019 00:22:17 -0500 Subject: Pythonic Y2K In-Reply-To: <6306832c-9e31-7a8a-90e8-7016f552b779@DancesWithMice.info> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> <6306832c-9e31-7a8a-90e8-7016f552b779@DancesWithMice.info> Message-ID: <004f01d4ae24$9cf47870$d6dd6950$@verizon.net> Dave, You have me worried now. Yes, years from now you may need experts who can handle not just 2.X but specific versions like 2.4. Assuming python keeps making incompatible changes and is up to version 9.02, you may also have 3.X experts and 4.X experts and so on. Of course, by then, some of the experts may be an AI specializing ... All kidding aside, I have to wonder if future developments may result in new categories of computer languages that are designed anew in radically different ways to the point where it may get more people to switch and more languages to halt further development. I see Unicode as a potential driver. The number of symbols in languages like python is fixed by what can be seen on a normal keyboard. That keyboard needs to change a bit, or some virtual version, to support lots more. When that happens, we won't be forced to do as much sharing and overloading as we do now. How many ways is "%" used including within one line of code? >>> print("%d %s " % (9 % 5, "ways to use %")) 4 ways to use % Similarly, {} can be used for dictionaries or sets but an empty set initializes a dictionary only. [] can be used to index lists by number or dictionaries by key. There are not as many such sets of characters available and <> is reserved for other uses and parentheses also has an odd role with tuples as well as keeping things in some order of operations. Imagine adding a few more matched symbols including some you can define for your own newly created kinds of data like matrices. Similarly, you could have an abbreviated way of defining additional operations if you could just use come common mathematical symbols that are not in ASCII, not to mention some dingbats. If a programming language leaped across the ASCII divide (and I am sure some have, including the languages that used backspace to make overwritten multi-character operators) I can see ways to make more compact but less confusing languages. I admit that might confuse some people, especially some that only really know one language. I am used to multiple languages including some with rather unique character sets and perhaps may be the only one willing to use such a language. OK, sort of kidding. I have seen many forums like this one (and not just about computer languages) where I encounter true believers that do not welcome any suggestion that there may be other things out there with some merit or that their own may change. I welcome change and am interested in different ways of thinking. This makes it harder for me to quite see the viewpoint that I associate with stasis. But, to each their own. Perhaps literally. -----Original Message----- From: Python-list On Behalf Of DL Neil Sent: Wednesday, January 16, 2019 11:04 PM To: Python Subject: Re: Pythonic Y2K On 17/01/19 4:45 PM, Larry Martell wrote: > On Wed, Jan 16, 2019 at 9:35 PM Avi Gross wrote: >> >> Chris, >> >> The comparison to Y2K was not a great one. I am not sure what people >> did in advance, but all it took was to set the clock forward on a >> test system and look for anomalies. Not everything would be found but it gave some hints. > > Clearly you did not live through that. I did and I got over 2 years of > real work from it. Companies hired me to check their code and find > their Y2K exposures. Things like a hard coded '19' being added to a 2 > digit year. Or code that only allocated 2 bytes for the year. I could > go on and on. At one client I had I found over 4,000 places in their > code that needed to be modified. And there was no widespread use of > VMs that you could easily and quickly spin up for testing. It was a > real problem but because of many people like me, it was dealt with. > Now the next thing to deal with is the Jan. 19, 2038 problem. I'll be > 80 then, but probably still writing code. Call me if you need me. Same. The easy part was finding the hardware, configuring identical systems, and changing the date-era. Remember that we pre-dated TDD, so we pretty much re-designed entire testing suites! The most difficult work was with the oldest systems - for which there was no/little/worthless documentation, and usually no dev staff with 'memory'. Then there were the faults in OpSys and systems programs on which we could supposedly rely - I still have a couple of certificates somewhere, for diagnosing faults which MSFT had not found... The difficulty of multi-layer fault-finding is an order of magnitude more difficult than Python debugging alone! I'm told there are fewer and fewer COBOL programmers around, and those that survive can command higher rates as a consequence. Would going 'back' to that be regarded as "up" skilling? Does this imply that there might one day be a premium chargeable by Py2.n coders? -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Thu Jan 17 00:53:00 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jan 2019 16:53:00 +1100 Subject: Pythonic Y2K In-Reply-To: <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> Message-ID: On Thu, Jan 17, 2019 at 3:55 PM Avi Gross wrote: > The forthcoming UNIX 2038 problem will, paradoxically happen on January 19. > Paradoxically? What do you mean by that? ChrisA From avigross at verizon.net Thu Jan 17 01:03:24 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 17 Jan 2019 01:03:24 -0500 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <00a101d4adcb$cb457480$61d05d80$@verizon.net> Message-ID: <007301d4ae2a$5bd67db0$13837910$@verizon.net> Greg, Boy am I getting sorry I brought this topic up again. Getting hard to take seriously. I am not making fun of the python name. I am making fun of the people that want a GOOD REASON for choosing a name. People generally don't care what silly name you choose for a dog and certainly tolerate weird names for a racehorse. But they might question naming a child Thingamajig Mistake Jones or Moon Unit, whatever that means. Is python an elegant animal name for the language python once was? Sure. Many animals are admired and on the cover of computer books. My PERSONAL opinion is that it has become quite a complex language and might as well be named "The Bronx Zoo" as it houses lots of different animating aspects. I like it when a commonly used name is easy to remember and pronounce unlike, say, 3CPO and R2D2. I am now truly sorry I said anything since no matter what I say, someone will find it wanting. When python grows enough, maybe we can rename it "the Full Monty" and people will still ask why. The name is among the least important things about python. So is the animal it also represents. But if it pleases some people, good for them. -----Original Message----- From: Python-list On Behalf Of Gregory Ewing Sent: Thursday, January 17, 2019 12:10 AM To: python-list at python.org Subject: Re: the python name Avi Gross wrote: > The question that seems to come up too often about the python name is > a distraction. In particular, it is answered fairly prominently in > many places as just being a nonsensical name because a founder once > liked a comedic entity that chose an oddball name, so they did too. That may be how it started, but I don't think Python is a silly name for a programming language at all. There's a long tradition of naming things after animals that have some of the qualities you want people to associate with them. In the case of Python, it's not a particularly fast animal, but it is sleek and powerful, and its minimal design has a certain elegance to it. So, I think it's very appropriate. -- Greg -- https://mail.python.org/mailman/listinfo/python-list From dieter at handshake.de Thu Jan 17 02:41:12 2019 From: dieter at handshake.de (dieter) Date: Thu, 17 Jan 2019 08:41:12 +0100 Subject: python package management confusion References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> Message-ID: <878szj4tpj.fsf@handshake.de> dcs3spp via Python-list writes: > ... > How do I configure python setup.py develop to pull the pyramid_core dependent packages using virtualenv? Your "setup.py" below should work (once, you have removed the "****"). If the "pyramid" package correctly declares its dependencies, then the "pyramid_core" is even likely unnecessary. Try it out. > *************** setup.py ****************** > > import os > import sys > > from setuptools import setup, find_packages > > here = os.path.abspath(os.path.dirname(__file__)) > with open(os.path.join(here, 'README.md')) as f: > README = f.read() > with open(os.path.join(here, 'CHANGES.md')) as f: > CHANGES = f.read() > > requires = [ > 'cryptography', > 'odfpy', > 'PyJWT', > 'pycrypto', > 'pyramid', > ***** 'pyramid_core', ******* > requirements.txt file? > 'pyramid_debugtoolbar', > 'pyramid_tm', > 'requests==2.18.4', > 'SQLAlchemy', > 'transaction', > 'zope.sqlalchemy', > 'waitress', > 'psycopg2-binary', > 'python-dateutil', > 'uwsgi', > 'marshmallow-sqlalchemy', > ] > > setup_requires = [ > 'pytest-runner', > ] > > tests_require = [ > 'boto3', > 'lovely-pytest-docker', > 'pytest', > 'pytest-cov', > 'tuspy', > 'WebTest >= 1.3.1', > ] > > setup(name='api', > version='0.0', > description='api', > long_description=README + '\n\n' + CHANGES, > classifiers=[ > "Programming Language :: Python", > "Framework :: Pyramid", > "Topic :: Internet :: WWW/HTTP", > "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", > ], > author='simon pears', > author_email='roughlea-music at outlook.com', > url='', > keywords='web wsgi bfg pylons pyramid', > packages=find_packages('src'), > package_dir={'': 'src'}, > include_package_data=True, > zip_safe=False, > extras_require={ > 'testing': tests_require, > }, > install_requires=requires, > setup_requires=setup_requires, > tests_require=tests_require, > test_suite='tests', > entry_points="""\ > [paste.app_factory] > main = api:main > [console_scripts] > initialize_api_db = api.scripts.initializedb:main > """, > ) From stone.zhong at gmail.com Thu Jan 17 03:10:36 2019 From: stone.zhong at gmail.com (Stone Zhong) Date: Thu, 17 Jan 2019 00:10:36 -0800 (PST) Subject: ImportError: cannot import name certificate_transparency Message-ID: <466066ad-c929-4373-a2da-0771cb651159@googlegroups.com> Hi, My program depend on package oci, I am using the following command to install it: pip install oci Everything works perfect in virtualenv (I am still using python 2.7.x) Now I am creating a zip file from the libraries: pip install oci -t ~/temp/oci cd ~/temp/oci zip -r ~/temp/oci.zip . Test A) PYTHONPATH=~/temp/oci myapp.py Test B) PYTHONPATH=~/temp/oci.zip myapp.py Test A) works fine and Test B) failed with error "ImportError: cannot import name certificate_transparency" It seems we have some so file there: ./cryptography/hazmat/bindings/_padding.so ./cryptography/hazmat/bindings/_openssl.so ./cryptography/hazmat/bindings/_constant_time.so ./_cffi_backend.so I also tested below: mytest.py: ... from cryptography.hazmat.bindings._constant_time import lib PYTHONPATH=~/temp/oci.zip mytest.py I end up with error "ImportError: No module named _constant_time" So my guess is, package with shared lib (.so files) cannot be put into zip file, is it a bug in python zipimport? The reason I have to use a zip file is, I need it in a spark job, I cannot do "virtualenv" in pyspark, have to use --py-files to pass the zip file for all dependent packages. Thanks, Stone From stone.zhong at gmail.com Thu Jan 17 03:27:36 2019 From: stone.zhong at gmail.com (Stone Zhong) Date: Thu, 17 Jan 2019 00:27:36 -0800 (PST) Subject: ImportError: cannot import name certificate_transparency In-Reply-To: <466066ad-c929-4373-a2da-0771cb651159@googlegroups.com> References: <466066ad-c929-4373-a2da-0771cb651159@googlegroups.com> Message-ID: On Thursday, January 17, 2019 at 12:10:51 AM UTC-8, Stone Zhong wrote: > Hi, > > My program depend on package oci, I am using the following command to install it: > pip install oci > > Everything works perfect in virtualenv (I am still using python 2.7.x) > > Now I am creating a zip file from the libraries: > > pip install oci -t ~/temp/oci > cd ~/temp/oci > zip -r ~/temp/oci.zip . > > Test A) PYTHONPATH=~/temp/oci myapp.py > Test B) PYTHONPATH=~/temp/oci.zip myapp.py > > Test A) works fine and Test B) failed with error "ImportError: cannot import name certificate_transparency" > > It seems we have some so file there: > ./cryptography/hazmat/bindings/_padding.so > ./cryptography/hazmat/bindings/_openssl.so > ./cryptography/hazmat/bindings/_constant_time.so > ./_cffi_backend.so > > I also tested below: > > mytest.py: > ... > from cryptography.hazmat.bindings._constant_time import lib > > PYTHONPATH=~/temp/oci.zip mytest.py > > I end up with error "ImportError: No module named _constant_time" > > So my guess is, package with shared lib (.so files) cannot be put into zip file, is it a bug in python zipimport? > > The reason I have to use a zip file is, I need it in a spark job, I cannot do "virtualenv" in pyspark, have to use --py-files to pass the zip file for all dependent packages. > > Thanks, > Stone ok, found the doc @ https://docs.python.org/3/library/zipimport.html import of dynamic modules (.pyd, .so) is disallowed. So it is not a bug. From stefano at stalksoftINVALID.com Thu Jan 17 07:00:00 2019 From: stefano at stalksoftINVALID.com (steve) Date: Thu, 17 Jan 2019 12:00:00 +0000 Subject: [tkinter] question about correct use of validation References: Message-ID: Il 16/01/19 08:51, Peter Otten ha scritto: > def make_ui(self): > ''' create user interface ''' > > def vcmd(maxlength): > return self.parent.register( > partial(self.maxlength_validate, maxlength=maxlength) > ), "%P" > ... ok following your advice and that of Rick in the previous post, I developed 2 solutions, one without classes and one with classes. I write to you if you need someone: 1) solution with class (taking a cue from here: http://effbot.org/zone/tkinter-entry-validate.htm - I wanted to reduce the code, I'm working on it) from Tkinter import * class View(): ''' example for set max length of char in Entry widget. -Class implantation- ''' def __init__(self, parent): self.parent = parent self.make_ui() def make_ui(self): ''' create user interface ''' self.id1_entry = self.make_entry(self.parent, maxlen=1).pack() self.id2_entry = self.make_entry(self.parent, maxlen=2).pack() self.id3_entry = self.make_entry(self.parent, maxlen=3).pack() self.id4_entry = self.make_entry(self.parent, maxlen=4).pack() self.id5_entry = self.make_entry(self.parent, maxlen=5).pack() def make_entry(self, parent, width=50, maxlen=30, highlightcolor='blue', validate='key'): entry = MyEntry(parent, maxlen=maxlen) entry.configure(width=width, highlightcolor=highlightcolor) return entry class ValidatingEntry(Entry): # base class for validating entry widgets def __init__(self, master, value="", **kw): apply(Entry.__init__, (self, master), kw) self.__value = value self.__variable = StringVar() self.__variable.set(value) self.__variable.trace("w", self.__callback) self.config(textvariable=self.__variable) self.configure(highlightcolor='blue') def __callback(self, *dummy): value = self.__variable.get() newvalue = self.validate(value) if newvalue is None: self.__variable.set(self.__value) elif newvalue != value: self.__value = newvalue self.__variable.set(newvalue) else: self.__value = value def validate(self, value): # override: return value, new value, or None if invalid return value class MyEntry(ValidatingEntry): def __init__(self, master, value="", maxlen=None, **kw): self.maxlength = maxlen apply(ValidatingEntry.__init__, (self, master), kw) def validate(self, value): return value[:self.maxlength] def run(): root = Tk() root.title('test') View(root) root.mainloop() if __name__ == "__main__": run() ------------------------------------------------------------ 2) classless solution (part of your code) from Tkinter import * from functools import partial class View(): ''' example for set max length of char in Entry widget. -Functions implantation- ''' def __init__(self, parent): self.parent = parent self.make_ui() def make_ui(self): ''' create user interface ''' self.id1_entry = self.make_entry(self.parent, maxlen=1).pack() self.id2_entry = self.make_entry(self.parent, maxlen=2).pack() self.id3_entry = self.make_entry(self.parent, maxlen=3).pack() self.id4_entry = self.make_entry(self.parent, maxlen=4).pack() self.id5_entry = self.make_entry(self.parent, maxlen=5).pack() def make_entry(self, parent, width=50, maxlen=30, highlightcolor='blue', validate='key'): def vcmd(maxlength): return self.parent.register(partial(self.maxlength_validate, maxlength=maxlength)), "%P" entry = Entry(parent) entry.configure(width=width, highlightcolor=highlightcolor, validate='key', validatecommand=vcmd(maxlen)) return entry def maxlength_validate(self, value, maxlength): return len(value) <= maxlength def run(): root = Tk() root.title('test') View(root) root.mainloop() if __name__ == "__main__": run() Thank you all From tdldev at gmail.com Thu Jan 17 07:55:57 2019 From: tdldev at gmail.com (Jack Dangler) Date: Thu, 17 Jan 2019 07:55:57 -0500 Subject: Guido (Sarducci) In-Reply-To: <003901d4ae0f$29d64e00$7d82ea00$@verizon.net> References: <003901d4ae0f$29d64e00$7d82ea00$@verizon.net> Message-ID: <39b6c577-45b1-8f7f-192a-d86c664be7a0@gmail.com> On 1/16/19 9:48 PM, Avi Gross wrote: > Dennis, > > I wish to apologize for introducing any suggestion to name anything as > Guido, let alone any language that springs from a python. Yes, it may be a > stereotypic Italian name related to what you hint at. You probably > recognized it as an allusion to someone who is clearly Dutch and has some > finite relationship with python. The name is ultimately Germanic and used in > many countries. > > I, in a Monty Python Spirit, insist I was thinking about the Saturday Night > Live comedic character from generations ago, Father Guido Sarducci, who > does indeed appear to be Italian. That is the pythonic way to choose a name > although 3.X might well have been named after the Three Stooges. > > Again, my apologies. I will try to resume being serious and maybe talk about > mission creep. > > Avi > > -----Original Message----- > From: Python-list On > Behalf Of Dennis Lee Bieber > Sent: Wednesday, January 16, 2019 4:36 PM > To: python-list at python.org > Subject: Re: the python name > > On Wed, 16 Jan 2019 13:46:29 -0500, "Avi Gross" > declaimed the following: > >> [HUMOR for the ALERT] >> >> But as languages develop and evolve, sometimes a name change may be a >> decent idea. Perhaps version 4.0 should be renamed Guido so we can get >> more silly questions. >> > So we can make jokes about a mafia hitman (which is where many might > go with the name) > >> Imagine people developing languages like X and Y and over the years >> enhancing them. >> >> An Enhanced or Extended X, naturally, might be renamed EX. > Getting too close to REXX (which was something like Restructured > EXtended eXecutor). > >> With further Super new features (think super-symmetry in Physics) we >> would have a Super Extended X, or SEX in brief. >> > Computer science already has sexpr > https://en.wikipedia.org/wiki/S-expression > > > > Finda de pope ina de pizza! A very funny skit! From __peter__ at web.de Thu Jan 17 08:08:26 2019 From: __peter__ at web.de (Peter Otten) Date: Thu, 17 Jan 2019 14:08:26 +0100 Subject: [tkinter] question about correct use of validation References: Message-ID: steve wrote: > Il 16/01/19 08:51, Peter Otten ha scritto: > >> def make_ui(self): >> ''' create user interface ''' >> >> def vcmd(maxlength): >> return self.parent.register( >> partial(self.maxlength_validate, maxlength=maxlength) >> ), "%P" >> > ... > > ok following your advice and that of Rick in the previous post, I > developed 2 solutions, one without classes and one with classes. I write > to you if you need someone: Two remarks: > self.id1_entry = self.make_entry(self.parent, maxlen=1).pack() You set all idX_entry attributes to None, as that's what pack() returns. > apply(Entry.__init__, (self, master), kw) You can write that in way compatible with Python 3 as Entry.__init__(self, master, **kw) > Thank you all You're welcome. From simonppears at googlemail.com Thu Jan 17 11:27:52 2019 From: simonppears at googlemail.com (dcs3spp) Date: Thu, 17 Jan 2019 08:27:52 -0800 (PST) Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> Message-ID: <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> On Thursday, 17 January 2019 07:41:43 UTC, dieter wrote: > dcs3spp via Python-list writes: > > ... > > How do I configure python setup.py develop to pull the pyramid_core dependent packages using virtualenv? > > Your "setup.py" below should work (once, you have removed the "****"). > If the "pyramid" package correctly declares its dependencies, > then the "pyramid_core" is even likely unnecessary. > > Try it out. > > > *************** setup.py ****************** > > > > import os > > import sys > > > > from setuptools import setup, find_packages > > > > here = os.path.abspath(os.path.dirname(__file__)) > > with open(os.path.join(here, 'README.md')) as f: > > README = f.read() > > with open(os.path.join(here, 'CHANGES.md')) as f: > > CHANGES = f.read() > > > > requires = [ > > 'cryptography', > > 'odfpy', > > 'PyJWT', > > 'pycrypto', > > 'pyramid', > > ***** 'pyramid_core', ******* > > requirements.txt file? > > 'pyramid_debugtoolbar', > > 'pyramid_tm', > > 'requests==2.18.4', > > 'SQLAlchemy', > > 'transaction', > > 'zope.sqlalchemy', > > 'waitress', > > 'psycopg2-binary', > > 'python-dateutil', > > 'uwsgi', > > 'marshmallow-sqlalchemy', > > ] > > > > setup_requires = [ > > 'pytest-runner', > > ] > > > > tests_require = [ > > 'boto3', > > 'lovely-pytest-docker', > > 'pytest', > > 'pytest-cov', > > 'tuspy', > > 'WebTest >= 1.3.1', > > ] > > > > setup(name='api', > > version='0.0', > > description='api', > > long_description=README + '\n\n' + CHANGES, > > classifiers=[ > > "Programming Language :: Python", > > "Framework :: Pyramid", > > "Topic :: Internet :: WWW/HTTP", > > "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", > > ], > > author='simon pears', > > author_email='roughlea-music at outlook.com', > > url='', > > keywords='web wsgi bfg pylons pyramid', > > packages=find_packages('src'), > > package_dir={'': 'src'}, > > include_package_data=True, > > zip_safe=False, > > extras_require={ > > 'testing': tests_require, > > }, > > install_requires=requires, > > setup_requires=setup_requires, > > tests_require=tests_require, > > test_suite='tests', > > entry_points="""\ > > [paste.app_factory] > > main = api:main > > [console_scripts] > > initialize_api_db = api.scripts.initializedb:main > > """, > > ) Apologies dieter, I have not explained very well. I have written the pyramid_core package, it is not an external pypi package. I wish to use it across my own private projects, including CI builds mentioned earlier. How do I configure setuptools to pull my own private dependency package using virtualenv + python setup.py develop From ibrewster at flyravn.com Thu Jan 17 13:01:50 2019 From: ibrewster at flyravn.com (Israel Brewster) Date: Thu, 17 Jan 2019 18:01:50 +0000 Subject: AssertionError without traceback? In-Reply-To: <87zhs25px1.fsf@handshake.de> References: <87zhs25px1.fsf@handshake.de> Message-ID: <430B8927-2179-477F-BD6D-20CE2F85C60B@flyravn.com> ----------------------------------------------- Israel Brewster Systems Analyst II 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- [cid:bfa5c323-b100-481d-96b1-fc256ef2eb39 at flyravn.com] [cid:8c891973-9e67-47b3-aa14-5f58b9b93607 at flyravn.com] On Jan 14, 2019, at 10:40 PM, dieter > wrote: Israel Brewster > writes: I have a flask application deployed on CentOS 7 using Python 3.6.7 and uwsgi 2.0.17.1, proxied behind nginx. uwsgi is configured to listed on a socket in /tmp. The app uses gevent and the flask_uwsgi_websockets plugin as well as various other third-party modules, all installed via pip in a virtualenv. The environment was set up using pip just a couple of days ago, so everything should be fully up-to-date. The application *appears* to be running properly (it is in moderate use and there have been no reports of issues, nor has my testing turned up any problems), however I keep getting entries like the following in the error log: AssertionError 2019-01-14T19:16:32Z failed with AssertionError I would try to find out where the log message above has been generated and ensure it does not only log the information above but also the associated traceback. Any tips as to how? I tried putting in additional logging at a couple places where I called gevent.spawn() to see if that additional logging lined up with the assertions, but no luck. I guess I could just start peppering my code with logging commands, and hope something pops, but this seems quite...inelegant. I have not been able to reproduce the error, unfortunately. I assume that the log comes from some framework -- maybe "uwsgi" or "gevent". It is a weakness to log exceptions without the associated traceback. Fully agreed on both points. The reference to the callback for some reason puts me in mind of C code, but of course AssertionError is python, so maybe not. For what it's worth, the issue only seems to happen when the server is under relatively heavy load. During the night, when it is mostly idle, I don't get many (if any) errors. And this has only been happening since I upgraded to CentOS7 and the latest versions of all the frameworks. Hopefully it isn't a version incompatibility... There is no additional information provided, just that. I was running the same app (checked out from a GIT repository, so exact same code) on CentOS 6 for years without issue, it was only since I moved to CentOS 7 that I've seen the errors. I have not so far been able to correlate this error with any specific request. Has anyone seen anything like this before such that you can give me some pointers to fixing this? As the application *appears* to be functioning normally, it may not be a big issue, but it has locked up once since the move (no errors in the log, just not responding on the socket), so I am a bit concerned. ----------------------------------------------- Israel Brewster Systems Analyst II 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- [cid:05a3a602-0c27-4749-91b8-096a5857d984 at flyravn.com] [cid:bbc82752-6db4-44cf-b919-421ed304e1d1 at flyravn.com] -- https://mail.python.org/mailman/listinfo/python-list From Joseph.Schachner at Teledyne.com Thu Jan 17 13:46:03 2019 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Thu, 17 Jan 2019 18:46:03 +0000 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> Message-ID: <57efad901005434f8e135f318b9abdf9@Teledyne.com> I'd like to add one more thing to your list of what companies will have to consider: 6) The ability to hire and retain employees who will be happy to program in an obsolete version of Python. A version about which new books will probably not be written. A version which new packages will not support. A version which most other companies will no longer be using, so programming only in Python 2 will place the employee at a disadvantage compared to others who have gained experience with Python 3 if they ever have to change employers. --- Joseph S. -----Original Message----- From: Chris Angelico Sent: Wednesday, January 16, 2019 2:15 PM To: Python Subject: Re: Pythonic Y2K On Thu, Jan 17, 2019 at 6:04 AM Avi Gross wrote: > > I see messages like the following where someone is still asking how to > do something in some version of python 2.X. > > I recall the days before the year 2000 with the Y2K scare when people > worried that legacy software might stop working or do horrible things > once the clock turned. It may even have been scary enough for some > companies to rewrite key applications and even switch from languages like COBOL. > > What is happening in the python community, and especially in places > where broken software may be a serious problem? > > I assume versions of python 2.X will continue to be available for some > time but without any further support and without features being back-ported. Commercial support for Python 2 will probably continue for a while, in the same way that support for versions older than 2.7 is still available to Red Hat customers today (if I'm not mistaken). Otherwise, well, the software will continue without updates or security patches until it breaks. Companies will have to weigh up five costs against each other: 1) The cost of the status quo: the risk of critical failures or external attacks against unsupported and unpatched software 2) The cost of migrating to Python 3 3) The cost of migrating to a completely different language 4) The cost of maintaining their own local fork of Python 2 5) The cost of using a supported commercial platform such as RHEL. For most small to medium projects, it's probably going to come down to #1 or #2, where #1 has the laziness bonus. For many larger companies, #1 is an unpayable cost. Everyone has to make that choice, and remember that "cost" doesn't just mean money (for instance, the cost of moving to Linux might be quite considerable for a Windows shop, and even within a Linux ecosystem, switching to Red Hat may have consequences to other programs you might need). ChrisA From rosuav at gmail.com Thu Jan 17 14:10:28 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jan 2019 06:10:28 +1100 Subject: Pythonic Y2K In-Reply-To: <57efad901005434f8e135f318b9abdf9@Teledyne.com> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <57efad901005434f8e135f318b9abdf9@Teledyne.com> Message-ID: On Fri, Jan 18, 2019 at 5:48 AM Schachner, Joseph wrote: > > I'd like to add one more thing to your list of what companies will have to consider: > > 6) The ability to hire and retain employees who will be happy to program in an obsolete version of Python. A version about which new books will probably not be written. A version which new packages will not support. A version which most other companies will no longer be using, so programming only in Python 2 will place the employee at a disadvantage compared to others who have gained experience with Python 3 if they ever have to change employers. > The costs I described were _alternatives_, so what you've really described here is one component of the costs of status quo, maintaining a local fork, or using commercial Py2 support (options 1, 4, and 5). It is definitely a cost, though, and may at some point become the impetus for a company to migrate to Py3... but frankly, I doubt it. "Legacy code" is a pretty big thing in a lot of places. Just search thedailywtf.com for "legacy" and you'll find plenty of stories of terrible codebases held together by duct tape and blue tack, run through a hodge-podge of different language interpreters, or even just one interpreter but the wrong one... https://thedailywtf.com/articles/VB_0x2b__0x2b_ By comparison to THAT, a "legacy system" that runs a clean Python 2.7 is going to be pretty tame. Until someone says, oh hey, we should use function annotations, and then starts running all their code (in production) via 2to3... naw, that'll never happen, right? Oh. ChrisA From ian.g.kelly at gmail.com Thu Jan 17 14:13:35 2019 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 17 Jan 2019 12:13:35 -0700 Subject: Pythonic Y2K In-Reply-To: <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> Message-ID: On Wed, Jan 16, 2019 at 9:57 PM Avi Gross wrote: > > The forthcoming UNIX 2038 problem will, paradoxically happen on January 19. I wonder what they will do long before then. Will they just add a byte or four or 256 and then make a date measurable in picoseconds? Or will they start using a number format that can easily deal with 1 Million B.C. and 5 Billion A.D. just in case we escape earth before it co-locates with the expanding sun. The obvious solution is to stop using 32-bit Unix timestamps and start using 64-bit Unix timestamps. This change has already been made in some OSes, and the problem will not repeat until the year 292,277,026,596, by which time it is highly unlikely that either Unix timestamps or humankind itself will still exist. Even if they will, that moment in time is so far out from the present that I can't really be bothered by the possibility. We have 19 years to take care of the problem before it happens. Hopefully this time around we won't be trying to fix it right up until the last minute. From PythonList at DancesWithMice.info Thu Jan 17 14:16:15 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 18 Jan 2019 08:16:15 +1300 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <00a101d4adcb$cb457480$61d05d80$@verizon.net> Message-ID: <569acb71-a5db-f5ea-7a0f-2ab8fffc63e5@DancesWithMice.info> On 17/01/19 6:10 PM, Gregory Ewing wrote: > Avi Gross wrote: >> The question that seems to come up too often about the python name is a >> distraction. In particular, it is answered fairly prominently in many >> places >> as just being a nonsensical name because a founder once liked a comedic >> entity that chose an oddball name, so they did too. > There's a long tradition of naming things after animals that have some > of the qualities you want people to associate with them. In the case > of Python, it's not a particularly fast animal, but it is sleek and > powerful, and its minimal design has a certain elegance to it. > So, I think it's very appropriate. Elsewhere there is discussion about the long tail (life) of v2. So, is there also some notion of Python shedding its skin, ie making way for newer concepts and greater consistency? (not that New Zealanders need to know much about snakes!) -- Regards =dn From arj.python at gmail.com Thu Jan 17 14:25:26 2019 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 17 Jan 2019 23:25:26 +0400 Subject: Guido (Sarducci) In-Reply-To: <39b6c577-45b1-8f7f-192a-d86c664be7a0@gmail.com> References: <003901d4ae0f$29d64e00$7d82ea00$@verizon.net> <39b6c577-45b1-8f7f-192a-d86c664be7a0@gmail.com> Message-ID: haha that list is the best py community par excellence ? Abdur-Rahmaan Janhangeer http://www.pythonmembers.club Mauritius From grant.b.edwards at gmail.com Thu Jan 17 15:05:15 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 17 Jan 2019 20:05:15 +0000 (UTC) Subject: Pythonic Y2K References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <57efad901005434f8e135f318b9abdf9@Teledyne.com> Message-ID: On 2019-01-17, Schachner, Joseph wrote: > I'd like to add one more thing to your list of what companies will have to consider: > > 6) The ability to hire and retain employees who will be happy to > program in an obsolete version of Python. A version about which > new books will probably not be written. A version which new > packages will not support. A version which most other companies > will no longer be using, so programming only in Python 2 will > place the employee at a disadvantage compared to others who have > gained experience with Python 3 if they ever have to change > employers. IMO, that's a non-issue. AFAICT, a pretty large percentage of SW developers are using obsolete or proprietary tools that aren't cool and fashionable, don't have outside support, about which books aren't being written, and for which third-party packages and libraries don't exist. I also don't think an experience Python2 developer would be turned down for a position on a project that's using Python3. -- Grant Edwards grant.b.edwards Yow! Do you guys know we at just passed thru a BLACK gmail.com HOLE in space? From stefano at stalksoft-Invalid-.Com Thu Jan 17 15:28:05 2019 From: stefano at stalksoft-Invalid-.Com (steve) Date: Thu, 17 Jan 2019 21:28:05 +0100 Subject: [tkinter] question about correct use of validation References: Message-ID: Il 17/01/19 14:08, Peter Otten ha scritto: > Two remarks: > >> self.id1_entry = self.make_entry(self.parent, maxlen=1).pack() > > You set all idX_entry attributes to None, as that's what pack() returns. you mean.. self.idx_entry = self.make_entry(self.parent, width=50, maxlen=30, highlightcolor='blue', validate='key') ? or self.idx_entry.pack() ? I did not understand :-D > >> apply(Entry.__init__, (self, master), kw) > > You can write that in way compatible with Python 3 as > > Entry.__init__(self, master, **kw) > Ok this i understood From PythonList at DancesWithMice.info Thu Jan 17 16:32:08 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 18 Jan 2019 10:32:08 +1300 Subject: the python name In-Reply-To: <6al14et67fcqm0j8k20bjcchp6eplc73n3@4ax.com> References: <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <00a101d4adcb$cb457480$61d05d80$@verizon.net> <5p8v3ep4rijg8u0kki9t8jr9ebnbjggkjv@4ax.com> <6al14et67fcqm0j8k20bjcchp6eplc73n3@4ax.com> Message-ID: <6b6dfb72-1299-f48c-29ef-d0ef6ca5ec20@DancesWithMice.info> On 18/01/19 8:20 AM, Dennis Lee Bieber wrote: > On Thu, 17 Jan 2019 18:12:33 +1300, Gregory Ewing > declaimed the following: > >> Dennis Lee Bieber wrote: >>> Getting too close to REXX (which was something like Restructured >>> EXtended eXecutor). >> >> And if we continue the theme of dinosaur evolution, we end up >> with Tyrannosaurus REXX. > > I'd propose that the Regina project be renamed to that -- one tyrant to > rule all REXX LotR reference aside, just how many pythonistas do you think also speak Latin - to be able to appreciate that joke? -- Regards =dn From rosuav at gmail.com Thu Jan 17 16:38:17 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jan 2019 08:38:17 +1100 Subject: the python name In-Reply-To: <6b6dfb72-1299-f48c-29ef-d0ef6ca5ec20@DancesWithMice.info> References: <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <00a101d4adcb$cb457480$61d05d80$@verizon.net> <5p8v3ep4rijg8u0kki9t8jr9ebnbjggkjv@4ax.com> <6al14et67fcqm0j8k20bjcchp6eplc73n3@4ax.com> <6b6dfb72-1299-f48c-29ef-d0ef6ca5ec20@DancesWithMice.info> Message-ID: On Fri, Jan 18, 2019 at 8:33 AM DL Neil wrote: > > On 18/01/19 8:20 AM, Dennis Lee Bieber wrote: > > On Thu, 17 Jan 2019 18:12:33 +1300, Gregory Ewing > > declaimed the following: > > > >> Dennis Lee Bieber wrote: > >>> Getting too close to REXX (which was something like Restructured > >>> EXtended eXecutor). > >> > >> And if we continue the theme of dinosaur evolution, we end up > >> with Tyrannosaurus REXX. > > > > I'd propose that the Regina project be renamed to that -- one tyrant to > > rule all REXX > > > LotR reference aside, just how many pythonistas do you think also speak > Latin - to be able to appreciate that joke? > "Regina" is a REXX interpreter. https://regina-rexx.sourceforge.io/ You don't necessarily have to know Latin to know about "regina" and "rex"; a bit of knowledge of royal protocol can help, or you might just recognize the parallels. But honestly, knowing a bit of Latin isn't a bad thing :) ChrisA From __peter__ at web.de Thu Jan 17 16:46:31 2019 From: __peter__ at web.de (Peter Otten) Date: Thu, 17 Jan 2019 22:46:31 +0100 Subject: [tkinter] question about correct use of validation References: Message-ID: steve wrote: > Il 17/01/19 14:08, Peter Otten ha scritto: > >> Two remarks: >> >>> self.id1_entry = self.make_entry(self.parent, maxlen=1).pack() >> >> You set all idX_entry attributes to None, as that's what pack() returns. > > you mean.. > > self.idx_entry = self.make_entry(self.parent, width=50, maxlen=30, > highlightcolor='blue', validate='key') ? > > or > > self.idx_entry.pack() ? > > I did not understand :-D Both. This > self.id1_entry = self.make_entry(self.parent, maxlen=1).pack() will assign None to self.id1_entry. You need two steps self.id1_entry = self.make_entry(...) # create widget self.id1_entry.pack() # layout widget Alternatives: - If you know that you'll always just call pack() you can change the make_entry() method accordingly def make_entry(...): ... entry.pack() return entry - Write a helper function def pack(widget): widget.pack() return widget and then use it self.id1_entry = pack(self.make_entry(...)) # create and layout widget From PythonList at DancesWithMice.info Thu Jan 17 16:47:10 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 18 Jan 2019 10:47:10 +1300 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> Message-ID: <57a2c05f-add2-1a97-bdf5-d6b40d04fc8e@DancesWithMice.info> On 17/01/19 6:53 PM, Chris Angelico wrote: > On Thu, Jan 17, 2019 at 3:55 PM Avi Gross wrote: >> The forthcoming UNIX 2038 problem will, paradoxically happen on January 19. >> > > Paradoxically? What do you mean by that? First we had to duck the Y2K problem. By moving everything to 64-bits, we duck the Unix Millennium problem. There you go: two ducks - a pair-o-ducks! I assume the paradox involves noting that the end of the (32-bit) Unix epoch, does not coincide with the end of a (Gregorian) calendar year. Actually, aren't there three date-time problems to be ducked? Wasn't Python's move to having wider timestamps (+= fractions of seconds) in part connected with the need to modify NTP - which hits the wall a few years before 2038... -- Regards =dn From rosuav at gmail.com Thu Jan 17 17:04:45 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jan 2019 09:04:45 +1100 Subject: Pythonic Y2K In-Reply-To: <57a2c05f-add2-1a97-bdf5-d6b40d04fc8e@DancesWithMice.info> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> <57a2c05f-add2-1a97-bdf5-d6b40d04fc8e@DancesWithMice.info> Message-ID: On Fri, Jan 18, 2019 at 8:47 AM DL Neil wrote: > > On 17/01/19 6:53 PM, Chris Angelico wrote: > > On Thu, Jan 17, 2019 at 3:55 PM Avi Gross wrote: > >> The forthcoming UNIX 2038 problem will, paradoxically happen on January 19. > >> > > > > Paradoxically? What do you mean by that? > > > First we had to duck the Y2K problem. > By moving everything to 64-bits, we duck the Unix Millennium problem. > > There you go: two ducks - a pair-o-ducks! Well, I'm sorry Neil, but these things are well documented. In fact, you can find information on the web, OR you can examine the man pages in your local installation. Wait, we're right back where we started... a pair-o-docs.... > I assume the paradox involves noting that the end of the (32-bit) Unix > epoch, does not coincide with the end of a (Gregorian) calendar year. Ahh yes, as paradoxical as when the Mayan Y2K happened in December of 2012. Gotcha. > Actually, aren't there three date-time problems to be ducked? Wasn't > Python's move to having wider timestamps (+= fractions of seconds) in > part connected with the need to modify NTP - which hits the wall a few > years before 2038... Oh, probably. But one of the reasons I use high level languages is so I don't have to worry about the sizes of integers. In fact, some day, we won't use floats to store seconds, we'll just use bignum integers to store some number of Planck times.... ChrisA From stefano at stalksoft-Invalid-.Com Thu Jan 17 17:05:20 2019 From: stefano at stalksoft-Invalid-.Com (steve) Date: Thu, 17 Jan 2019 23:05:20 +0100 Subject: [tkinter] question about correct use of validation References: Message-ID: >> Il 17/01/19 14:08, Peter Otten ha scritto: > Alternatives: > > - If you know that you'll always just call pack() you can change the > make_entry() method accordingly > > def make_entry(...): > ... > entry.pack() > return entry > > > - Write a helper function > > def pack(widget): > widget.pack() > return widget > > and then use it > > self.id1_entry = pack(self.make_entry(...)) # create and layout widget > > it's true! they are important things that make the difference and help in understanding. Thanks a lot of support ;-) From avigross at verizon.net Thu Jan 17 17:16:00 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 17 Jan 2019 17:16:00 -0500 Subject: Sarah Guido Message-ID: <006801d4aeb2$3a847d00$af8d7700$@verizon.net> Perhaps it is not a coincidence that I plucked the mock-suggestion to name a language Guido out of thin air. A book I ordered quite a while ago arrived. "Introduction to Machine Learning with Python: A Guide for Data Scientists" by Andreas C. M?ller and <<>> Note the last name is the same Guido we have been discussing for no meaningful reason whatsoever merely because naming after a (live) founder may not be a good reason. I tend to order books in bunches and I have no recollection of even noticing the first author, let alone the second. I have received and read many of the books on the subject that arrived first. Still, the way I read I tend to see everything around an area even if I am not consciously reading it so I suspect a subliminal recognition along with perhaps a subliminal amusement that Guido is now both the first and last name of someone I can associate with python. If I had been involved in the above book publication, I might have suggested using the word "Guide" instead of "Introduction" as it melds well with the name "Guido" so it is good nobody would even dream of asking me. Maybe her next book will be abut a GUI to DO or something that fits. P.S. This is not an endorsement of the book mentioned above nor of Machine Learning in general but IS an endorsement for using python for such things. Then again, I also endorse R as I have actually already done such things using it and want broader choices. Heck, I have already used both together. Their approaches can be maddeningly different and that opens up opportunities. -----Original Message----- From: Python-list On Behalf Of Avi Gross Sent: Wednesday, January 16, 2019 9:49 PM To: python-list at python.org Subject: Guido (Sarducci) Dennis, I wish to apologize for introducing any suggestion to name anything as Guido, let alone any language that springs from a python. Yes, it may be a stereotypic Italian name related to what you hint at. You probably recognized it as an allusion to someone who is clearly Dutch and has some finite relationship with python. The name is ultimately Germanic and used in many countries. I, in a Monty Python Spirit, insist I was thinking about the Saturday Night Live comedic character from generations ago, Father Guido Sarducci, who does indeed appear to be Italian. That is the pythonic way to choose a name although 3.X might well have been named after the Three Stooges. Again, my apologies. I will try to resume being serious and maybe talk about mission creep. Avi -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Wednesday, January 16, 2019 4:36 PM To: python-list at python.org Subject: Re: the python name On Wed, 16 Jan 2019 13:46:29 -0500, "Avi Gross" declaimed the following: >[HUMOR for the ALERT] > >But as languages develop and evolve, sometimes a name change may be a >decent idea. Perhaps version 4.0 should be renamed Guido so we can get >more silly questions. > So we can make jokes about a mafia hitman (which is where many might go with the name) > >Imagine people developing languages like X and Y and over the years >enhancing them. > >An Enhanced or Extended X, naturally, might be renamed EX. Getting too close to REXX (which was something like Restructured EXtended eXecutor). > >With further Super new features (think super-symmetry in Physics) we >would have a Super Extended X, or SEX in brief. > Computer science already has sexpr https://en.wikipedia.org/wiki/S-expression -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list From athanasios.kourpetis at gmail.com Thu Jan 17 16:59:18 2019 From: athanasios.kourpetis at gmail.com (athanasios.kourpetis at gmail.com) Date: Thu, 17 Jan 2019 13:59:18 -0800 (PST) Subject: oldschool texter GUI with python, char repeating is not working great ! Message-ID: <095e6b50-2175-4d94-9871-1e564344ae64@googlegroups.com> I have this tkinter GUI of an old school texter that runs on a Raspberry pi 3. I have 16 pressure analog pressure sensors that i am readding them through a multiplexor, and i pass there values to an ADC mcp3002. if the value pass a thresshold i consider it as a key press, and there i need some chars to roll while i have it pressed inside a text area, if the voltage passes the thresshold the other way i consider the key to be released and the last char that was inside the text area will be set at that cursor point, the cursor will move one place next, and wait untill an other press to do the same thing again. this is the code for the def : def process(value): global keypressed, keyreleased num_press=0 #message=[] #this table gets the chars. After the roll is finished the last char is appented to it. eventually this table is piped to minimodem. steps=0 i=0 x=int(value) key_pressed=x #proceedInLoop = True while True: binary_x="{0:04b}".format(x) #get the binary of x and set each 0 and 1 to the appropreate GPIO GPIO.output(26, int(binary_x[0])) GPIO.output(13, int(binary_x[1])) GPIO.output(12, int(binary_x[2])) GPIO.output(5, int(binary_x[3])) # average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] # voltage = int(round(((channeldata * vref * 2) / resolution),0))+ calibration #voltage = 6000 # temporary voltage for testing print(voltage) if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) key_pressed=x if ( voltage < 4000) : #key is released keypressed = False keyreleased = True x=x+1 if ( voltage >= 4001) : #key is pressed keypressed = True keyreleased = False key_pressed=x#define which key is pressed # print(i) if key_pressed==0: transmite(message) x=x+1 sleep(0.01) keypressed = False keyreleased = True if key_pressed==1: print('read') keypressed = False keyreleased = True if key_pressed==2: sys.stdout.write('\033[2K]') sys.stdout.write('\033[1G]') keypressed = False keyreleased = True if key_pressed==3: #print('\b\b') print('\b ', end="", flush=True) sys.stdout.write('\010') sleep(1) keypressed = False keyreleased = True if key_pressed > 3: #if key == key_pressed : while num_press <= (max_press[key_pressed]) and keyreleased==False: #average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] voltage = int(round(((channeldata*vref*2)/resolution),0))+ calibration if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) if ( voltage < 4000) : #key is released print("voltage < 4000") keyreleased = True keypressed = False sys.stdout.write('\033[1C') char=sensor[key_pressed][num_press] message.append(char) # here is the append. num_press=0 #else : #keypressed = True #keyreleased = False if num_press <= max_press[key_pressed] and keyreleased == False: top.Text1.insert("end", sensor[key_pressed][num_press] + '\n') print(sensor[key_pressed][num_press]) #text_widget.insert(INSERT, sensor[key_pressed][num_press]) #Text1.insert(INSERT, sensor[key_pressed][num_press]) sys.stdout.write('\010') num_press=num_press+1 time.sleep(0.5) if num_press == max_press[key_pressed] : #num_press=0 keyreleased = True keypressed = False #top.Text1.insert("end", sensor[key_pressed][num_press]) if x == 16 : x=0 key = key_pressed print(message) if keyreleased: break it gets the values from this set of tables : sensor16=['1','-','\\','/','*'] sensor15=['4','G','H','I'] sensor14=['7','P','Q','R','S'] sensor13=['*'] sensor12=['2','A','B','C'] sensor11=['5','J','K','L'] sensor10=['8','T','U','V'] sensor09=['0',' '] sensor08=['3','D','E','F'] sensor07=['6','M','N','O'] sensor06=['9','W','X','Y','Z'] sensor05=['#','|'] sensor04=['BACKSPACE'] sensor03=['DELETE ALL'] sensor02=['READ'] sensor01=['TRANSMITE'] sensor=[sensor01,sensor02,sensor03,sensor04, sensor05, sensor06, sensor07, sensor08, sensor09, sensor10, sensor11, sensor12, sensor13, sensor14, sensor15, sensor16] #the maximum number of times each sensor can be pressed #before it rols back to the first character. max_press=[1,1,1,1,2,5,4,4,2,4,4,4,1,5,4,5] i have a class created with buttons and everything, i have managed to make it work with real presses of mouse on the buttons but that only works for one roll, when it gets to the seccond one everything goes wild. so i am trying to to create a def that runs every 100 millisecs and check if any of those pressure sensors has passed the threshold and if yes to invoke the apropreate button and do what is all ready been doing, but from the other hand the rooling is not working great either. i pass the entire code, while i am lost here ! the code is not clean while i have a lot of things that are left there after some test and i have no idea if they supposed to leave or not. so any ideas are more than welcome while i am completly lost here . #! /usr/bin/env python # -*- coding: utf-8 -*- # # GUI module generated by PAGE version 4.19 # in conjunction with Tcl version 8.6 # Dec 27, 2018 08:20:37 PM IST platform: Windows NT import sys try: import Tkinter as tk except ImportError: import tkinter as tk try: import ttk py3 = False except ImportError: import tkinter.ttk as ttk py3 = True import time #import uinput import RPi.GPIO as GPIO import spidev # import the SPI driver from time import sleep from array import * import os import subprocess import random import time from threading import Timer from itertools import groupby import threading #initial constants here DEBUG = False vref = 3.3 * 1000 # V-Ref in mV (Vref = VDD for the MCP3002) resolution = 2**10 # for 10 bits of resolution calibration = 38 # in mV, to make up for the precision of the components GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) #for the channels of the 4067 multiplexor 16 to 1 #change the channels and pipe from the output of the multiplexer #the analog readings to the 0 channel of the MCP3002 ADC GPIO.setup(5, GPIO.OUT) GPIO.setup(12, GPIO.OUT) GPIO.setup(13, GPIO.OUT) GPIO.setup(26, GPIO.OUT) #start_time=time.time() #elapsed_time=time.time() # MCP3002 Control bits # # 7 6 5 4 3 2 1 0 # X 1 S O M X X X # # bit 6 = Start Bit # S = SGL or \DIFF SGL = 1 = Single Channel, 0 = \DIFF is pseudo differential # O = ODD or \SIGN # in Single Ended Mode (SGL = 1) # ODD 0 = CH0 = + GND = - (read CH0) # 1 = CH1 = + GND = - (read CH1) # in Pseudo Diff Mode (SGL = 0) # ODD 0 = CH0 = IN+, CH1 = IN- # 1 = CH0 = IN-, CH1 = IN+ # # M = MSBF # MSBF = 1 = LSB first format # 0 = MSB first format # ------------------------------ # SPI setup spi_max_speed = 1000000 # 1 MHz (1.2MHz = max for 2V7 ref/supply) # reason is that the ADC input cap needs time to get charged to the input level. CE = 0 # CE0 | CE1, selection of the SPI device spi = spidev.SpiDev() spi.open(0,CE) # Open up the communication to the device spi.max_speed_hz = spi_max_speed # # create a function that sets the configuration parameters and gets the results # from the MCP3002 # # key presses values key0=['0',' '] key1=['1','-','\\','/','*'] key2=['2','A','B','C'] key3=['3','D','E','F'] key4=['4','G','H','I'] key5=['5','J','K','L'] key6=['6','M','N','O'] key7=['7','P','Q','R','S'] key8=['8','T','U','V'] key9=['9','W','X','Y','Z'] key10=['*'] key11=['#','|'] keyArray = [key0,key1,key2,key3,key4,key5,key6,key7,key8,key9,key10,key11] key_max_press = [2,5,4,4,4,4,4,5,4,5,1,2] #Each analog sensor has some characters to roll sensor16=['1','-','\\','/','*'] sensor15=['4','G','H','I'] sensor14=['7','P','Q','R','S'] sensor13=['*'] sensor12=['2','A','B','C'] sensor11=['5','J','K','L'] sensor10=['8','T','U','V'] sensor09=['0',' '] sensor08=['3','D','E','F'] sensor07=['6','M','N','O'] sensor06=['9','W','X','Y','Z'] sensor05=['#','|'] sensor04=['BACKSPACE'] sensor03=['DELETE ALL'] sensor02=['READ'] sensor01=['TRANSMITE'] sensor=[sensor01,sensor02,sensor03,sensor04, sensor05, sensor06, sensor07, sensor08, sensor09, sensor10, sensor11, sensor12, sensor13, sensor14, sensor15, sensor16] #the maximum number of times each sensor can be pressed #before it rols back to the first character. max_press=[1,1,1,1,2,5,4,4,2,4,4,4,1,5,4,5] message=[] ## # main functions start here ## # read sensor data def read_mcp3002(channel): # see datasheet for more information # 8 bit control : # X, Strt, SGL|!DIFF, ODD|!SIGN, MSBF, X, X, X # 0, 1, 1=SGL, 0 = CH0 , 0 , 0, 0, 0 = 96d # 0, 1, 1=SGL, 1 = CH1 , 0 , 0, 0, 0 = 112d if channel == 0: cmd = 0b01100000 else: cmd = 0b01110000 if DEBUG : print("cmd = ", cmd) spi_data = spi.xfer2([cmd,0]) # send hi_byte, low_byte; receive hi_byte, low_byte if DEBUG : print("Raw ADC (hi-byte, low_byte) = {}".format(spi_data)) # receive data range: 000..3FF (10 bits) # MSB first: (set control bit in cmd for LSB first) # spidata[0] = X, X, X, X, X, 0, B9, B8 # spidata[1] = B7, B6, B5, B4, B3, B2, B1, B0 # LSB: mask all but B9 & B8, shift to left and add to the MSB adc_data = ((spi_data[0] & 3) << 8) + spi_data[1] return adc_data # function to transmite message def transmite_message(): messageArray = [] messageString = top.Text1.get("1.0","end") if len(messageString) > 0 : for char in messageString: messageArray.append(char) # here is the append. #print(messageArray) a = ''.join(messageArray) print(a) p1 = subprocess.Popen(["minimodem" , '--tx' , '25'], stdin=subprocess.PIPE) p1.stdin.write(bytes(a, 'UTF-8')) p1.stdin.flush() #The transmiting function def transmite(minima): a = ''.join(minima) print(a) p1 = subprocess.Popen(["minimodem" , '--tx' , '25'], stdin=subprocess.PIPE) p1.stdin.write(bytes(a, 'UTF-8')) p1.stdin.flush() # close root window def close_window(): root.destroy() # delete character def delete_char(): tempString = top.Text2.get("1.0","end") if len(tempString) > 0 : groups = groupby(tempString) result = [(label, sum(1 for _ in group)) for label, group in groups] #print (len(result)) # [('6', 2), ('#', 1), ('6', 1), ('\n', 1)] if len(result) > 1: tempValue = result[len(result)-2][0] tempCounter = result[len(result)-2][1] + 1 print(tempValue) print(tempCounter) tempString = tempString[:-tempCounter] top.Text2.delete('1.0', "end") top.Text2.insert("end", tempString) # append temporary character in invisible string def print_char(key): process(key) top.Text2.insert("end", sensor[key][0]) inputString = top.Text2.get("1.0","end") print('now i am here') # rolling character one by one def print_rolling_char(): threading.Timer(0.5, print_rolling_char).start() inputString = top.Text2.get("1.0","end") if len(inputString.rstrip()) < 1: top.Text1.delete('1.0', "end") if len(inputString) > 0 : groups = groupby(inputString) result = [(label, sum(1 for _ in group)) for label, group in groups] #print (len(result)) # [('6', 2), ('#', 1), ('6', 1), ('\n', 1)] if len(result) > 1: print('i am in len result >1 ') top.Text1.delete('1.0', "end") for x in result: tempValue = x[0] tempCounter = x[1] if tempValue != '\n' and tempValue != '|': # if tempCounter > key_max_press[int(tempCounter)]: while tempCounter > key_max_press[int(tempCounter)]: tempCounter = tempCounter - key_max_press[int(tempCounter)] print('tempCounter is ', tempCounter) print('key_max_press is ', key_max_press[int(tempCounter)]) if tempValue != '*' and tempValue != '#': charNew = keyArray[int(tempValue)][tempCounter-1] else: if tempValue == '*': charNew = keyArray[10][tempCounter-1] else: charNew = keyArray[11][tempCounter-1] if charNew != '|': top.Text1.insert("end", charNew) #message.append(charNew) # here is the append. # else: # tempCounter = x[1] # read sensors data each second def read_sensor_data(): threading.Timer(1.0, read_sensor_data).start() file = open("sensor_1.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label2.config(text = lineList[-1]) file = open("sensor_2.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label3.config(text = lineList[-1]) file = open("sensor_3.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label4.config(text = lineList[-1]) file = open("sensor_4.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label5.config(text = lineList[-1]) file = open("compass.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label1.config(text = lineList[-1]) # add separator in between same character def add_separator(self): top.Text2.insert("end", '|') # clear text area def clear_message(self): top.Text2.delete('1.0', "end") # dummy click in every 1 sec def loop_process(): threading.Timer(1.0, loop_process).start() process_for_loop() # main function to render UI screen def vp_start_gui(): '''Starting point when module is the main routine.''' global val, w, root, top root = tk.Tk() root.attributes("-fullscreen", False) top = Toplevel1 (root) print_rolling_char() loop_process() read_sensor_data() root.mainloop() w = None def create_Toplevel1(root, *args, **kwargs): '''Starting point when module is imported by another program.''' global w, w_win, rt rt = root w = tk.Toplevel (root) top = Toplevel1 (w) #unknown_support.init(w, top, *args, **kwargs) return (w, top) def destroy_Toplevel1(): global w w.destroy() w = None # main process loop def process_for_loop(): global keypressed, keyreleased, key_pressed num_press = 0 #message=[] #this table gets the chars. After the roll is finished the last char is appented to it. eventually this table is piped to minimodem. steps = 0 i = 0 for x in range(0,16): # threading.Timer(0.5, loop_process).start() key_pressed=x #proceedInLoop = True binary_x="{0:04b}".format(x) GPIO.output(26, int(binary_x[0])) GPIO.output(13, int(binary_x[1])) GPIO.output(12, int(binary_x[2])) GPIO.output(5, int(binary_x[3])) # average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] # voltage = int(round(((channeldata * vref * 2) / resolution),0))+ calibration #voltage = 6000 # temporary voltage for testing #print(voltage) if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) #key_pressed=x if ( voltage < 4000) : #key is released keypressed = False keyreleased = True x=x+1 if ( voltage >= 4001) : #key is pressed keypressed = True keyreleased = False key_pressed=x#define which key is pressed # print(i) if key_pressed==0: transmite(message) x=x+1 sleep(0.01) keypressed = False keyreleased = True if key_pressed==1: print('read') keypressed = False keyreleased = True if key_pressed==2: sys.stdout.write('\033[2K]') sys.stdout.write('\033[1G]') keypressed = False keyreleased = True if key_pressed==3: #print('\b\b') print('\b ', end="", flush=True) sys.stdout.write('\010') sleep(1) keypressed = False keyreleased = True if key_pressed > 3: #if key == key_pressed : while num_press <= (max_press[key_pressed]) and keyreleased==False: #average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] voltage = int(round(((channeldata*vref*2)/resolution),0))+ calibration if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) if ( voltage < 4000) : #key is released print("voltage < 4000") keyreleased = True keypressed = False sys.stdout.write('\033[1C') char=sensor[key_pressed][num_press] message.append(char) # here is the append. num_press=0 #else : #keypressed = True #keyreleased = False if num_press <= max_press[key_pressed] and keyreleased == False: top.Text1.insert("end", sensor[key_pressed][num_press] + '\n') print(sensor[key_pressed][num_press]) #text_widget.insert(INSERT, sensor[key_pressed][num_press]) #Text1.insert(INSERT, sensor[key_pressed][num_press]) sys.stdout.write('\010') num_press=num_press+1 time.sleep(0.5) if num_press == max_press[key_pressed] : num_press=0 keyreleased = True keypressed = False #top.Text1.insert("end", sensor[key_pressed][num_press]) key = key_pressed print(message) if keyreleased: break # open read message screen def open_reading_screen(): close_window() os.system('python3 messageread.py') #open sensor reading screen def open_sensor_reading(): close_window() os.system('python3 onescreentorule.py') # loop def process(value): global keypressed, keyreleased num_press=0 #message=[] #this table gets the chars. After the roll is finished the last char is appented to it. eventually this table is piped to minimodem. steps=0 i=0 x=int(value) key_pressed=x #proceedInLoop = True while True: binary_x="{0:04b}".format(x) #get the binary of x and set each 0 and 1 to the appropreate GPIO GPIO.output(26, int(binary_x[0])) GPIO.output(13, int(binary_x[1])) GPIO.output(12, int(binary_x[2])) GPIO.output(5, int(binary_x[3])) # average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] # voltage = int(round(((channeldata * vref * 2) / resolution),0))+ calibration #voltage = 6000 # temporary voltage for testing print(voltage) if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) key_pressed=x if ( voltage < 4000) : #key is released keypressed = False keyreleased = True x=x+1 if ( voltage >= 4001) : #key is pressed keypressed = True keyreleased = False key_pressed=x#define which key is pressed # print(i) if key_pressed==0: transmite(message) x=x+1 sleep(0.01) keypressed = False keyreleased = True if key_pressed==1: print('read') keypressed = False keyreleased = True if key_pressed==2: sys.stdout.write('\033[2K]') sys.stdout.write('\033[1G]') keypressed = False keyreleased = True if key_pressed==3: #print('\b\b') print('\b ', end="", flush=True) sys.stdout.write('\010') sleep(1) keypressed = False keyreleased = True if key_pressed > 3: #if key == key_pressed : while num_press <= (max_press[key_pressed]) and keyreleased==False: #average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] voltage = int(round(((channeldata*vref*2)/resolution),0))+ calibration if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) if ( voltage < 4000) : #key is released print("voltage < 4000") keyreleased = True keypressed = False sys.stdout.write('\033[1C') char=sensor[key_pressed][num_press] message.append(char) # here is the append. num_press=0 #else : #keypressed = True #keyreleased = False if num_press <= max_press[key_pressed] and keyreleased == False: top.Text1.insert("end", sensor[key_pressed][num_press] + '\n') print(sensor[key_pressed][num_press]) #text_widget.insert(INSERT, sensor[key_pressed][num_press]) #Text1.insert(INSERT, sensor[key_pressed][num_press]) sys.stdout.write('\010') num_press=num_press+1 time.sleep(0.5) if num_press == max_press[key_pressed] : #num_press=0 keyreleased = True keypressed = False #top.Text1.insert("end", sensor[key_pressed][num_press]) if x == 16 : x=0 key = key_pressed print(message) if keyreleased: break #proceedInLoop = False class Toplevel1: def __init__(self, top=None): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#ececec' # Closest X11 color: 'gray92' top.geometry("600x450+579+181") top.title("New Toplevel") top.configure(background="#d9d9d9") top.configure(highlightbackground="#d9d9d9") top.configure(highlightcolor="black") self.Frame1 = tk.Frame(top) self.Frame1.place(relx=0.033, rely=0.067, relheight=0.9, relwidth=0.942) self.Frame1.configure(relief='groove') self.Frame1.configure(borderwidth="2") self.Frame1.configure(relief='groove') self.Frame1.configure(background="#d9d9d9") self.Frame1.configure(highlightbackground="#d9d9d9") self.Frame1.configure(highlightcolor="black") self.Frame1.configure(width=565) self.Text1 = tk.Text(self.Frame1) self.Text1.place(relx=0.124, rely=0.148, relheight=0.281, relwidth=0.786) self.Text1.configure(background="white") self.Text1.configure(font="TkTextFont") self.Text1.configure(foreground="black") self.Text1.configure(highlightbackground="#d9d9d9") self.Text1.configure(highlightcolor="black") self.Text1.configure(insertbackground="black") self.Text1.configure(selectbackground="#c4c4c4") self.Text1.configure(selectforeground="black") self.Text1.configure(width=444) self.Text1.configure(wrap='word') self.Text2 = tk.Text(self.Frame1) self.Text2.place(relx=0.118, rely=0.287, relheight=0, relwidth=0) self.Text2.configure(background="white") self.Text2.configure(font="TkTextFont") self.Text2.configure(foreground="black") self.Text2.configure(highlightbackground="#d9d9d9") self.Text2.configure(highlightcolor="black") self.Text2.configure(insertbackground="black") self.Text2.configure(selectbackground="#c4c4c4") self.Text2.configure(selectforeground="black") self.Text2.configure(width=374) self.Text2.configure(wrap='word') #self.Text2.insert("1.0", "Hello") self.Label1 = tk.Label(self.Frame1) self.Label1.place(relx=0.035, rely=0.025, height=41, width=107) self.Label1.configure(activebackground="#f9f9f9") self.Label1.configure(activeforeground="black") self.Label1.configure(background="#d9d9d9") self.Label1.configure(disabledforeground="#a3a3a3") self.Label1.configure(foreground="#000000") self.Label1.configure(highlightbackground="#d9d9d9") self.Label1.configure(highlightcolor="black") self.Label1.configure(text='''Compass Value''') self.Label1.configure(width=107) self.Label2 = tk.Label(self.Frame1) self.Label2.place(relx=0.23, rely=0.049, height=31, width=74) self.Label2.configure(activebackground="#f9f9f9") self.Label2.configure(activeforeground="black") self.Label2.configure(background="#d9d9d9") self.Label2.configure(disabledforeground="#a3a3a3") self.Label2.configure(foreground="#000000") self.Label2.configure(highlightbackground="#d9d9d9") self.Label2.configure(highlightcolor="black") self.Label2.configure(text='''Sensor1''') self.Label3 = tk.Label(self.Frame1) self.Label3.place(relx=0.372, rely=0.049, height=31, width=104) self.Label3.configure(activebackground="#f9f9f9") self.Label3.configure(activeforeground="black") self.Label3.configure(background="#d9d9d9") self.Label3.configure(disabledforeground="#a3a3a3") self.Label3.configure(foreground="#000000") self.Label3.configure(highlightbackground="#d9d9d9") self.Label3.configure(highlightcolor="black") self.Label3.configure(text='''Sensor2''') self.Label4 = tk.Label(self.Frame1) self.Label4.place(relx=0.566, rely=0.049, height=31, width=74) self.Label4.configure(activebackground="#f9f9f9") self.Label4.configure(activeforeground="black") self.Label4.configure(background="#d9d9d9") self.Label4.configure(disabledforeground="#a3a3a3") self.Label4.configure(foreground="#000000") self.Label4.configure(highlightbackground="#d9d9d9") self.Label4.configure(highlightcolor="black") self.Label4.configure(text='''Sensor3''') self.Label5 = tk.Label(self.Frame1) self.Label5.place(relx=0.743, rely=0.049, height=31, width=74) self.Label5.configure(activebackground="#f9f9f9") self.Label5.configure(activeforeground="black") self.Label5.configure(background="#d9d9d9") self.Label5.configure(disabledforeground="#a3a3a3") self.Label5.configure(foreground="#000000") self.Label5.configure(highlightbackground="#d9d9d9") self.Label5.configure(highlightcolor="black") self.Label5.configure(text='''Sensor_4''') self.Button1 = tk.Button(self.Frame1) self.Button1.place(relx=0.142, rely=0.444, height=44, width=77) self.Button1.configure(activebackground="#ececec") self.Button1.configure(activeforeground="#000000") self.Button1.configure(background="#d9d9d9") self.Button1.configure(disabledforeground="#a3a3a3") self.Button1.configure(foreground="#000000") self.Button1.configure(highlightbackground="#d9d9d9") self.Button1.configure(highlightcolor="black") self.Button1.configure(pady="0") self.Button1.configure(text='''1 Special char''') self.Button1.configure(width=77) #self.Button1.configure(command=lambda: process(15)) self.Button1.configure(command=lambda: print_char(15)) self.Button2 = tk.Button(self.Frame1) self.Button2.place(relx=0.319, rely=0.444, height=39, width=64) self.Button2.configure(activebackground="#ececec") self.Button2.configure(activeforeground="#000000") self.Button2.configure(background="#d9d9d9") self.Button2.configure(disabledforeground="#a3a3a3") self.Button2.configure(foreground="#000000") self.Button2.configure(highlightbackground="#d9d9d9") self.Button2.configure(highlightcolor="black") self.Button2.configure(pady="0") self.Button2.configure(text='''2 ABC''') #self.Button2.configure(command=lambda: process(11), repeatdelay=500, repeatinterval=100) #self.Button2.bind('',start_process) #self.Button2.bind('',stop_process) #self.Button2.configure(command=lambda: print_char()) self.Button2.configure(command=lambda: print_char(11)) self.Button3 = tk.Button(self.Frame1) self.Button3.place(relx=0.478, rely=0.444, height=39, width=67) self.Button3.configure(activebackground="#ececec") self.Button3.configure(activeforeground="#000000") self.Button3.configure(background="#d9d9d9") self.Button3.configure(disabledforeground="#a3a3a3") self.Button3.configure(foreground="#000000") self.Button3.configure(highlightbackground="#d9d9d9") self.Button3.configure(highlightcolor="black") self.Button3.configure(pady="0") self.Button3.configure(text='''3 DEF''') self.Button3.configure(width=67) self.Button3.configure(command=lambda: print_char(7)) self.Button4 = tk.Button(self.Frame1) self.Button4.place(relx=0.637, rely=0.444, height=44, width=147) self.Button4.configure(activebackground="#ececec") self.Button4.configure(activeforeground="#000000") self.Button4.configure(background="#d9d9d9") self.Button4.configure(disabledforeground="#a3a3a3") self.Button4.configure(foreground="#000000") self.Button4.configure(highlightbackground="#d9d9d9") self.Button4.configure(highlightcolor="black") self.Button4.configure(pady="0") self.Button4.configure(text='''BACK SPACE / CLEAR ALL''') #self.Button4.configure(command=lambda: process(3)) #self.Button4.configure(command=lambda: print_char(3)) self.Button4.bind('',clear_message) self.Button4.configure(command=lambda: delete_char()) self.Button5 = tk.Button(self.Frame1) self.Button5.place(relx=0.637, rely=0.568, height=44, width=147) self.Button5.configure(activebackground="#ececec") self.Button5.configure(activeforeground="#000000") self.Button5.configure(background="#d9d9d9") self.Button5.configure(disabledforeground="#a3a3a3") self.Button5.configure(foreground="#000000") self.Button5.configure(highlightbackground="#d9d9d9") self.Button5.configure(highlightcolor="black") self.Button5.configure(pady="0") self.Button5.configure(text='''SENSOR READING''') self.Button5.configure(command=lambda: open_sensor_reading()) self.Button6 = tk.Button(self.Frame1) self.Button6.place(relx=0.637, rely=0.691, height=44, width=147) self.Button6.configure(activebackground="#ececec") self.Button6.configure(activeforeground="#000000") self.Button6.configure(background="#d9d9d9") self.Button6.configure(disabledforeground="#a3a3a3") self.Button6.configure(foreground="#000000") self.Button6.configure(highlightbackground="#d9d9d9") self.Button6.configure(highlightcolor="black") self.Button6.configure(pady="0") self.Button6.configure(text='''READ MESSAGES''') self.Button6.configure(command=lambda: open_reading_screen()) self.Button7 = tk.Button(self.Frame1) self.Button7.place(relx=0.637, rely=0.815, height=34, width=147) self.Button7.configure(activebackground="#ececec") self.Button7.configure(activeforeground="#000000") self.Button7.configure(background="#d9d9d9") self.Button7.configure(disabledforeground="#a3a3a3") self.Button7.configure(foreground="#000000") self.Button7.configure(highlightbackground="#d9d9d9") self.Button7.configure(highlightcolor="black") self.Button7.configure(pady="0") self.Button7.configure(text='''TRANSMITE''') #self.Button7.configure(command=lambda: process(0)) self.Button7.configure(command=lambda: transmite_message()) self.Button8 = tk.Button(self.Frame1) self.Button8.place(relx=0.142, rely=0.568, height=39, width=74) self.Button8.configure(activebackground="#ececec") self.Button8.configure(activeforeground="#000000") self.Button8.configure(background="#d9d9d9") self.Button8.configure(disabledforeground="#a3a3a3") self.Button8.configure(foreground="#000000") self.Button8.configure(highlightbackground="#d9d9d9") self.Button8.configure(highlightcolor="black") self.Button8.configure(pady="0") self.Button8.configure(text='''4 GHI''') self.Button8.configure(width=74) #self.Button8.configure(command=lambda: process(14)) self.Button8.configure(command=lambda: print_char(14)) self.Button9 = tk.Button(self.Frame1) self.Button9.place(relx=0.319, rely=0.568, height=39, width=61) self.Button9.configure(activebackground="#ececec") self.Button9.configure(activeforeground="#000000") self.Button9.configure(background="#d9d9d9") self.Button9.configure(disabledforeground="#a3a3a3") self.Button9.configure(foreground="#000000") self.Button9.configure(highlightbackground="#d9d9d9") self.Button9.configure(highlightcolor="black") self.Button9.configure(pady="0") self.Button9.configure(text='''5 JKL''') self.Button9.configure(width=61) #self.Button9.configure(command=lambda: process(10)) self.Button9.configure(command=lambda: print_char(10)) self.Button10 = tk.Button(self.Frame1) self.Button10.place(relx=0.478, rely=0.568, height=39, width=63) self.Button10.configure(activebackground="#ececec") self.Button10.configure(activeforeground="#000000") self.Button10.configure(background="#d9d9d9") self.Button10.configure(disabledforeground="#a3a3a3") self.Button10.configure(foreground="#000000") self.Button10.configure(highlightbackground="#d9d9d9") self.Button10.configure(highlightcolor="black") self.Button10.configure(pady="0") self.Button10.configure(text='''6 MNO''') self.Button10.configure(width=63) #self.Button10.configure(command=lambda: print_char(6)) self.Button10.configure(command=lambda: print_char(6)) self.Button11 = tk.Button(self.Frame1) self.Button11.place(relx=0.142, rely=0.691, height=39, width=77) self.Button11.configure(activebackground="#ececec") self.Button11.configure(activeforeground="#000000") self.Button11.configure(background="#d9d9d9") self.Button11.configure(disabledforeground="#a3a3a3") self.Button11.configure(foreground="#000000") self.Button11.configure(highlightbackground="#d9d9d9") self.Button11.configure(highlightcolor="black") self.Button11.configure(pady="0") self.Button11.configure(text='''7 PQR''') self.Button11.configure(width=77) #self.Button11.configure(command=lambda: process(13)) self.Button11.configure(command=lambda: print_char(13)) self.Button12 = tk.Button(self.Frame1) self.Button12.place(relx=0.319, rely=0.691, height=39, width=62) self.Button12.configure(activebackground="#ececec") self.Button12.configure(activeforeground="#000000") self.Button12.configure(background="#d9d9d9") self.Button12.configure(disabledforeground="#a3a3a3") self.Button12.configure(foreground="#000000") self.Button12.configure(highlightbackground="#d9d9d9") self.Button12.configure(highlightcolor="black") self.Button12.configure(pady="0") self.Button12.configure(text='''8 STUV''') #self.Button12.configure(command=lambda: process(9)) self.Button12.configure(command=lambda: print_char(9)) self.Button13 = tk.Button(self.Frame1) self.Button13.place(relx=0.478, rely=0.691, height=39, width=66) self.Button13.configure(activebackground="#ececec") self.Button13.configure(activeforeground="#000000") self.Button13.configure(background="#d9d9d9") self.Button13.configure(disabledforeground="#a3a3a3") self.Button13.configure(foreground="#000000") self.Button13.configure(highlightbackground="#d9d9d9") self.Button13.configure(highlightcolor="black") self.Button13.configure(pady="0") self.Button13.configure(text='''9 WXYZ''') self.Button13.configure(width=66) #self.Button13.configure(command=lambda: process(5)) self.Button13.configure(command=lambda: print_char(5)) self.Button14 = tk.Button(self.Frame1) self.Button14.place(relx=0.142, rely=0.815, height=34, width=82) self.Button14.configure(activebackground="#ececec") self.Button14.configure(activeforeground="#000000") self.Button14.configure(background="#d9d9d9") self.Button14.configure(disabledforeground="#a3a3a3") self.Button14.configure(foreground="#000000") self.Button14.configure(highlightbackground="#d9d9d9") self.Button14.configure(highlightcolor="black") self.Button14.configure(pady="0") self.Button14.configure(text='''*''') self.Button14.configure(width=82) #self.Button14.configure(command=close_window) #self.Button14.configure(command=lambda: process(12)) self.Button14.configure(command=lambda: print_char(12)) self.Button15 = tk.Button(self.Frame1) self.Button15.place(relx=0.319, rely=0.815, height=39, width=66) self.Button15.configure(activebackground="#ececec") self.Button15.configure(activeforeground="#000000") self.Button15.configure(background="#d9d9d9") self.Button15.configure(disabledforeground="#a3a3a3") self.Button15.configure(foreground="#000000") self.Button15.configure(highlightbackground="#d9d9d9") self.Button15.configure(highlightcolor="black") self.Button15.configure(pady="0") self.Button15.configure(text='''0 SPACE''') self.Button15.configure(width=66) #self.Button15.configure(command=lambda: process(8)) self.Button15.configure(command=lambda: print_char(8)) self.Button16 = tk.Button(self.Frame1) self.Button16.place(relx=0.478, rely=0.815, height=34, width=58) self.Button16.configure(activebackground="#ececec") self.Button16.configure(activeforeground="#000000") self.Button16.configure(background="#d9d9d9") self.Button16.configure(disabledforeground="#a3a3a3") self.Button16.configure(foreground="#000000") self.Button16.configure(highlightbackground="#d9d9d9") self.Button16.configure(highlightcolor="black") self.Button16.configure(pady="0") self.Button16.configure(text='''# >''') self.Button16.configure(width=58) #self.Button16.bind('',add_separator) self.Button16.configure(command=lambda: print_char(4)) #self.Button16.configure(command=lambda: process(4)) num_press=0 message=[] steps=0 i=0 x=0 key_pressed=x #message_string=" #print(message_string) #p1 = subprocess.Popen(["minimodem" , '--tx' , '300'], stdin=subprocess.PIPE) #p1.stdin.write(bytes(message_ if __name__ == '__main__': vp_start_gui() please help ! From avigross at verizon.net Thu Jan 17 17:37:17 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 17 Jan 2019 17:37:17 -0500 Subject: Pythonic Y2K In-Reply-To: <57efad901005434f8e135f318b9abdf9@Teledyne.com> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <57efad901005434f8e135f318b9abdf9@Teledyne.com> Message-ID: <007201d4aeb5$338d5140$9aa7f3c0$@verizon.net> Well said, Joseph. Unfortunately, many companies are run these days with a view toward the IMMEDIATE bottom line. I mean numbers like revenues or expenses are seen short-term. If a project stops development on new things and spends time redoing old things, there are expenses recorded with no revenues. Another organization might go ahead and get up to date and a few years down the road their projects are sailing along while the first employer keeps running into obstacles and is not able to get new developments and so on. But often, the manager making the decision will have taken their bonus or promotion and perhaps moved on or retired. Not to be political, I note many government entities, especially including the state I live in, have gigantic pension obligations they have no easy way to meet. Over the years in negotiations with unions they have often traded rich promises for the future instead of immediate pay hikes. The costs may largely be invisible and did not impact their current budgets so they could waste money on other things such as giveaways that help them get re-elected to ever higher office. But the costs are getting very visible now, and especially when the stocks they invest in decline. Back in the computer world, Y2K gave such managers some cover. There was a FIRM deadline. I wonder how many used the impending arrival of the year 2000 as an excuse to perhaps clean up other parts of their act and charge it to prevention. I mean they might suggest they rewrite some legacy COBOL or even machine language programs into something more modern or other improvements like getting a new database including new hardware. I also wonder if jobs for some programmers declined sharply in the years after when not only were they not desperately needed, but perhaps not needed at all unless they developed new talents. Just FYI, the name Y2K always struck me as similar nonsense. They abbreviated Year and 2000 from at least 8 characters to 3 and did it wrong as 2K is 2048. As far as I know, nothing special will happen in 2048 and I also have no special vision for 2020. -----Original Message----- From: Python-list On Behalf Of Schachner, Joseph Sent: Thursday, January 17, 2019 1:46 PM To: Python Subject: RE: Pythonic Y2K I'd like to add one more thing to your list of what companies will have to consider: 6) The ability to hire and retain employees who will be happy to program in an obsolete version of Python. A version about which new books will probably not be written. A version which new packages will not support. A version which most other companies will no longer be using, so programming only in Python 2 will place the employee at a disadvantage compared to others who have gained experience with Python 3 if they ever have to change employers. --- Joseph S. -----Original Message----- From: Chris Angelico Sent: Wednesday, January 16, 2019 2:15 PM To: Python Subject: Re: Pythonic Y2K On Thu, Jan 17, 2019 at 6:04 AM Avi Gross wrote: > > I see messages like the following where someone is still asking how to > do something in some version of python 2.X. > > I recall the days before the year 2000 with the Y2K scare when people > worried that legacy software might stop working or do horrible things > once the clock turned. It may even have been scary enough for some > companies to rewrite key applications and even switch from languages like COBOL. > > What is happening in the python community, and especially in places > where broken software may be a serious problem? > > I assume versions of python 2.X will continue to be available for some > time but without any further support and without features being back-ported. Commercial support for Python 2 will probably continue for a while, in the same way that support for versions older than 2.7 is still available to Red Hat customers today (if I'm not mistaken). Otherwise, well, the software will continue without updates or security patches until it breaks. Companies will have to weigh up five costs against each other: 1) The cost of the status quo: the risk of critical failures or external attacks against unsupported and unpatched software 2) The cost of migrating to Python 3 3) The cost of migrating to a completely different language 4) The cost of maintaining their own local fork of Python 2 5) The cost of using a supported commercial platform such as RHEL. For most small to medium projects, it's probably going to come down to #1 or #2, where #1 has the laziness bonus. For many larger companies, #1 is an unpayable cost. Everyone has to make that choice, and remember that "cost" doesn't just mean money (for instance, the cost of moving to Linux might be quite considerable for a Windows shop, and even within a Linux ecosystem, switching to Red Hat may have consequences to other programs you might need). ChrisA -- https://mail.python.org/mailman/listinfo/python-list From avigross at verizon.net Thu Jan 17 17:45:54 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 17 Jan 2019 17:45:54 -0500 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> Message-ID: <007301d4aeb6$679f6fd0$36de4f70$@verizon.net> Ian, You just scared me. It is 2019 which has four digits. In less than 8,000 years we will need to take the fifth to make numbers from 10,000 to 10,999. 90,000 years later we will need a sixth digit and so on. Do you know how many potential Y2K-like anomalies we may have between now and year 292,277,026,596 when it may all be over? Will people evert learn and just set aside lots of room that dates can grow into or allow varying lengths? Makes me wonder though why anyone in the distant future would want numbers that long to represent that date. I suspect that long before then, some surviving members of whatever the human race becomes will do a reset to a new calendar such as the date the first settlers arrived in the Gamma Quadrant. So whatever unit they store time in, though, may still need a way to reach back to historic times just as we do by talking about what may have happened in 2000 B.C. -----Original Message----- From: Python-list On Behalf Of Ian Kelly Sent: Thursday, January 17, 2019 2:14 PM To: Python Subject: Re: Pythonic Y2K On Wed, Jan 16, 2019 at 9:57 PM Avi Gross wrote: > > The forthcoming UNIX 2038 problem will, paradoxically happen on > January 19. I wonder what they will do long before then. Will they just add a byte or four or 256 and then make a date measurable in picoseconds? Or will they start using a number format that can easily deal with 1 Million B.C. and 5 Billion A.D. just in case we escape earth before it co-locates with the expanding sun. The obvious solution is to stop using 32-bit Unix timestamps and start using 64-bit Unix timestamps. This change has already been made in some OSes, and the problem will not repeat until the year 292,277,026,596, by which time it is highly unlikely that either Unix timestamps or humankind itself will still exist. Even if they will, that moment in time is so far out from the present that I can't really be bothered by the possibility. We have 19 years to take care of the problem before it happens. Hopefully this time around we won't be trying to fix it right up until the last minute. -- https://mail.python.org/mailman/listinfo/python-list From ibrewster at flyravn.com Thu Jan 17 18:18:43 2019 From: ibrewster at flyravn.com (Israel Brewster) Date: Thu, 17 Jan 2019 23:18:43 +0000 Subject: AssertionError without traceback? In-Reply-To: <87zhs25px1.fsf@handshake.de> References: <87zhs25px1.fsf@handshake.de> Message-ID: <3B8F4D00-5BD7-4012-AB44-AB3426C9525D@flyravn.com> > On Jan 14, 2019, at 10:40 PM, dieter wrote: > > Israel Brewster writes: >> I have a flask application deployed on CentOS 7 using Python 3.6.7 and uwsgi 2.0.17.1, proxied behind nginx. uwsgi is configured to listed on a socket in /tmp. The app uses gevent and the flask_uwsgi_websockets plugin as well as various other third-party modules, all installed via pip in a virtualenv. The environment was set up using pip just a couple of days ago, so everything should be fully up-to-date. The application *appears* to be running properly (it is in moderate use and there have been no reports of issues, nor has my testing turned up any problems), however I keep getting entries like the following in the error log: >> >> AssertionError >> 2019-01-14T19:16:32Z failed with AssertionError > > I would try to find out where the log message above has been generated > and ensure it does not only log the information above but also the > associated traceback. > > I assume that the log comes from some framework -- maybe "uwsgi" > or "gevent". It is a weakness to log exceptions without the > associated traceback. After extensive debugging, it would appear the issue arrises due to a combination of my use of gevent.spawn to run a certain function, and the portion of that function that sends web socket messages. If I remove either the gevent.spawn and just call the function directly, or keep the gevent.spawn but don't try to send any messages via web sockets, the error goes away. With the combination, I *occasionally* get the message - most of the time it works. So I guess I just run everything synchronously for now, and as log as the performance isn't hurt noticeably, call it good. I still find it strange that this never happened on CentOS 6, but whatever. The gevent.spawn calls were probably pre-mature optimization anyway. > >> There is no additional information provided, just that. I was running the same app (checked out from a GIT repository, so exact same code) on CentOS 6 for years without issue, it was only since I moved to CentOS 7 that I've seen the errors. I have not so far been able to correlate this error with any specific request. Has anyone seen anything like this before such that you can give me some pointers to fixing this? As the application *appears* to be functioning normally, it may not be a big issue, but it has locked up once since the move (no errors in the log, just not responding on the socket), so I am a bit concerned. >> ----------------------------------------------- >> Israel Brewster >> Systems Analyst II >> 5245 Airport Industrial Rd >> Fairbanks, AK 99709 >> (907) 450-7293 >> ----------------------------------------------- >> >> [cid:05a3a602-0c27-4749-91b8-096a5857d984 at flyravn.com] >> >> >> >> [cid:bbc82752-6db4-44cf-b919-421ed304e1d1 at flyravn.com] > > -- > https://mail.python.org/mailman/listinfo/python-list From athanasios.kourpetis at gmail.com Thu Jan 17 18:17:08 2019 From: athanasios.kourpetis at gmail.com (athanasios.kourpetis at gmail.com) Date: Thu, 17 Jan 2019 15:17:08 -0800 (PST) Subject: oldschool texter GUI with python, char repeating is not working great ! In-Reply-To: <095e6b50-2175-4d94-9871-1e564344ae64@googlegroups.com> References: <095e6b50-2175-4d94-9871-1e564344ae64@googlegroups.com> Message-ID: <107b1c30-6abe-4619-8c8d-5a9c021c7d66@googlegroups.com> i just uploaded everything on github https://github.com/kourpetis/python_old_school_texter From PythonList at DancesWithMice.info Thu Jan 17 22:35:00 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 18 Jan 2019 16:35:00 +1300 Subject: Pythonic Y2K In-Reply-To: <007201d4aeb5$338d5140$9aa7f3c0$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <57efad901005434f8e135f318b9abdf9@Teledyne.com> <007201d4aeb5$338d5140$9aa7f3c0$@verizon.net> Message-ID: <1fba46b9-4dd6-18ac-6388-ecd140ec8cc1@DancesWithMice.info> > Back in the computer world, Y2K gave such managers some cover. There was a > FIRM deadline. I wonder how many used the impending arrival of the year 2000 > as an excuse to perhaps clean up other parts of their act and charge it to > prevention. I mean they might suggest they rewrite some legacy COBOL or even > machine language programs into something more modern or other improvements > like getting a new database including new hardware. Of course we did! However, as pointed-out elsewhere, sometimes the costs of re-writing seemed less than those required to ameliorate any number of unknown issues in the legacy code. Remembering that we would also remove unneeded cruft, and (usually) add features needed for 'today's use'. What were you saying about politicians 'playing' with retirement funds and public money? The other advantage to a re-write decision was even more under-hand: once agreed, that became a dev project (with a 31Dec1999 drop-dead deadline) and was NO LONGER part of the Y2K project, ie no longer 'my problem'! I recall at least one project where the users over-egged their case (IMHO), taking the dev option even against my advice. They failed to make the deadline. Let's just say, on their part, there was a lot of fancy-footwork during the first days of 2000... > I also wonder if jobs for some programmers declined sharply in the years > after when not only were they not desperately needed, but perhaps not needed > at all unless they developed new talents. No, quite the opposite. What happened was that many other projects were put-off pending Y2K amelioration. Once we could release staff, they were greeted with open arms, and often far, far, greater appreciation than normally meets a new dev upon arrival. > Just FYI, the name Y2K always struck me as similar nonsense. They > abbreviated Year and 2000 from at least 8 characters to 3 and did it wrong > as 2K is 2048. As far as I know, nothing special will happen in 2048 and I > also have no special vision for 2020. You don't seem to understand journalism: Never let the truth (facts) interfere with a 'good story'! I was just talking with a (tech) librarian, who had asked me about "the Unix Millennium bug" a few weeks ago, and mentioned this thread. He groaned, wondering how long it will be before some hack writes a sensationalist book with which to greet the end of the (binary) world... My play-time this afternoon will involve using Python to keep (time-code) track of when/where to superimpose components into a video stream... (I should be back before 2038) -- Regards =dn From kai.peters at gmail.com Thu Jan 17 23:55:52 2019 From: kai.peters at gmail.com (TUA) Date: Thu, 17 Jan 2019 20:55:52 -0800 (PST) Subject: TKinter Newbie question Message-ID: Why does the button frame in the code below not show? I intend to have it displayed in between the notebook at the top and the fake statusbar at the bottom. Thanks for any help! from tkinter import ttk import tkinter as tk class MainForm(): def __init__(self, master): self.master = master self.master.title('Test') nb = ttk.Notebook(self.master) page_1 = ttk.Frame(nb) nframe = ttk.LabelFrame(page_1, text='Frame', padding = 10) tk.Label(nframe, padx = 10, pady = 5, text = 'Name').pack() tk.Entry(nframe, width = 30).pack() tk.Label(nframe, padx = 10, pady = 5, text = 'City').pack() tk.Entry(nframe, width = 30).pack() # nframe.pack(fill="both", expand="yes", padx = 10, pady = 10) # pad around the frame nb.add(page_1, text = 'Tab #1') nb.pack(expand = True, fill = "both") #------------------------------------------------------------------------------------------- # button frame for Help button >>>>>>>> why does it not show? <<<<<<<<<<<<<<<<<<<< #------------------------------------------------------------------------------------------- bf = ttk.Frame(self.master, relief = tk.SUNKEN) tk.Button(bf, padx = 10, relief = tk.GROOVE, text = 'Help') bf.pack(side = tk.BOTTOM, fill = tk.X) #------------------------------------------------------------------------------------------- # fake a status bar from a label #------------------------------------------------------------------------------------------- sb = tk.Label(self.master, text = ' Waiting for rain ...', bd = 1, anchor = tk.W, relief = tk.SUNKEN) sb.pack(side = tk.BOTTOM, fill = tk.X) def CloseApplication(self): self.master.destroy() def StartApplication(): root = tk.Tk() MainForm(root) root.mainloop() if __name__ == '__main__': StartApplication() From dieter at handshake.de Fri Jan 18 02:38:35 2019 From: dieter at handshake.de (dieter) Date: Fri, 18 Jan 2019 08:38:35 +0100 Subject: python package management confusion References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> Message-ID: <875zum8lfo.fsf@handshake.de> dcs3spp via Python-list writes: > ... > How do I configure setuptools to pull my own private dependency package using virtualenv + python setup.py develop You call "python setup.py develop" for your own package (which the "python" from the virtualenv). This makes your package (more precisely, the one whose "setup.py" you have activated) available in the virtualenv. The "making available" happens in a way, that Python is actually using your package's source tree; thus, modifications in this source tree are seen by Python (either the next "run" or via "importlib.reload"). From __peter__ at web.de Fri Jan 18 02:50:37 2019 From: __peter__ at web.de (Peter Otten) Date: Fri, 18 Jan 2019 08:50:37 +0100 Subject: TKinter Newbie question References: Message-ID: TUA wrote: > Why does the button frame in the code below not show? > tk.Button(bf, padx = 10, relief = tk.GROOVE, text = 'Help') You forgot to layout it with .pack(). > I intend to have it displayed in between the notebook at the top and the > fake statusbar at the bottom. I think for that you need to swap the sb.pack() and bf.pack() calls, or remove side=BOTTOM from bf.pack(). From David.Raymond at tomtom.com Fri Jan 18 09:19:10 2019 From: David.Raymond at tomtom.com (David Raymond) Date: Fri, 18 Jan 2019 14:19:10 +0000 Subject: Pythonic Y2K In-Reply-To: <007301d4aeb6$679f6fd0$36de4f70$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> <004e01d4ae20$b1b2f970$1518ec50$@verizon.net> <007301d4aeb6$679f6fd0$36de4f70$@verizon.net> Message-ID: Which brings up the assumption that this whole A.D. thing is gonna stick around for more than a few millennia and isn't just a fad. Sloppy to just use positive for A.D. and negative for B.C. without a discrete unit for Age. What happens when Sauron is defeated and the Third Age is declared? Or if we go back to "in the 65th year of the reign of Elizabeth, second of her name"? Or if someone declares a new epoch and that this is really the year 49 A.U. (Anno Unixy)? -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Avi Gross Sent: Thursday, January 17, 2019 5:46 PM To: python-list at python.org Subject: RE: Pythonic Y2K Ian, You just scared me. It is 2019 which has four digits. In less than 8,000 years we will need to take the fifth to make numbers from 10,000 to 10,999. 90,000 years later we will need a sixth digit and so on. Do you know how many potential Y2K-like anomalies we may have between now and year 292,277,026,596 when it may all be over? Will people evert learn and just set aside lots of room that dates can grow into or allow varying lengths? Makes me wonder though why anyone in the distant future would want numbers that long to represent that date. I suspect that long before then, some surviving members of whatever the human race becomes will do a reset to a new calendar such as the date the first settlers arrived in the Gamma Quadrant. So whatever unit they store time in, though, may still need a way to reach back to historic times just as we do by talking about what may have happened in 2000 B.C. -----Original Message----- From: Python-list On Behalf Of Ian Kelly Sent: Thursday, January 17, 2019 2:14 PM To: Python Subject: Re: Pythonic Y2K On Wed, Jan 16, 2019 at 9:57 PM Avi Gross wrote: > > The forthcoming UNIX 2038 problem will, paradoxically happen on > January 19. I wonder what they will do long before then. Will they just add a byte or four or 256 and then make a date measurable in picoseconds? Or will they start using a number format that can easily deal with 1 Million B.C. and 5 Billion A.D. just in case we escape earth before it co-locates with the expanding sun. The obvious solution is to stop using 32-bit Unix timestamps and start using 64-bit Unix timestamps. This change has already been made in some OSes, and the problem will not repeat until the year 292,277,026,596, by which time it is highly unlikely that either Unix timestamps or humankind itself will still exist. Even if they will, that moment in time is so far out from the present that I can't really be bothered by the possibility. We have 19 years to take care of the problem before it happens. Hopefully this time around we won't be trying to fix it right up until the last minute. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list From simonppears at googlemail.com Fri Jan 18 09:52:10 2019 From: simonppears at googlemail.com (dcs3spp) Date: Fri, 18 Jan 2019 06:52:10 -0800 (PST) Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> <875zum8lfo.fsf@handshake.de> Message-ID: On Friday, 18 January 2019 07:39:00 UTC, dieter wrote: > dcs3spp via Python-list writes: > > ... > > How do I configure setuptools to pull my own private dependency package using virtualenv + python setup.py develop > > > You call "python setup.py develop" for your own package > (which the "python" from the virtualenv). > > This makes your package (more precisely, the one whose "setup.py" > you have activated) available in the virtualenv. > The "making available" happens in a way, that Python is actually > using your package's source tree; thus, modifications in this > source tree are seen by Python (either the next "run" or via > "importlib.reload"). Thanks dieter I understand that is the case if I have one project and have tried it and that works fine. My situation is similar to the following.... Assume the following two privately developed projects that I have written, each with their own setup.py: 1. parent exists in folder $HOME/project/ 2. child exists in folder $HOME/a_different_project/ *child could be also be used by other projects in the future.... parent has a dependency requirement on child and so child is listed as an install dependency in parent setup.py if I try python setup.py develop from parent project it fails to find child dependency on build. I have created a github project to illustrate the scenario @ https://github.com/dcs3spp/setuptools_dependency_example From torriem at gmail.com Fri Jan 18 10:36:14 2019 From: torriem at gmail.com (Michael Torrie) Date: Fri, 18 Jan 2019 08:36:14 -0700 Subject: Pythonic Y2K In-Reply-To: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> Message-ID: On 01/16/2019 12:02 PM, Avi Gross wrote: > I recall the days before the year 2000 with the Y2K scare when people > worried that legacy software might stop working or do horrible things once > the clock turned. It may even have been scary enough for some companies to > rewrite key applications and even switch from languages like COBOL. Of course it wasn't just a scare. The date rollover problem was very real. It's interesting that now we call it the Y2K "scare" and since most things came through that okay we often suppose that the people who were warning about this impending problem were simply being alarmist and prophets of doom. We often deride them. But the fact is, people did take these prophets of doom seriously and there was a massive, even heroic effort, to fix a lot of these critical backend systems so that disaster was avoided (just barely). I'm not talking about PCs rolling over to 00. I'm talking about banking software, mission critical control software. It certainly was scary enough for a lot of companies to spend a lot of money rewriting key software. The problem wasn't with COBOL necessarily. In the end disaster was averted (rather narrowly) thanks to the hard work of a lot of people, and thanks to the few people who were vocal in warning of the impending issue. That said, I'm not sure Python 2.7's impending EOL is comparable to the Y2K crisis. From larry.martell at gmail.com Fri Jan 18 10:47:19 2019 From: larry.martell at gmail.com (Larry Martell) Date: Fri, 18 Jan 2019 10:47:19 -0500 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> Message-ID: On Fri, Jan 18, 2019 at 10:43 AM Michael Torrie wrote: > > On 01/16/2019 12:02 PM, Avi Gross wrote: > > I recall the days before the year 2000 with the Y2K scare when people > > worried that legacy software might stop working or do horrible things once > > the clock turned. It may even have been scary enough for some companies to > > rewrite key applications and even switch from languages like COBOL. > > Of course it wasn't just a scare. The date rollover problem was very > real. It's interesting that now we call it the Y2K "scare" and since > most things came through that okay we often suppose that the people who > were warning about this impending problem were simply being alarmist and > prophets of doom. We often deride them. But the fact is, people did > take these prophets of doom seriously and there was a massive, even > heroic effort, to fix a lot of these critical backend systems so that > disaster was avoided (just barely). I'm not talking about PCs rolling > over to 00. I'm talking about banking software, mission critical > control software. It certainly was scary enough for a lot of companies > to spend a lot of money rewriting key software. The problem wasn't with > COBOL necessarily. I had one client, a hedge fund, that I fixed literally 1000's of Y2K issues for. When Y2K came and there were no problems, the owner said to me "You made such a big deal about the Y2K thing, and nothing happened." From shakti.shrivastava13 at gmail.com Fri Jan 18 12:16:59 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Fri, 18 Jan 2019 22:46:59 +0530 Subject: mocking for get method in requests Message-ID: Hello people, I noticed something weird (weird as per my current knowledge, though I know its subjective) today. sample.py file -- import requests def random_testing(): out = requests.get('www.cisco.com') a = out.json() return a testing.py file -- @patch(*?*sample.requests') def test_random_testing(self, mock_req): mock_req.get('').return_value = 'Hello' out = api.random_testing() Patching the sample.requests in this way does not lead the output of requests.get() function in sample.py file to be ?Hello? as indicated in mock_req.get('').return_value = 'Hello' Instead, it creates a new field called return_value in ?out', and hence out.return_value is ?Hello? instead of just ?out?. But if I patch it as, @patch(*?*sample.requests') def test_random_testing(self, mock_req): mock_req.get.return_value = 'Hello' out = api.random_testing() It does give the value of ?out? as ?Hello? in sample.py file. I know I am missing something, which is where I need some help :) Thanks. -- UG, CSE, RVCE, Bengaluru. From David.Raymond at tomtom.com Fri Jan 18 12:21:13 2019 From: David.Raymond at tomtom.com (David Raymond) Date: Fri, 18 Jan 2019 17:21:13 +0000 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> Message-ID: Reminds me of a similar problem that didn't get noticed until it did actually hit: In 2007 the first time a group of F-22's crossed the international date line every computer system in the aircraft crashed, losing comms, navigation, avionics, and a host of other systems. Fortunately their engines, landing gear, and enough other systems still worked, so they were able to visually follow their refueling tankers back to Hawaii and land, where they had to sit for a couple days before Lockheed could patch their software. If the circumstances had been a little different they could have lost a whole group of shiny new $150 million aircraft to a software bug and left a bunch a pilots floating in life rafts for a while in the middle of the Pacific. -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Michael Torrie Sent: Friday, January 18, 2019 10:36 AM To: python-list at python.org Subject: Re: Pythonic Y2K On 01/16/2019 12:02 PM, Avi Gross wrote: > I recall the days before the year 2000 with the Y2K scare when people > worried that legacy software might stop working or do horrible things once > the clock turned. It may even have been scary enough for some companies to > rewrite key applications and even switch from languages like COBOL. Of course it wasn't just a scare. The date rollover problem was very real. It's interesting that now we call it the Y2K "scare" and since most things came through that okay we often suppose that the people who were warning about this impending problem were simply being alarmist and prophets of doom. We often deride them. But the fact is, people did take these prophets of doom seriously and there was a massive, even heroic effort, to fix a lot of these critical backend systems so that disaster was avoided (just barely). I'm not talking about PCs rolling over to 00. I'm talking about banking software, mission critical control software. It certainly was scary enough for a lot of companies to spend a lot of money rewriting key software. The problem wasn't with COBOL necessarily. In the end disaster was averted (rather narrowly) thanks to the hard work of a lot of people, and thanks to the few people who were vocal in warning of the impending issue. That said, I'm not sure Python 2.7's impending EOL is comparable to the Y2K crisis. -- https://mail.python.org/mailman/listinfo/python-list From grant.b.edwards at gmail.com Fri Jan 18 13:10:03 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 18 Jan 2019 18:10:03 +0000 (UTC) Subject: Pythonic Y2K References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <57efad901005434f8e135f318b9abdf9@Teledyne.com> <007201d4aeb5$338d5140$9aa7f3c0$@verizon.net> <1fba46b9-4dd6-18ac-6388-ecd140ec8cc1@DancesWithMice.info> <3t444el8k6vngt5hnmblb6p0k16g3toihk@4ax.com> Message-ID: On 2019-01-18, Dennis Lee Bieber wrote: > Hey... I'm still waiting for a novelization of the TRS-DOS date "bug". > TRS-DOS directory structure only allocated 3-bits for the year. Three bits for the year? they didn't expect those computers to last long, eh? [My current Thinkpad is over 10 years old.] -- Grant Edwards grant.b.edwards Yow! BARBARA STANWYCK makes at me nervous!! gmail.com From none at invalid.com Fri Jan 18 13:18:40 2019 From: none at invalid.com (mm0fmf) Date: Fri, 18 Jan 2019 18:18:40 +0000 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <003801d4ae0d$1b6356d0$522a0470$@verizon.net> Message-ID: On 17/01/2019 02:34, Avi Gross wrote: > > but all it took was to set the clock forward on a test system and > look for anomalies. You're new to programming or you're not very old and certainly haven't run much pre-Y2k software. ;-) Issues that needed solving: 2 digits only for the date use of 99 or 00 in the year for "magic" purposes software that didn't know 2000 was a leap year One machine I had to update (all in Z80 assembler) had the date in the format DD-MMM-199Y, i.e. only the units year could be changed. There was a comment in the date code saying ; marketing say this machine will stop being sold in 1993 so there ; is no need to support anything other than 1990-1999 in the year It was still being sold in 2002! The reason there were so few Y2K issues was that things were fixed in advance. And yes, there was also lots of stupidity and hysterics from people who didn't know. One major change, after people started fixing this in issue in earnest, dates started to always include the century digits. Now get off my lawn! :-) From avigross at verizon.net Fri Jan 18 14:45:48 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 18 Jan 2019 14:45:48 -0500 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> Message-ID: <000001d4af66$69757f60$3c607e20$@verizon.net> Michael, I certainly agree with you on most of what you said. My internal humor makes me see patterns that are not at all applicable. Such as the common "2" in python 2.X and Y2K which influence my choice of phrases. And, perhaps even more oddly, I see Y and K in both Y2K and the slightly odd spelling of pYthoniK, and even 2/to. Just the way my mind works as it searches for patterns knowing that most of them do not really exist and then trying to winnow it down to those that do. Can't expect anyone to follow and would be afraid of anyone that can. As stated, nothing horrible happens immediately when python 2.X is officially declared as no longer supported by the main python organizations. I am sure they can go to NetFLIX or FOX and be revived as a series for a while longer like Longmire and Last Man Standing after their original networks abandoned them. But it can take something noisy to get the attention of some people. For Y2K, there was a very real threat even if it only impacted one program in a hundred or even 10,000. That one could be quite serious if it was in a mission critical component. What if it decided to delete lots of data or declare people dead or send a missile the wrong way (as if there is a right way!) The problem was not just the two digits used but that many languages might allow longer items to write into other parts of memory leading to further corruption. Or a program simply changed to handle wider data might encounter old data and do odd things or now be too big to fit into memory or even have some weird sporadic race condition now that it took a tad longer to run and so on. And, fixing something quickly (or even slowly) might introduce brand new errors. There was plenty to be scared about. Change is scary but sometimes what is even scarier is no change. In the end not much happened BUT I wonder what could have happened if nobody went through most of the code and often adjusted it. Some vaccines have worked so well that people say we don't need them because hardly anyone gets that infection any more. Really? Does that mean it was a waste to use it in the first place or perhaps there is some cause/effect there. I am often asked to proofread something before it is sent out. I find an amazing number of things including many quite relevant and obvious. What is scary is I keep seeing errors in things that get out there. Most are harmless and are either not noticed at all, such as a repeated "of" but in a computer language, something like that can just break things. I was amused recently at a book that seemed to use the word "score" when talking about a python module that does statistical work (more like Machine Learning) and noted it was a mistake that should have said "core = -1" because it was an option allowing the algorithm to run in parallel on as many cores (i.e. CPU) as the machine had available. Again, the spelling did matter but I suspect few would notice. That is why Y2K often required teams of people with different backgrounds to slog through code reviews so more problems would be found than any one person might notice. Anyone who has been involved in projects where you get errors reported and recorded as modification requests may relate to this. The requests are often routed around to be validated and see if they are duplicates and then assigned priorities and some make it into future versions. What bothered me is we would see reports coming from unit testing and then more in system tests and then from the field after deployment but they just kept coming. Some problems will only be seen if you take some convoluted pathway. Y2K was a problem they should have seen decades away and some did. I don't make fun of COBOL. It was a tool largely designed for a purpose that made some people who like Business stuff to be happy or be able to do more than they used to. FORTRAN and LISP and other such tools made other such groups happy. Yes, Modern Languages may make many early ones look like toys NOW as we stand on the shoulders of Lilliputians. But my view of the world sees marketing and politics and frankly radicals using scare tactics as major drivers of events and they tend to overdo to the point where everything becomes a crisis and therefore nothing can be taken seriously even if it turns out to BE a crisis. The Software industry is no different. So I suggest a sober discussion on benefits that may occur. I note some improvements are NOT. My machine keeps rebooting with other strange behavior because it is trying to load an improvement/UPDATE that oddly was already done last month. Turns out I am not alone and a fix involves uninstalling the old one the hard way. Microsoft does things like this frequently when an update messes things up and another update is needed to the point where many simply decide to wait a while. That brings me to the point. One horrible thing about some programs such as C was that they could fail drastically at run time. Blue Screen of Death type of fail. You had to save your work regularly. Languages like python allow you to catch exceptions and deal intelligently with them to at least close down gracefully or even recover. Heck, many programs depend on this and instead of cluttering their code with lots of tests, wait for the error to happen and adjust in the rare case it does. So how reasonable would it be to still have lots of legacy software using languages and programmers that have no easy ways to make their programs more robust? How would such software react if it received information say in UNICODE? I predict that many people and companies have ignored warnings that the 2.X train would someday be diverted to a dead-end track. It was always far enough off in the future. But when a LAST DATE for updates is announced, some may sit up and take notice. It may literally take something like Insurance Companies (or the VC types) refusing to continue supporting them if they do not change, to get them the hint. And, over time, many companies do go under or are bought by another and often that will cause old projects to go away or morph. But there is nothing fundamentally wrong with using 2.X. As I said jokingly, if anyone wanted to keep it and support it as a DIFFERENT language than the more modern python, fine. -----Original Message----- From: Python-list On Behalf Of Michael Torrie Sent: Friday, January 18, 2019 10:36 AM To: python-list at python.org Subject: Re: Pythonic Y2K On 01/16/2019 12:02 PM, Avi Gross wrote: > I recall the days before the year 2000 with the Y2K scare when people > worried that legacy software might stop working or do horrible things > once the clock turned. It may even have been scary enough for some > companies to rewrite key applications and even switch from languages like COBOL. Of course it wasn't just a scare. The date rollover problem was very real. It's interesting that now we call it the Y2K "scare" and since most things came through that okay we often suppose that the people who were warning about this impending problem were simply being alarmist and prophets of doom. We often deride them. But the fact is, people did take these prophets of doom seriously and there was a massive, even heroic effort, to fix a lot of these critical backend systems so that disaster was avoided (just barely). I'm not talking about PCs rolling over to 00. I'm talking about banking software, mission critical control software. It certainly was scary enough for a lot of companies to spend a lot of money rewriting key software. The problem wasn't with COBOL necessarily. In the end disaster was averted (rather narrowly) thanks to the hard work of a lot of people, and thanks to the few people who were vocal in warning of the impending issue. That said, I'm not sure Python 2.7's impending EOL is comparable to the Y2K crisis. -- https://mail.python.org/mailman/listinfo/python-list From avigross at verizon.net Fri Jan 18 16:55:28 2019 From: avigross at verizon.net (Avi Gross) Date: Fri, 18 Jan 2019 16:55:28 -0500 Subject: Pythonic Y2K In-Reply-To: References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> Message-ID: <000601d4af78$8678b160$936a1420$@verizon.net> Larry, I keep hearing similar things about the Flu Vaccine. It only works 40% of the time or whatever. But most of the people that get the flu get a different strain they were not vaccinated against! There are hundreds of strains out there and by protecting the herd against just a few, others will flourish. So was it worth it? Your argument would be that your work found lots of things related to Y2000 that could have been a problem and therefore never got a chance to show. I wonder if anyone did a case study and found an organization that refused to budge and changed nothing, not even other products that were changed like the OS? If such organizations had zero problems, that would be interesting. If they had problems and rapidly had their software changed or fixed, that would be another and we could ask if the relative cost and consequence made such an approach cheaper. But in reality, I suspect that many of the vendors supplying products made the change for all their clients. I bet Oracle might have offered some combination of new and improved products to replace old ones or tools that could be used to say read in a database in one format and write it out again with wider date fields. The vast difference some allude to is realistic. Y2K swept the globe in about 24 hours. No easy way to avoid it for many applications. Someone running python 2.X on their own machines may be able to continue living in their bubble for quite a while. If you sell or share a product with python frozen into an app, it makes no difference. But asking some clients to maintain multiple copies of python set up so one app keeps running as all others use the newer one, may not remain a great solution indefinitely. Has anyone considered something that may be at the edges. How well do cooperating programs work together? I mean if program one processes and saves some data structures using something like pickle, and program two is supposed to read the pickle back in and continue processing, then you may get anomalies of many kinds if they use different pythons. Similarly, processes that start up other scripts and communicate with them, may need to start newer programs that use the 3.X or beyond version as no back-ported version exists. The bubble may enlarge and may eventually burst. -----Original Message----- From: Python-list On Behalf Of Larry Martell Sent: Friday, January 18, 2019 10:47 AM To: Python Subject: Re: Pythonic Y2K On Fri, Jan 18, 2019 at 10:43 AM Michael Torrie wrote: > > On 01/16/2019 12:02 PM, Avi Gross wrote: > > I recall the days before the year 2000 with the Y2K scare when > > people worried that legacy software might stop working or do > > horrible things once the clock turned. It may even have been scary > > enough for some companies to rewrite key applications and even switch from languages like COBOL. > > Of course it wasn't just a scare. The date rollover problem was very > real. It's interesting that now we call it the Y2K "scare" and since > most things came through that okay we often suppose that the people > who were warning about this impending problem were simply being > alarmist and prophets of doom. We often deride them. But the fact > is, people did take these prophets of doom seriously and there was a > massive, even heroic effort, to fix a lot of these critical backend > systems so that disaster was avoided (just barely). I'm not talking > about PCs rolling over to 00. I'm talking about banking software, > mission critical control software. It certainly was scary enough for > a lot of companies to spend a lot of money rewriting key software. > The problem wasn't with COBOL necessarily. I had one client, a hedge fund, that I fixed literally 1000's of Y2K issues for. When Y2K came and there were no problems, the owner said to me "You made such a big deal about the Y2K thing, and nothing happened." -- https://mail.python.org/mailman/listinfo/python-list From larry.martell at gmail.com Fri Jan 18 17:08:43 2019 From: larry.martell at gmail.com (Larry Martell) Date: Fri, 18 Jan 2019 17:08:43 -0500 Subject: Pythonic Y2K In-Reply-To: <000601d4af78$8678b160$936a1420$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <000601d4af78$8678b160$936a1420$@verizon.net> Message-ID: On Fri, Jan 18, 2019 at 4:56 PM Avi Gross wrote: > > Larry, > > I keep hearing similar things about the Flu Vaccine. It only works 40% of > the time or whatever. But most of the people that get the flu get a > different strain they were not vaccinated against! That seems like a complete non-sequitur. What does that have to do with Y2K? But I will tell you something: I've never had a flu vaccine in my life and I've never had the flu. And I will tell you something else: I have proof that worrying works - 99% of the things I worry about never happen, so it must work. And please stop top posting. > There are hundreds of strains out there and by protecting the herd against > just a few, others will flourish. So was it worth it? > > Your argument would be that your work found lots of things related to Y2000 > that could have been a problem and therefore never got a chance to show. I > wonder if anyone did a case study and found an organization that refused to > budge and changed nothing, not even other products that were changed like > the OS? If such organizations had zero problems, that would be interesting. > If they had problems and rapidly had their software changed or fixed, that > would be another and we could ask if the relative cost and consequence made > such an approach cheaper. > > But in reality, I suspect that many of the vendors supplying products made > the change for all their clients. I bet Oracle might have offered some > combination of new and improved products to replace old ones or tools that > could be used to say read in a database in one format and write it out again > with wider date fields. > > The vast difference some allude to is realistic. Y2K swept the globe in > about 24 hours. No easy way to avoid it for many applications. Someone > running python 2.X on their own machines may be able to continue living in > their bubble for quite a while. If you sell or share a product with python > frozen into an app, it makes no difference. But asking some clients to > maintain multiple copies of python set up so one app keeps running as all > others use the newer one, may not remain a great solution indefinitely. > > Has anyone considered something that may be at the edges. How well do > cooperating programs work together? I mean if program one processes and > saves some data structures using something like pickle, and program two is > supposed to read the pickle back in and continue processing, then you may > get anomalies of many kinds if they use different pythons. Similarly, > processes that start up other scripts and communicate with them, may need to > start newer programs that use the 3.X or beyond version as no back-ported > version exists. The bubble may enlarge and may eventually burst. > > -----Original Message----- > From: Python-list On > Behalf Of Larry Martell > Sent: Friday, January 18, 2019 10:47 AM > To: Python > Subject: Re: Pythonic Y2K > > On Fri, Jan 18, 2019 at 10:43 AM Michael Torrie wrote: > > > > On 01/16/2019 12:02 PM, Avi Gross wrote: > > > I recall the days before the year 2000 with the Y2K scare when > > > people worried that legacy software might stop working or do > > > horrible things once the clock turned. It may even have been scary > > > enough for some companies to rewrite key applications and even switch > from languages like COBOL. > > > > Of course it wasn't just a scare. The date rollover problem was very > > real. It's interesting that now we call it the Y2K "scare" and since > > most things came through that okay we often suppose that the people > > who were warning about this impending problem were simply being > > alarmist and prophets of doom. We often deride them. But the fact > > is, people did take these prophets of doom seriously and there was a > > massive, even heroic effort, to fix a lot of these critical backend > > systems so that disaster was avoided (just barely). I'm not talking > > about PCs rolling over to 00. I'm talking about banking software, > > mission critical control software. It certainly was scary enough for > > a lot of companies to spend a lot of money rewriting key software. > > The problem wasn't with COBOL necessarily. > > I had one client, a hedge fund, that I fixed literally 1000's of Y2K issues > for. When Y2K came and there were no problems, the owner said to me "You > made such a big deal about the Y2K thing, and nothing happened." From gheskett at shentel.net Fri Jan 18 17:59:59 2019 From: gheskett at shentel.net (Gene Heskett) Date: Fri, 18 Jan 2019 17:59:59 -0500 Subject: Pythonic Y2K In-Reply-To: <000601d4af78$8678b160$936a1420$@verizon.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <000601d4af78$8678b160$936a1420$@verizon.net> Message-ID: <201901181759.59747.gheskett@shentel.net> On Friday 18 January 2019 16:55:28 Avi Gross wrote: > Larry, > > I keep hearing similar things about the Flu Vaccine. It only works 40% > of the time or whatever. But most of the people that get the flu get a > different strain they were not vaccinated against! > > There are hundreds of strains out there and by protecting the herd > against just a few, others will flourish. So was it worth it? > > Your argument would be that your work found lots of things related to > Y2000 that could have been a problem and therefore never got a chance > to show. I wonder if anyone did a case study and found an organization > that refused to budge and changed nothing, not even other products > that were changed like the OS? If such organizations had zero > problems, that would be interesting. If they had problems and rapidly > had their software changed or fixed, that would be another and we > could ask if the relative cost and consequence made such an approach > cheaper. > > But in reality, I suspect that many of the vendors supplying products > made the change for all their clients. I bet Oracle might have offered > some combination of new and improved products to replace old ones or > tools that could be used to say read in a database in one format and > write it out again with wider date fields. > > The vast difference some allude to is realistic. Y2K swept the globe > in about 24 hours. No easy way to avoid it for many applications. > Someone running python 2.X on their own machines may be able to > continue living in their bubble for quite a while. If you sell or > share a product with python frozen into an app, it makes no > difference. But asking some clients to maintain multiple copies of > python set up so one app keeps running as all others use the newer > one, may not remain a great solution indefinitely. > > Has anyone considered something that may be at the edges. How well do > cooperating programs work together? I mean if program one processes > and saves some data structures using something like pickle, and > program two is supposed to read the pickle back in and continue > processing, then you may get anomalies of many kinds if they use > different pythons. Similarly, processes that start up other scripts > and communicate with them, may need to start newer programs that use > the 3.X or beyond version as no back-ported version exists. The bubble > may enlarge and may eventually burst. > > -----Original Message----- > From: Python-list > On Behalf Of > Larry Martell > Sent: Friday, January 18, 2019 10:47 AM > To: Python > Subject: Re: Pythonic Y2K > > On Fri, Jan 18, 2019 at 10:43 AM Michael Torrie wrote: > > On 01/16/2019 12:02 PM, Avi Gross wrote: > > > I recall the days before the year 2000 with the Y2K scare when > > > people worried that legacy software might stop working or do > > > horrible things once the clock turned. It may even have been scary > > > enough for some companies to rewrite key applications and even > > > switch > > from languages like COBOL. > > > Of course it wasn't just a scare. The date rollover problem was > > very real. It's interesting that now we call it the Y2K "scare" and > > since most things came through that okay we often suppose that the > > people who were warning about this impending problem were simply > > being alarmist and prophets of doom. We often deride them. But the > > fact is, people did take these prophets of doom seriously and there > > was a massive, even heroic effort, to fix a lot of these critical > > backend systems so that disaster was avoided (just barely). I'm not > > talking about PCs rolling over to 00. I'm talking about banking > > software, mission critical control software. It certainly was scary > > enough for a lot of companies to spend a lot of money rewriting key > > software. The problem wasn't with COBOL necessarily. > > I had one client, a hedge fund, that I fixed literally 1000's of Y2K > issues for. When Y2K came and there were no problems, the owner said > to me "You made such a big deal about the Y2K thing, and nothing > happened." -- I would quite cheerfully have bought a ticket to watch and hear your reply, Larry. Or better yet, silently reached into your briefcase and brought out an invoice, listing what and where you patched, and what you would normally charge to find and fix each one individually when the gun went off for real 36 hours back and his fund was losing 1% an hour. Sometimes the truth shuts them up but theres usually some yelling involved. > https://mail.python.org/mailman/listinfo/python-list 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 rshepard at appl-ecosys.com Fri Jan 18 19:01:08 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Fri, 18 Jan 2019 16:01:08 -0800 (PST) Subject: Pythonic Y2K In-Reply-To: <201901181759.59747.gheskett@shentel.net> References: <00a801d4adce$0d5cc9c0$28165d40$@verizon.net> <000601d4af78$8678b160$936a1420$@verizon.net> <201901181759.59747.gheskett@shentel.net> Message-ID: On Fri, 18 Jan 2019, Gene Heskett wrote: >> I had one client, a hedge fund, that I fixed literally 1000's of Y2K >> issues for. When Y2K came and there were no problems, the owner said >> to me "You made such a big deal about the Y2K thing, and nothing >> happened." -- > I would quite cheerfully have bought a ticket to watch and hear your > reply, Larry. My response would have been, "That's because of all the time and effort I devoted to fixing all the issues that would have put you out of business. Perhaps a bonus is due me?" This is a common situation for all consultants, including environmental scientists such as I am. Clients don't know how to fix the problems they face, nor have that capability in-house, so they need external assistance. This lack of knowledge means they don't understand why the project took so long nor recognize the effort put in by the consultant. People tend to take for granted when things work smoothly but notice when there are glitches. Ask any major conference or annual meeting director about this. :-) A similar situation is faced by those of us who are expected to "prove" a negative. Carpe weekend, all, Rich From kai.peters at gmail.com Fri Jan 18 10:28:31 2019 From: kai.peters at gmail.com (TUA) Date: Fri, 18 Jan 2019 07:28:31 -0800 (PST) Subject: TKinter Newbie question In-Reply-To: References: Message-ID: <52bc7aec-3f8d-494a-9d0a-97e009154d2e@googlegroups.com> Thanks for your fresh pair of eyes! From cam.davidson.pilon at gmail.com Fri Jan 18 14:20:01 2019 From: cam.davidson.pilon at gmail.com (Cameron Davidson-Pilon) Date: Fri, 18 Jan 2019 14:20:01 -0500 Subject: Python Packages Survey Message-ID: Hello! I invite you to participate in the Python Packages Survey - it takes less than a minute to complete, and will help open source developers understand their users' better. Thanks for participating! https://python-packages-survey.com/ -- Cameron Davidson-Pilon Data Origami From duncan at invalid.invalid Fri Jan 18 21:29:54 2019 From: duncan at invalid.invalid (duncan smith) Date: Sat, 19 Jan 2019 02:29:54 +0000 Subject: sampling from frequency distribution / histogram without replacement In-Reply-To: References: Message-ID: On 14/01/2019 20:11, duncan smith wrote: > Hello, > Just checking to see if anyone has attacked this problem before > for cases where the population size is unfeasibly large. i.e. The number > of categories is manageable, but the sum of the frequencies, N, > precludes simple solutions such as creating a list, shuffling it and > using the first n items to populate the sample (frequency distribution / > histogram). > > I note that numpy.random.hypergeometric will allow me to generate a > sample when I only have two categories, and that I could probably > implement some kind of iterative / partitioning approach calling this > repeatedly. But before I do I thought I'd ask if anyone has tackled this > before. Can't find much on the web. Cheers. > > Duncan > After much tinkering I came up with the following: import numpy as np def hypgeom_variate(freqs, n): # recursive partitioning approach sample = [0] * len(freqs) cumsum = np.cumsum(list(chain([0], freqs))) if n > cumsum[-1]: raise ValueError('n cannot be greater than population size') hypergeometric = np.random.hypergeometric argslist = [(0, len(freqs), 0, cumsum[-1], n)] for i, k, ci, ck, m in argslist: if k == i + 1: sample[i] = m else: j = (i + k) // 2 cj = cumsum[j] x = hypergeometric(cj - ci, ck - cj, m, 1)[0] y = m-x if x: argslist.append((i, j, ci, cj, x)) if y: argslist.append((j, k, cj, ck, y)) return sample Cheers. Duncan From greg.ewing at canterbury.ac.nz Fri Jan 18 23:17:21 2019 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sat, 19 Jan 2019 17:17:21 +1300 Subject: the python name In-Reply-To: References: <05ff6fbc-69d5-4d3c-9073-67e774bd3c0a@googlegroups.com> <2qjq2e9lke64s4biv85pg1gk84t9eqe23l@4ax.com> <002701d4a300$1501bd30$3f053790$@verizon.net> <6e0df20a-3ba4-3e20-3edc-b738355b37a5@DancesWithMice.info> <8C008AF9-0B1E-4736-B075-86ECF09082FF@mac.com> <005701d4a44b$5a8e6190$0fab24b0$@verizon.net> <00d701d4a4ab$15c4f820$414ee860$@verizon.net> <00a101d4adcb$cb457480$61d05d80$@verizon.net> <569acb71-a5db-f5ea-7a0f-2ab8fffc63e5@DancesWithMice.info> Message-ID: DL Neil wrote: > (not that New Zealanders need to know much about snakes!) Probably recommended when we visit Australia, though. Also we seem to have imported some of their spiders in recent years, so it's only a matter of time before their snakes follow. I wonder if we could get Australia to pay for a snake-proof wall across the Tasman? -- Greg From dieter at handshake.de Sat Jan 19 02:33:26 2019 From: dieter at handshake.de (dieter) Date: Sat, 19 Jan 2019 08:33:26 +0100 Subject: python package management confusion References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> <875zum8lfo.fsf@handshake.de> Message-ID: <875zulje49.fsf@handshake.de> dcs3spp via Python-list writes: > On Friday, 18 January 2019 07:39:00 UTC, dieter wrote: > ... > My situation is similar to the following.... > > Assume the following two privately developed projects that I have written, each with their own setup.py: > 1. parent exists in folder $HOME/project/ > 2. child exists in folder $HOME/a_different_project/ > *child could be also be used by other projects in the future.... > > parent has a dependency requirement on child and so child is listed as an install dependency in parent setup.py > > if I try python setup.py develop from parent project it fails to find child dependency on build. Do you tell me to have a cyclic dependency structure? If not, first install "child" in your virtualenv (by whatever means, maybe "python setup.py develop"), then "parent". From kwpolska at gmail.com Sat Jan 19 04:40:50 2019 From: kwpolska at gmail.com (Chris Warrick) Date: Sat, 19 Jan 2019 10:40:50 +0100 Subject: Python Packages Survey In-Reply-To: References: Message-ID: On Sat, 19 Jan 2019 at 01:22, Cameron Davidson-Pilon wrote: > > Hello! I invite you to participate in the Python Packages Survey - it takes > less than a minute to complete, and will help open source developers > understand their users' better. Thanks for participating! > > https://python-packages-survey.com/ The site says: > Completing the survey is as easy as running a Python script No, thanks. A better way to get meaningful results is to just create a good old web form, where you can ask people more detailed questions than just mining the installed package list. Also, even if you promise to filter out private packages, they *do* reach your server, and many people would prefer that didn?t happen. -- Chris Warrick PGP: 5EAAEA16 From joepareti54 at gmail.com Sat Jan 19 05:42:48 2019 From: joepareti54 at gmail.com (joseph pareti) Date: Sat, 19 Jan 2019 11:42:48 +0100 Subject: basic question on how "import" works Message-ID: [*u23885 at c009 3_NeuralNetworks]$ cat foo.py* from __future__ import print_function # Import MNIST data from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) [u23885 at c009 3_NeuralNetworks]$ when the above code is executed, equivalent of *$ python foo.py* the output is as follows: ... Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes. Extracting /tmp/data/train-images-idx3-ubyte.gz Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes. Extracting /tmp/data/train-labels-idx1-ubyte.gz Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes. Extracting /tmp/data/t10k-images-idx3-ubyte.gz Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes. Extracting /tmp/data/t10k-labels-idx1-ubyte.gz ... My questions are: 1. where are the write / print statements that display *Successfully downloaded, extracting ...* 2. I don't see any such files in /tmp/data on my system, why? 3. (this is part of a code for training a neuronal network which works as expected, it's just for my own understanding of how this works -- Thank you) -- Regards, Joseph Pareti - Artificial Intelligence consultant cell +49 1520 1600 209 cell +39 339 797 0644 From simonppears at googlemail.com Sat Jan 19 06:17:01 2019 From: simonppears at googlemail.com (dcs3spp) Date: Sat, 19 Jan 2019 03:17:01 -0800 (PST) Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> <875zum8lfo.fsf@handshake.de> <875zulje49.fsf@handshake.de> Message-ID: On Saturday, 19 January 2019 07:33:50 UTC, dieter wrote: > dcs3spp via Python-list writes: > > On Friday, 18 January 2019 07:39:00 UTC, dieter wrote: > > ... > > My situation is similar to the following.... > > > > Assume the following two privately developed projects that I have written, each with their own setup.py: > > 1. parent exists in folder $HOME/project/ > > 2. child exists in folder $HOME/a_different_project/ > > *child could be also be used by other projects in the future.... > > > > parent has a dependency requirement on child and so child is listed as an install dependency in parent setup.py > > > > if I try python setup.py develop from parent project it fails to find child dependency on build. > > Do you tell me to have a cyclic dependency structure? > > If not, first install "child" in your virtualenv (by whatever > means, maybe "python setup.py develop"), then "parent". Thanks for your suggestion.No, no cyclic dependency structure. Child does not depend on parent. Child could be used by separate projects in the future. Child will not be cyclic, it will not import projects that import it. Installing child first is what I tried yesterday, https://github.com/dcs3spp/setuptools_dependency_example/blob/master/README.md , when trying to understand the suggested approach of using python setup.py develop to pull dependencies. The advantage of the devpi approach, adopted earlier, is that this additional complexity is hidden from developers. They do not need to be concerned about the order that they install dependencies, e.g. install child first and then install parent. Developers just run python setup.py develop and it automatically fetches the child dependency. However, the devpi approach requires a private repository to be setup and I am not sure whether it is possible to give access to it for usage in CI cloud technologies, such as gitlab.com. If I stuck with devpi then I would presumably have to follow the route of a bare metal environment for CI server (e.g. Jenkins). Hence, my thoughts on paying subscription to a private pypi cloud repository?.. My question is, can setuptools be configured to pull in child from a separate git repository when running?python setup.py develop?from parent folder? I have since found and tried this approach at https://stackoverflow.com/a/53706140/8325270 It appears that later versions of setuptools can install via a PEP508 url. I currently trying to investigate this approach?.. From mignoncharly at yahoo.fr Sat Jan 19 08:35:12 2019 From: mignoncharly at yahoo.fr (mignoncharly at yahoo.fr) Date: Sat, 19 Jan 2019 05:35:12 -0800 (PST) Subject: How to access a folder inside a zip file Message-ID: <081ba7b6-06b2-4160-b84c-94286168ca0c@googlegroups.com> Hello! I'm a newbie in python and I was trying to access a folder inside a zip file and I also have issues with relative and absolute path. Thks in advance. In projects there a lot of urls (i'll read them later one by one and store them in a list/array so that I could work with it easily) here is the path: home/name/tutorial/prof/ks.zip/projects should I use file_name = "ks.zip" or file_location = os.path.dirname(os.path.abspath(__file__)) #print(file_location) ? # specifying the zip file name file_name = "ks.zip" # opening the zip file in READ mode with ZipFile(file_name, 'r') as zip: # printing all the contents of the zip file zip.printdir() # extracting all the files print('Extracting all the files now...') zip.extractall() print('Done!') From mignoncharly at yahoo.fr Sat Jan 19 08:36:01 2019 From: mignoncharly at yahoo.fr (mignoncharly) Date: Sat, 19 Jan 2019 05:36:01 -0800 (PST) Subject: How to access a folder in a zip file? Message-ID: Hello! I'm a newbie in python and I was trying to access a folder inside a zip file and I also have issues with relative and absolute path. Thks in advance. In projects there a lot of urls (i'll read them later one by one and store them in a list/array so that I could work with it easily) here is the path: home/name/tutorial/prof/ks.zip/projects should I use file_name = "ks.zip" or file_location = os.path.dirname(os.path.abspath(__file__)) #print(file_location) ? # specifying the zip file name file_name = "ks.zip" # opening the zip file in READ mode with ZipFile(file_name, 'r') as zip: # printing all the contents of the zip file zip.printdir() # extracting all the files print('Extracting all the files now...') zip.extractall() print('Done!') From jsf80238 at gmail.com Sat Jan 19 10:01:10 2019 From: jsf80238 at gmail.com (Jason Friedman) Date: Sat, 19 Jan 2019 08:01:10 -0700 Subject: Python Packages Survey In-Reply-To: References: Message-ID: On Fri, Jan 18, 2019 at 5:22 PM Cameron Davidson-Pilon < cam.davidson.pilon at gmail.com> wrote: > Hello! I invite you to participate in the Python Packages Survey - it takes > less than a minute to complete, and will help open source developers > understand their users' better. Thanks for participating! > > https://python-packages-survey.com/ > > I took the plunge. Other than smoke coming out of my computer everything seems to be normal. From avigross at verizon.net Sat Jan 19 17:07:06 2019 From: avigross at verizon.net (Avi Gross) Date: Sat, 19 Jan 2019 17:07:06 -0500 Subject: checking protocols. Message-ID: <003c01d4b043$5133be70$f39b3b50$@verizon.net> Short question. Checking if a protocol is set up? Many python improvements are changes to classes that implement a protocol. There are things you can do to make your own classes work with the protocol by setting various dunder variables like __iter__, __next__ and writing appropriate ode including throwing the right error class when done. Similarly the "with" statement works with objects that implement __enter__ and __exit__. There can be plenty of others like this and more can be anticipated in the future. So, several related questions. Tools that help a developer add appropriate things to an object to implement the protocol or to test if it was done right. Perhaps a function with a name like is_iterable() that tells if the protocol can be applied. For the specific case of an iterable, I found something that seems to work for at least some cases: from collections import Iterable item = [1, 2, 3, 4] isinstance(item, Iterable) Not sure if it would work on one I created that did the right things or what it checks. I am interested in a pointer to something that describes many of the known protocols or extensions and maybe to modules designed sort of as I said above. I am aware some protocols may be not-quite standard with parts of the protocol embedded in different objects like wrappers or objects returned upon a request to have a proxy and many other techniques that seem to abound and allow multiple layers of indirection or seemingly almost magical as in multiple inheritance drop-ins and so on. That is what may make these things harder if someone uses something like __getattr__ or descriptors to intercept calls and provide the functionality without any actual sign of the dunder key normally expected. And, yes, I am aware of a tried and true method called try ... except ... to see if it seems to work. From rshepard at appl-ecosys.com Sat Jan 19 18:01:29 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sat, 19 Jan 2019 15:01:29 -0800 (PST) Subject: ttk present but not found for import Message-ID: I've started to learn tkinter as the GUI widget set I'll use from now on. While ttk-8.6 is installed here (/usr/lib/tk8.6/ttk), I cannot import it: $ python3 Python 3.6.7 (default, Dec 8 2018, 06:22:57) [GCC 5.5.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>> import ttk Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'ttk' >>> What have I done incorrectly? TIA, Rich From rshepard at appl-ecosys.com Sat Jan 19 18:15:11 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sat, 19 Jan 2019 15:15:11 -0800 (PST) Subject: ttk present but not found for import [RESOLVED] In-Reply-To: References: Message-ID: On Sat, 19 Jan 2019, Rich Shepard wrote: > What have I done incorrectly? Got it: from tkinter import ttk Rich From robertvstepp at gmail.com Sat Jan 19 19:13:53 2019 From: robertvstepp at gmail.com (boB Stepp) Date: Sat, 19 Jan 2019 18:13:53 -0600 Subject: ttk present but not found for import In-Reply-To: References: Message-ID: On Sat, Jan 19, 2019 at 5:02 PM Rich Shepard wrote: > > I've started to learn tkinter as the GUI widget set I'll use from now on. > While ttk-8.6 is installed here (/usr/lib/tk8.6/ttk), I cannot import it: > > $ python3 > Python 3.6.7 (default, Dec 8 2018, 06:22:57) > [GCC 5.5.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import tkinter > >>> import ttk > Traceback (most recent call last): > File "", line 1, in > ModuleNotFoundError: No module named 'ttk' > >>> > > What have I done incorrectly? import tkinter.ttk -- boB From prakashsharmacs24 at gmail.com Sun Jan 20 10:41:56 2019 From: prakashsharmacs24 at gmail.com (prakashsharmacs24 at gmail.com) Date: Sun, 20 Jan 2019 07:41:56 -0800 (PST) Subject: Error while using suds: suds.TypeNotFound: Type not found Message-ID: <70311809-f6e7-4a48-9626-bf6f44869fc6@googlegroups.com> I want to consume the web services described in the following: https://login.keyinvoice.com/API3_ws.php?wsdl I am using python 3.5.x and suds version 0.6. What I tried 1 from suds.client import Client url = 'https://login.keyinvoice.com/API3_ws.php?wsdl' client = Client(url) Error: suds.TypeNotFound: Type not found: '(Array, http://www.w3.org/2001/XMLSchema, )' What I tried 2 from suds.client import Client from suds.xsd.doctor import Import, ImportDoctor imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd') imp.filter.add('http://login.keyinvoice.com/soap/KI_API3') client = Client(url, doctor=ImportDoctor(imp)) Error: suds.TypeNotFound: Type not found: '(Array, http://www.w3.org/2001/XMLSchema, )' Already visited these URL: SOAP suds and the dreaded schema Type Not Found error Type not found wsdl python suds client - suds.TypeNotFound python suds From prakashsharmacs24 at gmail.com Sun Jan 20 10:43:57 2019 From: prakashsharmacs24 at gmail.com (prakashsharmacs24 at gmail.com) Date: Sun, 20 Jan 2019 07:43:57 -0800 (PST) Subject: Error while using suds: suds.TypeNotFound: Type not found In-Reply-To: <70311809-f6e7-4a48-9626-bf6f44869fc6@googlegroups.com> References: <70311809-f6e7-4a48-9626-bf6f44869fc6@googlegroups.com> Message-ID: <94c9e554-2b99-4c2f-bcb3-713e02b84811@googlegroups.com> On Sunday, January 20, 2019 at 9:12:10 PM UTC+5:30, prakashs... at gmail.com wrote: > I want to consume the web services described in the following: > > https://login.keyinvoice.com/API3_ws.php?wsdl > > I am using python 3.5.x and suds version 0.6. What I tried 1 > > from suds.client import Client > url = 'https://login.keyinvoice.com/API3_ws.php?wsdl' > client = Client(url) > > Error: > > suds.TypeNotFound: Type not found: '(Array, http://www.w3.org/2001/XMLSchema, )' > > What I tried 2 > > from suds.client import Client > from suds.xsd.doctor import Import, ImportDoctor > imp = Import('http://www.w3.org/2001/XMLSchema', > location='http://www.w3.org/2001/XMLSchema.xsd') > imp.filter.add('http://login.keyinvoice.com/soap/KI_API3') > client = Client(url, doctor=ImportDoctor(imp)) > > Error: > > suds.TypeNotFound: Type not found: '(Array, http://www.w3.org/2001/XMLSchema, )' > > Already visited these URL: > > https://stackoverflow.com/questions/4719854/soap-suds-and-the-dreaded-schema-type-not-found-error > > https://stackoverflow.com/questions/25721035/type-not-found-wsdl-python-suds-client-suds-typenotfound From simonppears at googlemail.com Sun Jan 20 11:19:27 2019 From: simonppears at googlemail.com (dcs3spp) Date: Sun, 20 Jan 2019 08:19:27 -0800 (PST) Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> <875zum8lfo.fsf@handshake.de> <875zulje49.fsf@handshake.de> Message-ID: <1149632f-0817-4733-985f-37b1ad909ab8@googlegroups.com> On Saturday, 19 January 2019 11:17:19 UTC, dcs3spp wrote: > On Saturday, 19 January 2019 07:33:50 UTC, dieter wrote: > > dcs3spp via Python-list writes: > > > On Friday, 18 January 2019 07:39:00 UTC, dieter wrote: > > > ... > > > My situation is similar to the following.... > > > > > > Assume the following two privately developed projects that I have written, each with their own setup.py: > > > 1. parent exists in folder $HOME/project/ > > > 2. child exists in folder $HOME/a_different_project/ > > > *child could be also be used by other projects in the future.... > > > > > > parent has a dependency requirement on child and so child is listed as an install dependency in parent setup.py > > > > > > if I try python setup.py develop from parent project it fails to find child dependency on build. > > > > Do you tell me to have a cyclic dependency structure? > > > > If not, first install "child" in your virtualenv (by whatever > > means, maybe "python setup.py develop"), then "parent". > > Thanks for your suggestion.No, no cyclic dependency structure. Child does not depend on parent. Child could be used by separate projects in the future. Child will not be cyclic, it will not import projects that import it. > > Installing child first is what I tried yesterday, https://github.com/dcs3spp/setuptools_dependency_example/blob/master/README.md , when trying to understand the suggested approach of using python setup.py develop to pull dependencies. > > The advantage of the devpi approach, adopted earlier, is that this additional complexity is hidden from developers. They do not need to be concerned about the order that they install dependencies, e.g. install child first and then install parent. Developers just run python setup.py develop and it automatically fetches the child dependency. > > However, the devpi approach requires a private repository to be setup and I am not sure whether it is possible to give access to it for usage in CI cloud technologies, such as gitlab.com. If I stuck with devpi then I would presumably have to follow the route of a bare metal environment for CI server (e.g. Jenkins). Hence, my thoughts on paying subscription to a private pypi cloud repository?.. > > > My question is, can setuptools be configured to pull in child from a separate git repository when running?python setup.py develop?from parent folder? I have since found and tried this approach at https://stackoverflow.com/a/53706140/8325270 > It appears that later versions of setuptools can install via a PEP508 url. I currently trying to investigate this approach?.. After trying PEP508 url approach my conclusions are as follows. A PEP508 url for a git repository can be used in *install_requires* of *setup.py*. An example is listed below. ``` requires = [ 'parent', 'kinto-http at git+https://github.com/Kinto/kinto-http.py', ] ... install_requires=requires ``` The package can then be installed with pip, using ```pip install -e . or pip install .``` However, installation with setuptools is then broken, i.e. ```python setup.py develop``` and ```python setup.py install``` fails. setuptools looks for packages in pypi indexes. To install using setuptools a devpi index would have to be installed and configured or packages would have to installed from a paid for pypi repository in the cloud. Alternatively, developers could manually install each private package dependency individually, prior to running ```python setup.py develop``` for the source package. Unless, there are other alternative(s) such as zc.buildout with mr developer plugin etc..... If I want to have a Python private project, referencing other private project(s), available under source control and CI via gitlab.com, it seems that I can use the pip approach with PEP508 or use a requirements.txt file containing the git projects referenced as PEP508 urls, i.e. ```pip install -r requirements.txt```. Confusion, stems from the fact that pip and setuptools dependencies are then not synchronised, i.e. setuptools will break if PEP508 urls are listed for install_requires. Presumably the approach is to use either pip or setuptools but not both? From michael.stemper at gmail.com Sun Jan 20 12:25:14 2019 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Sun, 20 Jan 2019 11:25:14 -0600 Subject: How to access a folder in a zip file? In-Reply-To: References: Message-ID: On 19/01/2019 07.36, mignoncharly wrote: > Hello! > > I'm a newbie in python and I was trying to access a folder inside a zip file and I also have issues with relative and absolute path. Thks in advance. > > In projects there a lot of urls (i'll read them later one by one and store them in a list/array so that I could work with it easily) > > here is the path: home/name/tutorial/prof/ks.zip/projects Are you sure? Could it possibly be: /home/name/tutorial/prof/ks.zip/projects instead? -- Michael F. Stemper What happens if you play John Cage's "4'33" at a slower tempo? From python at mrabarnett.plus.com Sun Jan 20 13:22:19 2019 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 20 Jan 2019 18:22:19 +0000 Subject: Error while using suds: suds.TypeNotFound: Type not found In-Reply-To: <70311809-f6e7-4a48-9626-bf6f44869fc6@googlegroups.com> References: <70311809-f6e7-4a48-9626-bf6f44869fc6@googlegroups.com> Message-ID: <9ec195b5-b1c8-926e-813f-737366f0cc6f@mrabarnett.plus.com> On 2019-01-20 15:41, prakashsharmacs24 at gmail.com wrote: > > > I want to consume the web services described in the following: > > https://login.keyinvoice.com/API3_ws.php?wsdl > > I am using python 3.5.x and suds version 0.6. What I tried 1 > > from suds.client import Client > url = 'https://login.keyinvoice.com/API3_ws.php?wsdl' > client = Client(url) > > Error: > > suds.TypeNotFound: Type not found: '(Array, http://www.w3.org/2001/XMLSchema, )' > > What I tried 2 > > from suds.client import Client > from suds.xsd.doctor import Import, ImportDoctor > imp = Import('http://www.w3.org/2001/XMLSchema', > location='http://www.w3.org/2001/XMLSchema.xsd') > imp.filter.add('http://login.keyinvoice.com/soap/KI_API3') > client = Client(url, doctor=ImportDoctor(imp)) > > Error: > > suds.TypeNotFound: Type not found: '(Array, http://www.w3.org/2001/XMLSchema, )' > > Already visited these URL: > > SOAP suds and the dreaded schema Type Not Found error > > Type not found wsdl python suds client - suds.TypeNotFound > python suds > Have you tried: https://www.w3.org/2001/XMLSchema instead? ("https" instead of "http") From oscar.j.benjamin at gmail.com Sun Jan 20 15:38:02 2019 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Sun, 20 Jan 2019 20:38:02 +0000 Subject: python package management confusion In-Reply-To: <1149632f-0817-4733-985f-37b1ad909ab8@googlegroups.com> References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> <875zum8lfo.fsf@handshake.de> <875zulje49.fsf@handshake.de> <1149632f-0817-4733-985f-37b1ad909ab8@googlegroups.com> Message-ID: On Sun, 20 Jan 2019 at 16:22, dcs3spp via Python-list wrote: > > On Saturday, 19 January 2019 11:17:19 UTC, dcs3spp wrote: > > > > My question is, can setuptools be configured to pull in child from a separate git repository when running python setup.py develop from parent folder? I have since found and tried this approach at https://stackoverflow.com/a/53706140/8325270 > > It appears that later versions of setuptools can install via a PEP508 url. I currently trying to investigate this approach?.. > > After trying PEP508 url approach my conclusions are as follows. > > A PEP508 url for a git repository can be used in *install_requires* of *setup.py*. An example is listed below. > ``` > requires = [ > 'parent', > 'kinto-http at git+https://github.com/Kinto/kinto-http.py', > ] > ... > install_requires=requires > ``` > The package can then be installed with pip, using ```pip install -e . or pip install .``` > > However, installation with setuptools is then broken, i.e. ```python setup.py develop``` and ```python setup.py install``` fails. setuptools looks for packages in pypi indexes. To install using setuptools a devpi index would have to be installed and configured or packages would have to installed from a paid for pypi repository in the cloud. Alternatively, developers could manually install each private package dependency individually, prior to running ```python setup.py develop``` for the source package. Unless, there are other alternative(s) such as zc.buildout with mr developer plugin etc..... > > If I want to have a Python private project, referencing other private project(s), available under source control and CI via gitlab.com, it seems that I can use the pip approach with PEP508 or use a requirements.txt file containing the git projects referenced as PEP508 urls, i.e. ```pip install -r requirements.txt```. > > Confusion, stems from the fact that pip and setuptools dependencies are then not synchronised, i.e. setuptools will break if PEP508 urls are listed for install_requires. Presumably the approach is to use either pip or setuptools but not both? I'm not sure what you mean by pip and setuptools not being synchronised. Pip depends on setuptools and cannot be used without it. Both setuptools and pip are maintained under the PyPA. They are intended to work together. in fact if your setup.py uses distutils instead of setuptools then pip will "inject" setuptools into it to ensure that meets pip's needs. You will need to be more specific about which commands you are using and what it is that becomes unsynchronised. -- Oscar From simonppears at googlemail.com Sun Jan 20 16:08:25 2019 From: simonppears at googlemail.com (dcs3spp) Date: Sun, 20 Jan 2019 13:08:25 -0800 (PST) Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> <875zum8lfo.fsf@handshake.de> <875zulje49.fsf@handshake.de> <1149632f-0817-4733-985f-37b1ad909ab8@googlegroups.com> Message-ID: On Sunday, 20 January 2019 20:38:30 UTC, Oscar Benjamin wrote: > On Sun, 20 Jan 2019 at 16:22, dcs3spp via Python-list > wrote: > > > > On Saturday, 19 January 2019 11:17:19 UTC, dcs3spp wrote: > > > > > > My question is, can setuptools be configured to pull in child from a separate git repository when running python setup.py develop from parent folder? I have since found and tried this approach at https://stackoverflow.com/a/53706140/8325270 > > > It appears that later versions of setuptools can install via a PEP508 url. I currently trying to investigate this approach?.. > > > > After trying PEP508 url approach my conclusions are as follows. > > > > A PEP508 url for a git repository can be used in *install_requires* of *setup.py*. An example is listed below. > > ``` > > requires = [ > > 'parent', > > 'kinto-http at git+https://github.com/Kinto/kinto-http.py', > > ] > > ... > > install_requires=requires > > ``` > > The package can then be installed with pip, using ```pip install -e . or pip install .``` > > > > However, installation with setuptools is then broken, i.e. ```python setup.py develop``` and ```python setup.py install``` fails. setuptools looks for packages in pypi indexes. To install using setuptools a devpi index would have to be installed and configured or packages would have to installed from a paid for pypi repository in the cloud. Alternatively, developers could manually install each private package dependency individually, prior to running ```python setup.py develop``` for the source package. Unless, there are other alternative(s) such as zc.buildout with mr developer plugin etc..... > > > > If I want to have a Python private project, referencing other private project(s), available under source control and CI via gitlab.com, it seems that I can use the pip approach with PEP508 or use a requirements.txt file containing the git projects referenced as PEP508 urls, i.e. ```pip install -r requirements.txt```. > > > > Confusion, stems from the fact that pip and setuptools dependencies are then not synchronised, i.e. setuptools will break if PEP508 urls are listed for install_requires. Presumably the approach is to use either pip or setuptools but not both? > > I'm not sure what you mean by pip and setuptools not being > synchronised. Pip depends on setuptools and cannot be used without it. > Both setuptools and pip are maintained under the PyPA. They are > intended to work together. in fact if your setup.py uses distutils > instead of setuptools then pip will "inject" setuptools into it to > ensure that meets pip's needs. > > You will need to be more specific about which commands you are using > and what it is that becomes unsynchronised. > > -- > Oscar Hi, Have since done further testing and figured out how I can install from a setup.py file using both pip and python setup.py develop. Confusion was caused by trying to install using both pip and setuptools with PEP508 urls in install_requires, see note at end of post.... >From what I understand setuptools offers *dependency_links* as a list of dependency urls. In the example below, the *pyramid_core* package is a private dependency that I have written. I am currently using pip 18.1. pip has an option *--process-dependencies* that issues a deprecation warning. The following *setup.py* example works with both setuptools (python setup develop etc.) and pip (pip install -e . and pip install .). The example *setup.py* below can be installed using both setuptools and pip as follows: ``` python setup.py develop python setup.py install pip install -e . --process-dependency-links pip install . ``` **setup.py that is compatible with both setuptools and pip 18.1** ================================================================= ``` import os from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(here, 'README.md')) as f: README = f.read() with open(os.path.join(here, 'CHANGES.md')) as f: CHANGES = f.read() dependencies = [ 'git+ssh://git at gitlab.com/dcs3spp/plantoeducate_core.git#egg=pyramid_core-0', ] requires = [ 'parent', 'pyramid_core', ] setup_requires = [ ] tests_require = [ 'pytest', 'pytest-cov', ] setup(name='parent', version='0.1', description='parent', long_description=README + '\n\n' + CHANGES, classifiers=[ "Programming Language :: Python", ], author='dcs3spp', author_email='myemail at outlook.com', url='', keywords='setuptools', packages=find_packages('src'), package_dir={'': 'src'}, include_package_data=True, zip_safe=False, extras_require={ 'testing': tests_require, }, install_requires=requires, dependency_links=dependencies, setup_requires=setup_requires, tests_require=tests_require, ) ``` Pip 18.1 supports reading pep508 direct urls from install_requires. In future release there are plans to deprecate the --process-dependency-links pip install option: - https://github.com/pypa/pip/issues/4187 - https://github.com/pypa/pip/pull/4175 Will setuptools provide ability to use direct pep508 urls in install_requires in the future also? From oscar.j.benjamin at gmail.com Sun Jan 20 16:27:25 2019 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Sun, 20 Jan 2019 21:27:25 +0000 Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> <875zum8lfo.fsf@handshake.de> <875zulje49.fsf@handshake.de> <1149632f-0817-4733-985f-37b1ad909ab8@googlegroups.com> Message-ID: On Sun, 20 Jan 2019 at 21:12, dcs3spp via Python-list wrote: > > Pip 18.1 supports reading pep508 direct urls from install_requires. In future release there are plans to deprecate the --process-dependency-links pip install option: > - https://github.com/pypa/pip/issues/4187 > - https://github.com/pypa/pip/pull/4175 > > Will setuptools provide ability to use direct pep508 urls in install_requires in the future also? Someone might answer here but if not I suggest asking this on distutils-sig: https://www.python.org/community/sigs/current/distutils-sig/ Also: https://github.com/pypa/setuptools/issues -- Oscar From simonppears at googlemail.com Sun Jan 20 16:36:52 2019 From: simonppears at googlemail.com (dcs3spp) Date: Sun, 20 Jan 2019 13:36:52 -0800 (PST) Subject: python package management confusion In-Reply-To: References: <42376f44-9a23-4f81-8568-1886a55737b2@googlegroups.com> <878szm75l8.fsf@handshake.de> <87imypqdwu.fsf@handshake.de> <80365292-a560-49b2-956b-948e378fadbd@googlegroups.com> <878szj4tpj.fsf@handshake.de> <9c54fc72-1742-4b4d-a467-2573bf65efb6@googlegroups.com> <875zum8lfo.fsf@handshake.de> <875zulje49.fsf@handshake.de> <1149632f-0817-4733-985f-37b1ad909ab8@googlegroups.com> Message-ID: <99dcf4e4-39a5-4036-871d-9c622bb9b0e7@googlegroups.com> On Sunday, 20 January 2019 21:27:53 UTC, Oscar Benjamin wrote: > On Sun, 20 Jan 2019 at 21:12, dcs3spp via Python-list > wrote: > > > > Pip 18.1 supports reading pep508 direct urls from install_requires. In future release there are plans to deprecate the --process-dependency-links pip install option: > > - https://github.com/pypa/pip/issues/4187 > > - https://github.com/pypa/pip/pull/4175 > > > > Will setuptools provide ability to use direct pep508 urls in install_requires in the future also? > > Someone might answer here but if not I suggest asking this on distutils-sig: > https://www.python.org/community/sigs/current/distutils-sig/ > > Also: > https://github.com/pypa/setuptools/issues > > -- > Oscar Cheers, thanks for the resource links, will give them a go. Appreciated :) From cs at cskk.id.au Sun Jan 20 18:44:08 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 21 Jan 2019 10:44:08 +1100 Subject: basic question on how "import" works In-Reply-To: References: Message-ID: <20190120234408.GA73677@cskk.homeip.net> On 19Jan2019 11:42, joseph pareti wrote: >[*u23885 at c009 3_NeuralNetworks]$ cat foo.py* >from __future__ import print_function > ># Import MNIST data >from tensorflow.examples.tutorials.mnist import input_data >mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) > >[u23885 at c009 3_NeuralNetworks]$ >when the above code is executed, equivalent of >*$ python foo.py* > >the output is as follows: >... >Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes. >Extracting /tmp/data/train-images-idx3-ubyte.gz >Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes. >Extracting /tmp/data/train-labels-idx1-ubyte.gz >Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes. >Extracting /tmp/data/t10k-images-idx3-ubyte.gz >Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes. >Extracting /tmp/data/t10k-labels-idx1-ubyte.gz >... >My questions are: > > 1. where are the write / print statements that display *Successfully > downloaded, extracting ...* I would expect these to be in the tensorflow package. Find out where that is installed, then grep the source for "Successfully". It is not uncommon for programmes to set their logging threshlds to emit "INFO" level logs if the output is a terminal, and possibly only "WARNING" or higher otherwise, so as to provide progress reporting to a person but less noise in a batch environment. So you may just be seeing info messages reporting progress. And it is likely that tere will be some mechanism to tune how noisy that it. > 2. I don't see any such files in /tmp/data on my system, why? These are probably temporary scratch files. The module will be fetching data files into the "/tmp/data" directory (which you have specified) and unpacking and importing their data. Once that is done the file is presumably discarded. If you cd into that directory in another terminal and run "ls" commands regularly _during_ the import phase, you should see the filesappear and disappear as they are fetched, processed and discarded. Cheers, Cameron Simpson From dieter at handshake.de Mon Jan 21 02:04:25 2019 From: dieter at handshake.de (dieter) Date: Mon, 21 Jan 2019 08:04:25 +0100 Subject: How to access a folder in a zip file? References: Message-ID: <87o98alcee.fsf@handshake.de> mignoncharly via Python-list writes: > I'm a newbie in python and I was trying to access a folder inside a zip file and I also have issues with relative and absolute path. Thks in advance. > > In projects there a lot of urls (i'll read them later one by one and store them in a list/array so that I could work with it easily) > > here is the path: home/name/tutorial/prof/ks.zip/projects > > should I use > > file_name = "ks.zip" "file_name" should get the file path to your "zip" archive. This path likely ends in "ks.zip" but likely has a prefix -- either to form an "absolute" path (one starting with "/") or a relative path starting from the "current working directory". > ... > # opening the zip file in READ mode > with ZipFile(file_name, 'r') as zip: In the "with" block, "zip" is a "ZipFile Object". Read its documentation in the "zipfile" module documentation. Especially look at "namelist" (this give you the member names of the archive) and "open" or "read". The members of a folder in the "zip" archive will be charaterized by a name prefix, ending in the folder name followed by "/". There may (or may not) be a prefix before the folder name. From dieter at handshake.de Mon Jan 21 02:22:04 2019 From: dieter at handshake.de (dieter) Date: Mon, 21 Jan 2019 08:22:04 +0100 Subject: Error while using suds: suds.TypeNotFound: Type not found References: <70311809-f6e7-4a48-9626-bf6f44869fc6@googlegroups.com> Message-ID: <87k1iylbkz.fsf@handshake.de> prakashsharmacs24 at gmail.com writes: > ... > I want to consume the web services described in the following: > > https://login.keyinvoice.com/API3_ws.php?wsdl > > I am using python 3.5.x and suds version 0.6. What I tried 1 > > from suds.client import Client > url = 'https://login.keyinvoice.com/API3_ws.php?wsdl' > client = Client(url) > > Error: > > suds.TypeNotFound: Type not found: '(Array, http://www.w3.org/2001/XMLSchema, )' "TypeNotFound" typically indicates a WSDL error, more precisely an error in the XML schema part of the WSDL (defining the used types). It means that a type is referenced which "suds" cannot find. In the above case, "suds" has not found the type "Array" in the XML schema specified by "http://www.w3.org/2001/XMLSchema". "https://www.w3.org/TR/xmlschema-2/#datatype-components" is the specification for "http://www.w3.org/2001/XMLSchema" and indeed, it does not mention a type "Array". Thus, "suds" seems to be correct in not finding the type. From winikam at gmail.com Mon Jan 21 03:32:15 2019 From: winikam at gmail.com (winikam at gmail.com) Date: Mon, 21 Jan 2019 00:32:15 -0800 (PST) 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: On Tuesday, December 5, 2017 at 7:44:48 AM UTC+11, christian... at gmail.com wrote: > Same with me, except that I tried to install Python 3.6.3. Unchecking "Install launcher for all users" helped, however. It works perfectly by unchecking that box! Thanks!! From pe3no at o2.pl Mon Jan 21 16:49:19 2019 From: pe3no at o2.pl (pe3no at o2.pl) Date: Mon, 21 Jan 2019 22:49:19 +0100 Subject: Find and display gif file/s in web browser, according to the passed string, compared to files names in the folder. Message-ID: Dear Programmers, I would like to ask you to write a program/script in Python 3.7 working at Windows 10 and Debian 9.x, according to the scenario: 1). The User in the console is writing the command and a text parameter, e.g.: "d Adam" 2). Script/program "d" assigns value "Adam" to variable "x". 3). A search is done in the folder from which command/script "d" was called. We check in all files names that have ".gif" extension. 4). Each file name is built according to the following pattern : Characters 1-7 contain the file prefix+number, Character/s starting from 8 to "*" are called "InitialText". Character/s from the first character after "*" until ".gif" are called "FinalText" 5). Program has to find file/s, for which "Adam" (value of "x") is between "InitialText" and "FinalText" and open it/them in a web browser. 6). Example 1: 6.1). Command "d Adam" was written in console. 6.2). Program found file WWP0001A*Azor.gif 6.3). "Adam" is between "A" and "Azor" 6.4). File "WWP0001A*Azor.gif" has been opened in the web browser. - Program has to open it in the next tab of an already opened browser. - If no web browser was open yet, the script has to open it first. - We want to open each gif file in a new tab of the same web browser. 7). Example 2: 7.1). "d Brzoza" was inserted in the console. 7.2). Program found 2 files that fit to the parameter : 7.2.1). WWP1119Barbara*Bzura.gif "Brzoza" is between "Barbara" and "Bzura". 7.2.2). WWP5324Akwarystyka*Przeprowadzka.gif "Brzoza" is also between "Akwarystyka" and "Przeprowadzka" 7.2.3). Both the files are opened in two new tabs of web browser. Number of files in search folder : 5000-10000 (no subfolders) The acceptable execution time : up to 3 seconds. Latin alphabet sorting or UTF-8 but I am not sure how to do it to let it work in both Windows 10 and Linux (e.g.: Debian 9.x) For the moment Polish, English and Italian languages will be used. (Russian, Japanese or Chinese might be added in future but not now). If this is a big problem, we can remove special characters, so "?" will be treated as "a", "?" as "e", etc. using the standard Latin sorting : abcdefghijklmnopqrstuvwxyz for the moment. If for performance reason it was a problem to search each time "on the fly" all files names in the directory then I would like to ask to suggest a solution to accelerate the search process. Please provide a detailed specification which would help me to prepare e.g. an index that would help to search, including rules, structure description/definition, exclusions, etc. I'm ready to pay a reasonable amount of money for writing it for me. Please, send your proposal to my e-mail from which I sent this article. Please, be patient if I expressed something not fully professionally :) Please, ask me additional questions using simple language to let me specify the missing or unclear elements "at high level" or in "pseudocode". Thank you in advance and best regards~~Peter~~pe3no. From grant.b.edwards at gmail.com Tue Jan 22 10:28:43 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 22 Jan 2019 15:28:43 -0000 (UTC) Subject: Find and display gif file/s in web browser, according to the passed string, compared to files names in the folder. References: Message-ID: On 2019-01-22, Dennis Lee Bieber wrote: > On Mon, 21 Jan 2019 22:49:19 +0100, "pe3no at o2.pl" declaimed > the following: > >>Character/s starting from 8 to "*" are called "InitialText". > > Illegal requirement in Windows, and likely also in Linux. "*" is > considered a wild-card character by command line utilities. In Linux, it quite legal to have a '*' character anywhere in a in a filename. In Linux, there are only two characters that are not allowed to appear in filenames: '/' and '\x00'. Using '*' as part of a filename does requires that you escape it if writing in a language that regards it as a special character (e.g. Bash or the 're' pattern language). However, Linux doesn't care, and neither does Python. > Define reasonable... Charging as a contractor I'd likely be asking > for $75-100 US$ PER HOUR SPENT. That seems a bit low to me. And don't forget the 4 hour minimum... -- Grant Edwards grant.b.edwards Yow! I'm rated PG-34!! at gmail.com From vincent.vande.vyvre at telenet.be Tue Jan 22 07:38:59 2019 From: vincent.vande.vyvre at telenet.be (Vincent Vande Vyvre) Date: Tue, 22 Jan 2019 13:38:59 +0100 Subject: How to force the path of a lib ? Message-ID: <03669bc2-c4e3-09be-ac05-c418a3c7f07c@telenet.be> I'm working into a virtual environment (py370_venv) python-3.7.0 is installed into .localpythons/lib/python3.7 So, the paths are: # python-3.7.0 ~/.localpythons/lib/python3.7/ # my binding python -> libexiv2 ~/.localpythons/lib/python3.7/site-packages/pyexiv2/*.py ~/.localpythons/lib/python3.7/site-packages/pyexiv2/libexiv2python.cpython-37m-x86_64-linux-gnu.so # and the latest version of libexiv2 ~/CPython/py370_venv/lib/libexiv2.so.0.27.0 All theses path are in the sys.path Now I test my binding: >>> import pyexiv2 Traceback (most recent call last): ? File "", line 1, in ? File "/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/pyexiv2/__init__.py", line 60, in ??? import libexiv2python ImportError: /home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/libexiv2python.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE >>> Checking the libexiv2.so the symbol exists ~/CPython/py370_venv/lib$ objdump -T libexiv2.so.0.27.0 .... 000000000012c8d0 g??? DF .text??? 000000000000000f? Base _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE .... But it is not present into my old libexiv2 system, so I presume python use /usr/lib/x86_64-linux-gnu/libexiv2.so.14.0.0? (The old 0.25) instead of ?~/CPython/py370_venv/lib/libexiv2.so.0.27.0 (The latest 0.27) How can I solve that ? My sys.path: ['', '/home/vincent/.localpythons/lib/python37.zip', '/home/vincent/.localpythons/lib/python3.7', '/home/vincent/.localpythons/lib/python3.7/lib-dynload', '/home/vincent/CPython/py370_venv/lib/python3.7/site-packages', '/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg', '/home/vincent/CPython/py370_venv/lib/'] Thanks, Vincent From vincent.vande.vyvre at telenet.be Tue Jan 22 12:30:50 2019 From: vincent.vande.vyvre at telenet.be (Vincent Vande Vyvre) Date: Tue, 22 Jan 2019 18:30:50 +0100 Subject: How to force the path of a lib ? Message-ID: (Resend because the previous message was incomplete) Hi, I am working on a python3 binding of a C++ lib. This lib is installed in my system but the latest version of this lib introduce several incompatibilities. So I need to update my python binding. I'm working into a virtual environment (py370_venv) python-3.7.0 is installed into ./localpythons/lib/python3.7 So, the paths are: # python-3.7.0 ~/./localpythons/lib/python3.7/ # my binding python -> libexiv2 ~/./localpythons/lib/python3.7/site-packages/pyexiv2/*.py ~/./localpythons/lib/python3.7/site-packages/pyexiv2/libexiv2python.cpython-37m-x86_64-linux-gnu.so # and the latest version of libexiv2 ~/CPython/py370_venv/lib/libexiv2.so.0.27.0 All theses path are in the sys.path Now I test my binding: >>> import pyexiv2 Traceback (most recent call last): ? File "", line 1, in ? File "/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/pyexiv2/__init__.py", line 60, in ??? import libexiv2python ImportError: /home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/libexiv2python.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE >>> Checking the libexiv2.so the symbol exists ~/CPython/py370_venv/lib$ objdump -T libexiv2.so.0.27.0 .... 000000000012c8d0 g??? DF .text??? 000000000000000f? Base _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE .... But it is not present into my old libexiv2 system, so I presume python use /usr/lib/x86_64-linux-gnu/libexiv2.so.14.0.0? (The old 0.25) instead of ?~/CPython/py370_venv/lib/libexiv2.so.0.27.0 (The latest 0.27) How can I solve that ? My sys.path: ['', '/home/vincent/.localpythons/lib/python37.zip', '/home/vincent/.localpythons/lib/python3.7', '/home/vincent/.localpythons/lib/python3.7/lib-dynload', '/home/vincent/CPython/py370_venv/lib/python3.7/site-packages', '/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg', '/home/vincent/CPython/py370_venv/lib/'] Thanks, Vincent From Joseph.Schachner at Teledyne.com Tue Jan 22 14:00:59 2019 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Tue, 22 Jan 2019 19:00:59 +0000 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? Message-ID: In the company I work for we have a program (free) that runs scripts (that we sell) to test according to particular standards. The program embeds a Python interpreter, and the scripts are Python (which uses functions revealed to Python from within the program). Well, this year must be time ... I've told my manager that we need to change from Python 2.7.13 (the last version to which I updated it) to Python 3.x, whatever the latest is, sometime this year and to get that on our roadmap. I should mention that updating from earlier 2.x versions through 2.7.13 has not caused any errors or problems in our scripts. I guess that is as expected. I've read about the 2to3 utility, and I think our Python code is pretty simple ... I don't expect much beyond changing print to print( ) wherever it occurs (we capture stdout and stderr and emit what we get to a file, that can be very helpful). There are Python function calls to C functions that are callable from Python in our program but that should not be a problem, they are known to be functions. Still, I am concerned; I have never tried using 2to3 so I can't give a justifiable estimate of how long this migration might take. For anyone who has moved a substantial bunch of Python 2 to Python 3, can you please reply with your experience? Did you run into any issues? Did 2to3 do its job well, or did you have to review its output to eliminate some working but silly thing? Thank you, anyone who replies, for replying. --- Joseph S. From cem.isik at compello.com.tr Tue Jan 22 14:18:25 2019 From: cem.isik at compello.com.tr (cem.isik at compello.com.tr) Date: Tue, 22 Jan 2019 11:18:25 -0800 (PST) Subject: ttk present but not found for import In-Reply-To: References: Message-ID: <1ce62775-5683-4a5c-be6c-84a41fa85655@googlegroups.com> On Sunday, 20 January 2019 02:01:45 UTC+3, Rich Shepard wrote: > I've started to learn tkinter as the GUI widget set I'll use from now on. > While ttk-8.6 is installed here (/usr/lib/tk8.6/ttk), I cannot import it: > > $ python3 > Python 3.6.7 (default, Dec 8 2018, 06:22:57) > [GCC 5.5.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import tkinter > >>> import ttk > Traceback (most recent call last): > File "", line 1, in > ModuleNotFoundError: No module named 'ttk' > >>> > > What have I done incorrectly? > > TIA, > > Rich try as below; import tkinter.ttk as ttk From cem.isik at compello.com.tr Tue Jan 22 14:18:49 2019 From: cem.isik at compello.com.tr (cem.isik at compello.com.tr) Date: Tue, 22 Jan 2019 11:18:49 -0800 (PST) Subject: ttk present but not found for import In-Reply-To: References: Message-ID: <19d24ef1-d195-4f33-aaea-91eb926fd20b@googlegroups.com> On Sunday, 20 January 2019 02:01:45 UTC+3, Rich Shepard wrote: > I've started to learn tkinter as the GUI widget set I'll use from now on. > While ttk-8.6 is installed here (/usr/lib/tk8.6/ttk), I cannot import it: > > $ python3 > Python 3.6.7 (default, Dec 8 2018, 06:22:57) > [GCC 5.5.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import tkinter > >>> import ttk > Traceback (most recent call last): > File "", line 1, in > ModuleNotFoundError: No module named 'ttk' > >>> > > What have I done incorrectly? > > TIA, > > Rich From grant.b.edwards at gmail.com Tue Jan 22 14:20:23 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 22 Jan 2019 19:20:23 -0000 (UTC) Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? References: Message-ID: On 2019-01-22, Schachner, Joseph wrote: > For anyone who has moved a substantial bunch of Python 2 to Python > 3, can you please reply with your experience? If you used bytes (or raw binary strings) at all (e.g. for doing things like network or serial protocols) you're in for a lot of pain. Everything else is pretty minor. -- Grant Edwards grant.b.edwards Yow! Are we live or on at tape? gmail.com From rshepard at appl-ecosys.com Tue Jan 22 14:55:43 2019 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 22 Jan 2019 11:55:43 -0800 (PST) Subject: ttk present but not found for import In-Reply-To: <1ce62775-5683-4a5c-be6c-84a41fa85655@googlegroups.com> References: <1ce62775-5683-4a5c-be6c-84a41fa85655@googlegroups.com> Message-ID: On Tue, 22 Jan 2019, cem.isik at compello.com.tr wrote: > try as below; > import tkinter.ttk as ttk I posted this solution shortly after the first message. Thanks, Rich From akkana at shallowsky.com Tue Jan 22 17:42:05 2019 From: akkana at shallowsky.com (Akkana Peck) Date: Tue, 22 Jan 2019 15:42:05 -0700 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: References: Message-ID: <20190122224205.GD1452@shallowsky.com> Grant Edwards writes: > On 2019-01-22, Schachner, Joseph wrote: > > > For anyone who has moved a substantial bunch of Python 2 to Python > > 3, can you please reply with your experience? > > If you used bytes (or raw binary strings) at all (e.g. for doing > things like network or serial protocols) you're in for a lot of pain. > > Everything else is pretty minor. 2to3 handles most porting issues nicely. The three pain points I've hit are the bytes vs strings vs unicode problem Grant mentions; GUIs in either Qt or (especially) GTK; and networking, anything that uses urllib, urllib2 or related libraries. For those three issues I usually have to do a lot of porting and debugging by hand, and a lot of testing afterward because there are always problems that crop up later upon discovering that the Python3 version of some library is returning bytes when Python3 wants chars, or some such. If you don't have automated tests set up, consider writing some now, before you start porting, with particular emphasis on anything that gets data from a network or writes it to a file. ...Akkana From rosuav at gmail.com Tue Jan 22 17:54:51 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 23 Jan 2019 09:54:51 +1100 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: <20190122224205.GD1452@shallowsky.com> References: <20190122224205.GD1452@shallowsky.com> Message-ID: On Wed, Jan 23, 2019 at 9:43 AM Akkana Peck wrote: > > Grant Edwards writes: > > On 2019-01-22, Schachner, Joseph wrote: > > > > > For anyone who has moved a substantial bunch of Python 2 to Python > > > 3, can you please reply with your experience? > > > > If you used bytes (or raw binary strings) at all (e.g. for doing > > things like network or serial protocols) you're in for a lot of pain. > > > > Everything else is pretty minor. > > 2to3 handles most porting issues nicely. The three pain points I've > hit are ...... networking, anything that > uses urllib, urllib2 or related libraries. For this last one, I would recommend first porting your code to using 'requests' as much as possible, if you aren't already. The requests API is consistent across Py2 and Py3, and then all you need urllib itself for is a handful of utility functions like urllib.parse, which I believe 2to3 can handle. Yes, requests is third-party. But it's such a good library that I recommend it fully any time you aren't utterly unable to use non-core libraries. ChrisA From cs at cskk.id.au Tue Jan 22 18:21:02 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 23 Jan 2019 10:21:02 +1100 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: References: Message-ID: <20190122232102.GA78179@cskk.homeip.net> On 22Jan2019 19:20, Grant Edwards wrote: >On 2019-01-22, Schachner, Joseph wrote: >> For anyone who has moved a substantial bunch of Python 2 to Python >> 3, can you please reply with your experience? > >If you used bytes (or raw binary strings) at all (e.g. for doing >things like network or serial protocols) you're in for a lot of pain. Yes, but you will be the better for it afterwards. I've had a few programs which worked with binary data, and often also "text". In Python 2 there was _constant_ uncertanty when these were mixed (writing text into binary fields and related). In Python 3 I am never confused. It is a huge win. The pain here is completely offset by the relief which comes later. >Everything else is pretty minor. Largely. It is also possible to write a _lot_ of code compatible with both 2 and 3. from __future__ import absolute_imports, print_function gets you a long way. It will force these 2 things on your Python 2, making it Python 3 ready in that regard before you cut over. I gather the 2to3 tool is useful, but it generates _separate_ Python 3 code from your python 2 codebase as I understand it. I don't like that maintenance burden. I went with portability myself for most things, and a small personal library of python 3 flavoured routines with python 2 ports for some differing behaviour (because that gets me native Python 3 performance in Python 3, post cutover - the library is basicly "import the Python 3 names" in Python 3, and "implement the same names in Python 2" where needed for the Python 2). The "six" library is apparently the go to one for this kind of thing, I gather. The pain level is really pretty low. The bytes vs strings stuff is the most difficult, but the outcome is vastly better afterwards. Cheers, Cameron Simpson From dieter at handshake.de Wed Jan 23 01:56:56 2019 From: dieter at handshake.de (dieter) Date: Wed, 23 Jan 2019 07:56:56 +0100 Subject: How to force the path of a lib ? References: Message-ID: <87a7jrn9on.fsf@handshake.de> Vincent Vande Vyvre writes: > I am working on a python3 binding of a C++ lib. This lib is installed > in my system but the latest version of this lib introduce several > incompatibilities. So I need to update my python binding. > > I'm working into a virtual environment (py370_venv) python-3.7.0 is > installed into ./localpythons/lib/python3.7 > > So, the paths are: > # python-3.7.0 > ~/./localpythons/lib/python3.7/ > # my binding python -> libexiv2 > ~/./localpythons/lib/python3.7/site-packages/pyexiv2/*.py > ~/./localpythons/lib/python3.7/site-packages/pyexiv2/libexiv2python.cpython-37m-x86_64-linux-gnu.so > > # and the latest version of libexiv2 > ~/CPython/py370_venv/lib/libexiv2.so.0.27.0 > > All theses path are in the sys.path > > Now I test my binding: >>>> import pyexiv2 > Traceback (most recent call last): > ? File "", line 1, in > ? File > "/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/pyexiv2/__init__.py", > line 60, in > ??? import libexiv2python > ImportError: > /home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/libexiv2python.cpython-37m-x86_64-linux-gnu.so: > undefined symbol: _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE >>>> > > Checking the libexiv2.so the symbol exists > ~/CPython/py370_venv/lib$ objdump -T libexiv2.so.0.27.0 > .... > 000000000012c8d0 g??? DF .text??? 000000000000000f? Base > _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE > .... > > But it is not present into my old libexiv2 system, so I presume python use > /usr/lib/x86_64-linux-gnu/libexiv2.so.14.0.0? (The old 0.25) instead of > ?~/CPython/py370_venv/lib/libexiv2.so.0.27.0 (The latest 0.27) > > How can I solve that ? To load external C/C++ shared objects, the dynamic lickage loader (ldd) is used. "ldd" does not look at Pthon's "sys.path". Unless configured differently, it looks at standard places (such as "/usr/lib/x86_64-linux-gnu"). You have several options to tell "ldd" where to look for shared objects: * use the envvar "LD_LIBRARY_PATH" This is a "path variable" similar to the shell's "PATH", telling the dynamic loader in which directories (before the standard ones) to look for shared objects * use special linker options (when you link your Python extension shared object) to tell where dependent shared object can be found. From dieter at handshake.de Wed Jan 23 02:08:41 2019 From: dieter at handshake.de (dieter) Date: Wed, 23 Jan 2019 08:08:41 +0100 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? References: Message-ID: <875zufn952.fsf@handshake.de> "Schachner, Joseph" writes: > ... > For anyone who has moved a substantial bunch of Python 2 to Python 3, can you please reply with your experience? It can be simple and it can be difficult. I have found "http://python-future.org/compatible_idioms.html" especially useful. > Did you run into any issues? Besides the already mentioned "urllib*" and "bytes/str" problems, I have had significant issues with "dict" (missing "iter*" methods, missing "has_key"). Another important problem domain are doctests with unicode results. > Did 2to3 do its job well I have not used "2to3" -- because I doubt, that it can handle important cases, i.e. when a Python 2 "str" must become a Python 3 bytes or when a "dict.{keys, values, items}" must be listified. From rosuav at gmail.com Wed Jan 23 02:25:42 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 23 Jan 2019 18:25:42 +1100 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: <875zufn952.fsf@handshake.de> References: <875zufn952.fsf@handshake.de> Message-ID: On Wed, Jan 23, 2019 at 6:10 PM dieter wrote: > > Did 2to3 do its job well > > I have not used "2to3" -- because I doubt, that it can handle > important cases, i.e. when a Python 2 "str" must become a Python 3 bytes > or when a "dict.{keys, values, items}" must be listified. Have you tried? It errs on the side of safety. Your code should be functional, and then if you decide that they _don't_ need to be listified, you can remove the list() call. ChrisA From ndbecker2 at gmail.com Wed Jan 23 07:11:42 2019 From: ndbecker2 at gmail.com (Neal Becker) Date: Wed, 23 Jan 2019 07:11:42 -0500 Subject: How to force the path of a lib ? References: <87a7jrn9on.fsf@handshake.de> Message-ID: dieter wrote: > Vincent Vande Vyvre writes: >> I am working on a python3 binding of a C++ lib. This lib is installed >> in my system but the latest version of this lib introduce several >> incompatibilities. So I need to update my python binding. >> >> I'm working into a virtual environment (py370_venv) python-3.7.0 is >> installed into ./localpythons/lib/python3.7 >> >> So, the paths are: >> # python-3.7.0 >> ~/./localpythons/lib/python3.7/ >> # my binding python -> libexiv2 >> ~/./localpythons/lib/python3.7/site-packages/pyexiv2/*.py >> ~/./localpythons/lib/python3.7/site- packages/pyexiv2/libexiv2python.cpython-37m-x86_64-linux-gnu.so >> >> # and the latest version of libexiv2 >> ~/CPython/py370_venv/lib/libexiv2.so.0.27.0 >> >> All theses path are in the sys.path >> >> Now I test my binding: >>>>> import pyexiv2 >> Traceback (most recent call last): >> File "", line 1, in >> File >> "/home/vincent/CPython/py370_venv/lib/python3.7/site- packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/pyexiv2/__init__.py", >> line 60, in >> import libexiv2python >> ImportError: >> /home/vincent/CPython/py370_venv/lib/python3.7/site- packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/libexiv2python.cpython-37m- x86_64-linux-gnu.so: >> undefined symbol: _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE >>>>> >> >> Checking the libexiv2.so the symbol exists >> ~/CPython/py370_venv/lib$ objdump -T libexiv2.so.0.27.0 >> .... >> 000000000012c8d0 g DF .text 000000000000000f Base >> _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE >> .... >> >> But it is not present into my old libexiv2 system, so I presume python >> use /usr/lib/x86_64-linux-gnu/libexiv2.so.14.0.0 (The old 0.25) instead >> of ~/CPython/py370_venv/lib/libexiv2.so.0.27.0 (The latest 0.27) >> >> How can I solve that ? > > To load external C/C++ shared objects, the dynamic lickage loader > (ldd) is used. "ldd" does not look at Pthon's "sys.path". > Unless configured differently, it looks at standard places > (such as "/usr/lib/x86_64-linux-gnu"). > > You have several options to tell "ldd" where to look for > shared objects: > > * use the envvar "LD_LIBRARY_PATH" > This is a "path variable" similar to the shell's "PATH", > telling the dynamic loader in which directories (before > the standard ones) to look for shared objects > > * use special linker options (when you link your Python > extension shared object) to tell where dependent shared > object can be found. > To follow up on that last point, look up --rpath and related. From joepareti54 at gmail.com Wed Jan 23 08:47:57 2019 From: joepareti54 at gmail.com (joseph pareti) Date: Wed, 23 Jan 2019 14:47:57 +0100 Subject: generate matplotlib images without having access to an X server Message-ID: The following piece of code is supposed to generate images for plotting: (in *bold*, my added / corrected statements) ... *# JP handle non X server* *import matplotlib* *matplotlib.use('Agg')* # JP import matplotlib.pyplot as plt import numpy as np import tensorflow as tf ... # Generate images from noise, using the generator network. f, a = plt.subplots(4, 10, figsize=(10, 4)) for i in range(10): # Noise input. z = np.random.uniform(-1., 1., size=[4, noise_dim]) g = sess.run([gen_sample], feed_dict={gen_input: z}) g = np.reshape(g, newshape=(4, 28, 28, 1)) # Reverse colours for better display g = -1 * (g - 1) for j in range(4): # Generate image from noise. Extend to 3 channels for matplot figure. img = np.reshape(np.repeat(g[j][:, :, np.newaxis], 3, axis=2), newshape=(28, 28, 3)) a[j][i].imshow(img) *# JP HAck* *# see https://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server * *# "tuple packing" -----> https://docs.python.org/2/tutorial/datastructures.html#tuples-and-sequences * *# f.show()* *# plt.draw()* *# plt.waitforbuttonpress()* *# a.savefig('a.png')* * f.savefig('f.png')* To make it run, I commented out all plt.* statements. Indeed it runs and it produces the 'f.png' picture. However, when the statement: a.savefig('a.png') is also activated (i.e. not commented out), the program ends with the following exception: * a.savefig('a.png')* *AttributeError: 'numpy.ndarray' object has no attribute 'savefig'* Anything I am missing? I am not familiar with the code, just trying to understand it. Thank you -- Regards, Joseph Pareti - Artificial Intelligence consultant cell +49 1520 1600 209 cell +39 339 797 0644 From grant.b.edwards at gmail.com Wed Jan 23 09:15:30 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 23 Jan 2019 14:15:30 -0000 (UTC) Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? References: <20190122232102.GA78179@cskk.homeip.net> Message-ID: On 2019-01-22, Cameron Simpson wrote: > On 22Jan2019 19:20, Grant Edwards wrote: >>On 2019-01-22, Schachner, Joseph wrote: >>> For anyone who has moved a substantial bunch of Python 2 to Python >>> 3, can you please reply with your experience? >> >>If you used bytes (or raw binary strings) at all (e.g. for doing >>things like network or serial protocols) you're in for a lot of pain. > > Yes, but you will be the better for it afterwards. It's a lot better if you're leaving Python2 behind. If you're maintaing 2/3 compatible code that uses bytes, the pain is chronic rather than acute. > I've had a few programs which worked with binary data, and often > also "text". In Python 2 there was _constant_ uncertanty when these > were mixed (writing text into binary fields and related). In Python > 3 I am never confused. It is a huge win. For whatever reason, I guess I never ran into that very much. -- Grant Edwards grant.b.edwards Yow! Here I am in the at POSTERIOR OLFACTORY LOBULE gmail.com but I don't see CARL SAGAN anywhere!! From bill at baddogconsulting.com Wed Jan 23 12:18:03 2019 From: bill at baddogconsulting.com (Bill Deegan) Date: Wed, 23 Jan 2019 09:18:03 -0800 Subject: SCons 3.0.4 Release Message-ID: A new SCons release, 3.0.4, is now available on the SCons download page: http://www.scons.org/download.php Or via pypi: pip install scons Here is a summary of the changes since 3.0.3: NEW FUNCTIONALITY - Added TEMPFILESUFFIX to allow user to specify suffix for tempfiles used for long command lines - Initial support for ARM architectures with Microsoft Visual Studio 2017. You must set TARGET_ARCH to arm or arm64 to enable. FIXES - Fixed issue detecting installs of Microsoft Visual Studio 2017 as well as Microsoft build tools 2017. git shortlog --no-merges -ns 3.0.3..HEAD 17 Daniel 10 Mats Wichmann 4 Daniel Moody 4 William Deegan 3 anatoly techtonik 1 Tobias Herzog From cs at cskk.id.au Wed Jan 23 15:22:53 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Thu, 24 Jan 2019 07:22:53 +1100 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: References: Message-ID: <20190123202253.GA1676@cskk.homeip.net> On 23Jan2019 14:15, Grant Edwards wrote: >On 2019-01-22, Cameron Simpson wrote: >> On 22Jan2019 19:20, Grant Edwards wrote: >>>On 2019-01-22, Schachner, Joseph wrote: >>>> For anyone who has moved a substantial bunch of Python 2 to Python >>>> 3, can you please reply with your experience? >>> >>>If you used bytes (or raw binary strings) at all (e.g. for doing >>>things like network or serial protocols) you're in for a lot of pain. >> >> Yes, but you will be the better for it afterwards. > >It's a lot better if you're leaving Python2 behind. If you're >maintaing 2/3 compatible code that uses bytes, the pain is chronic >rather than acute. Um, yes, very true. >> I've had a few programs which worked with binary data, and often >> also "text". In Python 2 there was _constant_ uncertanty when these >> were mixed (writing text into binary fields and related). In Python >> 3 I am never confused. It is a huge win. > >For whatever reason, I guess I never ran into that very much. The instance I have in mind was a fairly complex bit of code doing lots of binary and also strings in Python 2. It is now Python 3 only and far cleaner. As as you suggest, _not_ Python 2 compatible. Cheers, Cameron Simpson From stefan_ml at behnel.de Wed Jan 23 15:34:07 2019 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 23 Jan 2019 21:34:07 +0100 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: <20190122232102.GA78179@cskk.homeip.net> References: <20190122232102.GA78179@cskk.homeip.net> Message-ID: Cameron Simpson schrieb am 23.01.19 um 00:21: > ?from __future__ import absolute_imports, print_function > > gets you a long way. ... and: division. Stefan From ian.g.kelly at gmail.com Wed Jan 23 16:51:55 2019 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 23 Jan 2019 14:51:55 -0700 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: References: <20190122232102.GA78179@cskk.homeip.net> Message-ID: On Wed, Jan 23, 2019 at 1:36 PM Stefan Behnel wrote: > > Cameron Simpson schrieb am 23.01.19 um 00:21: > > from __future__ import absolute_imports, print_function > > > > gets you a long way. > > ... and: division. All right, but apart from absolute imports, the print function, and true division, what has Python 3.x ever done for us? *ducks* From paulmattheww at gmail.com Wed Jan 23 17:29:38 2019 From: paulmattheww at gmail.com (paulmattheww at gmail.com) Date: Wed, 23 Jan 2019 14:29:38 -0800 (PST) Subject: ValueError: Input contains NaN, infinity or a value too large for dtype('float32') In-Reply-To: References: Message-ID: <2bc28f14-ff32-4d7f-b15f-58034c53cc6b@googlegroups.com> > You may be using the sklearn package incorrectly; you'll > have to read the (apparently quite prolific) documentation yourself, > I've never used it. > > -- > Rhodri James *-* Kynesim Ltd So why would you try to answer it? I have the same issue but there are no NaN, infinites, negative infinites or large values. From PythonList at DancesWithMice.info Wed Jan 23 19:38:56 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 24 Jan 2019 13:38:56 +1300 Subject: checking protocols. In-Reply-To: <003c01d4b043$5133be70$f39b3b50$@verizon.net> References: <003c01d4b043$5133be70$f39b3b50$@verizon.net> Message-ID: <383da114-d6aa-48d2-6b53-a52e17700b11@DancesWithMice.info> Avi Haven't noticed an answer to this. Did I miss anything? On 20/01/19 11:07 AM, Avi Gross wrote: > Short question. Checking if a protocol is set up? =do you mean that to check/require that a class exhibits a particular protocol we should use abstract classes - will not instantiate unless all the required components are coded? > Many python improvements are changes to classes that implement a protocol. > There are things you can do to make your own classes work with the protocol > by setting various dunder variables like __iter__, __next__ and writing > appropriate ode including throwing the right error class when done. > Similarly the "with" statement works with objects that implement __enter__ > and __exit__. There can be plenty of others like this and more can be > anticipated in the future. > > So, several related questions. Tools that help a developer add appropriate > things to an object to implement the protocol or to test if it was done > right. Perhaps a function with a name like is_iterable() that tells if the > protocol can be applied. For the specific case of an iterable, I found > something that seems to work for at least some cases: > > from collections import Iterable > item = [1, 2, 3, 4] > > isinstance(item, Iterable) > > Not sure if it would work on one I created that did the right things or what > it checks. =your code should be 'approved' if it implements the next() method, etc. Did you try such? > I am interested in a pointer to something that describes many of the known > protocols or extensions and maybe to modules designed sort of as I said > above. I am aware some protocols may be not-quite standard with parts of the > protocol embedded in different objects like wrappers or objects returned > upon a request to have a proxy and many other techniques that seem to abound > and allow multiple layers of indirection or seemingly almost magical as in > multiple inheritance drop-ins and so on. That is what may make these things > harder if someone uses something like __getattr__ or descriptors to > intercept calls and provide the functionality without any actual sign of the > dunder key normally expected. =Questioning similarly, I recall finding one of these - but do you think that I can re-find it now? Apologies. I (too) think it would be handy to have such a list. There are many for the 'magic methods' themselves, in all the better Py3 texts. Yesterday I needed to add __LT__() to allow a list of class instances to be sorted, __EQ__ to enable a list of (other) instances to be searched (if element in list_of_instances), and made a class callable (__call__()). Each time I wondered: is this the best way to accomplish or is there already a mechanism I could be employing/not 'reinventing the wheel'. (perhaps incompletely!) For your further reading pleasure (maybe): On the this topic, one of many references is Interfaces in Python: Protocols and ABCs http://masnun.rocks/2017/04/15/interfaces-in-python-protocols-and-abcs/ Which reminded me of the amusingly titled: Duck Typing vs. Goose Typing, Pythonic Interfaces https://dgkim5360.github.io/blog/python/2017/07/duck-typing-vs-goose-typing-pythonic-interfaces/ Diving into the docs (although not finding exactly what we seek): https://docs.python.org/3/library/abc.html - didn't include all, eg context managers: https://docs.python.org/3/library/contextlib.html At a deeper level: https://docs.python.org/3/c-api/abstract.html?highlight=abstract and https://docs.python.org/3.6/c-api/object.html - again, incomplete in the sense (I gained) of this enquiry. Hopefully there's something to keep your mind occupied... -- Regards =dn From rosuav at gmail.com Wed Jan 23 19:44:40 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Jan 2019 11:44:40 +1100 Subject: checking protocols. In-Reply-To: <383da114-d6aa-48d2-6b53-a52e17700b11@DancesWithMice.info> References: <003c01d4b043$5133be70$f39b3b50$@verizon.net> <383da114-d6aa-48d2-6b53-a52e17700b11@DancesWithMice.info> Message-ID: On Thu, Jan 24, 2019 at 11:40 AM DL Neil wrote: > > Avi > > Haven't noticed an answer to this. Did I miss anything? > No idea where you originally sent it, but I didn't see it until just now. ChrisA From avigross at verizon.net Wed Jan 23 21:19:01 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 23 Jan 2019 21:19:01 -0500 Subject: checking protocols. In-Reply-To: <383da114-d6aa-48d2-6b53-a52e17700b11@DancesWithMice.info> References: <003c01d4b043$5133be70$f39b3b50$@verizon.net> <383da114-d6aa-48d2-6b53-a52e17700b11@DancesWithMice.info> Message-ID: <005f01d4b38b$2c1d22c0$84576840$@verizon.net> See reply BELOW in sections marked by ==========: -----Original Message----- From: DL Neil Sent: Wednesday, January 23, 2019 7:39 PM To: Avi Gross ; python-list at python.org Subject: Re: checking protocols. Avi Haven't noticed an answer to this. Did I miss anything? ==========REPLY ON non-TOP as requested on 1/23/2019============ Dave, I never saw the original message appear and thus expected no replies. I see a later post by Chris indicating he did not see it either. I assumed perhaps a moderator needed to approve it. My question really boils down to being intrigued how the python language can be extended using documented protocols in more ways and having a place where you can see a list of the ones out there and a way to join in with your own classes reliably and so on. I note there may be many unpublished protocols used internally within modules that also create similar structures but do not expect to be emulated. I see interpolated comments below and will interpolate within that but it gets confusing. ==========END first set of remarks on 1/23/2019============ ==========ORIGINAL MESSAGE BELOW if anyone wants to see in-line comments and supply info.=============== On 20/01/19 11:07 AM, Avi Gross wrote: > Short question. Checking if a protocol is set up? =do you mean that to check/require that a class exhibits a particular protocol we should use abstract classes - will not instantiate unless all the required components are coded? ========== I am not looking for any specific options but indeed including an abstract class might be one way to go. It might supply a reasonable way to ask if the class you make yourself INTENDS on running that protocol and would enforce the presence of the required methods somewhere in the inheritance chain. Of course the functions could be stubs that don't do the right thing, or anything passable. > Many python improvements are changes to classes that implement a protocol. > There are things you can do to make your own classes work with the > protocol by setting various dunder variables like __iter__, __next__ > and writing appropriate ode including throwing the right error class when done. > Similarly the "with" statement works with objects that implement > __enter__ and __exit__. There can be plenty of others like this and > more can be anticipated in the future. > > So, several related questions. Tools that help a developer add > appropriate things to an object to implement the protocol or to test > if it was done right. Perhaps a function with a name like > is_iterable() that tells if the protocol can be applied. For the > specific case of an iterable, I found something that seems to work for at least some cases: > > from collections import Iterable > item = [1, 2, 3, 4] > > isinstance(item, Iterable) > > Not sure if it would work on one I created that did the right things > or what it checks. =your code should be 'approved' if it implements the next() method, etc. Did you try such? ==========Just to be clear, yes. That is the current state of affairs. ANY CODE can be run but probably fails when it does not follow the recipe. Any of many places that expect the iteration protocol will ask for a __iter__ and either catch the error or fail. If it works, they will call __next__ as often as needed and may or may not fail well if it is not found. And, as noted, the function may throw the right error object on completion or not and that may cause the caller to fail mysteriously or be bypassed if some other error is thrown instead. What I am hoping for is OPEN to multiple solutions or to be told there is no such need. One solution would be something that can be used to exercise the function and report if the protocol is being honored. In this case, that is fairly trivial. Just try the object in one of many places the iterator protocol is used. It may be less clear how you check if the 'with' protocol is satisfied as it may not properly close whatever it is guarding like closing a file or freeing a lock. If you test that you may not notice the file remains open and so on. But will your code also work if the user closed the file already on purpose? > I am interested in a pointer to something that describes many of the > known protocols or extensions and maybe to modules designed sort of as > I said above. I am aware some protocols may be not-quite standard with > parts of the protocol embedded in different objects like wrappers or > objects returned upon a request to have a proxy and many other > techniques that seem to abound and allow multiple layers of > indirection or seemingly almost magical as in multiple inheritance > drop-ins and so on. That is what may make these things harder if > someone uses something like __getattr__ or descriptors to intercept > calls and provide the functionality without any actual sign of the dunder key normally expected. =Questioning similarly, I recall finding one of these - but do you think that I can re-find it now? Apologies. I (too) think it would be handy to have such a list. There are many for the 'magic methods' themselves, in all the better Py3 texts. Yesterday I needed to add __LT__() to allow a list of class instances to be sorted, __EQ__ to enable a list of (other) instances to be searched (if element in list_of_instances), and made a class callable (__call__()). Each time I wondered: is this the best way to accomplish or is there already a mechanism I could be employing/not 'reinventing the wheel'. (perhaps incompletely!) For your further reading pleasure (maybe): On the this topic, one of many references is Interfaces in Python: Protocols and ABCs http://masnun.rocks/2017/04/15/interfaces-in-python-protocols-and-abcs/ Which reminded me of the amusingly titled: Duck Typing vs. Goose Typing, Pythonic Interfaces https://dgkim5360.github.io/blog/python/2017/07/duck-typing-vs-goose-typing-pythonic-interfaces/ Diving into the docs (although not finding exactly what we seek): https://docs.python.org/3/library/abc.html - didn't include all, eg context managers: https://docs.python.org/3/library/contextlib.html At a deeper level: https://docs.python.org/3/c-api/abstract.html?highlight=abstract and https://docs.python.org/3.6/c-api/object.html - again, incomplete in the sense (I gained) of this enquiry. Hopefully there's something to keep your mind occupied... ==========I appreciate the references and will follow up. Quick side note about the phrase "magic" is that I was reading up on Ipython and Jupiter Notebookss and they have yet another concept of magic based on commands starting with "%" as in "%run file" as they are not talking to core python directly but sort of a level above. ===The ideal goal is for magical features to be invisible and magical at one level while being very clear and aboveboard in other ways. So, I would like to be able to do something that tells me clearly what some object implements as in: from magic import protocols_detected if ("iteration" in protocols_detected(my_object): ... Now obviously some simple protocols that use one dunder method may be easier to check in a simpler way. Does the object support a sorting algorithm as in your example? But does that mean defining either __lt__ or __gt__ or must it be both as well as __eq__ and perhaps more? There are virus checkers that store lists of fingerprints that can be used to look in places within a file to guess well if it contains a known virus. I am thinking of an application that stores some similar fingerprint for lots of known protocols and when asked, produces a list like the code above, or some other method. Of course an object that wants to support lots of protocols using mix-in and abstract classes might get quite complex. And, as noted, python on a deeper level lets programmers be beyond devious as the simple-looking object turns out to have all kinds of wrappers and proxies that can obfuscate the heck out of figuring out what methods actually exist and in which of many related objects they are hidden. I honestly cannot expect any such tools to be more than heuristics that can get it wrong. To be concrete, you can make a class definition that simply does not show a definition for something like __iter__ but uses descriptors and decorators and other techniques that effectively create the darn thing indirectly at the time it is evaluated or when it is first asked for or even delay creating what is needed until needed. The above is speculative so please don't expect me to back it up with a specific example. LOL! ==========Regardless, Avi. -- Regards =dn From robin at reportlab.com Thu Jan 24 04:16:00 2019 From: robin at reportlab.com (Robin Becker) Date: Thu, 24 Jan 2019 09:16:00 +0000 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: References: Message-ID: On 22/01/2019 19:00, Schachner, Joseph wrote: .......... > For anyone who has moved a substantial bunch of Python 2 to Python 3, can you please reply with your experience? Did you run into any issues? Did 2to3 do its job well, or did you have to review its output to eliminate some working but silly thing? > ,...... I did the port of reportlab (www.reportlab.com) from code supporting 2.x only x>=3 to a version which supported 2.7.z & >=3.3. The reportlab toolkit was then about 14 years old and had (and still has lots of cruft). The port effort began 20130215 and ended 20140326 ie 13 months. There were 333 commits on the branch. I used 2to3, but not six. Because we needed to maintain 2.7 and >=3.3 there were quite a few issues related to simple things like iterkeys/values/items <--> keys/values/items removal of xrange etc etc. Maintaining compatible extensions is also hard. Pdf production requires byte output and was already quite messy because reportlab supported both utf8 and unicode inputs; it hasn't got a lot easier. As for performance the 3.x runs were generally slower than 2.7, but I think that situation has changed with 3.6 & 3.7 (for the reportlab tests on windows 2.7 takes 68.7", 3.4 83.8", 3.5 77.0", 3.6 61.5" & 3.7 60.9"). At some point reportlab will be made 3.x only which will require more effort. -- Robin Becker From vinay_sajip at yahoo.co.uk Thu Jan 24 04:35:19 2019 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 24 Jan 2019 09:35:19 +0000 (UTC) Subject: ANN: A new version (0.4.4) of python-gnupg has been released. It contains a security-related change - please update to this version References: <486227803.367000.1548322519153.ref@mail.yahoo.com> Message-ID: <486227803.367000.1548322519153@mail.yahoo.com> A new version of the Python module which wraps GnuPG has been released. What Changed?=============This is an enhancement and security-fix release, and all users are stronglyencouraged to upgrade. Brief summary: * Fixed #108: Changed how any return value from the on_data callable is? processed. In earlier versions, the return value was ignored. In this version,? if the return value is False, the data received from gpg is not? buffered. Otherwise (if the value is None or True, for example), the? data is buffered as normal. This functionality can be used to do your own? buffering, or to prevent buffering altogether. ? The on_data callable is also called once with an empty byte-string to? signal the end of data from gpg. * Fixed #97: Added an additional attribute check_fingerprint_collisions to? GPG instances, which defaults to False. It seems that gpg is happy? to have duplicate keys and fingerprints in a keyring, so we can't be too? strict. A user can set this attribute of an instance to True to trigger a? check for collisions. * Fixed #111: With GnuPG 2.2.7 or later, provide the fingerprint of a signing? key for a failed signature verification, if available. * Fixed #21: For verification where multiple signatures are involved, a? mapping of signature_ids to fingerprint, keyid, username, creation date,? creation timestamp and expiry timestamp is provided. * Added a check to disallow certain control characters ('\r', '\n', NUL) in? passphrases. This fix mitigates against CVE-2019-6690. This release [2] has been signed with my code signing key: Vinay Sajip (CODE SIGNING KEY) Fingerprint: CA74 9061 914E AC13 8E66 EADB 9147 B477 339A 9B86 Recent changes to PyPI don't show the GPG signature with the download links.An alternative download source where the signatures are available is the project'sown downloads page [5]. What Does It Do?================The gnupg module allows Python programs to make use of thefunctionality provided by the Gnu Privacy Guard (abbreviated GPG orGnuPG). Using this module, Python programs can encrypt and decryptdata, digitally sign documents and verify digital signatures, manage(generate, list and delete) encryption keys, using proven Public KeyInfrastructure (PKI) encryption technology based on OpenPGP. This module is expected to be used with Python versions >= 2.4, as itmakes use of the subprocess module which appeared in that version ofPython. This module is a newer version derived from earlier work byAndrew Kuchling, Richard Jones and Steve Traugott. A test suite using unittest is included with the source distribution. Simple usage: >>> import gnupg>>> gpg = gnupg.GPG(gnupghome='/path/to/keyring/directory')>>> gpg.list_keys() [{...'fingerprint': 'F819EE7705497D73E3CCEE65197D5DAC68F1AAB2','keyid': '197D5DAC68F1AAB2','length': '1024','type': 'pub','uids': ['', 'Gary Gross (A test user) ']},{...'fingerprint': '37F24DD4B918CC264D4F31D60C5FEFA7A921FC4A','keyid': '0C5FEFA7A921FC4A','length': '1024',...'uids': ['', 'Danny Davis (A test user) ']}]>>> encrypted = gpg.encrypt("Hello, world!", ['0C5FEFA7A921FC4A'])>>> str(encrypted) '-----BEGIN PGP MESSAGE-----\nVersion: GnuPG v1.4.9 (GNU/Linux)\n\nhQIOA/6NHMDTXUwcEAf.-----END PGP MESSAGE-----\n'>>> decrypted = gpg.decrypt(str(encrypted), passphrase='secret')>>> str(decrypted) 'Hello, world!'>>> signed = gpg.sign("Goodbye, world!", passphrase='secret')>>> verified = gpg.verify(str(signed))>>> print "Verified" if verified else "Not verified" 'Verified' As always, your feedback is most welcome (especially bug reports [3],patches and suggestions for improvement, or any other points via themailing list/discussion group [4]). Enjoy! Cheers Vinay SajipRed Dove Consultants Ltd. [1] https://bitbucket.org/vinay.sajip/python-gnupg[2] https://pypi.python.org/pypi/python-gnupg/0.4.4[3] https://bitbucket.org/vinay.sajip/python-gnupg/issues[4] https://groups.google.com/forum/#!forum/python-gnupg[5] https://bitbucket.org/vinay.sajip/python-gnupg/downloads/ From rhodri at kynesim.co.uk Thu Jan 24 06:55:03 2019 From: rhodri at kynesim.co.uk (Rhodri James) Date: Thu, 24 Jan 2019 11:55:03 +0000 Subject: ValueError: Input contains NaN, infinity or a value too large for dtype('float32') In-Reply-To: <2bc28f14-ff32-4d7f-b15f-58034c53cc6b@googlegroups.com> References: <2bc28f14-ff32-4d7f-b15f-58034c53cc6b@googlegroups.com> Message-ID: <4f42d7c8-b465-1a72-931b-d4b33b6cadb7@kynesim.co.uk> On 23/01/2019 22:29, paulmattheww at gmail.com wrote: >> You may be using the sklearn package incorrectly; you'll >> have to read the (apparently quite prolific) documentation yourself, >> I've never used it. >> >> -- >> Rhodri James *-* Kynesim Ltd > > So why would you try to answer it? I have the same issue but there are no NaN, infinites, negative infinites or large values. > I tried to answer it probably because it looked fishy and some people need encouragement to read the fine manual. I don't know for sure, you trimmed all the attribution and I can't find a thread of this name in the archives for last year. What is "the same issue"? -- Rhodri James *-* Kynesim Ltd From robin at reportlab.com Thu Jan 24 09:17:22 2019 From: robin at reportlab.com (Robin Becker) Date: Thu, 24 Jan 2019 14:17:22 +0000 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: References: <20190122232102.GA78179@cskk.homeip.net> Message-ID: <8a734057-02de-1c5c-3b27-7468dbf4668e@chamonix.reportlab.co.uk> On 23/01/2019 21:51, Ian Kelly wrote: > On Wed, Jan 23, 2019 at 1:36 PM Stefan Behnel wrote: >> ......... > All right, but apart from absolute imports, the print function, and true > division, what has Python 3.x ever done for us? > > *ducks* > headaches :) -- Robin Becker From petef4+usenet at gmail.com Thu Jan 24 14:13:56 2019 From: petef4+usenet at gmail.com (Pete Forman) Date: Thu, 24 Jan 2019 19:13:56 +0000 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? References: Message-ID: <87zhrp50nf.fsf@gmail.com> Robin Becker writes: > On 22/01/2019 19:00, Schachner, Joseph wrote: > .......... >> For anyone who has moved a substantial bunch of Python 2 to Python 3, >> can you please reply with your experience? Did you run into any >> issues? Did 2to3 do its job well, or did you have to review its >> output to eliminate some working but silly thing? >> > ,...... > I did the port of reportlab (www.reportlab.com) from code supporting > 2.x only x>=3 to a version which supported 2.7.z & >=3.3. The > reportlab toolkit was then about 14 years old and had (and still has > lots of cruft). The port effort began 20130215 and ended 20140326 ie > 13 months. There were 333 commits on the branch. I used 2to3, but not > six. Because we needed to maintain 2.7 and >=3.3 there were quite a > few issues related to simple things like iterkeys/values/items <--> > keys/values/items removal of xrange etc etc. > > Maintaining compatible extensions is also hard. Pdf production > requires byte output and was already quite messy because reportlab > supported both utf8 and unicode inputs; it hasn't got a lot easier. > > As for performance the 3.x runs were generally slower than 2.7, but I > think that situation has changed with 3.6 & 3.7 (for the reportlab > tests on windows 2.7 takes 68.7", 3.4 83.8", 3.5 77.0", 3.6 61.5" & > 3.7 60.9"). > > At some point reportlab will be made 3.x only which will require more > effort. Packages like reportlab with a need to support both Python 2 and 3 end up with the worst of both worlds. The initial drive for Py3k was to drop cruft that had accumulated over the years. Mixing old and new hampers your ability to write clean 3 code. -- Pete Forman From vincent.vande.vyvre at telenet.be Thu Jan 24 05:24:39 2019 From: vincent.vande.vyvre at telenet.be (Vincent Vande Vyvre) Date: Thu, 24 Jan 2019 11:24:39 +0100 Subject: How to force the path of a lib ? In-Reply-To: References: <87a7jrn9on.fsf@handshake.de> Message-ID: Le 23/01/19 ? 13:11, Neal Becker a ?crit?: > dieter wrote: > >> Vincent Vande Vyvre writes: >> ..... >> To load external C/C++ shared objects, the dynamic lickage loader >> (ldd) is used. "ldd" does not look at Pthon's "sys.path". >> Unless configured differently, it looks at standard places >> (such as "/usr/lib/x86_64-linux-gnu"). >> >> You have several options to tell "ldd" where to look for >> shared objects: >> >> * use the envvar "LD_LIBRARY_PATH" >> This is a "path variable" similar to the shell's "PATH", >> telling the dynamic loader in which directories (before >> the standard ones) to look for shared objects >> >> * use special linker options (when you link your Python >> extension shared object) to tell where dependent shared >> object can be found. >> > To follow up on that last point, look up --rpath and related. > Trying the first solution with "export LD_LIBRARY_PATH=/home/vincent/CPython/py370_venv/lib" has no effect. The second solution is better, after looking de doc of distutils.core.Extension I've added this line into my setup.py ??? Extension('libexiv2python', ??????? ..., runtime_library_dirs=['/home/vincent/CPython/py370_venv/lib/'], ??????? ... rebuild, install and test Type "help", "copyright", "credits" or "license" for more information. >>> import pyexiv2 >>> Great! Many thanks, Vincent From dboland9 at offilive.com Thu Jan 24 14:42:59 2019 From: dboland9 at offilive.com (Dave) Date: Thu, 24 Jan 2019 14:42:59 -0500 Subject: preferences file Message-ID: I'm doing a small application and want to add user preferences. Did some googling to see if there are standard Python ways/tools, but it seems not so much. My specific questions are: 1. Best practices for a user preference file/system? 2. File format favored and why - ini, JSON, etc? 3. File location? I'm using Ubuntu and I believe that the correct location would be home/.config/ . What about Mac and Windows? Would like to find a Python library that handles all of this, but so far... Thanks, Dave From python.list at tim.thechases.com Thu Jan 24 14:33:28 2019 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 24 Jan 2019 13:33:28 -0600 Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: References: Message-ID: <20190124133328.6930b714@bigbox.christie.dr> On 2019-01-22 19:20, Grant Edwards wrote: > > For anyone who has moved a substantial bunch of Python 2 to Python > > 3, can you please reply with your experience? > > If you used bytes (or raw binary strings) at all (e.g. for doing > things like network or serial protocols) you're in for a lot of > pain. This was my biggest pain point, but it was a good pain. At $DAYJOB we had files coming from customers and telecom providers where the encoding had never been specified. By going through the conversion process, we were able to formalize the encoding of various files meaning fewer crashes when some unexpected character would slip in and fail to convert. A painful process, but the end result was better in a multitude of ways. -tkc From PythonList at DancesWithMice.info Thu Jan 24 15:37:09 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 25 Jan 2019 09:37:09 +1300 Subject: checking protocols. In-Reply-To: <005f01d4b38b$2c1d22c0$84576840$@verizon.net> References: <003c01d4b043$5133be70$f39b3b50$@verizon.net> <383da114-d6aa-48d2-6b53-a52e17700b11@DancesWithMice.info> <005f01d4b38b$2c1d22c0$84576840$@verizon.net> Message-ID: <29c7f758-9f0e-e699-594f-fdfacad16e12@DancesWithMice.info> Avi > > Haven't noticed an answer to this. Did I miss anything? > > I never saw the original message appear and thus expected no replies. I see a later post by Chris indicating he did not see it either. I assumed perhaps a moderator needed to approve it. =a silly question on my part. A quick check of the list archive shows your original post but no previous responses. > My question really boils down to being intrigued how the python language can be extended using documented protocols in more ways and having a place where you can see a list of the ones out there and a way to join in with your own classes reliably and so on. =if I am interpreting your intent correctly (equally that of Pythonic thinking) the idea is for 'more' to happen at compile-time. This expectation likely comes?came from our earlier training in more strict/rigid languages. Whereas many characteristics of Python flow directly as consequences of it being (chosen/designed to be) a dynamic language - and thus many?most such decisions delayed until run-time. =The first (related) example which springs to mind is object polymorphism. It must be so much harder to achieve such incredible power and flexibility (as Python does) when 'rules' are 'cast in stone' early. =However, it might be worth making suggestions generated 'here' to the (hard-working) docs team. There are discussions of specific protocols, in their individual locations throughout the manual/library. Is it sufficiently clear what is expected when building our own classes according to 'the' protocol? =Rather than collecting all the protocols' documentation together (cf the sequence currently used), maybe an cross-index somewhere? > I note there may be many unpublished protocols used internally within modules that also create similar structures but do not expect to be emulated. =coming from Python, the PSL, or third-parties? > I see interpolated comments below and will interpolate within that but it gets confusing. =am using line-prefix to help differentiate. Interleaved comments help (?me) with following the conversational flow - and ensuring that each point/question is addressed (he hopes) > On 20/01/19 11:07 AM, Avi Gross wrote: >> Short question. Checking if a protocol is set up? > > =do you mean that to check/require that a class exhibits a particular protocol we should use abstract classes - will not instantiate unless all the required components are coded? > > ========== I am not looking for any specific options but indeed including an abstract class might be one way to go. It might supply a reasonable way to ask if the class you make yourself INTENDS on running that protocol and would enforce the presence of the required methods somewhere in the inheritance chain. Of course the functions could be stubs that don't do the right thing, or anything passable. ... (previous content removed, as no longer necessary) =The phrase "we're all adults here" is often used to justify Python's apparent inexactitude (cf other languages*). However, I often wonder whether that is merely an excuse to avoid explaining oneself properly. For example, 'here' (or is it another list, strictly speaking?) I read ANNouncements of package updates. How many tell me wonderful additions to the package, how much work went into them, what I'd now be able to do with it, and who I should credit for all such goodness - but don't actually get around to mentioning the package's objectives or applicability? Unless I know said package, these ANNs are a waste of my reading-time! =On the other hand, such 'openness' as non-enforced "private variables" (applying the 'adults' phrase) enables us to consider them "private" in the normal course, but to abuse the notion should the need take us (and caution have been thrown to the wind)! =Back to protocols: and if I want to code certain magic methods, etc, comprising a protocol, should I be allowed to choose to ignore other(s)? Be it on my own head! * comparing Python to other languages is (IMHO) neither a reliable nor particularly logical argument. How can we be 'the best' if all we do is copy and reproduce everyone else - and would that even be possible? Surely the valid comparison is between the problems which must be solved and the facilities of the language chosen to code the solution? =That said, there is no question that Python has been developing somewhat schizoid tendencies. Another mantra has always been: 'it is better to ask forgiveness than permission'*, and thus we should wrap assumptive code in a try...except block. This change took a long time to sit comfortably in my (albeit small) brain - and possibly still requires conscious consideration. My thought pattern** is still: first check the data, then ..., ie ensure denominator is not zero before dividing rather than try: divide except (whatever): print( "Not by zero, bub!" ) * (originally attributed to Adm Grace Hopper of COBOL fame, if you're into irony!). ** after reaching for my old man's walking stick, I'll note that far fewer ComSc courses these days offer Numerical Analysis, than were available, even expected, in 'the good, old days'. Perhaps that's why earlier this week I had one of our brave, young, experts puzzled by floating-point rounding and binary approximations? =That said, look at all the isinstance()-type functions which have crept-in over the years, to say nothing of 'introspection' facilities, eg https://docs.python.org/3/library/inspect.html which are being ?mis used in creative ways. NB such appears only a few pages 'on' from the abcs mentioned last time. (BTW That section of the library: "Python Runtime Services" offers much applicable to these and earlier points) =NB I'm not complaining about a lack of consistency, and definitely not language "purity", just-saying... =After all that, if someone gives you code, should you be able to rely upon it? =Once that question, and its implications, has been considered we can move on to a slight rewording: if someone (else) gives you code, should you rely upon it? (remember all the jokes giving neophyte PC-/MS-DOS users a single line of code which caused them to blindly re-format the hard drive?) =ultimately if someone gives me a class/module instructing that it be used as a context manager, when my code runs it will fall-over in a steaming heap at the with, if there is no __exit__() (for example). At which point I will either reach out and apply rapid, sharp, pressure to the end of the miscreant's nose; or I'll reconfigure that code into 'file-13'. =if the "stubs" mentioned are there merely to remind me of an implementation concern (and hopefully, how it is expected to interface with the whole) then isn't their implementation (or lack) on my head? > ==========Just to be clear, yes. That is the current state of affairs. ANY CODE can be run but probably fails when it does not follow the recipe. Any of many places that expect the iteration protocol will ask for a __iter__ and either catch the error or fail. If it works, they will call __next__ as often as needed and may or may not fail well if it is not found. And, as noted, the function may throw the right error object on completion or not and that may cause the caller to fail mysteriously or be bypassed if some other error is thrown instead. What I am hoping for is OPEN to multiple solutions or to be told there is no such need. One solution would be something that can be used to exercise the function and report if the protocol is being honored. In this case, that is fairly trivial. Just try the object in one of many places the iterator protocol is used. It may be less clear how you check if the 'with' protocol is satisfied as it may not properly close whatever it is guarding like > closing a file or freeing a lock. If you test that you may not notice the file remains open and so on. But will your code also work if the user closed the file already on purpose? ... =much of this discussed, above. Failures in documentation go back for as long as there has been programmers! =We should now move to such considerations at TDD (Test-driven Design) - again, somewhat different, albeit much the same, as perhaps we were first taught. =I tell you nothing in describing the typical relationship between the person who writes the class and the coder who wants to use it. What are the chances that their minds are in complete agreeance? The class-coder makes various assumptions. The application-coder has hopes and requirements. The trick with up-front (and in-house) design is to find these earlier in the process. However, if time passes or the class was provided by a third-party, a library, or whatever; that is not possible. So, (your question) how can we be sure? =The TDD philosophy is that we (application writers) should first sit down and prepare some tests - if I push this data in, xyz should happen; etc. Now, if the class has come from some charlatan or incompetent (or plainly does something quite different or differently) we prove it quickly - and the other way around, the more we test, the more confidence we can have. =Isn't this preferable to 'blind faith'? =does such TDD/acceptance testing address the request: "something that can be used to exercise the function and report if the protocol is being honored"? > ==========I appreciate the references and will follow up. Quick side note about the phrase "magic" is that I was reading up on Ipython and Jupiter Notebookss and they have yet another concept of magic based on commands starting with "%" as in "%run file" as they are not talking to core python directly but sort of a level above. =Back in 'the good, old days' (now I'm really in-the-groove/playing a broken record) we often used macros and pre-processors. Isn't this %-stuff familiar in that context? > ===The ideal goal is for magical features to be invisible and magical at one level while being very clear and aboveboard in other ways. So, I would like to be able to do something that tells me clearly what some object implements as in: > > from magic import protocols_detected > if ("iteration" in protocols_detected(my_object): ... =an interesting idea. How well might it sit within the philosophies of Static Typing (https://docs.python.org/3/library/typing.html)? PEP483: https://www.python.org/dev/peps/pep-0483/ PEP484: https://www.python.org/dev/peps/pep-0484/ PEP526: https://www.python.org/dev/peps/pep-0526/ > Now obviously some simple protocols that use one dunder method may be easier to check in a simpler way. Does the object support a sorting algorithm as in your example? But does that mean defining either __lt__ or __gt__ or must it be both as well as __eq__ and perhaps more? =this should be explained in the docs. Pick a protocol. Do you think such explanations/specifications (in)sufficient? > There are virus checkers that store lists of fingerprints that can be used to look in places within a file to guess well if it contains a known virus. I am thinking of an application that stores some similar fingerprint for lots of known protocols and when asked, produces a list like the code above, or some other method. Of course an object that wants to support lots of protocols using mix-in and abstract classes might get quite complex. And, as noted, python on a deeper level lets programmers be beyond devious as the simple-looking object turns out to have all kinds of wrappers and proxies that can obfuscate the heck out of figuring out what methods actually exist and in which of many related objects they are hidden. I honestly cannot expect any such tools to be more than heuristics that can get it wrong. To be concrete, you can make a class definition that simply does not show a definition for something like __iter__ but uses descriptors and decorators and other techniques that eff > ectively create the darn thing indirectly at the time it is evaluated or when it is first asked for or even delay creating what is needed until needed. > > The above is speculative so please don't expect me to back it up with a specific example. LOL! =per Static Typing, above. However, your "I honestly cannot expect any such tools to be more than heuristics" is enough to make me wonder whether it is worth considering, or if the above, and similar, approaches are but a 'necessary cost of doing business'? It would be great to have though! -- Regards =dn From kwpolska at gmail.com Thu Jan 24 16:13:05 2019 From: kwpolska at gmail.com (Chris Warrick) Date: Thu, 24 Jan 2019 22:13:05 +0100 Subject: preferences file In-Reply-To: References: Message-ID: On Thu, 24 Jan 2019 at 20:50, Dave wrote: > > I'm doing a small application and want to add user preferences. Did > some googling to see if there are standard Python ways/tools, but it > seems not so much. My specific questions are: > > 1. Best practices for a user preference file/system? Put them in the appropriate config directory (see answer to Q3). Windows has the registry and macOS has User Defaults, but a custom format is fine, especially if you?re making something multi-platform. > 2. File format favored and why - ini, JSON, etc? If you want/expect humans to edit it, go with INI (configparser). Otherwise (if the editing is done via your app with a nice UI), JSON can express more than just key-value mappings, although there are no comments, and its strict syntax requirements can be problematic for non-programmers trying to edit the file. Randomly loading .py or pickle files can potentially be unsafe; writing .py files in an automated way is not trivial. I wouldn?t bother with any other formats, mainly since they are not supported in stdlib, although if you need human editing and more advanced structures, then maybe YAML/TOML (they aren?t as foolproof as INI though). > 3. File location? I'm using Ubuntu and I believe that the correct > location would be home/.config/ . What about Mac and Windows? https://pypi.org/project/appdirs/ -- Chris Warrick PGP: 5EAAEA16 From PythonList at DancesWithMice.info Thu Jan 24 16:25:45 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 25 Jan 2019 10:25:45 +1300 Subject: preferences file In-Reply-To: References: Message-ID: <3e7393ed-d9d8-58ad-53f5-b3a925a1a1d1@DancesWithMice.info> Dave, On 25/01/19 8:42 AM, Dave wrote: > I'm doing a small application and want to add user preferences.? Did > some googling to see if there are standard Python ways/tools, but it > seems not so much.? My specific questions are: > > 1. Best practices for a user preference file/system? > [edited] > Would like to find a Python library that handles all of this, but so far... =Had a similar need. Also looked around, but failed. Will be interested in any discussion that follows... > 2. File format favored and why - ini, JSON, etc? =Am no great fan of .ini (a) where it is most used, ie cynicism and bias; and (b) and because it is too "flat". =Initially thought to use .conf, comforted by frequent use on Linux servers, but similar criticism. (at this point the PSL's configparser bows out) =Looked at .JSON and liked the syntactic similarities to Python. (utility available in PSL) =Settled on .YAML, mostly because not very different to .JSON yet has specific, applicable design philosophy. (IIRC picked this up through pip3) =Ended-up coding my own little utility to call from any/every application; based on import yaml. Will be interested to see if someone suggests something I missed back-then... =Have been gradually adding further facilities, eg commandLN overrides. Also, been wondering about its applicability to my web work - particularly when it comes to separating versions, eg "live" from (user acceptance) "test"... =Once done, I've noticed myself coding fewer global constants, instead putting them into the .yaml configuration file. Of course, this adds a point-of-failure - particularly if the user has access/editing rights on the file (but with great power, comes ...!) > 3. File location?? I'm using Ubuntu and I believe that the correct > location would be home/.config/ .? What about Mac and Windows? =Makes good sense, but ultimately depends upon usage/the application/how it is to be delivered to the users (and possibly more). Obviously if the user is not on that machine, or you run on behalf of several users that won't work (perhaps implement separate .../userNM/ sub-directories and use such for both config input and any output files/reports). =Again, will be interested to see others' ideas... (this smart-alec locates his windows in the wall, and keeps his mac in the cupboard/closet) -- Regards =dn From eryksun at gmail.com Fri Jan 25 00:19:39 2019 From: eryksun at gmail.com (eryk sun) Date: Thu, 24 Jan 2019 23:19:39 -0600 Subject: preferences file In-Reply-To: <7tfk4ed1bn3rv8pd1lpcas33gcetqm5vis@4ax.com> References: <7tfk4ed1bn3rv8pd1lpcas33gcetqm5vis@4ax.com> Message-ID: On 1/24/19, Dennis Lee Bieber wrote: > On Thu, 24 Jan 2019 14:42:59 -0500, Dave declaimed > the following: >> >>3. File location? I'm using Ubuntu and I believe that the correct >>location would be home/.config/ . What about Mac and Windows? >> > Windows? > > %UserProfile%\Roaming\ That should be "%UserProfile%\AppData\Roaming". This is the default path, which should never be used directly because "Roaming" is relocatable. Use "%AppData%" instead. That said, relying on environment variables isn't the best practice. The value might be wrong if the folder was relocated after our process tree was created. Use the shell's well-known-folder interface instead. For example: import pythoncom from win32com.shell import shell kfmgr = pythoncom.CoCreateInstance( shell.CLSID_KnownFolderManager, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IKnownFolderManager) appdata = kfmgr.GetFolder(shell.FOLDERID_RoamingAppData) appdata_path = appdata.GetPath() IKnownFolderManager interface: https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iknownfoldermanager IKnownFolder interface: https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iknownfolder From Karsten.Hilbert at gmx.net Fri Jan 25 04:58:37 2019 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Fri, 25 Jan 2019 10:58:37 +0100 Subject: preferences file In-Reply-To: References: Message-ID: <20190125095837.GA2669@hermes.hilbert.loc> On Thu, Jan 24, 2019 at 02:42:59PM -0500, Dave wrote: > I'm doing a small application and want to add user preferences. Did some > googling to see if there are standard Python ways/tools, but it seems not so > much. My specific questions are: > > 1. Best practices for a user preference file/system? Centralize as much as possible - if there's a database consider putting user options into that. Standard library helps in keeping dependencies down (ConfigParser). > 2. File format favored and why - ini, JSON, etc? Stay with something human readable. INI is nice, but doesn't nest well, as was said. And it does not easily lend itself to "list" style options. > 3. File location? I'm using Ubuntu and I believe that the correct location > would be home/.config/ . What about Mac and Windows? pip3 search xdg: xdg (3.0.2) - Variables defined by the XDG Base Directory Specification python-xdgapp (1.0) - Python XDG for Applications mir.xdg (1.0.0) - XDG Base Directory support dirspec (13.08) - XDG Base and User directories implementation xdgspec (0.1.1) - Convenient access to XDG Base Directory Specification variables pyxdg-open (0.2.1) - Opens URL or file in user preferred application (xdg-open replacement). Depending on UI toolkit: https://wxpython.org/Phoenix/docs/html/wx.StandardPaths.html Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From gabriele1NOSPAM at hotmail.com Fri Jan 25 06:56:57 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Fri, 25 Jan 2019 12:56:57 +0100 Subject: Exercize to understand from three numbers which is more high Message-ID: number1 = int( input("Insert the first number: ")) number2 = int( input("Insert the second number: ")) number3 = int( input("Insert the third number: ")) if number1 > number2 and number1 > number3: print("Max number is: ",number1) if number2 > number1 and number2 > number3: print("Max number is: ",number2) else: print("Max number is: ",number3) Try to insert numbers 3, 2 and 1 and the result will be number 3 and 1, can you help me to fix it?! :\ ^Bart From dan at djph.net Fri Jan 25 07:13:03 2019 From: dan at djph.net (Dan Purgert) Date: Fri, 25 Jan 2019 12:13:03 -0000 (UTC) Subject: Exercize to understand from three numbers which is more high References: Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ^Bart wrote: > > if number1 > number2 and number1 > number3: > print("Max number is: ",number1) > > if number2 > number1 and number2 > number3: > print("Max number is: ",number2) > > else: > print("Max number is: ",number3) > > Try to insert numbers 3, 2 and 1 and the result will be number 3 and 1, > can you help me to fix it?! :\ > > ^Bart Should probably be if (num1 > num2) and (num1>num3) [...] *elseif* (num2 > num1) and (num2>num3) [...] else (NOTE -- it's early and I likely crossed syntax from a different language) -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEBcqaUD8uEzVNxUrujhHd8xJ5ooEFAlxK/U4ACgkQjhHd8xJ5 ooHWPQf+PHv6QN8fWFCeYvMwkIs/GUMH9am+4XfUG6KJE6o+6cFiD7kLcLJI8eU6 78r2G/Lgv+zfcF7Tm6hkt+SHzDFTxuSNKeIDZh6zCUwS1RgRg6ormM7UAjkrO+lJ MEY4rVjLbZDuvky6Iy0r8CcPOVH5wZrbSpUjUgXQgV5AP8Pw5zgdjzHTVcl5e9T9 rcWBUgFKZkYCx53rqtLUVnm+ZKmT70VxOCVU/tKLbb6JQAZrPaHzRhi6tBI3GZNM +P9cWJATWQNu4r+bCSWez9EbMgWT2k8Cg35G4XizaWVaTtsj9/gSsnMtFYCzo5Hb JbrSbRJIr7cBjr+gPKhra7IPJDKyOA== =pAVt -----END PGP SIGNATURE----- -- |_|O|_| |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From joel.goldstick at gmail.com Fri Jan 25 07:43:10 2019 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Fri, 25 Jan 2019 07:43:10 -0500 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: On Fri, Jan 25, 2019 at 7:16 AM Dan Purgert wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > ^Bart wrote: > > > > if number1 > number2 and number1 > number3: > > print("Max number is: ",number1) > > > > if number2 > number1 and number2 > number3: > > print("Max number is: ",number2) > > > > else: > > print("Max number is: ",number3) > > > > Try to insert numbers 3, 2 and 1 and the result will be number 3 and 1, > > can you help me to fix it?! :\ > > > > ^Bart > -- > https://mail.python.org/mailman/listinfo/python-list This looks like homework. What you are asking could be solved a number of ways. I'm guessing your homework wants you to learn about if/else and comparison operators. At any rate, try the python tutor forum, and be more specific to the rules of your assignment -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From bgailer at gmail.com Fri Jan 25 08:30:17 2019 From: bgailer at gmail.com (Bob Gailer) Date: Fri, 25 Jan 2019 08:30:17 -0500 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: On Jan 25, 2019 7:00 AM, "^Bart" wrote: > > number1 = int( input("Insert the first number: ")) > > number2 = int( input("Insert the second number: ")) > > number3 = int( input("Insert the third number: ")) > > if number1 > number2 and number1 > number3: > print("Max number is: ",number1) > > if number2 > number1 and number2 > number3: > print("Max number is: ",number2) > > else: > print("Max number is: ",number3) > > Try to insert numbers 3, 2 and 1 and the result will be number 3 and 1, can you help me to fix it?! :\ Suggestion: Pretend that you are the computer. Mentally execute each statement, providing input as required, and write down the results. Something like: Statement Input Result 1 3 number1 = 3 2 2 number2 = 2 3 1 number3 = 1 4 Max number is 3 5 False 6 Max number is 1 Do not guess or assume anything. Just do exactly what each statement says. As an alternative use some kind of debugger that will let you step through the program statement by statement. Most interactive development environments such as IDLE let you do this. You might as well learn to do this now as you will be needing it more and more as you go on. Personally I would not have given any answer to the problem until you had an opportunity to research it more thoroughly. We don't learn by being given answers. Also in the future use tutor at python.org as that's the proper place for this kind of question. Bob Gailer From songbird at anthive.com Fri Jan 25 11:04:51 2019 From: songbird at anthive.com (songbird) Date: Fri, 25 Jan 2019 11:04:51 -0500 Subject: preferences file References: Message-ID: <3morhf-4b2.ln1@anthive.com> Dave wrote: > I'm doing a small application and want to add user preferences. Did > some googling to see if there are standard Python ways/tools, but it > seems not so much. My specific questions are: > > 1. Best practices for a user preference file/system? use as many default parameters as you can so that the user can run it without any configuration changes if possible. what i did was this: config.py which sets the default values used by other modules which then gets imported by any module that needs those values. these can be changed during operation if needed, but are not saved unless specifically desired. if the user desires to save a different configuration than the above default values then that file is saved to $HOME/.config//config_.json i also made sure to upload my app to PyPI making sure the is unique enough there (but also checked it via the packages listing for Debian and Ubuntu to make sure there wasn't a conflict). > 2. File format favored and why - ini, JSON, etc? configuration info and saved user games i've ended up using json. it is easy to load and save and should be universal enough. > 3. File location? I'm using Ubuntu and I believe that the correct > location would be home/.config/ . What about Mac and Windows? yes, user saved info would go into: $HOME/.local/share/ should be ok for any posix system (Debian, Ubuntu, MacOS) if the system doesn't have home directories but does have /usr/local you can put things in there (just check to make sure first that you aren't clobbering someone else's directories or files :) ). > Would like to find a Python library that handles all of this, but so far... every recommendation so far i've seen looks to be either not adopted widely or not actively developed/maintained. songbird From tjreedy at udel.edu Fri Jan 25 16:23:29 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 25 Jan 2019 16:23:29 -0500 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: On 1/25/2019 6:56 AM, ^Bart wrote: > number1 = int( input("Insert the first number: ")) > > number2 = int( input("Insert the second number: ")) > > number3 = int( input("Insert the third number: ")) > > if number1 > number2 and number1 > number3: > ??? print("Max number is: ",number1) > > if number2 > number1 and number2 > number3: > ??? print("Max number is: ",number2) > > else: > ??????? print("Max number is: ",number3) > > Try to insert numbers 3, 2 and 1 and the result will be number 3 and 1, > can you help me to fix it? In my experience based on decades of writing programs... 1. The assignment/exercise/problem should be a write a function with a particular signature. So first decide on the signature. def max3(n1, n2, n3): "Return the max of the three inputs." return None # To be replaced. 2. The next thing to do is to WRITE A TEST. Any course that does not pound this into your head is defective. In this case, use the numbers 1, 2, 3. There are 6 permutations of 3 items, so list them explicitly. (For more than 3, up to some reasonable limit, use itertools.permutations.) trios = ((1,2,3), ..., (3,2,1)) # Replace ... with the other 4. for trio in trios: m = max3(*trio) if m != 3: print(f"Error: max3(*{m}) is {m}, not 3.") print("Test done") Note: after removing '...,' from trios, I followed my advice and tested the above by running it, and caught a couple of typos and improved the error message. Replacing 'None' and '...' is your job. 3. The test will initially fail 6 times. Good. Now edit the body of max3 until there are none. 4. Worrying about external input comes last. -- Terry Jan Reedy From Karsten.Hilbert at gmx.net Fri Jan 25 17:05:46 2019 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Fri, 25 Jan 2019 23:05:46 +0100 Subject: preferences file In-Reply-To: <3morhf-4b2.ln1@anthive.com> References: <3morhf-4b2.ln1@anthive.com> Message-ID: <20190125220546.GA2693@hermes.hilbert.loc> On Fri, Jan 25, 2019 at 11:04:51AM -0500, songbird wrote: > if the system doesn't have home directories but does have > /usr/local you can put things in there (just check to make > sure first that you aren't clobbering someone else's directories > or files :) ). I don't that that's typically writable to for any odd user. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From travisgriggs at gmail.com Fri Jan 25 17:58:20 2019 From: travisgriggs at gmail.com (Travis Griggs) Date: Fri, 25 Jan 2019 14:58:20 -0800 Subject: More elegant way to avoid this hacky implementation of single line reduce for grouping a collection? Message-ID: <3D8653B6-31EA-40BB-AD83-CDBDA1B56D3B@gmail.com> Yesterday, I was pondering how to implement groupby, more in the vein of how Kotlin, Swift, Objc, Smalltalk do it, where order doesn?t matter. For example: def groupby(iterable, groupfunc): result = defaultdict(list) for each in iterable: result[groupfunc(each)].append(each) return result original = [1, 2, 3, 4, 5, 1, 2, 4, 2] groupby(original, lambda x: str(x)) ==> {?1?: [1, 1], ?2?: [2, 2, 2], ?3?: [3], ?4?: [4, 4], ?5?: [5]} Easy enough, but I found myself obsessing about doing it with a reduce. At one point, I lost sight of whether that was even a better idea or not (the above is pretty simple); I just wanted to know if I could do it. My naive attempt didn?t work so well: grouped = reduce( lambda grouper, each: grouper[str(each)].append(each), allValues, defaultdict(list)) Since the result of the append() function is None, the second reduction fails, because the accumulator ceases to be a dictionary. I persisted and came up with the following piece of evil, using a tuple to move the dict reference from reduction to reduction, but also force the (ignored) side effect of updating the same dict: grouped = reduce( lambda accum, each: (accum[0], accum[0][str(each)].append(each)), allValues, (defaultdict(list), None))[0] My question, only for the sake of learning python3 fu/enlightenment, is there a simpler way to do this with a reduce? I get there?s lots of way to do a groupby. The pursuit here is what?s the simplest/cleverest/sneakiest way to do it with reduce, especially if the quality that gorupfunc (str() in this example) is only called once per item is persevered. From python at mrabarnett.plus.com Fri Jan 25 18:50:27 2019 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 25 Jan 2019 23:50:27 +0000 Subject: More elegant way to avoid this hacky implementation of single line reduce for grouping a collection? In-Reply-To: <3D8653B6-31EA-40BB-AD83-CDBDA1B56D3B@gmail.com> References: <3D8653B6-31EA-40BB-AD83-CDBDA1B56D3B@gmail.com> Message-ID: <9898255d-b28c-55e0-d36d-c106fa4ccec6@mrabarnett.plus.com> On 2019-01-25 22:58, Travis Griggs wrote: > Yesterday, I was pondering how to implement groupby, more in the vein of how Kotlin, Swift, Objc, Smalltalk do it, where order doesn?t matter. For example: > > def groupby(iterable, groupfunc): > result = defaultdict(list) > for each in iterable: > result[groupfunc(each)].append(each) > return result > > original = [1, 2, 3, 4, 5, 1, 2, 4, 2] > groupby(original, lambda x: str(x)) ==> {?1?: [1, 1], ?2?: [2, 2, 2], ?3?: [3], ?4?: [4, 4], ?5?: [5]} > > Easy enough, but I found myself obsessing about doing it with a reduce. At one point, I lost sight of whether that was even a better idea or not (the above is pretty simple); I just wanted to know if I could do it. My naive attempt didn?t work so well: > > grouped = reduce( > lambda grouper, each: grouper[str(each)].append(each), > allValues, > defaultdict(list)) > > Since the result of the append() function is None, the second reduction fails, because the accumulator ceases to be a dictionary. > > I persisted and came up with the following piece of evil, using a tuple to move the dict reference from reduction to reduction, but also force the (ignored) side effect of updating the same dict: > > grouped = reduce( > lambda accum, each: (accum[0], accum[0][str(each)].append(each)), > allValues, > (defaultdict(list), None))[0] > > My question, only for the sake of learning python3 fu/enlightenment, is there a simpler way to do this with a reduce? I get there?s lots of way to do a groupby. The pursuit here is what?s the simplest/cleverest/sneakiest way to do it with reduce, especially if the quality that gorupfunc (str() in this example) is only called once per item is persevered. > How about this: grouped = lambda iterable, groupfunc: dict(reduce( lambda accum, each: accum[groupfunc(each)].append(each) or accum, iterable, defaultdict(list))) From __peter__ at web.de Sat Jan 26 04:00:44 2019 From: __peter__ at web.de (Peter Otten) Date: Sat, 26 Jan 2019 10:00:44 +0100 Subject: More elegant way to avoid this hacky implementation of single line reduce for grouping a collection? References: <3D8653B6-31EA-40BB-AD83-CDBDA1B56D3B@gmail.com> <9898255d-b28c-55e0-d36d-c106fa4ccec6@mrabarnett.plus.com> Message-ID: MRAB wrote: > On 2019-01-25 22:58, Travis Griggs wrote: >> >> grouped = reduce( >> lambda accum, each: (accum[0], >> accum[0][str(each)].append(each)), allValues, >> (defaultdict(list), None))[0] >> >> My question, only for the sake of learning python3 fu/enlightenment, is >> there a simpler way to do this with a reduce? I get there?s lots of way >> to do a groupby. The pursuit here is what?s the >> simplest/cleverest/sneakiest way to do it with reduce, especially if the >> quality that gorupfunc (str() in this example) is only called once per >> item is persevered. >> > How about this: > > grouped = lambda iterable, groupfunc: dict(reduce( > lambda accum, each: accum[groupfunc(each)].append(each) or accum, > iterable, > defaultdict(list))) The false-expr or ret-val expression could also be spelt (false-expr, ret-val)[1] I suppose the peephole optimiser could be taught to avoid building the tuple, i. e. def thelambda(accum, each): return (accum[groupfunc(each)].append(each), accum)[1] would be compiled to def thelambda(accum, each): accum[groupfunc(each)].append(each) return accum From songbird at anthive.com Sat Jan 26 17:35:26 2019 From: songbird at anthive.com (songbird) Date: Sat, 26 Jan 2019 17:35:26 -0500 Subject: preferences file References: <3morhf-4b2.ln1@anthive.com> <20190125220546.GA2693@hermes.hilbert.loc> Message-ID: Karsten Hilbert wrote: > On Fri, Jan 25, 2019 at 11:04:51AM -0500, songbird wrote: > >> if the system doesn't have home directories but does have >> /usr/local you can put things in there (just check to make >> sure first that you aren't clobbering someone else's directories >> or files :) ). > > I don't that that's typically writable to for any odd user. i'm assuming the person can get that changed if desired or change it themselves. if not, then it would be a rather strange situation IMO, to not have a home directory and to also not have some other place to put things. that said, i've not looked at an Android, IOS, Mac, or Windows system in a long time and is why i've had to ask here. over the holidays i touched a Mac for the first time in over 30yrs (no i don't get out much :) ) and wished i had more time to look into it more but couldn't. it would have been nice to answer some of my questions by a few minutes of poking around. at the moment i'm assuming that recent Mac's should be posix and have a $HOME and allow for $HOME/.local/share and $HOME/.config songbird From Karsten.Hilbert at gmx.net Sat Jan 26 17:52:09 2019 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Sat, 26 Jan 2019 23:52:09 +0100 Subject: preferences file In-Reply-To: References: <3morhf-4b2.ln1@anthive.com> <20190125220546.GA2693@hermes.hilbert.loc> Message-ID: <20190126225208.GA19983@hermes.hilbert.loc> On Sat, Jan 26, 2019 at 05:35:26PM -0500, songbird wrote: > >> if the system doesn't have home directories but does have > >> /usr/local you can put things in there (just check to make > >> sure first that you aren't clobbering someone else's directories > >> or files :) ). > > > > I don't that that's typically writable to for any odd user. > > i'm assuming the person can get that changed if desired > or change it themselves. if not, then it would be a > rather strange situation IMO, to not have a home directory > and to also not have some other place to put things. On a Linux system the only other place that should, by default, offer writable disk space is /tmp/ , I guess. Or else /media/$USER/a-user-mounted-removable-media/ > at the moment i'm assuming that recent Mac's should > be posix and have a $HOME and allow for $HOME/.local/share > and $HOME/.config Surely they should. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From songbird at anthive.com Sat Jan 26 19:43:03 2019 From: songbird at anthive.com (songbird) Date: Sat, 26 Jan 2019 19:43:03 -0500 Subject: preferences file References: <3morhf-4b2.ln1@anthive.com> <20190125220546.GA2693@hermes.hilbert.loc> <20190126225208.GA19983@hermes.hilbert.loc> Message-ID: Karsten Hilbert wrote: > On Sat, Jan 26, 2019 at 05:35:26PM -0500, songbird wrote: > >> >> if the system doesn't have home directories but does have >> >> /usr/local you can put things in there (just check to make >> >> sure first that you aren't clobbering someone else's directories >> >> or files :) ). >> > >> > I don't that that's typically writable to for any odd user. >> >> i'm assuming the person can get that changed if desired >> or change it themselves. if not, then it would be a >> rather strange situation IMO, to not have a home directory >> and to also not have some other place to put things. > > On a Linux system the only other place that should, by > default, offer writable disk space is /tmp/ , I guess. > > Or else /media/$USER/a-user-mounted-removable-media/ ugh! i forgot that /usr should be read only for most normal people. i guess /opt could be used instead with config changes going into /var/opt but i don't really like that either. i'd much rather keep all user information under the specific user home directory. >> at the moment i'm assuming that recent Mac's should >> be posix and have a $HOME and allow for $HOME/.local/share >> and $HOME/.config > > Surely they should. :) songbird From gabriele1NOSPAM at hotmail.com Sun Jan 27 05:19:54 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sun, 27 Jan 2019 11:19:54 +0100 Subject: Exercize to understand from three numbers which is more high References: Message-ID: > In my experience based on decades of writing programs... > > 1. The assignment/exercise/problem should be a write a function with a > particular signature.? So first decide on the signature. > > def max3(n1, n2, n3): > ??? "Return the max of the three inputs." > ??? return None? # To be replaced. I need to do this exercize just by using if, elif and else, in the next lesson we'll discuss other kind of rules! :) So I need to insert three int numbers and I should show which is the high, the middle and the min. # Exercize 305 number1 = int( input("Insert the first number: ")) number2 = int( input("Insert the second number: ")) number3 = int( input("Insert the third number: ")) numbermax = number1 numbermiddle = number2 numbermin = number3 if number2 > number1 and number2 > number3: numbermax = number2 if number3 < number2 and number3 < number1: numbermin = number3 else: numbermiddle is number1 print("Number max is: ",numbermax, "Number middle is; ",numbermiddle,"Number min is: ", numbermin) if number2 < number1 and number2 < number3: numbermin = number2 if number3 > number2 and number3 > number1: numbermax = number3 else: numbermiddle is number2 print("Number min is: ",numbermin) I don't understand how could I fix it :\ From gabriele1NOSPAM at hotmail.com Sun Jan 27 05:37:08 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sun, 27 Jan 2019 11:37:08 +0100 Subject: Exercize to understand from three numbers which is more high References: Message-ID: > You need to do this exercize just by using if, elif and else, > but in the quotation above, you use "=". We can use > < and = Now I wrote: number1 = int( input("Insert the first number: ")) number2 = int( input("Insert the second number: ")) number3 = int( input("Insert the third number: ")) numbermax = number1 numbermiddle = number2 numbermin = number3 if number2 > number1 and number2 > number3 and number3 < number2 and number3 < number1: numbermin = number3 numbermax = number2 numbermiddle = number1 print("Number max is: ",numbermax, "Number middle is: ",numbermiddle,"Number min is: ", numbermin) if number2 < number1 and number2 < number3 and number3 > number2 and number3 > number1: numbermin = number2 numbermax = number3 numbermiddle = number1 print("Number max is: ",numbermax, "Number middle is: ",numbermiddle,"Number min is: ", numbermin) else: print("Number max is: ",number1, "Number middle is: ",number2,"Number min is: ", number3) But it doesn't work... :\ From sjmsoft at gmail.com Sun Jan 27 06:58:00 2019 From: sjmsoft at gmail.com (sjmsoft at gmail.com) Date: Sun, 27 Jan 2019 03:58:00 -0800 (PST) Subject: What is your experience porting Python 2.7.x scripts to Python 3.x? In-Reply-To: References: Message-ID: <06057ac3-7497-45d0-bbf9-5a2a1bce50ea@googlegroups.com> After chickening out a couple of times over the past few years, about eight months ago we migrated our small code base from 2.7.14 to 3.6.5. Some notes: On 2.7 we spent a couple of years coding with 3.x in mind, using import from __future__ and coding to Python 3 standards wherever possible. This greatly reduced the number of changes put into production during cutover and got us used to Python 3. We used 2to3.py and found that it handled easy cases (print) well and provided a good check on my work when I hand-converted. The string versus bytes issue was the most difficult. We receive many files from other financial institutions, who receive some of the data from yet other FIs. Most of them seem to have little understanding of, or interest in, encodings, and claim to send the files in 'ASCII'. Python 3 is intolerant of dirty data, whereas previous Pythons let anything go. I because very familiar with encoding= and errors= on open(). And network protocols want bytes. I also suggest paying special attention to division (/). We used the __future__ import to handle this early. We had some problems installing Python 3.6.5 on Windows Server 2012 that already had 2.7, particularly Registry settings that wound up being wrong. The problems seemed to occur erratically, so YMMV. After some trial and error, we chose to leave Python 2.7 installed and install Python launcher for Windows (PyLauncher), to allow for easy fallback (which we never had to do) and because this provided the smoothest install. We have found Python 3.6.5 to be very reliable on Windows Server 2012. My next project is to upgrade to Windows Server 2016 and Python 3.7 on a new machine. We will not be installing Python 2.7 on this machine. HTH, Steve J. Martin From frank at chagford.com Sun Jan 27 07:34:25 2019 From: frank at chagford.com (Frank Millman) Date: Sun, 27 Jan 2019 14:34:25 +0200 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: "^Bart" wrote in message news:q2k1kk$1anf$1 at gioia.aioe.org... > > > You need to do this exercize just by using if, elif and else, > > but in the quotation above, you use "=". > > We can use > < and = > > Now I wrote: > > number1 = int( input("Insert the first number: ")) > > number2 = int( input("Insert the second number: ")) > > number3 = int( input("Insert the third number: ")) > [snip stuff that doesn?t work] > > But it doesn't work... :\ > You have got to a starting point - you have three numbers. Good. Where do you do go from here? I would start with two of the numbers, and work out which one is higher. Once you know that, you can compare that one with the third number, and work out which one is higher. >From that, you can work out which one is the highest of all three. Then you can apply the same logic to work out which is the lowest. Give that a go, and come back here if you get stuck. Frank Millman From jose-marcio.martins_da_cruz at mines-paristech.fr Fri Jan 25 02:55:26 2019 From: jose-marcio.martins_da_cruz at mines-paristech.fr (Jose Marcio Martins da Cruz) Date: Fri, 25 Jan 2019 08:55:26 +0100 Subject: ANN: Smil 0.9.1 Message-ID: Hi all, I'm pleased to announce Smil - Simple Morphological Image Library - v. 0.9.1 SMIL is a library with all basic and some advanced mathematical morphology features which can be extended with plugins and user modules. It's been developed in C++ and has a Python interface thanks to Swig. It's a product of CMM, the research Center of Mathematical Morphology of Mines-Paristech. The discipline of Mathematical Morphology was created here in the 60's by Jean Serra and Georges Matheron. We use Smil in our research activities in the field. Smil is distributed with GPL license. You can find Smil - binaries and documentation - at our web site : http://smil.cmm.mines-paristech.fr or the source code at : https://github.com/ensmp-cmm/smil Thanks -- --------------------------------------------------------------- Jose Marcio MARTINS DA CRUZ, Ph.D. Ecole des Mines de Paris Centre de Morphologie Math?matique --------------------------------------------------------------- Spam : http://amzn.to/LEscRu ou http://bit.ly/SpamJM --------------------------------------------------------------- From vrinda8899 at gmail.com Sat Jan 26 06:24:54 2019 From: vrinda8899 at gmail.com (Vrinda Bansal) Date: Sat, 26 Jan 2019 16:54:54 +0530 Subject: Problem in Installing version 3.7.2(64 bit) Message-ID: Dear Sir/Madam, After Installation of the version 3.7.2(64 bit) in Windows 8 when I run the program it gives an error. Screenshot of the error is attached below. Please help me. Regards, Vrinda Bansal G-3 Kamla Nagar, Agra From spaddie at hotmail.com Sat Jan 26 10:06:10 2019 From: spaddie at hotmail.com (Sarah P) Date: Sat, 26 Jan 2019 15:06:10 +0000 Subject: python 3.7.2 Message-ID: Hi, I?m having problems installing and using python as it defaults into [ ...users/ user/appdata/local/programs/] etc etc, its about 9 locations in all but there is no route to ?app data?, the trail is lost at this point. Its such an obscure location and I cannot find it anywhere on windows, even though it is working okay, I?m worried I will lose files. I cannot transfer files saved on python 3.4 to the new python3.7.2 as I cannot find the new version on my computer. In the installer it defaults to this location and there is no option to install it anywhere else (greyed out box). It says I need write permissions to change the location but no more information about how to do this. Also, I thought it would be an add on, not a whole new download. What happens if I delete python 3.4 after I have downloaded 3.7.2? will I lose all my existing code samples? I?m a student programmer and I can?t understand the highly technical, expert level documentation that might rectify the problem and there is only a small amount of information anyway. I just want to download Python to C drive on windows, it should be really easy... Hope you can help Sarah Padden From Matthew.Lagoe at gmail.com Sat Jan 26 16:32:36 2019 From: Matthew.Lagoe at gmail.com (Matthew Lagoe) Date: Sat, 26 Jan 2019 14:32:36 -0700 Subject: Sub-Org Applications for GSoC 2019 due soon! Message-ID: Hey all, it's Google Summer of Code time again! PSF Sub-org applications are due Febuary 4th so if your project could use some student code this year get moving! If your project is involved with python and you would be willing to mentor students this summer email gsoc-admins at python.org so we can make sure to get your project on the list. All projects using python are welcome! We need a good set of sub-organisations and ideas by Feb 4 for our application, and then if we're accepted by Google, we can add a few other ideas up until Feb 28 or so. For those not familiar with it, Google Summer of Code is a mentoring program where Google provides stipends to pay students to work with selected open source organizations. PSF has participated for many years now, and we're hoping to be selected to participate again. The PSF GSoC page is http://python-gsoc.org/ That has contact information and answers to questions like "what does it take to be a mentor?" and please feel free to ask if there's more you want to know! Thank you! Matthew Lagoe From abdallahadham1998 at gmail.com Fri Jan 25 06:11:24 2019 From: abdallahadham1998 at gmail.com (Abdallah Adham) Date: Fri, 25 Jan 2019 13:11:24 +0200 Subject: Fatal Python error Message-ID: Hey I am having this problem for about 2 weeks, I can't do anything, so please give me some instructions so I can solve it. Fatal Python error: initfsencoding: unable to load the file system code. ModuleNotFoundError: No module named 'encodings' :Current thread 0x00003c7c (most recent call first Process finished with exit code -1073740791 (0xC0000409) Thanks From bill at celestial.net Thu Jan 24 22:22:10 2019 From: bill at celestial.net (Bill Campbell) Date: Thu, 24 Jan 2019 19:22:10 -0800 Subject: preferences file In-Reply-To: References: Message-ID: <20190125032210.GA32182@ayn.mi.celestial.com> On Thu, Jan 24, 2019, Dave wrote: >I'm doing a small application and want to add user preferences. Did some >googling to see if there are standard Python ways/tools, but it seems not so >much. My specific questions are: > >1. Best practices for a user preference file/system? Generally I put them in the user's $HOME or $HOME/etc directory with appropriate permissions unless working in a virtual environement. >2. File format favored and why - ini, JSON, etc? I like ini for most user configuration files as the format is simple, easy to read, and handled nicely with the ConfigParser libraries. >3. File location? I'm using Ubuntu and I believe that the correct location >would be home/.config/ . What about Mac and Windows? See above. Same for Mac. I don't do Windows. Bill -- INTERNET: bill at celestial.com Bill Campbell; Celestial Software LLC URL: http://www2.celestial.com/ 6641 E. Mercer Way Mobile: (206) 947-5591 PO Box 820 Fax: (206) 232-9186 Mercer Island, WA 98040-0820 The budget should be balanced, the Treasury should be refilled, public debt should be reduced, the arrogance of officialdom should be tempered and controlled, and the assistance to foreign lands should be curtailed lest Rome become bankrupt. People must again learn to work, instead of living on public assistance. -- Cicero - 55 BC From hemantkumarmehta at outlook.com Fri Jan 25 13:39:23 2019 From: hemantkumarmehta at outlook.com (Hemant Mehta) Date: Fri, 25 Jan 2019 18:39:23 +0000 Subject: Unable to install Python 3 Message-ID: Dear Team, I am unable to install python 3 in my computer. Kindly find my system configuration details & error details occured at the time of installation. Please do the needful on priority. Regards, Hemant Mehta From shakti.shrivastava13 at gmail.com Sun Jan 27 08:17:02 2019 From: shakti.shrivastava13 at gmail.com (Shakti Kumar) Date: Sun, 27 Jan 2019 18:47:02 +0530 Subject: Unable to install Python 3 In-Reply-To: References: Message-ID: On Sun, 27 Jan 2019 at 18:44, Hemant Mehta wrote: > > Dear Team, > > I am unable to install python 3 in my computer. > Kindly find my system configuration details & error details occured at the time of installation. Unable to find the system configuration details & error details. > *Please do the needful on priority.* > > > Regards, > Hemant Mehta > -- > https://mail.python.org/mailman/listinfo/python-list -- From songbird at anthive.com Sun Jan 27 09:26:36 2019 From: songbird at anthive.com (songbird) Date: Sun, 27 Jan 2019 09:26:36 -0500 Subject: Fatal Python error References: Message-ID: Abdallah Adham wrote: > Hey > I am having this problem for about 2 weeks, I can't do anything, so please > give me some instructions so I can solve it. > > Fatal Python error: initfsencoding: unable to load the file system code. > ModuleNotFoundError: No module named 'encodings' > >:Current thread 0x00003c7c (most recent call first > > Process finished with exit code -1073740791 (0xC0000409) https://stackoverflow.com/questions/54087049/fatal-python-error-initfsencoding-unable-to-load-the-file-system-codec songbird From gabriele1NOSPAM at hotmail.com Sun Jan 27 09:59:42 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sun, 27 Jan 2019 15:59:42 +0100 Subject: Exercize to understand from three numbers which is more high References: Message-ID: > You have got to a starting point - you have three numbers. Good. > > Where do you do go from here? > > I would start with two of the numbers, and work out which one is higher. # SOLVED!!! number1 = int( input("Insert the first number: ")) number2 = int( input("Insert the second number: ")) number3 = int( input("Insert the third number: ")) numbermax = number1 numbermiddle = number2 numbermin = number3 if number2 > number1 and number2 > number3: numbermax = number2 print("Number max is: ",numbermax) if number1 > number2 and number1 > number3: numbermax = number1 print("Number max is: ",numbermax) if number3 > number2 and number3 > number1: numbermax = number3 print("Number max is: ",numbermax) if number2 < number1 and number2 < number3: numbermin = number2 print("Number min is: ",numbermin) if number1 < number2 and number1 < number3: numbermin = number1 print("Number min is: ",numbermin) if number3 < number2 and number3 < number1: numbermin = number3 print("Number min is: ",numbermin) numbermiddle = (number1+number2+number3)-(numbermax+numbermin) print("Number middle is: ",numbermiddle) Maybe it's not the best way to do it but at this time in our course we should try to solve problems just by using few things like if, else, etc. I know there's also min or max but before to use them we must understand if else! :) > Frank Millman Thank you very much, you helped me to power on my brain! :D ^Bart From __peter__ at web.de Sun Jan 27 10:14:31 2019 From: __peter__ at web.de (Peter Otten) Date: Sun, 27 Jan 2019 16:14:31 +0100 Subject: Exercize to understand from three numbers which is more high References: Message-ID: ^Bart wrote: >> You have got to a starting point - you have three numbers. Good. >> >> Where do you do go from here? >> >> I would start with two of the numbers, and work out which one is higher. > > # SOLVED!!! Hm, what does your script print if there are equal numbers? From alister.ware at ntlworld.com Sun Jan 27 10:54:50 2019 From: alister.ware at ntlworld.com (Alister) Date: Sun, 27 Jan 2019 15:54:50 GMT Subject: Exercize to understand from three numbers which is more high References: Message-ID: On Sun, 27 Jan 2019 15:59:42 +0100, ^Bart wrote: >> You have got to a starting point - you have three numbers. Good. >> >> Where do you do go from here? >> >> I would start with two of the numbers, and work out which one is >> higher. > > # SOLVED!!! > number1 = int( input("Insert the first number: ")) > > number2 = int( input("Insert the second number: ")) > > number3 = int( input("Insert the third number: ")) > > numbermax = number1 > > numbermiddle = number2 > > numbermin = number3 > > if number2 > number1 and number2 > number3: > numbermax = number2 > > print("Number max is: ",numbermax) > > if number1 > number2 and number1 > number3: > numbermax = number1 > > print("Number max is: ",numbermax) > > if number3 > number2 and number3 > number1: > numbermax = number3 > > print("Number max is: ",numbermax) > > if number2 < number1 and number2 < number3: > numbermin = number2 > > print("Number min is: ",numbermin) > > if number1 < number2 and number1 < number3: > numbermin = number1 > > print("Number min is: ",numbermin) > > if number3 < number2 and number3 < number1: > numbermin = number3 > > print("Number min is: ",numbermin) > > numbermiddle = (number1+number2+number3)-(numbermax+numbermin) > > print("Number middle is: ",numbermiddle) > > Maybe it's not the best way to do it but at this time in our course we > should try to solve problems just by using few things like if, else, > etc. I know there's also min or max but before to use them we must > understand if else! :) > >> Frank Millman > > Thank you very much, you helped me to power on my brain! :D ^Bart as a follow on exercise if you have covered them yet, convert your code into a function takes the 3 numbers as parameters. you will find as you progress it is a better way of structuring your program & increases flexibility. good luck with your learning & congratulations on asking for assistance not simply a solution -- Zoidberg: Muy macho. Hey, gringos, here comes El Zoido to ruin your drinking water! From gabriele1NOSPAM at hotmail.com Sun Jan 27 12:03:25 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sun, 27 Jan 2019 18:03:25 +0100 Subject: Exercize to understand from three numbers which is more high References: Message-ID: > Hm, what does your script print if there are equal numbers? Insert the first number: 5 Insert the second number: 6 Insert the third number: 5 Number max is: 6 Number middle is: 5 >>> The exercize was made to improve the use of if with three different conditions, maybe it could be nice to write something like "there isn't a middle number" but it goes further the exercize! :) From gabriele1NOSPAM at hotmail.com Sun Jan 27 12:08:21 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Sun, 27 Jan 2019 18:08:21 +0100 Subject: Exercize to understand from three numbers which is more high References: Message-ID: > as a follow on exercise if you have covered them yet, convert your code > into a function takes the 3 numbers as parameters. you will find as you > progress it is a better way of structuring your program & increases > flexibility. Next step will be to study functions and I'll have other kind of homework but I'll be able also to solve old problems in another way! :) > good luck with your learning & congratulations on asking for assistance > not simply a solution Thank you for your reply, maybe you'll read new posts from me next week or this night! Lol! :) From tjreedy at udel.edu Sun Jan 27 14:45:14 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 27 Jan 2019 14:45:14 -0500 Subject: Problem in Installing version 3.7.2(64 bit) In-Reply-To: References: Message-ID: On 1/26/2019 6:24 AM, Vrinda Bansal wrote: > Dear Sir/Madam, > > After Installation of the version 3.7.2(64 bit) in Windows 8 when I run the > program it gives an error. Screenshot of the error is attached below. Nope. This is text only mail list. Images are tossed. You must copy and paste. -- Terry Jan Reedy From eryksun at gmail.com Sun Jan 27 16:29:41 2019 From: eryksun at gmail.com (eryk sun) Date: Sun, 27 Jan 2019 15:29:41 -0600 Subject: python 3.7.2 In-Reply-To: References: Message-ID: On 1/27/19, Dennis Lee Bieber wrote: > On Sat, 26 Jan 2019 15:06:10 +0000, Sarah P declaimed > the following: > > C:\Users\Wulfraed>dir %userprofile%\appdata Avoid hard coding default paths. The roaming and local application data directories are relocatable. It's even less typing to use the proper variable, e.g. "%localappdata%" vs "%userprofile%\appdata\local". Also, if you can remember this in CMD, you can just as easily type it in Explorer's location bar, which supports environment variables. Explorer even has a "shell:" protocol that's more reliable than environment variables, e.g. "shell:Local AppData" and "shell:UserProgramFiles". environment variables https://ss64.com/nt/syntax-variables.html shell: folders https://ss64.com/nt/shell.html more shell: folders https://www.winhelponline.com/blog/shell-commands-to-access-the-special-folders Side Note Thanks to Steve Dower, there's now a Microsoft Store app for Python 3.7 [1]. Feedback would be appreciated if you have a supported system (Windows 10 1809+, build 10.0.17763+). Notably, 3.7.2 has a new venv launcher for Windows. The launcher is named "python.exe" in the environment's "Scripts" directory, but it's not a copy of or symlink to the installed "python.exe". It works around the limited access of store apps by directly running the installed Python with a __PYVENV_LAUNCHER__ environment variable. This needs more testing. A significant bug has already been addressed for multiprocessing. [1]: https://www.microsoft.com/en-us/p/python-37/9nj46sx7x90p From frank at chagford.com Mon Jan 28 00:08:14 2019 From: frank at chagford.com (Frank Millman) Date: Mon, 28 Jan 2019 07:08:14 +0200 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: "^Bart" wrote in message news:q2kh0t$1hnj$1 at gioia.aioe.org... > > > You have got to a starting point - you have three numbers. Good. > > > > Where do you do go from here? > > > > I would start with two of the numbers, and work out which one is higher. > > # SOLVED!!! > number1 = int( input("Insert the first number: ")) > > number2 = int( input("Insert the second number: ")) > > number3 = int( input("Insert the third number: ")) > > numbermax = number1 > > numbermiddle = number2 > > numbermin = number3 > > if number2 > number1 and number2 > number3: > numbermax = number2 > > print("Number max is: ",numbermax) > > if number1 > number2 and number1 > number3: > numbermax = number1 > > print("Number max is: ",numbermax) > > if number3 > number2 and number3 > number1: > numbermax = number3 > > print("Number max is: ",numbermax) > > if number2 < number1 and number2 < number3: > numbermin = number2 > > print("Number min is: ",numbermin) > > if number1 < number2 and number1 < number3: > numbermin = number1 > > print("Number min is: ",numbermin) > > if number3 < number2 and number3 < number1: > numbermin = number3 > > print("Number min is: ",numbermin) > > numbermiddle = (number1+number2+number3)-(numbermax+numbermin) > > print("Number middle is: ",numbermiddle) > > Maybe it's not the best way to do it but at this time in our course we > should try to solve problems just by using few things like if, else, etc. > I know there's also min or max but before to use them we must understand > if else! :) > > Thank you very much, you helped me to power on my brain! :D > Excellent! Glad I could help. Two comments on your code - 1. The last two lines appear to be indented under the 'if number3 < ' line. I think you want them to be unindented so that they run every time. 2. When you have lines such as - if a == 1: do something if a == 2: do something else then if 'a' is equal to 1, there is no need to check for 'a' equal to 2. Python allows you to shortcut this as follows - if a == 1: do something elif a == 2: do something else Frank From PythonList at DancesWithMice.info Mon Jan 28 02:33:45 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 28 Jan 2019 20:33:45 +1300 Subject: preferences file In-Reply-To: <20190125032210.GA32182@ayn.mi.celestial.com> References: <20190125032210.GA32182@ayn.mi.celestial.com> Message-ID: On 25/01/19 4:22 PM, Bill Campbell wrote: > On Thu, Jan 24, 2019, Dave wrote: >> I'm doing a small application and want to add user preferences. Did some >> googling to see if there are standard Python ways/tools, but it seems not so >> much. My specific questions are: >> >> 1. Best practices for a user preference file/system? > > Generally I put them in the user's $HOME or $HOME/etc directory > with appropriate permissions unless working in a virtual > environement. Good idea. What about running a multi-tenant application (for multiple users who are not also system-users) - cf them logging-on to run their own. It is appropriate, possibly even "required" to keep Fred's config file, reports, graphs, logs, etc; separate from Barney's. Ideally they will not be sub-dirs of the application/package. -- Regards =dn From gabriele1NOSPAM at hotmail.com Mon Jan 28 04:03:44 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Mon, 28 Jan 2019 10:03:44 +0100 Subject: Exercize to understand from three numbers which is more high References: Message-ID: > Excellent! Glad I could help. Thank you! :) I'm studying Python everyday and I try to do the best! :) > 1. The last two lines appear to be indented under the 'if number3 < ' > line. I think you want them to be unindented so that they run every time. I'm sorry but I didn't completely understand what you wrote about the last two lines, please could you write how my code could be fixed? > 2. When you have lines such as - > > ?? if a == 1: > ?????? do something > ?? if a == 2: > ?????? do something else > > then if 'a' is equal to 1, there is no need to check for 'a' equal to 2. > > Python allows you to shortcut this as follows - > > ?? if a == 1: > ?????? do something > ?? elif a == 2: > ?????? do something else Finally I understood the differences between if and elif! Lol! :D > Frank Thank you very much for your patience! :) ^Bart From frank at chagford.com Mon Jan 28 04:57:01 2019 From: frank at chagford.com (Frank Millman) Date: Mon, 28 Jan 2019 11:57:01 +0200 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: "^Bart" wrote in message news:q2mghh$ah6$1 at gioia.aioe.org... > > > 1. The last two lines appear to be indented under the 'if number3 < ' > > line. I think you want them to be unindented so that they run every > > time. > > I'm sorry but I didn't completely understand what you wrote about the last > two lines, please could you write how my code could be fixed? > The last four lines of your program look like this - if number3 < number2 and number3 < number1: numbermin = number3 print("Number min is: ",numbermin) numbermiddle = (number1+number2+number3)-(numbermax+numbermin) print("Number middle is: ",numbermiddle) The last three lines all fall under the 'if number3 < number2' line, so they will only be executed if that line evaluates to True. I think that you want the last two lines to be executed every time. If so, they should be lined up underneath the 'if', not the 'print'. > > > if a == 1: > > do something > > elif a == 2: > > do something else > > Finally I understood the differences between if and elif! Lol! :D > It is actually short for 'else if', but I guess it is not obvious if you have not seen it before! Frank From songbird at anthive.com Mon Jan 28 07:02:47 2019 From: songbird at anthive.com (songbird) Date: Mon, 28 Jan 2019 07:02:47 -0500 Subject: preferences file References: <20190125032210.GA32182@ayn.mi.celestial.com> Message-ID: <7k73if-cl2.ln1@anthive.com> DL Neil wrote: > On 25/01/19 4:22 PM, Bill Campbell wrote: >> On Thu, Jan 24, 2019, Dave wrote: >>> I'm doing a small application and want to add user preferences. Did some >>> googling to see if there are standard Python ways/tools, but it seems not so >>> much. My specific questions are: >>> >>> 1. Best practices for a user preference file/system? >> >> Generally I put them in the user's $HOME or $HOME/etc directory >> with appropriate permissions unless working in a virtual >> environement. > > Good idea. > > What about running a multi-tenant application (for multiple users who > are not also system-users) - cf them logging-on to run their own. It is > appropriate, possibly even "required" to keep Fred's config file, > reports, graphs, logs, etc; separate from Barney's. Ideally they will > not be sub-dirs of the application/package. if it is per user defined then $HOME/.config/, $HOME/.local/share/ and any temporary data can go in $HOME/.cache/ will do it for posix on Windows there is the per user app stuff which i haven't sorted out yet. $HOME changes per user login name change. songbird From Karsten.Hilbert at gmx.net Mon Jan 28 07:29:02 2019 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Mon, 28 Jan 2019 13:29:02 +0100 Subject: preferences file In-Reply-To: <7k73if-cl2.ln1@anthive.com> References: <20190125032210.GA32182@ayn.mi.celestial.com> <7k73if-cl2.ln1@anthive.com> Message-ID: <20190128122901.GC2141@hermes.hilbert.loc> On Mon, Jan 28, 2019 at 07:02:47AM -0500, songbird wrote: > > What about running a multi-tenant application (for multiple users who > > are not also system-users) - cf them logging-on to run their own. It is > > appropriate, possibly even "required" to keep Fred's config file, > > reports, graphs, logs, etc; separate from Barney's. Ideally they will > > not be sub-dirs of the application/package. > > if it is per user defined then $HOME/.config/, > $HOME/.local/share/ and any temporary data can go > in $HOME/.cache/ will do it for posix on Windows > there is the per user app stuff which i haven't sorted out > yet. > > $HOME changes per user login name change. $HOME/.config/// $HOME/.cache/// Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From songbird at anthive.com Mon Jan 28 10:23:31 2019 From: songbird at anthive.com (songbird) Date: Mon, 28 Jan 2019 10:23:31 -0500 Subject: preferences file References: <20190125032210.GA32182@ayn.mi.celestial.com> <7k73if-cl2.ln1@anthive.com> <20190128122901.GC2141@hermes.hilbert.loc> Message-ID: Karsten Hilbert wrote: > On Mon, Jan 28, 2019 at 07:02:47AM -0500, songbird wrote: > >> > What about running a multi-tenant application (for multiple users who >> > are not also system-users) - cf them logging-on to run their own. It is >> > appropriate, possibly even "required" to keep Fred's config file, >> > reports, graphs, logs, etc; separate from Barney's. Ideally they will >> > not be sub-dirs of the application/package. >> >> if it is per user defined then $HOME/.config/, >> $HOME/.local/share/ and any temporary data can go >> in $HOME/.cache/ will do it for posix on Windows >> there is the per user app stuff which i haven't sorted out >> yet. >> >> $HOME changes per user login name change. > > $HOME/.config/// > $HOME/.cache/// that makes no sense as you already have unique user name covered by $HOME so why repeat again? songbird From Karsten.Hilbert at gmx.net Mon Jan 28 10:31:38 2019 From: Karsten.Hilbert at gmx.net (Karsten Hilbert) Date: Mon, 28 Jan 2019 16:31:38 +0100 Subject: preferences file In-Reply-To: References: <20190125032210.GA32182@ayn.mi.celestial.com> <7k73if-cl2.ln1@anthive.com> <20190128122901.GC2141@hermes.hilbert.loc> Message-ID: <20190128153138.GG2141@hermes.hilbert.loc> On Mon, Jan 28, 2019 at 10:23:31AM -0500, songbird wrote: > Karsten Hilbert wrote: > > On Mon, Jan 28, 2019 at 07:02:47AM -0500, songbird wrote: > > > >> > What about running a multi-tenant application (for multiple users who > >> > are not also system-users) - cf them logging-on to run their own. It is > >> > appropriate, possibly even "required" to keep Fred's config file, > >> > reports, graphs, logs, etc; separate from Barney's. Ideally they will > >> > not be sub-dirs of the application/package. > >> > >> if it is per user defined then $HOME/.config/, > >> $HOME/.local/share/ and any temporary data can go > >> in $HOME/.cache/ will do it for posix on Windows > >> there is the per user app stuff which i haven't sorted out > >> yet. > >> > >> $HOME changes per user login name change. > > > > $HOME/.config/// > > $HOME/.cache/// > > that makes no sense as you already have unique > user name covered by $HOME so why repeat again? Because you seemed to imply that the login user is different from the app user: "the per user app stuff") Apparently you meant something else ? Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B From PythonList at DancesWithMice.info Mon Jan 28 12:22:45 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 29 Jan 2019 06:22:45 +1300 Subject: preferences file In-Reply-To: <20190128122901.GC2141@hermes.hilbert.loc> References: <20190125032210.GA32182@ayn.mi.celestial.com> <7k73if-cl2.ln1@anthive.com> <20190128122901.GC2141@hermes.hilbert.loc> Message-ID: <27ecf8e6-0ff3-1e68-7471-dc4520aa1d03@DancesWithMice.info> On 29/01/19 1:29 AM, Karsten Hilbert wrote: > On Mon, Jan 28, 2019 at 07:02:47AM -0500, songbird wrote: > >>> What about running a multi-tenant application (for multiple users who >>> are not also system-users) - cf them logging-on to run their own. It is >>> appropriate, possibly even "required" to keep Fred's config file, >>> reports, graphs, logs, etc; separate from Barney's. Ideally they will >>> not be sub-dirs of the application/package. >> >> if it is per user defined then $HOME/.config/, >> $HOME/.local/share/ and any temporary data can go >> in $HOME/.cache/ will do it for posix on Windows >> there is the per user app stuff which i haven't sorted out >> yet. >> >> $HOME changes per user login name change. > > $HOME/.config/// > $HOME/.cache/// +1 The latter for tmp/intermediate files (without hassles, eg creating unique fileNMs!). - and which can be wiped with a single command at the end of the run! The former for 'valuable stuff'. With the opportunity, to separate output presentations and inputs using sub-dirs! (noticed in one such implementation, the need to separate different 'runs' of the same app, by the same client, using alternate hypotheses - that required another 'layer' of sub-dirs!) Thanks! -- Regards =dn From songbird at anthive.com Mon Jan 28 13:03:50 2019 From: songbird at anthive.com (songbird) Date: Mon, 28 Jan 2019 13:03:50 -0500 Subject: preferences file References: <20190125032210.GA32182@ayn.mi.celestial.com> <7k73if-cl2.ln1@anthive.com> <20190128122901.GC2141@hermes.hilbert.loc> <20190128153138.GG2141@hermes.hilbert.loc> Message-ID: <6ps3if-c57.ln1@anthive.com> Karsten Hilbert wrote: > On Mon, Jan 28, 2019 at 10:23:31AM -0500, songbird wrote: >> Karsten Hilbert wrote: >> > On Mon, Jan 28, 2019 at 07:02:47AM -0500, songbird wrote: >> > >> >> > What about running a multi-tenant application (for multiple users who >> >> > are not also system-users) - cf them logging-on to run their own. It is >> >> > appropriate, possibly even "required" to keep Fred's config file, >> >> > reports, graphs, logs, etc; separate from Barney's. Ideally they will >> >> > not be sub-dirs of the application/package. >> >> >> >> if it is per user defined then $HOME/.config/, >> >> $HOME/.local/share/ and any temporary data can go >> >> in $HOME/.cache/ will do it for posix on Windows >> >> there is the per user app stuff which i haven't sorted out >> >> yet. >> >> >> >> $HOME changes per user login name change. >> > >> > $HOME/.config/// >> > $HOME/.cache/// >> >> that makes no sense as you already have unique >> user name covered by $HOME so why repeat again? > > Because you seemed to imply that the login user is different > from the app user: > > "the per user app stuff") > > Apparently you meant something else ? sorry for being unclear. each user is taken care of by $HOME and for me there is no other complication. songbird From songbird at anthive.com Mon Jan 28 13:11:40 2019 From: songbird at anthive.com (songbird) Date: Mon, 28 Jan 2019 13:11:40 -0500 Subject: preferences file References: <20190125032210.GA32182@ayn.mi.celestial.com> <7k73if-cl2.ln1@anthive.com> <20190128122901.GC2141@hermes.hilbert.loc> <27ecf8e6-0ff3-1e68-7471-dc4520aa1d03@DancesWithMice.info> Message-ID: DL Neil wrote: > On 29/01/19 1:29 AM, Karsten Hilbert wrote: >> On Mon, Jan 28, 2019 at 07:02:47AM -0500, songbird wrote: >> >>>> What about running a multi-tenant application (for multiple users who >>>> are not also system-users) - cf them logging-on to run their own. It is >>>> appropriate, possibly even "required" to keep Fred's config file, >>>> reports, graphs, logs, etc; separate from Barney's. Ideally they will >>>> not be sub-dirs of the application/package. >>> >>> if it is per user defined then $HOME/.config/, >>> $HOME/.local/share/ and any temporary data can go >>> in $HOME/.cache/ will do it for posix on Windows >>> there is the per user app stuff which i haven't sorted out >>> yet. >>> >>> $HOME changes per user login name change. >> >> $HOME/.config/// >> $HOME/.cache/// > > > +1 > > The latter for tmp/intermediate files (without hassles, eg creating > unique fileNMs!). - and which can be wiped with a single command at the > end of the run! > > The former for 'valuable stuff'. With the opportunity, to separate > output presentations and inputs using sub-dirs! > > (noticed in one such implementation, the need to separate different > 'runs' of the same app, by the same client, using alternate hypotheses - > that required another 'layer' of sub-dirs!) > > Thanks! oh, well i don't need anything that complicated but usually there is a way of generating unique file names and managing temporary files. if you are running an application by a login user which does not log out then eventually you may need to use some other method of cleaning up the application's files somehow but to me that is a whole different topic from the issue of where to put them. songbird From PythonList at DancesWithMice.info Mon Jan 28 13:50:58 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Tue, 29 Jan 2019 07:50:58 +1300 Subject: preferences file In-Reply-To: References: <20190125032210.GA32182@ayn.mi.celestial.com> <7k73if-cl2.ln1@anthive.com> <20190128122901.GC2141@hermes.hilbert.loc> <27ecf8e6-0ff3-1e68-7471-dc4520aa1d03@DancesWithMice.info> Message-ID: <1bee5809-aa7c-6324-6bf6-2e011008e5fc@DancesWithMice.info> On 29/01/19 7:11 AM, songbird wrote: > DL Neil wrote: >> On 29/01/19 1:29 AM, Karsten Hilbert wrote: >>> On Mon, Jan 28, 2019 at 07:02:47AM -0500, songbird wrote: >>> >>>>> What about running a multi-tenant application (for multiple users who >>>>> are not also system-users) - cf them logging-on to run their own. It is >>>>> appropriate, possibly even "required" to keep Fred's config file, >>>>> reports, graphs, logs, etc; separate from Barney's. Ideally they will >>>>> not be sub-dirs of the application/package. >>>> >>>> if it is per user defined then $HOME/.config/, >>>> $HOME/.local/share/ and any temporary data can go >>>> in $HOME/.cache/ will do it for posix on Windows >>>> there is the per user app stuff which i haven't sorted out >>>> yet. >>>> >>>> $HOME changes per user login name change. >>> >>> $HOME/.config/// >>> $HOME/.cache/// >> >> >> ...The latter for tmp/intermediate files (without hassles, eg creating >> unique fileNMs!). - and which can be wiped with a single command at the >> end of the run! >>... > > oh, well i don't need anything that complicated but > usually there is a way of generating unique file names > and managing temporary files. =if the directory is dedicated to a user (and thus the files therein driven by his/her/their particular config file), then the issue of unique fileNMs no longer exists. Less complexity = more happiness (potential)... > if you are running an application by a login user > which does not log out then eventually you may need > to use some other method of cleaning up the application's > files somehow but to me that is a whole different topic > from the issue of where to put them. =(a) context managers =(b) when the intermediate files (from an 'inherited system') are over-large (see also Backlog list!), this can become an issue. Yes, it appears some way from the OP's intent (apologies to him, if appropriate). However, K's comment encouraged a re-think: - whilst re-developing the app into a multi-tenant possibility, using config files to separate the individuals/project teams/departments (back to the original question), my thought was that the intermediate files "belonged to" the app. Hence they were re-sited under (Linux) /tmp (considerations per above). - if the consideration of "separation" between the multiple 'tenants' is important (not in my case), then a generalised drop-zone, eg /tmp, is NOT acceptable, eg security/privacy. - hence the conclusion that any intermediate files should also be separated 'under' , ie that they 'belong to' the user and NOT to the app! - this naturally leads to another convenience: unlike concerns for over-filling /tmp, there is no need to keep track of what has/not been created in $HOME/.cache/// because at the end of the run, all contents of the directory (incl/excl) can?should be deleted! (a context manager?) Obvious when you think about it, but wasn't 'at the time'. Ideas appended to Project's Backlog... Again, thanks! -- Regards =dn From David.Raymond at tomtom.com Mon Jan 28 14:27:05 2019 From: David.Raymond at tomtom.com (David Raymond) Date: Mon, 28 Jan 2019 19:27:05 +0000 Subject: time.strftime question on 0 as argument Message-ID: https://docs.python.org/3.7/library/time.html#time.strftime In the docs there is "0 is a legal argument for any position in the time tuple; if it is normally illegal the value is forced to a correct one." and yet if given 0 for the year/first item in the tuple it raises a ValueError. Is that a bug in the code, the documentation, or my understanding? Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.strftime("%b", (0, 1, 0, 0, 0, 0, 0, 0, 0)) Traceback (most recent call last): File "", line 1, in ValueError: strftime() requires year in [1; 9999] >>> Looks like it works in 2, so maybe an incorrect documentation carryover? Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.strftime("%b", (0, 1, 0, 0, 0, 0, 0, 0, 0)) 'Jan' >>> From Gronicus at SGA.Ninja Mon Jan 28 10:29:24 2019 From: Gronicus at SGA.Ninja (Steve) Date: Mon, 28 Jan 2019 10:29:24 -0500 Subject: How do I get a python program to work on my phone? Message-ID: <002501d4b71e$406d16e0$c14744a0$@SGA.Ninja> This is my first message to this forum, I am not sure how to submit it so please correct me if I am not doing this properly. =========================================== Being new to python as of a year ago December and have extensive programming experience: C++, VBasic, HTML etc... I installed Python and wrote a program that documents my blood readings enough that my A1c results went from 9.1 to 6.4 in about two months and have had low numbers since. I now want to run it on my MotoG phone. The program accepts keyed in data and will access two text files to keep data and I would like to have the program chime my phone to remind me to take the next reading. First step is to get it running in my phone How do I do it? What software do I need to make the transfer? Steve ================= Footnote: Zamboni locks up after running into a large patch of loose teeth. From robertomartinezp at gmail.com Mon Jan 28 11:14:33 2019 From: robertomartinezp at gmail.com (=?UTF-8?Q?Roberto_Mart=C3=ADnez?=) Date: Mon, 28 Jan 2019 17:14:33 +0100 Subject: List of methods affected by 'Special method lookup' Message-ID: Hi, the documentation about Special method lookup claims: "For custom classes, implicit invocations of special methods are only guaranteed to work correctly if defined on an object?s type, not in the object?s instance dictionary. " Does this statement holds for every special method mentioned in section 3.3 Special method names ? Best regards, Roberto From torriem at gmail.com Mon Jan 28 16:35:05 2019 From: torriem at gmail.com (Michael Torrie) Date: Mon, 28 Jan 2019 14:35:05 -0700 Subject: How do I get a python program to work on my phone? In-Reply-To: <002501d4b71e$406d16e0$c14744a0$@SGA.Ninja> References: <002501d4b71e$406d16e0$c14744a0$@SGA.Ninja> Message-ID: On 2019-01-28 8:29 a.m., Steve wrote: > I now want to run it on my MotoG phone. The program accepts keyed in data > and will access two text files to keep data and I would like to have the > program chime my phone to remind me to take the next reading. > > First step is to get it running in my phone > How do I do it? What software do I need to make the transfer? You might want to check into Kivy[1], which is a framework for making apps that can run on Android using Python (and also iOS and desktop operating systems as well). [1] https://kivy.org/#home From avigross at verizon.net Mon Jan 28 17:16:21 2019 From: avigross at verizon.net (Avi Gross) Date: Mon, 28 Jan 2019 17:16:21 -0500 Subject: meta protocol protocol Message-ID: <003701d4b757$195f49e0$4c1ddda0$@verizon.net> I brought up a topic earlier and am now taking a different slant. I am thinking of the wisdom of having a protocol on announcing what protocols you implement. Python has many protocols that are now part of the language and I suspect many more will arise. Python already has a series of variables stored in classes or instances that store lists or dictionaries of THINGS and I won't mention them in details as they are numerous and often mysterious. So I wondered what people thought of the general idea of adding one more with some name like __PROTOCOLS__ that could be stored at something like the class level. Here are examples of one person listing what they consider protocols: https://ref.readthedocs.io/en/latest/understanding_python/interfaces/existin g_protocols.html https://stephensugden.com/crash_into_python/Protocols.html When an object implements a protocol such as being callable, that generally means they provide a method in the name __call__ which is simple enough to check for if you know where to look. But the sequence protocol may require quite a few such methods to be fully implemented and testing for dunders len, getitem, setitem, delitem, reversed, contains, getslice, setslice, and delslice may be a bit much. So what if the powers that be that determine the fate of python come up with a meta protocol. All protocols would be given a NAME for official purposes. The two examples might become "callable" and "sequence" and the meaning of saying you properly provide a protocol would be well documented. So if someone creates an object, part of the process might be to add entries for each protocol you declare you properly support to something like the __PROTOCOLS__ variable. How to do so is an implementation decision but it could be as easy as adding a method to the top class "object" than any subclass can inherit and use to declare one or more protocols in use. You might also add another method like has_protocol(name) that returns True if it is registered. As a programmer, you might no longer need to know the details to see if something is in some category. Rather than checking for the presence of various dunderheads, you simply ask if a protocol is implemented and then use it. I am not sure anything like this is wanted or practical and am asking if people have already suggested something along these lines or whether it would even be something worth doing or practical. I can think of many complications starting with what happens if someone lies and continuing with what happens if a class inherits from multiple other classes but some methods are over-ridden or no longer the first one found in the MRO search. Of course, it would also be nice if there was also a tool that could be used by developers to validate claims to implement a protocol before run-time either in a shallow way (the right names are defined) or a deeper way by exercising the functionality to see it does what is expected. That, too, leads to me wondering how this could work as the above reference suggests the copy protocol contains both a __copy__() and a __deepcopy__() and I can imagine having just the first. When I say PROTOCOL, I mean it in a very broad sense. For example, what makes an object type IMMUTABLE? What makes the contents of an object INVISIBLE as in you use techniques so the only way to gain access to the hidden internals of an object is through various kinds of proxies that keep you from actually seeing what is going on. Such aspects may not have an exact protocol but if you want to use something as a key in a dictionary maybe it will be happy to allow it if it thinks you are of an immutable type. Other functionality may refuse to work with objects not deemed invisible for privacy concerns. Again. Not a serious proposal just wondering if my thought process is flawed deeply or am I just shallow. From eryksun at gmail.com Mon Jan 28 20:03:42 2019 From: eryksun at gmail.com (eryk sun) Date: Mon, 28 Jan 2019 19:03:42 -0600 Subject: time.strftime question on 0 as argument In-Reply-To: References: Message-ID: On 1/28/19, David Raymond wrote: > > In the docs there is > "0 is a legal argument for any position in the time tuple; if it is normally > illegal the value is forced to a correct one." The POSIX specification for strftime only states that "[i]f any of the specified values are outside the normal range, the characters stored are unspecified" [1]. Python tries to bring some semblance of order across the various implementations of this function. For tm_year, it was eventually decided circa Python 3.2 to support the full signed range on most platforms, even if isn't a normal date, such as year 0 and negative year values. For example, in 3.6.7 in Linux: >>> time.strftime("%Y = %C * 100 + %y", (0, 0, 0, 0, 0, 0, 0, 0, 0)) '0 = 0 * 100 + 00' >>> time.strftime("%Y = %C * 100 + %y", (-10, 0, 0, 0, 0, 0, 0, 0, 0)) '-10 = -1 * 100 + 90' 2.7.15 in Linux has different behavior, especially if time.accept2dyear is true (set by default unless the environment variable PYTHONY2K is defined). >>> time.accept2dyear 1 >>> time.strftime("%Y = %C * 100 + %y", (0, 0, 0, 0, 0, 0, 0, 0, 0)) '2000 = 20 * 100 + 00' >>> time.strftime("%Y = %C * 100 + %y", (-10, 0, 0, 0, 0, 0, 0, 0, 0)) Traceback (most recent call last): File "", line 1, in ValueError: year out of range The magical year value of 2000 comes from code to support pre-Y2K scripts that assume years 69-99 are 1969-1999 and years 0-68 are 2000-2068. If we force time.accept2dyear to false, we see that Python 2 actually requires the year to be at least 1900. >>> time.accept2dyear = 0 >>> time.strftime("%Y = %C * 100 + %y", (0, 0, 0, 0, 0, 0, 0, 0, 0)) Traceback (most recent call last): File "", line 1, in ValueError: year >= 1900 required > and yet if given 0 for the year/first item in the tuple it raises a > ValueError. > > Is that a bug in the code, the documentation, or my understanding? It's not a bug. However, in recent versions of the Windows C runtime, "%y" does support year values down to 0 (but not negative years), so the check [2] can be relaxed down to 0 (whatever year 0 is supposed to be), and the additional check for "%y" can be removed [3]. [1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html [2]: https://github.com/python/cpython/blob/v3.7.2/Modules/timemodule.c#L721 [3]: https://github.com/python/cpython/blob/v3.7.2/Modules/timemodule.c#L760 From tjreedy at udel.edu Mon Jan 28 20:21:31 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 28 Jan 2019 20:21:31 -0500 Subject: List of methods affected by 'Special method lookup' In-Reply-To: References: Message-ID: On 1/28/2019 11:14 AM, Roberto Mart?nez wrote: > Hi, > > the documentation about Special method lookup > > claims: > "For custom classes, implicit invocations of special methods are only > guaranteed to work correctly if defined on an object?s type, not in the > object?s instance dictionary. " > > Does this statement holds for every special method mentioned in section 3.3 > Special method names > ? You should generally take such statements at face value. Unless you find specific exceptions mentioned elsewhere, 'no guarantee' means just that, regardless of how any particular implementation behaves today. -- Terry Jan Reedy From as at sci.fi Tue Jan 29 06:59:07 2019 From: as at sci.fi (Anssi Saari) Date: Tue, 29 Jan 2019 13:59:07 +0200 Subject: Problem in Installing version 3.7.2(64 bit) References: Message-ID: Terry Reedy writes: > On 1/26/2019 6:24 AM, Vrinda Bansal wrote: >> Dear Sir/Madam, >> >> After Installation of the version 3.7.2(64 bit) in Windows 8 when I run the >> program it gives an error. Screenshot of the error is attached below. > > Nope. This is text only mail list. Images are tossed. You must copy > and paste. Just curious, but wouldn't it be better to just reject messages with attachments instead of silent removal? I suppose the end result is mostly the same for the person asking but the rest of us would be spared. From bgailer at gmail.com Tue Jan 29 07:52:40 2019 From: bgailer at gmail.com (Bob Gailer) Date: Tue, 29 Jan 2019 07:52:40 -0500 Subject: How do I get a python program to work on my phone? In-Reply-To: <002501d4b71e$406d16e0$c14744a0$@SGA.Ninja> References: <002501d4b71e$406d16e0$c14744a0$@SGA.Ninja> Message-ID: kivy has a very steep learning curve. The easy way to use kivy is to install the kivy launcher app which then lets you run a Python program and access the kivy widgets. If you really want to dive into kivy I will send you a presentation I gave on kivy. After a lot of work I did manage to create an install an app. An interesting alternatives to create a simple web page to run in the phone's browser. If you don't already have a server on the web you can rent one from secure dragon for as low as $12 a year. Install websocketd and python. Websocketd lets you do all sorts of interesting things such as serve static pages, CGI programs, and use websockets. Websockets requires a little bit of JavaScript but makes the interaction between a browser page and a Python program on the server ridiculously easy. Much easier than Ajax. Feel free to ask for more information. I posted a Python program on the websocketd website that shows how to do the server side of websockets communication. Bob Gailer From tdldev at gmail.com Tue Jan 29 10:27:48 2019 From: tdldev at gmail.com (Jack Dangler) Date: Tue, 29 Jan 2019 10:27:48 -0500 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: On 1/27/19 5:19 AM, ^Bart wrote: >> In my experience based on decades of writing programs... >> >> 1. The assignment/exercise/problem should be a write a function with >> a particular signature.? So first decide on the signature. >> >> def max3(n1, n2, n3): >> ???? "Return the max of the three inputs." >> ???? return None? # To be replaced. > > I need to do this exercize just by using if, elif and else, in the > next lesson we'll discuss other kind of rules! :) > > So I need to insert three int numbers and I should show which is the > high, the middle and the min. > > # Exercize 305 > > number1 = int( input("Insert the first number: ")) > > number2 = int( input("Insert the second number: ")) > > number3 = int( input("Insert the third number: ")) > > numbermax = number1 > > numbermiddle = number2 > > numbermin = number3 > > if number2 > number1 and number2 > number3: > ??? numbermax = number2 > > if number3 < number2 and number3 < number1: > ??? numbermin = number3 > > else: > ??? numbermiddle is number1 > > print("Number max is: ",numbermax, "Number middle is; > ",numbermiddle,"Number min is: ", numbermin) > > if number2 < number1 and number2 < number3: > ??? numbermin = number2 > > if number3 > number2 and number3 > number1: > ??? numbermax = number3 > > else: > ??? numbermiddle is number2 > > print("Number min is: ",numbermin) > > I don't understand how could I fix it :\ wow. Seems like a lot going on. You have 3 ints and need to determine the max? Doesn't this work? N1, N2, N3 if N1>N2 ? if N1>N3 ??? MaxNum = N1 elif N2>N3 ? MaxNum = N2 elif N1 References: Message-ID: <13cb55c5-1a44-9df1-35eb-708665b09d1d@gmail.com> On 1/27/19 7:34 AM, Frank Millman wrote: > "^Bart" wrote in message news:q2k1kk$1anf$1 at gioia.aioe.org... >> >> >??? You need to do this exercize just by using if, elif and else, >> >??? but in the quotation above, you use "=". >> >> We can use > < and = >> >> Now I wrote: >> >> number1 = int( input("Insert the first number: ")) >> >> number2 = int( input("Insert the second number: ")) >> >> number3 = int( input("Insert the third number: ")) >> > > [snip stuff that doesn?t work] > >> >> But it doesn't work... :\ >> > > You have got to a starting point - you have three numbers. Good. > > Where do you do go from here? > > I would start with two of the numbers, and work out which one is higher. > > Once you know that, you can compare that one with the third number, > and work out which one is higher. > > From that, you can work out which one is the highest of all three. > > Then you can apply the same logic to work out which is the lowest. > > Give that a go, and come back here if you get stuck. > > Frank Millman > > > Frank - The OP didn't appear to need to 'sort' the inputs, but only to > solve for the highest value of the three using limited arithmetic > operators. I like your text walkthrough. It should give the OP enough > to go on. I only supplied a linear solution because I am not sure why > this would be a struggle. From torriem at gmail.com Tue Jan 29 10:44:42 2019 From: torriem at gmail.com (Michael Torrie) Date: Tue, 29 Jan 2019 08:44:42 -0700 Subject: How do I get a python program to work on my phone? In-Reply-To: References: <002501d4b71e$406d16e0$c14744a0$@SGA.Ninja> Message-ID: On 2019-01-29 5:52 a.m., Bob Gailer wrote: > An interesting alternatives to create a simple web page to run in the > phone's browser. If you don't already have a server on the web you can rent > one from secure dragon for as low as $12 a year. Install websocketd and > python. Websocketd lets you do all sorts of interesting things such as > serve static pages, CGI programs, and use websockets. Websockets requires a > little bit of JavaScript but makes the interaction between a browser page > and a Python program on the server ridiculously easy. Much easier than > Ajax. Feel free to ask for more information. I posted a Python program on > the websocketd website that shows how to do the server side of websockets > communication. If you're willing to forego Python and embrace Javascript, there are many options, some are fairly easy to get into. Adobe has their PhoneGap system (http://phonegap.com). There are others. They call these hybrid apps. Recently I made a small app using V-Play which is based on QtQuick. Was super easy. The most amount of time was spent figuring out QML GUI layout. Straight QtQuick works decently well too, using the QtCreator IDE. There have been some Python to javascript compilers, or implementations of Python in Javascript. So maybe it's possible to make a hybrid app using Python. From torriem at torriefamily.org Tue Jan 29 10:48:18 2019 From: torriem at torriefamily.org (Michael Torrie) Date: Tue, 29 Jan 2019 08:48:18 -0700 Subject: How do I get a python program to work on my phone? In-Reply-To: References: <002501d4b71e$406d16e0$c14744a0$@SGA.Ninja> Message-ID: <4b853bd7-8222-9b91-aec2-7fd3a2fe2384@torriefamily.org> On 2019-01-29 8:44 a.m., Michael Torrie wrote: > There have been some Python to javascript compilers, or implementations > of Python in Javascript. So maybe it's possible to make a hybrid app > using Python. Here's an interesting project that might work with some hybrid app development frameworks: https://github.com/QQuick/Transcrypt Translates Python 3.7 code to Javascript, with an emphasis on integration with javascript libraries for web development. Interesting. From 2QdxY4RzWzUUiLuE at potatochowder.com Tue Jan 29 11:02:53 2019 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Tue, 29 Jan 2019 10:02:53 -0600 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: On 1/29/19 9:27 AM, Jack Dangler wrote: > wow. Seems like a lot going on. You have 3 ints and need to determine > the max? Doesn't this work? > > N1, N2, N3 > > if N1>N2 > ? if N1>N3 > ??? MaxNum = N1 > elif N2>N3 > ? MaxNum = N2 > elif N1 ? MaxNum = N3 No. Assuing that you meant to include colons where I think you did, what if (N1, N2, N3) == (5, 4, 6)? From python at mrabarnett.plus.com Tue Jan 29 13:40:16 2019 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 29 Jan 2019 18:40:16 +0000 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: On 2019-01-29 16:02, Dan Sommers wrote: > On 1/29/19 9:27 AM, Jack Dangler wrote: > >> wow. Seems like a lot going on. You have 3 ints and need to determine >> the max? Doesn't this work? >> >> N1, N2, N3 >> >> if N1>N2 >> ? if N1>N3 >> ??? MaxNum = N1 >> elif N2>N3 >> ? MaxNum = N2 >> elif N1> ? MaxNum = N3 > > No. Assuing that you meant to include colons where I think > you did, what if (N1, N2, N3) == (5, 4, 6)? > And it's still longer and more complicated than it needs to be. From Joseph.Schachner at Teledyne.com Tue Jan 29 13:46:10 2019 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Tue, 29 Jan 2019 18:46:10 +0000 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: Explanation: 5 > 4 so it goes into the first if. 5 is not greater than 6, so it does not assign N1 to MaxNum. The elif (because of the lack of indent) applies to the first if, so nothing further is executed. Nothing has been assigned to MaxNum, so that variable does not exist. You're right, it does not work. How about this: Mylist = [ N1, N2, N3] Maxnum = N1 for value in Mylist: if value > Maxnum: Maxnum = value print(Maxnum) Or were lists and for loops excluded from this exercise? --- Joe S. On 1/29/19 9:27 AM, Jack Dangler wrote: > wow. Seems like a lot going on. You have 3 ints and need to determine > the max? Doesn't this work? > > N1, N2, N3 > > if N1>N2 > ? if N1>N3 > ??? MaxNum = N1 > elif N2>N3 > ? MaxNum = N2 > elif N1 ? MaxNum = N3 No. Assuing that you meant to include colons where I think you did, what if (N1, N2, N3) == (5, 4, 6)? From adrian.ordona at gmail.com Tue Jan 29 14:52:19 2019 From: adrian.ordona at gmail.com (Adrian Ordona) Date: Tue, 29 Jan 2019 14:52:19 -0500 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: i'm also a beginner reading all the replies helps. i was trying the problem myself and came up with the below code with a users input. num1 = int(input("Enter first number: "))num2 = int(input("Enter second number: "))num3 = int(input("Enter third number: "))if num1 > num2 and num1 > num3: print(num1, " is th max number")elif num2 > num1 and num2 > num3: print(num2, " is the max number")else: print(num3, "is the max number") On Tue, Jan 29, 2019 at 1:48 PM Schachner, Joseph < Joseph.Schachner at teledyne.com> wrote: > Explanation: 5 > 4 so it goes into the first if. 5 is not greater than 6, > so it does not assign N1 to MaxNum. The elif (because of the lack of > indent) applies to the first if, so nothing further is executed. Nothing > has been assigned to MaxNum, so that variable does not exist. You're > right, it does not work. > > How about this: > Mylist = [ N1, N2, N3] > Maxnum = N1 > for value in Mylist: > if value > Maxnum: > Maxnum = value > print(Maxnum) > > Or were lists and for loops excluded from this exercise? > --- Joe S. > > On 1/29/19 9:27 AM, Jack Dangler wrote: > > > wow. Seems like a lot going on. You have 3 ints and need to determine > > the max? Doesn't this work? > > > > N1, N2, N3 > > > > if N1>N2 > > if N1>N3 > > MaxNum = N1 > > elif N2>N3 > > MaxNum = N2 > > elif N1 > MaxNum = N3 > > No. Assuing that you meant to include colons where I think you did, what > if (N1, N2, N3) == (5, 4, 6)? > > -- > https://mail.python.org/mailman/listinfo/python-list > From songbird at anthive.com Tue Jan 29 11:31:58 2019 From: songbird at anthive.com (songbird) Date: Tue, 29 Jan 2019 11:31:58 -0500 Subject: Problem in Installing version 3.7.2(64 bit) References: Message-ID: Anssi Saari wrote: > Terry Reedy writes: >> On 1/26/2019 6:24 AM, Vrinda Bansal wrote: >>> Dear Sir/Madam, >>> >>> After Installation of the version 3.7.2(64 bit) in Windows 8 when I run the >>> program it gives an error. Screenshot of the error is attached below. >> >> Nope. This is text only mail list. Images are tossed. You must copy >> and paste. > > Just curious, but wouldn't it be better to just reject messages with > attachments instead of silent removal? I suppose the end result is > mostly the same for the person asking but the rest of us would be > spared. my understanding is that this list is actually several combined services (i'm not sure how the mailing list operates or how it filters or rejects things) and then there is the usenet list comp.lang.python (which is how i see articles and replies). usenet has usually been a text only service unless you have a specific binary group (some usenet servers have them and others don't). asking the person to upload the image to someplace else and provide a link to the image would be a thing for the FAQ if there were one for either or both of the e-mail list service provider or the usenet group. songbird From Joseph.Schachner at Teledyne.com Tue Jan 29 15:30:39 2019 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Tue, 29 Jan 2019 20:30:39 +0000 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: Yes, that works. Assuming it was correctly formatted when you ran it. The formatting could not possibly be run in a Python interpreter, I think. --- Joseph S. From: Adrian Ordona Sent: Tuesday, January 29, 2019 2:52 PM To: Schachner, Joseph Cc: Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com>; python-list at python.org Subject: Re: Exercize to understand from three numbers which is more high i'm also a beginner reading all the replies helps. i was trying the problem myself and came up with the below code with a users input. num1 = int(input("Enter first number: "))num2 = int(input("Enter second number: "))num3 = int(input("Enter third number: "))if num1 > num2 and num1 > num3: print(num1, " is th max number")elif num2 > num1 and num2 > num3: print(num2, " is the max number")else: print(num3, "is the max number") On Tue, Jan 29, 2019 at 1:48 PM Schachner, Joseph > wrote: Explanation: 5 > 4 so it goes into the first if. 5 is not greater than 6, so it does not assign N1 to MaxNum. The elif (because of the lack of indent) applies to the first if, so nothing further is executed. Nothing has been assigned to MaxNum, so that variable does not exist. You're right, it does not work. How about this: Mylist = [ N1, N2, N3] Maxnum = N1 for value in Mylist: if value > Maxnum: Maxnum = value print(Maxnum) Or were lists and for loops excluded from this exercise? --- Joe S. On 1/29/19 9:27 AM, Jack Dangler wrote: > wow. Seems like a lot going on. You have 3 ints and need to determine > the max? Doesn't this work? > > N1, N2, N3 > > if N1>N2 > if N1>N3 > MaxNum = N1 > elif N2>N3 > MaxNum = N2 > elif N1 MaxNum = N3 No. Assuing that you meant to include colons where I think you did, what if (N1, N2, N3) == (5, 4, 6)? -- https://mail.python.org/mailman/listinfo/python-list From adrian.ordona at gmail.com Tue Jan 29 15:37:31 2019 From: adrian.ordona at gmail.com (Adrian Ordona) Date: Tue, 29 Jan 2019 12:37:31 -0800 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: The code actually works just the way i copy and pasted Sent from my iPhone > On Jan 29, 2019, at 12:34, Ian Clark wrote: > > just the pure number of letters next to parenthesis would cause the Parser to error out > >> On Tue, Jan 29, 2019 at 12:32 PM Schachner, Joseph wrote: >> Yes, that works. Assuming it was correctly formatted when you ran it. >> The formatting could not possibly be run in a Python interpreter, I think. >> >> --- Joseph S. >> >> From: Adrian Ordona >> Sent: Tuesday, January 29, 2019 2:52 PM >> To: Schachner, Joseph >> Cc: Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com>; python-list at python.org >> Subject: Re: Exercize to understand from three numbers which is more high >> >> i'm also a beginner reading all the replies helps. >> i was trying the problem myself and came up with the below code with a users input. >> >> >> num1 = int(input("Enter first number: "))num2 = int(input("Enter second number: "))num3 = int(input("Enter third number: "))if num1 > num2 and num1 > num3: print(num1, " is th max number")elif num2 > num1 and num2 > num3: print(num2, " is the max number")else: print(num3, "is the max number") >> >> On Tue, Jan 29, 2019 at 1:48 PM Schachner, Joseph > wrote: >> Explanation: 5 > 4 so it goes into the first if. 5 is not greater than 6, so it does not assign N1 to MaxNum. The elif (because of the lack of indent) applies to the first if, so nothing further is executed. Nothing has been assigned to MaxNum, so that variable does not exist. You're right, it does not work. >> >> How about this: >> Mylist = [ N1, N2, N3] >> Maxnum = N1 >> for value in Mylist: >> if value > Maxnum: >> Maxnum = value >> print(Maxnum) >> >> Or were lists and for loops excluded from this exercise? >> --- Joe S. >> >> On 1/29/19 9:27 AM, Jack Dangler wrote: >> >> > wow. Seems like a lot going on. You have 3 ints and need to determine >> > the max? Doesn't this work? >> > >> > N1, N2, N3 >> > >> > if N1>N2 >> > if N1>N3 >> > MaxNum = N1 >> > elif N2>N3 >> > MaxNum = N2 >> > elif N1> > MaxNum = N3 >> >> No. Assuing that you meant to include colons where I think you did, what if (N1, N2, N3) == (5, 4, 6)? >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> -- >> https://mail.python.org/mailman/listinfo/python-list From bob at mellowood.ca Tue Jan 29 15:31:03 2019 From: bob at mellowood.ca (Bob van der Poel) Date: Tue, 29 Jan 2019 13:31:03 -0700 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: On Tue, Jan 29, 2019 at 12:52 PM Adrian Ordona wrote: > i'm also a beginner reading all the replies helps. > i was trying the problem myself and came up with the below code with a > users input. > > > num1 = int(input("Enter first number: "))num2 = int(input("Enter second > number: "))num3 = int(input("Enter third number: "))if num1 > num2 and num1 > > num3: print(num1, " is th max number")elif num2 > num1 and num2 > num3: > print(num2, " is the max number")else: print(num3, "is the max number") > > On Tue, Jan 29, 2019 at 1:48 PM Schachner, Joseph < > Joseph.Schachner at teledyne.com> wrote: > > > Explanation: 5 > 4 so it goes into the first if. 5 is not greater than > 6, > > so it does not assign N1 to MaxNum. The elif (because of the lack of > > indent) applies to the first if, so nothing further is executed. Nothing > > has been assigned to MaxNum, so that variable does not exist. You're > > right, it does not work. > > > > How about this: > > Mylist = [ N1, N2, N3] > > Maxnum = N1 > > for value in Mylist: > > if value > Maxnum: > > Maxnum = value > > print(Maxnum) > > > > Or were lists and for loops excluded from this exercise? > > --- Joe S. > > > > On 1/29/19 9:27 AM, Jack Dangler wrote: > > > > > wow. Seems like a lot going on. You have 3 ints and need to determine > > > the max? Doesn't this work? > > > > > > N1, N2, N3 > > > > > > if N1>N2 > > > if N1>N3 > > > MaxNum = N1 > > > elif N2>N3 > > > MaxNum = N2 > > > elif N1 > > MaxNum = N3 > > > > No. Assuing that you meant to include colons where I think you did, what > > if (N1, N2, N3) == (5, 4, 6)? > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > -- > https://mail.python.org/mailman/listinfo/python-list > Isn't the easiest way to do this is: sorted( [n1,n2,n3] )[-1] to get the largest value? -- **** 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 Tue Jan 29 16:25:01 2019 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 30 Jan 2019 08:25:01 +1100 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: On Wed, Jan 30, 2019 at 8:20 AM Bob van der Poel wrote: > Isn't the easiest way to do this is: > > sorted( [n1,n2,n3] )[-1] > > to get the largest value? >>> help(max) But the point of this exercise is not to use sorted() or max(). ChrisA From ianhclark510 at gmail.com Mon Jan 28 19:42:19 2019 From: ianhclark510 at gmail.com (Ian Clark) Date: Mon, 28 Jan 2019 16:42:19 -0800 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: threw this together, let me know what you think num_list=[] name_list = ['first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth'] name_it = name_list.pop(0) while len(num_list) < 3: try: num_list.append( int( input(f"Insert the {name_it} number: "))) except ValueError: print('Not a number, try again!') else: name_it = name_list.pop(0) print(f"Max number is: {sorted(num_list)[-1]}") On Mon, Jan 28, 2019 at 1:58 AM Frank Millman wrote: > "^Bart" wrote in message news:q2mghh$ah6$1 at gioia.aioe.org... > > > > > 1. The last two lines appear to be indented under the 'if number3 < ' > > > line. I think you want them to be unindented so that they run every > > > time. > > > > I'm sorry but I didn't completely understand what you wrote about the > last > > two lines, please could you write how my code could be fixed? > > > > The last four lines of your program look like this - > > if number3 < number2 and number3 < number1: > numbermin = number3 > > print("Number min is: ",numbermin) > > numbermiddle = (number1+number2+number3)-(numbermax+numbermin) > > print("Number middle is: ",numbermiddle) > > The last three lines all fall under the 'if number3 < number2' line, so > they > will only be executed if that line evaluates to True. > > I think that you want the last two lines to be executed every time. If so, > they should be lined up underneath the 'if', not the 'print'. > > > > > > if a == 1: > > > do something > > > elif a == 2: > > > do something else > > > > Finally I understood the differences between if and elif! Lol! :D > > > > It is actually short for 'else if', but I guess it is not obvious if you > have not seen it before! > > Frank > > > -- > https://mail.python.org/mailman/listinfo/python-list > From ianhclark510 at gmail.com Mon Jan 28 19:48:25 2019 From: ianhclark510 at gmail.com (Ian Clark) Date: Mon, 28 Jan 2019 16:48:25 -0800 Subject: Problem in Installing version 3.7.2(64 bit) In-Reply-To: References: Message-ID: back in my day we had to show our professors errors on punchcard! and we liked it On Sun, Jan 27, 2019 at 11:51 AM Terry Reedy wrote: > On 1/26/2019 6:24 AM, Vrinda Bansal wrote: > > Dear Sir/Madam, > > > > After Installation of the version 3.7.2(64 bit) in Windows 8 when I run > the > > program it gives an error. Screenshot of the error is attached below. > > Nope. This is text only mail list. Images are tossed. You must copy > and paste. > > -- > Terry Jan Reedy > > -- > https://mail.python.org/mailman/listinfo/python-list > From ianhclark510 at gmail.com Tue Jan 29 15:34:26 2019 From: ianhclark510 at gmail.com (Ian Clark) Date: Tue, 29 Jan 2019 12:34:26 -0800 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: just the pure number of letters next to parenthesis would cause the Parser to error out On Tue, Jan 29, 2019 at 12:32 PM Schachner, Joseph < Joseph.Schachner at teledyne.com> wrote: > Yes, that works. Assuming it was correctly formatted when you ran it. > The formatting could not possibly be run in a Python interpreter, I think. > > --- Joseph S. > > From: Adrian Ordona > Sent: Tuesday, January 29, 2019 2:52 PM > To: Schachner, Joseph > Cc: Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com>; > python-list at python.org > Subject: Re: Exercize to understand from three numbers which is more high > > i'm also a beginner reading all the replies helps. > i was trying the problem myself and came up with the below code with a > users input. > > > num1 = int(input("Enter first number: "))num2 = int(input("Enter second > number: "))num3 = int(input("Enter third number: "))if num1 > num2 and num1 > > num3: print(num1, " is th max number")elif num2 > num1 and num2 > > num3: print(num2, " is the max number")else: print(num3, "is the max > number") > > On Tue, Jan 29, 2019 at 1:48 PM Schachner, Joseph < > Joseph.Schachner at teledyne.com> > wrote: > Explanation: 5 > 4 so it goes into the first if. 5 is not greater than 6, > so it does not assign N1 to MaxNum. The elif (because of the lack of > indent) applies to the first if, so nothing further is executed. Nothing > has been assigned to MaxNum, so that variable does not exist. You're > right, it does not work. > > How about this: > Mylist = [ N1, N2, N3] > Maxnum = N1 > for value in Mylist: > if value > Maxnum: > Maxnum = value > print(Maxnum) > > Or were lists and for loops excluded from this exercise? > --- Joe S. > > On 1/29/19 9:27 AM, Jack Dangler wrote: > > > wow. Seems like a lot going on. You have 3 ints and need to determine > > the max? Doesn't this work? > > > > N1, N2, N3 > > > > if N1>N2 > > if N1>N3 > > MaxNum = N1 > > elif N2>N3 > > MaxNum = N2 > > elif N1 > MaxNum = N3 > > No. Assuing that you meant to include colons where I think you did, what > if (N1, N2, N3) == (5, 4, 6)? > > -- > https://mail.python.org/mailman/listinfo/python-list > -- > https://mail.python.org/mailman/listinfo/python-list > From ianhclark510 at gmail.com Tue Jan 29 16:04:43 2019 From: ianhclark510 at gmail.com (Ian Clark) Date: Tue, 29 Jan 2019 13:04:43 -0800 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: which version of Python? I get Syntax error on 3.7.1 On Tue, Jan 29, 2019 at 12:37 PM Adrian Ordona wrote: > The code actually works just the way i copy and pasted > > Sent from my iPhone > > On Jan 29, 2019, at 12:34, Ian Clark wrote: > > just the pure number of letters next to parenthesis would cause the Parser > to error out > > On Tue, Jan 29, 2019 at 12:32 PM Schachner, Joseph < > Joseph.Schachner at teledyne.com> wrote: > >> Yes, that works. Assuming it was correctly formatted when you ran it. >> The formatting could not possibly be run in a Python interpreter, I think. >> >> --- Joseph S. >> >> From: Adrian Ordona >> Sent: Tuesday, January 29, 2019 2:52 PM >> To: Schachner, Joseph >> Cc: Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com>; >> python-list at python.org >> Subject: Re: Exercize to understand from three numbers which is more high >> >> i'm also a beginner reading all the replies helps. >> i was trying the problem myself and came up with the below code with a >> users input. >> >> >> num1 = int(input("Enter first number: "))num2 = int(input("Enter second >> number: "))num3 = int(input("Enter third number: "))if num1 > num2 and num1 >> > num3: print(num1, " is th max number")elif num2 > num1 and num2 > >> num3: print(num2, " is the max number")else: print(num3, "is the max >> number") >> >> On Tue, Jan 29, 2019 at 1:48 PM Schachner, Joseph < >> Joseph.Schachner at teledyne.com> >> wrote: >> Explanation: 5 > 4 so it goes into the first if. 5 is not greater than >> 6, so it does not assign N1 to MaxNum. The elif (because of the lack of >> indent) applies to the first if, so nothing further is executed. Nothing >> has been assigned to MaxNum, so that variable does not exist. You're >> right, it does not work. >> >> How about this: >> Mylist = [ N1, N2, N3] >> Maxnum = N1 >> for value in Mylist: >> if value > Maxnum: >> Maxnum = value >> print(Maxnum) >> >> Or were lists and for loops excluded from this exercise? >> --- Joe S. >> >> On 1/29/19 9:27 AM, Jack Dangler wrote: >> >> > wow. Seems like a lot going on. You have 3 ints and need to determine >> > the max? Doesn't this work? >> > >> > N1, N2, N3 >> > >> > if N1>N2 >> > if N1>N3 >> > MaxNum = N1 >> > elif N2>N3 >> > MaxNum = N2 >> > elif N1> > MaxNum = N3 >> >> No. Assuing that you meant to include colons where I think you did, what >> if (N1, N2, N3) == (5, 4, 6)? >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From ianhclark510 at gmail.com Tue Jan 29 19:30:56 2019 From: ianhclark510 at gmail.com (Ian Clark) Date: Tue, 29 Jan 2019 16:30:56 -0800 Subject: Exercize to understand from three numbers which is more high In-Reply-To: References: Message-ID: Like this? num_max = 0 num_index = 0 name_list = ['first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth'] name_it = name_list.pop(0) while num_index <3: try: num_list = int( input(f"Insert the {name_it} number: ")) except ValueError: print('Not a number, try again!') else: num_index += 1 if num_list > num_max: num_max = num_list name_it = name_list.pop(0) print(f"Max number is: {num_max}") On Tue, Jan 29, 2019 at 1:26 PM Chris Angelico wrote: > On Wed, Jan 30, 2019 at 8:20 AM Bob van der Poel wrote: > > Isn't the easiest way to do this is: > > > > sorted( [n1,n2,n3] )[-1] > > > > to get the largest value? > > >>> help(max) > > But the point of this exercise is not to use sorted() or max(). > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From 101929.ha at gmail.com Mon Jan 28 21:19:30 2019 From: 101929.ha at gmail.com (Hamish Allen) Date: Tue, 29 Jan 2019 13:19:30 +1100 Subject: Python stopped installing packages Message-ID: <5c4fb835.1c69fb81.368a4.0f4a@mx.google.com> Hi, Recently I?ve been trying to code a Discord bot in Python 3.6.2, then I realised that some features of discord.py were only available in Python 3.7+ (as seen here on the right near the top https://docs.python.org/3/library/asyncio.html), so I downloaded 3.7.2. After correctly changing the environmental variables to have Python 3.7.2 before Python 3.6.2, I tried installing (for installing I was using cmd ?pip install discord.py?, I?m not aware of any other way to install packages) discord.py onto Python 3.7.2, but after a few seconds there would be a whole page of red error text (attached), then it would say successfully installed. I tried importing it in code, but it would return errors implying it was incorrectly installed. I asked one of my friends for some help. He suggested uninstalling Python 3.6.2 and 3.7.2 and reinstalling Python 3.7.2. I thought this was a pretty good idea so I did it. Discord.py still refuses to be installed. I tried installing some of the packages I had in 3.6.2, but they had the same sort of problem. I?ve tried running the installer to repair the files, but that didn?t work. I would appreciate if you could help me. I got discord.py from here: https://github.com/Rapptz/discord.py I?ve tried the 3 commands in the Installing section and I?ve tried pip install discord.py. Thanks, Hamish From ianhclark510 at gmail.com Tue Jan 29 19:56:56 2019 From: ianhclark510 at gmail.com (Ian Clark) Date: Tue, 29 Jan 2019 16:56:56 -0800 Subject: Python stopped installing packages In-Reply-To: <5c4fb835.1c69fb81.368a4.0f4a@mx.google.com> References: <5c4fb835.1c69fb81.368a4.0f4a@mx.google.com> Message-ID: according to https://pypi.org/project/discord.py/ Discord.py only supports 3.4 and 3.5 On Tue, Jan 29, 2019 at 4:52 PM Hamish Allen <101929.ha at gmail.com> wrote: > Hi, > > Recently I?ve been trying to code a Discord bot in Python 3.6.2, then I > realised that some features of discord.py were only available in Python > 3.7+ (as seen here on the right near the top > https://docs.python.org/3/library/asyncio.html), so I downloaded 3.7.2. > After correctly changing the environmental variables to have Python 3.7.2 > before Python 3.6.2, I tried installing (for installing I was using cmd > ?pip install discord.py?, I?m not aware of any other way to install > packages) discord.py onto Python 3.7.2, but after a few seconds there would > be a whole page of red error text (attached), then it would say > successfully installed. I tried importing it in code, but it would return > errors implying it was incorrectly installed. I asked one of my friends for > some help. He suggested uninstalling Python 3.6.2 and 3.7.2 and > reinstalling Python 3.7.2. I thought this was a pretty good idea so I did > it. Discord.py still refuses to be installed. I tried installing some of > the packages I had in 3.6.2, but they had the same sort of problem. I?ve > tried running the installer to repair the files, but that didn?t work. I > would appreciate if you could help me. I got discord.py from here: > https://github.com/Rapptz/discord.py I?ve tried the 3 commands in the > Installing section and I?ve tried pip install discord.py. > > Thanks, > Hamish > -- > https://mail.python.org/mailman/listinfo/python-list > From avigross at verizon.net Tue Jan 29 21:47:19 2019 From: avigross at verizon.net (Avi Gross) Date: Tue, 29 Jan 2019 21:47:19 -0500 Subject: The power of three, sort of Message-ID: <008601d4b846$1e375030$5aa5f090$@verizon.net> I have chosen to stay out of the discussion as it clearly was a TEACHING example where giving an ANSWER is not the point. So I would like to add some thought without a detailed answer for the boring way some are trying to steer an answer for. They are probably right that the instructor wants the students to learn that way. My understanding is the lesson was in how to use the IF command on exactly three numbers to get the maximum, or perhaps both the maximum and minimum. If this was not for school but the real world, the trivial answer would be to use max() or min() or perhaps a minmax() that returns a tuple. Or, you could sort() and choose the first and/or last. All the above are easy and expand well to any number of N items. My second thought was to do it in one of several standard methods with nested IF/ELSE statements perhaps using an ELIF. It would produce six (or perhaps more) branches and each of them would set any of a/b/c to be the maximum. A second complete set would invert some of the > or >= symbols to get the minimum. But that seems quite long and complicated and I will not show it as we keep waiting for the student to solve it and then show it so any other students could copy it! Since there are 3! Possible combinations (albeit if some numbers are the same, sort of less) a brute force method seems preferable as in: if (a >= b >= c): max = a . if (c >= b >= a): max = c That seems wasteful in so many ways and can be shortened perhaps to: if (a >= b >= c): max = a elif (b >= a >= c): max = b . else: max = c Again, six known combinations and fewer tests on average. Another variation is arguably even easier to think about. max, min = float('-inf'), float('inf') if a > max: max = a . if c > max: max = c # repeat for min using < No nesting and I assume within the allowed rules. The latter makes you wonder about using the one (perhaps two or three) line version: a, b, c = int(input("first: ")), int(input("second: ")), int(input("last: ")) max = a if (a>=b and a>=c) else (b if (b>=a and b>=c) else c) print("max = %d" % max) Again, fairly simple but using a ternary and nested version of if. Results: first: 5 second: 10 last: 7 max = 10 first: 5 second: 10 last: 10 max = 10 Not saying this is a charmed version using the power of three but I wonder what kind of answers the instructor expects. I mean you can trivially write more versions including iterative ones where you unpack the input into a tuple or list and iterate on it or where you use a function for recursion or create an object you keep adding to that maintains the biggest so far and on and on. You can even do calculations after the first two inputs and then use that to compare after the third input. There is no one right answer even for simplified methods. If I get to teach this, I probably would not tell them there are many ways but might give extra credit for those who innovate or make it somewhat more efficient looking but perhaps penalize solutions that others might not easily understand. Ending comment. Every use of the ellipsis above should not be typed in and represent missing lines that need to be added but are not being specified. The one liner does work and there are more nested variations of that you can use. My thoughts apply well beyond this simple example to the question of how you define a problem so that people use only what they know so far and are taught how to use it even if they may not ever actually need to use it again. From bad_n_mad at yahoo.com Tue Jan 29 22:24:20 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Wed, 30 Jan 2019 04:24:20 +0100 Subject: Trying to figure out the data type from the code snippet Message-ID: I am trying to figure out what data type is assigned to variable p in this code snippet: for p in game.players.passing(): print p, p.team, p.passing_att, p.passer_rating() Results: R.Wilson SEA 29 55.7 J.Ryan SEA 1 158.3 A.Rodgers GB 34 55.8 https://stackoverflow.com/q/28056171/1324175 If p is a string ('print p' prints names of the players) then how is possible to access p.something? If p is an object, then how can p return a string? -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From cs at cskk.id.au Tue Jan 29 23:12:55 2019 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 30 Jan 2019 15:12:55 +1100 Subject: Trying to figure out the data type from the code snippet In-Reply-To: References: Message-ID: <20190130041255.GA24502@cskk.homeip.net> On 30Jan2019 04:24, Chupo wrote: >I am trying to figure out what data type is assigned to variable p in >this code snippet: > >for p in game.players.passing(): > print p, p.team, p.passing_att, p.passer_rating() Well, Python comes with a type() builtin function: print type(p) >Results: > >R.Wilson SEA 29 55.7 >J.Ryan SEA 1 158.3 >A.Rodgers GB 34 55.8 > >https://stackoverflow.com/q/28056171/1324175 > >If p is a string ('print p' prints names of the players) then how is >possible to access p.something? Well, if p is just a string, then you can't: strings don't have the attributes (".something") you're using. Thereofre p is not a string. (It _could_ be a subtype of str, but that is pretty unlikely. What you're probably wanting to know is that the print statement calls str(x) for every "x" which it is asked to print, and that "p" has a __str__ method returning the "R.Wilson" string (etc). All object's have an __str__ method, and for "p" it has been defined to produce what looks like a player's name. >If p is an object, then how can p return a string? "p" is definitely an object: all values in Python are objects. "p" doesn't return a string, it returns "p". However, "print" actually prints "str(p)". So it is call's p's __str__ method to get a string to print out. Think of it this way: print's purpose it to print things out, and it prints to the output which is text. You can only write strings to text, so print converts _everything_ it is given to a string. That "55.7" in your output: that is a string representing a floating point value. Cheers, Cameron Simpson From PythonList at DancesWithMice.info Wed Jan 30 00:12:02 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Wed, 30 Jan 2019 18:12:02 +1300 Subject: Trying to figure out the data type from the code snippet In-Reply-To: <20190130041255.GA24502@cskk.homeip.net> References: <20190130041255.GA24502@cskk.homeip.net> Message-ID: <916a8b5b-92a4-80f1-89a1-ba4c6f25ee1a@DancesWithMice.info> On 30/01/19 5:12 PM, Cameron Simpson wrote: > On 30Jan2019 04:24, Chupo wrote: >> I am trying to figure out what data type is assigned to variable p in >> this code snippet: >> >> for p in game.players.passing(): >> ?? print p, p.team, p.passing_att, p.passer_rating() > > Well, Python comes with a type() builtin function: > > ?print type(p) Alternately/additionally, if you ask help(p), it will reveal-all about the "class" (of which p is an "instance") - including some answers to your second question (and perhaps others which logically follow-on). If these terms are unfamiliar to you, then 'the manual' reference is https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes (although from the code above, it would appear that you are looking at Python 2.n!). There are plenty of other tutorials available. Additionally, Coursera has announced a course starting this week (U.Michigan), in Python and its classes - which can be audited for $free or used to obtain some sort of certification... -- Regards =dn From as at sci.fi Wed Jan 30 07:48:47 2019 From: as at sci.fi (Anssi Saari) Date: Wed, 30 Jan 2019 14:48:47 +0200 Subject: Problem in Installing version 3.7.2(64 bit) References: Message-ID: songbird writes: > my understanding is that this list is actually > several combined services (i'm not sure how the > mailing list operates or how it filters or rejects > things) and then there is the usenet list comp.lang.python > (which is how i see articles and replies). I'm aware but the message was sent to the mailing list and it's the mailing list that removes attachments. I suppose some Usenet servers might strip or reject articles that look like binaries, don't really know. I do think it extremely unlikely a beginner would send a Usenet post except maybe via Google Groups but that interface doesn't do attachments AFAIK. As the mailing list has moderators and they have recently flexed their muscles by outright banning people I'm hoping they would stop these attachment posts too. This would stop the oft repeated responses that attachments are stripped which I find annoying. From Richard at Damon-Family.org Wed Jan 30 08:02:57 2019 From: Richard at Damon-Family.org (Richard Damon) Date: Wed, 30 Jan 2019 08:02:57 -0500 Subject: Problem in Installing version 3.7.2(64 bit) In-Reply-To: References: Message-ID: <861d869d-b82c-65d5-259b-d2c973a755fd@Damon-Family.org> On 1/30/19 7:48 AM, Anssi Saari wrote: > songbird writes: > >> my understanding is that this list is actually >> several combined services (i'm not sure how the >> mailing list operates or how it filters or rejects >> things) and then there is the usenet list comp.lang.python >> (which is how i see articles and replies). > I'm aware but the message was sent to the mailing list and it's the > mailing list that removes attachments. I suppose some Usenet servers > might strip or reject articles that look like binaries, don't really > know. I do think it extremely unlikely a beginner would send a Usenet > post except maybe via Google Groups but that interface doesn't do > attachments AFAIK. > > As the mailing list has moderators and they have recently flexed their > muscles by outright banning people I'm hoping they would stop these > attachment posts too. This would stop the oft repeated responses that > attachments are stripped which I find annoying. > Part of the issue is that the software that does the processing isn't early enough in the mail queue to actually 'reject' the mail, but can only create a 'bounce back' message. The problem with bounce messages is that they go to who the message says is the sender, not necessarily to who the actual sender was, so create a back-scatter issue. The list software also does a lot more than just strip attachments, it appears that it also strips out (or maybe converts) html formatted messages and just passes on plain text messages. As someone who runs another list using the same software, a LOT of people don't understand this restriction and a far portion of the messages to the list are sent as HTML formatted, so rejecting rather than just stripping these would make a lot of people unhappy/confused. A lot of people also have little graphic included in their base message as signatures, etc, that naturally get stripped out in the conversion to plain text. -- Richard Damon From nimbiotics at gmail.com Wed Jan 30 09:37:23 2019 From: nimbiotics at gmail.com (Mario R. Osorio) Date: Wed, 30 Jan 2019 06:37:23 -0800 (PST) Subject: How do I get a python program to work on my phone? In-Reply-To: References: <002501d4b71e$406d16e0$c14744a0$@SGA.Ninja> Message-ID: You might want to check this project: https://pybee.org/ I've never used it but it shows promising. BTW, I'm a diabetic myself and I would be very thankful if you could share your application. I'm currently using 2 Android apps: StickBuddy offers a system to keep track of both where you pinch your fingers and where you inject insulin thus avoiding injecting or pinching repeatedly in the same locations. Insulator is a quick and dirty insuline intake calculator. They are both great but I'd like to have them in a single app that would immediately calculate the insuline needed according to the reading I just enter. StickBuddy has a lot of other interesting goodies; It also helps me keep track of my carbohydrate intake. Both apps are free. From none at invalid.com Wed Jan 30 13:17:35 2019 From: none at invalid.com (mm0fmf) Date: Wed, 30 Jan 2019 18:17:35 +0000 Subject: Problem in Installing version 3.7.2(64 bit) In-Reply-To: References: Message-ID: On 29/01/2019 00:48, Ian Clark wrote: > back in my day we had to show our professors errors on punchcard! and we > liked it > > On Sun, Jan 27, 2019 at 11:51 AM Terry Reedy wrote: > >> On 1/26/2019 6:24 AM, Vrinda Bansal wrote: >>> Dear Sir/Madam, >>> >>> After Installation of the version 3.7.2(64 bit) in Windows 8 when I run >> the >>> program it gives an error. Screenshot of the error is attached below. >> >> Nope. This is text only mail list. Images are tossed. You must copy >> and paste. >> >> -- >> Terry Jan Reedy >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> In which case you should know not to top punch your reply! From jkn_gg at nicorp.f9.co.uk Wed Jan 30 18:06:43 2019 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Wed, 30 Jan 2019 15:06:43 -0800 (PST) Subject: what considerations for changing height of replacement radiator? Message-ID: <7fea1bbf-5941-4d47-a550-c3c91397d1ec@googlegroups.com> Hi all I'm looking at changing a radiator in a bedroom shortly and wondering about my options re. sizing. The current radiator is 900mm W x 600mm H, and is single panel, no convector. So looking at some representative specs, let's say 550W output. I would be replacing this with a single panel, single convector radiator. From looking at the spec again, the same sized radiator gives around 50% greater output - 900W. I am wondering about fitting a 900mm W x 450mm H single panel, single convector, which would then reduce the output again to 700W or so, similar to the original. My reason for doing this would simply be 'neater appearance' of the smaller radiator, but it wouldn't be a problem if the replacement was the same size as the original. I am wondering if there is anything else (apart from power output) that I should be considering here? The radiator will be under a window and the CH is an olde school 'plan C', I think. I would probably fit a TRV in any case. There is no need to heat the room any better than currently... Thanks for any advice. Cheers Jon N From rosuav at gmail.com Wed Jan 30 18:37:18 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 31 Jan 2019 10:37:18 +1100 Subject: what considerations for changing height of replacement radiator? In-Reply-To: <7fea1bbf-5941-4d47-a550-c3c91397d1ec@googlegroups.com> References: <7fea1bbf-5941-4d47-a550-c3c91397d1ec@googlegroups.com> Message-ID: On Thu, Jan 31, 2019 at 10:11 AM jkn wrote: > > Hi all > I'm looking at changing a radiator in a bedroom shortly and wondering about > my options re. sizing. No problems! A Python 2.7 radiator is sometimes smaller than a Python 3.5+ radiator, but the newer model of radiator has a number of advantageous features. For example, you can seamlessly use temperatures in Arabic or Russian as well as English, and you can track your energy usage using the 'statistics' module. Or possibly this email was sent to the wrong list :) ChrisA From ianhclark510 at gmail.com Wed Jan 30 18:42:44 2019 From: ianhclark510 at gmail.com (Ian Clark) Date: Wed, 30 Jan 2019 15:42:44 -0800 Subject: what considerations for changing height of replacement radiator? In-Reply-To: <7fea1bbf-5941-4d47-a550-c3c91397d1ec@googlegroups.com> References: <7fea1bbf-5941-4d47-a550-c3c91397d1ec@googlegroups.com> Message-ID: looking for a Space heater? sorry, not the Java mailing list On Wed, Jan 30, 2019 at 3:11 PM jkn wrote: > Hi all > I'm looking at changing a radiator in a bedroom shortly and wondering > about > my options re. sizing. > > The current radiator is 900mm W x 600mm H, and is single panel, no > convector. So > looking at some representative specs, let's say 550W output. > > I would be replacing this with a single panel, single convector radiator. > From > looking at the spec again, the same sized radiator gives around 50% greater > output - 900W. > > I am wondering about fitting a 900mm W x 450mm H single panel, single > convector, > which would then reduce the output again to 700W or so, similar to the > original. > > My reason for doing this would simply be 'neater appearance' of the smaller > radiator, but it wouldn't be a problem if the replacement was the same > size as > the original. I am wondering if there is anything else (apart from power > output) > that I should be considering here? > > The radiator will be under a window and the CH is an olde school 'plan C', > I > think. I would probably fit a TRV in any case. There is no need to heat > the room > any better than currently... > > Thanks for any advice. > > Cheers > Jon N > -- > https://mail.python.org/mailman/listinfo/python-list > From avigross at verizon.net Wed Jan 30 20:02:40 2019 From: avigross at verizon.net (Avi Gross) Date: Wed, 30 Jan 2019 20:02:40 -0500 Subject: what considerations for changing height of replacement radiator? References: <7fea1bbf-5941-4d47-a550-c3c91397d1ec@googlegroups.com> Message-ID: <005e01d4b900$aa2afeb0$fe80fc10$@verizon.net> I disagree, politely, Chris. The request is too BASIC and Radiator is best done in R. I note especially how it has support for heat maps. But as with Python, I recommend a recent version of 3.X, and at least version 3.3.3 that came out in March 2017. As for the python 2.7 radiator, it works better if it is a new style class radiating from base class object. -----Original Message----- From: Python-list On Behalf Of Chris Angelico Sent: Wednesday, January 30, 2019 6:37 PM To: Python Subject: Re: what considerations for changing height of replacement radiator? On Thu, Jan 31, 2019 at 10:11 AM jkn wrote: > > Hi all > I'm looking at changing a radiator in a bedroom shortly and > wondering about my options re. sizing. No problems! A Python 2.7 radiator is sometimes smaller than a Python 3.5+ radiator, but the newer model of radiator has a number of advantageous features. For example, you can seamlessly use temperatures in Arabic or Russian as well as English, and you can track your energy usage using the 'statistics' module. Or possibly this email was sent to the wrong list :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list From bad_n_mad at yahoo.com Wed Jan 30 21:35:59 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 03:35:59 +0100 Subject: Trying to figure out the data type from the code snippet References: <20190130041255.GA24502@cskk.homeip.net> Message-ID: In article , Cameron Simpson says... > What you're probably wanting to know is that the print statement calls > str(x) for every "x" which it is asked to print, and that "p" has a > __str__ method returning the "R.Wilson" string (etc). All object's have > an __str__ method, and for "p" it has been defined to produce what looks > like a player's name. > Yes, that is exactly what answers my question, thank you very much for such a comprehensive explanation! I couldn't use type() because implementation of: game.players.passing() is not known. This is all info I saw: https://stackoverflow.com/q/28056171/1324175 I searched Google using quite a few search strings, for example: python object returning value python class returning value python dot python attribute but didn't find an answer because I didn't know what exactly should I search for. Best Regards -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From bad_n_mad at yahoo.com Wed Jan 30 21:38:10 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 03:38:10 +0100 Subject: Trying to figure out the data type from the code snippet References: <20190130041255.GA24502@cskk.homeip.net> <916a8b5b-92a4-80f1-89a1-ba4c6f25ee1a@DancesWithMice.info> Message-ID: In article , DL Neil says... > Alternately/additionally, if you ask help(p), it will reveal-all about > the "class" (of which p is an "instance") - including some answers to > your second question (and perhaps others which logically follow-on). Yes, but unfortunately this was all I had: https://stackoverflow.com/q/28056171/1324175 -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From PythonList at DancesWithMice.info Wed Jan 30 22:07:55 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 31 Jan 2019 16:07:55 +1300 Subject: Trying to figure out the data type from the code snippet In-Reply-To: References: <20190130041255.GA24502@cskk.homeip.net> <916a8b5b-92a4-80f1-89a1-ba4c6f25ee1a@DancesWithMice.info> Message-ID: On 31/01/19 3:38 PM, Chupo via Python-list wrote: > In article , DL > Neil says... >> Alternately/additionally, if you ask help(p), it will reveal-all about >> the "class" (of which p is an "instance") - including some answers to >> your second question (and perhaps others which logically follow-on). > > Yes, but unfortunately this was all I had: > > https://stackoverflow.com/q/28056171/1324175 It can't be - there must be some source for p (code and data)! Surely you're only showing us a small portion of the code? Like printing the type() or the string representation, using help() is a matter of adding one line to the source code... -- Regards =dn From bad_n_mad at yahoo.com Wed Jan 30 22:54:44 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 04:54:44 +0100 Subject: Trying to figure out the data type from the code snippet References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> Message-ID: In article <8bff3a64-e154-4e39-b558-952e8f28ae2e at googlegroups.com>, Rick Johnson says... > Listen... if you are not familiar with all of Python's built-in functions, > all special methods of Python objects, and all the methods of strings, > integers, floats, lists, tuples, dicts (and possibly others that i forgot > to mention), you can't do much of anything with this language. > > I would advise you to read a beginners tutorial. I am by any means not Python expert but I do have a basic Python knowledge and I do occasionally use Pyhon to perform some tasks. I am not a professional programmer but rather an electrical engineer and I am using various programming languages since 1982. I started with Z80 and 6502 assembler, Fortran, Pascal, ... and since I am often using microcontrollers my main programming languages are C and assembler. However, sometimes when I have to process some data, parse some file, generate some data, extract of filter some results acquired by sampling or measuring analog values, ... I do use Python - although I never learnt it from the book. I am using Python as a tool to accomplish the tasks as they 'arrive' and although my code is for sure not written in Pythonic way - it works. Since arrival of various SoCs (e.g. Rasbperry Pi) I used Python not only for pre/post processing the data but for building applications as well and some of the Python programs I wrote are: - Driver for *very* fast 3D printer which is unique in its construction - Filtering the data acquired from multiple AD converters sampling movements of human body using Savitzky-Golay filter - Program for sending large amount of data in real time via I2C BUS towards multiple microcontrollers every 10 ms (I used threading and Queue from multiprocessing and I am, upon sending the data over I2C BUS, scheduling a new thread in a way timing disturbances caused by background tasks and interrupts don't accumulate over time) - Programs used as 'a glue' between node.js code and microcontrollers - Interpolating the data used for sinhronizing lip movements of humanoid robot with spoken words between the keyframes - 3D animation of humaniod robot arms based on the data acquired by motion capture and by recording movements using rotary encoders And yes, I did use OOP. For example, I can use my driver for 3D printer to print one layer as follows: from Printer3D import Head import numpy as np import cv2 import glob import time np.set_printoptions(threshold=np.nan) layer = cv2.imread("./png_input/layer.png") visina, sirina = layer.shape[:2] print visina, sirina layer = cv2.cvtColor(layer, cv2.COLOR_BGR2GRAY) #layer = cv2.resize(layer, None, fx=0.5, fy=0.5, interpolation = cv2.INTER_AREA) hd = Head(layer) hd.setSteps_x(44, 44, 382) hd.setDistance(21) hd.setHead_GPIO([0, 4, 17, 27, 22, 10, 9, 11, 5, 6]) hd.setMotor_GPIO([13, 19, 26, 21, 20, 16]) hd.move(Head.ROW_UP, 10) hd.printLayer() hd.move(Head.UP, 10) So, the truth is - I am indeed (obviously) not familiar with everything you mentioned but you can decide for yourself if everything I already did using Python could be classified as 'not much'. -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From bad_n_mad at yahoo.com Wed Jan 30 23:00:22 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 05:00:22 +0100 Subject: Trying to figure out the data type from the code snippet References: <20190130041255.GA24502@cskk.homeip.net> <916a8b5b-92a4-80f1-89a1-ba4c6f25ee1a@DancesWithMice.info> Message-ID: In article , DL Neil says... > It can't be - there must be some source for p (code and data)! Surely > you're only showing us a small portion of the code? > I am not author of the question on StackOverflow. I was looking for something about Python and that question was among the search results. You can see the question was asked 4 years ago. -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From jkn_gg at nicorp.f9.co.uk Thu Jan 31 02:45:13 2019 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Wed, 30 Jan 2019 23:45:13 -0800 (PST) Subject: what considerations for changing height of replacement radiator? In-Reply-To: References: <7fea1bbf-5941-4d47-a550-c3c91397d1ec@googlegroups.com> <005e01d4b900$aa2afeb0$fe80fc10$@verizon.net> Message-ID: <1dffe899-5876-4519-903a-08d0475e7742@googlegroups.com> All very droll, thanks for the replies guys. I spotted my posting error 0.0001 secs after pressing the button... uk.d-i-y-is-that-way-ly yours J^n From gabriele1NOSPAM at hotmail.com Thu Jan 31 04:18:20 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Thu, 31 Jan 2019 10:18:20 +0100 Subject: =?UTF-8?B?SG93IHRvIHJlcGxhY2Ugc3BhY2UgaW4gYSBzdHJpbmcgd2l0aCBcbg==?= Message-ID: Hello everybody! :) I got a text and I should replace every space with \n without to use str.replace, I thought something like this: text = "The best day of my life!" space = (' ') if text.count(' ') in text: space=\n rightText = text-space print(rightText) I should have an output like this: The best day of my life! From mal at europython.eu Thu Jan 31 04:25:52 2019 From: mal at europython.eu (M.-A. Lemburg) Date: Thu, 31 Jan 2019 10:25:52 +0100 Subject: EPS: Announcing the Guido van Rossum Core Developer Grant Message-ID: <29ea24cb-1621-4e84-26ef-e2b1b7b6f730@europython.eu> At the last General Assembly of the EuroPython Society (EPS) at EuroPython 2018 in Edinburgh, we voted on a new grant program we want to put in place for future EuroPython conferences. We all love Python and this is one of the main reasons we are putting on EuroPython year after year, serving the "cast of thousands" which support Python. But we also believe it is important to give something back to the main team of developers who have contributed lots of their time and energy to make Python happen: the Python Core Developers. This group is small, works countless hours, often in their free time and often close to burnout due to not enough new core developers joining the team. Free Tickets for Python Core Developers --------------------------------------- To help with growing the team, putting it more into the spotlight and give them a place to meet, demonstrate their work and a stage to invite new developers, we decided to give Python Core Developers free entry to future EuroPython conferences, starting with EuroPython 2019 in Basel, Switzerland In recognition of Guido?s almost 20 years of leading this team, and with his permission, we have named the grant ?Guido van Rossum Core Developer Grant?. Details of the grant program are available on our core grant page: https://www.europython-society.org/core-grant PS: If you are a core developer and want to organize a workshop, language summit or similar event at EuroPython 2019, please get in touch with our program workgroup (program at europython.eu) soon, so that we can arrange rooms, slots, etc. PPS: If you want to become a core developer, please have a look at the Python Dev Guide: https://devguide.python.org/coredev/ 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://www.europython-society.org/post/182445627020/announcing-the-guido-van-rossum-core-developer Tweet: https://twitter.com/europythons/status/1090901995635073024 Enjoy, -- EuroPython Society https://ep2019.europython.eu/ https://www.europython-society.org/ From alister.ware at ntlworld.com Thu Jan 31 04:46:22 2019 From: alister.ware at ntlworld.com (Alister) Date: Thu, 31 Jan 2019 09:46:22 GMT Subject: How to replace space in a string with \n References: Message-ID: On Thu, 31 Jan 2019 10:18:20 +0100, ^Bart wrote: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, Why? > I thought something like this: > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: > space=\n > > rightText = text-space > > print(rightText) > > I should have an output like this: > The best day of my life! -- There is nothing new except what has been forgotten. -- Marie Antoinette From gabriele1NOSPAM at hotmail.com Thu Jan 31 04:55:03 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Thu, 31 Jan 2019 10:55:03 +0100 Subject: =?UTF-8?B?UmU6IEhvdyB0byByZXBsYWNlIHNwYWNlIGluIGEgc3RyaW5nIHdpdGggXG4=?= References: Message-ID: > Why? It's a school test, now we should use just what we studied, if than, else, sequences, etc.! ^Bart From michael.poeltl at univie.ac.at Thu Jan 31 04:31:37 2019 From: michael.poeltl at univie.ac.at (Michael Poeltl) Date: Thu, 31 Jan 2019 10:31:37 +0100 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: <20190131093137.vdfmpbfkuzgsinsw@univie.ac.at> maybe this is an alternative way to get your wished result. >>> text = "The best day of my life!" >>> newtext = '\n'.join( text.split() ) >>> print(newtext) The best day of my life! >>> yours Michael * ^Bart [2019-01-31 10:22]: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: > space=\n > > rightText = text-space > > print(rightText) > > I should have an output like this: > The > best > day > of > my > life! > > -- > https://mail.python.org/mailman/listinfo/python-list -- Michael Poeltl Computational Materials Physics at University Wien, Sensengasse 8/12, A-1090 Wien, AUSTRIA http://cmp.univie.ac.at/ http://homepage.univie.ac.at/michael.poeltl/ using elinks-0.12, mutt-1.5.21, and vim-7.4, with python-3.6.1, on linux mint 17.3 (rose) :-) fon: +43-1-4277-51409 "Lehrend lernen wir!" From michael.poeltl at univie.ac.at Thu Jan 31 04:34:03 2019 From: michael.poeltl at univie.ac.at (Michael Poeltl) Date: Thu, 31 Jan 2019 10:34:03 +0100 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: <20190131093403.xhtwntwnna2ffgha@univie.ac.at> hi, Maybe this is a proper way to do what you'd liked to achieve >>> text = "The best day of my life!" >>> newtext = '\n'.join( text.split() ) >>> print(newtext) The best day of my life! >>> yours Michael * ^Bart [2019-01-31 10:22]: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: > space=\n > > rightText = text-space > > print(rightText) > > I should have an output like this: > The > best > day > of > my > life! > > -- > https://mail.python.org/mailman/listinfo/python-list -- Michael Poeltl Computational Materials Physics at University Wien, Sensengasse 8/12, A-1090 Wien, AUSTRIA http://cmp.univie.ac.at/ http://homepage.univie.ac.at/michael.poeltl/ using elinks-0.12, mutt-1.5.21, and vim-7.4, with python-3.6.1, on linux mint 17.3 (rose) :-) fon: +43-1-4277-51409 "Lehrend lernen wir!" From michael.poeltl at univie.ac.at Thu Jan 31 04:37:52 2019 From: michael.poeltl at univie.ac.at (Michael Poeltl) Date: Thu, 31 Jan 2019 10:37:52 +0100 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: <20190131093752.kqtkltwa726y26l4@univie.ac.at> hi, ^Bart ended in a Mail-Delivery... so I send it ONLY to the python-list ^Bert, a proper way to do what you'd liked to achieve is the following: >>> text = "The best day of my life!" >>> newtext = '\n'.join( text.split() ) >>> print(newtext) The best day of my life! >>> regards Michael * ^Bart [2019-01-31 10:22]: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: > space=\n > > rightText = text-space > > print(rightText) > > I should have an output like this: > The > best > day > of > my > life! > > -- > https://mail.python.org/mailman/listinfo/python-list -- Michael Poeltl Computational Materials Physics at University Wien, Sensengasse 8/12, A-1090 Wien, AUSTRIA http://cmp.univie.ac.at/ http://homepage.univie.ac.at/michael.poeltl/ using elinks-0.12, mutt-1.5.21, and vim-7.4, with python-3.6.1, on linux mint 17.3 (rose) :-) fon: +43-1-4277-51409 "Lehrend lernen wir!" From __peter__ at web.de Thu Jan 31 05:13:10 2019 From: __peter__ at web.de (Peter Otten) Date: Thu, 31 Jan 2019 11:13:10 +0100 Subject: How to replace space in a string with \n References: Message-ID: ^Bart wrote: >> Why? > > It's a school test, now we should use just what we studied, if than, > else, sequences, etc.! > > ^Bart Hint: you can iterate over the characters of a string >>> for c in "hello": ... print(c) ... h e l l o From antoon.pardon at vub.be Thu Jan 31 05:14:11 2019 From: antoon.pardon at vub.be (Antoon Pardon) Date: Thu, 31 Jan 2019 11:14:11 +0100 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: <059c75eb-4d93-e0c6-ea6b-a53708e57c94@vub.be> On 31/01/19 10:18, ^Bart wrote: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: Have you even tried to run this? > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: > ??? space=\n I don't think this does what you think it does. text.count(' ') will return 5, an integer. So you are testing if 5 is in text. But since 5 is an integer that will raise a TypeError. > > rightText = text-space Where does text-space come from? -- Antoon. From antoon.pardon at vub.be Thu Jan 31 05:17:21 2019 From: antoon.pardon at vub.be (Antoon Pardon) Date: Thu, 31 Jan 2019 11:17:21 +0100 Subject: How to replace space in a string with \n In-Reply-To: <20190131093752.kqtkltwa726y26l4@univie.ac.at> References: <20190131093752.kqtkltwa726y26l4@univie.ac.at> Message-ID: <0976c7e3-c9c5-a50c-fe40-5232ce54f62d@vub.be> On 31/01/19 10:37, Michael Poeltl wrote: > hi, > > ^Bart ended in a Mail-Delivery... > so I send it ONLY to the python-list > > ^Bert, a proper way to do what you'd liked to achieve is the following: No it is not the proper way of a school test to copy what others provided. -- Antoon. From gabriele1NOSPAM at hotmail.com Thu Jan 31 05:43:36 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Thu, 31 Jan 2019 11:43:36 +0100 Subject: =?UTF-8?B?UmU6IEhvdyB0byByZXBsYWNlIHNwYWNlIGluIGEgc3RyaW5nIHdpdGggXG4=?= References: <059c75eb-4d93-e0c6-ea6b-a53708e57c94@vub.be> Message-ID: > Have you even tried to run this? No, it doesn't run, it's just a personal idea! :) > I don't think this does what you think it does. > > text.count(' ') will return 5, an integer. So you are testing if 5 is in text. But since > 5 is an integer that will raise a TypeError. Yes, I understood this is wrong! >> rightText = text-space > > > Where does text-space come from? I thought to use (text) - (space), space is " " but I should replace in text what I said in the variable is space. I know there are a lot o solutions but this afternoon I'll ask to the teacher what we should do to do it! Thank you very much for your reply! :) ^Bart From gabriele1NOSPAM at hotmail.com Thu Jan 31 05:47:07 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Thu, 31 Jan 2019 11:47:07 +0100 Subject: =?UTF-8?B?UmU6IEhvdyB0byByZXBsYWNlIHNwYWNlIGluIGEgc3RyaW5nIHdpdGggXG4=?= References: <20190131093403.xhtwntwnna2ffgha@univie.ac.at> Message-ID: > . A correct answer to the exercise would be: > > |You cannot replace a space with \n in a string, > |because strings are immutable in Python. Yes, I thought in a wrong way! :) From gabriele1NOSPAM at hotmail.com Thu Jan 31 05:49:09 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Thu, 31 Jan 2019 11:49:09 +0100 Subject: =?UTF-8?B?UmU6IEhvdyB0byByZXBsYWNlIHNwYWNlIGluIGEgc3RyaW5nIHdpdGggXG4=?= References: <20190131093403.xhtwntwnna2ffgha@univie.ac.at> Message-ID: Il 31/01/19 10:34, Michael Poeltl ha scritto: > hi, > Maybe this is a proper way to do what you'd liked to achieve > >>>> text = "The best day of my life!" >>>> newtext = '\n'.join( text.split() ) >>>> print(newtext) > The > best > day > of > my > life! >>>> > > yours > Michael Thanks Michael, I'll ask to my teacher in the afternoon if he has the same idea, you know when you start a new language you should solve problems just with few things, when your mind understood how the language works you can use every tools of this language! :) ^Bart From gabriele1NOSPAM at hotmail.com Thu Jan 31 05:50:29 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Thu, 31 Jan 2019 11:50:29 +0100 Subject: =?UTF-8?B?UmU6IEhvdyB0byByZXBsYWNlIHNwYWNlIGluIGEgc3RyaW5nIHdpdGggXG4=?= References: Message-ID: > You coulde use ?sub? from the module ?re?, then. > (The Python Library Reference, Release 3.8.0a0 - > 6.2 re - Regular expression operations) We're using 3.7.2 :\ > Otherwise, > > Write a loop that takes the first character from > the source and appends it to a new string until > there is no more character left in the source. > > You now should have written a loop that copies > the string character by character. > > Then it is easy to modify the loop a little bit > to complete the exercise. I'll ask it to the teacher this afternoon, thanks for your reply! :) ^Bart From gabriele1NOSPAM at hotmail.com Thu Jan 31 05:53:10 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Thu, 31 Jan 2019 11:53:10 +0100 Subject: =?UTF-8?B?UmU6IEhvdyB0byByZXBsYWNlIHNwYWNlIGluIGEgc3RyaW5nIHdpdGggXG4=?= References: <20190131093752.kqtkltwa726y26l4@univie.ac.at> <0976c7e3-c9c5-a50c-fe40-5232ce54f62d@vub.be> Message-ID: > No it is not the proper way of a school test to copy what others provided. You're right but I need just to understand what tools I should use, it could be nice if the teacher says something like "use just these three tools to solve this problem" or "you don't need to use these other tools to do it!" I hope you understood what I mean... ^Bart From antoon.pardon at vub.be Thu Jan 31 05:58:18 2019 From: antoon.pardon at vub.be (Antoon Pardon) Date: Thu, 31 Jan 2019 11:58:18 +0100 Subject: How to replace space in a string with \n In-Reply-To: References: <20190131093403.xhtwntwnna2ffgha@univie.ac.at> Message-ID: <0aaddc78-7990-6bf9-be6c-b100b4b68428@vub.be> On 31/01/19 11:47, ^Bart wrote: >> ?? . A correct answer to the exercise would be: >> >> |You cannot replace a space with \n in a string, >> |because strings are immutable in Python. > > Yes, I thought in a wrong way! :) > Well maybe you can turn the string into a list of characters. Then replace the spaces with newlines and finaly turn the list into a string again. -- Antoon. From rosuav at gmail.com Thu Jan 31 06:09:40 2019 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 31 Jan 2019 22:09:40 +1100 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: On Thu, Jan 31, 2019 at 9:56 PM ^Bart wrote: > > > You coulde use ?sub? from the module ?re?, then. > > (The Python Library Reference, Release 3.8.0a0 - > > 6.2 re - Regular expression operations) > > We're using 3.7.2 :\ > Don't worry about that difference - 3.8 is only minorly different from 3.7. ChrisA From michael.poeltl at univie.ac.at Thu Jan 31 06:17:40 2019 From: michael.poeltl at univie.ac.at (Michael Poeltl) Date: Thu, 31 Jan 2019 12:17:40 +0100 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: <20190131111740.dmu3x5cxn33bcuif@univie.ac.at> hi ^Bert, I've just thought that you don't like to use text.replace(' ', '\n'), and so I came up with another way to get the job done. So it was part of a "school-test" - uiuitststs ;-) follow the hint from Peter then, and inside *your* for-loop ask yourself, how to inspect the value of c in a loop and what to do *if* the value of c was ' ' . as mentioned, a string is immuteable, so you cannot change it *inplace* - you have to build a new str-object (has a new object-id the starting with an empty string say newtext = '' and with each loop over your original text you add one character like newtext = newtext+c and only if c has a value of ' ', then you add a different value like '\n' well, now you should try to understand peters for-loop, and then you should try to combine what you have learned with the if-statement within the for(-loop) block happy learning the python-language! It's a great one, this I can promise you! regards Michael * Peter Otten <__peter__ at web.de> [2019-01-31 11:15]: > ^Bart wrote: > > >> Why? > > > > It's a school test, now we should use just what we studied, if than, > > else, sequences, etc.! > > > > ^Bart > > Hint: you can iterate over the characters of a string > > >>> for c in "hello": > ... print(c) > ... > h > e > l > l > o > > > > > -- > https://mail.python.org/mailman/listinfo/python-list -- Michael Poeltl Computational Materials Physics at University Wien, Sensengasse 8/12, A-1090 Wien, AUSTRIA http://cmp.univie.ac.at/ http://homepage.univie.ac.at/michael.poeltl/ using elinks-0.12, mutt-1.5.21, and vim-7.4, with python-3.6.1, on linux mint 17.3 (rose) :-) fon: +43-1-4277-51409 "Lehrend lernen wir!" From gabriele1NOSPAM at hotmail.com Thu Jan 31 06:35:47 2019 From: gabriele1NOSPAM at hotmail.com (^Bart) Date: Thu, 31 Jan 2019 12:35:47 +0100 Subject: =?UTF-8?B?UmU6IEhvdyB0byByZXBsYWNlIHNwYWNlIGluIGEgc3RyaW5nIHdpdGggXG4=?= References: Message-ID: [Solved by myself and I'm happy!!! :)] text = "The best day of my life!" space = text[3] print (text.replace(space, "\n")) [Like what I said in another message, in the afternoon I'll ask to the teacher if for this exercise we're able to use .replace] From ianhclark510 at gmail.com Thu Jan 31 11:19:52 2019 From: ianhclark510 at gmail.com (Ian Clark) Date: Thu, 31 Jan 2019 08:19:52 -0800 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: text = "The best day of my life!" output = '' for i in text: if i == ' ': output +='\n' else: output += i print(output) throwing my hat in the ring, not only is it .replace free it is entirely method free On Thu, Jan 31, 2019 at 3:41 AM ^Bart wrote: > [Solved by myself and I'm happy!!! :)] > > text = "The best day of my life!" > > space = text[3] > > print (text.replace(space, "\n")) > > [Like what I said in another message, in the afternoon I'll ask to the > teacher if for this exercise we're able to use .replace] > -- > https://mail.python.org/mailman/listinfo/python-list > From avigross at verizon.net Thu Jan 31 13:10:36 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 31 Jan 2019 13:10:36 -0500 Subject: How to replace space in a string with \n In-Reply-To: References: <20190131093403.xhtwntwnna2ffgha@univie.ac.at> Message-ID: <005a01d4b990$4419fcd0$cc4df670$@verizon.net> It is amazing to watch what happens when a fairly simple question is asked to see how people answer. In an effort not to ramble, I will summarize my thoughts. The student wanted to know how to solve a problem using only what they already should know and that specifically they should not use a method. In effect, they are being asked to write the kind of code that might be used to make such a method. There were many answers including some that absurdly suggested even more advanced methods they should not know. Frankly, the question belongs more in the sister list for tutoring and even there, the goal is NOT to supply an answer but point out flaws in code provided as an attempt or suggest an outline of a method and let the student fill it out and learn. This is not only a public forum but one that is searchable indefinitely into the future. Providing a full-blown answer not only hands a solution to one student but to their classmates and any future takers. I note another poster asking questions turns out to be not a student but someone quite advanced who likes to learn just in time as they search for what is needed. They require a very different approach and can learn well from being handed a more detailed solution they can interpolate into their project. So, how do you replace? I think a loop answer is probably best for this student. For the second type of questioner, many of the others would be great including suggesting they just use replace as there is nothing wrong with that! NOTE: It is great when we have an exact set of requirements. I note that the requirement here might not require making a new string at all. If you just need to PRINT the words on multiple lines, one solution is to call "print" on each character in the loop using the appropriate method to suppress printing a newline except when you see a blank. From tjreedy at udel.edu Thu Jan 31 13:25:11 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 31 Jan 2019 13:25:11 -0500 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: On 1/31/2019 11:19 AM, Ian Clark wrote: > text = "The best day of my life!" > output = '' > > for i in text: > if i == ' ': > output +='\n' > else: > output += i > > print(output) > > throwing my hat in the ring, not only is it .replace free it is entirely > method free But this is an awful, O(n*n) way to solve an inherently O(n) problem, which I think should not be taught to beginners unless they are simultaneously taught to never do this for indefinitely large n. -- Terry Jan Reedy From grant.b.edwards at gmail.com Thu Jan 31 13:33:08 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 31 Jan 2019 18:33:08 -0000 (UTC) Subject: How to replace space in a string with \n References: Message-ID: On 2019-01-31, Terry Reedy wrote: > On 1/31/2019 11:19 AM, Ian Clark wrote: >> text = "The best day of my life!" >> output = '' >> >> for i in text: >> if i == ' ': >> output +='\n' >> else: >> output += i >> >> print(output) > But this is an awful, O(n*n) way to solve an inherently O(n) problem, How is it O(n^2)? It loops through the input sequence exactly once. That looks like O(n) to me. -- Grant Edwards grant.b.edwards Yow! Not SENSUOUS ... only at "FROLICSOME" ... and in gmail.com need of DENTAL WORK ... in PAIN!!! From rosuav at gmail.com Thu Jan 31 13:36:28 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 1 Feb 2019 05:36:28 +1100 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: On Fri, Feb 1, 2019 at 5:34 AM Grant Edwards wrote: > > On 2019-01-31, Terry Reedy wrote: > > On 1/31/2019 11:19 AM, Ian Clark wrote: > >> text = "The best day of my life!" > >> output = '' > >> > >> for i in text: > >> if i == ' ': > >> output +='\n' > >> else: > >> output += i > >> > >> print(output) > > > But this is an awful, O(n*n) way to solve an inherently O(n) problem, > > How is it O(n^2)? > > It loops through the input sequence exactly once. That looks like > O(n) to me. > Appending onto an immutable string means copying the entire string and adding the new character. (CPython does have an optimization that can sometimes improve this specific case, but in general, this algorithm runs in quadratic time.) ChrisA From grant.b.edwards at gmail.com Thu Jan 31 13:36:21 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 31 Jan 2019 18:36:21 -0000 (UTC) Subject: How to replace space in a string with \n References: Message-ID: On 2019-01-31, Grant Edwards wrote: > On 2019-01-31, Terry Reedy wrote: >> On 1/31/2019 11:19 AM, Ian Clark wrote: >>> text = "The best day of my life!" >>> output = '' >>> >>> for i in text: >>> if i == ' ': >>> output +='\n' >>> else: >>> output += i >>> >>> print(output) > >> But this is an awful, O(n*n) way to solve an inherently O(n) problem, > > How is it O(n^2)? > > It loops through the input sequence exactly once. That looks like > O(n) to me. Doh! The 'output +=' operation is also O(n), and it's executed n times. -- Grant Edwards grant.b.edwards Yow! I hope something GOOD at came in the mail today so gmail.com I have a REASON to live!! From grant.b.edwards at gmail.com Thu Jan 31 13:49:50 2019 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 31 Jan 2019 18:49:50 -0000 (UTC) Subject: How to replace space in a string with \n References: Message-ID: On 2019-01-31, ^Bart wrote: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: > > text = "The best day of my life!" [...] > I should have an output like this: > The > best > day > of > my > life! Here's a solution. But don't turn it in. You're not supposed to know how to do this yet, and your instructor will know you copied it from the internet: print(''.join('\n' if c == ' ' else c for c in text)) -- Grant Edwards grant.b.edwards Yow! over in west at Philadelphia a puppy is gmail.com vomiting ... From neilc at norwich.edu Thu Jan 31 14:49:59 2019 From: neilc at norwich.edu (Neil Cerutti) Date: 31 Jan 2019 19:49:59 GMT Subject: How to replace space in a string with \n References: Message-ID: On 2019-01-31, ^Bart wrote: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: > space=\n > > rightText = text-space > > print(rightText) Your code resembles Python code, but it isn't close enough for me to offer reasonable help. You should figure out how to solve your problem *before* you start to write code. A paper and pencil will be required! -- Neil Cerutti From bad_n_mad at yahoo.com Thu Jan 31 14:50:37 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 20:50:37 +0100 Subject: Trying to figure out the data type from the code snippet References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: In article <67d5c4bc-7212-43d0-b44f-7f22efffa17c at googlegroups.com>, Rick Johnson says... > I'm impressed! But you're asking basic questions that someone with your resume should either (1) already know, or (2) be competent enough to find on their own. Now don't get me wrong. My intention is not to ridicule you. But, with your resume, you should be embarrassed to ask such basic questions. You are obviously not an idiot. If you can do what you claim you can do, then you are intelligent and driven person. There are redeemable qualities. Don't waste them. And don't undercut your reputation by appearing to be a hapless rube. I was thought there aren't stupid questions, just stupid answers and I for sure won't apologize for asking any question. If someone things the question I asked is stupid they can ignore it. I am not affraid of losing my reputation by asking a question. > Hmm. I don't see anything here that a child couldn't be taught to do. You failed to see the point of the code snippet I pasted, let me explain what was my intention to show with that code: Since I said I wrote a driver for 3D printer and since there is: from Printer3D import Head at the beginning of the code and there is: hd = Head(layer) below - from just those two lines you could conclude I wrote Head class meaning I *am* aware what object is. And since hd.printLayer() obviously does print a layer of the material, that means my 3D printer driver is working well. I assumed you could imagine that the driver for driving the head of 3D printer is not just a few lines of code, that it works in real-time and that it interacts with the hardware. > Your reseme may be impressive... What I mentioned is not my resume, I just mentioned what I, knowing only Python basics, did using Python. My resume includes: Embedded devices for industry process control automation (temperature, fluid level, time, data from PID controller, ?); VFD control systems with complex menu structure, user friendly interface, failsafe and data retention; IoT applications; multi-channel sound generation; bike computer; remote data acquisition over RF; data logging; ERP software coding (C#); client&web service sw for warehouse handheld data acquisition system (SOAP requests), software for CNC machines duty simplifications and many more I am an expert on embedded systems design with more than 50,000 lines of C code built-in in various working firmwares. I both designed and built many embedded electronic devices based on various microcontrollers doing all the production stages, designing circuit schematics, calculating the elements, designing printed circuit boards, generating Gerber files according to the manufacturing requirements, soldering components (both TH and SMD) and coding&debugging the firmwares. By utilizing GCC based toolchain and Bare Metal Programming, developing my own libraries and optimizing the most critical routines by writing them in assembler I can often design the devices based on 16 MHz or even just 8 MHz Atmel AVR line of microcontrollers, where others would resort to using 72 MHz ARM or even more powerful processors. Although my carefully optimized devices usually outperform the devices based on even much more powerful hardware, I am using the newest generation of microcontrollers such as ESP8266 and ESP32 as well. I learnt Z80 assembler when I was 10 and after years of coding in both Z80 and 6502 assembler it was easy to start using Microchip's PIC microcontrollers. Later on I switched to Atmel's (now Microchip) microcontrollers and to the newest ones I mentioned before. I can start using completely new family of microcontrollers and completely new toolchains in a matter of days. I coded all sorts of SPI, I2C, UART, 1-Wire etc. and custom communication routines, both using the hardware peripherals and/or bit banging algorithms, hardware/software PWM, efficient debounce algorithms, multitasking environments, routines for precise measuring of pulse lengths, complex ISR routines with carefully calculated T-states (cycles) per pass, DDS algorithms, graphic display libraries, libraries for communicating with various devices (e.g. NRF24L01+), EEPROM wear leveling routines and many more. Furthermore, I have a vast experience with reverse engineering .hex files extracted from microcontrollers which allows me to easily proof the assembly code generated by the compiler in order to - if necessary - rewrite the code in a more efficient way, while my deep understanding of serial and parallel programming protocols, bootloaders, JTAG debugging and inner workings of a microcontroller allows me to cope with all kinds of problems that could be met while developing embedded devices (e.g. noisy environments, black-outs, brown-outs, BUS contention, contact bounce, ?). Additionally, I have a reasonable knowledge of Genetic and other AI algorithms (pathfinding, game AI, ?). To name just a few. > But your Python skills, are not. Unfortunately they are not. But have I ever said they are? However I did use C++, Java, JavaScript, PHP, C#, Perl, LISP, Bash, GLSL, (X)HTML, CSS, ... And, yes, I did use Python :-) ps I strongly suggest you reading some basic netiquette article regarding posting on newsgroups - specifically the parts about recommended line lengths when posting articles, this one is good enough: http://linux.sgms-centre.com/misc/netiquette.php -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From bad_n_mad at yahoo.com Thu Jan 31 14:55:07 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 20:55:07 +0100 Subject: Trying to figure out the data type from the code snippet References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: > I was thought > I meant: 'I was taught'. -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From rosuav at gmail.com Thu Jan 31 15:00:33 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 1 Feb 2019 07:00:33 +1100 Subject: Trying to figure out the data type from the code snippet In-Reply-To: References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: On Fri, Feb 1, 2019 at 6:56 AM Chupo via Python-list wrote: > > In article <67d5c4bc-7212-43d0-b44f-7f22efffa17c at googlegroups.com>, > Rick Johnson says... > > > > > I'm impressed! But you're asking basic questions that someone with your resume should either (1) already know, or (2) be competent enough to find on their own. Now don't get me wrong. My intention is not to ridicule you. But, with your resume, you should be embarrassed to ask such basic questions. You are obviously not an idiot. If you can do what you claim you can do, then you are intelligent and driven > person. There are redeemable qualities. Don't waste them. And don't undercut your reputation by appearing to be a hapless rube. > > > I was thought there aren't stupid questions, just stupid answers and I > for sure won't apologize for asking any question. If someone things the > question I asked is stupid they can ignore it. I am not affraid of > losing my reputation by asking a question. > > There are stupid questions, but I enjoy answering those too. You don't need to apologize for asking these questions. All you need to do is ignore the trolls like Rick. In fact, if you abandon Google Groups and instead read the mailing list python-list at python.org, you can just leave behind all the people who've been blocked. ChrisA From bad_n_mad at yahoo.com Thu Jan 31 15:31:55 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 21:31:55 +0100 Subject: Trying to figure out the data type from the code snippet References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: In article , Chris Angelico says... > There are stupid questions, but I enjoy answering those too. You don't > need to apologize for asking these questions. All you need to do is > ignore the trolls like Rick. In fact, if you abandon Google Groups and > instead read the mailing list python-list at python.org, you can just > leave behind all the people who've been blocked. > Thank you for the tip. I am in fact not using Google Groups but am accessing comp.lang.python via nntp:// by using a newsreader. I think Google Groups destroyed usenet. -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From rosuav at gmail.com Thu Jan 31 15:39:17 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 1 Feb 2019 07:39:17 +1100 Subject: Trying to figure out the data type from the code snippet In-Reply-To: References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: On Fri, Feb 1, 2019 at 7:36 AM Chupo via Python-list wrote: > > In article , Chris > Angelico says... > > There are stupid questions, but I enjoy answering those too. You don't > > need to apologize for asking these questions. All you need to do is > > ignore the trolls like Rick. In fact, if you abandon Google Groups and > > instead read the mailing list python-list at python.org, you can just > > leave behind all the people who've been blocked. > > > > Thank you for the tip. > > I am in fact not using Google Groups but am accessing comp.lang.python > via nntp:// by using a newsreader. Ah okay. You may want to killfile a few people then, since you're using an actual real newsreader and have that capability. ChrisA From bad_n_mad at yahoo.com Thu Jan 31 15:58:24 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 21:58:24 +0100 Subject: Trying to figure out the data type from the code snippet References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: In article , Chris Angelico says... > Ah okay. You may want to killfile a few people then, since you're > using an actual real newsreader and have that capability. > Yes, Gravity has Bozo Bin for that purpose :-) But although I've been using newsgroups for 20 years I've never blocked a single person by using a filter because it is not hard to just not open certain messages posted by known authors. Especially nowadays when post count is so low. -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From bad_n_mad at yahoo.com Thu Jan 31 17:12:21 2019 From: bad_n_mad at yahoo.com (Chupo) Date: Thu, 31 Jan 2019 23:12:21 +0100 Subject: Trying to figure out the data type from the code snippet References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: In article , Rick Johnson says... > You know _all_ that What I mentioned is just a small excerpt of what I know :-) > yet... you didn't know about the built-in `type()` method? Exactly :-) > Well, that's just great. We can only hope you don't try your hand at any mission-critical code. And i suppose when the plane crashes you can always fall back on the "beautiful plumage" of your resume, eh chap? > Now that you are saying that, I thing I should abandon my 150 km/h racing quadcopter flight controller project :-O Especially because my idea was to use PYTHON for analyzing the data from onboard black box flash in order to fine tune PIDs. Hahah LOL :-) -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo From PythonList at DancesWithMice.info Thu Jan 31 17:54:59 2019 From: PythonList at DancesWithMice.info (DL Neil) Date: Fri, 1 Feb 2019 11:54:59 +1300 Subject: Trying to figure out the data type from the code snippet In-Reply-To: References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: <57c599b5-58f8-36d2-68e3-5c12749710cb@DancesWithMice.info> On 1/02/19 9:00 AM, Chris Angelico wrote: > On Fri, Feb 1, 2019 at 6:56 AM Chupo via Python-list > wrote: >> In article <67d5c4bc-7212-43d0-b44f-7f22efffa17c at googlegroups.com>, >> Rick Johnson says... >> >> I was thought there aren't stupid questions, just stupid answers and I >> for sure won't apologize for asking any question. If someone things the >> question I asked is stupid they can ignore it. I am not affraid of >> losing my reputation by asking a question. > There are stupid questions, but I enjoy answering those too. You don't ... (TLDR?: the are "stupid questions", here's why, and some ideas with which to frame/consider responses) Many years ago, gulp, decades ago; when I first started-out in vocational training, I also thought 'there are no stupid questions, only stupid answers'. Possibly I was?am idealistic in other ways too. Whilst this phrase 'sounds good', is it logical? It seems to assume that a questioner can never ask something in a stupid fashion, whilst at the same time assuming/insulting a respondent with the opposite assumption. (notwithstanding that it can be difficult to find the right words with which to phrase a question - particularly someone learning Python's concepts. Also, we should never forget that many 'here' are not communicating in their primary/home language - thank you for making that effort!) Back when we rode dinosaurs to school, the maxim was "children should be seen and not heard". The teacher was 'the sage on the stage' and questions had to be invited/were not encouraged - talking to others was either "behind the teacher's back" or "cheating", and thus subject to discipline (yes, there was such a thing, once upon a time). Today, there is a more social approach to learning, where questions, of the teacher or of peers are encouraged - and if you'll permit me to disappear into cognitive psychology for a moment, it is a much more efficient way to learn! However, it also requires that whereas we didn't 'interfere' with others' learning by keeping silent, the members of such a 'modern' society find new levels of respect for each other, when it is (not) acceptable to do such things, etc, etc. Contrarily, we also live in 'the Internet Age' which includes the rise of a sense (?right) of "immediacy". In short: we want it now! Sadly, this engenders an apparent motivation to rush 'in' (see also "panic"), rather than holding-fire and thinking first - or as the old dinosaur used to say "put brain into gear, before mouth into motion"! I should also mention that the above is very much a description of how things are 'in the west' (ie 'western world', 'western culture'). Younger colleagues educated in India and China (per example only) tell me that their educational modus 'today' is much closer to my own 'back then'. Accordingly, until friendships are establish, preparedness to ask questions is low - is thought to reveal ignorance, even lack of respect of 'teacher'. There are 'bad questions': - someone unable to immediately solve a problem, turns to his colleague/this list and garbles: - there may be facts, but are they sufficient? - there is often no background to understand the motivation for the question - there is usually a component of 'how do I fix my solution' cf here is the (actual) problem to be solved - laziness, ie asking someone else to exert effort to save self - eg no evidence of an attempted solution - no reference to web or book research - learning avoidance (even 'destruction'): - see current conversation on list where student has clearly said that he is dealing with a teacher-directed assignment So the definition of 'bad question' may boil-down to the motivation of the questioner being 'good' or 'bad', rather than the wording itself. Why are you asking this question? Amusingly enough, that's amongst the training given to anyone learning training (if you follow): always try to (first) understand why the person is asking you this question, then try to answer in similar mode! - a question asked on-impulse pretty much implies that a direct/complete answer will be taken similarly. In which case, it is extremely unlikely that the questioner will *learn* from the experience - thus will be forced to ask again 'next time'. "Give a man a fish and he eats today. Teach a man to fish and he eats every day!" (only an aphorism, sadly not literal fact!) Accordingly, 'answering' the original question with clarification questions is not a 'silly answer'. Indeed neuroscience shows that taking a break from a problem allows the brain to move 'the facts' from "working memory" into 'the back of my mind' and/or more permanent memory (ie learning); and possibly more important to problem-solving, from the logico-cortex into other parts of the brain where 'the facts' become associated with "prior knowledge" and other components of 'intelligence' may be brought to bear. How often have you taken a shower, gone out jogging, walked to the water cooler; and suddenly 'the answer' somehow magically presents itself in your mind! Accordingly, forcing our impulse-driven questioner to wait for his/her own brain to catch-up is also 'an answer'! (and how many times have you kindly responded to such a question only to have that person rudely retort that (s)he'd already solved the problem. (like you weren't fast-enough man!). Questioner motivation? Whither 'respect'?) - lazy questioners make themselves quickly apparent. After a while colleagues/fellow list-members become irritated and ignore the person - a "time-sink" rather than a contributing member of society. (see various recent posts offering technical and social 'solutions' to this) Accordingly, answers designed to elicit evidence of 'prior work' might seem rude (what code do you have so far? what was the err.msg?), but are actually a form of polite response (and perhaps 'kinder' than 'blanking' his/her enquiry?) - learning avoidance can be apparent in either or both the original question and replies to responses. Whilst RTFM may seem to be a rude response (on multiple levels), in fact it is in many ways the best thing to do. Perhaps it would be more constructive to point to particular pages within the (fine) manual, eg the ones specifically dealing with Python classes or introspection; or mention concepts which should be examined (see recent posts). However, once again, if the actual objective facing the questioner is that (s)he learn (perhaps the design behind the 'homework' assigned by a teacher!), then giving a 'perfect code' answer *appears* to solve the problem, but induces cognitive by-pass in the questioner. It only appears to be 'the right thing to do' and responds to the questioner's request that list-members extend "kindness" - 'the right thing to do' *socially*. However, from a learning/teaching point-of-view, having acquired only "an answer" (cf how to find the answer/arrive at a solution), the next time teacher assigns work, the same *low* level of question appears on the list... From a training perspective, showing the student where 'the solution' may be found or ideas worthy of exploration, equips him/her with (learning that there is) a tool which can be applied to future problems (even many decades later! - please excuse the ageist, sardonic humor if not to your taste). With reference to 'reputation': actually this is a 'big deal' in the modern world and social networking. Posts chasing "likes" is casual evidence of such. Employers reviewing potential employees by trawling social media certainly think so. Do the list members have some sort of responsibility to become respondents to the questioner? In which case, what is the complementary responsibility - and how is it demonstrated? A questioner is free to say *whatever*, but surely every relationship requires some measure of respect? When I first started training 'over the Internet' of great concern was moving from the (known) difficulties of relating to a few hundred students in a lecture, to the 'unknown' of how to help (tens of) thousands of trainees over discussion boards. Perhaps a background in 'radio' helped (it becomes quite easy to recognise a person's voice, without actually 'hearing' the call-sign; and even at the 'low-level' of Morse code an individual's "fist" becomes readily recognisable). I soon discovered that 'personality' is revealed, even in such a text-only medium! Thus it became possible to 'tune' responses to the personality - knowing who to rebuff and where to best devote time... Certainly, here on the list there are email addresses which stand-out, for one reason or another. The student who asks homework-questions, the person who is operating a some meta-level (way above mere Python syntax), etc. As advised by others, we read or delete, as we're wont... Every now and again, someone asks what can be done to 'improve' the quality of questions being asked on the list. The different lists for different purposes are an attempt to reduce the reader's impression of 'noise' - and you'll see this on the likes of StackOverflow when folk are directed to another board.. (IIRC) The Let's Encrypt people tried to tackle this problem by putting a template into each new question. The poster is prompted to enter identification data, eg OpSys, version numbers, whatever. I'm amazed (but again, I'm 'old' - in the eyes of some others) at how many posters ignore the template and blurt requirements in their own (selfish?) manner. Needless to say, that's sufficient indication for many to decide that it is indeed a "silly question", and hit DEL(ete). Certainly, when reading the question, if the answer first requires information that should have been included, per the template, the silliness of the question/the motivations of the questioner/the questioner's respect for list members' time, becomes starkly evident. Sadly then, the 'solution' actually requires extra and pointless reading before the question is even posed! Which brings us to another, perhaps idealistic, question: can we use technology to solve what is essentially a personal (the questioner, the respondent) or social problem? -- Regards =dn From tjreedy at udel.edu Thu Jan 31 18:05:50 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 31 Jan 2019 18:05:50 -0500 Subject: How to replace space in a string with \n In-Reply-To: References: Message-ID: On 1/31/2019 1:36 PM, Grant Edwards wrote: > On 2019-01-31, Grant Edwards wrote: >> On 2019-01-31, Terry Reedy wrote: >>> On 1/31/2019 11:19 AM, Ian Clark wrote: >>>> text = "The best day of my life!" >>>> output = '' >>>> >>>> for i in text: >>>> if i == ' ': >>>> output +='\n' >>>> else: >>>> output += i >>>> >>>> print(output) >> >>> But this is an awful, O(n*n) way to solve an inherently O(n) problem, >> >> How is it O(n^2)? >> >> It loops through the input sequence exactly once. That looks like >> O(n) to me. > > Doh! > > The 'output +=' operation is also O(n), and it's executed n times. It is like bubble sort doing n x O(n) operations. This does not mean that O(n*n) is always bad as it may beat O(n*logn) or even O(n) in terms of real time when the neglected multiplier and other terms are considered*. I regularly write use + to catenate a few, fixed number of terms. But I just read a blogger who used += in a loop like the above where there could also be 1000s or more strings to be added together. * timsort (Tim Peters), used for list.sort and other language sorts, uses 'O(n*n)' binary insert sort for 'short' subarrays. Tim empirically selected 64 as the boundary between 'short' and 'long' for Python. On modern CPUs, the O(n*n), shifting part of an array, is done (relatively fast) with a single machine instruction. -- Terry Jan Reedy From tjreedy at udel.edu Thu Jan 31 18:13:36 2019 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 31 Jan 2019 18:13:36 -0500 Subject: Trying to figure out the data type from the code snippet In-Reply-To: References: <8bff3a64-e154-4e39-b558-952e8f28ae2e@googlegroups.com> <67d5c4bc-7212-43d0-b44f-7f22efffa17c@googlegroups.com> Message-ID: On 1/31/2019 3:31 PM, Chupo via Python-list wrote: > In article , Chris > Angelico says... >> There are stupid questions, but I enjoy answering those too. You don't >> need to apologize for asking these questions. All you need to do is >> ignore the trolls like Rick. In fact, if you abandon Google Groups and >> instead read the mailing list python-list at python.org, you can just >> leave behind all the people who've been blocked. >> > > Thank you for the tip. > > I am in fact not using Google Groups but am accessing comp.lang.python > via nntp:// by using a newsreader. Then point your newsreader, as I have, to news.gmane.org and subscribe to gmane.comp.python.general, which mirrors python-list. -- Terry Jan Reedy From avigross at verizon.net Thu Jan 31 19:28:12 2019 From: avigross at verizon.net (Avi Gross) Date: Thu, 31 Jan 2019 19:28:12 -0500 Subject: Bringing Order to programming Message-ID: <012b01d4b9c5$03d8e930$0b8abb90$@verizon.net> The discussion moved on to debating if an algorithm is O(N) or O(N**2). For small amounts of text, on fast machines, it really is not worth worrying about the cost of appending to the end of a growing string resulting in multiple copies and lots of garbage collection. Many computer textbooks love to tell you that nothing should be modifiable as a paradigm and endless copying is good for you since you never change existing data so fewer mistakes ... But, for any programmers that happily want to read in entire books and for some reason then replace all spaces with newlines, may I suggest the following. Convert your "text" to/from a list of individual characters. Copy the non-space characters to the end of an empty list and append a newline when you see a space. This part should be O(N) as lists have a fast way to append in constant time. At the end, use str(listname) to do what is needed to get back a string. Also O(N). I won't supply the code for obvious reasons but it looks like: final_list = [] for character in initial_text: # Add carefully to the end of final_list final_text = str(final_list) The second variant is to use the newer bytearray data structure very carefully as it is to a first approximation a mutable string. Adding to the end of a new one should be quick. WARNING: I said be careful. A bytearray is more like a list of 8-bit ints. With care you can handle ASCII text. From python at mrabarnett.plus.com Thu Jan 31 21:56:08 2019 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 1 Feb 2019 02:56:08 +0000 Subject: Bringing Order to programming In-Reply-To: <012b01d4b9c5$03d8e930$0b8abb90$@verizon.net> References: <012b01d4b9c5$03d8e930$0b8abb90$@verizon.net> Message-ID: <9bf14d79-1464-49c7-62ee-327868ddba51@mrabarnett.plus.com> On 2019-02-01 00:28, Avi Gross wrote: > The discussion moved on to debating if an algorithm is O(N) or O(N**2). > > For small amounts of text, on fast machines, it really is not worth worrying > about the cost of appending to the end of a growing string resulting in > multiple copies and lots of garbage collection. Many computer textbooks love > to tell you that nothing should be modifiable as a paradigm and endless > copying is good for you since you never change existing data so fewer > mistakes ... > > But, for any programmers that happily want to read in entire books and for > some reason then replace all spaces with newlines, may I suggest the > following. > > Convert your "text" to/from a list of individual characters. Copy the > non-space characters to the end of an empty list and append a newline when > you see a space. This part should be O(N) as lists have a fast way to append > in constant time. At the end, use str(listname) to do what is needed to get > back a string. Also O(N). > > I won't supply the code for obvious reasons but it looks like: > > final_list = [] > for character in initial_text: > # Add carefully to the end of final_list > final_text = str(final_list) > > The second variant is to use the newer bytearray data structure very > carefully as it is to a first approximation a mutable string. Adding to the > end of a new one should be quick. WARNING: I said be careful. A bytearray is > more like a list of 8-bit ints. With care you can handle ASCII text. > If you're replacing anything within the ASCII range, it'll also work for UTF-8! From rosuav at gmail.com Thu Jan 31 22:08:39 2019 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 1 Feb 2019 14:08:39 +1100 Subject: Bringing Order to programming In-Reply-To: <9bf14d79-1464-49c7-62ee-327868ddba51@mrabarnett.plus.com> References: <012b01d4b9c5$03d8e930$0b8abb90$@verizon.net> <9bf14d79-1464-49c7-62ee-327868ddba51@mrabarnett.plus.com> Message-ID: On Fri, Feb 1, 2019 at 2:00 PM MRAB wrote: > > On 2019-02-01 00:28, Avi Gross wrote: > > The second variant is to use the newer bytearray data structure very > > carefully as it is to a first approximation a mutable string. Adding to the > > end of a new one should be quick. WARNING: I said be careful. A bytearray is > > more like a list of 8-bit ints. With care you can handle ASCII text. > > > If you're replacing anything within the ASCII range, it'll also work for > UTF-8! It'll work if you represent the string as UTF-8 bytes, yes. Perhaps it would be better to represent a string as a sequence of 21-bit integers instead of 8-bit integers? ChrisA From ben.usenet at bsb.me.uk Thu Jan 31 23:28:22 2019 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Fri, 01 Feb 2019 04:28:22 +0000 Subject: Bringing Order to programming References: <012b01d4b9c5$03d8e930$0b8abb90$@verizon.net> Message-ID: <87h8dop1y1.fsf@bsb.me.uk> ram at zedat.fu-berlin.de (Stefan Ram) writes: > source = \ > 'Python is an easy to learn, powerful programming language. It has' + \ > ' efficient high-level data structures and a simple but effective' + \ > ' approach to object-oriented programming. Python's elegant syntax' + \ You have an unexscped ' in there. > ' and dynamic typing, together with its interpreted nature, make it' + \ > ' an ideal language for scripting and rapid application development' + \ > ' in many areas on most platforms. '; > transcript > > a 0.0680 s, a 1.2040 s, a 9.5823 s, a 81.9688 s, My times are very nearly linear: a 0.0280 s, a 0.2931 s, a 2.9006 s, a 29.4318 s, -- Ben.