From james at webbpsychology.co.nz Sat Sep 1 03:25:27 2018 From: james at webbpsychology.co.nz (james at webbpsychology.co.nz) Date: Sat, 1 Sep 2018 00:25:27 -0700 (PDT) Subject: Python installer hangs in Windows 7 In-Reply-To: References: <765703485.1601081.1486357381135.ref@mail.yahoo.com> <765703485.1601081.1486357381135@mail.yahoo.com> Message-ID: <4743f337-7a8a-4346-8263-e39a5dcf2d66@googlegroups.com> Same problem, Win7, Unchecking "Install launcher for all users" sorted things. Thanks for the advice. From frank at chagford.com Sat Sep 1 07:27:59 2018 From: frank at chagford.com (Frank Millman) Date: Sat, 1 Sep 2018 13:27:59 +0200 Subject: Question about floating point Message-ID: "Frank Millman" wrote in message news:... "Frank Millman" wrote in message news:pm3l2m$kv4$1 at blaine.gmane.org... > > I know about this gotcha - > > >>> x = 1.1 + 2.2 > >>> x > 3.3000000000000003 > [...] I have enjoyed the discussion, and I have learnt a lot about floating point. Thanks to all. I have just noticed one oddity which I thought worth a mention. >>> from decimal import Decimal as D >>> f"{D('1.1')+D('2.2'):.60f}" '3.300000000000000000000000000000000000000000000000000000000000' >>> '{:.60f}'.format(D('1.1') + D('2.2')) '3.300000000000000000000000000000000000000000000000000000000000' >>> '%.60f' % (D('1.1') + D('2.2')) '3.299999999999999822364316059974953532218933105468750000000000' >>> The first two format methods behave as expected. The old-style '%' operator does not. Frank From p.f.moore at gmail.com Sat Sep 1 10:23:28 2018 From: p.f.moore at gmail.com (Paul Moore) Date: Sat, 1 Sep 2018 15:23:28 +0100 Subject: Question about floating point In-Reply-To: References: Message-ID: On Sat, 1 Sep 2018 at 12:31, Frank Millman wrote: > > "Frank Millman" wrote in message news:pm3l2m$kv4$1 at blaine.gmane.org... > > > > I know about this gotcha - > > > > >>> x = 1.1 + 2.2 > > >>> x > > 3.3000000000000003 > > > [...] > > I have enjoyed the discussion, and I have learnt a lot about floating point. > Thanks to all. > > I have just noticed one oddity which I thought worth a mention. > > >>> from decimal import Decimal as D > >>> f"{D('1.1')+D('2.2'):.60f}" > '3.300000000000000000000000000000000000000000000000000000000000' > >>> '{:.60f}'.format(D('1.1') + D('2.2')) > '3.300000000000000000000000000000000000000000000000000000000000' > >>> '%.60f' % (D('1.1') + D('2.2')) > '3.299999999999999822364316059974953532218933105468750000000000' > >>> > > The first two format methods behave as expected. The old-style '%' operator > does not. > > Frank Presumably, Decimal has a custom formatting method. The old-style % formatting doesn't support custom per-class formatting, so %.60f converts its argument to float and then prints it. Paul From steve+comp.lang.python at pearwood.info Sat Sep 1 10:23:40 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 1 Sep 2018 14:23:40 +0000 (UTC) Subject: Question about floating point References: Message-ID: On Sat, 01 Sep 2018 13:27:59 +0200, Frank Millman wrote: >>>> from decimal import Decimal as D >>>> f"{D('1.1')+D('2.2'):.60f}" > '3.300000000000000000000000000000000000000000000000000000000000' >>>> '{:.60f}'.format(D('1.1') + D('2.2')) > '3.300000000000000000000000000000000000000000000000000000000000' >>>> '%.60f' % (D('1.1') + D('2.2')) > '3.299999999999999822364316059974953532218933105468750000000000' >>>> >>>> > The first two format methods behave as expected. The old-style '%' > operator does not. The % operator casts the argument to a (binary) float. The other two don't need to, because they call Decimal's own format method. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From mohan4h at gmail.com Sat Sep 1 13:11:59 2018 From: mohan4h at gmail.com (mohan4h at gmail.com) Date: Sat, 1 Sep 2018 10:11:59 -0700 (PDT) Subject: Help Needed : script weird result. Message-ID: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> All, I m trying to run this small script to find the lowest of the given array of numbers. The script works fine for various combination of inputs but fails in a weird way for a particular set of inputs, can anyone point the mistake in the script and the behavior. Script x = input ("Enter the numbers separated by space and press ENTER :") x = x.split(" ") def checkmin(arr): lowest = arr[0] for count in range(0,len(arr),1): if arr[count] < lowest : lowest = arr[count] else : pass print (lowest) return lowest minimum = checkmin(x) print ("Lowest : {0}".format (minimum)) Weird output is as below. ================== RESTART: C:\Users\mohan\Desktop\temp.py ================== Enter the numbers separated by space and press ENTER :5 90 63 82 59 24 5 5 5 5 5 24 Lowest : 24 Regards Mohan C From duncan at invalid.invalid Sat Sep 1 13:20:31 2018 From: duncan at invalid.invalid (duncan smith) Date: Sat, 1 Sep 2018 18:20:31 +0100 Subject: Help Needed : script weird result. In-Reply-To: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> References: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> Message-ID: On 01/09/18 18:11, mohan4h at gmail.com wrote: > All, > > I m trying to run this small script to find the lowest of the given array of numbers. The script works fine for various combination of inputs but fails in a weird way for a particular set of inputs, can anyone point the mistake in the script and the behavior. > > Script > > x = input ("Enter the numbers separated by space and press ENTER :") > x = x.split(" ") > > def checkmin(arr): > lowest = arr[0] > for count in range(0,len(arr),1): > if arr[count] < lowest : > lowest = arr[count] > else : > pass > print (lowest) > return lowest > > minimum = checkmin(x) > print ("Lowest : {0}".format (minimum)) > > > Weird output is as below. > > ================== RESTART: C:\Users\mohan\Desktop\temp.py ================== > Enter the numbers separated by space and press ENTER :5 90 63 82 59 24 > 5 > 5 > 5 > 5 > 5 > 24 > Lowest : 24 > > Regards > Mohan C > Compare, >>> min(5, 90, 63, 82, 59, 24) 5 >>> min('5', '90', '63', '82', '59', '24') '24' >>> Duncan From 2QdxY4RzWzUUiLuE at potatochowder.com Sat Sep 1 13:27:44 2018 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Sat, 1 Sep 2018 13:27:44 -0400 Subject: Help Needed : script weird result. In-Reply-To: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> References: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> Message-ID: On 9/1/18 1:11 PM, mohan4h at gmail.com wrote: > All, > > I m trying to run this small script to find the lowest of the given array of numbers. The script works fine for various combination of inputs but fails in a weird way for a particular set of inputs, can anyone point the mistake in the script and the behavior. > > Script > > x = input ("Enter the numbers separated by space and press ENTER :") Think about what x is here, and what x.split does. > x = x.split(" ") Now think about what x is again, and recall that Python is strongly typed. Dan From joel.goldstick at gmail.com Sat Sep 1 13:29:59 2018 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Sat, 1 Sep 2018 13:29:59 -0400 Subject: Help Needed : script weird result. In-Reply-To: References: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> Message-ID: On Sat, Sep 1, 2018 at 1:26 PM duncan smith wrote: > > On 01/09/18 18:11, mohan4h at gmail.com wrote: > > All, > > > > I m trying to run this small script to find the lowest of the given array of numbers. The script works fine for various combination of inputs but fails in a weird way for a particular set of inputs, can anyone point the mistake in the script and the behavior. > > > > Script > > > > x = input ("Enter the numbers separated by space and press ENTER :") > > x = x.split(" ") > > > > def checkmin(arr): > > lowest = arr[0] > > for count in range(0,len(arr),1): > > if arr[count] < lowest : > > lowest = arr[count] > > else : > > pass > > print (lowest) > > return lowest > > > > minimum = checkmin(x) > > print ("Lowest : {0}".format (minimum)) > > > > > > Weird output is as below. > > > > ================== RESTART: C:\Users\mohan\Desktop\temp.py ================== > > Enter the numbers separated by space and press ENTER :5 90 63 82 59 24 > > 5 > > 5 > > 5 > > 5 > > 5 > > 24 > > Lowest : 24 > > > > Regards > > Mohan C > > > > > Compare, > > >>> min(5, 90, 63, 82, 59, 24) > 5 > >>> min('5', '90', '63', '82', '59', '24') > '24' > >>> > > Duncan > -- > https://mail.python.org/mailman/listinfo/python-list integers are not strings. Strings collate according to alphanumeric sequence. So the 2 in 24 makes it less than the 5 -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From pkpearson at nowhere.invalid Sat Sep 1 13:43:58 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 1 Sep 2018 17:43:58 GMT Subject: Verifying the integrity/lineage of a file References: <1535726212.3464303.1492604560.35EA349A@webmail.messagingengine.com> <1535741518.3530403.1492875656.23ECF436@webmail.messagingengine.com> Message-ID: On Fri, 31 Aug 2018 12:51:58 -0600, Malcolm Greene wrote: > Thanks for the replies! I'm going to investigate the use of > python-gnupg which is a Python wrapper for the GPG command line > utility. This library is based on gpg.py written by Andrew Kuchling. > I'm all ears if f anyone has any alternative recommendations or > python-gnupg tips to share. BTW: Target clients are running under > Windows and Linux. Writing your own crypto software is fraught with peril, and that includes using existing libraries. If you don't expect your system to get serious attention from a competent adversary, then fine, go ahead. No ... not even that. If you're _quite_confident_ that your system will never get serious attention ... go ahead. But if you think your system might someday be attacked by an adversary who will exploit insufficiently unguessable nonces, or accidental nonce re-use, or swap-space images of your executing code, or side channels, or any of the other hundreds of issues that have left the history of cryptography so entertainingly littered with the bodies of brilliant aspirants, . . . then use a much-studied, time-tested product. Don't take my word for it (retired cryptologist), ask any reputable cryptologist. Or ask on the sci.crypt newsgroup; they need some traffic. -- To email me, substitute nowhere->runbox, invalid->com. From pkpearson at nowhere.invalid Sat Sep 1 14:05:07 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 1 Sep 2018 18:05:07 GMT Subject: Help Needed : script weird result. References: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> Message-ID: On Sat, 1 Sep 2018 10:11:59 -0700 (PDT), mohan4h at gmail.com wrote: > All, > > I m trying to run this small script to find the lowest of the given > array of numbers. The script works fine for various combination of > inputs but fails in a weird way for a particular set of inputs, can > anyone point the mistake in the script and the behavior. > > Script > > x = input ("Enter the numbers separated by space and press ENTER :") > x = x.split(" ") > > def checkmin(arr): > lowest = arr[0] > for count in range(0,len(arr),1): > if arr[count] < lowest : > lowest = arr[count] > else : > pass > print (lowest) > return lowest > > minimum = checkmin(x) > print ("Lowest : {0}".format (minimum)) > > > Weird output is as below. > >================== RESTART: C:\Users\mohan\Desktop\temp.py ================== > Enter the numbers separated by space and press ENTER :5 90 63 82 59 24 > 5 > 5 > 5 > 5 > 5 > 24 > Lowest : 24 Assuming this is homework, here's a hint: Instead of "5 90 63 82 59 24", feed it "2 1111", or "1 099999" or "1 2 3 ." (yes, "."). As a stylistic matter, looping over an array's indices is more cumbersome than looping over the elements of the array ("for x in arr:"), unless you actually need the index for something, which you don't. Also, two of the three arguments you pass to range can be omitted. -- To email me, substitute nowhere->runbox, invalid->com. From alon.najman at gmail.com Sat Sep 1 14:19:13 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Sat, 1 Sep 2018 11:19:13 -0700 (PDT) Subject: how to get a value from CSV specific cell (A7) thanks Message-ID: <2c1abe2c-2ceb-4d20-a849-abded7e825f2@googlegroups.com> how to get a value from CSV specific cell (A7) thanks From george at fischhof.hu Sat Sep 1 14:45:26 2018 From: george at fischhof.hu (George Fischhof) Date: Sat, 1 Sep 2018 20:45:26 +0200 Subject: how to get a value from CSV specific cell (A7) thanks In-Reply-To: <2c1abe2c-2ceb-4d20-a849-abded7e825f2@googlegroups.com> References: <2c1abe2c-2ceb-4d20-a849-abded7e825f2@googlegroups.com> Message-ID: HI, CSV has no cells, but you can use csv module from standard lib https://docs.python.org/3/library/csv.html and you can get 7th data from the first row (as A means the first row) __george__ ezt ?rta (id?pont: 2018. szept. 1., Szo, 20:24): > how to get a value from CSV specific cell (A7) thanks > -- > https://mail.python.org/mailman/listinfo/python-list > From mohan4h at gmail.com Sat Sep 1 21:12:35 2018 From: mohan4h at gmail.com (mohan4h at gmail.com) Date: Sat, 1 Sep 2018 18:12:35 -0700 (PDT) Subject: Help Needed : script weird result. In-Reply-To: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> References: <89e2e06e-5678-4f45-a380-395d9e9da0fb@googlegroups.com> Message-ID: <21970087-5949-4943-ab9b-27124547e33d@googlegroups.com> On Sunday, September 2, 2018 at 1:12:17 AM UTC+8, moh... at gmail.com wrote: > All, > > I m trying to run this small script to find the lowest of the given array of numbers. The script works fine for various combination of inputs but fails in a weird way for a particular set of inputs, can anyone point the mistake in the script and the behavior. > > Script > > x = input ("Enter the numbers separated by space and press ENTER :") > x = x.split(" ") > > def checkmin(arr): > lowest = arr[0] > for count in range(0,len(arr),1): > if arr[count] < lowest : > lowest = arr[count] > else : > pass > print (lowest) > return lowest > > minimum = checkmin(x) > print ("Lowest : {0}".format (minimum)) > > > Weird output is as below. > > ================== RESTART: C:\Users\mohan\Desktop\temp.py ================== > Enter the numbers separated by space and press ENTER :5 90 63 82 59 24 > 5 > 5 > 5 > 5 > 5 > 24 > Lowest : 24 > > Regards > Mohan C Thanks to Duncan, Joel, Peter and Dan. Now I understood what was wrong with the script and i fixed it, Now my scripts executes as expected and also i understand a concept in type casting. As always this group is awesome and responsive, Thanks again guys. Regards Mohan C From __peter__ at web.de Sun Sep 2 03:42:25 2018 From: __peter__ at web.de (Peter Otten) Date: Sun, 02 Sep 2018 09:42:25 +0200 Subject: how to get a value from CSV specific cell (A7) thanks References: <2c1abe2c-2ceb-4d20-a849-abded7e825f2@googlegroups.com> Message-ID: alon.najman at gmail.com wrote: > how to get a value from CSV specific cell (A7) thanks $ cat csv_sheet.py #!/usr/bin/python3 import re import csv import string LOOKUP = {c: i for i, c in enumerate(string.ascii_uppercase, 1)} def a2i(s): """ >>> a2i("A") 0 >>> a2i("Z") 25 >>> a2i("AA") 26 >>> a2i("AZ") 51 >>> a2i("BA") 52 """ sigma = 0 for c in s: sigma *= len(LOOKUP) sigma += LOOKUP[c] return sigma - 1 def offset(s): m = re.match("([A-Z]+)([0-9]+)", s.upper()) if m is None: raise ValueError col, row = m.groups() return a2i(col), int(row) - 1 if __name__ == "__main__": import argparse parser = argparse.ArgumentParser() parser.add_argument("file") parser.add_argument("cells", metavar="cell", nargs="+") args = parser.parse_args() with open(args.file) as f: rows = list(csv.reader(f)) for cell in args.cells: x, y = offset(cell) print(rows[y][x]) $ cat tmp.csv 1,2,3,4,5,6,7,8,9 10,20,30,40,50,60,70,80,90 100,200,300,400,500,600,700,800,900 1000,2000,3000,4000,5000,6000,7000,8000,9000 10000,20000,30000,40000,50000,60000,70000,80000,90000 100000,200000,300000,400000,500000,600000,700000,800000,900000 1000000,2000000,3000000,4000000,5000000,6000000,7000000,8000000,9000000 $ ./csv_sheet.py tmp.csv a7 b2 c3 1000000 20 300 $ python3 -m doctest csv_sheet.py # otherwise untested From random832 at fastmail.com Sun Sep 2 10:12:22 2018 From: random832 at fastmail.com (Random832) Date: Mon, 03 Sep 2018 02:12:22 +1200 Subject: Can't drop files on python scripts in a fresh installation of Windows Message-ID: <3649929437@f38.n261.z1.binkp.net> Python itself runs fine, but when I try to drop a file on a script it just doesn't work. If I try to regsvr32 the shell extension, it says: The module "c:\windows\pyshellext.amd64.dll" failed to load. There was no indication of any problem until this. Apparently it is linked against "VCRUNTIME140.dll", not (or in addition to? peview shows both) the universal CRT. Installing the Visual C++ 2015 redistributable resolved it, but there was no instruction for this. From alon.najman at gmail.com Sun Sep 2 13:07:30 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Sun, 2 Sep 2018 10:07:30 -0700 (PDT) Subject: how to get a value from CSV specific cell (A7) thanks In-Reply-To: <2c1abe2c-2ceb-4d20-a849-abded7e825f2@googlegroups.com> References: <2c1abe2c-2ceb-4d20-a849-abded7e825f2@googlegroups.com> Message-ID: On Saturday, September 1, 2018 at 9:19:29 PM UTC+3, alon.... at gmail.com wrote: > how to get a value from CSV specific cell (A7) thanks thanks all ! From mystirk at gmail.com Sun Sep 2 15:07:10 2018 From: mystirk at gmail.com (Alex Kaye) Date: Mon, 03 Sep 2018 07:07:10 +1200 Subject: Anaconda with Python 3.7 Message-ID: <3643127085@f38.n261.z1.binkp.net> When one downloads Anaconda, doesn't it bring Pyhon with it ? AK On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans wrote: > On 2018-09-03 11:38, gvim wrote: > > Anyone have any idea when Anaconda might ship a version compatible with > > Python 3.7. I sent them 2 emails but no reply. > > > > gvim > > You can install Python 3.7 in a conda environment right now. Most > packages (certainly all the ones I use) appear to be available for > Python 3.7 at least on Windows and Linux already. > > > -- > https://mail.python.org/mailman/listinfo/python-list > From mystirk at gmail.com Sun Sep 2 15:08:34 2018 From: mystirk at gmail.com (Alex Kaye) Date: Mon, 03 Sep 2018 07:08:34 +1200 Subject: Anaconda with Python 3.7 Message-ID: <1220594870@f38.n261.z1.binkp.net> Sorry bad typing. AK On Mon, Sep 3, 2018 at 7:07 AM Alex Kaye wrote: > When one downloads Anaconda, doesn't it > bring Pyhon with it ? > > AK > > On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans wrote: > >> On 2018-09-03 11:38, gvim wrote: >> > Anyone have any idea when Anaconda might ship a version compatible with >> > Python 3.7. I sent them 2 emails but no reply. >> > >> > gvim >> >> You can install Python 3.7 in a conda environment right now. Most >> packages (certainly all the ones I use) appear to be available for >> Python 3.7 at least on Windows and Linux already. >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From python at bdurham.com Sun Sep 2 15:45:32 2018 From: python at bdurham.com (Malcolm Greene) Date: Mon, 03 Sep 2018 07:45:32 +1200 Subject: Cross platform mutex to prevent script running more than instance? Message-ID: <4282084746@f38.n261.z1.binkp.net> Use case: Want to prevent 2+ instances of a script from running ... ideally in a cross platform manner. I've been researching this topic and am surprised how complicated this capability appears to be and how the diverse the solution set is. I've seen solutions ranging from using directories, named temporary files, named sockets/pipes, etc. Is there any consensus on best practice here? Thank you, Malcolm From gvimrc at gmail.com Sun Sep 2 18:38:42 2018 From: gvimrc at gmail.com (gvim) Date: Mon, 03 Sep 2018 10:38:42 +1200 Subject: Anaconda with Python 3.7 Message-ID: <2015613120@f38.n261.z1.binkp.net> Anyone have any idea when Anaconda might ship a version compatible with Python 3.7. I sent them 2 emails but no reply. gvim From tjol at tjol.eu Sun Sep 2 19:18:24 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 03 Sep 2018 11:18:24 +1200 Subject: Error installing libraries Message-ID: <2442963809@f38.n261.z1.binkp.net> On 2018-09-03 09:10, ojas gupta wrote: > error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-to ols > > ---------------------------------------- > Command ""c:\users\ojas gupta\appdata\local\programs\python\python37\python.e xe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\ Local\\Temp\\pip-install-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\OJASGU~1\AppData\Local\Temp\pip-install-1d03ayeg\mysqlclient\ > > > And the link provided to install Visual C++ 14.0 doesn? ?t work . I installed Visual Studio 2017 and C++ Redistributable 2017 but same issue still . mysqlclient binary packages for Windows are available from Christoph Gohlke: https://www.lfd.uci.edu/~gohlke/pythonlibs/ If you use these you won't need a C compiler. As for the C compiler issue, I'd expect installing Visual Studio 2017 to work, but I've only ever used the standalone "build tools" with Python on Windows myself... See: https://wiki.python.org/moin/WindowsCompilers#Compilers_Installation_and_config uration > > It will be extremely appreciated if u help me . Thanks . > From tjol at tjol.eu Sun Sep 2 19:49:36 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 03 Sep 2018 11:49:36 +1200 Subject: Anaconda with Python 3.7 Message-ID: <1822356585@f38.n261.z1.binkp.net> On 2018-09-03 11:38, gvim wrote: > Anyone have any idea when Anaconda might ship a version compatible with > Python 3.7. I sent them 2 emails but no reply. > > gvim You can install Python 3.7 in a conda environment right now. Most packages (certainly all the ones I use) appear to be available for Python 3.7 at least on Windows and Linux already. From darcy at VybeNetworks.com Sun Sep 2 20:15:16 2018 From: darcy at VybeNetworks.com (D'Arcy Cain) Date: Mon, 03 Sep 2018 12:15:16 +1200 Subject: Cross platform mutex to prevent script running more than instance? Message-ID: <2451295911@f38.n261.z1.binkp.net> On 09/03/18 09:45, Malcolm Greene wrote: > Use case: Want to prevent 2+ instances of a script from running ... > ideally in a cross platform manner. I've been researching this topic and > am surprised how complicated this capability appears to be and how the > diverse the solution set is. I've seen solutions ranging from using > directories, named temporary files, named sockets/pipes, etc. Is there > any consensus on best practice here? Here's my simple method which works in pure Python so I guess that makes it cross-platform. Well, as long as it has process IDs anyway. There's a small window between reading the file and writing the new one but for most purposes that should be OK. If you have to worry about those nano-second situations you will need to use one of those more complicated methods. import os, sys def ok2run(lockfile): mypid = os.getpid() try: pid = int(open(lockfile).read()) except FileNotFoundError: pass else: try: os.kill(pid, 0) except OSError: pass else: return False print(mypid, file=open(lockfile, 'w')) return True if not ok2run("/tmp/lockfile"): sys.exit(0) -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:darcy at Vex.Net VoIP: sip:darcy at VybeNetworks.com From ojaskushagra98 at gmail.com Sun Sep 2 20:40:48 2018 From: ojaskushagra98 at gmail.com (ojas gupta) Date: Mon, 03 Sep 2018 12:40:48 +1200 Subject: Error installing libraries Message-ID: <1816685770@f38.n261.z1.binkp.net> I am having trouble with installation of one library ? ?mysqlclient? ? and it keeps on showing the same message (copied below as it is ) . THE MESSAGE : C:\>pip install mysqlclient Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d 1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error Complete output from command "c:\users\ojas gupta\appdata\local\programs\python\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\Local\\Temp\\pip-i nstall-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt --single-version-externally-managed --compile: c:\users\ojas gupta\appdata\local\programs\python\python37\lib\distutils\di st.py:274: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running install running build running build_py creating build creating build\lib.win-amd64-3.7 copying _mysql_exceptions.py -> build\lib.win-amd64-3.7 creating build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\__init__.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\compat.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\connections.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\converters.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\cursors.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\release.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\times.py -> build\lib.win-amd64-3.7\MySQLdb creating build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.7\MySQLdb\constant s copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.7\MySQLdb\constant s copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.7\MySQLdb\constants running build_ext building '_mysql' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools ---------------------------------------- Command ""c:\users\ojas gupta\appdata\local\programs\python\python37\python.exe " -u -c "import setuptools, tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\Lo cal\\Temp\\pip-install-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\OJASGU~1\AppData\Local\Temp\pip-install-1d03ayeg\mysqlclient\ And the link provided to install Visual C++ 14.0 doesn? ?t work . I installed Visual Studio 2017 and C++ Redistributable 2017 but same issue still . It will be extremely appreciated if u help me . Thanks . From tmrsg11 at gmail.com Sun Sep 2 21:49:18 2018 From: tmrsg11 at gmail.com (C W) Date: Mon, 03 Sep 2018 13:49:18 +1200 Subject: Why list.reverse() modifies the list, but name.replace() does not Message-ID: <172316076@f38.n261.z1.binkp.net> Hello all, I am learning the basics of Python. How do I know when a method modifies the original object, when it does not. I have to exmaples: Example 1: > L = [3, 6, 1,4] > L.reverse() > L [4, 1, 6, 3] This changes the original list. Example 2: > name = "John Smith" > name.replace("J", j") > name 'John Smith' This does not change the original string. Why the two examples produce different results? As a beginner, I find this confusing. How do you do it? Thank you! From joel.goldstick at gmail.com Sun Sep 2 22:01:38 2018 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Mon, 03 Sep 2018 14:01:38 +1200 Subject: Why list.reverse() modifies the list, but name.replace() does not Message-ID: <1487271268@f38.n261.z1.binkp.net> On Mon, Sep 3, 2018 at 1:50 PM C W wrote: > > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: > > L = [3, 6, 1,4] > > L.reverse() > > L > [4, 1, 6, 3] > This changes the original list. > > Example 2: > > name = "John Smith" > > name.replace("J", j") > > name > 'John Smith' > This does not change the original string. > > Why the two examples produce different results? As a beginner, I find this > confusing. How do you do it? > > Thank you! > -- > https://mail.python.org/mailman/listinfo/python-list Learn about help. Go to python command line and type help(L) it will show that this method reverses in place. Type help(name) and it will show that this method returns the result, but does not change your list. -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From breamoreboy at gmail.com Sun Sep 2 22:17:10 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Mon, 03 Sep 2018 14:17:10 +1200 Subject: PEP 8001 -- Python Governance Voting Process Message-ID: <1122862614@f38.n261.z1.binkp.net> I believe that this https://www.python.org/dev/peps/pep-8001/ may be of interest. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From fabiofz at gmail.com Sun Sep 2 23:05:18 2018 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Mon, 03 Sep 2018 15:05:18 +1200 Subject: PyDev 6.5.0 released Message-ID: <3879200349@f38.n261.z1.binkp.net> PyDev 6.5.0 Release Highlights - *Debugger* - Debugger is *much* more responsive (fixed bug in reader/writer on the PyDev side). - *breakpoint()* builtin is now supported to add a programmatic breakpoint (on any Python version). - Watch expression no longer giving error if evaluation is empty (patch by glhez). - *Editor* - Code folding of *#region/#endregion* regions (patch by ghbcode). - There's a new action which allows creating local imports from a global import (use *Ctrl+1* on top of global import name). - It's now possible to change the default interpreter through an action (default binding: *Ctrl+Shift+Alt+I*). - The interactive console now has scroll lock (patch by bongibong). About PyDev PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and IronPython development, now also available for Python on Visual Studio Code. It comes with goodies such as code completion, syntax highlighting, syntax analysis, code analysis, refactor, debug, interactive console, etc. It is also available as a standalone through LiClipse with goodies such as multiple cursors, theming and support for many other languages, such as Django Templates, Jinja2, Html, JavaScript, etc. Links: PyDev: http://pydev.org PyDev Blog: http://pydev.blogspot.com PyDev on VSCode: http://pydev.org/vscode LiClipse: http://www.liclipse.com PyVmMonitor - Python Profiler: http://www.pyvmmonitor.com/ Cheers, Fabio Zadrozny From tjol at tjol.eu Mon Sep 3 00:29:30 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 03 Sep 2018 16:29:30 +1200 Subject: Anaconda with Python 3.7 Message-ID: <2712289210@f38.n261.z1.binkp.net> On 2018-09-03 16:07, Alex Kaye wrote: > When one downloads Anaconda, doesn't it > bring Pyhon with it ? It does, but one of the main features is the ability to create additional virtual environments which can use different versions of Python. You can even upgrade these environments to a different Python version, and all the conda-installed (Python) packages will be installed in the new Python version. https://conda.io/docs/user-guide/tasks/manage-environments.html -- Thomas PS: Please always make sure you reply on-list. > > AK > > On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans > wrote: > > On 2018-09-03 11:38, gvim wrote: > > Anyone have any idea when Anaconda might ship a version compatible > with > > Python 3.7. I sent them 2 emails but no reply. > > > > gvim > > You can install Python 3.7 in a conda environment right now. Most > packages (certainly all the ones I use) appear to be available for > Python 3.7 at least on Windows and Linux already. > > > -- > https://mail.python.org/mailman/listinfo/python-list > From random832 at fastmail.com Mon Sep 3 02:12:22 2018 From: random832 at fastmail.com (Random832) Date: Mon, 03 Sep 2018 02:12:22 -0400 Subject: Can't drop files on python scripts in a fresh installation of Windows 10 and Python 3.7 Message-ID: <1535955142.3930848.1494690064.0170B4E1@webmail.messagingengine.com> Python itself runs fine, but when I try to drop a file on a script it just doesn't work. If I try to regsvr32 the shell extension, it says: The module "c:\windows\pyshellext.amd64.dll" failed to load. There was no indication of any problem until this. Apparently it is linked against "VCRUNTIME140.dll", not (or in addition to? peview shows both) the universal CRT. Installing the Visual C++ 2015 redistributable resolved it, but there was no instruction for this. From ojaskushagra98 at gmail.com Mon Sep 3 03:10:49 2018 From: ojaskushagra98 at gmail.com (ojas gupta) Date: Mon, 3 Sep 2018 12:40:49 +0530 Subject: Error installing libraries Message-ID: <5b8cde7e.1c69fb81.d8193.63a9@mx.google.com> I am having trouble with installation of one library ?mysqlclient? and it keeps on showing the same message (copied below as it is ) . THE MESSAGE : C:\>pip install mysqlclient Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error Complete output from command "c:\users\ojas gupta\appdata\local\programs\python\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\Local\\Temp\\pip-install-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt --single-version-externally-managed --compile: c:\users\ojas gupta\appdata\local\programs\python\python37\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running install running build running build_py creating build creating build\lib.win-amd64-3.7 copying _mysql_exceptions.py -> build\lib.win-amd64-3.7 creating build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\__init__.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\compat.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\connections.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\converters.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\cursors.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\release.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\times.py -> build\lib.win-amd64-3.7\MySQLdb creating build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.7\MySQLdb\constants running build_ext building '_mysql' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools ---------------------------------------- Command ""c:\users\ojas gupta\appdata\local\programs\python\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\Local\\Temp\\pip-install-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\OJASGU~1\AppData\Local\Temp\pip-install-1d03ayeg\mysqlclient\ And the link provided to install Visual C++ 14.0 doesn?t work . I installed Visual Studio 2017 and C++ Redistributable 2017 but same issue still . It will be extremely appreciated if u help me . Thanks . From breamoreboy at gmail.com Mon Sep 3 03:21:36 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Mon, 03 Sep 2018 19:21:36 +1200 Subject: Why list.reverse() modifies the list, but name.replace() does not Message-ID: <3688098930@f38.n261.z1.binkp.net> On 03/09/18 18:49, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. Lists are mutable, i.e. can be changed, so it makes sense to do this change in place. > > Example 2: >> name = "John Smith" >> name.replace("J", j") >> name > 'John Smith' > This does not change the original string. Strings are immutable, i.e. cannot be changed, so you have to create a new string. Your call to `replace` will do just that, but as it's not saved `name` remains the same. You could use name = name.replace("J", j") or newname = name.replace("J", j") as you see fit. > > Why the two examples produce different results? As a beginner, I find this > confusing. How do you do it? > > Thank you! > -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From gvimrc at gmail.com Mon Sep 3 05:10:28 2018 From: gvimrc at gmail.com (gvim) Date: Mon, 03 Sep 2018 21:10:28 +1200 Subject: Anaconda with Python 3.7 Message-ID: <499750406@f38.n261.z1.binkp.net> On 03/09/2018 10:49, Thomas Jollans wrote: > On 2018-09-03 11:38, gvim wrote: >> Anyone have any idea when Anaconda might ship a version compatible with >> Python 3.7. I sent them 2 emails but no reply. >> >> gvim > > You can install Python 3.7 in a conda environment right now. Most > packages (certainly all the ones I use) appear to be available for > Python 3.7 at least on Windows and Linux already. > That's not the same as a specific Python 3.7 distribution. Why are they so tight-lipped about it? I mean it's been a couple of months now. Do they usually take so long? gvim From tjol at tjol.eu Mon Sep 3 05:18:24 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 3 Sep 2018 11:18:24 +0200 Subject: Error installing libraries In-Reply-To: <5b8cde7e.1c69fb81.d8193.63a9@mx.google.com> References: <5b8cde7e.1c69fb81.d8193.63a9@mx.google.com> Message-ID: On 2018-09-03 09:10, ojas gupta wrote: > error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools > > ---------------------------------------- > Command ""c:\users\ojas gupta\appdata\local\programs\python\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\Local\\Temp\\pip-install-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\OJASGU~1\AppData\Local\Temp\pip-install-1d03ayeg\mysqlclient\ > > > And the link provided to install Visual C++ 14.0 doesn?t work . I installed Visual Studio 2017 and C++ Redistributable 2017 but same issue still . mysqlclient binary packages for Windows are available from Christoph Gohlke: https://www.lfd.uci.edu/~gohlke/pythonlibs/ If you use these you won't need a C compiler. As for the C compiler issue, I'd expect installing Visual Studio 2017 to work, but I've only ever used the standalone "build tools" with Python on Windows myself... See: https://wiki.python.org/moin/WindowsCompilers#Compilers_Installation_and_configuration > > It will be extremely appreciated if u help me . Thanks . > From gvimrc at gmail.com Mon Sep 3 05:38:42 2018 From: gvimrc at gmail.com (gvim) Date: Mon, 03 Sep 2018 10:38:42 +0100 Subject: Anaconda with Python 3.7 Message-ID: <5B8D0122.1030408@gmail.com> Anyone have any idea when Anaconda might ship a version compatible with Python 3.7. I sent them 2 emails but no reply. gvim From tjol at tjol.eu Mon Sep 3 05:49:37 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 3 Sep 2018 11:49:37 +0200 Subject: Anaconda with Python 3.7 In-Reply-To: <5B8D0122.1030408@gmail.com> References: <5B8D0122.1030408@gmail.com> Message-ID: <9cdbe22f-71ed-07a0-873d-a5fe443075e9@tjol.eu> On 2018-09-03 11:38, gvim wrote: > Anyone have any idea when Anaconda might ship a version compatible with > Python 3.7. I sent them 2 emails but no reply. > > gvim You can install Python 3.7 in a conda environment right now. Most packages (certainly all the ones I use) appear to be available for Python 3.7 at least on Windows and Linux already. From breamoreboy at gmail.com Mon Sep 3 09:17:11 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Mon, 3 Sep 2018 14:17:11 +0100 Subject: PEP 8001 -- Python Governance Voting Process Message-ID: I believe that this https://www.python.org/dev/peps/pep-8001/ may be of interest. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From tmrsg11 at gmail.com Mon Sep 3 09:42:14 2018 From: tmrsg11 at gmail.com (Mike C) Date: Tue, 04 Sep 2018 01:42:14 +1200 Subject: Why list.reverse() modifies the list, but name.replace() does not Message-ID: <1321442848@f38.n261.z1.binkp.net> Yes, I forgot that strings are immutable. I can't change anything in the string. Silly me! Thank you very much, I appreciate it. I guess sometimes it just take an outsider to take you outside the box. And all is answered. :) ________________________________ From: Python-list on behalf of Mark Lawrence Sent: Monday, September 3, 2018 2:21:36 PM To: python-list at python.org Subject: Re: Why list.reverse() modifies the list, but name.replace() does not modify the string? On 03/09/18 18:49, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. Lists are mutable, i.e. can be changed, so it makes sense to do this change in place. > > Example 2: >> name = "John Smith" >> name.replace("J", j") >> name > 'John Smith' > This does not change the original string. Strings are immutable, i.e. cannot be changed, so you have to create a new string. Your call to `replace` will do just that, but as it's not saved `name` remains the same. You could use name = name.replace("J", j") or newname = name.replace("J", j") as you see fit. > > Why the two examples produce different results? As a beginner, I find this > confusing. How do you do it? > > Thank you! > -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list From python at bdurham.com Mon Sep 3 09:45:32 2018 From: python at bdurham.com (Malcolm Greene) Date: Mon, 03 Sep 2018 07:45:32 -0600 Subject: Cross platform mutex to prevent script running more than instance? Message-ID: <1535982332.2956406.1495078752.46D50927@webmail.messagingengine.com> Use case: Want to prevent 2+ instances of a script from running ... ideally in a cross platform manner. I've been researching this topic and am surprised how complicated this capability appears to be and how the diverse the solution set is. I've seen solutions ranging from using directories, named temporary files, named sockets/pipes, etc. Is there any consensus on best practice here? Thank you, Malcolm From mystirk at gmail.com Mon Sep 3 10:07:11 2018 From: mystirk at gmail.com (Alex Kaye) Date: Mon, 3 Sep 2018 07:07:11 -0700 Subject: Anaconda with Python 3.7 In-Reply-To: <9cdbe22f-71ed-07a0-873d-a5fe443075e9@tjol.eu> References: <5B8D0122.1030408@gmail.com> <9cdbe22f-71ed-07a0-873d-a5fe443075e9@tjol.eu> Message-ID: When one downloads Anaconda, doesn't it bring Pyhon with it ? AK On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans wrote: > On 2018-09-03 11:38, gvim wrote: > > Anyone have any idea when Anaconda might ship a version compatible with > > Python 3.7. I sent them 2 emails but no reply. > > > > gvim > > You can install Python 3.7 in a conda environment right now. Most > packages (certainly all the ones I use) appear to be available for > Python 3.7 at least on Windows and Linux already. > > > -- > https://mail.python.org/mailman/listinfo/python-list > From mystirk at gmail.com Mon Sep 3 10:08:34 2018 From: mystirk at gmail.com (Alex Kaye) Date: Mon, 3 Sep 2018 07:08:34 -0700 Subject: Anaconda with Python 3.7 In-Reply-To: References: <5B8D0122.1030408@gmail.com> <9cdbe22f-71ed-07a0-873d-a5fe443075e9@tjol.eu> Message-ID: Sorry bad typing. AK On Mon, Sep 3, 2018 at 7:07 AM Alex Kaye wrote: > When one downloads Anaconda, doesn't it > bring Pyhon with it ? > > AK > > On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans wrote: > >> On 2018-09-03 11:38, gvim wrote: >> > Anyone have any idea when Anaconda might ship a version compatible with >> > Python 3.7. I sent them 2 emails but no reply. >> > >> > gvim >> >> You can install Python 3.7 in a conda environment right now. Most >> packages (certainly all the ones I use) appear to be available for >> Python 3.7 at least on Windows and Linux already. >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From tjol at tjol.eu Mon Sep 3 10:29:31 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 3 Sep 2018 16:29:31 +0200 Subject: Anaconda with Python 3.7 In-Reply-To: References: <5B8D0122.1030408@gmail.com> <9cdbe22f-71ed-07a0-873d-a5fe443075e9@tjol.eu> Message-ID: <71908200-dfa0-1aaf-6ea2-c5194fdc67e6@tjol.eu> On 2018-09-03 16:07, Alex Kaye wrote: > When one downloads Anaconda, doesn't it > bring Pyhon with it ? It does, but one of the main features is the ability to create additional virtual environments which can use different versions of Python. You can even upgrade these environments to a different Python version, and all the conda-installed (Python) packages will be installed in the new Python version. https://conda.io/docs/user-guide/tasks/manage-environments.html -- Thomas PS: Please always make sure you reply on-list. > > AK > > On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans > wrote: > > On 2018-09-03 11:38, gvim wrote: > > Anyone have any idea when Anaconda might ship a version compatible > with > > Python 3.7. I sent them 2 emails but no reply. > > > > gvim > > You can install Python 3.7 in a conda environment right now. Most > packages (certainly all the ones I use) appear to be available for > Python 3.7 at least on Windows and Linux already. > > > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Mon Sep 3 12:08:10 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 04 Sep 2018 04:08:10 +1200 Subject: Why list.reverse() modifies the list, but name.replace() does not Message-ID: <2973097304@f38.n261.z1.binkp.net> On Tue, Sep 4, 2018 at 3:49 AM, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. > > Example 2: >> name = "John Smith" >> name.replace("J", j") >> name > 'John Smith' > This does not change the original string. > > Why the two examples produce different results? As a beginner, I find this > confusing. How do you do it? A very fair question. Firstly, strings are immutable. Once you have a string, nothing can ever change it. Lists, on the other hand, can change (you can append to them, remove elements, etc, etc). So reversing a string in-place is impossible, but it's an option for the list. Secondly, you get a clue from the return values. >>> L = [3, 6, 1,4] >>> L.reverse() >>> L [4, 1, 6, 3] >>> name = "John Smith" >>> name.replace("J", "j") 'john Smith' >>> name 'John Smith' Notice how name.replace() returns the new string, but L.reverse() doesn't return anything? (Technically it returns None, but that's used as a signal meaning "I got nuffin, govna!".) That's a strong clue; if something sounds like it ought to make a change, but it returns None, it's almost certainly changed the object in-place. If you like, you can iterate backwards over the list, rather than actually reversing it: for number in reversed(L): ... And you can use a very convenient, if a little obscure, syntax to create a reversed copy of the list: >>> L [4, 1, 6, 3] >>> L[::-1] [3, 6, 1, 4] (So you can assign that to another name, or whatever.) This is called "slicing" the list, if you want to look it up in the docs. Ultimately, your question comes down to the difference between mutable and immutable types. Definitely something worth learning more about, and definitely worth asking these sorts of questions about. Thanks for asking! :) ChrisA From darcy at VybeNetworks.com Mon Sep 3 12:15:17 2018 From: darcy at VybeNetworks.com (D'Arcy Cain) Date: Mon, 3 Sep 2018 12:15:17 -0400 Subject: Cross platform mutex to prevent script running more than instance? In-Reply-To: <1535982332.2956406.1495078752.46D50927@webmail.messagingengine.com> References: <1535982332.2956406.1495078752.46D50927@webmail.messagingengine.com> Message-ID: On 09/03/18 09:45, Malcolm Greene wrote: > Use case: Want to prevent 2+ instances of a script from running ... > ideally in a cross platform manner. I've been researching this topic and > am surprised how complicated this capability appears to be and how the > diverse the solution set is. I've seen solutions ranging from using > directories, named temporary files, named sockets/pipes, etc. Is there > any consensus on best practice here? Here's my simple method which works in pure Python so I guess that makes it cross-platform. Well, as long as it has process IDs anyway. There's a small window between reading the file and writing the new one but for most purposes that should be OK. If you have to worry about those nano-second situations you will need to use one of those more complicated methods. import os, sys def ok2run(lockfile): mypid = os.getpid() try: pid = int(open(lockfile).read()) except FileNotFoundError: pass else: try: os.kill(pid, 0) except OSError: pass else: return False print(mypid, file=open(lockfile, 'w')) return True if not ok2run("/tmp/lockfile"): sys.exit(0) -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:darcy at Vex.Net VoIP: sip:darcy at VybeNetworks.com From tmrsg11 at gmail.com Mon Sep 3 13:49:18 2018 From: tmrsg11 at gmail.com (C W) Date: Mon, 3 Sep 2018 13:49:18 -0400 Subject: Why list.reverse() modifies the list, but name.replace() does not modify the string? Message-ID: Hello all, I am learning the basics of Python. How do I know when a method modifies the original object, when it does not. I have to exmaples: Example 1: > L = [3, 6, 1,4] > L.reverse() > L [4, 1, 6, 3] This changes the original list. Example 2: > name = "John Smith" > name.replace("J", j") > name 'John Smith' This does not change the original string. Why the two examples produce different results? As a beginner, I find this confusing. How do you do it? Thank you! From joel.goldstick at gmail.com Mon Sep 3 14:01:39 2018 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Mon, 3 Sep 2018 14:01:39 -0400 Subject: Why list.reverse() modifies the list, but name.replace() does not modify the string? In-Reply-To: References: Message-ID: On Mon, Sep 3, 2018 at 1:50 PM C W wrote: > > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: > > L = [3, 6, 1,4] > > L.reverse() > > L > [4, 1, 6, 3] > This changes the original list. > > Example 2: > > name = "John Smith" > > name.replace("J", j") > > name > 'John Smith' > This does not change the original string. > > Why the two examples produce different results? As a beginner, I find this > confusing. How do you do it? > > Thank you! > -- > https://mail.python.org/mailman/listinfo/python-list Learn about help. Go to python command line and type help(L) it will show that this method reverses in place. Type help(name) and it will show that this method returns the result, but does not change your list. -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From fabiofz at gmail.com Mon Sep 3 14:05:19 2018 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Mon, 3 Sep 2018 15:05:19 -0300 Subject: PyDev 6.5.0 released Message-ID: PyDev 6.5.0 Release Highlights - *Debugger* - Debugger is *much* more responsive (fixed bug in reader/writer on the PyDev side). - *breakpoint()* builtin is now supported to add a programmatic breakpoint (on any Python version). - Watch expression no longer giving error if evaluation is empty (patch by glhez). - *Editor* - Code folding of *#region/#endregion* regions (patch by ghbcode). - There's a new action which allows creating local imports from a global import (use *Ctrl+1* on top of global import name). - It's now possible to change the default interpreter through an action (default binding: *Ctrl+Shift+Alt+I*). - The interactive console now has scroll lock (patch by bongibong). About PyDev PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and IronPython development, now also available for Python on Visual Studio Code. It comes with goodies such as code completion, syntax highlighting, syntax analysis, code analysis, refactor, debug, interactive console, etc. It is also available as a standalone through LiClipse with goodies such as multiple cursors, theming and support for many other languages, such as Django Templates, Jinja2, Html, JavaScript, etc. Links: PyDev: http://pydev.org PyDev Blog: http://pydev.blogspot.com PyDev on VSCode: http://pydev.org/vscode LiClipse: http://www.liclipse.com PyVmMonitor - Python Profiler: http://www.pyvmmonitor.com/ Cheers, Fabio Zadrozny From rosuav at gmail.com Mon Sep 3 14:08:11 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 4 Sep 2018 04:08:11 +1000 Subject: Why list.reverse() modifies the list, but name.replace() does not modify the string? In-Reply-To: References: Message-ID: On Tue, Sep 4, 2018 at 3:49 AM, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. > > Example 2: >> name = "John Smith" >> name.replace("J", j") >> name > 'John Smith' > This does not change the original string. > > Why the two examples produce different results? As a beginner, I find this > confusing. How do you do it? A very fair question. Firstly, strings are immutable. Once you have a string, nothing can ever change it. Lists, on the other hand, can change (you can append to them, remove elements, etc, etc). So reversing a string in-place is impossible, but it's an option for the list. Secondly, you get a clue from the return values. >>> L = [3, 6, 1,4] >>> L.reverse() >>> L [4, 1, 6, 3] >>> name = "John Smith" >>> name.replace("J", "j") 'john Smith' >>> name 'John Smith' Notice how name.replace() returns the new string, but L.reverse() doesn't return anything? (Technically it returns None, but that's used as a signal meaning "I got nuffin, govna!".) That's a strong clue; if something sounds like it ought to make a change, but it returns None, it's almost certainly changed the object in-place. If you like, you can iterate backwards over the list, rather than actually reversing it: for number in reversed(L): ... And you can use a very convenient, if a little obscure, syntax to create a reversed copy of the list: >>> L [4, 1, 6, 3] >>> L[::-1] [3, 6, 1, 4] (So you can assign that to another name, or whatever.) This is called "slicing" the list, if you want to look it up in the docs. Ultimately, your question comes down to the difference between mutable and immutable types. Definitely something worth learning more about, and definitely worth asking these sorts of questions about. Thanks for asking! :) ChrisA From breamoreboy at gmail.com Mon Sep 3 14:21:36 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Mon, 3 Sep 2018 19:21:36 +0100 Subject: Why list.reverse() modifies the list, but name.replace() does not modify the string? In-Reply-To: References: Message-ID: On 03/09/18 18:49, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. Lists are mutable, i.e. can be changed, so it makes sense to do this change in place. > > Example 2: >> name = "John Smith" >> name.replace("J", j") >> name > 'John Smith' > This does not change the original string. Strings are immutable, i.e. cannot be changed, so you have to create a new string. Your call to `replace` will do just that, but as it's not saved `name` remains the same. You could use name = name.replace("J", j") or newname = name.replace("J", j") as you see fit. > > Why the two examples produce different results? As a beginner, I find this > confusing. How do you do it? > > Thank you! > -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From cfkaran2 at gmail.com Mon Sep 3 15:57:36 2018 From: cfkaran2 at gmail.com (CFK) Date: Tue, 04 Sep 2018 07:57:36 +1200 Subject: Cross platform mutex to prevent script running more than instance? Message-ID: <990857391@f38.n261.z1.binkp.net> What about using flock()? I don't know if it works on Windows, but it works really well for Unix/Linux systems. I typically create a log file in a known location using any atomic method that doesn't replace/overwrite a file, and flock() it for the duration of the script. Thanks, Cem Karan On Mon, Sep 3, 2018, 11:39 PM Cameron Simpson wrote: > On 03Sep2018 07:45, Malcolm Greene wrote: > >Use case: Want to prevent 2+ instances of a script from running ... > >ideally in a cross platform manner. I've been researching this topic and > >am surprised how complicated this capability appears to be and how the > >diverse the solution set is. I've seen solutions ranging from using > >directories, named temporary files, named sockets/pipes, etc. Is there > >any consensus on best practice here? > > I like os.mkdir of a known directory name. This tends to be atomic and > forbidden when the name already exists, on all UNIX platforms, over remote > filesystems. And, I expect, likewise on Windows. > > All the other modes like opening files O_EXCL etc tend to be platform > specific > and not reliable over network filesystems. > > And pid based approaches don't work cross machine, if that is an issue. > > Cheers, > Cameron Simpson > -- > https://mail.python.org/mailman/listinfo/python-list > From gvimrc at gmail.com Mon Sep 3 16:10:28 2018 From: gvimrc at gmail.com (gvim) Date: Mon, 03 Sep 2018 21:10:28 +0100 Subject: Anaconda with Python 3.7 In-Reply-To: <9cdbe22f-71ed-07a0-873d-a5fe443075e9@tjol.eu> References: <5B8D0122.1030408@gmail.com> <9cdbe22f-71ed-07a0-873d-a5fe443075e9@tjol.eu> Message-ID: <5B8D9534.7070506@gmail.com> On 03/09/2018 10:49, Thomas Jollans wrote: > On 2018-09-03 11:38, gvim wrote: >> Anyone have any idea when Anaconda might ship a version compatible with >> Python 3.7. I sent them 2 emails but no reply. >> >> gvim > > You can install Python 3.7 in a conda environment right now. Most > packages (certainly all the ones I use) appear to be available for > Python 3.7 at least on Windows and Linux already. > That's not the same as a specific Python 3.7 distribution. Why are they so tight-lipped about it? I mean it's been a couple of months now. Do they usually take so long? gvim From alon.najman at gmail.com Mon Sep 3 17:21:14 2018 From: alon.najman at gmail.com (alon najman) Date: Tue, 04 Sep 2018 09:21:14 +1200 Subject: Hi I'm trying to get live data from stock using python , is it possible Message-ID: <801718173@f38.n261.z1.binkp.net> Hi , for example: I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. From alon.najman at gmail.com Mon Sep 3 17:22:02 2018 From: alon.najman at gmail.com (alon najman) Date: Tue, 04 Sep 2018 09:22:02 +1200 Subject: Hi I'm trying to get live data from stock using python , is it poss References: <801718173@f38.n261.z1.binkp.net> Message-ID: <40654038@f38.n261.z1.binkp.net> On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, alon.... at gmail.com wrote: > Hi , > for example: > I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. im using python 2.7 From mfioretti at nexaima.net Mon Sep 3 18:22:38 2018 From: mfioretti at nexaima.net (M. Fioretti) Date: Tue, 04 Sep 2018 10:22:38 +1200 Subject: problem with json.dumps / complexjson.loads in python 3.4 virtualenv Message-ID: <3703730629@f38.n261.z1.binkp.net> Greetings, I have an error in a python application that I installed. I already opened an issue about it on the application page at github, but I would also greatly appreciate any help to (at least) better debug the problem, because I urgently need to use that program. Details: I need to run the python client for the shaarli bookmarks manager, whose home page is https://github.com/shaarli/python-shaarli-client, on a Centos release 7.5 x86_64 server. Since that client requires python >= 3.4, and I do not want to move the whole server to that version, I created a virtualenv following the instructions at https://github.com/shaarli/python-shaarli-client/blob/master/docs/user/installa tion.rst When I try to run it, I get the error messages that I already reported in full at https://github.com/shaarli/python-shaarli-client/issues/33 as far as I can understand after some searching, it **may** be the problem described at https://mcgrattan.org/2017/01/24/ordered-json-in-python-with-requests/ but I honestly don't know enough python, to go further without some help/pointers. TIA, Marco -- http://mfioretti.com From tjol at tjol.eu Mon Sep 3 18:23:52 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 04 Sep 2018 10:23:52 +1200 Subject: Cross platform mutex to prevent script running more than instance? Message-ID: <2371455@f38.n261.z1.binkp.net> On 09/04/2018 05:35 AM, Cameron Simpson wrote: > On 03Sep2018 07:45, Malcolm Greene wrote: >> Use case: Want to prevent 2+ instances of a script from running ... >> ideally in a cross platform manner. I've been researching this topic and >> am surprised how complicated this capability appears to be and how the >> diverse the solution set is. I've seen solutions ranging from using >> directories, named temporary files,? named sockets/pipes, etc. Is there >> any consensus on best practice here? > > I like os.mkdir of a known directory name. This tends to be atomic and > forbidden when the name already exists, on all UNIX platforms, over > remote filesystems. And, I expect, likewise on Windows. The trouble with a simple lock file (or directory) is of course that it can't recover from the program being killed or from program or system crashes without manual intervention. For some use cases that's fine, for others it's a problem. > > All the other modes like opening files O_EXCL etc tend to be platform > specific and not reliable over network filesystems. > > And pid based approaches don't work cross machine, if that is an issue. I think a PID file is the traditional approach for *nix daemons, but as you say, it does have its own drawbacks. -- Thomas From torriem at gmail.com Mon Sep 3 20:06:30 2018 From: torriem at gmail.com (Michael Torrie) Date: Tue, 04 Sep 2018 12:06:30 +1200 Subject: Hi I'm trying to get live data from stock using python , is it Message-ID: <1754826131@f38.n261.z1.binkp.net> On 09/04/2018 10:21 AM, alon.najman at gmail.com wrote: > Hi , > for example: > I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. > Yes it's definitely possible! Hop on Google and do some searches; you're bound to find some articles on the subject, possibly some demo code, and probably some Python libraries to automate the process. Google search terms you'll want to try include things like "python stock price email." From steve+comp.lang.python at pearwood.info Mon Sep 3 20:26:24 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Tue, 04 Sep 2018 12:26:24 +1200 Subject: Any SML coders able to translate this to Python? Message-ID: <3267563839@f38.n261.z1.binkp.net> I have this snippet of SML code which I'm trying to translate to Python: fun isqrt n = if n=0 then 0 else let val r = isqrt (n/4) in if n < (2*r+1)^2 then 2*r else 2*r+1 end I've tried reading up on SML and can't make heads or tails of the "let...in...end" construct. The best I've come up with is this: def isqrt(n): if n == 0: return 0 else: r = isqrt(n/4) if n < (2*r+1)**2: return 2*r else: return 2*r+1 but I don't understand the let ... in part so I'm not sure if I'm doing it right. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From skip.montanaro at gmail.com Mon Sep 3 21:20:38 2018 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Tue, 04 Sep 2018 13:20:38 +1200 Subject: Hi I'm trying to get live data from stock using python , Message-ID: <1124407156@f38.n261.z1.binkp.net> > I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. Try searching pypi.org for "finance", then scroll through the many returned packages. A few show how to get stock data from Yahoo! or Google. Skip From cs at cskk.id.au Mon Sep 3 21:35:58 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 04 Sep 2018 13:35:58 +1200 Subject: Cross platform mutex to prevent script running more than instance? Message-ID: <1552389016@f38.n261.z1.binkp.net> On 03Sep2018 07:45, Malcolm Greene wrote: >Use case: Want to prevent 2+ instances of a script from running ... >ideally in a cross platform manner. I've been researching this topic and >am surprised how complicated this capability appears to be and how the >diverse the solution set is. I've seen solutions ranging from using >directories, named temporary files, named sockets/pipes, etc. Is there >any consensus on best practice here? I like os.mkdir of a known directory name. This tends to be atomic and forbidden when the name already exists, on all UNIX platforms, over remote filesystems. And, I expect, likewise on Windows. All the other modes like opening files O_EXCL etc tend to be platform specific and not reliable over network filesystems. And pid based approaches don't work cross machine, if that is an issue. Cheers, Cameron Simpson From p.f.moore at gmail.com Mon Sep 3 21:38:26 2018 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 04 Sep 2018 13:38:26 +1200 Subject: Any SML coders able to translate this to Python? Message-ID: <3032243757@f38.n261.z1.binkp.net> On Tue, 4 Sep 2018 at 13:31, Steven D'Aprano wrote: > > I have this snippet of SML code which I'm trying to translate to Python: > > fun isqrt n = if n=0 then 0 > else let val r = isqrt (n/4) > in > if n < (2*r+1)^2 then 2*r > else 2*r+1 > end > > > I've tried reading up on SML and can't make heads or tails of the > "let...in...end" construct. > > > The best I've come up with is this: > > def isqrt(n): > if n == 0: > return 0 > else: > r = isqrt(n/4) > if n < (2*r+1)**2: > return 2*r > else: > return 2*r+1 > > but I don't understand the let ... in part so I'm not sure if I'm doing > it right. I've not used SML much, but what you have looks right. let ... in is basically a local binding "let x = 12 in x+2" is saying "the value of x+2 with x set to 12". As I'm sure you realise (but I'll add it here for the sake of any newcomers who read this), the recursive approach is not natural (or efficient) in Python, whereas it's the natural approach in functional languages like SML. In Python an iterative solution would be better. Paul From tmrsg11 at gmail.com Mon Sep 3 21:42:15 2018 From: tmrsg11 at gmail.com (Mike C) Date: Tue, 4 Sep 2018 01:42:15 +0000 Subject: Why list.reverse() modifies the list, but name.replace() does not modify the string? In-Reply-To: References: , Message-ID: Yes, I forgot that strings are immutable. I can't change anything in the string. Silly me! Thank you very much, I appreciate it. I guess sometimes it just take an outsider to take you outside the box. And all is answered. :) ________________________________ From: Python-list on behalf of Mark Lawrence Sent: Monday, September 3, 2018 2:21:36 PM To: python-list at python.org Subject: Re: Why list.reverse() modifies the list, but name.replace() does not modify the string? On 03/09/18 18:49, C W wrote: > Hello all, > > I am learning the basics of Python. How do I know when a method modifies > the original object, when it does not. I have to exmaples: > Example 1: >> L = [3, 6, 1,4] >> L.reverse() >> L > [4, 1, 6, 3] > This changes the original list. Lists are mutable, i.e. can be changed, so it makes sense to do this change in place. > > Example 2: >> name = "John Smith" >> name.replace("J", j") >> name > 'John Smith' > This does not change the original string. Strings are immutable, i.e. cannot be changed, so you have to create a new string. Your call to `replace` will do just that, but as it's not saved `name` remains the same. You could use name = name.replace("J", j") or newname = name.replace("J", j") as you see fit. > > Why the two examples produce different results? As a beginner, I find this > confusing. How do you do it? > > Thank you! > -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list From grant.b.edwards at gmail.com Mon Sep 3 22:13:36 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 04 Sep 2018 14:13:36 +1200 Subject: Verifying the integrity/lineage of a file Message-ID: <114553588@f38.n261.z1.binkp.net> On 2018-09-01, Peter Pearson wrote: > Writing your own crypto software is fraught with peril, and that > includes using existing libraries. Writing your own crypto software isn't a problem, and it can be very educational. Just don't _use_ your own crypto software. Howerver, the set of people who write software without intending to use it is pretty small... -- Grant Edwards grant.b.edwards Yow! ... the MYSTERIANS are at in here with my CORDUROY gmail.com SOAP DISH!! From cs at cskk.id.au Mon Sep 3 23:35:59 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 4 Sep 2018 13:35:59 +1000 Subject: Cross platform mutex to prevent script running more than instance? In-Reply-To: <1535982332.2956406.1495078752.46D50927@webmail.messagingengine.com> References: <1535982332.2956406.1495078752.46D50927@webmail.messagingengine.com> Message-ID: <20180904033559.GA19349@cskk.homeip.net> On 03Sep2018 07:45, Malcolm Greene wrote: >Use case: Want to prevent 2+ instances of a script from running ... >ideally in a cross platform manner. I've been researching this topic and >am surprised how complicated this capability appears to be and how the >diverse the solution set is. I've seen solutions ranging from using >directories, named temporary files, named sockets/pipes, etc. Is there >any consensus on best practice here? I like os.mkdir of a known directory name. This tends to be atomic and forbidden when the name already exists, on all UNIX platforms, over remote filesystems. And, I expect, likewise on Windows. All the other modes like opening files O_EXCL etc tend to be platform specific and not reliable over network filesystems. And pid based approaches don't work cross machine, if that is an issue. Cheers, Cameron Simpson From marko at pacujo.net Tue Sep 4 00:32:28 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 04 Sep 2018 16:32:28 +1200 Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> Message-ID: <3333871854@f38.n261.z1.binkp.net> Steven D'Aprano : > I have this snippet of SML code which I'm trying to translate to Python: > > fun isqrt n = if n=0 then 0 > else let val r = isqrt (n/4) > in > if n < (2*r+1)^2 then 2*r > else 2*r+1 > end > > > I've tried reading up on SML and can't make heads or tails of the > "let...in...end" construct. > > > The best I've come up with is this: > > def isqrt(n): > if n == 0: > return 0 > else: > r = isqrt(n/4) > if n < (2*r+1)**2: > return 2*r > else: > return 2*r+1 > > but I don't understand the let ... in part so I'm not sure if I'm doing > it right. You must make sure "r" doesn't leak outside its syntactic context so: def isqrt(n): if n == 0: return 0 else: def f2398478957(): r = isqrt(n//4) if n < (2*r+1)**2: return 2*r else: return 2*r+1 return f2398478957() (Also use // instead of /: isqrt = integer square root.) Marko From pkpearson at nowhere.invalid Tue Sep 4 01:03:54 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: Tue, 04 Sep 2018 17:03:54 +1200 Subject: Pass a list of values as options to 3 dropdown menus Message-ID: <2721677299@f38.n261.z1.binkp.net> On Sun, 2 Sep 2018 13:40:18 -0700 (PDT), Nick Berg wrote: > how can i be able to store a list of values to drop-down menu and then > grab the value that the user selects? > > ************************************************** > name = month = year = '' > > # populate names, months, years > names.add( '====================' ) > months = ( '==========', '???????????????1?? ... > years = ( '=====', 2010, 2011, 2012, 2 ... > > > pdata = pdata + ''' >


??? ?1?????????1???R ?????????R????????:
>
> > > > > >
>


> ''' % ( url_for( 'seek', name=name, month=month, year=year ), name, name, month, month, year, year ) > ************************************************** I can't tell whether this is an HTML question or a Python question. If you can reduce it to a Python question, perhaps I can help. -- To email me, substitute nowhere->runbox, invalid->com. From shinobi at f153.n1.z21.fsxnet Tue Sep 4 02:21:00 2018 From: shinobi at f153.n1.z21.fsxnet (shinobi) Date: Tue, 04 Sep 2018 18:21:00 +1200 Subject: CURSES WINDOWS Message-ID: <3149779059@f153.n1.z21.fsxnet> Hello All, can anyone please let me know what's the path to port linux python curses program to Windows? Thanks From tjol at tjol.eu Tue Sep 4 02:39:54 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 04 Sep 2018 18:39:54 +1200 Subject: Hi I'm trying to get live data from stock using python , is it Message-ID: <1177710080@f38.n261.z1.binkp.net> On 2018-09-04 18:22, alon.najman at gmail.com wrote: > On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, alon.... at gmail.com wrote: >> Hi , >> for example: >> I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. Of course it's possible. The standard library includes facilities modules for interacting with web services, modules for writing emails, and everything else you'll need. > > im using python 2.7 > Please use Python 3, especially if you're new to Python. Python 2.7 is woefully out of date. From mfioretti at nexaima.net Tue Sep 4 04:22:39 2018 From: mfioretti at nexaima.net (M. Fioretti) Date: Tue, 04 Sep 2018 10:22:39 +0200 Subject: problem with json.dumps / complexjson.loads in python 3.4 virtualenv Message-ID: Greetings, I have an error in a python application that I installed. I already opened an issue about it on the application page at github, but I would also greatly appreciate any help to (at least) better debug the problem, because I urgently need to use that program. Details: I need to run the python client for the shaarli bookmarks manager, whose home page is https://github.com/shaarli/python-shaarli-client, on a Centos release 7.5 x86_64 server. Since that client requires python >= 3.4, and I do not want to move the whole server to that version, I created a virtualenv following the instructions at https://github.com/shaarli/python-shaarli-client/blob/master/docs/user/installation.rst When I try to run it, I get the error messages that I already reported in full at https://github.com/shaarli/python-shaarli-client/issues/33 as far as I can understand after some searching, it **may** be the problem described at https://mcgrattan.org/2017/01/24/ordered-json-in-python-with-requests/ but I honestly don't know enough python, to go further without some help/pointers. TIA, Marco -- http://mfioretti.com From tjol at tjol.eu Tue Sep 4 04:23:52 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 4 Sep 2018 10:23:52 +0200 Subject: Cross platform mutex to prevent script running more than instance? In-Reply-To: <20180904033559.GA19349@cskk.homeip.net> References: <1535982332.2956406.1495078752.46D50927@webmail.messagingengine.com> <20180904033559.GA19349@cskk.homeip.net> Message-ID: <3598ab8b-071d-a8e1-6a3e-539c3a93de30@tjol.eu> On 09/04/2018 05:35 AM, Cameron Simpson wrote: > On 03Sep2018 07:45, Malcolm Greene wrote: >> Use case: Want to prevent 2+ instances of a script from running ... >> ideally in a cross platform manner. I've been researching this topic and >> am surprised how complicated this capability appears to be and how the >> diverse the solution set is. I've seen solutions ranging from using >> directories, named temporary files,? named sockets/pipes, etc. Is there >> any consensus on best practice here? > > I like os.mkdir of a known directory name. This tends to be atomic and > forbidden when the name already exists, on all UNIX platforms, over > remote filesystems. And, I expect, likewise on Windows. The trouble with a simple lock file (or directory) is of course that it can't recover from the program being killed or from program or system crashes without manual intervention. For some use cases that's fine, for others it's a problem. > > All the other modes like opening files O_EXCL etc tend to be platform > specific and not reliable over network filesystems. > > And pid based approaches don't work cross machine, if that is an issue. I think a PID file is the traditional approach for *nix daemons, but as you say, it does have its own drawbacks. -- Thomas From cfkaran2 at gmail.com Tue Sep 4 07:57:37 2018 From: cfkaran2 at gmail.com (CFK) Date: Tue, 4 Sep 2018 07:57:37 -0400 Subject: Cross platform mutex to prevent script running more than instance? In-Reply-To: <20180904033559.GA19349@cskk.homeip.net> References: <1535982332.2956406.1495078752.46D50927@webmail.messagingengine.com> <20180904033559.GA19349@cskk.homeip.net> Message-ID: What about using flock()? I don't know if it works on Windows, but it works really well for Unix/Linux systems. I typically create a log file in a known location using any atomic method that doesn't replace/overwrite a file, and flock() it for the duration of the script. Thanks, Cem Karan On Mon, Sep 3, 2018, 11:39 PM Cameron Simpson wrote: > On 03Sep2018 07:45, Malcolm Greene wrote: > >Use case: Want to prevent 2+ instances of a script from running ... > >ideally in a cross platform manner. I've been researching this topic and > >am surprised how complicated this capability appears to be and how the > >diverse the solution set is. I've seen solutions ranging from using > >directories, named temporary files, named sockets/pipes, etc. Is there > >any consensus on best practice here? > > I like os.mkdir of a known directory name. This tends to be atomic and > forbidden when the name already exists, on all UNIX platforms, over remote > filesystems. And, I expect, likewise on Windows. > > All the other modes like opening files O_EXCL etc tend to be platform > specific > and not reliable over network filesystems. > > And pid based approaches don't work cross machine, if that is an issue. > > Cheers, > Cameron Simpson > -- > https://mail.python.org/mailman/listinfo/python-list > From steve+comp.lang.python at pearwood.info Tue Sep 4 08:26:24 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Tue, 4 Sep 2018 12:26:24 +0000 (UTC) Subject: Any SML coders able to translate this to Python? Message-ID: I have this snippet of SML code which I'm trying to translate to Python: fun isqrt n = if n=0 then 0 else let val r = isqrt (n/4) in if n < (2*r+1)^2 then 2*r else 2*r+1 end I've tried reading up on SML and can't make heads or tails of the "let...in...end" construct. The best I've come up with is this: def isqrt(n): if n == 0: return 0 else: r = isqrt(n/4) if n < (2*r+1)**2: return 2*r else: return 2*r+1 but I don't understand the let ... in part so I'm not sure if I'm doing it right. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From p.f.moore at gmail.com Tue Sep 4 08:38:26 2018 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 4 Sep 2018 13:38:26 +0100 Subject: Any SML coders able to translate this to Python? In-Reply-To: References: Message-ID: On Tue, 4 Sep 2018 at 13:31, Steven D'Aprano wrote: > > I have this snippet of SML code which I'm trying to translate to Python: > > fun isqrt n = if n=0 then 0 > else let val r = isqrt (n/4) > in > if n < (2*r+1)^2 then 2*r > else 2*r+1 > end > > > I've tried reading up on SML and can't make heads or tails of the > "let...in...end" construct. > > > The best I've come up with is this: > > def isqrt(n): > if n == 0: > return 0 > else: > r = isqrt(n/4) > if n < (2*r+1)**2: > return 2*r > else: > return 2*r+1 > > but I don't understand the let ... in part so I'm not sure if I'm doing > it right. I've not used SML much, but what you have looks right. let ... in is basically a local binding "let x = 12 in x+2" is saying "the value of x+2 with x set to 12". As I'm sure you realise (but I'll add it here for the sake of any newcomers who read this), the recursive approach is not natural (or efficient) in Python, whereas it's the natural approach in functional languages like SML. In Python an iterative solution would be better. Paul From marko at pacujo.net Tue Sep 4 09:32:29 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 04 Sep 2018 16:32:29 +0300 Subject: Any SML coders able to translate this to Python? References: Message-ID: <8736uppevm.fsf@elektro.pacujo.net> Steven D'Aprano : > I have this snippet of SML code which I'm trying to translate to Python: > > fun isqrt n = if n=0 then 0 > else let val r = isqrt (n/4) > in > if n < (2*r+1)^2 then 2*r > else 2*r+1 > end > > > I've tried reading up on SML and can't make heads or tails of the > "let...in...end" construct. > > > The best I've come up with is this: > > def isqrt(n): > if n == 0: > return 0 > else: > r = isqrt(n/4) > if n < (2*r+1)**2: > return 2*r > else: > return 2*r+1 > > but I don't understand the let ... in part so I'm not sure if I'm doing > it right. You must make sure "r" doesn't leak outside its syntactic context so: def isqrt(n): if n == 0: return 0 else: def f2398478957(): r = isqrt(n//4) if n < (2*r+1)**2: return 2*r else: return 2*r+1 return f2398478957() (Also use // instead of /: isqrt = integer square root.) Marko From grant.b.edwards at gmail.com Tue Sep 4 10:13:37 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 4 Sep 2018 14:13:37 +0000 (UTC) Subject: Verifying the integrity/lineage of a file References: <1535726212.3464303.1492604560.35EA349A@webmail.messagingengine.com> <1535741518.3530403.1492875656.23ECF436@webmail.messagingengine.com> Message-ID: On 2018-09-01, Peter Pearson wrote: > Writing your own crypto software is fraught with peril, and that > includes using existing libraries. Writing your own crypto software isn't a problem, and it can be very educational. Just don't _use_ your own crypto software. Howerver, the set of people who write software without intending to use it is pretty small... -- Grant Edwards grant.b.edwards Yow! ... the MYSTERIANS are at in here with my CORDUROY gmail.com SOAP DISH!! From tjol at tjol.eu Tue Sep 4 10:28:12 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 4 Sep 2018 16:28:12 +0200 Subject: Any SML coders able to translate this to Python? In-Reply-To: References: Message-ID: On 2018-09-04 14:26, Steven D'Aprano wrote: > I have this snippet of SML code which I'm trying to translate to Python: > > fun isqrt n = if n=0 then 0 > else let val r = isqrt (n/4) > in > if n < (2*r+1)^2 then 2*r > else 2*r+1 > end > > > I've tried reading up on SML and can't make heads or tails of the > "let...in...end" construct. I don't know SML specifically, but my guess would be that let X = Y in A end means "A, evaluated in a local scope where X refers to Y". Reasoning: often (e.g. in JavaScript), 'let' sets something in a local scope, and I think Haskell has a construct like this? It's been a while since I played around with Haskell though... In an as-direct-as-possible Python translation, (lambda X=Y: A)() So, isqrt = (lambda n: 0 if n == 0 else (lambda r=isqrt(n//4): 2*r if n < (2*r+1)**2 else 2*r+1)()) This is obviously the same as your multi-expression function, with the addition of the integer division as suggested by Marko. Cheers, Thomas > > The best I've come up with is this: > > def isqrt(n): > if n == 0: > return 0 > else: > r = isqrt(n/4) > if n < (2*r+1)**2: > return 2*r > else: > return 2*r+1 > > but I don't understand the let ... in part so I'm not sure if I'm doing > it right. > > From tjol at tjol.eu Tue Sep 4 10:32:57 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 4 Sep 2018 16:32:57 +0200 Subject: Verifying the integrity/lineage of a file In-Reply-To: References: <1535726212.3464303.1492604560.35EA349A@webmail.messagingengine.com> <1535741518.3530403.1492875656.23ECF436@webmail.messagingengine.com> Message-ID: On 2018-09-04 16:13, Grant Edwards wrote: > On 2018-09-01, Peter Pearson wrote: > >> Writing your own crypto software is fraught with peril, and that >> includes using existing libraries. > > Writing your own crypto software isn't a problem, and it can be very > educational. > > Just don't _use_ your own crypto software. > > Howerver, the set of people who write software without intending to > use it is pretty small... > Apart from all the people writing specialist software that's not relevant to their profession (seeing as they're programmers, not whatever the target audience is) intending to sell it. From alon.najman at gmail.com Tue Sep 4 12:21:15 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Tue, 4 Sep 2018 09:21:15 -0700 (PDT) Subject: Hi I'm trying to get live data from stock using python , is it possible? Message-ID: Hi , for example: I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. From alon.najman at gmail.com Tue Sep 4 12:22:03 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Tue, 4 Sep 2018 09:22:03 -0700 (PDT) Subject: Hi I'm trying to get live data from stock using python , is it possible? In-Reply-To: References: Message-ID: On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, alon.... at gmail.com wrote: > Hi , > for example: > I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. im using python 2.7 From tjol at tjol.eu Tue Sep 4 12:39:54 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 4 Sep 2018 18:39:54 +0200 Subject: Hi I'm trying to get live data from stock using python , is it possible? In-Reply-To: References: Message-ID: On 2018-09-04 18:22, alon.najman at gmail.com wrote: > On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, alon.... at gmail.com wrote: >> Hi , >> for example: >> I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. Of course it's possible. The standard library includes facilities modules for interacting with web services, modules for writing emails, and everything else you'll need. > > im using python 2.7 > Please use Python 3, especially if you're new to Python. Python 2.7 is woefully out of date. From pkpearson at nowhere.invalid Tue Sep 4 13:03:55 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 4 Sep 2018 17:03:55 GMT Subject: Pass a list of values as options to 3 dropdown menus References: <824e8a9e-6192-47fa-865c-3c5b5cfa7576@googlegroups.com> Message-ID: On Sun, 2 Sep 2018 13:40:18 -0700 (PDT), Nick Berg wrote: > how can i be able to store a list of values to drop-down menu and then > grab the value that the user selects? > > ************************************************** > name = month = year = '' > > # populate names, months, years > names.add( '====================' ) > months = ( '==========', '????????? ... > years = ( '=====', 2010, 2011, 2012, 2 ... > > > pdata = pdata + ''' >


?????????? ?????????:
>
> > > > > >
>


> ''' % ( url_for( 'seek', name=name, month=month, year=year ), name, name, month, month, year, year ) > ************************************************** I can't tell whether this is an HTML question or a Python question. If you can reduce it to a Python question, perhaps I can help. -- To email me, substitute nowhere->runbox, invalid->com. From torriem at gmail.com Tue Sep 4 14:06:31 2018 From: torriem at gmail.com (Michael Torrie) Date: Tue, 4 Sep 2018 12:06:31 -0600 Subject: Hi I'm trying to get live data from stock using python , is it possible? In-Reply-To: References: Message-ID: <906ea2ad-a98e-d83c-db33-1aebf8eab780@gmail.com> On 09/04/2018 10:21 AM, alon.najman at gmail.com wrote: > Hi , > for example: > I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. > Yes it's definitely possible! Hop on Google and do some searches; you're bound to find some articles on the subject, possibly some demo code, and probably some Python libraries to automate the process. Google search terms you'll want to try include things like "python stock price email." From skip.montanaro at gmail.com Tue Sep 4 14:20:38 2018 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Tue, 4 Sep 2018 13:20:38 -0500 Subject: Hi I'm trying to get live data from stock using python , is it possible? In-Reply-To: References: Message-ID: > I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. Try searching pypi.org for "finance", then scroll through the many returned packages. A few show how to get stock data from Yahoo! or Google. Skip From tjreedy at udel.edu Tue Sep 4 15:08:06 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 4 Sep 2018 15:08:06 -0400 Subject: Pass a list of values as options to 3 dropdown menus In-Reply-To: References: <824e8a9e-6192-47fa-865c-3c5b5cfa7576@googlegroups.com> Message-ID: On 9/4/2018 1:03 PM, Peter Pearson wrote: > On Sun, 2 Sep 2018 13:40:18 -0700 (PDT), Nick Berg wrote: >> how can i be able to store a list of values to drop-down menu and then >> grab the value that the user selects? In a python program, use one of the gui packages. Tkinter usually comes with python and can handle this easily with a Listbox or ttk.Combobox. -- Terry Jan Reedy From akkana at shallowsky.com Tue Sep 4 16:47:44 2018 From: akkana at shallowsky.com (Akkana Peck) Date: Tue, 4 Sep 2018 14:47:44 -0600 Subject: Hi I'm trying to get live data from stock using python , is it possible? In-Reply-To: References: Message-ID: <20180904204744.GD1325@shallowsky.com> Skip Montanaro writes: > > I want to know if AAPL is more than value 300 and if it does I want it to send to me mail with gmail :) . thanks for the help.. > > Try searching pypi.org for "finance", then scroll through the many > returned packages. A few show how to get stock data from Yahoo! or > Google. Yahoo and Google both used to offer APIs for financial data, and matplotlib (later moved into a separate module, mpl_finance) used to have a Python wrapper around Yahoo's API; but Yahoo shut their financial API down in mid-2017 and Google followed suit soon after. See: http://www.financial-hacker.com/bye-yahoo-and-thank-you-for-the-fish/ The comments include links to a lot of possible alternatives. Most of them require API keys and some charge a fee. You should probably try several to find out which works best for you, and expect to update your code every year or two as financial quote services seem to come and go. ...Akkana From cs at cskk.id.au Tue Sep 4 18:47:27 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 5 Sep 2018 08:47:27 +1000 Subject: Cross platform mutex to prevent script running more than instance? In-Reply-To: References: Message-ID: <20180904224727.GA17544@cskk.homeip.net> On 04Sep2018 07:57, CFK wrote: >What about using flock()? I don't know if it works on Windows, but it works >really well for Unix/Linux systems. I typically create a log file in a >known location using any atomic method that doesn't replace/overwrite a >file, and flock() it for the duration of the script. Please adopt the inline reply format. Thanks. The good things about flock() and open(O_EXCL) and other variations is that if your program aborts (or its OS aborts) the lock goes away. The downside is that it is less cross platform (including network filesystems). Even ignoring nonUNIX systems I have counter examples: I've got a (pretty dumb) embedded Linux box here whose NFS doesn't support locking. SO flock() goes out the window if the lock uses it. Now, many use cases are single machine or may never meaningfully use a network filesystem. But if I'm writing _library_ code then I, as the author, don't know who will be calling my code in the future. So my inclination is to go for mkdir because it is so portable and robust. The downside with mkdir, and also with pd files really, is that a program or OS abort can leave them lying around. Being persistent objects, some kind of cleanup is needed. For me, that is usually a price I'll accept in order to have a robust works-anywhere tool. Aside: pid files? How do you know they're really stale? PIDs can be reused. On Linux and many UNIXes, PIDs get reused really fast (sequentially allocated); even OpenBSD with its cool unpredictable PIDs has this issue to a lesser degree. What you can get away with depends on your use cases. If you like automatic cleanup, flock and its file descriptor based variants are simple and at least always go away on program exit, whatever the reason. If you can wear some cleanup, mkdir is portable and releiable. (And you can store state information inside the dir!) Given the subject line ("Cross platform mutex to prevent script running more than instance") I'd go for mkdir myself. Cheers, Cameron Simpson >Thanks, >Cem Karan > >On Mon, Sep 3, 2018, 11:39 PM Cameron Simpson wrote: > >> On 03Sep2018 07:45, Malcolm Greene wrote: >> >Use case: Want to prevent 2+ instances of a script from running ... >> >ideally in a cross platform manner. I've been researching this topic and >> >am surprised how complicated this capability appears to be and how the >> >diverse the solution set is. I've seen solutions ranging from using >> >directories, named temporary files, named sockets/pipes, etc. Is there >> >any consensus on best practice here? >> >> I like os.mkdir of a known directory name. This tends to be atomic and >> forbidden when the name already exists, on all UNIX platforms, over remote >> filesystems. And, I expect, likewise on Windows. >> >> All the other modes like opening files O_EXCL etc tend to be platform >> specific >> and not reliable over network filesystems. >> >> And pid based approaches don't work cross machine, if that is an issue. >> >> Cheers, >> Cameron Simpson From greg.ewing at canterbury.ac.nz Tue Sep 4 20:43:26 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 05 Sep 2018 12:43:26 +1200 Subject: Verifying the integrity/lineage of a file In-Reply-To: References: <1535726212.3464303.1492604560.35EA349A@webmail.messagingengine.com> <1535741518.3530403.1492875656.23ECF436@webmail.messagingengine.com> Message-ID: Grant Edwards wrote: > Writing your own crypto software isn't a problem, and it can be very > educational. > > Just don't _use_ your own crypto software. Okay, so find a friend who also likes writing crypto software, and use each other's software. Problem solved. :-) -- Greg From arj.python at gmail.com Tue Sep 4 22:17:07 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 5 Sep 2018 06:17:07 +0400 Subject: Verifying the integrity/lineage of a file In-Reply-To: References: <1535726212.3464303.1492604560.35EA349A@webmail.messagingengine.com> <1535741518.3530403.1492875656.23ECF436@webmail.messagingengine.com> Message-ID: i think he was referring to a wrapper for a crypto-software Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius On Sat, 1 Sep 2018, 21:45 Peter Pearson, wrote: > > Writing your own crypto software is fraught with peril, > From pkpearson at nowhere.invalid Wed Sep 5 00:36:40 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 5 Sep 2018 04:36:40 GMT Subject: Pass a list of values as options to 3 dropdown menus References: <824e8a9e-6192-47fa-865c-3c5b5cfa7576@googlegroups.com> <8f14bf90-2aea-4a87-93de-183c2983906b@googlegroups.com> Message-ID: On Tue, 4 Sep 2018 10:13:07 -0700 (PDT), Nick Berg wrote: [snip] > > May i ask how you managed to send an email with a domain > nowhere.invalid ? I would like to do the same. I don't post by sending email, I post by using a news client (slrn), which interacts with the Usenet system (en.wikipedia.org/wiki/News_client), a largely decentralized news-sharing system that dates from the 1970's (I think) and works through the use of a somewhat casual network of servers that circulate messages among themselves. In contrast (if I read your headers right), you read and post by using Google Groups, a newfangled invention that we fossils from the days of gods and giants consider lame and hostile to efficient organization, and we suspect that prolonged use results in an inability to hoist one's trousers above one's buttocks and a tendency to use interrogatory intonation on declarative sentences. -- To email me, substitute nowhere->runbox, invalid->com. From dieter at handshake.de Wed Sep 5 02:21:22 2018 From: dieter at handshake.de (dieter) Date: Wed, 05 Sep 2018 08:21:22 +0200 Subject: problem with json.dumps / complexjson.loads in python 3.4 virtualenv References: Message-ID: <874lf4ea71.fsf@handshake.de> "M. Fioretti" writes: > I have an error in a python application that I installed. I already > opened an issue about it on the application page at github, but I > would also greatly appreciate any help to (at least) better debug the > problem, because I urgently need to use that program. > > Details: > > I need to run the python client for the shaarli bookmarks manager, > whose home page is https://github.com/shaarli/python-shaarli-client, > on a Centos release 7.5 x86_64 server. Since that client requires > python >= 3.4, and I do not want to move the whole server to that > version, I created a virtualenv following the instructions at > https://github.com/shaarli/python-shaarli-client/blob/master/docs/user/installation.rst > > When I try to run it, I get the error messages that I already reported > in full at > > https://github.com/shaarli/python-shaarli-client/issues/33 Looks like the problem is immediately at the start of the response (--> "ValueError: Expecting value: line 1 column 1 (char 0)"), i.e. the server response is not recognizable as a JSON encoded value. I would debug your "main" program (I would use the "pdb" module ("Python DeBugger")) and instead of calling "response.json()" look at the string value of "response" (likely "json.read()"). This might give you some hint why the server failed to produce an acceptable response. > as far as I can understand after some searching, it **may** be the > problem described at > https://mcgrattan.org/2017/01/24/ordered-json-in-python-with-requests/ It is very unlikely that this is related. From dieter at handshake.de Wed Sep 5 02:23:50 2018 From: dieter at handshake.de (dieter) Date: Wed, 05 Sep 2018 08:23:50 +0200 Subject: Error installing libraries References: <5b8cde7e.1c69fb81.d8193.63a9@mx.google.com> Message-ID: <87zhwwcvih.fsf@handshake.de> Gilmeh Serda writes: > On Mon, 03 Sep 2018 12:40:49 +0530, ojas gupta wrote: > >> error: Microsoft Visual C++ 14.0 is required. > > Wonder why it doesn't work? At least, the error message is clear: the process needs "Microsoft Visual C++ 14.0". It is installed on your computer? From as at sci.fi Wed Sep 5 02:59:20 2018 From: as at sci.fi (Anssi Saari) Date: Wed, 05 Sep 2018 09:59:20 +0300 Subject: CURSES WINDOWS References: <3149779059@f153.n1.z21.fsxnet> Message-ID: shinobi at f153.n1.z21.fsxnet (shinobi) writes: > Hello All, > > can anyone please let me know what's the path to port linux python curses > program to Windows? Is there really anything that needs to be done? At least a simple hello world python curses program runs on Windows and Linux with no changes. From dotancohen at gmail.com Wed Sep 5 03:49:25 2018 From: dotancohen at gmail.com (Dotan Cohen) Date: Wed, 5 Sep 2018 10:49:25 +0300 Subject: CURSES WINDOWS In-Reply-To: <3149779059@f153.n1.z21.fsxnet> References: <3149779059@f153.n1.z21.fsxnet> Message-ID: Your subject line will sure draw attention to the topic! On Tue, Sep 4, 2018 at 8:33 PM shinobi wrote: > > Hello All, > > can anyone please let me know what's the path to port linux python curses > program to Windows? > > Thanks > > -- > https://mail.python.org/mailman/listinfo/python-list -- Dotan Cohen http://gibberish.co.il http://what-is-what.com From abhi.darkness at gmail.com Wed Sep 5 07:10:43 2018 From: abhi.darkness at gmail.com (Abhiram R) Date: Wed, 5 Sep 2018 16:40:43 +0530 Subject: CURSES WINDOWS In-Reply-To: References: <3149779059@f153.n1.z21.fsxnet> Message-ID: And here I thought this was a rant :D On Tue, Sep 4, 2018 at 8:33 PM shinobi wrote: > > > > Hello All, > > > > can anyone please let me know what's the path to port linux python curses > > program to Windows? > > > > Thanks > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > -- Abhiram R abhiramr.github.io From fabiofz at gmail.com Wed Sep 5 11:30:29 2018 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 5 Sep 2018 12:30:29 -0300 Subject: How to drop six support and go to Python 3 only? Message-ID: My scenario is having an app which was on Py 2, ported to Python 2 and 3 (using six) and will become Python 3 only in a few months. So, my question is: when Python 2 is no longer needed, is there some tool which helps removing the six compatibility layer (as well as the if six.PY2/six.PY3 checks) so that the codebase becomes pythonic again? Thanks, Fabio From cspealma at redhat.com Wed Sep 5 16:06:48 2018 From: cspealma at redhat.com (Calvin Spealman) Date: Wed, 5 Sep 2018 16:06:48 -0400 Subject: Hi I'm trying to get live data from stock using python , is it poss In-Reply-To: <40654038@f38.n261.z1.binkp.net> References: <801718173@f38.n261.z1.binkp.net> <40654038@f38.n261.z1.binkp.net> Message-ID: Please don't keep spamming this list with the same question, while you have not responded to any of the advice you've already been given. If you have specific trouble with any of that advice and need further help, please give details and ask new questions! Good luck. On Wed, Sep 5, 2018 at 4:02 PM alon najman wrote: > On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, alon.... at gmail.com > wrote: > > Hi , > > for example: > > I want to know if AAPL is more than value 300 and if it does I want it to > send to me mail with gmail :) . thanks for the help.. > > im using python 2.7 > > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Wed Sep 5 16:30:01 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 6 Sep 2018 06:30:01 +1000 Subject: Hi I'm trying to get live data from stock using python , is it poss In-Reply-To: References: <801718173@f38.n261.z1.binkp.net> <40654038@f38.n261.z1.binkp.net> Message-ID: On Thu, Sep 6, 2018 at 6:06 AM, Calvin Spealman wrote: > Please don't keep spamming this list with the same question, while you have > not responded to any of the advice you've already been given. > > If you have specific trouble with any of that advice and need further help, > please give details and ask new questions! > I don't think this was spamming the list with the same question; a glitch somewhere in a netnews server appears to be re-posting some old posts. ChrisA From pacqa100 at yahoo.com.au Wed Sep 5 17:46:45 2018 From: pacqa100 at yahoo.com.au (Peter) Date: Thu, 6 Sep 2018 07:46:45 +1000 Subject: CURSES WINDOWS In-Reply-To: References: <3149779059@f153.n1.z21.fsxnet> Message-ID: <2e92f6c3-bc9e-fe23-f1ac-ea840b2abc4d@yahoo.com.au> I get this: > C:\Users\Me> py > Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 > bit (Inte > l)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import curses > Traceback (most recent call last): > ? File "", line 1, in > ? File "C:\Program Files (x86)\Python36-32\lib\curses\__init__.py", > line 13, in > > ??? from _curses import * > ModuleNotFoundError: No module named '_curses' > >>> I get the same on py 2.7 On 5/09/2018 4:59 PM, Anssi Saari wrote: > shinobi at f153.n1.z21.fsxnet (shinobi) writes: > >> Hello All, >> >> can anyone please let me know what's the path to port linux python curses >> program to Windows? > Is there really anything that needs to be done? At least a simple hello > world python curses program runs on Windows and Linux with no changes. > > From m.dartiailh at gmail.com Wed Sep 5 21:07:40 2018 From: m.dartiailh at gmail.com (Matthieu Dartiailh) Date: Wed, 5 Sep 2018 21:07:40 -0400 Subject: Calling an unbound method in C using the Public API In-Reply-To: References: <3DE6586F-3022-4946-8FE7-112642EEC921@gmail.com> Message-ID: Thanks Serhiy. This does come with a performance penalty (in particular for function taking keyword arguments) but this is to be expected. Also the PyList_Insert solution does not sadly work for all the methods that I need to wrap. Best Matthieu > On Aug 30, 2018, at 11:09 AM, Serhiy Storchaka wrote: > > 29.08.18 17:33, Matthieu Dartiailh ????: >> I tried to look at the public C API for a way to call an unbound method with a minimal cost (in term of speed and memory). It seems to me, but please correct me if I am wrong, that one cannot call a MethodDef using only the public API. To use the public C API, one has to use PyCFunction_Call (or a variant) that expect a PyCFunctionObject which binds a the MethodDef to an instance. In my case, to avoid creating a temporary PyCFunctionObject each time I call list.insert on my custom subclass instance, I have to store that PyCFunctionObject for each instance. But this means storing 7 PyCFunctionObject per instance (one for each method of list I need to wrap). So I can either use the public API and increase the memory footprint or slow down the code by creating PyCFunctionObject for each call >> , or use large amount of the private API. >> Am I missing something ? > > In general, you need to cache the unbound method object, and call it with self as the first argument. > > list_insert = PyObject_GetAttrString((PyObject *)&PyList_Type, "insert"); > ... > res = PyObject_CallFunctionObjArgs(list_insert, self, index, value, NULL); > > But in the particular case of the insert method it will be easier and more efficient to use PyList_Insert(). > > -- > https://mail.python.org/mailman/listinfo/python-list From marko at pacujo.net Thu Sep 6 00:29:32 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 06 Sep 2018 07:29:32 +0300 Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> Message-ID: <87ftyn2qqb.fsf@elektro.pacujo.net> Marko Rauhamaa (Marko Rauhamaa): > Steven D'Aprano : >> I have this snippet of SML code which I'm trying to translate to Python: >> >> fun isqrt n = if n=0 then 0 >> else let val r = isqrt (n/4) >> in >> if n < (2*r+1)^2 then 2*r >> else 2*r+1 >> end > [...] > You must make sure "r" doesn't leak outside its syntactic context so: > > def isqrt(n): > if n == 0: > return 0 > else: > def f2398478957(): > r = isqrt(n//4) > if n < (2*r+1)**2: > return 2*r > else: > return 2*r+1 > return f2398478957() Actually, this is a more direct translation: def isqrt(n): if n == 0: return 0 else: def f2398478957(r): if n < (2*r+1)**2: return 2*r else: return 2*r+1 return f2398478957(isqrt(n//4)) Marko From mfioretti at nexaima.net Thu Sep 6 02:15:22 2018 From: mfioretti at nexaima.net (M. Fioretti) Date: Thu, 06 Sep 2018 08:15:22 +0200 Subject: [SOLVED]: problem with json.dumps / complexjson.loads in python 3.4 virtualenv In-Reply-To: <874lf4ea71.fsf@handshake.de> References: <874lf4ea71.fsf@handshake.de> Message-ID: <64b99cb72a1f924a5988213b7d3bfda2@nexaima.net> On 2018-09-05 08:21, dieter wrote: > "M. Fioretti" writes: >> I have an error in a python application that I installed... >> ... https://github.com/shaarli/python-shaarli-client/issues/33 > ... > Looks like the problem is immediately at the start of the response > (--> "ValueError: Expecting value: line 1 column 1 (char 0)"), > i.e. the server response is not recognizable as a JSON encoded value. indeed, it turned out that the problem was a misconfiguration of the server that prevented it from sending correct answers when contacted by that python application. Thanks for helping me to look in the right direction. Marco -- http://mfioretti.com From rosuav at gmail.com Thu Sep 6 03:27:18 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 6 Sep 2018 17:27:18 +1000 Subject: Any SML coders able to translate this to Python? In-Reply-To: <87ftyn2qqb.fsf@elektro.pacujo.net> References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> Message-ID: On Thu, Sep 6, 2018 at 2:29 PM, Marko Rauhamaa wrote: > Marko Rauhamaa (Marko Rauhamaa): >> Steven D'Aprano : >>> I have this snippet of SML code which I'm trying to translate to Python: >>> >>> fun isqrt n = if n=0 then 0 >>> else let val r = isqrt (n/4) >>> in >>> if n < (2*r+1)^2 then 2*r >>> else 2*r+1 >>> end >> [...] >> You must make sure "r" doesn't leak outside its syntactic context so: >> >> def isqrt(n): >> if n == 0: >> return 0 >> else: >> def f2398478957(): >> r = isqrt(n//4) >> if n < (2*r+1)**2: >> return 2*r >> else: >> return 2*r+1 >> return f2398478957() > > Actually, this is a more direct translation: > > def isqrt(n): > if n == 0: > return 0 > else: > def f2398478957(r): > if n < (2*r+1)**2: > return 2*r > else: > return 2*r+1 > return f2398478957(isqrt(n//4)) > I don't understand why you created that nested function instead of something simple like renaming the variable. Is there a difference here? ChrisA From marko at pacujo.net Thu Sep 6 04:44:14 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 06 Sep 2018 11:44:14 +0300 Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> Message-ID: <87r2i7nhgh.fsf@elektro.pacujo.net> Chris Angelico : > On Thu, Sep 6, 2018 at 2:29 PM, Marko Rauhamaa wrote: >> Marko Rauhamaa (Marko Rauhamaa): >>> Steven D'Aprano : >>>> I have this snippet of SML code which I'm trying to translate to Python: >>>> >>>> fun isqrt n = if n=0 then 0 >>>> else let val r = isqrt (n/4) >>>> in >>>> if n < (2*r+1)^2 then 2*r >>>> else 2*r+1 >>>> end >>> [...] >>> You must make sure "r" doesn't leak outside its syntactic context so: >>> >>> def isqrt(n): >>> if n == 0: >>> return 0 >>> else: >>> def f2398478957(): >>> r = isqrt(n//4) >>> if n < (2*r+1)**2: >>> return 2*r >>> else: >>> return 2*r+1 >>> return f2398478957() >> >> Actually, this is a more direct translation: >> >> def isqrt(n): >> if n == 0: >> return 0 >> else: >> def f2398478957(r): >> if n < (2*r+1)**2: >> return 2*r >> else: >> return 2*r+1 >> return f2398478957(isqrt(n//4)) >> > > I don't understand why you created that nested function instead of > something simple like renaming the variable. Is there a difference > here? Yes, in understanding the semantics of "let." "let" is used to introduce local bindings in some functional programming languages. I must admit I'm not fully versed in ML but it looks like the analogue in Lisp variants. This is how the above function would be written in Scheme: (define (isqrt n) (if (= n 0) 0 (let ((r (isqrt (quotient n 4)))) (if (< n (expt (1+ (* 2 r)) 2)) (* 2 r) (1+ (* 2 r)))))) Now, Lisp's "let" can be implemented/defined using "lambda": (let ((X A) (Y B) ...) . BODY) => ((lambda (X Y ...) . BODY) A B ...) which gives us: (define (isqrt n) (if (= n 0) 0 ((lambda (r) (if (< n (expt (1+ (* 2 r)) 2)) (* 2 r) (1+ (* 2 r)))) (isqrt (quotient n 4))))) Python does have a limited form of "lambda" and even a conditional expression so--as others have mentioned--this particular function could be translated pretty directly into Python using its lambda. More generally and idiomatically, though, Python's functions are named. So that explains the version I give above. Marko From rosuav at gmail.com Thu Sep 6 04:50:12 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 6 Sep 2018 18:50:12 +1000 Subject: Any SML coders able to translate this to Python? In-Reply-To: <87r2i7nhgh.fsf@elektro.pacujo.net> References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> Message-ID: On Thu, Sep 6, 2018 at 6:44 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Thu, Sep 6, 2018 at 2:29 PM, Marko Rauhamaa wrote: >>> Marko Rauhamaa (Marko Rauhamaa): >>>> Steven D'Aprano : >>>>> I have this snippet of SML code which I'm trying to translate to Python: >>>>> >>>>> fun isqrt n = if n=0 then 0 >>>>> else let val r = isqrt (n/4) >>>>> in >>>>> if n < (2*r+1)^2 then 2*r >>>>> else 2*r+1 >>>>> end >>>> [...] >>>> You must make sure "r" doesn't leak outside its syntactic context so: >>>> >>>> def isqrt(n): >>>> if n == 0: >>>> return 0 >>>> else: >>>> def f2398478957(): >>>> r = isqrt(n//4) >>>> if n < (2*r+1)**2: >>>> return 2*r >>>> else: >>>> return 2*r+1 >>>> return f2398478957() >>> >>> Actually, this is a more direct translation: >>> >>> def isqrt(n): >>> if n == 0: >>> return 0 >>> else: >>> def f2398478957(r): >>> if n < (2*r+1)**2: >>> return 2*r >>> else: >>> return 2*r+1 >>> return f2398478957(isqrt(n//4)) >>> >> >> I don't understand why you created that nested function instead of >> something simple like renaming the variable. Is there a difference >> here? > > Yes, in understanding the semantics of "let." > > "let" is used to introduce local bindings in some functional programming > languages. I must admit I'm not fully versed in ML but it looks like the > analogue in Lisp variants. This is how the above function would be > written in Scheme: > > (define (isqrt n) > (if (= n 0) > 0 > (let ((r (isqrt (quotient n 4)))) > (if (< n (expt (1+ (* 2 r)) 2)) > (* 2 r) > (1+ (* 2 r)))))) > > Now, Lisp's "let" can be implemented/defined using "lambda": > > (let ((X A) (Y B) ...) . BODY) > > => > > ((lambda (X Y ...) . BODY) A B ...) > > which gives us: > > (define (isqrt n) > (if (= n 0) > 0 > ((lambda (r) > (if (< n (expt (1+ (* 2 r)) 2)) > (* 2 r) > (1+ (* 2 r)))) > (isqrt (quotient n 4))))) > > Python does have a limited form of "lambda" and even a conditional > expression so--as others have mentioned--this particular function could > be translated pretty directly into Python using its lambda. > > More generally and idiomatically, though, Python's functions are named. > So that explains the version I give above. And even more idiomatically, Python doesn't require a new scope just for a new variable. So a much more idiomatic translation would be to simply ensure that the inner variable can't collide, and then ignore the function boundary. And I'm not sure if there even is a name collision. What's the issue with scoping at all here? What's the inner function actually achieving? ChrisA From marko at pacujo.net Thu Sep 6 05:15:57 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 06 Sep 2018 12:15:57 +0300 Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> Message-ID: <87musvnfzm.fsf@elektro.pacujo.net> Chris Angelico : > On Thu, Sep 6, 2018 at 6:44 PM, Marko Rauhamaa wrote: > And even more idiomatically, Python doesn't require a new scope just > for a new variable. So a much more idiomatic translation would be to > simply ensure that the inner variable can't collide, and then ignore > the function boundary. And I'm not sure if there even is a name > collision. What's the issue with scoping at all here? What's the inner > function actually achieving? We can debate what the inner function is achieving. The main point is that functional languages create an inner function for each "let" statement. Steve was wondering what "let" meant, and the Python code--I hope--helped illustrate it. Typical Scheme code is riddled with inner functions. Local variables? An inner function. A loop? An inner function. Exception handling? An inner function. Scheme can also be written procedurally through macros, but those macros generate inner functions. Marko From antoon.pardon at vub.be Thu Sep 6 05:22:52 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Thu, 6 Sep 2018 11:22:52 +0200 Subject: Any SML coders able to translate this to Python? In-Reply-To: References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> Message-ID: <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> On 06-09-18 10:50, Chris Angelico wrote: > On Thu, Sep 6, 2018 at 6:44 PM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> On Thu, Sep 6, 2018 at 2:29 PM, Marko Rauhamaa wrote: >>>> Marko Rauhamaa (Marko Rauhamaa): >>>>> Steven D'Aprano : >>>>>> I have this snippet of SML code which I'm trying to translate to Python: >>>>>> >>>>>> fun isqrt n = if n=0 then 0 >>>>>> else let val r = isqrt (n/4) >>>>>> in >>>>>> if n < (2*r+1)^2 then 2*r >>>>>> else 2*r+1 >>>>>> end >>>>> [...] >>>>> You must make sure "r" doesn't leak outside its syntactic context so: >>>>> >>>>> def isqrt(n): >>>>> if n == 0: >>>>> return 0 >>>>> else: >>>>> def f2398478957(): >>>>> r = isqrt(n//4) >>>>> if n < (2*r+1)**2: >>>>> return 2*r >>>>> else: >>>>> return 2*r+1 >>>>> return f2398478957() >>>> Actually, this is a more direct translation: >>>> >>>> def isqrt(n): >>>> if n == 0: >>>> return 0 >>>> else: >>>> def f2398478957(r): >>>> if n < (2*r+1)**2: >>>> return 2*r >>>> else: >>>> return 2*r+1 >>>> return f2398478957(isqrt(n//4)) >>>> >>> I don't understand why you created that nested function instead of >>> something simple like renaming the variable. Is there a difference >>> here? >> Yes, in understanding the semantics of "let." >> >> "let" is used to introduce local bindings in some functional programming >> languages. I must admit I'm not fully versed in ML but it looks like the >> analogue in Lisp variants. This is how the above function would be >> written in Scheme: >> >> (define (isqrt n) >> (if (= n 0) >> 0 >> (let ((r (isqrt (quotient n 4)))) >> (if (< n (expt (1+ (* 2 r)) 2)) >> (* 2 r) >> (1+ (* 2 r)))))) >> >> Now, Lisp's "let" can be implemented/defined using "lambda": >> >> (let ((X A) (Y B) ...) . BODY) >> >> => >> >> ((lambda (X Y ...) . BODY) A B ...) >> >> which gives us: >> >> (define (isqrt n) >> (if (= n 0) >> 0 >> ((lambda (r) >> (if (< n (expt (1+ (* 2 r)) 2)) >> (* 2 r) >> (1+ (* 2 r)))) >> (isqrt (quotient n 4))))) >> >> Python does have a limited form of "lambda" and even a conditional >> expression so--as others have mentioned--this particular function could >> be translated pretty directly into Python using its lambda. >> >> More generally and idiomatically, though, Python's functions are named. >> So that explains the version I give above. > And even more idiomatically, Python doesn't require a new scope just > for a new variable. You may have overlooked where Marko wrote: Actually, this is a more *direct* translation -- Antoon. From rosuav at gmail.com Thu Sep 6 05:31:06 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 6 Sep 2018 19:31:06 +1000 Subject: Any SML coders able to translate this to Python? In-Reply-To: <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> Message-ID: On Thu, Sep 6, 2018 at 7:22 PM, Antoon Pardon wrote: > On 06-09-18 10:50, Chris Angelico wrote: >> On Thu, Sep 6, 2018 at 6:44 PM, Marko Rauhamaa wrote: >>> Chris Angelico : >>> >>>> On Thu, Sep 6, 2018 at 2:29 PM, Marko Rauhamaa wrote: >>>>> Marko Rauhamaa (Marko Rauhamaa): >>>>>> Steven D'Aprano : >>>>>>> I have this snippet of SML code which I'm trying to translate to Python: >>>>>>> >>>>>>> fun isqrt n = if n=0 then 0 >>>>>>> else let val r = isqrt (n/4) >>>>>>> in >>>>>>> if n < (2*r+1)^2 then 2*r >>>>>>> else 2*r+1 >>>>>>> end >>>>>> [...] >>>>>> You must make sure "r" doesn't leak outside its syntactic context so: >>>>>> >>>>>> def isqrt(n): >>>>>> if n == 0: >>>>>> return 0 >>>>>> else: >>>>>> def f2398478957(): >>>>>> r = isqrt(n//4) >>>>>> if n < (2*r+1)**2: >>>>>> return 2*r >>>>>> else: >>>>>> return 2*r+1 >>>>>> return f2398478957() >>>>> Actually, this is a more direct translation: >>>>> >>>>> def isqrt(n): >>>>> if n == 0: >>>>> return 0 >>>>> else: >>>>> def f2398478957(r): >>>>> if n < (2*r+1)**2: >>>>> return 2*r >>>>> else: >>>>> return 2*r+1 >>>>> return f2398478957(isqrt(n//4)) >>>>> >>>> I don't understand why you created that nested function instead of >>>> something simple like renaming the variable. Is there a difference >>>> here? >>> Yes, in understanding the semantics of "let." >>> >>> "let" is used to introduce local bindings in some functional programming >>> languages. I must admit I'm not fully versed in ML but it looks like the >>> analogue in Lisp variants. This is how the above function would be >>> written in Scheme: >>> >>> (define (isqrt n) >>> (if (= n 0) >>> 0 >>> (let ((r (isqrt (quotient n 4)))) >>> (if (< n (expt (1+ (* 2 r)) 2)) >>> (* 2 r) >>> (1+ (* 2 r)))))) >>> >>> Now, Lisp's "let" can be implemented/defined using "lambda": >>> >>> (let ((X A) (Y B) ...) . BODY) >>> >>> => >>> >>> ((lambda (X Y ...) . BODY) A B ...) >>> >>> which gives us: >>> >>> (define (isqrt n) >>> (if (= n 0) >>> 0 >>> ((lambda (r) >>> (if (< n (expt (1+ (* 2 r)) 2)) >>> (* 2 r) >>> (1+ (* 2 r)))) >>> (isqrt (quotient n 4))))) >>> >>> Python does have a limited form of "lambda" and even a conditional >>> expression so--as others have mentioned--this particular function could >>> be translated pretty directly into Python using its lambda. >>> >>> More generally and idiomatically, though, Python's functions are named. >>> So that explains the version I give above. >> And even more idiomatically, Python doesn't require a new scope just >> for a new variable. > > You may have overlooked where Marko wrote: > Actually, this is a more *direct* translation That was *after* stating this: > You must make sure "r" doesn't leak outside its syntactic context so: Why "must"? The request was to translate this into Python, not to slavishly imitate every possible semantic difference even if it won't actually affect behaviour. If there were some way in which the name actually HAD to be kept scoped in, then sure - maybe a name collision or something - but I can't see that here. So by insisting that the translation maintain an unnecessary inner function, Marko is distracting from a logical and semantic translation of the behaviour of the function. Unless I'm missing something, and there actually IS a good reason for the inner function, other than "well, that's how it works in the source language". ChrisA From jfong at ms4.hinet.net Thu Sep 6 05:38:13 2018 From: jfong at ms4.hinet.net (Jach Fong) Date: Thu, 6 Sep 2018 17:38:13 +0800 Subject: Debug script under pdb, how to avoid a bunch of errors caused by the exit()? Message-ID: <68c6a650-9515-078a-a009-8092511e6001@ms4.hinet.net> Here the script file, test0.py: -------------------------- password = 'bad' if password == 'bad': print('bad password') exit() else: print('good password') print('something else to do') -------------------- When running it under Python3.4 Windows Vista, no problem at all. D:\Works\Python>py test0.py bad password But if debug it under pdb: D:\Works\Python>py -m pdb test0.py > d:\works\python\test0.py(1)() -> password = 'bad' (Pdb) tbreak 3 Breakpoint 1 at d:\works\python\test0.py:3 (Pdb) cont Deleted breakpoint 1 at d:\works\python\test0.py:3 > d:\works\python\test0.py(3)() -> print('bad password') (Pdb) cont bad password The program exited via sys.exit(). Exit status: None > d:\works\python\test0.py(1)() -> password = 'bad' (Pdb) Traceback (most recent call last): File "C:\Python34\lib\pdb.py", line 1661, in main pdb._runscript(mainpyfile) File "C:\Python34\lib\pdb.py", line 1542, in _runscript self.run(statement) File "C:\Python34\lib\bdb.py", line 431, in run exec(cmd, globals, locals) File "", line 1, in File "d:\works\python\test0.py", line 1, in password = 'bad' File "d:\works\python\test0.py", line 1, in password = 'bad' File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch return self.dispatch_line(frame) File "C:\Python34\lib\bdb.py", line 66, in dispatch_line self.user_line(frame) File "C:\Python34\lib\pdb.py", line 259, in user_line self.interaction(frame, None) File "C:\Python34\lib\pdb.py", line 346, in interaction self._cmdloop() File "C:\Python34\lib\pdb.py", line 319, in _cmdloop self.cmdloop() File "C:\Python34\lib\cmd.py", line 126, in cmdloop line = input(self.prompt) ValueError: I/O operation on closed file. Uncaught exception. Entering post mortem debugging Running 'cont' or 'step' will restart the program > c:\python34\lib\cmd.py(126)cmdloop() -> line = input(self.prompt) (Pdb) Traceback (most recent call last): File "C:\Python34\lib\pdb.py", line 1661, in main pdb._runscript(mainpyfile) File "C:\Python34\lib\pdb.py", line 1542, in _runscript self.run(statement) File "C:\Python34\lib\bdb.py", line 431, in run exec(cmd, globals, locals) File "", line 1, in File "d:\works\python\test0.py", line 1, in password = 'bad' File "d:\works\python\test0.py", line 1, in password = 'bad' File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch return self.dispatch_line(frame) File "C:\Python34\lib\bdb.py", line 66, in dispatch_line self.user_line(frame) File "C:\Python34\lib\pdb.py", line 259, in user_line self.interaction(frame, None) File "C:\Python34\lib\pdb.py", line 346, in interaction self._cmdloop() File "C:\Python34\lib\pdb.py", line 319, in _cmdloop self.cmdloop() File "C:\Python34\lib\cmd.py", line 126, in cmdloop line = input(self.prompt) ValueError: I/O operation on closed file. During handling of the above exception, another exception occurred: 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 "C:\Python34\lib\pdb.py", line 1688, in pdb.main() File "C:\Python34\lib\pdb.py", line 1680, in main pdb.interaction(None, t) File "C:\Python34\lib\pdb.py", line 346, in interaction self._cmdloop() File "C:\Python34\lib\pdb.py", line 319, in _cmdloop self.cmdloop() File "C:\Python34\lib\cmd.py", line 126, in cmdloop line = input(self.prompt) ValueError: I/O operation on closed file. D:\Works\Python> How to get rid of these? Best Regards, Jach Fong --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From marko at pacujo.net Thu Sep 6 06:48:54 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 06 Sep 2018 13:48:54 +0300 Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> Message-ID: <87in3ioq95.fsf@elektro.pacujo.net> Chris Angelico : > The request was to translate this into Python, not to slavishly > imitate every possible semantic difference even if it won't actually > affect behaviour. I trust Steven to be able to refactor the code into something more likable. His only tripping point was the meaning of the "let" construct. Marko From as at sci.fi Thu Sep 6 08:49:10 2018 From: as at sci.fi (Anssi Saari) Date: Thu, 06 Sep 2018 15:49:10 +0300 Subject: CURSES WINDOWS References: <3149779059@f153.n1.z21.fsxnet> <2e92f6c3-bc9e-fe23-f1ac-ea840b2abc4d@yahoo.com.au> Message-ID: Peter via Python-list writes: >> ??? from _curses import * >> ModuleNotFoundError: No module named '_curses' Oh yes, I tested in Cygwin and maybe it doesn't count? But for Windows there's a curses wheel available at https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses From torriem at gmail.com Thu Sep 6 09:50:17 2018 From: torriem at gmail.com (Michael Torrie) Date: Thu, 6 Sep 2018 07:50:17 -0600 Subject: fsxNet Usenet gateway problem again In-Reply-To: References: <801718173@f38.n261.z1.binkp.net> <40654038@f38.n261.z1.binkp.net> Message-ID: <09b57fb1-1eaa-2599-8e9d-2e319863ee8b@gmail.com> On 09/05/2018 02:30 PM, Chris Angelico wrote: > I don't think this was spamming the list with the same question; a > glitch somewhere in a netnews server appears to be re-posting some old > posts. I wonder why this bbs gateway in New Zealand keeps doing this. Seems like someone contacts the postmaster there and he fixes the problem, and then it keeps coming back. Configuration gets reverted? From michael.stemper at gmail.com Thu Sep 6 10:04:21 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Thu, 6 Sep 2018 09:04:21 -0500 Subject: Object-oriented philosophy Message-ID: Over the summer, I've been working on a simulation. After months of design and redesign, I finally coded it up in two days over Labor Day weekend. Works great. The core of the simulation is a set of models of three different types of electrical loads (characterized based on how they respond to voltage changes), implemented as python classes. Since the three classes all had common methods (by design), I thought that maybe refactoring these three classes to inherit from a parent class would be beneficial. I went ahead and did so. (Outlines of before and after are at the end of the post.) Net net is that the only thing that ended up being common was the __init__ methods. Two of the classes have identical __init__ methods; the third has a superset of that method. The other methods all have completely different implementations. This isn't due to poor coding, but due to the fact that what these model have different physical characteristics. Not being that familiar with object-oriented programming (I grew up on FORTRAN and c), I'm seeking opinions: Is there really any benefit to this change? Yes, I've eliminated some (a few lines per class) duplicate code. On the other hand, I've added the parent class and the (probably small, but not non-existent) overhead of invoking super(). How does one judge when it's worthwhile to do this and when it's not? What criteria would somebody seasoned in OO and python use to say "good idea" vs "don't waste your time"? Other thoughts on this topic would also be appreciated. Comparison follows: ============= begin original ================ class ConstantPower( ): def __init__( self, xmlmodel, V ): def Resistance( self, V ): def Power( self, V ): def FixedValue( self ): class ConstantCurrent( ): def __init__( self, xmlmodel, V ): def Resistance( self, V ): def Power( self, V ): def FixedValue( self ): class ConstantImpedance( ): def __init__( self, xmlmodel, V ): def Resistance( self, V ): def Power( self, V ): def FixedValue( self ): def Update( self, V ): =============== end original ================ ============= begin revised ================= class LoadModel( ): def __init__( self, xmlmodel, V, id ): class ConstantPower( LoadModel ): def __init__( self, xmlmodel, V ): super().__init__( xmlmodel, V, "constant power" ) def Resistance( self, V ): def Power( self, V ): def FixedValue( self ): class ConstantCurrent( LoadModel ): def __init__( self, xmlmodel, V ): super().__init__( xmlmodel, V, "constant current" ) def Resistance( self, V ): def Power( self, V ): def FixedValue( self ): class ConstantImpedance( LoadModel ): def __init__( self, xmlmodel, V ): super().__init__( xmlmodel, V, self.name ) def Resistance( self, V ): def Power( self, V ): def FixedValue( self ): def Update( self, V ): =============== end revised ================= -- Michael F. Stemper This email is to be read by its intended recipient only. Any other party reading is required by the EULA to send me $500.00. From marko at pacujo.net Thu Sep 6 10:34:58 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 06 Sep 2018 17:34:58 +0300 Subject: Object-oriented philosophy References: Message-ID: <87d0tqofsd.fsf@elektro.pacujo.net> "Michael F. Stemper" : > Since the three classes all had common methods (by design), I > thought that maybe refactoring these three classes to inherit from > a parent class would be beneficial. I went ahead and did so. > (Outlines of before and after are at the end of the post.) > > Net net is that the only thing that ended up being common was the > __init__ methods. Two of the classes have identical __init__ > methods; the third has a superset of that method. The other methods > all have completely different implementations. This isn't due to > poor coding, but due to the fact that what these model have > different physical characteristics. > > [...] > > Is there really any benefit to this change? Yes, I've eliminated > some (a few lines per class) duplicate code. On the other hand, > I've added the parent class and the (probably small, but not > non-existent) overhead of invoking super(). > > How does one judge when it's worthwhile to do this and when it's > not? What criteria would somebody seasoned in OO and python use > to say "good idea" vs "don't waste your time"? Ultimately, a seasoned OO programmer might prefer one structure in the morning and another structure in the afternoon. Python's ducktyping makes it possible to develop classes to an interface that is not spelled out as a base class. My opinion is that you should not define base classes only to show pedigree as you would need to in, say, Java. Then, is it worthwhile to define a base class just to avoid typing the same constructor twice? That's a matter of opinion. You can go either way. Just understand that the base class doesn't serve a philosophical role but is simply an implementation utility. Be prepared to refactor the code and get rid of the base class the moment the commonality disappears. On the other hand, why is it that the two constructors happen to coincide? Is it an indication that the two classes have something deeper in common that the third one doesn't? If it is not a coincidence, go ahead and give the base class a name that expresses the commonality. Don't be afraid of "wasting your time" or worry too much about whether something is a "good idea." Be prepared to massage the code over time as your understanding and tastes evolve. Marko From rhodri at kynesim.co.uk Thu Sep 6 10:35:21 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Thu, 6 Sep 2018 15:35:21 +0100 Subject: Object-oriented philosophy In-Reply-To: References: Message-ID: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> On 06/09/18 15:04, Michael F. Stemper wrote: > Net net is that the only thing that ended up being common was the > __init__ methods. Two of the classes have identical __init__ > methods; the third has a superset of that method. The other methods > all have completely different implementations. This isn't due to > poor coding, but due to the fact that what these model have > different physical characteristics. > > Not being that familiar with object-oriented programming (I grew up > on FORTRAN and c), I'm seeking opinions: > > Is there really any benefit to this change? Yes, I've eliminated > some (a few lines per class) duplicate code. On the other hand, > I've added the parent class and the (probably small, but not > non-existent) overhead of invoking super(). What you've done is the work you would have to do in a statically-typed language such as C++. You've been taking advantage of duck typing to have the rest of your code not have to care about what type of load you are modelling, but in C++ (say) you would need the superclass to supply the type information to let the rest of your code compile. Is it worth creating the superclass in Python? It sounds like it's a bit marginal in your case. I'm not that seasoned in object-oriented design either, but my yardstick would be how much common code does it eliminate? It's a very subjective measure, but basically it's the same subjective measure as for pulling any common code into a separate function. -- Rhodri James *-* Kynesim Ltd From mal at europython.eu Thu Sep 6 10:53:54 2018 From: mal at europython.eu (M.-A. Lemburg) Date: Thu, 6 Sep 2018 16:53:54 +0200 Subject: EuroPython 2018: Videos for Friday available Message-ID: <3c1a570d-3456-d052-26ef-0385cbf621b2@europython.eu> We are pleased to announce the third and last batch of cut videos from EuroPython 2018 in Edinburgh, Scotland, UK. * EuroPython 2018 YouTube Playlist * https://www.youtube.com/watch?v=UXSr1OL5JKo&t=0s&index=130&list=PL8uoeex94UhFrNUV2m5MigREebUms39U5 In the last batch, we have included all videos for Friday, July 27 2018, the third conference day. In total, we now have more than 130 videos available for you to watch. All EuroPython videos, including the ones from previous conferences, are available on our EuroPython YouTube Channel. http://europython.tv/ Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/177798571707/europython-2018-videos-for-friday-available Tweet: https://twitter.com/europython/status/1037666146147811328 Enjoy, -- EuroPython 2018 Team https://ep2018.europython.eu/ https://www.europython-society.org/ From arj.python at gmail.com Thu Sep 6 11:40:09 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 6 Sep 2018 19:40:09 +0400 Subject: Object-oriented philosophy In-Reply-To: References: Message-ID: Also, get someone, preferrable a python engineer to review your code. yours, Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius From tjol at tjol.eu Thu Sep 6 12:03:19 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 6 Sep 2018 18:03:19 +0200 Subject: fsxNet Usenet gateway problem again In-Reply-To: <09b57fb1-1eaa-2599-8e9d-2e319863ee8b@gmail.com> References: <801718173@f38.n261.z1.binkp.net> <40654038@f38.n261.z1.binkp.net> <09b57fb1-1eaa-2599-8e9d-2e319863ee8b@gmail.com> Message-ID: On 2018-09-06 15:50, Michael Torrie wrote: > On 09/05/2018 02:30 PM, Chris Angelico wrote: >> I don't think this was spamming the list with the same question; a >> glitch somewhere in a netnews server appears to be re-posting some old >> posts. > > I wonder why this bbs gateway in New Zealand keeps doing this. Seems > like someone contacts the postmaster there and he fixes the problem, and > then it keeps coming back. Configuration gets reverted? > I love that the reposted messages come with a header Path: uni-berlin.de!<...>!.POSTED.agency.bbs.nz!not-for-mail ^^^^^^^^^^^^^ From tjol at tjol.eu Thu Sep 6 12:07:55 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 6 Sep 2018 18:07:55 +0200 Subject: Object-oriented philosophy In-Reply-To: References: Message-ID: <9f6d8cf5-d315-9ebb-8753-27e24ce22056@tjol.eu> On 2018-09-06 17:40, Abdur-Rahmaan Janhangeer wrote: > Also, get someone, preferrable a python engineer to review your code. Does anyone here know anyone who would refer to themselves as a "Python engineer" with a straight face? I merely ask... -- Thomas From pengyu.ut at gmail.com Thu Sep 6 12:32:13 2018 From: pengyu.ut at gmail.com (Peng Yu) Date: Thu, 6 Sep 2018 11:32:13 -0500 Subject: OpenSSL error Message-ID: Hi, I got the following error. Does anybody know how to fix it? Thanks. $ pip Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/bin/pip", line 7, in from pip._internal import main File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/__init__.py", line 42, in from pip._internal import cmdoptions File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/cmdoptions.py", line 16, in from pip._internal.index import ( File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/index.py", line 14, in from pip._vendor import html5lib, requests, six File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", line 97, in from pip._vendor.urllib3.contrib import pyopenssl File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in import OpenSSL.SSL File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in from OpenSSL import rand, crypto, SSL File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSSL/SSL.py", line 118, in SSL_ST_INIT = _lib.SSL_ST_INIT AttributeError: 'module' object has no attribute 'SSL_ST_INIT' -- Regards, Peng From oscar.j.benjamin at gmail.com Thu Sep 6 12:33:00 2018 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 6 Sep 2018 17:33:00 +0100 Subject: Debug script under pdb, how to avoid a bunch of errors caused by the exit()? In-Reply-To: <68c6a650-9515-078a-a009-8092511e6001@ms4.hinet.net> References: <68c6a650-9515-078a-a009-8092511e6001@ms4.hinet.net> Message-ID: On Thu, 6 Sep 2018 at 10:59, Jach Fong wrote: > > Here the script file, test0.py: > -------------------------- > password = 'bad' > if password == 'bad': > print('bad password') > exit() > else: > print('good password') > > print('something else to do') > -------------------- > > When running it under Python3.4 Windows Vista, no problem at all. > > D:\Works\Python>py test0.py > bad password > > But if debug it under pdb: > > D:\Works\Python>py -m pdb test0.py > [...] > ValueError: I/O operation on closed file. > Uncaught exception. Entering post mortem debugging > > How to get rid of these? I haven't noticed this behaviour before but then I normally use functions rather than writing my code at top level and quitting with exit(). If I had written your script then it might look something like: def main(): password = 'bad' if password == 'bad': print('bad password') return # <-- Not exit() else: print('good password') print('something else to do') if __name__ == "__main__": main() Now since you're no longer using exit() to end the program it doesn't need to screw up pdb. -- Oscar From vhnguyenn at yahoo.com Thu Sep 6 13:26:43 2018 From: vhnguyenn at yahoo.com (Viet Nguyen) Date: Thu, 6 Sep 2018 10:26:43 -0700 (PDT) Subject: Why emumerated list is empty on 2nd round of print? Message-ID: >>> numList [2, 7, 22, 30, 1, 8] >>> aList = enumerate(numList) >>> for i,j in aList:print(i,j) 0 2 1 7 2 22 3 30 4 1 5 8 >>> for i,j in aList:print(i,j) >>> From rosuav at gmail.com Thu Sep 6 13:34:03 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 7 Sep 2018 03:34:03 +1000 Subject: Why emumerated list is empty on 2nd round of print? In-Reply-To: References: Message-ID: On Fri, Sep 7, 2018 at 3:26 AM, Viet Nguyen via Python-list wrote: >>>> numList > [2, 7, 22, 30, 1, 8] > >>>> aList = enumerate(numList) > >>>> for i,j in aList:print(i,j) > > 0 2 > 1 7 > 2 22 > 3 30 > 4 1 > 5 8 > >>>> for i,j in aList:print(i,j) > >>>> Because it's not an enumerated list, it's an enumerated iterator. Generally, you'll just use that directly in the loop: for i, value in enumerate(numbers): There's generally no need to hang onto it from one loop to another. ChrisA From vhnguyenn at yahoo.com Thu Sep 6 14:50:17 2018 From: vhnguyenn at yahoo.com (Viet Nguyen) Date: Thu, 6 Sep 2018 11:50:17 -0700 (PDT) Subject: Why emumerated list is empty on 2nd round of print? In-Reply-To: References: Message-ID: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> On Thursday, September 6, 2018 at 10:34:19 AM UTC-7, Chris Angelico wrote: > On Fri, Sep 7, 2018 at 3:26 AM, Viet Nguyen via Python-list > wrote: > >>>> numList > > [2, 7, 22, 30, 1, 8] > > > >>>> aList = enumerate(numList) > > > >>>> for i,j in aList:print(i,j) > > > > 0 2 > > 1 7 > > 2 22 > > 3 30 > > 4 1 > > 5 8 > > > >>>> for i,j in aList:print(i,j) > > > >>>> > > Because it's not an enumerated list, it's an enumerated iterator. > Generally, you'll just use that directly in the loop: > > for i, value in enumerate(numbers): > > There's generally no need to hang onto it from one loop to another. > > ChrisA Thanks ChrisA. If I do this "aList = enumerate(numList)", isn't it stored permanently in aList now? I see your point to use it directly, but just in case I do need to hang onto it from one loop to another, then how is that done? Anyway I think I'm ok and I got what I need for now. From richard.t.vandyk at lmco.com Thu Sep 6 15:10:10 2018 From: richard.t.vandyk at lmco.com (VanDyk, Richard T) Date: Thu, 6 Sep 2018 19:10:10 +0000 Subject: don't quite understand mailing list Message-ID: <39f7985fde9446f08c9ac056f3d28373@lmco.com> Greetings; I sent in a question on how to install robot framework on python 3.7 using pip (or any other way). None of the commands on the >>> seem to work for me. I was asked to update the c/c++ runtime which I don't know what that means. I was also asked to subscribe to the mailing list. I did that but don't want everyone's submitted question to come to me. Can you please take me off the mailing list or prevent questions from coming to me. Can you advise me on my problem or point me in the right direction? Thanks. Richard VanDyk Software Contractor (Indotronix), Missiles and Fire Control Lockheed Martin Corporation 1701 W Marshall Dr, Grand Prairie, TX 75051 Phone: 972-603-3303 [cid:image001.png at 01D3B492.AF6B5C30] From David.Raymond at tomtom.com Thu Sep 6 15:11:57 2018 From: David.Raymond at tomtom.com (David Raymond) Date: Thu, 6 Sep 2018 19:11:57 +0000 Subject: Why emumerated list is empty on 2nd round of print? In-Reply-To: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> References: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> Message-ID: The actual "enumerate" object is really just holding a current index and a reference to the original list. So if you alter the original list while you're iterating through it you'll see the changes. If you want a full copy then you can just wrap it with list() Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> numList = [2, 7, 22, 30, 1, 8] >>> aList = enumerate(numList) >>> aList.__next__() (0, 2) >>> numList[1] = 5 >>> aList.__next__() (1, 5) >>> aList2 = list(enumerate(numList)) >>> aList2 [(0, 2), (1, 5), (2, 22), (3, 30), (4, 1), (5, 8)] >>> numList[3] = -12 >>> aList2 [(0, 2), (1, 5), (2, 22), (3, 30), (4, 1), (5, 8)] >>> aList.__next__() (2, 22) >>> aList.__next__() (3, -12) >>> aList.__next__() (4, 1) >>> aList.__next__() (5, 8) >>> aList.__next__() Traceback (most recent call last): File "", line 1, in StopIteration >>> -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Viet Nguyen via Python-list Sent: Thursday, September 06, 2018 2:50 PM To: python-list at python.org Subject: Re: Why emumerated list is empty on 2nd round of print? On Thursday, September 6, 2018 at 10:34:19 AM UTC-7, Chris Angelico wrote: > On Fri, Sep 7, 2018 at 3:26 AM, Viet Nguyen via Python-list > wrote: > >>>> numList > > [2, 7, 22, 30, 1, 8] > > > >>>> aList = enumerate(numList) > > > >>>> for i,j in aList:print(i,j) > > > > 0 2 > > 1 7 > > 2 22 > > 3 30 > > 4 1 > > 5 8 > > > >>>> for i,j in aList:print(i,j) > > > >>>> > > Because it's not an enumerated list, it's an enumerated iterator. > Generally, you'll just use that directly in the loop: > > for i, value in enumerate(numbers): > > There's generally no need to hang onto it from one loop to another. > > ChrisA Thanks ChrisA. If I do this "aList = enumerate(numList)", isn't it stored permanently in aList now? I see your point to use it directly, but just in case I do need to hang onto it from one loop to another, then how is that done? Anyway I think I'm ok and I got what I need for now. -- https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Thu Sep 6 15:21:41 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 7 Sep 2018 05:21:41 +1000 Subject: Why emumerated list is empty on 2nd round of print? In-Reply-To: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> References: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> Message-ID: On Fri, Sep 7, 2018 at 4:50 AM, Viet Nguyen via Python-list wrote: >> Because it's not an enumerated list, it's an enumerated iterator. >> Generally, you'll just use that directly in the loop: >> >> for i, value in enumerate(numbers): >> >> There's generally no need to hang onto it from one loop to another. >> >> ChrisA > > Thanks ChrisA. If I do this "aList = enumerate(numList)", isn't it stored permanently in aList now? I see your point to use it directly, but just in case I do need to hang onto it from one loop to another, then how is that done? Anyway I think I'm ok and I got what I need for now. > The enumerator is. It doesn't become something different when you assign it to something. Assume you don't need to hang onto it, until such time as that changes. :) ChrisA From vhnguyenn at yahoo.com Thu Sep 6 15:36:41 2018 From: vhnguyenn at yahoo.com (Viet Nguyen) Date: Thu, 6 Sep 2018 12:36:41 -0700 (PDT) Subject: Why emumerated list is empty on 2nd round of print? In-Reply-To: References: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> Message-ID: <8f10ca2e-afde-492d-8499-41619e8e60ae@googlegroups.com> On Thursday, September 6, 2018 at 12:12:20 PM UTC-7, David Raymond wrote: > The actual "enumerate" object is really just holding a current index and a reference to the original list. So if you alter the original list while you're iterating through it you'll see the changes. If you want a full copy then you can just wrap it with list() > > Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> numList = [2, 7, 22, 30, 1, 8] > >>> aList = enumerate(numList) > >>> aList.__next__() > (0, 2) > >>> numList[1] = 5 > >>> aList.__next__() > (1, 5) > >>> aList2 = list(enumerate(numList)) > >>> aList2 > [(0, 2), (1, 5), (2, 22), (3, 30), (4, 1), (5, 8)] > >>> numList[3] = -12 > >>> aList2 > [(0, 2), (1, 5), (2, 22), (3, 30), (4, 1), (5, 8)] > >>> aList.__next__() > (2, 22) > >>> aList.__next__() > (3, -12) > >>> aList.__next__() > (4, 1) > >>> aList.__next__() > (5, 8) > >>> aList.__next__() > Traceback (most recent call last): > File "", line 1, in > StopIteration > >>> > > > -----Original Message----- > From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Viet Nguyen via Python-list > Sent: Thursday, September 06, 2018 2:50 PM > To: python-list at python.org > Subject: Re: Why emumerated list is empty on 2nd round of print? > > On Thursday, September 6, 2018 at 10:34:19 AM UTC-7, Chris Angelico wrote: > > On Fri, Sep 7, 2018 at 3:26 AM, Viet Nguyen via Python-list > > wrote: > > >>>> numList > > > [2, 7, 22, 30, 1, 8] > > > > > >>>> aList = enumerate(numList) > > > > > >>>> for i,j in aList:print(i,j) > > > > > > 0 2 > > > 1 7 > > > 2 22 > > > 3 30 > > > 4 1 > > > 5 8 > > > > > >>>> for i,j in aList:print(i,j) > > > > > >>>> > > > > Because it's not an enumerated list, it's an enumerated iterator. > > Generally, you'll just use that directly in the loop: > > > > for i, value in enumerate(numbers): > > > > There's generally no need to hang onto it from one loop to another. > > > > ChrisA > > Thanks ChrisA. If I do this "aList = enumerate(numList)", isn't it stored permanently in aList now? I see your point to use it directly, but just in case I do need to hang onto it from one loop to another, then how is that done? Anyway I think I'm ok and I got what I need for now. > -- > https://mail.python.org/mailman/listinfo/python-list Very clear and good examples! Thank you. From brunnre8 at gmail.com Thu Sep 6 15:42:22 2018 From: brunnre8 at gmail.com (Reto Brunner) Date: Thu, 6 Sep 2018 21:42:22 +0200 Subject: don't quite understand mailing list In-Reply-To: <39f7985fde9446f08c9ac056f3d28373@lmco.com> References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> Message-ID: <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> On Thu, Sep 06, 2018 at 07:10:10PM +0000, VanDyk, Richard T wrote: > Can you please take me off the mailing list or prevent questions from coming to me. Can you advise me on my problem or point me in the right direction? > Thanks. > https://mail.python.org/mailman/listinfo/python-list What do you think the link, which is attached to every email you receive from the list, is for? Listinfo sounds very promising, doesn't it? And if you actually go to it you'll find: "To unsubscribe from Python-list, get a password reminder, or change your subscription options enter your subscription email address" So how about you try that? From jqian at tibco.com Thu Sep 6 15:46:08 2018 From: jqian at tibco.com (Jason Qian) Date: Thu, 6 Sep 2018 15:46:08 -0400 Subject: ModuleNotFoundError: No module named 'encodings' Message-ID: Hi Need some help. I have a C++ application that invokes Python. ... Py_SetPythonHome("python_path"); Py_Initialize(); This works fine on Python 3.6.4 version, but got errors on Python 3.7.0 when calling Py_Initialize(), Fatal Python error: initfsencoding: unable to load the file system codec ModuleNotFoundError: No module named 'encodings' Thanks for the help Jason From rgaddi at highlandtechnology.invalid Thu Sep 6 15:55:07 2018 From: rgaddi at highlandtechnology.invalid (Rob Gaddi) Date: Thu, 6 Sep 2018 12:55:07 -0700 Subject: Object-oriented philosophy In-Reply-To: References: <9f6d8cf5-d315-9ebb-8753-27e24ce22056@tjol.eu> Message-ID: On 09/06/2018 09:07 AM, Thomas Jollans wrote: > On 2018-09-06 17:40, Abdur-Rahmaan Janhangeer wrote: >> Also, get someone, preferrable a python engineer to review your code. > > Does anyone here know anyone who would refer to themselves as a "Python > engineer" with a straight face? I merely ask... > > -- Thomas > Suddenly I'm filled with visions of pipe, fittings, and a herpetology degree. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From ethan at stoneleaf.us Thu Sep 6 16:06:22 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 06 Sep 2018 13:06:22 -0700 Subject: don't quite understand mailing list In-Reply-To: <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> Message-ID: <5B9188BE.6010600@stoneleaf.us> On 09/06/2018 12:42 PM, Reto Brunner wrote: > What do you think the link, which is attached to every email you receive > from the list, is for? Listinfo sounds very promising, doesn't it? > > And if you actually go to it you'll find: > "To unsubscribe from Python-list, get a password reminder, or change your subscription options enter your subscription email address" > > So how about you try that? Reto, your response is inappropriate. If you can't be kind and/or respectful, let someone else respond. -- ~Ethan~ From michael.stemper at gmail.com Thu Sep 6 16:18:26 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Thu, 6 Sep 2018 15:18:26 -0500 Subject: Object-oriented philosophy In-Reply-To: <87d0tqofsd.fsf@elektro.pacujo.net> References: <87d0tqofsd.fsf@elektro.pacujo.net> Message-ID: On 2018-09-06 09:34, Marko Rauhamaa wrote: > "Michael F. Stemper" : > >> Since the three classes all had common methods (by design), I >> thought that maybe refactoring these three classes to inherit from >> a parent class would be beneficial. I went ahead and did so. >> (Outlines of before and after are at the end of the post.) >> >> Net net is that the only thing that ended up being common was the >> __init__ methods. Two of the classes have identical __init__ >> methods; the third has a superset of that method. The other methods >> all have completely different implementations. This isn't due to >> poor coding, but due to the fact that what these model have >> different physical characteristics. >> >> [...] >> >> Is there really any benefit to this change? Yes, I've eliminated >> some (a few lines per class) duplicate code. On the other hand, >> I've added the parent class and the (probably small, but not >> non-existent) overhead of invoking super(). >> >> How does one judge when it's worthwhile to do this and when it's >> not? What criteria would somebody seasoned in OO and python use >> to say "good idea" vs "don't waste your time"? > > Ultimately, a seasoned OO programmer might prefer one structure in the > morning and another structure in the afternoon. I figured that was the case, which is why I sought criteria to consider rather than a cut-and-dried answer. > Python's ducktyping makes it possible to develop classes to an interface > that is not spelled out as a base class. After reviewing my code, I have a feeling that I'm not taking advantage of duck typing. I think that if LoadList held all types of load and I did this: for load in LoadList: load.served = load.Power( Feeder.V_load ) LoadServed += load.served it would be duck typing. Unfortunately, I'm not. I had thought that I needed to handle the constant power load (if there is one) separately in at least one point, and the same for a possible constant current load. The (zero to many) constant impedance loads are all in a list over which I loop. However, inspired by your point, I think that I've found a way to handle them all in one list. I'll play with it a little. > My opinion is that you should > not define base classes only to show pedigree as you would need to in, > say, Java. Maybe it was from what I've read about Java (zero experience) that gave me the idea to try this. > Then, is it worthwhile to define a base class just to avoid typing the > same constructor twice? That's a matter of opinion. You can go either > way. Just understand that the base class doesn't serve a philosophical > role but is simply an implementation utility. Be prepared to refactor > the code and get rid of the base class the moment the commonality > disappears. I'll keep that in mind, but the commonality is based on the laws of physics, so it's not a big risk. > On the other hand, why is it that the two constructors happen to > coincide? Is it an indication that the two classes have something deeper > in common that the third one doesn't? If it is not a coincidence, go > ahead and give the base class a name that expresses the commonality. The code which all three load types share, which is the total content of their parent, is as follows: def __init__( self, xmlmodel, V, id ): try: P_0s = xmlmodel.findall( 'RatedPower' )[0].text self.P_0 = float( P_0s ) except: Utility.DataErr( "Power not specified for %s load" % (id) ) if self.P_0<=0.0: Utility.DataErr( "Power for %s load must be postive, not %s" \ % (id,P_0s) ) The constant impedance loads then extend this by initializing a duty cycle model. (Think of something thermostatically controlled, such as an electric oven or electric space heating.) The constant impedance loads then extend this by initializing a duty cycle model. (Think of something thermostatically controlled, such as an electric oven or electric space heating.) The 30000-foot[1] view of the data model is: > Don't be afraid of "wasting your time" If was was afraid of that, I wouldn't have tried refactoring the code in the first place. I would have said "it works, don't bother." > or worry too much about whether > something is a "good idea." Well, if it turns out to be a bad idea, I'd rather learn that it's a bad idea. > Be prepared to massage the code over time as > your understanding and tastes evolve. Exactly what I was doing, and the point of asking was to extend my understanding. Thanks for taking the time to respond. -- Michael F. Stemper What happens if you play John Cage's "4'33" at a slower tempo? From michael.stemper at gmail.com Thu Sep 6 16:24:44 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Thu, 6 Sep 2018 15:24:44 -0500 Subject: Object-oriented philosophy In-Reply-To: References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> Message-ID: On 2018-09-06 09:35, Rhodri James wrote: > On 06/09/18 15:04, Michael F. Stemper wrote: >> Net net is that the only thing that ended up being common was the >> __init__ methods. Two of the classes have identical __init__ >> methods; the third has a superset of that method. The other methods >> all have completely different implementations. This isn't due to >> poor coding, but due to the fact that what these model have >> different physical characteristics. >> >> Not being that familiar with object-oriented programming (I grew up >> on FORTRAN and c), I'm seeking opinions: >> >> Is there really any benefit to this change? Yes, I've eliminated >> some (a few lines per class) duplicate code. On the other hand, >> I've added the parent class and the (probably small, but not >> non-existent) overhead of invoking super(). > > What you've done is the work you would have to do in a statically-typed > language such as C++.? You've been taking advantage of duck typing Upon review, it seems that I haven't. However, as noted in another followup, I think that I've found a way to do so. > Is it worth creating the superclass in Python?? It sounds like it's a > bit marginal in your case.? I'm not that seasoned in object-oriented > design either, but my yardstick would be how much common code does it > eliminate? About half a dozen lines. Here's the common part: def __init__( self, xmlmodel, V, id ): try: P_0s = xmlmodel.findall( 'RatedPower' )[0].text self.P_0 = float( P_0s ) except: Utility.DataErr( "Power not specified for %s load" % (id) ) if self.P_0<=0.0: Utility.DataErr( "Power for %s load must be postive, not %s" \ % (id,P_0s) ) Actually, looking over it, I see that I can slightly simplify this. I suppose that's a good reason for putting it in one place -- if I want to change it, I only need to do it once, not three times. Thanks for your input. -- Michael F. Stemper Why doesn't anybody care about apathy? From michael.stemper at gmail.com Thu Sep 6 16:25:34 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Thu, 6 Sep 2018 15:25:34 -0500 Subject: Object-oriented philosophy In-Reply-To: References: Message-ID: On 2018-09-06 10:40, Abdur-Rahmaan Janhangeer wrote: > Also, get someone, preferrable a python engineer to review your code. Sounds like an advertisement to me. -- Michael F. Stemper Why doesn't anybody care about apathy? From michael.stemper at gmail.com Thu Sep 6 16:31:03 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Thu, 6 Sep 2018 15:31:03 -0500 Subject: Object-oriented philosophy In-Reply-To: References: Message-ID: On 2018-09-06 12:32, Stefan Ram wrote: > "Michael F. Stemper" writes: >> Is there really any benefit to this change? Yes, I've eliminated >> some (a few lines per class) duplicate code. On the other hand, >> I've added the parent class and the (probably small, but not >> non-existent) overhead of invoking super(). > > You have a operation ?Resistance( V )?. Mathematically, that's an operation, I suppose. I tend to think of it as either a function or a method. > OOP is advantageous if you can anticipate that you will want > to extend operations for other types. Since the way that each operation (aside from __init__) differs from one load type to the next, is there really an advantage? > I.e., if you anticipate a new type ?ConstantVoltage?, you Actually, although the possibility of other load models exists, ConstantVoltage() would be impossible, since these models are all defined based on the behavior of the load *in response to a change in voltage*. But your point is well-taken, which is part of why I considered doing inheritance. > can add an operation ?Resistance( V )? for this new type > without changing the existing definitions (open-closed > principle). > > Non-OOP is advantageous if you can anticipate that you will > want to add new operations for the existing types. > > (Non-OOP means in this case that you have a single > definition of a function ?Resistance( entity, V )? which > contains an internal multiple branch on the type of the > entity.) To be honest, that sounds painful and hard to maintain. Of course, back in my F77 days, it would have been the only option. Thanks for your time. -- Michael F. Stemper Why doesn't anybody care about apathy? From none at invalid.com Thu Sep 6 16:44:20 2018 From: none at invalid.com (mm0fmf) Date: Thu, 06 Sep 2018 21:44:20 +0100 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: On 06/09/2018 21:06, Ethan Furman wrote: > On 09/06/2018 12:42 PM, Reto Brunner wrote: > >> What do you think the link, which is attached to every email you receive >> from the list, is for? Listinfo sounds very promising, doesn't it? >> >> And if you actually go to it you'll find: >> "To unsubscribe from Python-list, get a password reminder, or change >> your subscription options enter your subscription email address" >> >> So how about you try that? > > Reto, your response is inappropriate. If you can't be kind and/or > respectful, let someone else respond. > > -- > ~Ethan~ Seriously if someone has a swanky signature advertising that they are a rocket scientist viz. "Software Contractor, Missiles and Fire Control" and yet doesn't know what a language runtime is or how mailing lists work then they are asking for that kind of reply. Just saying..... From rosuav at gmail.com Thu Sep 6 16:56:47 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 7 Sep 2018 06:56:47 +1000 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: On Fri, Sep 7, 2018 at 6:44 AM, mm0fmf wrote: > On 06/09/2018 21:06, Ethan Furman wrote: >> >> On 09/06/2018 12:42 PM, Reto Brunner wrote: >> >>> What do you think the link, which is attached to every email you receive >>> from the list, is for? Listinfo sounds very promising, doesn't it? >>> >>> And if you actually go to it you'll find: >>> "To unsubscribe from Python-list, get a password reminder, or change >>> your subscription options enter your subscription email address" >>> >>> So how about you try that? >> >> >> Reto, your response is inappropriate. If you can't be kind and/or >> respectful, let someone else respond. >> > > Seriously if someone has a swanky signature advertising that they are a > rocket scientist viz. "Software Contractor, Missiles and Fire Control" and > yet doesn't know what a language runtime is or how mailing lists work then > they are asking for that kind of reply. > Fortunately, not everyone has to respond snarkily. Richard, once you join a mailing list, ALL posts sent to it will come to your inbox. But what you do with them after that is up to you. I recommend configuring your mail client to filter the messages to their own folder (or equivalent - if you're using Gmail, their own "tag"), so you can then read them or ignore them at will, without them cluttering up your main inbox. ChrisA From python at mrabarnett.plus.com Thu Sep 6 17:00:26 2018 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 6 Sep 2018 22:00:26 +0100 Subject: Object-oriented philosophy In-Reply-To: References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> Message-ID: <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> On 2018-09-06 21:24, Michael F. Stemper wrote: > On 2018-09-06 09:35, Rhodri James wrote: >> On 06/09/18 15:04, Michael F. Stemper wrote: >>> Net net is that the only thing that ended up being common was the >>> __init__ methods. Two of the classes have identical __init__ >>> methods; the third has a superset of that method. The other methods >>> all have completely different implementations. This isn't due to >>> poor coding, but due to the fact that what these model have >>> different physical characteristics. >>> >>> Not being that familiar with object-oriented programming (I grew up >>> on FORTRAN and c), I'm seeking opinions: >>> >>> Is there really any benefit to this change? Yes, I've eliminated >>> some (a few lines per class) duplicate code. On the other hand, >>> I've added the parent class and the (probably small, but not >>> non-existent) overhead of invoking super(). >> >> What you've done is the work you would have to do in a statically-typed >> language such as C++.? You've been taking advantage of duck typing > > Upon review, it seems that I haven't. However, as noted in another > followup, I think that I've found a way to do so. > >> Is it worth creating the superclass in Python?? It sounds like it's a >> bit marginal in your case.? I'm not that seasoned in object-oriented >> design either, but my yardstick would be how much common code does it >> eliminate? > > About half a dozen lines. Here's the common part: > > def __init__( self, xmlmodel, V, id ): > > try: > P_0s = xmlmodel.findall( 'RatedPower' )[0].text > self.P_0 = float( P_0s ) > except: > Utility.DataErr( "Power not specified for %s load" % (id) ) > if self.P_0<=0.0: > Utility.DataErr( "Power for %s load must be postive, not %s" \ > % (id,P_0s) ) > > Actually, looking over it, I see that I can slightly simplify this. > I suppose that's a good reason for putting it in one place -- if I > want to change it, I only need to do it once, not three times. > > Thanks for your input. > A word of advice: don't use a "bare" except, i.e. one that doesn't specify what exception(s) it should catch. Your try...except above will catch _any_ exception. If you misspelled a name in the 'try' part, it would raise NameError, which would also be caught. There are rare occasions when it's OK, but even then you'd just want to do something and then re-raise it. Catch only those exceptions that you're prepared to deal with and allow any others to propagate and let you know that there's a problem! From ethan at stoneleaf.us Thu Sep 6 17:00:41 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 06 Sep 2018 14:00:41 -0700 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: <5B919579.50505@stoneleaf.us> On 09/06/2018 01:44 PM, mm0fmf wrote: > Seriously if someone has a swanky signature advertising that they are a rocket scientist viz. "Software Contractor, > Missiles and Fire Control" and yet doesn't know what a language runtime is or how mailing lists work then they are > asking for that kind of reply. No, they are not asking for it, they are asking for help. I chose not to reply because I didn't think I could do it kindly. I also know I've asked totally bone-headed questions in the past (although they seemed legitimate when I was asking them). In short, this list is not the place to be condescending nor mean-spirited. If the urge strikes, pass it up and move to the next post. -- ~Ethan~ From gheskett at shentel.net Thu Sep 6 17:20:52 2018 From: gheskett at shentel.net (Gene Heskett) Date: Thu, 6 Sep 2018 17:20:52 -0400 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> Message-ID: <201809061720.52644.gheskett@shentel.net> On Thursday 06 September 2018 16:44:20 mm0fmf wrote: > On 06/09/2018 21:06, Ethan Furman wrote: > > On 09/06/2018 12:42 PM, Reto Brunner wrote: > >> What do you think the link, which is attached to every email you > >> receive from the list, is for? Listinfo sounds very promising, > >> doesn't it? > >> > >> And if you actually go to it you'll find: > >> "To unsubscribe from Python-list, get a password reminder, or > >> change your subscription options enter your subscription email > >> address" > >> > >> So how about you try that? > > > > Reto, your response is inappropriate. If you can't be kind and/or > > respectful, let someone else respond. > > > > -- > > ~Ethan~ > > Seriously if someone has a swanky signature advertising that they are > a rocket scientist viz. "Software Contractor, Missiles and Fire > Control" and yet doesn't know what a language runtime is or how > mailing lists work then they are asking for that kind of reply. > > Just saying..... +1 -- 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 tjol at tjol.eu Thu Sep 6 17:29:13 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 6 Sep 2018 23:29:13 +0200 Subject: ModuleNotFoundError: No module named 'encodings' In-Reply-To: References: Message-ID: On 09/06/2018 09:46 PM, Jason Qian via Python-list wrote: > Hi > > Need some help. > > I have a C++ application that invokes Python. > > ... > Py_SetPythonHome("python_path"); This isn't actually a line in your code, is it? For one thing, Py_SetPythonHome expects a wchar_t*... > Py_Initialize(); > > This works fine on Python 3.6.4 version, but got errors on Python 3.7.0 > when calling Py_Initialize(), > > Fatal Python error: initfsencoding: unable to load the file system codec > ModuleNotFoundError: No module named 'encodings' So, Python can't find a core module. This either means your Python 3.7 build is broken, or it doesn't know where to look. Perhaps whatever it is you're actually passing to Py_SetPythonHome needs to be changed to point to the right place? (i.e. maybe you're giving it the location of the Python 3.6 library rather than the Python 3.7 one) -- Thomas From pacqa100 at yahoo.com.au Thu Sep 6 18:33:25 2018 From: pacqa100 at yahoo.com.au (Peter) Date: Fri, 7 Sep 2018 08:33:25 +1000 Subject: Debug script under pdb, how to avoid a bunch of errors caused by the exit()? In-Reply-To: <68c6a650-9515-078a-a009-8092511e6001@ms4.hinet.net> References: <68c6a650-9515-078a-a009-8092511e6001@ms4.hinet.net> Message-ID: <8ee226fd-c482-84ad-1d22-fc8847843221@yahoo.com.au> I'm on 3.7.0 on Win 10, and get a different result. No traceback. Perhaps it's a bug in 3.4 that was fixed subsequently. C:\test> py -m pdb bugInPDB.py > c:\test\buginpdb.py(1)() -> password = 'bad' (Pdb) tbreak 3 Breakpoint 1 at c:\test\buginpdb.py:3 (Pdb) cont Deleted breakpoint 1 at c:\test\buginpdb.py:3 > c:\test\buginpdb.py(3)() -> print('bad password') (Pdb) cont bad password The program exited via sys.exit(). Exit status: None > c:\test\buginpdb.py(1)() -> password = 'bad' (Pdb) q C:\test> On 6/09/2018 7:38 PM, Jach Fong wrote: > Here the script file, test0.py: > -------------------------- > password = 'bad' > if password == 'bad': > ??? print('bad password') > ??? exit() > else: > ??? print('good password') > > print('something else to do') > -------------------- > > ??? When running it under Python3.4 Windows Vista, no problem at all. > > D:\Works\Python>py test0.py > bad password > > ??? But if debug it under pdb: > > D:\Works\Python>py -m pdb test0.py > > d:\works\python\test0.py(1)() > -> password = 'bad' > (Pdb) tbreak 3 > Breakpoint 1 at d:\works\python\test0.py:3 > (Pdb) cont > Deleted breakpoint 1 at d:\works\python\test0.py:3 > > d:\works\python\test0.py(3)() > -> print('bad password') > (Pdb) cont > bad password > The program exited via sys.exit(). Exit status: None > > d:\works\python\test0.py(1)() > -> password = 'bad' > (Pdb) Traceback (most recent call last): > ? File "C:\Python34\lib\pdb.py", line 1661, in main > ??? pdb._runscript(mainpyfile) > ? File "C:\Python34\lib\pdb.py", line 1542, in _runscript > ??? self.run(statement) > ? File "C:\Python34\lib\bdb.py", line 431, in run > ??? exec(cmd, globals, locals) > ? File "", line 1, in > ? File "d:\works\python\test0.py", line 1, in > ??? password = 'bad' > ? File "d:\works\python\test0.py", line 1, in > ??? password = 'bad' > ? File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch > ??? return self.dispatch_line(frame) > ? File "C:\Python34\lib\bdb.py", line 66, in dispatch_line > ??? self.user_line(frame) > ? File "C:\Python34\lib\pdb.py", line 259, in user_line > ??? self.interaction(frame, None) > ? File "C:\Python34\lib\pdb.py", line 346, in interaction > ??? self._cmdloop() > ? File "C:\Python34\lib\pdb.py", line 319, in _cmdloop > ??? self.cmdloop() > ? File "C:\Python34\lib\cmd.py", line 126, in cmdloop > ??? line = input(self.prompt) > ValueError: I/O operation on closed file. > Uncaught exception. Entering post mortem debugging > Running 'cont' or 'step' will restart the program > > c:\python34\lib\cmd.py(126)cmdloop() > -> line = input(self.prompt) > (Pdb) Traceback (most recent call last): > ? File "C:\Python34\lib\pdb.py", line 1661, in main > ??? pdb._runscript(mainpyfile) > ? File "C:\Python34\lib\pdb.py", line 1542, in _runscript > ??? self.run(statement) > ? File "C:\Python34\lib\bdb.py", line 431, in run > ??? exec(cmd, globals, locals) > ? File "", line 1, in > ? File "d:\works\python\test0.py", line 1, in > ??? password = 'bad' > ? File "d:\works\python\test0.py", line 1, in > ??? password = 'bad' > ? File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch > ??? return self.dispatch_line(frame) > ? File "C:\Python34\lib\bdb.py", line 66, in dispatch_line > ??? self.user_line(frame) > ? File "C:\Python34\lib\pdb.py", line 259, in user_line > ??? self.interaction(frame, None) > ? File "C:\Python34\lib\pdb.py", line 346, in interaction > ??? self._cmdloop() > ? File "C:\Python34\lib\pdb.py", line 319, in _cmdloop > ??? self.cmdloop() > ? File "C:\Python34\lib\cmd.py", line 126, in cmdloop > ??? line = input(self.prompt) > ValueError: I/O operation on closed file. > > During handling of the above exception, another exception occurred: > > 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 "C:\Python34\lib\pdb.py", line 1688, in > ??? pdb.main() > ? File "C:\Python34\lib\pdb.py", line 1680, in main > ??? pdb.interaction(None, t) > ? File "C:\Python34\lib\pdb.py", line 346, in interaction > ??? self._cmdloop() > ? File "C:\Python34\lib\pdb.py", line 319, in _cmdloop > ??? self.cmdloop() > ? File "C:\Python34\lib\cmd.py", line 126, in cmdloop > ??? line = input(self.prompt) > ValueError: I/O operation on closed file. > > D:\Works\Python> > > ??? How to get rid of these? > > Best Regards, > Jach Fong > > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > > From eryksun at gmail.com Thu Sep 6 18:56:57 2018 From: eryksun at gmail.com (eryk sun) Date: Thu, 6 Sep 2018 17:56:57 -0500 Subject: Cross platform mutex to prevent script running more than instance? In-Reply-To: <20180904224727.GA17544@cskk.homeip.net> References: <20180904224727.GA17544@cskk.homeip.net> Message-ID: On Tue, Sep 4, 2018 at 5:47 PM, Cameron Simpson wrote: > > The downside with mkdir, and also with pd files really, is that a program or > OS abort can leave them lying around. Being persistent objects, some kind of > cleanup is needed. While the OP needs a cross-platform solution, if it's just Windows, the cleanup problem for a temporary directory or lock file can be handled via the delete-on-close flag. This includes the case in which the process is forcefully terminated. However, it won't help if the system itself crashes or gets powered off abruptly. Details for a directory: *NT API* Call NtCreateFile with DELETE access, FILE_CREATE disposition, and the options FILE_DIRECTORY_FILE | FILE_DELETE_ON_CLOSE. *Windows API (undocumented)* Call CreateFile with CREATE_NEW disposition and the attributes/flags FILE_ATTRIBUTE_DIRECTORY | FILE_FLAG_POSIX_SEMANTICS | FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_DELETE_ON_CLOSE. *Windows API (documented)* Call CreateDirectory and then CreateFile with OPEN_EXISTING disposition and the flags FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_DELETE_ON_CLOSE. *C/POSIX API (undocumented)* Call os.mkdir and then os.open with the flags O_OBTAIN_DIR (0x2000) and O_TEMPORARY. (O_OBTAIN_DIR requires the Universal CRT, which is used by CPython 3.5+.) From sjatkins at gmail.com Thu Sep 6 20:42:48 2018 From: sjatkins at gmail.com (sjatkins at gmail.com) Date: Thu, 6 Sep 2018 17:42:48 -0700 (PDT) Subject: PEP 526 - var annotations and the spirit of python In-Reply-To: References: Message-ID: On Sunday, July 1, 2018 at 10:06:49 AM UTC-7, Abdur-Rahmaan Janhangeer wrote: > was viewing pep526, so, finally, python cannot do without hinting the type > as other languages? > will python finally move to > int x = 3 where int is a pre annotation? > > i am not arguing it's usefulness but rather, does it fit with python? > > Abdur-Rahmaan Janhangeer > https://github.com/Abdur-rahmaanJ Sigh. I came to python to escape type declaration jails and the infinite hair splitting of type inference systems. I am not at all happy to see this stuff in python code. From jfong at ms4.hinet.net Thu Sep 6 21:43:45 2018 From: jfong at ms4.hinet.net (Jach Fong) Date: Fri, 7 Sep 2018 09:43:45 +0800 Subject: Debug script under pdb, how to avoid a bunch of errors caused by the exit()? In-Reply-To: <8ee226fd-c482-84ad-1d22-fc8847843221@yahoo.com.au> References: <68c6a650-9515-078a-a009-8092511e6001@ms4.hinet.net> <8ee226fd-c482-84ad-1d22-fc8847843221@yahoo.com.au> Message-ID: <6c0ad82c-7847-a822-8b13-39afb776b8b3@ms4.hinet.net> I tried the following tests under pdb, 1. WinPython 3.6.6 on Vista, still saw those errors. 2. Python 3.4 on Win7, still saw those errors. 3. Python 3.6.3 on Win7, it's fine, no errors. Hmmm... seems both Python and OS are related? --Jach Peter via Python-list at 2018/9/7 AM 06:33 wrote: > I'm on 3.7.0 on Win 10, and get a different result. No traceback. > Perhaps it's a bug in 3.4 that was fixed subsequently. > > C:\test> py -m pdb bugInPDB.py > > c:\test\buginpdb.py(1)() > -> password = 'bad' > (Pdb) tbreak 3 > Breakpoint 1 at c:\test\buginpdb.py:3 > (Pdb) cont > Deleted breakpoint 1 at c:\test\buginpdb.py:3 > > c:\test\buginpdb.py(3)() > -> print('bad password') > (Pdb) cont > bad password > The program exited via sys.exit(). Exit status: None > > c:\test\buginpdb.py(1)() > -> password = 'bad' > (Pdb) q > > C:\test> > > On 6/09/2018 7:38 PM, Jach Fong wrote: >> Here the script file, test0.py: >> -------------------------- >> password = 'bad' >> if password == 'bad': >> ??? print('bad password') >> ??? exit() >> else: >> ??? print('good password') >> >> print('something else to do') >> -------------------- >> >> ??? When running it under Python3.4 Windows Vista, no problem at all. >> >> D:\Works\Python>py test0.py >> bad password >> >> ??? But if debug it under pdb: >> >> D:\Works\Python>py -m pdb test0.py >> > d:\works\python\test0.py(1)() >> -> password = 'bad' >> (Pdb) tbreak 3 >> Breakpoint 1 at d:\works\python\test0.py:3 >> (Pdb) cont >> Deleted breakpoint 1 at d:\works\python\test0.py:3 >> > d:\works\python\test0.py(3)() >> -> print('bad password') >> (Pdb) cont >> bad password >> The program exited via sys.exit(). Exit status: None >> > d:\works\python\test0.py(1)() >> -> password = 'bad' >> (Pdb) Traceback (most recent call last): >> ? File "C:\Python34\lib\pdb.py", line 1661, in main >> ??? pdb._runscript(mainpyfile) >> ? File "C:\Python34\lib\pdb.py", line 1542, in _runscript >> ??? self.run(statement) >> ? File "C:\Python34\lib\bdb.py", line 431, in run >> ??? exec(cmd, globals, locals) >> ? File "", line 1, in >> ? File "d:\works\python\test0.py", line 1, in >> ??? password = 'bad' >> ? File "d:\works\python\test0.py", line 1, in >> ??? password = 'bad' >> ? File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch >> ??? return self.dispatch_line(frame) >> ? File "C:\Python34\lib\bdb.py", line 66, in dispatch_line >> ??? self.user_line(frame) >> ? File "C:\Python34\lib\pdb.py", line 259, in user_line >> ??? self.interaction(frame, None) >> ? File "C:\Python34\lib\pdb.py", line 346, in interaction >> ??? self._cmdloop() >> ? File "C:\Python34\lib\pdb.py", line 319, in _cmdloop >> ??? self.cmdloop() >> ? File "C:\Python34\lib\cmd.py", line 126, in cmdloop >> ??? line = input(self.prompt) >> ValueError: I/O operation on closed file. >> Uncaught exception. Entering post mortem debugging >> Running 'cont' or 'step' will restart the program >> > c:\python34\lib\cmd.py(126)cmdloop() >> -> line = input(self.prompt) >> (Pdb) Traceback (most recent call last): >> ? File "C:\Python34\lib\pdb.py", line 1661, in main >> ??? pdb._runscript(mainpyfile) >> ? File "C:\Python34\lib\pdb.py", line 1542, in _runscript >> ??? self.run(statement) >> ? File "C:\Python34\lib\bdb.py", line 431, in run >> ??? exec(cmd, globals, locals) >> ? File "", line 1, in >> ? File "d:\works\python\test0.py", line 1, in >> ??? password = 'bad' >> ? File "d:\works\python\test0.py", line 1, in >> ??? password = 'bad' >> ? File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch >> ??? return self.dispatch_line(frame) >> ? File "C:\Python34\lib\bdb.py", line 66, in dispatch_line >> ??? self.user_line(frame) >> ? File "C:\Python34\lib\pdb.py", line 259, in user_line >> ??? self.interaction(frame, None) >> ? File "C:\Python34\lib\pdb.py", line 346, in interaction >> ??? self._cmdloop() >> ? File "C:\Python34\lib\pdb.py", line 319, in _cmdloop >> ??? self.cmdloop() >> ? File "C:\Python34\lib\cmd.py", line 126, in cmdloop >> ??? line = input(self.prompt) >> ValueError: I/O operation on closed file. >> >> During handling of the above exception, another exception occurred: >> >> 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 "C:\Python34\lib\pdb.py", line 1688, in >> ??? pdb.main() >> ? File "C:\Python34\lib\pdb.py", line 1680, in main >> ??? pdb.interaction(None, t) >> ? File "C:\Python34\lib\pdb.py", line 346, in interaction >> ??? self._cmdloop() >> ? File "C:\Python34\lib\pdb.py", line 319, in _cmdloop >> ??? self.cmdloop() >> ? File "C:\Python34\lib\cmd.py", line 126, in cmdloop >> ??? line = input(self.prompt) >> ValueError: I/O operation on closed file. >> >> D:\Works\Python> >> >> ??? How to get rid of these? >> >> Best Regards, >> Jach Fong >> >> >> --- >> This email has been checked for viruses by Avast antivirus software. >> https://www.avast.com/antivirus >> >> > > From steve+comp.lang.python at pearwood.info Thu Sep 6 21:56:13 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Fri, 7 Sep 2018 01:56:13 +0000 (UTC) Subject: Why emumerated list is empty on 2nd round of print? References: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> Message-ID: On Thu, 06 Sep 2018 11:50:17 -0700, Viet Nguyen via Python-list wrote: > If I do this "aList = enumerate(numList)", isn't it > stored permanently in aList now? Yes, but the question is "what is *it* that is stored? The answer is, it isn't a list, despite the name you choose. It is an enumerate iterator object, and iterator objects can only be iterated over once. If you really, truly need a list, call the list constructor: aList = list(enumerate(numList)) but that's generally a strange thing to do. It is more common to just call enumerate when you need it, not to hold on to the reference for later. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From arj.python at gmail.com Thu Sep 6 22:25:15 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Fri, 7 Sep 2018 06:25:15 +0400 Subject: PEP 526 - var annotations and the spirit of python In-Reply-To: References: Message-ID: hey, greetings, how did you come across this thread? Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius From steve+comp.lang.python at pearwood.info Thu Sep 6 22:40:01 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Fri, 7 Sep 2018 02:40:01 +0000 (UTC) Subject: don't quite understand mailing list References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: On Thu, 06 Sep 2018 13:06:22 -0700, Ethan Furman wrote: > On 09/06/2018 12:42 PM, Reto Brunner wrote: > >> What do you think the link, which is attached to every email you >> receive from the list, is for? Listinfo sounds very promising, doesn't >> it? >> >> And if you actually go to it you'll find: "To unsubscribe from >> Python-list, get a password reminder, or change your subscription >> options enter your subscription email address" >> >> So how about you try that? > > Reto, your response is inappropriate. If you can't be kind and/or > respectful, let someone else respond. No it wasn't inappropriate, and your attack on Reto is uncalled for. Reto's answer was kind and infinitely more respectful than your unnecessary criticism. As far as I can tell, this is Reto's first post here. After your hostile and unwelcoming response, I wouldn't be surprised if it was his last. His answer was both helpful and an *amazingly* restrained and kind response to a stupid question[1] asked by somebody claiming to be an professional software engineer. It was not condescending or mean- spirited, as you said in another post, nor was it snarky. But even had the OP been a total beginner to computing, it was still a helpful response containing the information needed to solve their immediate problem (how to unsubscribe from the list) with just the *tiniest* (and appropriate) hint of reproach to encourage them to learn how to solve their own problems for themselves so that in future, they will be a better contributor to whatever discussion forums they might find themselves on. Ethan, you are a great contributor on many of the Python mailing lists, but your tone-policing is inappropriate, and your CoC banning of Rick and Bart back in July was an excessive and uncalled for misuse of moderator power. To my shame, I didn't say anything at the time, but I won't be intimidated any longer by fear of the CoC and accusations of incivility. I'm speaking up now because your reply to Reto is unwelcoming, unhelpful and disrespectful, and coming from a moderator who has been known to ban people, that makes it even more hostile. [1] Yes, there are such things as stupid questions. If your doctor asked you "remind me again, which end of the needle goes into your arm?" what would you do? -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From steve+comp.lang.python at pearwood.info Thu Sep 6 22:42:56 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Fri, 7 Sep 2018 02:42:56 +0000 (UTC) Subject: Object-oriented philosophy References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> Message-ID: On Thu, 06 Sep 2018 22:00:26 +0100, MRAB wrote: > On 2018-09-06 21:24, Michael F. Stemper wrote: [...] >> try: >> P_0s = xmlmodel.findall( 'RatedPower' )[0].text >> self.P_0 = float( P_0s ) >> except: [...] > A word of advice: don't use a "bare" except, i.e. one that doesn't > specify what exception(s) it should catch. Excellent advice! More here: https://realpython.com/the-most-diabolical-python-antipattern/ -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From marko at pacujo.net Fri Sep 7 00:39:33 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 07 Sep 2018 07:39:33 +0300 Subject: don't quite understand mailing list References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: <87k1nx2a62.fsf@elektro.pacujo.net> mm0fmf : > On 06/09/2018 21:06, Ethan Furman wrote: >> On 09/06/2018 12:42 PM, Reto Brunner wrote: >>> What do you think the link, which is attached to every email you >>> receive from the list, is for? Listinfo sounds very promising, >>> doesn't it? >>> >>> And if you actually go to it you'll find: "To unsubscribe from >>> Python-list, get a password reminder, or change your subscription >>> options enter your subscription email address" >>> >>> So how about you try that? >> >> Reto, your response is inappropriate. If you can't be kind and/or >> respectful, let someone else respond. > > Seriously if someone has a swanky signature advertising that they are > a rocket scientist viz. "Software Contractor, Missiles and Fire > Control" and yet doesn't know what a language runtime is or how > mailing lists work then they are asking for that kind of reply. I'm with Ethan on this one. There was nothing in the original posting that merited ridicule. Marko From dieter at handshake.de Fri Sep 7 01:50:12 2018 From: dieter at handshake.de (dieter) Date: Fri, 07 Sep 2018 07:50:12 +0200 Subject: OpenSSL error References: Message-ID: <875zzhsvor.fsf@handshake.de> Peng Yu writes: > ... > from OpenSSL import rand, crypto, SSL > File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSSL/SSL.py", > line 118, in > SSL_ST_INIT = _lib.SSL_ST_INIT > AttributeError: 'module' object has no attribute 'SSL_ST_INIT' That is strange. The "_lib" actually comes from "cryptography.hazmat.bindings._openssl". Apparently, it defines quite some of the SSL related constants but not "SSL_ST_INIT". A potential reason could be that a wrong version of the "cryptography" packages is used, maybe due to a bad "PYTHONPATH" or "sys.path" value. Import "cryptography" and look at its "__file__" to verify where is comes from. Another potential reason: the contents of "_lib" might depend on the openssl system library. Then an incompatible version of this library might cause the problem. From breamoreboy at gmail.com Fri Sep 7 07:26:21 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Fri, 7 Sep 2018 12:26:21 +0100 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: On 07/09/18 03:40, Steven D'Aprano wrote: > On Thu, 06 Sep 2018 13:06:22 -0700, Ethan Furman wrote: > >> On 09/06/2018 12:42 PM, Reto Brunner wrote: >> >>> What do you think the link, which is attached to every email you >>> receive from the list, is for? Listinfo sounds very promising, doesn't >>> it? >>> >>> And if you actually go to it you'll find: "To unsubscribe from >>> Python-list, get a password reminder, or change your subscription >>> options enter your subscription email address" >>> >>> So how about you try that? >> >> Reto, your response is inappropriate. If you can't be kind and/or >> respectful, let someone else respond. > > No it wasn't inappropriate, and your attack on Reto is uncalled for. > > Reto's answer was kind and infinitely more respectful than your > unnecessary criticism. As far as I can tell, this is Reto's first post > here. After your hostile and unwelcoming response, I wouldn't be > surprised if it was his last. > > His answer was both helpful and an *amazingly* restrained and kind > response to a stupid question[1] asked by somebody claiming to be an > professional software engineer. It was not condescending or mean- > spirited, as you said in another post, nor was it snarky. > > But even had the OP been a total beginner to computing, it was still a > helpful response containing the information needed to solve their > immediate problem (how to unsubscribe from the list) with just the > *tiniest* (and appropriate) hint of reproach to encourage them to learn > how to solve their own problems for themselves so that in future, they > will be a better contributor to whatever discussion forums they might > find themselves on. > > Ethan, you are a great contributor on many of the Python mailing lists, > but your tone-policing is inappropriate, and your CoC banning of Rick and > Bart back in July was an excessive and uncalled for misuse of moderator > power. > > To my shame, I didn't say anything at the time, but I won't be > intimidated any longer by fear of the CoC and accusations of incivility. > I'm speaking up now because your reply to Reto is unwelcoming, unhelpful > and disrespectful, and coming from a moderator who has been known to ban > people, that makes it even more hostile. > > > > > [1] Yes, there are such things as stupid questions. If your doctor asked > you "remind me again, which end of the needle goes into your arm?" what > would you do? > > +1000 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From alon.najman at gmail.com Fri Sep 7 07:52:46 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Fri, 7 Sep 2018 04:52:46 -0700 (PDT) Subject: I try to edit and find data from a text file with python 2.7 (data from stock market) Message-ID: <420beeb9-f894-44b2-ab89-db27cff48785@googlegroups.com> hi, I try to edit a text file with python 2.7: ***** AAPL ***** Date: September 07 2018 Time: 14:10:52 Price: ,068,407 Ask: None High: None Low: None Previous Close: ,068,407 Volume: $?227.35?/?$?221.30 Market Cap: 20.23 but when I write it to a file I get: {'previous_close': ',068,407', 'volume': u'$\xa0227.35\xa0/\xa0$\xa0221.30', 'market_cap': '20.23', 'price': ',068,407', 'high': 'None', 'ask': 'None', 'low': 'None', 'time': '14:15:45', 'date': 'September 07 2018', 'ticker': 'AAPL'} why is that? and how do I get the price value only? so I will have only that in a variable? for example the variable: Price. this is my code.. import csv import itertools from nasdaq_stock import nasdaq_stock x=str(nasdaq_stock.stock('AAPL')) with open("log.txt", "w") as text_file: text_file.write(format(x)) with open('log.txt', 'r') as in_file: lines = in_file.read().splitlines() stripped = [line.replace(","," ").split() for line in lines] grouped = itertools.izip(*[stripped]*1) with open('log.csv', 'w') as out_file: writer = csv.writer(out_file) writer.writerow(('title', 'intro', 'tagline')) for group in grouped: writer.writerows(group) #locate cell import csv def read_cell(x, y): with open('log.csv', 'r') as f: reader = csv.reader(f) y_count = 0 for n in reader: if y_count == y: cell = n[x] return cell y_count += 1 #I try to find the value of Price.. print (read_cell(2,3)) From catanaangelo at gmail.com Fri Sep 7 08:55:31 2018 From: catanaangelo at gmail.com (catanaangelo at gmail.com) Date: Fri, 7 Sep 2018 05:55:31 -0700 (PDT) Subject: I need help to put the output from terminal in a csv file Message-ID: <6ed6748d-3310-41e2-b66a-e12573c711ca@googlegroups.com> HI! I need help putting the output from terminal in a csv file. I work on linux and I have python 2.7.15. I am running a python program which also runs some shell scripts. I need to capture the output from the .sh scripts and put it nicely in a csv table. I am using "commands.getoutput('bash example.sh')" to capture the output of the scripts (I can use subprocess too if needed). The outputs looks something like this: In case of an error { "error" : { "body" : "The requested device is currently not online. "detail" : "Make sure to connect the device", "event" : 123456, "header" : "Device Unavailable (123456)" } } And in case of a good output it look similar but has "status :0" instead of event and ofc it does say that it passed the test. I need to export the results of the .sh tests in a csv file with my .py program. The boss expects a table with 3 columns. The first one with The title TEST which has the name of the tests (.sh scripts). The 2nd with PASS/FAIL (this is determined by the "status" : 0 output for some tests and with a number between 1 and 4000 for others (i used regex for this, but I struggle a bit here too) and the 3rd one which returns the Value ( 0 in case status is 0 or the number between 1 and 4000 for the other tests). I really need some ideas, I struggle for 3 days already using regex, commands, subprocess and watching tutorials. I just can't solve this yet, I really need some ideas. Much appreciated. From steve+comp.lang.python at pearwood.info Fri Sep 7 08:59:46 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Fri, 7 Sep 2018 12:59:46 +0000 (UTC) Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> <87in3ioq95.fsf@elektro.pacujo.net> Message-ID: On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > Chris Angelico : >> The request was to translate this into Python, not to slavishly imitate >> every possible semantic difference even if it won't actually affect >> behaviour. > > I trust Steven to be able to refactor the code into something more > likable. His only tripping point was the meaning of the "let" construct. Thanks for the vote of confidence :-) However I have a follow up question. Why the "let" construct in the first place? Is this just a matter of principle, "put everything in its own scope as a matter of precautionary code hygiene"? Because I can't see any advantage to the inner function: >>>> def isqrt(n): >>>> if n == 0: >>>> return 0 >>>> else: >>>> def f2398478957(r): >>>> if n < (2*r+1)**2: >>>> return 2*r >>>> else: >>>> return 2*r+1 >>>> return f2398478957(isqrt(n//4)) Sure, it ensures that r is in its own namespace. But why is that an advantage in a function so small? Perhaps its a SML functional- programming thing. Putting aside the observation that recursion may not be the best way to do this in Python, I don't think that the inner function is actually needed. We can just write: def isqrt(n): if n == 0: return 0 else: r = isqrt(n//4) if n < (2*r+1)**2: return 2*r else: return 2*r+1 By the way I got this from this paper: https://www.cs.uni-potsdam.de/ti/kreitz/PDF/03cucs-intsqrt.pdf -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From p.f.moore at gmail.com Fri Sep 7 10:10:10 2018 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 7 Sep 2018 15:10:10 +0100 Subject: Any SML coders able to translate this to Python? In-Reply-To: References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> <87in3ioq95.fsf@elektro.pacujo.net> Message-ID: On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano wrote: > > On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > > > Chris Angelico : > >> The request was to translate this into Python, not to slavishly imitate > >> every possible semantic difference even if it won't actually affect > >> behaviour. > > > > I trust Steven to be able to refactor the code into something more > > likable. His only tripping point was the meaning of the "let" construct. > > Thanks for the vote of confidence :-) > > However I have a follow up question. Why the "let" construct in the first > place? Is this just a matter of principle, "put everything in its own > scope as a matter of precautionary code hygiene"? Because I can't see any > advantage to the inner function: My impression is that this is just functional programming "good style". As you say, it's not needed, it's just "keep things valid in the smallest range possible". Probably also related to the mathematical style of naming sub-expressions. Also, it's probably the case that in a (compiled) functional language like SML, the compiler can optimise this to avoid any actual inner function, leaving it as nothing more than a temporary name. Paul From rhodri at kynesim.co.uk Fri Sep 7 10:14:34 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Fri, 7 Sep 2018 15:14:34 +0100 Subject: I need help to put the output from terminal in a csv file In-Reply-To: <6ed6748d-3310-41e2-b66a-e12573c711ca@googlegroups.com> References: <6ed6748d-3310-41e2-b66a-e12573c711ca@googlegroups.com> Message-ID: On 07/09/18 13:55, catanaangelo at gmail.com wrote: > HI! I need help putting the output from terminal in a csv file. I work on linux and I have python 2.7.15. I am running a python program which also runs some shell scripts. > > I need to capture the output from the .sh scripts and put it nicely in a csv table. I am using "commands.getoutput('bash example.sh')" to capture the output of the scripts (I can use subprocess too if needed). > > The outputs looks something like this: > In case of an error > { > "error" : { > "body" : "The requested device is currently not online. > "detail" : "Make sure to connect the device", > "event" : 123456, > "header" : "Device Unavailable (123456)" > } > } > And in case of a good output it look similar but has "status :0" instead of event and ofc it does say that it passed the test. > > I need to export the results of the .sh tests in a csv file with my .py program. > The boss expects a table with 3 columns. The first one with The title TEST which has the name of the tests (.sh scripts). The 2nd with PASS/FAIL (this is determined by the "status" : 0 output for some tests and with a number between 1 and 4000 for others (i used regex for this, but I struggle a bit here too) and the 3rd one which returns the Value ( 0 in case status is 0 or the number between 1 and 4000 for the other tests). > > I really need some ideas, I struggle for 3 days already using regex, commands, subprocess and watching tutorials. > > I just can't solve this yet, I really need some ideas. From what you've said above, your basic problem is that you need to parse the output looking for lines containing '"status": ' where is some number. Let's assume that you have run one of the shell scripts and captured its output into a string. The first thing to do is to split the output into lines, which you can do with the "split()" string method. Then check each line in turn. If it contains a colon it may be what you want. "split()" the line at the colon and look at the first half. Once you have "strip()"ed off the spaces at the beginning and the end, is it "status"? If so, you've got your pass and the VALUE you want is in the second half. I hope that helps. -- Rhodri James *-* Kynesim Ltd From brian.j.oney at googlemail.com Fri Sep 7 10:17:44 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Fri, 07 Sep 2018 16:17:44 +0200 Subject: I need help to put the output from terminal in a csv file In-Reply-To: <6ed6748d-3310-41e2-b66a-e12573c711ca@googlegroups.com> References: <6ed6748d-3310-41e2-b66a-e12573c711ca@googlegroups.com> Message-ID: <1536329864.14649.1.camel@gmail.com> Please study the following to get you started. It looks like JSON output that you are dealing, which is good. I added a ", to the "body"-line, because I assume that you botched that when giving an example. ```python #!/usr/bin/env python import json output = ''' { ???"error" : { ??????"body" : "The requested device is currently not online.", ??????"detail" : "Make sure to connect the device", ??????"event" : 123456, ??????"header" : "Device Unavailable (123456)" ???} } ''' # help(json.loads) parsed = json.loads(output) if type(parsed) == dict: ????if type(parsed['error']) == dict: ????????print("yay!") ``` HTH From neilc at norwich.edu Fri Sep 7 10:39:02 2018 From: neilc at norwich.edu (Neil Cerutti) Date: 7 Sep 2018 14:39:02 GMT Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> <87in3ioq95.fsf@elektro.pacujo.net> Message-ID: On 2018-09-07, Steven D'Aprano wrote: > On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > >> Chris Angelico : >>> The request was to translate this into Python, not to slavishly imitate >>> every possible semantic difference even if it won't actually affect >>> behaviour. >> >> I trust Steven to be able to refactor the code into something more >> likable. His only tripping point was the meaning of the "let" construct. > > Thanks for the vote of confidence :-) > > However I have a follow up question. Why the "let" construct in > the first place? Is this just a matter of principle, "put > everything in its own scope as a matter of precautionary code > hygiene"? Because I can't see any advantage to the inner > function: let is a convenient way for functional languages to introduce new names for things. You'd consider it wherever you'd consider assigning something to a new name in Python. In this case, it was probably just to avoid writing out that square root calculation twice. Though you could use lambda calculus directly instead, that might be considered painful, and the first thing you'd then do is write a let macro. -- Neil Cerutti From jqian at tibco.com Fri Sep 7 11:13:03 2018 From: jqian at tibco.com (Jason Qian) Date: Fri, 7 Sep 2018 11:13:03 -0400 Subject: ModuleNotFoundError: No module named 'encodings' In-Reply-To: References: Message-ID: Thanks Thomas, You are right, this seems the Python home configuration issue. One more question. Is there a way I can catch the error ( Fatal Python error: initfsencoding: ..) as exception in the c code ? try{ Py_Initialize(); }catch(xxx) { } Thanks On Thu, Sep 6, 2018 at 5:29 PM, Thomas Jollans wrote: > On 09/06/2018 09:46 PM, Jason Qian via Python-list wrote: > >> Hi >> >> Need some help. >> >> I have a C++ application that invokes Python. >> >> ... >> Py_SetPythonHome("python_path"); >> > > This isn't actually a line in your code, is it? For one thing, > Py_SetPythonHome expects a wchar_t*... > > Py_Initialize(); >> >> This works fine on Python 3.6.4 version, but got errors on Python 3.7.0 >> when calling Py_Initialize(), >> >> Fatal Python error: initfsencoding: unable to load the file system codec >> ModuleNotFoundError: No module named 'encodings' >> > > So, Python can't find a core module. This either means your Python 3.7 > build is broken, or it doesn't know where to look. Perhaps whatever it is > you're actually passing to Py_SetPythonHome needs to be changed to point to > the right place? (i.e. maybe you're giving it the location of the Python > 3.6 library rather than the Python 3.7 one) > > -- Thomas > -- > https://mail.python.org/mailman/listinfo/python-list > From Joseph.Schachner at Teledyne.com Fri Sep 7 11:21:50 2018 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Fri, 7 Sep 2018 15:21:50 +0000 Subject: Why emumerated list is empty on 2nd round of print? In-Reply-To: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> References: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> Message-ID: <060f64ad527248f2aeb4ab62c9a3182d@Teledyne.com> The question "If I do this "aList = enumerate(numList)", isn't it stored permanently in aList now? I see your point to use it directly, but just in case I do need to hang onto it from one loop to another, then how is that done?" Reflects that you are thinking in a C++ kind of way I think. When you declare a variable name and assign to it, in Python what you have done is assigned to the name a reference to the content. It is never true that the content is "in" the variable. The variable does not have storage for what you assign to it. That content is stored somewhere, but the variable just has a reference to it. So, aList = enumerate(numList) creates an iterator, and aList is a reference to that iterator. It is not "in" aLIst. Despite the name, aList does not contain a list. (See above). Now, on to the second part: the problem you showed - that you can only loop through aList:print(i,j) once - is BECAUSE you hung onto it from one loop to another. Once the iterator is exhausted, it's exhausted. Think of another more common iterator you've probably used: file = open("filename.txt") for line in file; print line On EOF the iterator throws an exception (that is expected), the for loop catches the exception and exits. Files can be "rewound" by file.seek(0). But other than that, once you have reached EOF, you have reached EOF. It doesn't automagically rewind. If you do another for line in file; print line it will not print anything. Exactly the same behavior as you are surprised about for the enumerate iterator. I don?t even know if there is a method to reset the enumerate iterator. If there isn't one, then you should not hold the iterator from one loop to the next, you have to make another one. --- Joe S. -----Original Message----- From: Viet Nguyen Sent: Thursday, September 6, 2018 2:50 PM To: python-list at python.org Subject: Re: Why emumerated list is empty on 2nd round of print? On Thursday, September 6, 2018 at 10:34:19 AM UTC-7, Chris Angelico wrote: > On Fri, Sep 7, 2018 at 3:26 AM, Viet Nguyen via Python-list > wrote: > >>>> numList > > [2, 7, 22, 30, 1, 8] > > > >>>> aList = enumerate(numList) > > > >>>> for i,j in aList:print(i,j) > > > > 0 2 > > 1 7 > > 2 22 > > 3 30 > > 4 1 > > 5 8 > > > >>>> for i,j in aList:print(i,j) > > > >>>> > > Because it's not an enumerated list, it's an enumerated iterator. > Generally, you'll just use that directly in the loop: > > for i, value in enumerate(numbers): > > There's generally no need to hang onto it from one loop to another. > > ChrisA Thanks ChrisA. If I do this "aList = enumerate(numList)", isn't it stored permanently in aList now? I see your point to use it directly, but just in case I do need to hang onto it from one loop to another, then how is that done? Anyway I think I'm ok and I got what I need for now. From tjol at tjol.eu Fri Sep 7 11:46:03 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 7 Sep 2018 17:46:03 +0200 Subject: ModuleNotFoundError: No module named 'encodings' In-Reply-To: References: Message-ID: <53f71719-5cd5-7a7b-b4e6-25b34f48e82e@tjol.eu> On 2018-09-07 17:13, Jason Qian via Python-list wrote: > Thanks Thomas, > > You are right, this seems the Python home configuration issue. > > One more question. > > Is there a way I can catch the error ( Fatal Python error: initfsencoding: > ..) as exception in the c code ? It's a fatal error, which means it aborts. As I'm sure you know, C doesn't have exceptions. You might be able to handle SIGABRT, I'm not sure. > > try{ > Py_Initialize(); > }catch(xxx) > { > > } > > > Thanks > > > > On Thu, Sep 6, 2018 at 5:29 PM, Thomas Jollans wrote: > >> On 09/06/2018 09:46 PM, Jason Qian via Python-list wrote: >> >>> Hi >>> >>> Need some help. >>> >>> I have a C++ application that invokes Python. >>> >>> ... >>> Py_SetPythonHome("python_path"); >>> >> >> This isn't actually a line in your code, is it? For one thing, >> Py_SetPythonHome expects a wchar_t*... >> >> Py_Initialize(); >>> >>> This works fine on Python 3.6.4 version, but got errors on Python 3.7.0 >>> when calling Py_Initialize(), >>> >>> Fatal Python error: initfsencoding: unable to load the file system codec >>> ModuleNotFoundError: No module named 'encodings' >>> >> >> So, Python can't find a core module. This either means your Python 3.7 >> build is broken, or it doesn't know where to look. Perhaps whatever it is >> you're actually passing to Py_SetPythonHome needs to be changed to point to >> the right place? (i.e. maybe you're giving it the location of the Python >> 3.6 library rather than the Python 3.7 one) >> >> -- Thomas >> -- >> https://mail.python.org/mailman/listinfo/python-list >> From __peter__ at web.de Fri Sep 7 12:25:33 2018 From: __peter__ at web.de (Peter Otten) Date: Fri, 07 Sep 2018 18:25:33 +0200 Subject: I try to edit and find data from a text file with python 2.7 (data from stock market) References: <420beeb9-f894-44b2-ab89-db27cff48785@googlegroups.com> Message-ID: alon.najman at gmail.com wrote: > hi, > > I try to edit a text file with python 2.7: > > ***** AAPL ***** > Date: September 07 2018 > Time: 14:10:52 > Price: ,068,407 > Ask: None > High: None > Low: None > Previous Close: ,068,407 > Volume: $ 227.35 / $ 221.30 > Market Cap: 20.23 It looks like the author of the nasdaq_stock module was interested in a quick and dirty tool for personal needs rather than a clean library for general use. The text quoted above is printed implicitly by the stock() function. To suppress it you have to modify that function or to redirect sys.stdout. Another problem with the code is that it may swallow arbitrary exceptions. Therefore my error message below has to be vague. > but when I write it to a file I get: > {'previous_close': ',068,407', 'volume': > {u'$\xa0227.35\xa0/\xa0$\xa0221.30', 'market_cap': '20.23', 'price': > {',068,407', 'high': 'None', 'ask': 'None', 'low': 'None', 'time': > {'14:15:45', 'date': 'September 07 2018', 'ticker': 'AAPL'} > > why is that? If all goes well the stock function returns the above dict. > and how do I get the price value only? so I will have only > that in a variable? for example the variable: Price. import sys from nasdaq_stock import nasdaq_stock stock_info = nasdaq_stock.stock('AAPL') print if stock_info: price = stock_info["price"] ticker = stock_info["ticker"] print "Ticker:", ticker, "Price:", price else: print >> sys.stderr, "Something went wrong" From p.f.moore at gmail.com Fri Sep 7 12:33:38 2018 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 7 Sep 2018 17:33:38 +0100 Subject: Any SML coders able to translate this to Python? In-Reply-To: References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> <87in3ioq95.fsf@elektro.pacujo.net> Message-ID: On Fri, 7 Sep 2018 at 15:10, Paul Moore wrote: > > On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano > wrote: > > > > On Thu, 06 Sep 2018 13:48:54 +0300, Marko Rauhamaa wrote: > > > > > Chris Angelico : > > >> The request was to translate this into Python, not to slavishly imitate > > >> every possible semantic difference even if it won't actually affect > > >> behaviour. > > > > > > I trust Steven to be able to refactor the code into something more > > > likable. His only tripping point was the meaning of the "let" construct. > > > > Thanks for the vote of confidence :-) > > > > However I have a follow up question. Why the "let" construct in the first > > place? Is this just a matter of principle, "put everything in its own > > scope as a matter of precautionary code hygiene"? Because I can't see any > > advantage to the inner function: > > My impression is that this is just functional programming "good > style". As you say, it's not needed, it's just "keep things valid in > the smallest range possible". Probably also related to the > mathematical style of naming sub-expressions. Also, it's probably the > case that in a (compiled) functional language like SML, the compiler > can optimise this to avoid any actual inner function, leaving it as > nothing more than a temporary name. It's also worth noting that functional languages don't typically have variables or assignments (more accurately, such things aren't fundamental to the programming model the way they are in imperative languages). So although technically let introduces a new scope, in practical terms it's basically just "how functional programmers do assignments". Paul From marko at pacujo.net Fri Sep 7 13:12:08 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 07 Sep 2018 20:12:08 +0300 Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> <87in3ioq95.fsf@elektro.pacujo.net> Message-ID: <871sa5nsev.fsf@elektro.pacujo.net> Paul Moore : > On Fri, 7 Sep 2018 at 15:10, Paul Moore wrote: >> >> On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano >> wrote: >> > However I have a follow up question. Why the "let" construct in the >> > first place? Is this just a matter of principle, "put everything in >> > its own scope as a matter of precautionary code hygiene"? Because I >> > can't see any advantage to the inner function: >> >> My impression is that this is just functional programming "good >> style". [...] > > It's also worth noting that functional languages don't typically have > variables or assignments (more accurately, such things aren't > fundamental to the programming model the way they are in imperative > languages). So although technically let introduces a new scope, in > practical terms it's basically just "how functional programmers do > assignments". To put it succinctly, SML does it because there's no other way to introduce local variables. IOW, in many functional programming languages, the only local variables are function arguments. And if you want to go really functional, you can't even alter bindings. So to implement a for loop in Python under these constraints, you would implement: def f(n): sum = 0 m = 1 for i in range(n): sum += m * i if sum % m == 0: m += 1 return sum like this: def f(n): def auxf1(sum, m, i): if i == n: return sum else: def auxf2(sum, m, i): if sum % m == 0: return auxf1(sum, m + 1, i) else: return auxf1(sum, m, i) return auxf2(sum + m * i, m, i + 1) return auxf1(0, 1, 0) cheating slightly with locally named functions. If cheating is not allowed, you will need a Y combinator construct... Marko From catanaangelo at gmail.com Fri Sep 7 13:15:45 2018 From: catanaangelo at gmail.com (catanaangelo at gmail.com) Date: Fri, 7 Sep 2018 10:15:45 -0700 (PDT) Subject: I need help to put the output from terminal in a csv file In-Reply-To: <6ed6748d-3310-41e2-b66a-e12573c711ca@googlegroups.com> References: <6ed6748d-3310-41e2-b66a-e12573c711ca@googlegroups.com> Message-ID: <49cbb246-5ef9-4e95-b83b-aef4cfb758db@googlegroups.com> Thanks a lot, I've managed to make it work they way I wanted From oscar.j.benjamin at gmail.com Fri Sep 7 14:33:39 2018 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Fri, 7 Sep 2018 19:33:39 +0100 Subject: Why emumerated list is empty on 2nd round of print? In-Reply-To: <060f64ad527248f2aeb4ab62c9a3182d@Teledyne.com> References: <0fbcf3f3-fffa-4309-93e3-d37b76584035@googlegroups.com> <060f64ad527248f2aeb4ab62c9a3182d@Teledyne.com> Message-ID: On Fri, 7 Sep 2018 at 16:25, Schachner, Joseph wrote: >... > Now, on to the second part: the problem you showed - that you can only loop through aList:print(i,j) once - is BECAUSE you hung onto it from one loop to another. Once the iterator is exhausted, it's exhausted. > > Think of another more common iterator you've probably used: file = open("filename.txt") for line in file; print line > On EOF the iterator throws an exception (that is expected), the for loop catches the exception and exits. > Files can be "rewound" by file.seek(0). But other than that, once you have reached EOF, you have reached EOF. It doesn't automagically rewind. If you do another for line in file; print line it will not print anything. Exactly the same behavior as you are surprised about for the enumerate iterator. > > I don?t even know if there is a method to reset the enumerate iterator. If there isn't one, then you should not hold the iterator from one loop to the next, you have to make another one. There is no way to reset the enumerate iterator because it would not be possible in general. You can use enumerate with any iterable including an iterator that cannot itself be reset: for lineno, line in enumerate(fileobj, 1): print(lineno, line) In this case enumerate cannot reset the fileobj iterator there would be no way to implement enumerate such that it is always resettable. (Even if enumerate knew it was a file object that wouldn't necessarily make it seekable e.g. if it was a FIFO). You *could* however have enumerate return an object that was re-iterable whenever its underlying iterable is (but that's not how it is designed): class enumerate: def __init__(self, iterable, start=0): self.iterable = iterable self.start = start def __iter__(self): count = self.start for val in self.iterable: # Implicitly calls iter on iterable again yield count, val count += 1 -- Oscar From marko at pacujo.net Fri Sep 7 14:47:32 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 07 Sep 2018 21:47:32 +0300 Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> <87in3ioq95.fsf@elektro.pacujo.net> <871sa5nsev.fsf@elektro.pacujo.net> Message-ID: <87ftyl16wr.fsf@elektro.pacujo.net> Marko Rauhamaa : > def f(n): > def auxf1(sum, m, i): > if i == n: > return sum > else: > def auxf2(sum, m, i): > if sum % m == 0: > return auxf1(sum, m + 1, i) > else: > return auxf1(sum, m, i) > return auxf2(sum + m * i, m, i + 1) > return auxf1(0, 1, 0) > > cheating slightly with locally named functions. > > If cheating is not allowed, you will need a Y combinator construct... ... and here's the same function without cheating: f = (lambda n: (lambda auxf1, auxf2: auxf1(auxf1, auxf2, 0, 1, 0))( lambda auxf1, auxf2, sum, m, i: sum if i == n else auxf2(auxf1, auxf2, sum + m * i, m, i + 1), lambda auxf1, auxf2, sum, m, i: auxf1(auxf1, auxf2, sum, m + 1, i) if sum % m == 0 else auxf1(auxf1, auxf2, sum, m, i))) ... or replacing the conditional with arrays: f = (lambda n: (lambda auxf1, auxf2: auxf1(auxf1, auxf2, 0, 1, 0))( lambda auxf1, auxf2, sum, m, i: [lambda m: auxf2(auxf1, auxf2, sum + m * i, m, i + 1), lambda m: sum][i == n](m), lambda auxf1, auxf2, sum, m, i: [lambda m: auxf1(auxf1, auxf2, sum, m, i), lambda m: auxf1(auxf1, auxf2, sum, m + 1, i)][sum % m == 0](m))) It is possible to get rid of the arrays and numbers, too. Combinatory logic would allow us to get rid of the local variables. At the pinnacle of functional programming is iota: The iota programming language has only one primitive value, the Swiss-army-knife function ?, which can express Life, Universe and Everything: ? = lambda f: (f(lambda x: lambda y: lambda z: (x(z))(y(z))))( lambda q: lambda i: q) Marko From michael.stemper at gmail.com Fri Sep 7 15:51:20 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Fri, 7 Sep 2018 14:51:20 -0500 Subject: Object-oriented philosophy In-Reply-To: References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> Message-ID: On 2018-09-06 16:00, MRAB wrote: > On 2018-09-06 21:24, Michael F. Stemper wrote: >> On 2018-09-06 09:35, Rhodri James wrote: >>> Is it worth creating the superclass in Python?? It sounds like it's a >>> bit marginal in your case.? I'm not that seasoned in object-oriented >>> design either, but my yardstick would be how much common code does it >>> eliminate? >> >> About half a dozen lines. Here's the common part: >> >> def __init__( self, xmlmodel, V, id ): >> >> ?? try: >> ???? P_0s = xmlmodel.findall( 'RatedPower' )[0].text >> ???? self.P_0 = float( P_0s ) >> ?? except: >> ???? Utility.DataErr( "Power not specified for %s load" % (id) ) >> ?? if self.P_0<=0.0: >> ???? Utility.DataErr( "Power for %s load must be postive, not %s" \ >> ?????? % (id,P_0s) ) > A word of advice: don't use a "bare" except, i.e. one that doesn't > specify what exception(s) it should catch. Given that I moved the first line ("P_0s = ...") out of the "try" clause, does this align with your advice? # If pre-validation has been run, guaranteed to have RatedPower P_0s = xmlmodel.findall( 'RatedPower' )[0].text try: self.P_0 = float( P_0s ) except ValueError: Utility.DataErr( "Power for %s load, '%s', not parsable" \ % (id,P_0s) ) if self.P_0<=0.0: Utility.DataErr( "Power for %s load must be postive, not %s" \ % (id,P_0s) ) > Your try...except above will catch _any_ exception. If you misspelled a > name in the 'try' part, it would raise NameError, which would also be > caught. In another case where I had a "bare exception", I was using it to see if something was defined and substitute a default value if it wasn't. Have I cleaned this up properly? try id = xmlmodel.attrib['name'] except KeyError: id = "constant power" (Both changes appear to meet my intent, I'm more wondering about how pythonic they are.) -- Michael F. Stemper Isaiah 10:1-2 From michael.stemper at gmail.com Fri Sep 7 16:08:48 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Fri, 7 Sep 2018 15:08:48 -0500 Subject: Object-oriented philosophy In-Reply-To: References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> Message-ID: On 2018-09-07 14:51, Michael F. Stemper wrote: > On 2018-09-06 16:00, MRAB wrote: >> On 2018-09-06 21:24, Michael F. Stemper wrote: >> A word of advice: don't use a "bare" except, i.e. one that doesn't >> specify what exception(s) it should catch. > In another case where I had a "bare exception", I was using it to see if > something was defined and substitute a default value if it wasn't. Have > I cleaned this up properly? > > try > id = xmlmodel.attrib['name'] > except KeyError: > id = "constant power" Never mind! After I continued testing, I realized that the above should have been written as: if 'name' in xmlmodel.attrib: id = xmlmodel.attrib['name'] else: id = "constant power" -- Michael F. Stemper Always use apostrophe's and "quotation marks" properly. From python at mrabarnett.plus.com Fri Sep 7 16:39:37 2018 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 7 Sep 2018 21:39:37 +0100 Subject: Object-oriented philosophy In-Reply-To: References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> Message-ID: <5186fb9b-3d75-66a9-3715-4039b776c1a1@mrabarnett.plus.com> On 2018-09-07 20:51, Michael F. Stemper wrote: > On 2018-09-06 16:00, MRAB wrote: >> On 2018-09-06 21:24, Michael F. Stemper wrote: >>> On 2018-09-06 09:35, Rhodri James wrote: > >>>> Is it worth creating the superclass in Python?? It sounds like it's a >>>> bit marginal in your case.? I'm not that seasoned in object-oriented >>>> design either, but my yardstick would be how much common code does it >>>> eliminate? >>> >>> About half a dozen lines. Here's the common part: >>> >>> def __init__( self, xmlmodel, V, id ): >>> >>> ?? try: >>> ???? P_0s = xmlmodel.findall( 'RatedPower' )[0].text >>> ???? self.P_0 = float( P_0s ) >>> ?? except: >>> ???? Utility.DataErr( "Power not specified for %s load" % (id) ) >>> ?? if self.P_0<=0.0: >>> ???? Utility.DataErr( "Power for %s load must be postive, not %s" \ >>> ?????? % (id,P_0s) ) > >> A word of advice: don't use a "bare" except, i.e. one that doesn't >> specify what exception(s) it should catch. > > Given that I moved the first line ("P_0s = ...") out of the "try" > clause, does this align with your advice? > > # If pre-validation has been run, guaranteed to have RatedPower > P_0s = xmlmodel.findall( 'RatedPower' )[0].text > try: > self.P_0 = float( P_0s ) > except ValueError: > Utility.DataErr( "Power for %s load, '%s', not parsable" \ > % (id,P_0s) ) > if self.P_0<=0.0: > Utility.DataErr( "Power for %s load must be postive, not %s" \ > % (id,P_0s) ) > That's better. However, if P_0s can't be parse as a float, then self.P_0 will be unchanged (assuming that it already has a value, of course). Is it OK that if there's no rated power, or it's invalid, it'll report it and continue with whatever value, if any, that it already has? >> Your try...except above will catch _any_ exception. If you misspelled a >> name in the 'try' part, it would raise NameError, which would also be >> caught. > > In another case where I had a "bare exception", I was using it to see if > something was defined and substitute a default value if it wasn't. Have > I cleaned this up properly? > > try > id = xmlmodel.attrib['name'] > except KeyError: > id = "constant power" > > (Both changes appear to meet my intent, I'm more wondering about how > pythonic they are.) > There's an alternative that's recommended when the key is often absent: id = xmlmodel.attrib.get('name', "constant power") Catching an exception has a cost, so the usual advice is to use .get when the key is often absent, or catch KeyError when the key is usually present but occasionally is absent and you can provide a default value. From python at mrabarnett.plus.com Fri Sep 7 16:48:39 2018 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 7 Sep 2018 21:48:39 +0100 Subject: Object-oriented philosophy In-Reply-To: References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> Message-ID: <5e972014-845c-2814-32f0-08888c7fba6d@mrabarnett.plus.com> On 2018-09-07 21:08, Michael F. Stemper wrote: > On 2018-09-07 14:51, Michael F. Stemper wrote: >> On 2018-09-06 16:00, MRAB wrote: >>> On 2018-09-06 21:24, Michael F. Stemper wrote: > >>> A word of advice: don't use a "bare" except, i.e. one that doesn't >>> specify what exception(s) it should catch. > >> In another case where I had a "bare exception", I was using it to see if >> something was defined and substitute a default value if it wasn't. Have >> I cleaned this up properly? >> >> try >> id = xmlmodel.attrib['name'] >> except KeyError: >> id = "constant power" > > Never mind! After I continued testing, I realized that the above > should have been written as: > > if 'name' in xmlmodel.attrib: > id = xmlmodel.attrib['name'] > else: > id = "constant power" > > > That's actually _less_ Pythonic. Have a look at the entries "EAFP" and "LBYL" here: https://docs.python.org/3/glossary.html From michael.stemper at gmail.com Fri Sep 7 17:07:06 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Fri, 7 Sep 2018 16:07:06 -0500 Subject: Object-oriented philosophy In-Reply-To: References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> <5186fb9b-3d75-66a9-3715-4039b776c1a1@mrabarnett.plus.com> Message-ID: On 2018-09-07 15:39, MRAB wrote: > On 2018-09-07 20:51, Michael F. Stemper wrote: >> On 2018-09-06 16:00, MRAB wrote: >>> A word of advice: don't use a "bare" except, i.e. one that doesn't >>> specify what exception(s) it should catch. >> >> Given that I moved the first line ("P_0s = ...") out of the "try" >> clause, does this align with your advice? >> >> ? # If pre-validation has been run, guaranteed to have RatedPower >> ? P_0s = xmlmodel.findall( 'RatedPower' )[0].text >> ? try: >> ??? self.P_0 = float( P_0s ) >> ? except ValueError: >> ??? Utility.DataErr( "Power for %s load, '%s', not parsable" \ >> ????? % (id,P_0s) ) >> ? if self.P_0<=0.0: >> ??? Utility.DataErr( "Power for %s load must be postive, not %s" \ >> ????? % (id,P_0s) ) >> > That's better. > > However, if P_0s can't be parse as a float, then self.P_0 will be > unchanged (assuming that it already has a value, of course). This is the unique place where self.P_0 might have a value assigned. > Is it OK that if there's no rated power, or it's invalid, it'll report > it and continue with whatever value, if any, that it already has? No. If the data file doesn't have the right data, the simulation can't run. That's why DataErr reports the problem and invokes sys.exit(71). >> In another case where I had a "bare exception", I was using it to see if >> something was defined and substitute a default value if it wasn't. Have >> I cleaned this up properly? >> >> ? try >> ??? id = xmlmodel.attrib['name'] >> ? except KeyError: >> ??? id = "constant power" >> >> (Both changes appear to meet my intent, I'm more wondering about how >> pythonic they are.) >> > There's an alternative that's recommended when the key is often absent: > > ??? id = xmlmodel.attrib.get('name', "constant power") Oh, I like that much better than what I showed above, or how I "fixed" it cross-thread. Thanks! -- Michael F. Stemper You can lead a horse to water, but you can't make him talk like Mr. Ed by rubbing peanut butter on his gums. From steve+comp.lang.python at pearwood.info Fri Sep 7 20:06:50 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 8 Sep 2018 00:06:50 +0000 (UTC) Subject: Object-oriented philosophy References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> <5186fb9b-3d75-66a9-3715-4039b776c1a1@mrabarnett.plus.com> Message-ID: On Fri, 07 Sep 2018 16:07:06 -0500, Michael F. Stemper wrote: >>> In another case where I had a "bare exception", I was using it to see >>> if something was defined and substitute a default value if it wasn't. >>> Have I cleaned this up properly? >>> >>> ? try >>> ??? id = xmlmodel.attrib['name'] >>> ? except KeyError: >>> ??? id = "constant power" >>> >>> (Both changes appear to meet my intent, I'm more wondering about how >>> pythonic they are.) Yes, catch the direct exception you are expecting. That's perfectly Pythonic. >> There's an alternative that's recommended when the key is often absent: >> >> ??? id = xmlmodel.attrib.get('name', "constant power") > > Oh, I like that much better than what I showed above, or how I "fixed" > it cross-thread. Thanks! However, if the key is nearly always present, and your code is performance-critical, calling the "get" method has the slight disadvantage that it will be slightly slower than using the try...except form you show above. On the other hand, the get method has the big advantage that it's an expression that can be used in place, not a four-line compound statement. If I don't care about squeezing out every last bit of performance from the interpreter, I use whatever looks good to me on the day. That will often be the "get" method. But on the rare occasions I do care about performance, the basic rule of thumb I use is that if the key is likely to be missing more than about 10% of the time, I use the "LBYL" idiom (either an explicit test using "if key in dict" or just call the dict.get method). But don't stress about the choice. Chances are that any of the three options you tried (catch KeyError, check with "if" first, or using the get method) will be good enough. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From steve+comp.lang.python at pearwood.info Fri Sep 7 20:07:36 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 8 Sep 2018 00:07:36 +0000 (UTC) Subject: don't quite understand mailing list References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> <87k1nx2a62.fsf@elektro.pacujo.net> Message-ID: On Fri, 07 Sep 2018 07:39:33 +0300, Marko Rauhamaa wrote: > I'm with Ethan on this one. > > There was nothing in the original posting that merited ridicule. Then its a good thing there was nothing in the response that was ridicule. (A mild rebuke for a mild social faux pas is not ridicule.) -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From steve+comp.lang.python at pearwood.info Fri Sep 7 20:10:07 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sat, 8 Sep 2018 00:10:07 +0000 (UTC) Subject: Any SML coders able to translate this to Python? References: <3267563839@f38.n261.z1.binkp.net> <3333871854@f38.n261.z1.binkp.net> <87ftyn2qqb.fsf@elektro.pacujo.net> <87r2i7nhgh.fsf@elektro.pacujo.net> <7ec778b3-7db8-f9a9-2285-ff247b4c5200@vub.be> <87in3ioq95.fsf@elektro.pacujo.net> Message-ID: On Fri, 07 Sep 2018 15:10:10 +0100, Paul Moore wrote: > On Fri, 7 Sep 2018 at 14:06, Steven D'Aprano > wrote: [...] >> However I have a follow up question. Why the "let" construct in the >> first place? Is this just a matter of principle, "put everything in its >> own scope as a matter of precautionary code hygiene"? Because I can't >> see any advantage to the inner function: > > My impression is that this is just functional programming "good style". > As you say, it's not needed, it's just "keep things valid in the > smallest range possible". Probably also related to the mathematical > style of naming sub-expressions. Also, it's probably the case that in a > (compiled) functional language like SML, the compiler can optimise this > to avoid any actual inner function, leaving it as nothing more than a > temporary name. I guessed it would be something like that. Thanks Paul, and especially Marko for going above and beyond the call of duty with his multiple translations into functional-style Python, and everyone else who answered. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From hjp-python at hjp.at Sat Sep 8 09:54:20 2018 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 8 Sep 2018 15:54:20 +0200 Subject: fsxNet Usenet gateway problem again In-Reply-To: References: <801718173@f38.n261.z1.binkp.net> <40654038@f38.n261.z1.binkp.net> <09b57fb1-1eaa-2599-8e9d-2e319863ee8b@gmail.com> Message-ID: <20180908135420.prd7fv4qt7jyo3rm@hjp.at> On 2018-09-06 18:03:19 +0200, Thomas Jollans wrote: > I love that the reposted messages come with a header > > Path: uni-berlin.de!<...>!.POSTED.agency.bbs.nz!not-for-mail > ^^^^^^^^^^^^^ This is normal for Usenet Messages. The format of the path header is the same as that of UUCP mail addresses and in the early days of Usenet you could actually use the path as the mail address of the sender in many cases. This stopped working when UUCP was replaced by NNTP as the transport protocol, so servers added "not-for-mail" at the end instead of the username to prevent people from (ab)using the path as a mail address. 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 michael.stemper at gmail.com Sat Sep 8 10:05:36 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Sat, 8 Sep 2018 09:05:36 -0500 Subject: Object-oriented philosophy In-Reply-To: References: Message-ID: On 2018-09-06 16:04, Stefan Ram wrote: > "Michael F. Stemper" writes: >>> You have a operation ?Resistance( V )?. >> Mathematically, that's an operation, I suppose. I tend to think of it >> as either a function or a method. > > I deliberately did not use neither "a function" nor > "a method" because by "operation" I meant something else, > I meant the three methods "Resistance( V )? (literally, > ?Resistance( self, V )?) of your three classes (and possible > of other model classes added in the future) /viewed together > as an abstract concept/ "get the resistance under 'this' > model", independent of any specific load model. Took me two days, but I finally grok what you said. >>> OOP is advantageous if you can anticipate that you will want >>> to extend operations for other types. >> Since the way that each operation (aside from __init__) differs >>from one load type to the next, is there really an advantage? > > The implementation differs, but not the interface and meaning. > > The advantage is that you can extend this operation for > additional types /without/ modifying the existing implementations > (the open-closed principle!). Whereas with a single > procedure in a non-OOP language, you would have to /modify/ > (error-prone!) an existing procedure. And another advantage has surfaced through this discussion. Even though the common code was only half-a-dozen lines or so, it changed three times due to suggestions made in this thread. Abstracting it to a parent meant that I only had to implement and test each of these changes in one place, rather than three. >>> (Non-OOP means in this case that you have a single >>> definition of a function ?Resistance( entity, V )? which >>> contains an internal multiple branch on the type of the >>> entity.) >> To be honest, that sounds painful and hard to maintain. Of course, >> back in my F77 days, it would have been the only option. > > Well, non-OOP is /not/ obsolete. It just has other specific > advantages and disadvantages. It could be advantageous, > when one adds new operations more often than new types. To misquote "Chico Escuela", "Fortran been berry, berry good to me." -- Michael F. Stemper A preposition is something you should never end a sentence with. From sharan.basappa at gmail.com Sat Sep 8 12:40:49 2018 From: sharan.basappa at gmail.com (Sharan Basappa) Date: Sat, 8 Sep 2018 09:40:49 -0700 (PDT) Subject: perplexing error Message-ID: <6e268a02-f49e-46fc-990a-349b45d9dd0f@googlegroups.com> I am running a small python code. The main module calls another data loader module. I keep this getting this error. AttributeError: 'str' object has no attribute 'raw_data' I tried few things in the code and finally realized that no matter the line number is 68 of data loader module. Of course, this was after a few iterations. I then commented this line itself but I still get this error. Below is a little longer code snippet. AttributeErrorTraceback (most recent call last) D:\Projects\Initiatives\machine learning\Log analyzer\log_analyzer.py in () 32 model = para['models'] 33 assert model in ['DT', 'LR', 'SVM'] ---> 34 raw_data, event_mapping_data = data_loader.bgl_data_loader(para) 35 36 logger.debug("raw data %s \n", raw_data) D:\Projects\Initiatives\machine learning\loglizer-master\loglizer-master\utils\data_loader.py in bgl_data_loader(para) 66 # get the label for each log 67 data_df['label'] = (data_df['label'] != '-').astype(int) ---> 68 #logger.debug("data frame %s \n", data_df) 69 logger.debug("\n") 70 raw_data = data_df[['label','seconds_since']].as_matrix() AttributeError: 'str' object has no attribute 'raw_data' If you notice, line 68 is commented. I am not sure what I am doing wrong. Need some inputs ... From michael.stemper at gmail.com Sat Sep 8 12:47:54 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Sat, 8 Sep 2018 11:47:54 -0500 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> <87k1nx2a62.fsf@elektro.pacujo.net> <7tb6pdds80ni5atssgf39ubtg2h282343d@4ax.com> Message-ID: On 2018-09-07 21:23, Dennis Lee Bieber wrote: > On Sat, 8 Sep 2018 00:07:36 +0000 (UTC), Steven D'Aprano > declaimed the following: >> (A mild rebuke for a mild social faux pas is not ridicule.) > If I wanted to get snarky -- I'd suspect a /contractor/ might be > someone skilled in editing technical documents for a project, with little > actual computer skills. Justification for the harsh opinion: 30 years as a > software engineer at Lockheed Sunnyvale Maybe Lockheed only used contractors for documentation. My previous employer used them for much more than that: coding, testing, design. We had one guy who only contracted to us for a year, who was a guru in Oracle redundancy. He helped us through some rough design decisions. Sometimes (as with the Oracle guru) we used contractors because it didn't make sense to keep particular skills on staff. Sometimes, it was to meet a crunch that was anticipated to be brief. Sometimes, it was to fill an open slot while trying to find somebody to hire for that slot. -- Michael F. Stemper 87.3% of all statistics are made up by the person giving them. From __peter__ at web.de Sat Sep 8 14:32:24 2018 From: __peter__ at web.de (Peter Otten) Date: Sat, 08 Sep 2018 20:32:24 +0200 Subject: perplexing error References: <6e268a02-f49e-46fc-990a-349b45d9dd0f@googlegroups.com> Message-ID: Sharan Basappa wrote: > I am running a small python code. The main module calls another data > loader module. I keep this getting this error. > > AttributeError: 'str' object has no attribute 'raw_data' > > I tried few things in the code and finally realized that no matter the > line number is 68 of data loader module. Of course, this was after a few > iterations. I then commented this line itself but I still get this error. > > Below is a little longer code snippet. > > AttributeErrorTraceback (most recent call last) > D:\Projects\Initiatives\machine learning\Log analyzer\log_analyzer.py in > () > 32 model = para['models'] > 33 assert model in ['DT', 'LR', 'SVM'] > ---> 34 raw_data, event_mapping_data = > data_loader.bgl_data_loader(para) > 35 > 36 logger.debug("raw data %s \n", raw_data) > D:\Projects\Initiatives\machine > learning\loglizer-master\loglizer-master\utils\data_loader.py in > bgl_data_loader(para) > 66 # get the label for each log > 67 data_df['label'] = (data_df['label'] != '-').astype(int) > ---> 68 #logger.debug("data frame %s \n", data_df) > 69 logger.debug("\n") > 70 raw_data = data_df[['label','seconds_since']].as_matrix() > AttributeError: 'str' object has no attribute 'raw_data' > > If you notice, line 68 is commented. > I am not sure what I am doing wrong. > > Need some inputs ... The source code in the traceback is read from the file when the exception is raised. If you edit a module after importing it the traceback may pick lines that caused the code raising the exception, but now contain something completely different. A little demo: >>> with open("tmp.py", "w") as f: f.write("def f():\n return 1/0\n") ... 21 >>> import tmp >>> with open("tmp.py", "w") as f: f.write("def f():\n return 1/2\n") ... 21 >>> tmp.f() Traceback (most recent call last): File "", line 1, in File "/home/peter/tmp.py", line 2, in f return 1/2 ZeroDivisionError: division by zero Therefore you must ensure that the interpreter is restarted after changing the source code. This may include restarting a server or an editor. From internetado at alt119.net Sat Sep 8 14:34:45 2018 From: internetado at alt119.net (Internetado) Date: Sat, 08 Sep 2018 15:34:45 -0300 Subject: Python now a top-3 programming language as Julia's rise speeds up Message-ID: Python has entered the top three for the first time in the TIOBE programming language index, surpassed only by C and Java. According to TIOBE, Python is now becoming "increasingly ubiquitous" and a top choice at universities for all subjects that require programming, as well as in industry. The key to its popularity is it's easy to learn, install, and deploy.[...] https://www.zdnet.com/article/python-now-a-top-3-programming-language-as-julias-rise-speeds-up/#ftag=RSSbaffb68 -- Eduardo ---------- From pkpearson at nowhere.invalid Sat Sep 8 14:55:37 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 8 Sep 2018 18:55:37 GMT Subject: perplexing error References: <6e268a02-f49e-46fc-990a-349b45d9dd0f@googlegroups.com> Message-ID: On 8 Sep 2018 17:25:52 GMT, Stefan Ram wrote: > Sharan Basappa writes: >> 66 # get the label for each log >> 67 data_df['label'] = (data_df['label'] != '-').astype(int) >>---> 68 #logger.debug("data frame %s \n", data_df) >> 69 logger.debug("\n") >> 70 raw_data = data_df[['label','seconds_since']].as_matrix() >>AttributeError: 'str' object has no attribute 'raw_data' >>If you notice, line 68 is commented. >>I am not sure what I am doing wrong. > > In such cases, I do: > > print( 'at position 1' ) > data_df['label'] = (data_df['label'] != '-').astype(int) > print( 'at position 2' ) > raw_data = data_df[['label','seconds_since']].as_matrix() > print( 'at position 3' ) > > . If the last text printed is "at position 1", I will then > split even more: > > print( 'at position 1' ) > tmp = (data_df['label'] != '-').astype(int) > print( 'at position 1a' ) > data_df['label'] = tmp > print( 'at position 2' ) > raw_data = data_df[['label','seconds_since']].as_matrix() > print( 'at position 3' ) > > and so on until the cause is reduced to the smallest > possible unit of code. This approach is especially valuable when it turns out that the file you're editing is not the file being included. -- To email me, substitute nowhere->runbox, invalid->com. From alon.najman at gmail.com Sun Sep 9 10:37:37 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Sun, 9 Sep 2018 07:37:37 -0700 (PDT) Subject: I try to run selenium with firefox on RasberyPi3 ARM7 , any idea if it possible? Message-ID: <5bf23db8-f199-4888-b6dd-cbc719996163@googlegroups.com> I try to run selenium with firefox on RasberyPi3 ARM7 , any idea if it possible? what should I do? I don't mind to change to another driver From max at zettlmeissl.de Sun Sep 9 10:48:10 2018 From: max at zettlmeissl.de (=?UTF-8?Q?Max_Zettlmei=C3=9Fl?=) Date: Sun, 9 Sep 2018 16:48:10 +0200 Subject: "glob.glob('weirdness')" Any thoughts? In-Reply-To: References: Message-ID: On Sun, Sep 9, 2018 at 2:20 PM, Gilmeh Serda wrote: > > # Python 3.6.1/Linux > (acts the same in Python 2.7.3 also, by the way) > >>>> from glob import glob > >>>> glob('./Testfile *') > ['./Testfile [comment] some text.txt'] > >>>> glob('./Testfile [comment]*') > [] > >>>> glob('./Testfile [comment? some text.*') > ['./Testfile [comment] some text.txt'] > The behaviour is stated rather clearly in the documentation: For glob: "No tilde expansion is done, but *, ?, and character ranges expressed with [] will be correctly matched. This is done by using the os.scandir() and fnmatch.fnmatch() functions in concert, and not by actually invoking a subshell." [1] And then for fnmatch, since that is used by glob: "For a literal match, wrap the meta-characters in brackets. For example, '[?]' matches the character '?'." [2] Therefore glob('./Testfile [[]comment[]]*') is what you are looking for. It should be straightforward to wrap all the meta-characters which you want to use in their literal form in square brackets. The results of your analysis are also stated in the documentation for the glob patterns [1], so there is no guessing required. Your analysis about escaping special characters is wrong though. While backslashes are often used as escape characters, they are not used in such a fashion everywhere. In this case they are not used as escape characters, which makes a lot of sense when considering that the directory separator in Windows is a backslash and additionally using backslashes as escape characters would lead to quite some confusion in this case. [1] https://docs.python.org/3/library/glob.html [2] https://docs.python.org/3/library/fnmatch.html From tjol at tjol.eu Sun Sep 9 12:03:13 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Sun, 9 Sep 2018 18:03:13 +0200 Subject: "glob.glob('weirdness')" Any thoughts? In-Reply-To: References: Message-ID: On 09/09/2018 02:20 PM, Gilmeh Serda wrote: > > # Python 3.6.1/Linux > (acts the same in Python 2.7.3 also, by the way) > >>>> from glob import glob > >>>> glob('./Testfile *') > ['./Testfile [comment] some text.txt'] > >>>> glob('./Testfile [comment]*') > [] > >>>> glob('./Testfile [comment? some text.*') > ['./Testfile [comment] some text.txt'] > >>>> glob('./Testfile [comment[]*') > ['./Testfile [comment] some text.txt'] > >>>> glob('./Testfile [comment[] some text.*') > [] > > Testing: > >>>> fnmatch.translate('./Testfile [comment] some text.*') > '(?s:\\.\\/Testfile\\ [comment]\\ some\\ text\\..*)\\Z' > >>>> fnmatch.translate('./Testfile [comment? some text.*') > '(?s:\\.\\/Testfile\\ \\[comment.\\ some\\ text\\..*)\\Z' > > It seems it translates [comments] as a set of valid characters to look > for and doesn't care about the [] characters, which is what breaks it, I > assume. > > ? translates into RegEx . > * translates into RegEx .* > > And escaping doesn't work either, because: https://docs.python.org/3/library/glob.html#glob.escape demonstrates a way of escaping that works: glob('./Testfile [[]comment]*') > >>>> fnmatch.translate('./Testfile [comment\] some text.*') > '(?s:\\.\\/Testfile\\ [comment\\\\]\\ some\\ text\\..*)\\Z' > > ...the \ is replaced with \\ which breaks the pattern since it is no > longer a real escape character but an escaped escape character, if that > makes sense. > > When the file name has a non working RegEx set, e.g., './Testfile > comment]*' it works. > > Yes, easy to say "don't write that into file names," but I don't make the > rules. > > I guess I have to write my own. > > Oh, well... > From gheskett at shentel.net Sun Sep 9 12:47:02 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 9 Sep 2018 12:47:02 -0400 Subject: Object-oriented philosophy In-Reply-To: References: Message-ID: <201809091247.02817.gheskett@shentel.net> On Sunday 09 September 2018 08:19:52 Gilmeh Serda wrote: > On Thu, 06 Sep 2018 18:07:55 +0200, Thomas Jollans wrote: > >> Also, get someone, preferrable a python engineer to review your > >> code. > > > > Does anyone here know anyone who would refer to themselves as a > > "Python engineer" with a straight face? I merely ask... > > We're all tinker bells. > > -- > Gilmeh And some of us are just senior citizen tinkerers, like me :) I lurk here, hoping some of it will rub into me. -- 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 amirouche.boubekki at gmail.com Sun Sep 9 13:07:12 2018 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Sun, 9 Sep 2018 19:07:12 +0200 Subject: Object-oriented philosophy In-Reply-To: References: Message-ID: Le jeu. 6 sept. 2018 ? 16:05, Michael F. Stemper a ?crit : > > How does one judge when it's worthwhile to do this and when it's > not? What criteria would somebody seasoned in OO and python use > to say "good idea" vs "don't waste your time"? > I may qualify as experienced with Python, that being said, "to class or not to class?" is still an open question. I have been working on some stuff using Scheme and no OO machinery and it worked well. Also, mocked some stuff in the frontend using a purely functional approach. It works. So, I am wondering what's the purpose of OOP? Class-based error handling with exception and inheritance is very handy maybe perfect. I have been burned by Django class everywhere (ORM, REST, admin UI, data validation, etc?). Another place where class shines is when you have the same interface for different objects. Like others have said, it's more "duck typing" than OOP. Again following the "common interface" an abstract class is helpful and in this case, inheritance makes sense. But that doesn't require more that one or two level deep inheritance. So, in the end, I think that except for error handling and the subject.verb(**complements) syntax. OOP is dubious. Multiple inheritances outside mixin anyone? Metaclass outside ORM / ODM? From arj.python at gmail.com Sun Sep 9 13:34:28 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Sun, 9 Sep 2018 21:34:28 +0400 Subject: Object-oriented philosophy In-Reply-To: <9f6d8cf5-d315-9ebb-8753-27e24ce22056@tjol.eu> References: <9f6d8cf5-d315-9ebb-8753-27e24ce22056@tjol.eu> Message-ID: just see who a company employ as a py eng, ask him. Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius > > Does anyone here know anyone who would refer to themselves as a "Python > engineer" with a straight face? I merely ask... > > -- Thomas > -- > https://mail.python.org/mailman/listinfo/python-list > From sharan.basappa at gmail.com Sun Sep 9 23:12:28 2018 From: sharan.basappa at gmail.com (Sharan Basappa) Date: Sun, 9 Sep 2018 20:12:28 -0700 (PDT) Subject: perplexing error In-Reply-To: References: <6e268a02-f49e-46fc-990a-349b45d9dd0f@googlegroups.com> Message-ID: <4efc879e-9f65-44e7-b089-08d5337d77df@googlegroups.com> On Sunday, 9 September 2018 00:02:49 UTC+5:30, Peter Otten wrote: > Sharan Basappa wrote: > > > I am running a small python code. The main module calls another data > > loader module. I keep this getting this error. > > > > AttributeError: 'str' object has no attribute 'raw_data' > > > > I tried few things in the code and finally realized that no matter the > > line number is 68 of data loader module. Of course, this was after a few > > iterations. I then commented this line itself but I still get this error. > > > > Below is a little longer code snippet. > > > > AttributeErrorTraceback (most recent call last) > > D:\Projects\Initiatives\machine learning\Log analyzer\log_analyzer.py in > > () > > 32 model = para['models'] > > 33 assert model in ['DT', 'LR', 'SVM'] > > ---> 34 raw_data, event_mapping_data = > > data_loader.bgl_data_loader(para) > > 35 > > 36 logger.debug("raw data %s \n", raw_data) > > D:\Projects\Initiatives\machine > > learning\loglizer-master\loglizer-master\utils\data_loader.py in > > bgl_data_loader(para) > > 66 # get the label for each log > > 67 data_df['label'] = (data_df['label'] != '-').astype(int) > > ---> 68 #logger.debug("data frame %s \n", data_df) > > 69 logger.debug("\n") > > 70 raw_data = data_df[['label','seconds_since']].as_matrix() > > AttributeError: 'str' object has no attribute 'raw_data' > > > > If you notice, line 68 is commented. > > I am not sure what I am doing wrong. > > > > Need some inputs ... > > The source code in the traceback is read from the file when the exception is > raised. If you edit a module after importing it the traceback may pick lines > that caused the code raising the exception, but now contain something > completely different. A little demo: > > >>> with open("tmp.py", "w") as f: f.write("def f():\n return 1/0\n") > ... > 21 > >>> import tmp > >>> with open("tmp.py", "w") as f: f.write("def f():\n return 1/2\n") > ... > 21 > >>> tmp.f() > Traceback (most recent call last): > File "", line 1, in > File "/home/peter/tmp.py", line 2, in f > return 1/2 > ZeroDivisionError: division by zero > > Therefore you must ensure that the interpreter is restarted after changing > the source code. This may include restarting a server or an editor. Understood. Now I know why the error is stuck on that line. This gives me a clue. From alister.ware at ntlworld.com Mon Sep 10 05:31:54 2018 From: alister.ware at ntlworld.com (Alister) Date: Mon, 10 Sep 2018 09:31:54 GMT Subject: (new try) - Running a second wsgi script from within the first wsgi script References: Message-ID: On Sun, 09 Sep 2018 18:47:49 -0700, ????? ?????? wrote: > I have 3 wsgi scripts listening on 3 locations. What i'm trying to run > an wsgi script from within another wsgi script with the following > statement. > > page = 'clientele' > pdata = requests.get( 'http://superhost.gr/' + page ) > pdata = pdata.text + counter page = the location of another wsgi app. > > The error i'am getting when for i.e i try to load > http://superhost.gr/clientele > > mod_wsgi (pid=7152): Exception occurred processing WSGI script > '/home/nikos/public_html/app.py' > OSError: Apache/mod_wsgi failed to write response data: Broken pipe. > The other script by itself executes normally but NOT from within my > app.py script. > > Any ideas on how to execute a wsgi app (b) from within a wsgi app(a) and > store the response as html data? repeatedly asking the same question will not get you answered any faster in fact it may simply get you black-listed by many posters -- Why are you so hard to ignore? From alon.najman at gmail.com Mon Sep 10 06:48:46 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Mon, 10 Sep 2018 03:48:46 -0700 (PDT) Subject: on rasberry pi 3 python 2.7 , trying to run code on geckodriver with selenium and getting error Message-ID: <068cdf25-907a-4f20-97e3-8efee8ab3c3e@googlegroups.com> hi , on rasberry pi 3 python 2.7 , trying to run code on geckodriver with selenium and getting an error the Firefox browser is opened automatically :) it just don't work I'm not getting the stock value on the print BTW it works on my PC with ChromeDriver - Traceback (most recent call last): File "/home/pi/Desktop/Automation RatiL works on PC.py", line 22, in driver.get('https://www.investing.com/equities/ratio-par') File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 248, in get self.execute(Command.GET, {'url': url}) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute response = self.command_executor.execute(driver_command, params) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 401, in execute return self._request(command_info[0], url, body=data) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 433, in _request resp = self._conn.getresponse() File "/usr/lib/python2.7/httplib.py", line 1111, in getresponse response.begin() File "/usr/lib/python2.7/httplib.py", line 444, in begin version, status, reason = self._read_status() File "/usr/lib/python2.7/httplib.py", line 408, in _read_status raise BadStatusLine(line) BadStatusLine: '' thanks all From arj.python at gmail.com Mon Sep 10 07:23:23 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 10 Sep 2018 15:23:23 +0400 Subject: Lightweight Learn Python book Message-ID: wrote a small guide on python, feedbacks appreciated https://www.pythonmembers.club/wp-content/uploads/2018/09/lightweight_learn_python_draft_1-1.pdf Abdur-Rahmaan Janhangeer From ethan at stoneleaf.us Mon Sep 10 08:03:52 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 10 Sep 2018 05:03:52 -0700 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: On 09/06/2018 07:40 PM, Steven D'Aprano wrote: > On Thu, 06 Sep 2018 13:06:22 -0700, Ethan Furman wrote: >> On 09/06/2018 12:42 PM, Reto Brunner wrote: >> >>> What do you think the link, which is attached to every email you >>> receive from the list, is for? Listinfo sounds very promising, doesn't >>> it? >>> >>> And if you actually go to it you'll find: "To unsubscribe from >>> Python-list, get a password reminder, or change your subscription >>> options enter your subscription email address" >>> >>> So how about you try that? >> >> Reto, your response is inappropriate. If you can't be kind and/or >> respectful, let someone else respond. > > No it wasn't inappropriate, and your attack on Reto is uncalled for. It was inappropriate, and I wasn't attacking Reto. > Reto's answer was kind and infinitely more respectful than your > unnecessary criticism. As far as I can tell, this is Reto's first post > here. After your hostile and unwelcoming response, I wouldn't be > surprised if it was his last. > > His answer was both helpful and an *amazingly* restrained and kind > response to a stupid question[1] asked by somebody claiming to be an > professional software engineer. It was not condescending or mean- > spirited, as you said in another post, nor was it snarky. Wow. I suddenly feel like I'm running for political office to get hit with such a distortion of facts. > But even had the OP been a total beginner to computing, it was still a > helpful response containing the information needed to solve their > immediate problem (how to unsubscribe from the list) with just the > *tiniest* (and appropriate) hint of reproach to encourage them to learn > how to solve their own problems for themselves so that in future, they > will be a better contributor to whatever discussion forums they might > find themselves on. Yes, there was some helpful content. That doesn't excuse the manner of delivery. > Ethan, you are a great contributor on many of the Python mailing lists, > but your tone-policing is inappropriate, and your CoC banning of Rick and > Bart back in July was an excessive and uncalled for misuse of moderator > power. Mailing lists consists of two things: content and tone, and both are equally important. I volunteered to be a moderator for Python List as it felt to me like the existing moderators were overwhelmed by the sheer volume of this list, and a few bad actors were making this venue an unpleasant place to be. > To my shame, I didn't say anything at the time, but I won't be > intimidated any longer by fear of the CoC and accusations of incivility. > I'm speaking up now because your reply to Reto is unwelcoming, unhelpful > and disrespectful, and coming from a moderator who has been known to ban > people, that makes it even more hostile. Actually, you did say something at the time: https://mail.python.org/pipermail/python-list What I find most interesting in this post, though, is your declaration "I won't be intimidated any longer by fear of the CoC" -- it doesn't strike me as a scary document; it basically says, "be nice". > [1] Yes, there are such things as stupid questions. If your doctor asked > you "remind me again, which end of the needle goes into your arm?" what > would you do? I would laugh, because he would be joking. -- ~Ethan~ From rosuav at gmail.com Mon Sep 10 08:23:20 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 10 Sep 2018 22:23:20 +1000 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: On Mon, Sep 10, 2018 at 10:03 PM, Ethan Furman wrote: > On 09/06/2018 07:40 PM, Steven D'Aprano wrote: >> Ethan, you are a great contributor on many of the Python mailing lists, >> but your tone-policing is inappropriate, and your CoC banning of Rick and >> Bart back in July was an excessive and uncalled for misuse of moderator >> power. >> >> To my shame, I didn't say anything at the time, but I won't be >> intimidated any longer by fear of the CoC and accusations of incivility. >> I'm speaking up now because your reply to Reto is unwelcoming, unhelpful >> and disrespectful, and coming from a moderator who has been known to ban >> people, that makes it even more hostile. > > > Actually, you did say something at the time: > https://mail.python.org/pipermail/python-list Not sure what this link is stating. Did you intend to link directly to a post? Or are you saying generally that "stuff was said, check the archive"? > What I find most interesting in this post, though, is your declaration "I > won't be intimidated any longer by fear of the CoC" -- it doesn't strike me > as a scary document; it basically says, "be nice". It doesn't have to be worded scarily. Suppose the CoC simply said "be nice" - literally just those two words. It would actually be *more* scary, because its power would be far more arbitrary and at the whim of the individual moderators. Perhaps the mods would be less scary if there were more words in the CoC, such that we could point to section 5, subsection b2q, paragraph theta, as an explanation of the ban. I don't think it'd make python-list a better place, but at least it'd remove any accusations of "misuse of moderator power". For what it's worth, I support Ethan's actions - including when I've been on the receiving end of the criticism. The banning of Rick and Bart was most assuredly NOT misuse of power, at least not in my opinion (which, I'm aware, has zero weight, but hey, we all have one). Maybe people are forgetting that python-list IS a moderated list, and should be treated as one? ChrisA From max at zettlmeissl.de Mon Sep 10 08:40:45 2018 From: max at zettlmeissl.de (=?UTF-8?Q?Max_Zettlmei=C3=9Fl?=) Date: Mon, 10 Sep 2018 14:40:45 +0200 Subject: "glob.glob('weirdness')" Any thoughts? In-Reply-To: References: Message-ID: On Sun, Sep 9, 2018 at 6:03 PM, Thomas Jollans wrote: > On 09/09/2018 02:20 PM, Gilmeh Serda wrote: >> >> >> # Python 3.6.1/Linux >> (acts the same in Python 2.7.3 also, by the way) >> >>>>> from glob import glob >> >> >>>>> glob('./Testfile *') >> >> ['./Testfile [comment] some text.txt'] >> >>>>> glob('./Testfile [comment]*') >> >> [] >> [...] > > https://docs.python.org/3/library/glob.html#glob.escape demonstrates a way > of escaping that works: > > glob('./Testfile [[]comment]*') > That is about the least correct working solution one could conceive. Of course your suggested "glob('./Testfile [[]comment]*')" works in the positive case, but pretty much comes down to a glob('./Testfile [[]*'). And in the negative case it would provide many false positives. (e.g. "Testfile [falacy]", "Testfile monty", "Testfile ]not quite" and so on) Even if you wanted to use that strange character class, which is not a good idea (as explained above), using "[[]coment]" would be better, since there is no reason to repeat a character. From tjol at tjol.eu Mon Sep 10 09:05:34 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 10 Sep 2018 15:05:34 +0200 Subject: "glob.glob('weirdness')" Any thoughts? In-Reply-To: References: Message-ID: On 10/09/18 14:40, Max Zettlmei?l via Python-list wrote: > On Sun, Sep 9, 2018 at 6:03 PM, Thomas Jollans wrote: >> https://docs.python.org/3/library/glob.html#glob.escape demonstrates a way >> of escaping that works: >> >> glob('./Testfile [[]comment]*') >> > That is about the least correct working solution one could conceive. > Of course your suggested "glob('./Testfile [[]comment]*')" works in > the positive case, but pretty much comes down to a glob('./Testfile > [[]*'). > And in the negative case it would provide many false positives. (e.g. > "Testfile [falacy]", "Testfile monty", "Testfile ]not quite" and so > on) > Even if you wanted to use that strange character class, which is not a > good idea (as explained above), using "[[]coment]" would be better, > since there is no reason to repeat a character. >>> from glob import glob >>> glob('test *') ['test comment', 'test [co]mment', 'test [fallacy]', 'test [comments]', 'test [comment] a'] >>> glob('test [[]*') ['test [co]mment', 'test [fallacy]', 'test [comments]', 'test [comment] a'] >>> glob('test [[]c*') ['test [co]mment', 'test [comments]', 'test [comment] a'] >>> glob('test [[]comment]*') ['test [comment] a'] >>> I'm escaping the '[' as '[[]'. You can escape the ']' as well if you want, but there's no need as a ']' is not special unless it's preceded by an unescaped '['. To match the character class I think you thought my glob was matching, you'd have to use '[][comment]' rather than '[[]comment]'. -- Thomas From __peter__ at web.de Mon Sep 10 09:44:03 2018 From: __peter__ at web.de (Peter Otten) Date: Mon, 10 Sep 2018 15:44:03 +0200 Subject: "glob.glob('weirdness')" Any thoughts? References: Message-ID: Max Zettlmei?l via Python-list wrote: >> glob('./Testfile [[]comment]*') >> > > That is about the least correct working solution one could conceive. > Of course your suggested "glob('./Testfile [[]comment]*')" works in > the positive case, but pretty much comes down to a glob('./Testfile > [[]*'). > If you know regular expressions there is an easy way to verify that you are wrong: >>> import fnmatch >>> fnmatch.translate("foo [[]bar]*") 'foo\\ [[]bar\\].*\\Z(?ms)' And if you don't: >>> re.compile(_, re.DEBUG) literal 102 literal 111 literal 111 literal 32 literal 91 literal 98 literal 97 literal 114 literal 93 max_repeat 0 4294967295 any None at at_end_string re.compile('foo\\ [[]bar\\].*\\Z(?ms)', re.MULTILINE|re.DOTALL|re.DEBUG) >>> chr(91) '[' From ethan at stoneleaf.us Mon Sep 10 10:12:44 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 10 Sep 2018 07:12:44 -0700 Subject: don't quite understand mailing list In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> Message-ID: <809d42c8-ce86-3cea-aa38-7934d406b1f5@stoneleaf.us> On 09/10/2018 05:23 AM, Chris Angelico wrote: > On Mon, Sep 10, 2018 at 10:03 PM, Ethan Furman wrote: >> Actually, you did say something at the time: >> https://mail.python.org/pipermail/python-list > > Not sure what this link is stating. Did you intend to link directly to > a post? Or are you saying generally that "stuff was said, check the > archive"? No, it was a supposed to be a link, which I obviously mis-copied. Sorry. -- ~Ethan From rtomek at ceti.pl Mon Sep 10 12:04:30 2018 From: rtomek at ceti.pl (Tomasz Rola) Date: Mon, 10 Sep 2018 18:04:30 +0200 Subject: don't quite understand mailing list In-Reply-To: <39f7985fde9446f08c9ac056f3d28373@lmco.com> References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> Message-ID: <20180910160429.GA15229@tau1.ceti.pl> On Thu, Sep 06, 2018 at 07:10:10PM +0000, VanDyk, Richard T wrote: > Greetings; > > I sent in a question on how to install robot framework on python 3.7 > using pip (or any other way). None of the commands on the >>> seem > to work for me. I was asked to update the c/c++ runtime which I > don't know what that means. In such cases I ask google, like, literally type "update c/c++ runtime" in it. > I was also asked to subscribe to the mailing list. I did that but > don't want everyone's submitted question to come to me. Judging from what you wrote here, you: a) are going to use Python a bit in a near future b) have a bit to read before you understand what you are doing If both a) and b) are true, then I advice that you stay on list and keep reading whichever mail tingles your curiosity, or even at random. If you do this for long enough, you will finally learn enough to solve your problem(s). Maybe you will even be able to unsubscribe on your very own? HTH -- Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From max at zettlmeissl.de Mon Sep 10 14:39:44 2018 From: max at zettlmeissl.de (=?UTF-8?Q?Max_Zettlmei=C3=9Fl?=) Date: Mon, 10 Sep 2018 20:39:44 +0200 Subject: "glob.glob('weirdness')" Any thoughts? In-Reply-To: References: Message-ID: On Mon, Sep 10, 2018 at 3:05 PM, Thomas Jollans wrote: >>>> from glob import glob >>>> glob('test *') > ['test comment', 'test [co]mment', 'test [fallacy]', 'test [comments]', > 'test [comment] a'] >>>> glob('test [[]*') > ['test [co]mment', 'test [fallacy]', 'test [comments]', 'test [comment] a'] >>>> glob('test [[]c*') > ['test [co]mment', 'test [comments]', 'test [comment] a'] >>>> glob('test [[]comment]*') > ['test [comment] a'] >>>> > > I'm escaping the '[' as '[[]'. You can escape the ']' as well if you want, > but there's no need as a ']' is not special unless it's preceded by an > unescaped '['. > > To match the character class I think you thought my glob was matching, you'd > have to use '[][comment]' rather than '[[]comment]'. > That is of course correct. I'm sorry. Now that I looked at it again, I can't see how I came to that wrong conclusion. Your suggested "[][comment]" is exactly what I thought your "[[]comment]" to be and I can't explain to myself anymore how I came to that conclusion. There actually is glob.ecape [1] which escapes all the glob meta-characters in a path and does so exactly as in your example. (Since it is obviously the shortest and therefore in this case best way.) [1] https://docs.python.org/3/library/glob.html#glob.escape From pkpearson at nowhere.invalid Mon Sep 10 17:50:14 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 10 Sep 2018 21:50:14 GMT Subject: perplexing error References: <6e268a02-f49e-46fc-990a-349b45d9dd0f@googlegroups.com> Message-ID: On 8 Sep 2018 19:10:09 GMT, Stefan Ram wrote: > Peter Pearson writes: >>On 8 Sep 2018 17:25:52 GMT, Stefan Ram wrote: >>>In such cases, I do: >>>print( 'at position 1' ) >>This approach is especially valuable when it turns out that >>the file you're editing is not the file being included. > > I am not sure whether this is taken to be literally or as > being sarcastic. [snip] No sarcasm intended. I've made the editing-wrong-file goof many times. -- To email me, substitute nowhere->runbox, invalid->com. From rosuav at gmail.com Mon Sep 10 17:58:26 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 11 Sep 2018 07:58:26 +1000 Subject: perplexing error In-Reply-To: References: <6e268a02-f49e-46fc-990a-349b45d9dd0f@googlegroups.com> Message-ID: On Tue, Sep 11, 2018 at 7:50 AM, Peter Pearson wrote: > On 8 Sep 2018 19:10:09 GMT, Stefan Ram wrote: >> Peter Pearson writes: >>>On 8 Sep 2018 17:25:52 GMT, Stefan Ram wrote: >>>>In such cases, I do: >>>>print( 'at position 1' ) >>>This approach is especially valuable when it turns out that >>>the file you're editing is not the file being included. >> >> I am not sure whether this is taken to be literally or as >> being sarcastic. > [snip] > > No sarcasm intended. I've made the editing-wrong-file goof many times. > Me too. Or it's the right file, but not being deployed correctly. Or you're working on the wrong computer (especially if you have editors open via SSH). Or you just plain forgot to save... This sort of smoke test is invaluable. ChrisA From python at bdurham.com Mon Sep 10 21:43:36 2018 From: python at bdurham.com (Malcolm Greene) Date: Mon, 10 Sep 2018 19:43:36 -0600 Subject: logging module - how to include method's class name when using %(funcName) Message-ID: <1536630216.1551617.1503655568.386E4989@webmail.messagingengine.com> I'm using the Python logging module and looking for a way to include a method's class name when using %(funcName). Is this possible? When you have several related classes, just getting the function (method) name is not enough information to provide context on the code being executed. I'm outputting module name and line number so I can always go back and double check a caller's location in source, but that seems like an archaic way to find this type of information. Thank you, Malcolm From dieter at handshake.de Tue Sep 11 01:11:55 2018 From: dieter at handshake.de (dieter) Date: Tue, 11 Sep 2018 07:11:55 +0200 Subject: on rasberry pi 3 python 2.7 , trying to run code on geckodriver with selenium and getting error References: <068cdf25-907a-4f20-97e3-8efee8ab3c3e@googlegroups.com> Message-ID: <8736ugty78.fsf@handshake.de> alon.najman at gmail.com writes: > on rasberry pi 3 python 2.7 , trying to run code on geckodriver with selenium and getting an error the Firefox browser is opened automatically :) it just don't work I'm not getting the stock value on the print BTW it works on my PC with ChromeDriver - > > Traceback (most recent call last): > ... > File "/usr/lib/python2.7/httplib.py", line 408, in _read_status > raise BadStatusLine(line) > BadStatusLine: '' This means that the (HTTP/HTTPS) server response in not valid HTTP -- maybe, because the server died during the request processing. From dieter at handshake.de Tue Sep 11 01:17:12 2018 From: dieter at handshake.de (dieter) Date: Tue, 11 Sep 2018 07:17:12 +0200 Subject: logging module - how to include method's class name when using %(funcName) References: <1536630216.1551617.1503655568.386E4989@webmail.messagingengine.com> Message-ID: <87y3c8sjdz.fsf@handshake.de> Malcolm Greene writes: > I'm using the Python logging module and looking for a way to include a > method's class name when using %(funcName). Is this possible? If it does not happen automatically, the standard logging components will not let you do it (the name "funcName" is rather explicit; you get what the name promises). However, all logging components can be customized. The logging implementation has a fine grained architecture (read the documentation of the "logging" package). The component for your kind of customization is likely called "formatter". By registering you own "formatter", you will be able to get what you want. From marko at pacujo.net Tue Sep 11 02:59:29 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 11 Sep 2018 09:59:29 +0300 Subject: Object-oriented philosophy References: Message-ID: <87efe0msdq.fsf@elektro.pacujo.net> Rick Johnson : > Michael F. Stemper wrote: >> Object-oriented philosophy > [...] [...] [...] > > So, to make a long story short, you may want to do some > googling... Long story short, Michael, Rick is a masterful troll extraordinaire. Highly amusing when you're in the mood. Marko From niourf at gmail.com Tue Sep 11 07:58:48 2018 From: niourf at gmail.com (Nicolas Hug) Date: Tue, 11 Sep 2018 07:58:48 -0400 Subject: Pretty printing dicts with compact=True Message-ID: Is there a reason why the 'compact' parameter is ignored when pretty printing a dict? For example: pprint({x: x for x in range(15)}, compact=True) would be be printed in 15 lines while it could fit on 2. Is this a bug or was this decided on purpose? Thank you! From python at bdurham.com Tue Sep 11 08:21:36 2018 From: python at bdurham.com (Malcolm Greene) Date: Tue, 11 Sep 2018 06:21:36 -0600 Subject: Verify pip's requirements.txt file at runtime? Message-ID: <1536668496.2011099.1504149200.72DCBE3A@webmail.messagingengine.com> Is there a technique that would allow a script to verify its requirements.txt file before it runs? Use case: To detect unexpected changes to a script's runtime environment. Does the pip module expose any methods for this type of task? Thank you, Malcolm From antoon.pardon at vub.be Tue Sep 11 09:02:24 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Tue, 11 Sep 2018 15:02:24 +0200 Subject: Object-oriented philosophy In-Reply-To: References: <44db698d-7117-3312-17ab-55c3d5e73c30@kynesim.co.uk> <93f7c20b-9ab1-596b-cf71-1f150fe7a401@mrabarnett.plus.com> Message-ID: <9ed55750-894e-e07c-50f2-304a1423f15c@vub.be> On 07-09-18 22:08, Michael F. Stemper wrote: > >> try >> id = xmlmodel.attrib['name'] >> except KeyError: >> id = "constant power" > Never mind! After I continued testing, I realized that the above > should have been written as: > > if 'name' in xmlmodel.attrib: > id = xmlmodel.attrib['name'] > else: > id = "constant power" > > How about: id = xmlmodel.attrib.get('name', "constant power") From michael.stemper at gmail.com Tue Sep 11 09:56:39 2018 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Tue, 11 Sep 2018 08:56:39 -0500 Subject: Object-oriented philosophy In-Reply-To: <87efe0msdq.fsf@elektro.pacujo.net> References: <87efe0msdq.fsf@elektro.pacujo.net> Message-ID: On 2018-09-11 01:59, Marko Rauhamaa wrote: > Rick Johnson : > >> Michael F. Stemper wrote: >>> Object-oriented philosophy >> [...] [...] [...] >> >> So, to make a long story short, you may want to do some >> googling... > > Long story short, Michael, Rick is a masterful troll extraordinaire. Is that why he misquoted "Big Yellow Taxi"? (Hint: a song with "raped" in it would not have had any air time in 1970.) > Highly amusing when you're in the mood. Incoherent, too. -- Michael F. Stemper Galatians 3:28 From arj.python at gmail.com Tue Sep 11 12:51:24 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 11 Sep 2018 20:51:24 +0400 Subject: Object-oriented philosophy In-Reply-To: <87efe0msdq.fsf@elektro.pacujo.net> References: <87efe0msdq.fsf@elektro.pacujo.net> Message-ID: i did not see rick's mail on my gmail Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius Rick Johnson : > > > Michael F. Stemper wrote: > >> Object-oriented philosophy > > [...] [...] [...] > > > > So, to make a long story short, you may want to do some > > googling... > > Long story short, Michael, Rick is a masterful troll extraordinaire. > Highly amusing when you're in the mood. > > > Marko > From max at zettlmeissl.de Tue Sep 11 13:05:30 2018 From: max at zettlmeissl.de (=?UTF-8?Q?Max_Zettlmei=C3=9Fl?=) Date: Tue, 11 Sep 2018 19:05:30 +0200 Subject: Pretty printing dicts with compact=True In-Reply-To: References: Message-ID: On Tue, Sep 11, 2018 at 1:58 PM, Nicolas Hug wrote: > pprint({x: x for x in range(15)}, compact=True) > > would be be printed in 15 lines while it could fit on 2. > > > Is this a bug or was this decided on purpose? It is on purpose as can be seen in the code for pprint [1], which calls _format [2], which in the case of a dictionary calls _pprint_dict [3], which ultimately calls _format_dict_items [4]. (which does not use compact or rather _compact) To me it also seems to be the most sensible behaviour, since dictionaries with their keys and values are different from most other sequences. In a dictionary the relation between keys and values is the most important one and reading a dictionary certainly is easier if each key value pair has a line of it's own. (Especially if the keys and values vary a lot in their lengths.) [1] https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/pprint.py#L138 [2] https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/pprint.py#L154 [3] https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/pprint.py#L180 [4] https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/pprint.py#L333 From duncan at invalid.invalid Tue Sep 11 13:16:42 2018 From: duncan at invalid.invalid (duncan smith) Date: Tue, 11 Sep 2018 18:16:42 +0100 Subject: numpy use cases for where and out Message-ID: <%LSlD.10394$sH2.3964@fx25.iad> Hello, I'm writing some code for sparse arrays that is intended to pretty much follow the numpy API. Because my arrays can have different default values there is an issue with using the 'out' keyword argument for functions. e.g. If I elementwise multiply 2 arrays with defaults a and b, then the default of the product becomes a*b. Changing the default of 'out' to a*b (if that is not the existing default) requires pre-existing values in 'out' equal to the previous default to be filled in. It seems to be more hassle than it's worth, and basically eliminates sparsity. So I am wondering if there are any compelling use cases for 'out'. At the same time, I'm wondering about 'where'. It's less of an issue. But given my dictionary of keys implementation, and returning new arrays rather than views, I'm wondering if I could reasonably eliminate both. I don't think I've ever used either argument when using numpy. So I'm asking here in case there are use cases I've overlooked. TIA. Duncan From arj.python at gmail.com Tue Sep 11 13:17:15 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 11 Sep 2018 21:17:15 +0400 Subject: Object-oriented philosophy In-Reply-To: References: <87efe0msdq.fsf@elektro.pacujo.net> Message-ID: i know about the ban but since marko was getting it was wondering how thanks ! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius Ranting Rick is banned from posting to python-list. (And maybe also > from other Python project lists, I'm not sure about that.) > You can read about further details in the topic "Users banned". > > You should only see his messages if you read the Newsgroup or if > someone quotes a message that Rick has posted on the Newsgroup, since > the Newsgroup is unmoderated. > From __peter__ at web.de Tue Sep 11 13:46:27 2018 From: __peter__ at web.de (Peter Otten) Date: Tue, 11 Sep 2018 19:46:27 +0200 Subject: logging module - how to include method's class name when using %(funcName) References: <1536630216.1551617.1503655568.386E4989@webmail.messagingengine.com> Message-ID: Malcolm Greene wrote: > I'm using the Python logging module and looking for a way to include a > method's class name when using %(funcName). Is this possible? When you > have several related classes, just getting the function (method) name is > not enough information to provide context on the code being executed. > I'm outputting module name and line number so I can always go back and > double check a caller's location in source, but that seems like an > archaic way to find this type of information. In the code below I took the same approach, but automated it with pyclbr. While I'm not really happy with the result (is inspect or ast more suitable, should Logger be subclassed or adapted rather than specifying the LogRecord factory, can the class be determined lazily) here's the current state of things: $ cat findclass.py def ham(): log.warning("inside ham function") import bisect import pyclbr import logging LogRecord = logging.LogRecord class Module: def __init__(self, module): mod = pyclbr.readmodule_ex(module) line2func = [] for classname, cls in mod.items(): if isinstance(cls, pyclbr.Function): line2func.append((cls.lineno, "", cls.name)) else: for methodname, start in cls.methods.items(): line2func.append((start, classname, methodname)) line2func.sort() keys = [item[0] for item in line2func] self.line2func = line2func self.keys = keys def line_to_class(self, lineno): index = bisect.bisect(self.keys, lineno) - 1 return self.line2func[index][1] def lookup_module(module): return Module(module) def lookup_class(module, funcname, lineno): if funcname == "": return "" module = lookup_module(module) return module.line_to_class(lineno) def makeLogRecord(*args, **kw): record = LogRecord(*args, **kw) record.className = lookup_class( record.module, record.funcName, record.lineno ) if record.className != "": record.funcName = "{}.{}".format(record.className, record.funcName) return record logging.setLogRecordFactory(makeLogRecord) logging.basicConfig( format=logging.BASIC_FORMAT + " class=%(className)s func=%(funcName)s lineno=%(lineno)s" ) log = logging.getLogger() log.warning("module-level") def foo(): log.warning("inside foo function") def bar(): log.warning("inside bar function") class A: def foo(self): log.warning("inside A.foo method") class B: def foo(self): log.warning("inside B.foo method") A().foo() B().foo() foo() bar() ham() $ python3.7 findclass.py WARNING:root:module-level class= func= lineno=61 WARNING:root:inside A.foo method class=A func=A.foo lineno=71 WARNING:root:inside B.foo method class=B func=B.foo lineno=76 WARNING:root:inside foo function class= func=foo lineno=65 WARNING:root:inside bar function class= func=bar lineno=66 WARNING:root:inside ham function class= func=ham lineno=1 From endzis at freemail.hu Tue Sep 11 14:54:23 2018 From: endzis at freemail.hu (Bat erdene endzis) Date: Tue, 11 Sep 2018 20:54:23 +0200 (CEST) Subject: Python Probability Message-ID: Hello, I am new to Python and I?have an exercise which I struggle with. The question is: In the strategic board game called Risk, one player can attack up to three soldiers simultaneously, while the defending player can defend up to two. In the case of exactly three attackers and two defenders, the collision is as follows. An attacking player rolls three red dice while the defending player rolls two blue dice. Then they compare the bigest throws of the attacker and the defender. The lesser value loses a soldier, in the case of equal values the attacker loses one soldier. Then the second largest numbers are also compared in the same way. Thus, the battle has three outcomes: the attacker loses two soldiers, each side loses 1-1 soldiers, the defender loses two soldiers. Simulate 1000 times the experiment and determine the relative frequency of the three events.Simulate 1000000 times the experiment and determine the relative frequency of the three events.Calculate the exact probability of the three outcomes by examining all possible cases. The probability is the ratio of the favorable cases and the total number of cases. Write these results with 5 decimal places leaving 3 spaces between them! The output of the program looks like this (of course with other numbers) Attacker Draw Defender 1000 experiment 0.35222 0.44444 0.20334 1000000 experiment 0.33988 0.43011 0.23001 Probability 0.34000 0.43000 0.23000 The aim of this task is to get acquainted with the classical probability field, the relative frequency and the relation of it to the probability.Programming goal: recalling the basic elements of Python programming and generating random numbers.Help: by loading the random package (import random) and calling?random.random()?one may get a random number between 0 and 1 (by uniform distribution). The code?int(random.random()*6)+1?gives back an integer number between 1 and 6. So I did like: import random def dice(): ? ? attacker_dice=[random.randint(1,6) for _ in range(3)] ? ? defender_dice=[random.randint(1,6) for _ in range(2)] ? ? a=max(attacker_dice) ? ? b=max(defender_dice) ? ? for i in range(1000): ? ? ? ? F=0 ? ? ? ? S=0 ? ? ? ? T=0 ? ? ? ? if a>b: ? ? ? ? ? ? F+=1 ? ? ? ? if a==b: ? ? ? ? ? ? S+=1 ? ? ? ? else: ? ? ? ? ? ? T+=1 and I wanted to divide the F,T,S with 6^5 and make a table. But its giving me zeros or 333. And to get 5digits after the zero i wanted to use?"%.5f " %First.? Could you help me to finish this, and tell me what am I doing wrong? Thank you From niourf at gmail.com Tue Sep 11 15:21:13 2018 From: niourf at gmail.com (Nicolas Hug) Date: Tue, 11 Sep 2018 15:21:13 -0400 Subject: Pretty printing dicts with compact=True In-Reply-To: References: Message-ID: <867e93f1-7732-fd16-bc22-97baacb463a5@gmail.com> > To me it also seems to be the most sensible behaviour, since > dictionaries with their keys and values are different from most other > sequences. You've got a point but 1. That goes against the compact=True expected behaviour 2. Small dicts (e.g. /{x: x for x in range(5)}/) are still printed on a single line (regardless of the compact parameter), so I don't believe that was the rationale behind this behaviour. On 9/11/18 1:05 PM, Max Zettlmei?l wrote: > On Tue, Sep 11, 2018 at 1:58 PM, Nicolas Hug wrote: >> pprint({x: x for x in range(15)}, compact=True) >> >> would be be printed in 15 lines while it could fit on 2. >> >> >> Is this a bug or was this decided on purpose? > It is on purpose as can be seen in the code for pprint [1], which > calls _format [2], which in the case of a dictionary calls > _pprint_dict [3], which ultimately calls _format_dict_items [4]. > (which does not use compact or rather _compact) > > To me it also seems to be the most sensible behaviour, since > dictionaries with their keys and values are different from most other > sequences. In a dictionary the relation between keys and values is the > most important one and reading a dictionary certainly is easier if > each key value pair has a line of it's own. (Especially if the keys > and values vary a lot in their lengths.) > > [1] https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/pprint.py#L138 > [2] https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/pprint.py#L154 > [3] https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/pprint.py#L180 > [4] https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/pprint.py#L333 From pkpearson at nowhere.invalid Tue Sep 11 17:36:02 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 11 Sep 2018 21:36:02 GMT Subject: Python Probability References: Message-ID: On Tue, 11 Sep 2018 20:54:23 +0200 (CEST), Bat erdene endzis wrote: [snip] > def dice(): > attacker_dice=[random.randint(1,6) for _ in range(3)] > defender_dice=[random.randint(1,6) for _ in range(2)] > a=max(attacker_dice) > b=max(defender_dice) > for i in range(1000): > F=0 > S=0 > T=0 > if a>b: > F+=1 > if a==b: > S+=1 > else: > T+=1 Do you really want to set F, S, and T back to zero on each pass through that loop? Presumably you want to remove a from attacker_dice and b from defender_dicce and repeat the comparison with the new maxes. -- To email me, substitute nowhere->runbox, invalid->com. From gherron at digipen.edu Tue Sep 11 17:43:31 2018 From: gherron at digipen.edu (Gary Herron) Date: Tue, 11 Sep 2018 14:43:31 -0700 Subject: Python Probability In-Reply-To: References: Message-ID: <8b3b9cf5-6fc0-42a1-5270-c0f751e0f1af@digipen.edu> On 09/11/2018 11:54 AM, endzis at freemail.hu wrote: > Hello, > > I am new to Python and I?have an exercise which I struggle with. > > The question is: > In the strategic board game called Risk, one player can attack up to three soldiers simultaneously, while the defending player can defend up to two. In the case of exactly three attackers and two defenders, the collision is as follows. An attacking player rolls three red dice while the defending player rolls two blue dice. Then they compare the bigest throws of the attacker and the defender. The lesser value loses a soldier, in the case of equal values the attacker loses one soldier. Then the second largest numbers are also compared in the same way. Thus, the battle has three outcomes: the attacker loses two soldiers, each side loses 1-1 soldiers, the defender loses two soldiers. > Simulate 1000 times the experiment and determine the relative frequency of the three events.Simulate 1000000 times the experiment and determine the relative frequency of the three events.Calculate the exact probability of the three outcomes by examining all possible cases. The probability is the ratio of the favorable cases and the total number of cases. Write these results with 5 decimal places leaving 3 spaces between them! The output of the program looks like this (of course with other numbers) > > > Attacker Draw Defender > 1000 experiment 0.35222 0.44444 0.20334 > 1000000 experiment 0.33988 0.43011 0.23001 > Probability 0.34000 0.43000 0.23000 > > > > The aim of this task is to get acquainted with the classical probability field, the relative frequency and the relation of it to the probability.Programming goal: recalling the basic elements of Python programming and generating random numbers.Help: by loading the random package (import random) and calling?random.random()?one may get a random number between 0 and 1 (by uniform distribution). The code?int(random.random()*6)+1?gives back an integer number between 1 and 6. > > So I did like: > import random > > def dice(): > ? ? attacker_dice=[random.randint(1,6) for _ in range(3)] > ? ? defender_dice=[random.randint(1,6) for _ in range(2)] > ? ? a=max(attacker_dice) > ? ? b=max(defender_dice) > ? ? for i in range(1000): > ? ? ? ? F=0 > ? ? ? ? S=0 > ? ? ? ? T=0 > ? ? ? ? if a>b: > ? ? ? ? ? ? F+=1 > ? ? ? ? if a==b: > ? ? ? ? ? ? S+=1 > ? ? ? ? else: > ? ? ? ? ? ? T+=1 Every time through this loop, you set F, S and T to zero.? If you want those variables to accumulate values, move the three initialization lines to before the loop: F = 0 S = 0 T = 0 for ... ?? if a>b: ???? F += 1 ?? ... and so on ... But you have another problem.? You simulate rolling the dice only once.? For your 1000 trials, you need to roll the dice 1000 times. The first few lines that simulate the dice roll must be inside the loop so that each pass through the loop rolls the dice. > and I wanted to divide the F,T,S with 6^5 and make a table. But its giving me zeros or 333. And to get 5digits after the zero i wanted to use?"%.5f " %First. > > Could you help me to finish this, and tell me what am I doing wrong? > > Thank you -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From gherron at digipen.edu Tue Sep 11 17:47:38 2018 From: gherron at digipen.edu (Gary Herron) Date: Tue, 11 Sep 2018 14:47:38 -0700 Subject: Python Probability In-Reply-To: References: Message-ID: <041f292d-49d0-1a15-3bc8-94601cd59b18@digipen.edu> On 09/11/2018 11:54 AM, endzis at freemail.hu wrote: > Hello, > > I am new to Python and I?have an exercise which I struggle with. > > The question is: > In the strategic board game called Risk, one player can attack up to three soldiers simultaneously, while the defending player can defend up to two. In the case of exactly three attackers and two defenders, the collision is as follows. An attacking player rolls three red dice while the defending player rolls two blue dice. Then they compare the bigest throws of the attacker and the defender. The lesser value loses a soldier, in the case of equal values the attacker loses one soldier. Then the second largest numbers are also compared in the same way. Thus, the battle has three outcomes: the attacker loses two soldiers, each side loses 1-1 soldiers, the defender loses two soldiers. > Simulate 1000 times the experiment and determine the relative frequency of the three events.Simulate 1000000 times the experiment and determine the relative frequency of the three events.Calculate the exact probability of the three outcomes by examining all possible cases. The probability is the ratio of the favorable cases and the total number of cases. Write these results with 5 decimal places leaving 3 spaces between them! The output of the program looks like this (of course with other numbers) > > > Attacker Draw Defender > 1000 experiment 0.35222 0.44444 0.20334 > 1000000 experiment 0.33988 0.43011 0.23001 > Probability 0.34000 0.43000 0.23000 > > > > The aim of this task is to get acquainted with the classical probability field, the relative frequency and the relation of it to the probability.Programming goal: recalling the basic elements of Python programming and generating random numbers.Help: by loading the random package (import random) and calling?random.random()?one may get a random number between 0 and 1 (by uniform distribution). The code?int(random.random()*6)+1?gives back an integer number between 1 and 6. > > So I did like: > import random > > def dice(): > ? ? attacker_dice=[random.randint(1,6) for _ in range(3)] > ? ? defender_dice=[random.randint(1,6) for _ in range(2)] > ? ? a=max(attacker_dice) > ? ? b=max(defender_dice) > ? ? for i in range(1000): > ? ? ? ? F=0 > ? ? ? ? S=0 > ? ? ? ? T=0 > ? ? ? ? if a>b: > ? ? ? ? ? ? F+=1 > ? ? ? ? if a==b: > ? ? ? ? ? ? S+=1 > ? ? ? ? else: > ? ? ? ? ? ? T+=1 Every time through this loop, you set F, S and T to zero.? If you want those variables to accumulate values, move the three initialization lines to before the loop: F = 0 S = 0 T = 0 for ... ?? if a>b: ???? F += 1 ?? ... and so on ... But you have another problem.? You simulate rolling the dice only once.? For your 1000 trials, you need to roll the dice 1000 times. The first few lines that simulate the dice roll must be inside the loop so that each pass through the loop rolls the dice. > and I wanted to divide the F,T,S with 6^5 and make a table. But its giving me zeros or 333. And to get 5digits after the zero i wanted to use?"%.5f " %First. > > Could you help me to finish this, and tell me what am I doing wrong? > > Thank you -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From 2QdxY4RzWzUUiLuE at potatochowder.com Tue Sep 11 18:45:27 2018 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Tue, 11 Sep 2018 18:45:27 -0400 Subject: "glob.glob('weirdness')" Any thoughts? In-Reply-To: References: Message-ID: <48ee21d4-bdf2-79f2-eba9-621f02a92fcd@potatochowder.com> On 9/11/18 6:24 PM, Gilmeh Serda wrote: > I think this is no different than RegEx matching, so the routine really > shouldn't be called glob() but the_regex_variations_opus_five(). Maybe your version should be called crippled_glob. Globbing has a long history, longer than many of the people who use it. See . > If there really is a need for other stuff with brackets and what not, > this could go into a subclass of glob, say glob.brain_hemorrhage() or > something, for those so inclined to use it. Or maybe a keyword > parameter finicky=True/False. In their simplest form, the brackets match alternatives. For example, file[1234].text matches file1.text, file2.text, file3.text, and file4.text, but not file_something_else.text. Dan From ethan at stoneleaf.us Tue Sep 11 21:11:39 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 11 Sep 2018 18:11:39 -0700 Subject: final thoughts on [Re: don't quite understand mailing list] In-Reply-To: References: <39f7985fde9446f08c9ac056f3d28373@lmco.com> <20180906194222.5qvibrr3zr2z4gyc@ghostArch.localdomain> <5B9188BE.6010600@stoneleaf.us> <87k1nx2a62.fsf@elektro.pacujo.net> Message-ID: <27c92501-7739-04bf-e2a2-3a30e6d13601@stoneleaf.us> On 09/07/2018 05:07 PM, Steven D'Aprano wrote: > On Fri, 07 Sep 2018 07:39:33 +0300, Marko Rauhamaa wrote: >> I'm with Ethan on this one. >> >> There was nothing in the original posting that merited ridicule. > > Then its a good thing there was nothing in the response that was ridicule. Ridicule may not be the exact word for the contents of the first response, but it's close enough. > (A mild rebuke for a mild social faux pas is not ridicule.) Asking for help is not a social faux pas, at least not on this list. -- ~Ethan~ Python List Moderator P.S. Please do not respond to this thread unless you are trying to help the original poster. From alon.najman at gmail.com Tue Sep 11 22:51:01 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Tue, 11 Sep 2018 19:51:01 -0700 (PDT) Subject: GUI, Python2.7- how to build a loop with a button + textbox Message-ID: <67d20e33-c92c-4a46-980e-0da27fb44bca@googlegroups.com> hi, on python 2.7 how do I build a loop with a button + textbox? for example: I want the user to enter is name and then press "ok" button, I want his name to be printed 5 times. thanks! :) you people are amazing it's almost better then stackoverflow :D From ethan at stoneleaf.us Wed Sep 12 01:05:18 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 11 Sep 2018 22:05:18 -0700 Subject: Enum with nested classes or with types as members Message-ID: <059cd14d-5d13-8218-2bb3-0518e151ecd3@stoneleaf.us> Greetings! So the stdlib Enum has been around for a few years now. Has anyone written an enum that either had types as members: class Types(Enum): Int = int Str = str or that had nested classes: class Types(Enum): class Contained(Enum): circle = 1 square = 2 class style: something = 'yay!' ? If you have, why? Were you able to do everything you wanted, or did you have to work around any issues? I'm asking because in doing some work on Enum it became apparent to me that having nested classes was not a smooth, satisfying experience, and I'm considering treating them the same way as methods (they will no longer be converted into members). So if you use that functionality, tell me now! :) -- ~Ethan~ From tjol at tjol.eu Wed Sep 12 04:25:19 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Wed, 12 Sep 2018 10:25:19 +0200 Subject: GUI, Python2.7- how to build a loop with a button + textbox In-Reply-To: <67d20e33-c92c-4a46-980e-0da27fb44bca@googlegroups.com> References: <67d20e33-c92c-4a46-980e-0da27fb44bca@googlegroups.com> Message-ID: <325c33e4-4b5d-9a56-4543-e4f791621901@tjol.eu> On 12/09/18 04:51, alon.najman at gmail.com wrote: > hi, > > on python 2.7 Please use Python 3. > how do I build a loop with a button + textbox? There are many GUI libraries. Tkinter is part of the standard library and appears to be well-documented. https://docs.python.org/3/library/tkinter.html A good (and normally less ugly) alternative is Qt, using either PyQt5 or PySide2 for Python bindings. > > for example: > > I want the user to enter is name and then press "ok" button, I want his name to be printed 5 times. > > > thanks! :) you people are amazing it's almost better then stackoverflow :D From ben+python at benfinney.id.au Wed Sep 12 06:27:32 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 12 Sep 2018 20:27:32 +1000 Subject: Enum with nested classes or with types as members References: <059cd14d-5d13-8218-2bb3-0518e151ecd3@stoneleaf.us> Message-ID: <86in3b57u3.fsf@benfinney.id.au> Ethan Furman writes: > I'm asking because in doing some work on Enum it became apparent to me > that having nested classes was not a smooth, satisfying experience, > and I'm considering treating them the same way as methods (they will > no longer be converted into members). For reference (and to hopefully better inform this discussion) the topic, of Enum subclasses with nested class attributes, was raised recently by Ethan, and several conflicting positions were aired back then. > So if you use that functionality, tell me now! :) Thanks for keeping this going, I hope a consensus can emerge. -- \ ?If we listen only to those who are like us, we will squander | `\ the great opportunity before us: To live together peacefully in | _o__) a world of unresolved differences.? ?David Weinberger | Ben Finney From tienrua at gmail.com Wed Sep 12 09:43:43 2018 From: tienrua at gmail.com (tienrua at gmail.com) Date: Wed, 12 Sep 2018 06:43:43 -0700 (PDT) Subject: Running a second wsgi script from within the first wsgi script In-Reply-To: <4f353819-8ac8-4adc-8175-6eb95d2165a8@googlegroups.com> References: <4f353819-8ac8-4adc-8175-6eb95d2165a8@googlegroups.com> Message-ID: <0f0cf4b2-0c01-4c3a-b0b2-74e6b1a0ffe6@googlegroups.com> Actualy only one wsgi script can run(mean apache handler redirector), your server got "superhost.gr" name but this outer namespace(on apache.conf virtual server *:80), you need call local name for internal accessing. Replace "http://superhost.gr/clientele" to ["http://127.0.0.1/clientele", or "http://localhost/clientele"]. Request mode is important local>>global, global>>local, local>>local , i can't imagine which method you are using. I hope helpfull, kala imera! From fbergmann at suse.de Wed Sep 12 10:29:34 2018 From: fbergmann at suse.de (Florian Bergmann) Date: Wed, 12 Sep 2018 16:29:34 +0200 Subject: getfqdn passes a hostname to gethostbyaddr instead of an ip address Message-ID: Hello, While I was debugging some salt issues I dug into the python code and found a piece of code in the `socket.py` module that surprised my a bit: In the `getfqdn` function the `gethostbyaddr` name function is being called with a `hostname` instead of an `ipaddress`: ```python def getfqdn(name=''): """Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname from gethostname() is returned. """ name = name.strip() if not name or name == '0.0.0.0': name = gethostname() # (1) try: hostname, aliases, ipaddrs = gethostbyaddr(name) # (2) except error: pass else: aliases.insert(0, hostname) for name in aliases: if '.' in name: break else: name = hostname return name ``` 1. `gethostname()`: The documentation states: ``` Return a string containing the hostname of the machine where the Python interpreter is currently executing. If you want to know the current machine?s IP address, you may want to use gethostbyname(gethostname()). ``` 2. `gethostbyaddr()`: Also from the documentation: ``` Return a triple (hostname, aliaslist, ipaddrlist) where hostname is the primary host name responding to the *given ip_address* (...) ``` As the documentation states it expects an `ip_address` and not a hostname, but it is given a `hostname` instead. I used the following two snippets to check the different behaviors: ``` python -c 'import socket; print(socket.gethostbyaddr(socket.gethostbyname(socket.gethostname())))' ``` ``` python -c 'import socket; print(socket.gethostbyaddr(socket.gethostname()))' ``` Now on *most* of my machines the results are exactly the same, but on some it differs (which I actually attribute to strange `/etc/hosts` configurations). On the other hand I feel given the documentation, passing the `ip_address` would be the right thing to do, so I am wondering if I am missing something very obvious here (especially given that the code seems to be unchanged for 18 years). Best regards, Florian From alister.ware at ntlworld.com Wed Sep 12 11:41:46 2018 From: alister.ware at ntlworld.com (Alister) Date: Wed, 12 Sep 2018 15:41:46 GMT Subject: Sending file to the user gives UnicodeEncodeError in Flask framework References: <1e731169-a414-43e8-8ea8-c81edc863ddd@googlegroups.com> Message-ID: <_samD.597287$kv.81240@fx21.am4> On Wed, 12 Sep 2018 06:57:36 -0700, ????? ?????? wrote: > I want to send the user a file when he clicks the appropriate button and > I'm suing the following. > > # Prepare selected file for download... > send_file( '/home/nikos/wsgi/static/files/' + filename ) > > But no matter what file the usser selects iam always receiving this > response. > > > [Wed Sep 12 14:10:48.450211 2018] [wsgi:error] [pid 5172] [remote > 46.103.174.201:14089] File "/home/nikos/wsgi/downloads.py", line > 182, in file [Wed Sep 12 14:10:48.450214 2018] [wsgi:error] [pid > 5172] [remote 46.103.174.201:14089] send_file( > '/home/nikos/wsgi/static/files/' + filename ) > [Wed Sep 12 14:10:48.450219 2018] [wsgi:error] [pid 5172] [remote > 46.103.174.201:14089] File > "/usr/lib/python3.6/site-packages/flask/helpers.py", line 592, in > send_file [Wed Sep 12 14:10:48.450221 2018] [wsgi:error] [pid 5172] > [remote 46.103.174.201:14089] file = open(filename, 'rb') > [Wed Sep 12 14:10:48.450237 2018] [wsgi:error] [pid 5172] [remote > 46.103.174.201:14089] UnicodeEncodeError: 'ascii' codec can't encode > characters in position 30-39: ordinal not in range(128) > > > How will I be able to send the selected file to the user? try providing enough code for people to reproduce the problem & you may get some assistance although i suspect many posters may believe you to be a previous poster (also called Nicos) who was a disaster looking for somewhere to happen, if that is not you then I would also suggest you try reading https://www.biostars.org/p/75548/ -- "Free markets select for winning solutions." -- Eric S. Raymond From rhodri at kynesim.co.uk Wed Sep 12 12:08:50 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 12 Sep 2018 17:08:50 +0100 Subject: getfqdn passes a hostname to gethostbyaddr instead of an ip address In-Reply-To: References: Message-ID: <3b5968a0-8531-4e34-43a1-0cc7d4deb6d0@kynesim.co.uk> On 12/09/18 15:29, Florian Bergmann wrote: > Hello, > > While I was debugging some salt issues I dug into the python code and found a > piece of code in the `socket.py` module that surprised my a bit: > > In the `getfqdn` function the `gethostbyaddr` name function is being called with > a `hostname` instead of an `ipaddress`: [snip] > 2. `gethostbyaddr()`: > > Also from the documentation: > > ``` > Return a triple (hostname, aliaslist, ipaddrlist) where hostname is the primary host name responding to the *given ip_address* (...) > ``` > > As the documentation states it expects an `ip_address` and not a hostname, > but it is given a `hostname` instead. I believe the online documentation is wrong. The help text certainly differs: Help on built-in function gethostbyaddr in module _socket: gethostbyaddr(...) gethostbyaddr(host) -> (name, aliaslist, addresslist) Return the true host name, a list of aliases, and a list of IP addresses, for a host. The host argument is a string giving a host name or IP number. -- Rhodri James *-* Kynesim Ltd From steve+comp.lang.python at pearwood.info Wed Sep 12 12:16:05 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Wed, 12 Sep 2018 16:16:05 +0000 (UTC) Subject: Trying to use threading.local() Message-ID: I'm originally posted this on the Python-Ideas list, but this is probably more appropriate. import time from threading import Thread, local def func(): pass def attach(value): func.__params__ = local() func.__params__.value = value def worker(i): print("called from thread %s" % i) attach(i) assert func.__params__.value == i time.sleep(3) value = func.__params__.value if value != i: print("mismatch", i, value) for i in range(5): t = Thread(target=worker, args=(i,)) t.start() print() When I run that, each of the threads print their "called from ..." message, the assertions all pass, then a couple of seconds later they consistently all raise exceptions: Exception in thread Thread-1: Traceback (most recent call last): File "/usr/local/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/usr/local/lib/python3.5/threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "", line 5, in worker AttributeError: '_thread._local' object has no attribute 'value' What am I doing wrong? -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson From tjol at tjol.eu Wed Sep 12 14:00:41 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Wed, 12 Sep 2018 20:00:41 +0200 Subject: getfqdn passes a hostname to gethostbyaddr instead of an ip address In-Reply-To: References: Message-ID: On 12/09/18 16:29, Florian Bergmann wrote: > On the other hand I feel given the documentation, passing the `ip_address` would > be the right thing to do, so I am wondering if I am missing something very > obvious here (especially given that the code seems to be unchanged for 18 years). Whatever the docs say, turning the hostname into an IP address and working with that would be incorrect. Say we have a server, 'fred.weasley.example.com', which is also known as 'www.example.com'. Its reverse DNS pointer is 'fred.weasley.example.com'. Now, if we have 'example.com' on our DNS search path, the FQDN of 'www' is 'www.example.com', while the FQDN derived from the IP would be 'fred.weasley.example.com'. Right? From pkpearson at nowhere.invalid Wed Sep 12 14:51:35 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 12 Sep 2018 18:51:35 GMT Subject: GUI, Python2.7- how to build a loop with a button + textbox References: <67d20e33-c92c-4a46-980e-0da27fb44bca@googlegroups.com> Message-ID: On Tue, 11 Sep 2018 19:51:01 -0700 (PDT), alon.najman at gmail.com wrote: > hi, > > on python 2.7 how do I build a loop with a button + textbox? > > for example: > > I want the user to enter is name and then press "ok" button, I want > his name to be printed 5 times. Tested on Python 3.5.3: import browsergui as bg def button_clicked(): for i in range(5): print(text_field.value) text_field = bg.TextField() bg.GUI(text_field, bg.Button("OK", callback=button_clicked)).run(quiet=True) If you don't have browsergui, "pip install browsergui". -- To email me, substitute nowhere->runbox, invalid->com. From python at mrabarnett.plus.com Wed Sep 12 15:44:36 2018 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 12 Sep 2018 20:44:36 +0100 Subject: Trying to use threading.local() In-Reply-To: References: Message-ID: On 2018-09-12 17:16, Steven D'Aprano wrote: > I'm originally posted this on the Python-Ideas list, but this is probably > more appropriate. > > > import time > from threading import Thread, local > > def func(): > pass > > def attach(value): > func.__params__ = local() > func.__params__.value = value > > > def worker(i): > print("called from thread %s" % i) > attach(i) > assert func.__params__.value == i > time.sleep(3) > value = func.__params__.value > if value != i: > print("mismatch", i, value) > > for i in range(5): > t = Thread(target=worker, args=(i,)) > t.start() > > print() > > > > > > When I run that, each of the threads print their "called from ..." > message, the assertions all pass, then a couple of seconds later they > consistently all raise exceptions: > > Exception in thread Thread-1: > Traceback (most recent call last): > File "/usr/local/lib/python3.5/threading.py", line 914, in > _bootstrap_inner > self.run() > File "/usr/local/lib/python3.5/threading.py", line 862, in run > self._target(*self._args, **self._kwargs) > File "", line 5, in worker > AttributeError: '_thread._local' object has no attribute 'value' > > > > What am I doing wrong? > I've changed the code to: import time from threading import Thread, local def func(): pass def attach(value): func.__params__ = local() func.__params__.value = value def worker(i): print("called from thread %s" % i) attach(i) print('thread %s before sleep => %s' % (i, func.__params__)) assert func.__params__.value == i time.sleep(1) print('thread %s after sleep => %s' % (i, func.__params__)) time.sleep(1) print('thread %s finally => %s' % (i, func.__params__)) print('stored value for thread %s is %s' % (i, getattr(func.__params__, 'value', 'MISSING'))) for i in range(2): t = Thread(target=worker, args=(i,)) t.start() print() My output is: called from thread 0 thread 0 before sleep => <_thread._local object at 0x0000014936FB8C50> called from thread 1 thread 1 before sleep => <_thread._local object at 0x0000014936FB8CA8> thread 1 after sleep => <_thread._local object at 0x0000014936FB8CA8> thread 0 after sleep => <_thread._local object at 0x0000014936FB8CA8> thread 0 finally => <_thread._local object at 0x0000014936FB8CA8> stored value for thread 0 is MISSING thread 1 finally => <_thread._local object at 0x0000014936FB8CA8> stored value for thread 1 is 1 Note that thread 1 is overwriting the reference to the thread-local storage of thread 0. It looks like what's happening is that thread 0 ends up trying to read the storage for thread 1, but as it's for a different thread, the contents aren't visible to it. From __peter__ at web.de Wed Sep 12 16:14:02 2018 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Sep 2018 22:14:02 +0200 Subject: Trying to use threading.local() References: Message-ID: Steven D'Aprano wrote: > I'm originally posted this on the Python-Ideas list, but this is probably > more appropriate. > > > import time > from threading import Thread, local > > def func(): > pass > > def attach(value): # no new local() here > func.__params__.value = value > > def worker(i): > print("called from thread %s" % i) > attach(i) > assert func.__params__.value == i > time.sleep(3) > value = func.__params__.value > if value != i: > print("mismatch", i, value) func.__params__ = local() > > for i in range(5): > t = Thread(target=worker, args=(i,)) > t.start() > > print() > > > > > > When I run that, each of the threads print their "called from ..." > message, the assertions all pass, then a couple of seconds later they > consistently all raise exceptions: > > Exception in thread Thread-1: > Traceback (most recent call last): > File "/usr/local/lib/python3.5/threading.py", line 914, in > _bootstrap_inner > self.run() > File "/usr/local/lib/python3.5/threading.py", line 862, in run > self._target(*self._args, **self._kwargs) > File "", line 5, in worker > AttributeError: '_thread._local' object has no attribute 'value' > > > > What am I doing wrong? As I understand it you need one local() instance that is shared by all workers. Every thead will then see thread-specific values. Once you overwrite func.__params__ with a new local() in the next worker the data from the previously initialised worker is lost. From dieter at handshake.de Thu Sep 13 00:55:44 2018 From: dieter at handshake.de (dieter) Date: Thu, 13 Sep 2018 06:55:44 +0200 Subject: Sending file to the user gives UnicodeEncodeError in Flask framework References: <1e731169-a414-43e8-8ea8-c81edc863ddd@googlegroups.com> <_samD.597287$kv.81240@fx21.am4> Message-ID: <87sh2e6lnz.fsf@handshake.de> > On Wed, 12 Sep 2018 06:57:36 -0700, ????? ?????? wrote: >> I want to send the user a file when he clicks the appropriate button and >> I'm suing the following. >> >> # Prepare selected file for download... >> send_file( '/home/nikos/wsgi/static/files/' + filename ) >> >> But no matter what file the usser selects iam always receiving this >> response. >> >> >> [Wed Sep 12 14:10:48.450211 2018] [wsgi:error] [pid 5172] [remote >> 46.103.174.201:14089] File "/home/nikos/wsgi/downloads.py", line >> 182, in file [Wed Sep 12 14:10:48.450214 2018] [wsgi:error] [pid >> 5172] [remote 46.103.174.201:14089] send_file( >> '/home/nikos/wsgi/static/files/' + filename ) >> [Wed Sep 12 14:10:48.450219 2018] [wsgi:error] [pid 5172] [remote >> 46.103.174.201:14089] File >> "/usr/lib/python3.6/site-packages/flask/helpers.py", line 592, in >> send_file [Wed Sep 12 14:10:48.450221 2018] [wsgi:error] [pid 5172] >> [remote 46.103.174.201:14089] file = open(filename, 'rb') >> [Wed Sep 12 14:10:48.450237 2018] [wsgi:error] [pid 5172] [remote >> 46.103.174.201:14089] UnicodeEncodeError: 'ascii' codec can't encode >> characters in position 30-39: ordinal not in range(128) The "UnicodeEncodeError" indicates that Python tries to convert (= "encode") a unicode string into bytes and the corresponding encoding is unable to do so. It is quite natural, that the "send_file" wants to transfer bytes. It is not natural that in between it has to handle unicode. The "open(filename, 'rb')" should open the file in binary (= bytes) mode; subsequent reads should return bytes. But, potentially, the "open(filename, 'rb')", itself, raises the "UnicodeEncodeError". Is it possible that your "filename" contains special characters? In this case, you may need to encode (the complete!) filename yourself with an encoding appropriate for your file system (likely "utf-8") before you pass it to "send_file". From christysonia at gmail.com Thu Sep 13 03:11:35 2018 From: christysonia at gmail.com (christysonia at gmail.com) Date: Thu, 13 Sep 2018 00:11:35 -0700 (PDT) Subject: trying to connect the setarrange and blendshape input target weight while running the script am getting error in the 8th line. (for each in lip_val_list: ) Message-ID: <16bd8728-2c65-4be5-ab6b-14d3201778f0@googlegroups.com> lf_main_attr = "head_icon.Lf_Sticky_Lips" rt_main_attr = "head_icon.Rt_Sticky_Lips" lip_val_list = [18, 14] lip_name_list = ['upperLip', 'lowerLip'] name_counter = 0 for each in lip_val_list: half_val = (each / 2) + 1 total_val = each + 1 div_val = 10.0 / half_val counter = 0 while(counter References: <16bd8728-2c65-4be5-ab6b-14d3201778f0@googlegroups.com> Message-ID: Your indentation of that line is incorrect. You also have indentation errors on lines 14 and 21.? (Possibly more, that's all the further I checked.)? Do you understand Python's indentation rules? In the future, you can do a lot better to help us help you. First, tell us the error you got instead of just saying you got an error.? (Copy and paste the full error message.)? Also tell us what version of Python (2 or 3), and what platform, in case any of that matters.?? Your subject line contains lots of meaningless distractions:? What's a setarrange, what's a blendshape, what's an input target weight,? what does it mean to connect them?? Either none of that is important (as is the case in this simple indentation error), so don't include such distractions, or it does matter, so take the time to define those terms. Gary Herron On 09/13/2018 12:11 AM, christysonia at gmail.com wrote: > lf_main_attr = "head_icon.Lf_Sticky_Lips" > rt_main_attr = "head_icon.Rt_Sticky_Lips" > lip_val_list = [18, 14] > lip_name_list = ['upperLip', 'lowerLip'] > > name_counter = 0 > for each in lip_val_list: > half_val = (each / 2) + 1 > total_val = each + 1 > div_val = 10.0 / half_val > counter = 0 > while(counter lip_sr = pm.shadingNode( 'setRange', asUtility=True, n='lf_' + lip_name_list[name_counter] + str(counter+1) + '_setRange') > pm.setAttr(lip_sr + '.oldMaxX', (div_val * (counter+1))) > pm.setAttr(lip_sr + '.oldMinX', (div_val * counter)) > pm.setAttr(lip_sr + '.maxX', 0) > pm.setAttr(lip_sr + '.minX', 1) > if counter == (half_val - 1): > pm.setAttr(lip_sr + '.minX', 0.5) > pm.connectAttr(lf_main_attr, lip_sr + '.valueX', f=True) > lip_flip_sr = pm.shadingNode( 'setRange', asUtility=True, n='lf_' + lip_name_list[name_counter] + '_flip' + str(counter+1) + '_setRange') > pm.setAttr(lip_flip_sr + '.oldMaxX', 1) > if counter == (half_val - 1): > pm.setAttr(lip_flip_sr + '.oldMaxX', 0.5) > pm.setAttr(lip_flip_sr + '.oldMinX', 0) > pm.setAttr(lip_flip_sr + '.maxX', 0) > pm.setAttr(lip_flip_sr + '.minX', 1) > if counter == (half_val - 1): > pm.setAttr(lip_flip_sr + '.minX', 0.5) > pm.connectAttr(lip_sr + '.outValueX', lip_flip_sr + '.valueX', f=True) > if counter == (half_val - 1): > mid_pma = pm.shadingNode( 'plusMinusAverage', asUtility=True, n='ct_' + lip_name_list[name_counter] + str(counter+1) + '_plusMinusAverage') > pm.connectAttr(lip_sr + '.outValueX', mid_pma + '.input2D[0].input2Dx', f=True) > pm.connectAttr(lip_flip_sr + '.outValueX', mid_pma + '.input2D[0].input2Dy', f=True) > else: > pm.connectAttr(lip_sr + '.outValueX', lip_name_list[name_counter] + '_wire_bShape.inputTarget[0].inputTargetGroup[0].targetWeights[' + str(counter) + ']', f=True) > pm.connectAttr(lip_flip_sr + '.outValueX', lip_name_list[name_counter] + '_wire_bShape.inputTarget[0].inputTargetGroup[1].targetWeights[' + str(counter) + ']', f=True) > counter = counter + 1 > #div_val = 10.0 / 39 > counter = half_val - 1 > rev_counter = half_val > while(counter lip_sr = pm.shadingNode( 'setRange', asUtility=True, n='rt_' + lip_name_list[name_counter] + str(counter+1) + '_setRange') > pm.setAttr(lip_sr + '.oldMaxX', (div_val * rev_counter)) > pm.setAttr(lip_sr + '.oldMinX', (div_val * (rev_counter-1))) > pm.setAttr(lip_sr + '.maxX', 0) > pm.setAttr(lip_sr + '.minX', 1) > if counter == (half_val - 1): > pm.setAttr(lip_sr + '.minX', 0.5) > pm.connectAttr(rt_main_attr, lip_sr + '.valueX', f=True) > lip_flip_sr = pm.shadingNode( 'setRange', asUtility=True, n='rt_' + lip_name_list[name_counter] + '_flip' + str(counter+1) + '_setRange') > pm.setAttr(lip_flip_sr + '.oldMaxX', 1) > if counter == (half_val - 1): > pm.setAttr(lip_flip_sr + '.oldMaxX', 0.5) > pm.setAttr(lip_flip_sr + '.oldMinX', 0) > pm.setAttr(lip_flip_sr + '.maxX', 0) > pm.setAttr(lip_flip_sr + '.minX', 1) > if counter == (half_val - 1): > pm.setAttr(lip_flip_sr + '.minX', 0.5) > pm.connectAttr(lip_sr + '.outValueX', lip_flip_sr + '.valueX', f=True) > if counter == (half_val - 1): > pm.connectAttr(lip_sr + '.outValueX', mid_pma + '.input2D[1].input2Dx', f=True) > pm.connectAttr(lip_flip_sr + '.outValueX', mid_pma + '.input2D[1].input2Dy', f=True) > pm.connectAttr(mid_pma + '.output2Dx', lip_name_list[name_counter] + '_wire_bShape.inputTarget[0].inputTargetGroup[0].targetWeights[' + str(counter) + ']', f=True) > pm.connectAttr(mid_pma + '.output2Dy', lip_name_list[name_counter] + '_wire_bShape.inputTarget[0].inputTargetGroup[1].targetWeights[' + str(counter) + ']', f=True) > else: > pm.connectAttr(lip_sr + '.outValueX', lip_name_list[name_counter] + '_wire_bShape.inputTarget[0].inputTargetGroup[0].targetWeights[' + str(counter) + ']', f=True) > pm.connectAttr(lip_flip_sr + '.outValueX', lip_name_list[name_counter] + '_wire_bShape.inputTarget[0].inputTargetGroup[1].targetWeights[' + str(counter) + ']', f=True) > counter = counter + 1 > rev_counter = rev_counter - 1 > name_counter = name_counter + 1? > > > -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From antoon.pardon at vub.be Thu Sep 13 06:21:26 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Thu, 13 Sep 2018 12:21:26 +0200 Subject: Trying to use threading.local() In-Reply-To: References: Message-ID: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> On 12-09-18 22:14, Peter Otten wrote: > As I understand it you need one local() instance that is shared by all > workers. Every thead will then see thread-specific values. It has always puzzled me how this is useful. The times I work with threads, I just put thread specific values in the local variables of the thread function. What is gained by using threading.local instances? -- Antoon Pardon From cs at cskk.id.au Thu Sep 13 06:42:38 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Thu, 13 Sep 2018 20:42:38 +1000 Subject: Trying to use threading.local() In-Reply-To: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> Message-ID: <20180913104238.GA32122@cskk.homeip.net> On 13Sep2018 12:21, Antoon Pardon wrote: >On 12-09-18 22:14, Peter Otten wrote: >> As I understand it you need one local() instance that is shared by all >> workers. Every thead will then see thread-specific values. > >It has always puzzled me how this is useful. The times I work with threads, >I just put thread specific values in the local variables of the thread function. That works if your thread function is self contained (only that function needs access to the thread specific values) or you can easily pass the thread specific values on to subsidiary functions if they're needed. >What is gained by using threading.local instances? Supposing you've got some longer lived objects which existed before your thread started and survive after it completes, which want to maintain some state for client threads, by which I mean your subsequent threads which may make use of these objects. For this purpose the long lived object wants to keep some distinct state for each client thread, because they may use it concurrently. Consider an object looking after a database, which automatically opens a database connection to serve each client thread when it is accessed. You'd make a threading.local instance to manage this connection, and each thread would see its own distinct connection by accessing that threading.local instance. There's any number of other examples, but they probably all exist around objects essentially external to your thread function which need to provide thread specific state which isn't constructed by the thread function itself but instead as a consequence of the function accessing the long lived object. I've got an example here where I maintain a stack of data source contexts for some data access. Calling code looks like this: with S: ... call functions which make use of "S" implicitly ... with S2: ... here we use "S2" implicitly ... ... back to using "S" ... ... back to whatever was in use previously ... The "S" context manager pushes itself onto a stack, and the access code makes use of whatever is on the top of that stack. This supports generic code which doesn't have to pass "S" to every single function call, including _through_ functions which never use "S" but themselve call other functions which do. So the current "S" is effectively a piece of global context, like the UNIX working directory (it is implicitly used when you open a file with a relative pathname). Now imagine that I have multiple threads working this way. I now need thread specific context stacks. I do this with a threading.local instance, with the stack an attribute of the threading.local. Multiple threads can now freely push and pop from the context stack without interfering with each other. Hoping this clarifies the use case. Cheers, Cameron Simpson From __peter__ at web.de Thu Sep 13 08:22:04 2018 From: __peter__ at web.de (Peter Otten) Date: Thu, 13 Sep 2018 14:22:04 +0200 Subject: Trying to use threading.local() References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> Message-ID: Antoon Pardon wrote: > On 12-09-18 22:14, Peter Otten wrote: >> As I understand it you need one local() instance that is shared by all >> workers. Every thead will then see thread-specific values. > > It has always puzzled me how this is useful. The times I work with > threads, I just put thread specific values in the local variables of the > thread function. That would be my preferred approach, too. Passing around variables through multiple levels of function calls may be inconvenient, but global variables tend to cause more trouble in the long run. > What is gained by using threading.local instances? It's magic; it confuses the uninitiated ;) From rosuav at gmail.com Thu Sep 13 08:29:36 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 13 Sep 2018 22:29:36 +1000 Subject: Trying to use threading.local() In-Reply-To: References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> Message-ID: On Thu, Sep 13, 2018 at 10:22 PM, Peter Otten <__peter__ at web.de> wrote: > Antoon Pardon wrote: > >> On 12-09-18 22:14, Peter Otten wrote: >>> As I understand it you need one local() instance that is shared by all >>> workers. Every thead will then see thread-specific values. >> >> It has always puzzled me how this is useful. The times I work with >> threads, I just put thread specific values in the local variables of the >> thread function. > > That would be my preferred approach, too. Passing around variables through > multiple levels of function calls may be inconvenient, but global variables > tend to cause more trouble in the long run. "Preferred" doesn't exclude the possibility that alternatives are needed, though. For example, good luck making decimal.Decimal contexts work correctly without the help of thread-locals - there MIGHT be a way to do it, but even if there is, it sure won't be pretty. ChrisA From __peter__ at web.de Thu Sep 13 11:07:57 2018 From: __peter__ at web.de (Peter Otten) Date: Thu, 13 Sep 2018 17:07:57 +0200 Subject: Trying to use threading.local() References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> Message-ID: Chris Angelico wrote: > On Thu, Sep 13, 2018 at 10:22 PM, Peter Otten <__peter__ at web.de> wrote: >> Antoon Pardon wrote: >> >>> On 12-09-18 22:14, Peter Otten wrote: >>>> As I understand it you need one local() instance that is shared by all >>>> workers. Every thead will then see thread-specific values. >>> >>> It has always puzzled me how this is useful. The times I work with >>> threads, I just put thread specific values in the local variables of the >>> thread function. >> >> That would be my preferred approach, too. Passing around variables >> through multiple levels of function calls may be inconvenient, but global >> variables tend to cause more trouble in the long run. > > "Preferred" doesn't exclude the possibility that alternatives are > needed, though. For example, good luck making decimal.Decimal contexts > work correctly without the help of thread-locals - there MIGHT be a > way to do it, but even if there is, it sure won't be pretty. I'm outside my comfort zone with both threads and decimal, but it appears that you can pass the context explicitly. So getcontext().prec = 10 a = Decimal(1) # magically determine context b = Decimal(3) might become context = Context(prec=10) a = Decimal(1, context=context) b = Decimal(3, context=context) However, the trouble begins with a/b # magically determine context which has no way to smuggle in a third argument. The workaround while not pretty is at least straightforward: context.divide(a, b) From rosuav at gmail.com Thu Sep 13 12:43:31 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 14 Sep 2018 02:43:31 +1000 Subject: Trying to use threading.local() In-Reply-To: References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> Message-ID: On Fri, Sep 14, 2018 at 1:07 AM, Peter Otten <__peter__ at web.de> wrote: > However, the trouble begins with > > a/b # magically determine context > > which has no way to smuggle in a third argument. The workaround while not > pretty is at least straightforward: > > context.divide(a, b) Exactly. You can pass a context to a function or method, but not to an operator. And if you demand that functions/methods be used for absolutely everything, just so you can pass a context around, you require that absolutely everyone write Decimal-exclusive APIs, which are then unable to handle other types of number. ChrisA From vigand805 at gmail.com Thu Sep 13 14:30:52 2018 From: vigand805 at gmail.com (V&R Dota2) Date: Thu, 13 Sep 2018 20:30:52 +0200 Subject: No subject Message-ID: >From vigan Hi i wold like to join in this list because i want to start programing with python pls acept this From martin.schoon at gmail.com Thu Sep 13 14:59:14 2018 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 13 Sep 2018 18:59:14 GMT Subject: Fumbling with emacs + elpy + flake8 Message-ID: I am trying to set up emacs for Python coding on my secondary computer. I follow these instructions but fail to make flake8 play with elpy: https://realpython.com/emacs-the-best-python-editor/#elpy-python-development I have done this some time in the past on my main computer and there it works just fine. I have compared the set-up of this on the two computers and fail to figure out why it works on one and not the other. There are a couple of things that are not the same on the computers: 1) The secondary computer has a later version of emacs installed. 2) I used pip3 install --user flake8 on the secondary computer but on the primary computer I think I left out the --user flag (not knowing about it at the time) but I have added the path to .local/bin and M-x elpy-config finds flake8 on both computers. Yet it does not work on my secondary computer... Any leads are greatly appreciated. /Martin PS Debian on both computers. From brian.j.oney at googlemail.com Thu Sep 13 15:44:16 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Thu, 13 Sep 2018 21:44:16 +0200 Subject: Fumbling with emacs + elpy + flake8 In-Reply-To: References: Message-ID: <1536867856.1672.3.camel@gmail.com> Hi Martin, I have messed around alot with the myriad emacs configurations out there. I found spacemacs and threw out my crappy but beloved .emacs config. I have looked back, but will stay put. http://spacemacs.org/ Fumbling is a nice word. Spacemacs caters to lots of programmers. I can honestly recommend giving it a serious look. It's a well conceived emacs configuration. ** Features - Auto-completion using [[https://github.com/proofit404/anaconda-mode][anaconda-mode]] - Code Navigation using [[https://github.com/proofit404/anaconda-mode][anaconda-mode]] - Documentation Lookup using [[https://github.com/proofit404/anaconda-mode][anaconda-mode]] and [[https://github.com/tsgates/pylookup][pylookup]] - Test Runners using [[https://github.com/syl20bnr/nose.el][nose.el]] or [[https://github.com/ionrock/pytest-el][pytest]] - Virtual Environment using [[https://github.com/jorgenschaefer/pyvenv][pyvenv]] and [[https://github.com/yyuu/pyenv][pyenv]] - semantic mode is enabled - PEP8 compliant formatting via [[https://github.com/google/yapf][YAPF]] - PEP8 checks with [[https://pypi.python.org/pypi/flake8][flake8]] or [[https://pypi.python.org/pypi/pylint/1.6.4][pylint]] - Suppression of unused import with [[https://github.com/myint/autoflake][autoflake]] - Use the ~%~ key to jump between blocks with [[https://github.com/redguardtoo/evil-matchit][evil-matchit]] - Sort imports with [[https://pypi.python.org/pypi/isort][isort]] For more see: ~/.emacs.d/layers/+lang/python/README.org Here's what I ask you to consider: pip install flake8 pip install --upgrade "jedi>=0.9.0" "json-rpc>=1.8.1" "service_factory>=0.1.5" if [ -d ~/.emacs.d ]; then \rm -rf ~/.emacs.d/; fi git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d emacs It may be a rabbit hole, but that adventure belongs to emacs, somehow. Cheers Brian From jf_byrnes at comcast.net Thu Sep 13 16:04:56 2018 From: jf_byrnes at comcast.net (Jim) Date: Thu, 13 Sep 2018 15:04:56 -0500 Subject: Looking for a Scrapy cheatsheet Message-ID: I'm in the process of learning Scrapy. I've read through the docs and a couple of tutorials, but I am getting bogged down because I can't find a page/table/chart that gives a nice concise overview of the available commands and methods. Googling hasn't found anything usable. So does anyone know of a cheatsheet I can download. Thanks, Jim From jqian at tibco.com Thu Sep 13 16:50:32 2018 From: jqian at tibco.com (Jason Qian) Date: Thu, 13 Sep 2018 16:50:32 -0400 Subject: Help on PyList 3.7.0 Message-ID: Hey, Need some help on PyList. #get path PyObject *path = PyObject_GetAttrString(sys, "path"); #new user path PyObject* newPath = PyUnicode_DecodeUTF8(userPath, strlen( userPath ), errors); #append newPath to path PyList_Append(path, newPath); How to check if the newPath is already in the path ? So, If the path contains the newPath, I will not append the newpath. Thanks for help From python at mrabarnett.plus.com Thu Sep 13 17:24:53 2018 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 13 Sep 2018 22:24:53 +0100 Subject: Help on PyList 3.7.0 In-Reply-To: References: Message-ID: On 2018-09-13 21:50, Jason Qian via Python-list wrote: > Hey, > > Need some help on PyList. > > > #get path > PyObject *path = PyObject_GetAttrString(sys, "path"); > > #new user path > PyObject* newPath = PyUnicode_DecodeUTF8(userPath, strlen( userPath ), > errors); > > #append newPath to path > PyList_Append(path, newPath); > > How to check if the newPath is already in the path ? > > So, If the path contains the newPath, I will not append the newpath. > > > Thanks for help > A list is a sequence. Use PySequence_Contains. From italienisch1987 at gmail.com Thu Sep 13 18:11:31 2018 From: italienisch1987 at gmail.com (Bobby) Date: Thu, 13 Sep 2018 15:11:31 -0700 (PDT) Subject: Python for System Verilog testbench Message-ID: I have a very simple System Verilog (SV) adder as my DUT (device under test). I would like to generate a test bench for this DUT based on the 'requirements'. I wrote its (DUT) functions in simple text as 'requirements' while following a particular syntax. Now through the help of grammar, I would like to give the requirement input to the grammar. Questions: (1) Considering my end goal, i.e. to generate some particular parts of SV testbench from requirements, any good python parser available ? (2) If I use python parser, will any kind of python scripting will help me to generate the testbench in SV for my DUT ? My confusion at this point is that most of all the literature I am reading suggests linguistic techniques. Any non-linguistic technique ? From ladynikon at gmail.com Fri Sep 14 02:27:51 2018 From: ladynikon at gmail.com (Danyelle Davis) Date: Fri, 14 Sep 2018 02:27:51 -0400 Subject: Looking for a Scrapy cheatsheet In-Reply-To: References: Message-ID: The one that sans provides seems pretty decent. Did you not like it? On Thu, Sep 13, 2018 at 4:05 PM Jim wrote: > I'm in the process of learning Scrapy. I've read through the docs and a > couple of tutorials, but I am getting bogged down because I can't find a > page/table/chart that gives a nice concise overview of the available > commands and methods. > > Googling hasn't found anything usable. So does anyone know of a > cheatsheet I can download. > > Thanks, Jim > > -- > https://mail.python.org/mailman/listinfo/python-list > From george at fischhof.hu Fri Sep 14 02:40:45 2018 From: george at fischhof.hu (George Fischhof) Date: Fri, 14 Sep 2018 08:40:45 +0200 Subject: Python for System Verilog testbench In-Reply-To: References: Message-ID: Bobby ezt ?rta (id?pont: 2018. szept. 14., P 0:16): > > I have a very simple System Verilog (SV) adder as my DUT (device under > test). I would like to generate a test bench for this DUT based on the > 'requirements'. I wrote its (DUT) functions in simple text as > 'requirements' while following a particular syntax. Now through the help > of grammar, I would like to give the requirement input to the grammar. > > Questions: > > (1) Considering my end goal, i.e. to generate some particular parts > of > SV testbench from requirements, any good python parser available > ? > > (2) If I use python parser, will any kind of python scripting will > help me to generate the testbench in SV for my DUT ? My confusion at this > point is that most of all the literature I am reading suggests linguistic > techniques. Any non-linguistic technique ? > > > -- > https://mail.python.org/mailman/listinfo/python-list Hi, Perhaps you should check articles about BDD, and you can use PyTest test framework with pytest-bdd plugin __george__ > > From alon.najman at gmail.com Fri Sep 14 03:09:44 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Fri, 14 Sep 2018 00:09:44 -0700 (PDT) Subject: python 3.7 - I try to close the thread without closing the GUI is it possible? Message-ID: <8f9e292e-39fc-41c0-9187-c36f1252beb1@googlegroups.com> python 3.7 - I try to close the thread without closing the GUI is it possible? here is my code, sorry I'm am new with python and generally with code XD . thanks all # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'AlonStockMarket.ui' # # Created by: PyQt5 UI code generator 5.11.2 # # WARNING! All changes made in this file will be lost! import time import sys import requests from lxml import html import requests import urllib.request, urllib.error, urllib.parse import _thread from PyQt5 import QtCore, QtGui, QtWidgets from multiprocessing import Pool global flag import threading import time exitFlag = 0 class myThread (threading.Thread): def __init__(self, threadID, name, counter): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter def run(self): print ("Starting " + self.name) print_time(self.name, self.counter, 5) print ("Exiting " + self.name) def print_time(threadName, delay, counter): print("hello, world") while True: time.sleep(15) f=open("flag.txt", "r") if f.mode == 'r': flag =f.read() timeHour = int(time.strftime('%H')) print("keep alive") print (time.strftime('%H:%M:%S')) while ((timeHour>16) and (timeHour<23)): print(time.strftime('%H:%M:%S')) price=get_quote('evok') time.sleep(5) if flag!=time.strftime("%d/%m/%Y") and price>4: print ("send SMS") import requests requests.post('https://textbelt.com/text', { 'phone': '+972546233257', 'message': "Hi Alon Najman,EVOK value: "+Price, 'key': 'secret', }) #write to file with open("flag.txt", "w") as text_file: text_file.write(format(time.strftime("%d/%m/%Y"))) #read from file f=open("flag.txt", "r") if f.mode == 'r': flag =f.read() # Create new threads thread1 = myThread(1, "Thread-1", 1) # Start new Threads def get_quote(str): url="https://api.iextrading.com/1.0/stock/"+str+"/price" resource = urllib.request.urlopen(url) content = resource.read().decode(resource.headers.get_content_charset()) print (content) content=float(content) return content class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(666, 571) self.radioButton = QtWidgets.QRadioButton(Dialog) self.radioButton.setGeometry(QtCore.QRect(80, 190, 191, 24)) font = QtGui.QFont() font.setPointSize(14) self.radioButton.setFont(font) self.radioButton.setObjectName("radioButton") self.buttonGroup_2 = QtWidgets.QButtonGroup(Dialog) self.buttonGroup_2.setObjectName("buttonGroup_2") self.buttonGroup_2.addButton(self.radioButton) self.checkBox = QtWidgets.QCheckBox(Dialog) self.checkBox.setGeometry(QtCore.QRect(290, 450, 131, 17)) font = QtGui.QFont() font.setPointSize(14) self.checkBox.setFont(font) self.checkBox.setObjectName("checkBox") self.checkBox_2 = QtWidgets.QCheckBox(Dialog) self.checkBox_2.setGeometry(QtCore.QRect(290, 480, 141, 17)) font = QtGui.QFont() font.setPointSize(14) self.checkBox_2.setFont(font) self.checkBox_2.setObjectName("checkBox_2") self.textEdit = QtWidgets.QTextEdit(Dialog) self.textEdit.setGeometry(QtCore.QRect(130, 20, 321, 41)) self.textEdit.setObjectName("textEdit") self.radioButton_2 = QtWidgets.QRadioButton(Dialog) self.radioButton_2.setGeometry(QtCore.QRect(300, 190, 186, 24)) font = QtGui.QFont() font.setPointSize(14) self.radioButton_2.setFont(font) self.radioButton_2.setObjectName("radioButton_2") self.buttonGroup_2.addButton(self.radioButton_2) self.pushButton = QtWidgets.QPushButton(Dialog) self.pushButton.setGeometry(QtCore.QRect(60, 460, 72, 31)) font = QtGui.QFont() font.setPointSize(14) self.pushButton.setFont(font) self.pushButton.setObjectName("pushButton") self.radioButton_3 = QtWidgets.QRadioButton(Dialog) self.radioButton_3.setGeometry(QtCore.QRect(80, 250, 191, 24)) font = QtGui.QFont() font.setPointSize(14) self.radioButton_3.setFont(font) self.radioButton_3.setObjectName("radioButton_3") self.buttonGroup = QtWidgets.QButtonGroup(Dialog) self.buttonGroup.setObjectName("buttonGroup") self.buttonGroup.addButton(self.radioButton_3) self.radioButton_4 = QtWidgets.QRadioButton(Dialog) self.radioButton_4.setGeometry(QtCore.QRect(300, 250, 186, 24)) font = QtGui.QFont() font.setPointSize(14) self.radioButton_4.setFont(font) self.radioButton_4.setObjectName("radioButton_4") self.buttonGroup.addButton(self.radioButton_4) self.pushButton_2 = QtWidgets.QPushButton(Dialog) self.pushButton_2.setGeometry(QtCore.QRect(30, 20, 72, 31)) font = QtGui.QFont() font.setPointSize(14) self.pushButton_2.setFont(font) self.pushButton_2.setObjectName("pushButton_2") self.textEdit_4 = QtWidgets.QTextEdit(Dialog) self.textEdit_4.setGeometry(QtCore.QRect(310, 383, 221, 38)) font = QtGui.QFont() font.setPointSize(16) self.textEdit_4.setFont(font) self.textEdit_4.setObjectName("textEdit_4") self.textEdit_5 = QtWidgets.QTextEdit(Dialog) self.textEdit_5.setGeometry(QtCore.QRect(310, 340, 221, 38)) font = QtGui.QFont() font.setPointSize(16) self.textEdit_5.setFont(font) self.textEdit_5.setObjectName("textEdit_5") self.label = QtWidgets.QLabel(Dialog) self.label.setGeometry(QtCore.QRect(150, 80, 111, 16)) font = QtGui.QFont() font.setPointSize(14) self.label.setFont(font) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(Dialog) self.label_2.setGeometry(QtCore.QRect(410, 80, 131, 16)) font = QtGui.QFont() font.setPointSize(14) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(Dialog) self.label_3.setGeometry(QtCore.QRect(160, 350, 121, 20)) font = QtGui.QFont() font.setPointSize(14) self.label_3.setFont(font) self.label_3.setObjectName("label_3") self.label_4 = QtWidgets.QLabel(Dialog) self.label_4.setGeometry(QtCore.QRect(140, 390, 171, 20)) font = QtGui.QFont() font.setPointSize(14) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.splitter = QtWidgets.QSplitter(Dialog) self.splitter.setGeometry(QtCore.QRect(80, 120, 512, 31)) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setObjectName("splitter") self.textEdit_2 = QtWidgets.QTextEdit(self.splitter) self.textEdit_2.setObjectName("textEdit_2") self.textEdit_3 = QtWidgets.QTextEdit(self.splitter) self.textEdit_3.setObjectName("textEdit_3") self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog) self.pushButton.clicked.connect(self.printMessage) self.pushButton_2.clicked.connect(self.printMessage2) def printMessage(self): print ("what a great day!") thread1.start() def printMessage2(self): thread1._Thread_stop() def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate Dialog.setWindowTitle(_translate("Dialog", "Dialog")) self.radioButton.setText(_translate("Dialog", "Above Price (x>)")) self.checkBox.setText(_translate("Dialog", "SMS ALERT")) self.checkBox_2.setText(_translate("Dialog", "GMAIL ALERT")) self.textEdit.setHtml(_translate("Dialog", "\n" "\n" "

Alon Stock Market (alerts)

")) self.radioButton_2.setText(_translate("Dialog", "Bellow Price (x<)")) self.pushButton.setText(_translate("Dialog", "START")) self.radioButton_3.setText(_translate("Dialog", "get alert once a day")) self.radioButton_4.setText(_translate("Dialog", "get alert every time")) self.pushButton_2.setText(_translate("Dialog", "EXIT")) self.textEdit_4.setHtml(_translate("Dialog", "\n" "\n" "

Password of Gmail

")) self.textEdit_5.setHtml(_translate("Dialog", "\n" "\n" "

User of Gmail

")) self.label.setText(_translate("Dialog", "SYMBOL")) self.label_2.setText(_translate("Dialog", "PRICE VALUE")) self.label_3.setText(_translate("Dialog", "User of Gmail:")) self.label_4.setText(_translate("Dialog", "Password of Gmail:")) self.textEdit_2.setHtml(_translate("Dialog", "\n" "\n" "

STOCK SYMBOL

")) self.textEdit_3.setHtml(_translate("Dialog", "\n" "\n" "

STOCK SYMBOL

")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Dialog = QtWidgets.QDialog() ui = Ui_Dialog() ui.setupUi(Dialog) Dialog.show() sys.exit(app.exec_()) From antoon.pardon at vub.be Fri Sep 14 03:25:46 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Fri, 14 Sep 2018 09:25:46 +0200 Subject: Trying to use threading.local() In-Reply-To: References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> Message-ID: <7adecf64-1b0f-ce11-5e61-eab38d3502ba@vub.be> On 13-09-18 14:29, Chris Angelico wrote: > "Preferred" doesn't exclude the possibility that alternatives are > needed, though. For example, good luck making decimal.Decimal contexts > work correctly without the help of thread-locals - there MIGHT be a > way to do it, but even if there is, it sure won't be pretty. Can you elaborate on that. Suppose I have two threads, one in which I need a precision of 3 and the other in which I need a precision of 7. In what circumstances is it needed to use threads-locals to accomplish this and how do I accomplish this? If I want my decimal code be usable with threads, how should I write it? -- Antoon Pardon From qsx at chaotikum.eu Fri Sep 14 04:01:01 2018 From: qsx at chaotikum.eu (Thomas Schneider) Date: Fri, 14 Sep 2018 10:01:01 +0200 Subject: Add header at top with email.message Message-ID: Hi, the EmailMessage class of email.message provides the methods add_header() and __setitem__() to add a header to a message. add_header() effectively calls __setitem__(), which does `self._headers.append(self.policy.header_store_parse(name, val))`. This inserts the header at the bottom. It is, however, sometimes desired to insert a new header at the top of an (existing) message. This API doesn?t directly allow this. In my opinion, add_header() should have a flag at_top=False or similar, so that one can get this behaviour (it?ll be a bit difficult with __setitem__). What do you think about this? Is there a feasible way to do this and change the library? Should I post it somewhere where the devs can hear it and suggest that? Thanks, --qsx From rosuav at gmail.com Fri Sep 14 04:29:57 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 14 Sep 2018 18:29:57 +1000 Subject: Trying to use threading.local() In-Reply-To: <7adecf64-1b0f-ce11-5e61-eab38d3502ba@vub.be> References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> <7adecf64-1b0f-ce11-5e61-eab38d3502ba@vub.be> Message-ID: On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon wrote: > On 13-09-18 14:29, Chris Angelico wrote: >> "Preferred" doesn't exclude the possibility that alternatives are >> needed, though. For example, good luck making decimal.Decimal contexts >> work correctly without the help of thread-locals - there MIGHT be a >> way to do it, but even if there is, it sure won't be pretty. > > Can you elaborate on that. Suppose I have two threads, one in which I need > a precision of 3 and the other in which I need a precision of 7. In what > circumstances is it needed to use threads-locals to accomplish this and > how do I accomplish this? > > If I want my decimal code be usable with threads, how should I write it? Let's say both of those threads call the same function, which does this: def f(x, y): return x * 3 + y / 4 You can't pass a context as a parameter, so you have to set the context externally. Which is done thus: https://docs.python.org/3/library/decimal.html#decimal.setcontext Note that this sets it *for the current thread*. ChrisA From tjol at tjol.eu Fri Sep 14 04:34:52 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 14 Sep 2018 10:34:52 +0200 Subject: Trying to use threading.local() In-Reply-To: References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> <7adecf64-1b0f-ce11-5e61-eab38d3502ba@vub.be> Message-ID: <1e6e4592-9272-0784-0354-d5bde7f86dd4@tjol.eu> On 14/09/18 10:29, Chris Angelico wrote: > On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon wrote: >> On 13-09-18 14:29, Chris Angelico wrote: >>> "Preferred" doesn't exclude the possibility that alternatives are >>> needed, though. For example, good luck making decimal.Decimal contexts >>> work correctly without the help of thread-locals - there MIGHT be a >>> way to do it, but even if there is, it sure won't be pretty. >> Can you elaborate on that. Suppose I have two threads, one in which I need >> a precision of 3 and the other in which I need a precision of 7. In what >> circumstances is it needed to use threads-locals to accomplish this and >> how do I accomplish this? >> >> If I want my decimal code be usable with threads, how should I write it? > Let's say both of those threads call the same function, which does this: > > def f(x, y): > return x * 3 + y / 4 > > You can't pass a context as a parameter, so you have to set the > context externally. Which is done thus: > > https://docs.python.org/3/library/decimal.html#decimal.setcontext > > Note that this sets it *for the current thread*. > > ChrisA Ideally use a context manager to manage your context: https://docs.python.org/3/library/decimal.html#decimal.localcontext -- Thomas From rosuav at gmail.com Fri Sep 14 04:43:55 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 14 Sep 2018 18:43:55 +1000 Subject: Trying to use threading.local() In-Reply-To: <1e6e4592-9272-0784-0354-d5bde7f86dd4@tjol.eu> References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> <7adecf64-1b0f-ce11-5e61-eab38d3502ba@vub.be> <1e6e4592-9272-0784-0354-d5bde7f86dd4@tjol.eu> Message-ID: On Fri, Sep 14, 2018 at 6:34 PM, Thomas Jollans wrote: > On 14/09/18 10:29, Chris Angelico wrote: >> >> On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon >> wrote: >>> >>> On 13-09-18 14:29, Chris Angelico wrote: >>>> >>>> "Preferred" doesn't exclude the possibility that alternatives are >>>> needed, though. For example, good luck making decimal.Decimal contexts >>>> work correctly without the help of thread-locals - there MIGHT be a >>>> way to do it, but even if there is, it sure won't be pretty. >>> >>> Can you elaborate on that. Suppose I have two threads, one in which I >>> need >>> a precision of 3 and the other in which I need a precision of 7. In what >>> circumstances is it needed to use threads-locals to accomplish this and >>> how do I accomplish this? >>> >>> If I want my decimal code be usable with threads, how should I write it? >> >> Let's say both of those threads call the same function, which does this: >> >> def f(x, y): >> return x * 3 + y / 4 >> >> You can't pass a context as a parameter, so you have to set the >> context externally. Which is done thus: >> >> https://docs.python.org/3/library/decimal.html#decimal.setcontext >> >> Note that this sets it *for the current thread*. >> >> ChrisA > > > Ideally use a context manager to manage your context: > https://docs.python.org/3/library/decimal.html#decimal.localcontext Which is ALSO setting it "for the active thread", and (at least in the pure-Python implementation of the decimal module) is implemented on top of setcontext anyway. Actually, the context manager version highlights the need for thread-locality even more; you expect atomicity from it, and you'd be MAJORLY messed up if another thread broke that. BTW, to more specifically answer this question: On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon wrote: > If I want my decimal code be usable with threads, how should I write it? Just write it in the most simple and obvious way. Don't even think about contexts unless you need to, and if you do, don't concern yourself with threads and contexts unless you are yourself creating both of them. Even then, I believe decimal will DTRT by default in most cases. Thread locals are the magic that makes this happen, but you don't have to think about that magic usually. ChrisA From antoon.pardon at vub.be Fri Sep 14 05:18:42 2018 From: antoon.pardon at vub.be (Antoon Pardon) Date: Fri, 14 Sep 2018 11:18:42 +0200 Subject: Trying to use threading.local() In-Reply-To: References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> <7adecf64-1b0f-ce11-5e61-eab38d3502ba@vub.be> Message-ID: <26c10b5d-c631-a1fd-6b78-a022eb1dea88@vub.be> On 14-09-18 10:29, Chris Angelico wrote: > On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon wrote: >> >> ... Suppose I have two threads, one in which I need >> a precision of 3 and the other in which I need a precision of 7. In what >> circumstances is it needed to use threads-locals to accomplish this and >> how do I accomplish this? >> >> If I want my decimal code be usable with threads, how should I write it? > Let's say both of those threads call the same function, which does this: > > def f(x, y): > return x * 3 + y / 4 > > You can't pass a context as a parameter, so you have to set the > context externally. Which is done thus: > > https://docs.python.org/3/library/decimal.html#decimal.setcontext > > Note that this sets it *for the current thread*. So, if I understand correctly, the threads-local information in this case is part of the decimal implementation, so that the right context/precision is used for the right thread. -- Antoon Pardon. From toni.sissala at gmail.com Fri Sep 14 05:19:44 2018 From: toni.sissala at gmail.com (Toni Sissala) Date: Fri, 14 Sep 2018 12:19:44 +0300 Subject: Fumbling with emacs + elpy + flake8 In-Reply-To: References: Message-ID: I'm on Ubuntu 16.04. I found out that flake8 did not play well with emacs if installed with --user option, nor when installed in a virtual environment. Didn't research any further, since I got it working with plain pip3 install flake8 Do you see any error messages? Toni On 13.9.2018 21:59, Martin Sch??n wrote: > I am trying to set up emacs for Python coding on my secondary computer. > I follow these instructions but fail to make flake8 play with elpy: > > https://realpython.com/emacs-the-best-python-editor/#elpy-python-development > > I have done this some time in the past on my main computer and there it > works just fine. I have compared the set-up of this on the two computers > and fail to figure out why it works on one and not the other. > > There are a couple of things that are not the same on the computers: > > 1) The secondary computer has a later version of emacs installed. > > 2) I used pip3 install --user flake8 on the secondary computer but on > the primary computer I think I left out the --user flag (not knowing > about it at the time) but I have added the path to .local/bin and > M-x elpy-config finds flake8 on both computers. Yet it does not > work on my secondary computer... > > Any leads are greatly appreciated. > > /Martin > > PS Debian on both computers. From rosuav at gmail.com Fri Sep 14 05:28:38 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 14 Sep 2018 19:28:38 +1000 Subject: Trying to use threading.local() In-Reply-To: <26c10b5d-c631-a1fd-6b78-a022eb1dea88@vub.be> References: <6250cabf-780d-4aa4-e5c5-a57b50172d52@vub.be> <7adecf64-1b0f-ce11-5e61-eab38d3502ba@vub.be> <26c10b5d-c631-a1fd-6b78-a022eb1dea88@vub.be> Message-ID: On Fri, Sep 14, 2018 at 7:18 PM, Antoon Pardon wrote: > On 14-09-18 10:29, Chris Angelico wrote: >> On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon wrote: >>> >>> ... Suppose I have two threads, one in which I need >>> a precision of 3 and the other in which I need a precision of 7. In what >>> circumstances is it needed to use threads-locals to accomplish this and >>> how do I accomplish this? >>> >>> If I want my decimal code be usable with threads, how should I write it? >> Let's say both of those threads call the same function, which does this: >> >> def f(x, y): >> return x * 3 + y / 4 >> >> You can't pass a context as a parameter, so you have to set the >> context externally. Which is done thus: >> >> https://docs.python.org/3/library/decimal.html#decimal.setcontext >> >> Note that this sets it *for the current thread*. > > So, if I understand correctly, the threads-local information in this case is > part of the decimal implementation, so that the right context/precision is > used for the right thread. > Correct, though it's an exposed part of the API too, so it's not "implementation detail" in the sense that it could be changed easily. ChrisA From npcua at donbosco.edu.ph Fri Sep 14 08:37:38 2018 From: npcua at donbosco.edu.ph (Noel P. CUA) Date: Fri, 14 Sep 2018 05:37:38 -0700 (PDT) Subject: how to convert this psuedo code to python Message-ID: compose your own octave script to calculate the machine epsilon. Analyze the code. epsilon = 1 DO IF (epsilon+1<=1) EXIT epsilon = epsilon/2 END DO epsilon = 2 x epsilon -- *This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager . This message contains confidential information and is intended only for the individual named. *If you are not the named addressee you should not disseminate, distribute or copy this e-mail*. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.* From jf_byrnes at comcast.net Fri Sep 14 09:15:05 2018 From: jf_byrnes at comcast.net (Jim) Date: Fri, 14 Sep 2018 08:15:05 -0500 Subject: Looking for a Scrapy cheatsheet In-Reply-To: References: Message-ID: On 09/14/2018 01:27 AM, Danyelle Davis wrote: > The one that sans provides seems pretty decent. Did you not like it? What is sans? Do you have a url. Thanks, Jim > On Thu, Sep 13, 2018 at 4:05 PM Jim wrote: > >> I'm in the process of learning Scrapy. I've read through the docs and a >> couple of tutorials, but I am getting bogged down because I can't find a >> page/table/chart that gives a nice concise overview of the available >> commands and methods. >> >> Googling hasn't found anything usable. So does anyone know of a >> cheatsheet I can download. >> >> Thanks, Jim >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> From jqian at tibco.com Fri Sep 14 09:16:46 2018 From: jqian at tibco.com (Jason Qian) Date: Fri, 14 Sep 2018 09:16:46 -0400 Subject: Help on PyList 3.7.0 In-Reply-To: References: Message-ID: Thanks a lot. On Thu, Sep 13, 2018 at 5:24 PM, MRAB wrote: > On 2018-09-13 21:50, Jason Qian via Python-list wrote: > >> Hey, >> >> Need some help on PyList. >> >> >> #get path >> PyObject *path = PyObject_GetAttrString(sys, "path"); >> >> #new user path >> PyObject* newPath = PyUnicode_DecodeUTF8(userPath, strlen( userPath ), >> errors); >> >> #append newPath to path >> PyList_Append(path, newPath); >> >> How to check if the newPath is already in the path ? >> >> So, If the path contains the newPath, I will not append the newpath. >> >> >> Thanks for help >> >> A list is a sequence. Use PySequence_Contains. > -- > https://mail.python.org/mailman/listinfo/python-list > From max at zettlmeissl.de Fri Sep 14 09:17:23 2018 From: max at zettlmeissl.de (=?UTF-8?Q?Max_Zettlmei=C3=9Fl?=) Date: Fri, 14 Sep 2018 15:17:23 +0200 Subject: how to convert this psuedo code to python In-Reply-To: References: Message-ID: On Fri, Sep 14, 2018 at 2:37 PM, Noel P. CUA wrote: > compose your own octave script to calculate the machine > epsilon. Analyze the code. > > epsilon = 1 > DO > IF (epsilon+1<=1) EXIT > epsilon = epsilon/2 > END DO > epsilon = 2 x epsilon > epsilon = 1 while epsilon + 1 > 1: epsilon = epsilon / 2.0 epsilon = 2 * epsilon This will not work in Octave. But maybe it will help you in improving your understanding of the solution. From jf_byrnes at comcast.net Fri Sep 14 09:26:51 2018 From: jf_byrnes at comcast.net (Jim) Date: Fri, 14 Sep 2018 08:26:51 -0500 Subject: Looking for a Scrapy cheatsheet In-Reply-To: References: Message-ID: On 09/14/2018 08:15 AM, Jim wrote: > On 09/14/2018 01:27 AM, Danyelle Davis wrote: >> The one that sans provides seems pretty decent. Did you not like it? > > What is sans? Do you have a url. > > Thanks,? Jim Nevermind. I googled scrapy sans and I think we are talking about two different programs with the same name. I was inquiring about the web scraping program Scrapy. The one at SANS seems to be about penetration testing. Regards, Jim >> On Thu, Sep 13, 2018 at 4:05 PM Jim wrote: >> >>> I'm in the process of learning Scrapy. I've read through the docs and a >>> couple of tutorials, but I am getting bogged down because I can't find a >>> page/table/chart that gives a nice concise overview of the available >>> commands and methods. >>> >>> Googling hasn't found anything usable. So does anyone know of a >>> cheatsheet I can download. >>> >>> Thanks,? Jim >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >>> > > From jrgulizia at scola.org Fri Sep 14 09:28:59 2018 From: jrgulizia at scola.org (Joe Gulizia) Date: Fri, 14 Sep 2018 13:28:59 +0000 Subject: Looking for a Scrapy cheatsheet In-Reply-To: References: , Message-ID: I just goolged for SANS Scrapy Cheatsheet....they have several SANS.org ________________________________ From: Python-list on behalf of Jim Sent: Friday, September 14, 2018 8:15:05 AM To: python-list at python.org Subject: Re: Looking for a Scrapy cheatsheet On 09/14/2018 01:27 AM, Danyelle Davis wrote: > The one that sans provides seems pretty decent. Did you not like it? What is sans? Do you have a url. Thanks, Jim > On Thu, Sep 13, 2018 at 4:05 PM Jim wrote: > >> I'm in the process of learning Scrapy. I've read through the docs and a >> couple of tutorials, but I am getting bogged down because I can't find a >> page/table/chart that gives a nice concise overview of the available >> commands and methods. >> >> Googling hasn't found anything usable. So does anyone know of a >> cheatsheet I can download. >> >> Thanks, Jim >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> -- https://mail.python.org/mailman/listinfo/python-list From npcua at donbosco.edu.ph Fri Sep 14 10:33:59 2018 From: npcua at donbosco.edu.ph (Noel P. CUA) Date: Fri, 14 Sep 2018 07:33:59 -0700 (PDT) Subject: help me in python plssss!!!! Message-ID: <534d9777-a8cd-4aad-9a2a-389ad8f76df9@googlegroups.com> Calculate the true, relative and approximate errors, and Relate the absolute relative approximate error to the number of significant digits. epsilon = 1 while epsilon + 1 > 1: epsilon = epsilon / 2.0 epsilon = 2 * epsilon help me! -- *This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager . This message contains confidential information and is intended only for the individual named. *If you are not the named addressee you should not disseminate, distribute or copy this e-mail*. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.* From max at zettlmeissl.de Fri Sep 14 10:51:56 2018 From: max at zettlmeissl.de (=?UTF-8?Q?Max_Zettlmei=C3=9Fl?=) Date: Fri, 14 Sep 2018 16:51:56 +0200 Subject: help me in python plssss!!!! In-Reply-To: <534d9777-a8cd-4aad-9a2a-389ad8f76df9@googlegroups.com> References: <534d9777-a8cd-4aad-9a2a-389ad8f76df9@googlegroups.com> Message-ID: On Fri, Sep 14, 2018 at 4:33 PM, Noel P. CUA wrote: > Calculate the true, relative and approximate errors, and Relate the absolute relative approximate error to the number of significant digits. > > epsilon = 1 > > while epsilon + 1 > 1: > epsilon = epsilon / 2.0 > > epsilon = 2 * epsilon > > help me! > This list is not here to solve every single step of what is (presumably) your homework for you. Everything you present right here is what I helped you with in "how to convert this psuedo code to python". You will have to at least try it yourself and to present your approaches or at least ideas. Additionally, tutor at python.org seems to be more fitting for the rather basic level of the problems which you present. From tejaswidprakash at gmail.com Fri Sep 14 13:04:38 2018 From: tejaswidprakash at gmail.com (tejaswi) Date: Fri, 14 Sep 2018 22:34:38 +0530 Subject: Image processing libraries in python Message-ID: <20180914170438.r7lptuebri4rx5ts@tejaswis-laptop> Hello everyone, I was looking to work with images in python. I saw two packages related to this, Pillow and scipy.ndimage. I was wondering what purposes each of these serve. I've previously used matlab/octave's image processing facilities and found them quite easy to work with, so is scipy the way to go in that case. Thank you, Tejaswi D Prakash From python at mrabarnett.plus.com Fri Sep 14 13:35:03 2018 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 14 Sep 2018 18:35:03 +0100 Subject: Image processing libraries in python In-Reply-To: <20180914170438.r7lptuebri4rx5ts@tejaswis-laptop> References: <20180914170438.r7lptuebri4rx5ts@tejaswis-laptop> Message-ID: <01a81c31-4fbc-2379-aa3e-79c5cda58d18@mrabarnett.plus.com> On 2018-09-14 18:04, tejaswi wrote: > Hello everyone, > I was looking to work with images in python. I saw two packages > related to this, Pillow and scipy.ndimage. I was wondering what > purposes each of these serve. > I've previously used matlab/octave's image processing facilities and > found them quite easy to work with, so is scipy the way to go in that > case. > Depending on that you want to do, there's also OpenCV. From tjol at tjol.eu Fri Sep 14 13:57:03 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 14 Sep 2018 19:57:03 +0200 Subject: Image processing libraries in python In-Reply-To: <20180914170438.r7lptuebri4rx5ts@tejaswis-laptop> References: <20180914170438.r7lptuebri4rx5ts@tejaswis-laptop> Message-ID: <597493dc-32b0-4300-36de-02eab31fac1a@tjol.eu> On 14/09/18 19:04, tejaswi wrote: > Hello everyone, > I was looking to work with images in python. I saw two packages > related to this, Pillow and scipy.ndimage. I was wondering what > purposes each of these serve. > I've previously used matlab/octave's image processing facilities and > found them quite easy to work with, so is scipy the way to go in that > case. > Thank you, > Tejaswi D Prakash Pillow is great for simple image processing. Converting between formats, resizing, cropping, rotating. simple filters - that kind of thing. The kind of thing you might otherwise do with GIMP, you might say. For more in-depth image analysis, scipy.ndimage and scikit-image are your friends. Obviously they work better with the numpy/scipy ecosystem. And, as MRAB points out, there's also OpenCV, which is fantastic for certain types of problems (have a look at the docs). For some fields (e.g. astronomy) there are also more specialized packages that may help. In short, if you images are pictures, have a look at Pillow. If your images are data, have a look at scikit-image, scipy.ndimage, and maybe more specialized packages like OpenCV or astropy. -- Thomas From italienisch1987 at gmail.com Fri Sep 14 14:41:56 2018 From: italienisch1987 at gmail.com (Bobby) Date: Fri, 14 Sep 2018 20:41:56 +0200 Subject: Python for System Verilog testbench In-Reply-To: References: Message-ID: Hi George WOW! thanks for the reply and specially thanks for using the word 'BDD'. I read the articles regarding BDD the whole day and understood the concepts. Now will get this Pytest test framework with pytest bdd plugin. I found out it follows this Gherkin syntax. Then I read about this Gherkin synatx. It also looks good specially for Verilog. Maybe the syntax I was following earlier is too complicated. Some more questions regarding this: - I read that there are other Python framweorks also for BDD like 'behave'. What do you suggest as a beginner is Pytest-bdd is easier or 'behave' ? - If I am able to successfully map the requirements in pytest-bdd following this Gherkins syntax, in the end what we get is Python code. To proceed further, will I have to use Python to Verilog parser for the final Verilog kind of structure? On Friday, September 14, 2018, George Fischhof wrote: > > > Bobby ezt ?rta (id?pont: 2018. szept. 14., P 0:16): >> >> I have a very simple System Verilog (SV) adder as my DUT (device under test). I would like to generate a test bench for this DUT based on the 'requirements'. I wrote its (DUT) functions in simple text as 'requirements' while following a particular syntax. Now through the help of grammar, I would like to give the requirement input to the grammar. >> >> Questions: >> >> (1) Considering my end goal, i.e. to generate some particular parts of >> SV testbench from requirements, any good python parser available ? >> >> (2) If I use python parser, will any kind of python scripting will help me to generate the testbench in SV for my DUT ? My confusion at this point is that most of all the literature I am reading suggests linguistic techniques. Any non-linguistic technique ? >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list > > Hi, > Perhaps you should check articles about BDD, and you can use PyTest test framework with pytest-bdd plugin > __george__ > From dmarv at dop.com Fri Sep 14 20:39:30 2018 From: dmarv at dop.com (Dale Marvin) Date: Fri, 14 Sep 2018 17:39:30 -0700 Subject: Python for System Verilog testbench In-Reply-To: References: Message-ID: On 9/14/18 11:41 AM, Bobby wrote: > Hi George > > WOW! thanks for the reply and specially thanks for using the word 'BDD'. I > read the articles regarding BDD the whole day and understood the concepts. > Now will get this Pytest test framework with pytest bdd plugin. I found out > it follows this Gherkin syntax. Then I read about this Gherkin synatx. It > also looks good specially for Verilog. Maybe the syntax I was following > earlier is too complicated. > > Some more questions regarding this: > > - I read that there are other Python framweorks also > for BDD like 'behave'. What do you suggest as a beginner is Pytest-bdd is > easier or 'behave' ? > > - If I am able to successfully map the requirements in pytest-bdd following > this Gherkins syntax, in the end what we get is Python code. To proceed > further, will I have to use Python to Verilog parser for the final Verilog > kind of structure? > Hi Bobby, It's better to either bottom post, or inline your comments as the thread gets mangled in the archives. There is MyHDL that may be of some use: "MyHDL turns Python into a hardware description and verification language, providing hardware engineers with the power of the Python ecosystem." It supports synthesis from the Python RTL Models: - Dale > On Friday, September 14, 2018, George Fischhof wrote: >> >> >> Bobby ezt ?rta (id?pont: 2018. szept. 14., P > 0:16): >>> >>> I have a very simple System Verilog (SV) adder as my DUT (device under > test). I would like to generate a test bench for this DUT based on the > 'requirements'. I wrote its (DUT) functions in simple text as > 'requirements' while following a particular syntax. Now through the help > of grammar, I would like to give the requirement input to the grammar. >>> >>> Questions: >>> >>> (1) Considering my end goal, i.e. to generate some particular parts > of >>> SV testbench from requirements, any good python parser > available ? >>> >>> (2) If I use python parser, will any kind of python scripting will > help me to generate the testbench in SV for my DUT ? My confusion at this > point is that most of all the literature I am reading suggests linguistic > techniques. Any non-linguistic technique ? >>> >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >> >> Hi, >> Perhaps you should check articles about BDD, and you can use PyTest test > framework with pytest-bdd plugin >> __george__ >> From dieter at handshake.de Sat Sep 15 01:02:09 2018 From: dieter at handshake.de (dieter) Date: Sat, 15 Sep 2018 07:02:09 +0200 Subject: python 3.7 - I try to close the thread without closing the GUI is it possible? References: <8f9e292e-39fc-41c0-9187-c36f1252beb1@googlegroups.com> Message-ID: <87va77uze6.fsf@handshake.de> alon.najman at gmail.com writes: > python 3.7 - I try to close the thread without closing the GUI is it possible? I assume that with "close a thread" you mean "terminate a thread". It is difficult to terminate a thread from the outside, because on many platforms, there is no reliable way to terminate an (operating system level) thread in a safe way. The easiest thing would be that you prepare your thread to terminate (on its own) when the outside world sets a flag that it should terminate. In Python 2, there has been a C level Python function which allows to indicate to a thread that it should terminate. It implements the approach from the previous paragraph but at the Python interpreter level. It cannot stop a thread if it is not executing Python code (but somewhere in a "C" extension). Not sure, whether this function is available in Python 3. It might be possible that you move the activity now done in a thread into a process. Terminating a process is far easier than terminating a thread. From sjeik_appie at hotmail.com Sat Sep 15 03:23:50 2018 From: sjeik_appie at hotmail.com (Albert-Jan Roskam) Date: Sat, 15 Sep 2018 07:23:50 +0000 Subject: python 3.7 - I try to close the thread without closing the GUI is it possible? In-Reply-To: <8f9e292e-39fc-41c0-9187-c36f1252beb1@googlegroups.com> Message-ID: > I try to close the thread without closing the GUI is it possible? Qthread seems to be worth investigating: https://medium.com/@webmamoffice/getting-started-gui-s-with-python-pyqt-qthread-class-1b796203c18c From torriem at gmail.com Sat Sep 15 10:33:13 2018 From: torriem at gmail.com (Michael Torrie) Date: Sat, 15 Sep 2018 08:33:13 -0600 Subject: python 3.7 - I try to close the thread without closing the GUI is it possible? In-Reply-To: References: Message-ID: On 09/15/2018 01:23 AM, Albert-Jan Roskam wrote: > > I try to close the thread without closing the GUI is it possible? > > > Qthread seems to be worth investigating: > https://medium.com/@webmamoffice/getting-started-gui-s-with-python-pyqt-qthread-class-1b796203c18c Or better yet, investigate Qt's built-in, asynchronous http request calls. I believe the class is QNetworkRequest (and probably other related classes). This keeps the HTTP request all within the Qt event loop and eliminates the need for threads. Additionally it handles all the problems that might come up, such as connection problems, http errors, etc. It looks complicated, but it's simpler than using a thread. From torriem at gmail.com Sat Sep 15 10:35:36 2018 From: torriem at gmail.com (Michael Torrie) Date: Sat, 15 Sep 2018 08:35:36 -0600 Subject: python 3.7 - I try to close the thread without closing the GUI is it possible? In-Reply-To: References: Message-ID: <17423cfc-ee93-be2b-5539-3533967c1065@gmail.com> Here's a small PyQt example of using Qt's asynchronous facilities: http://zetcode.com/pyqt/qnetworkaccessmanager/ That should get the original poster started. From martin.schoon at gmail.com Sat Sep 15 12:01:06 2018 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 15 Sep 2018 16:01:06 GMT Subject: Fumbling with emacs + elpy + flake8 References: <1536867856.1672.3.camel@gmail.com> Message-ID: Den 2018-09-13 skrev Brian Oney : > Hi Martin, > > I have messed around alot with the myriad emacs configurations out > there. I found spacemacs and threw out my crappy but beloved .emacs > config. I have looked back, but will stay put. http://spacemacs.org/ > Thanks Brian but not the answer I was looking for this time. I will investigate though. /Martin From martin.schoon at gmail.com Sat Sep 15 12:06:38 2018 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 15 Sep 2018 16:06:38 GMT Subject: Fumbling with emacs + elpy + flake8 References: Message-ID: Den 2018-09-14 skrev Toni Sissala : > I'm on Ubuntu 16.04. I found out that flake8 did not play well with > emacs if installed with --user option, nor when installed in a virtual > environment. Didn't research any further, since I got it working with > plain pip3 install flake8 > Toni, your advice did not work out-of-the-box but it put me on the right track. When I revert to installing flake8 from Debian's repo it works. Strange as I have not done it like that on my primary computer. Both Debian installations but a generation apart. Case closed, I think. /Martin From alon.najman at gmail.com Sat Sep 15 12:54:11 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Sat, 15 Sep 2018 09:54:11 -0700 (PDT) Subject: python3.7 - how to open a new thread and close the old each click on a button? Message-ID: hii all, python3.7 - how to open a new thread and close the old each click on a button? here is my code: # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'AlonStockMarket.ui' # # Created by: PyQt5 UI code generator 5.11.2 # # WARNING! All changes made in this file will be lost! import time import sys import requests from lxml import html import requests import urllib.request, urllib.error, urllib.parse import _thread from PyQt5 import QtCore, QtGui, QtWidgets import threading global flag global loopexit flag=0 loopexit=0 def get_quote(str): url="https://api.iextrading.com/1.0/stock/"+str+"/price" resource = urllib.request.urlopen(url) content = resource.read().decode(resource.headers.get_content_charset()) print (content) content=float(content) return content def myfunction(): global flag global loopexit print ("Executing myfunction in thread: ") print("hello, world") while loopexit!=1: if (loopexit==1): break time.sleep(15) f=open("flag.txt", "r") if f.mode == 'r': flag =f.read() timeHour = int(time.strftime('%H')) print("keep alive") print (time.strftime('%H:%M:%S')) while ((timeHour>16) and (timeHour<23) and loopexit!=1): if (loopexit==1): break print(time.strftime('%H:%M:%S')) price=get_quote(UserSymbol) time.sleep(5) if flag!=time.strftime("%d/%m/%Y") and price>UserStockPrice and (RadioButtonAbove==True): print ("send SMS") import requests requests.post('https://textbelt.com/text', { 'phone': '+972541234567', 'message': "Hi Alon Najman,EVOK value: "+price, 'key': 'secret', }) #write to file with open("flag.txt", "w") as text_file: text_file.write(format(time.strftime("%d/%m/%Y"))) #read from file f=open("flag.txt", "r") if f.mode == 'r': flag =f.read() if flag!=time.strftime("%d/%m/%Y") and price)")) self.checkBox.setText(_translate("Dialog", "SMS ALERT")) self.checkBox_2.setText(_translate("Dialog", "GMAIL ALERT")) self.radioButton_2.setText(_translate("Dialog", "Bellow Price (x<)")) self.pushButton.setText(_translate("Dialog", "START")) self.radioButton_3.setText(_translate("Dialog", "get alert once a day")) self.radioButton_4.setText(_translate("Dialog", "get alert every time")) self.pushButton_2.setText(_translate("Dialog", "EXIT")) self.textEdit_4.setHtml(_translate("Dialog", "\n" "\n" "


")) self.textEdit_5.setHtml(_translate("Dialog", "\n" "\n" "


")) self.label.setText(_translate("Dialog", "SYMBOL:")) self.label_2.setText(_translate("Dialog", "PRICE :")) self.label_3.setText(_translate("Dialog", "User of Gmail:")) self.label_4.setText(_translate("Dialog", "Password of Gmail:")) self.textEdit_2.setHtml(_translate("Dialog", "\n" "\n" "


")) self.textEdit_3.setHtml(_translate("Dialog", "\n" "\n" "


")) self.label_5.setText(_translate("Dialog", "ALON STOCK MARKET APP")) self.pushButton_3.setText(_translate("Dialog", "STOP")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Dialog = QtWidgets.QDialog() ui = Ui_Dialog() ui.setupUi(Dialog) Dialog.show() sys.exit(app.exec_()) From alister.ware at ntlworld.com Sat Sep 15 13:49:31 2018 From: alister.ware at ntlworld.com (Alister) Date: Sat, 15 Sep 2018 17:49:31 GMT Subject: Experiences with a programming exercise References: Message-ID: On Sat, 15 Sep 2018 17:08:57 +0000, Stefan Ram wrote: > I gave two different functions: > > def triangle(): > for i in range( 3 ): > forward( 99 ); left( 360/3 ) > > def rectangle() > for i in range( 4 ): > forward( 99 ); left( 360/4 ) > > , and the exercise was to write a single definition for a function > ?angle( n )? that can be called with ?3? to paint a triangle and with > ?4? to paint a rectangle. Nearly all participants wrote something like > this: > > def angle( n ): > if n == 3: > for i in range( 3 ): > forward( 99 ); left( 360/3 ) > if n == 4: > for i in range( 4 ): > forward( 99 ); left( 360/4 ) > > Now I have added the requirement that the solution should be as short > as possible! seems a good exercise & you are breaking the students in step by stem which is also good get something that works, then make it better i would suggest instead of the new requirement to be make it a short as possible make it work with ANY number of sides. -- Max told his friend that he'd just as soon not go hiking in the hills. Said he, "I'm an anti-climb Max." [So is that punchline.] From ajay.patel305 at gmail.com Sat Sep 15 14:47:32 2018 From: ajay.patel305 at gmail.com (Ajay Patel) Date: Sat, 15 Sep 2018 11:47:32 -0700 (PDT) Subject: Copy constructor and assignment operator Message-ID: <442c9e7a-75cd-4c9d-add6-24d6e310ed62@googlegroups.com> I have created below code and i want to restrict an object copy. What are the methods called for copy constructor and assignment operator? Basically i don't want to allow below operation. p = Point(1,3) p2 = Point(6,7) => How to disallow below operations? p(p2) p = p2 Please point out a documentation for the same if available. class Point: def _init_(self, x = 0, y = 0): self.x = x self.y = y def _str_(self): return "({0},{1})".format(self.x,self.y) def _repr_(self): return "({0},{1})".format(self.x,self.y) def _call_(self,other): print("_call_") self.x = other.x self.y = other.y def _setattr_(self, name, value): print("_setattr_",name,value) From jsf80238 at gmail.com Sat Sep 15 14:52:48 2018 From: jsf80238 at gmail.com (Jason Friedman) Date: Sat, 15 Sep 2018 12:52:48 -0600 Subject: Add header at top with email.message In-Reply-To: References: Message-ID: > > the EmailMessage class of email.message provides the methods > add_header() and __setitem__() to add a header to a message. > add_header() effectively calls __setitem__(), which does > `self._headers.append(self.policy.header_store_parse(name, val))`. This > inserts the header at the bottom. > > It is, however, sometimes desired to insert a new header at the top of > an (existing) message. This API doesn?t directly allow this. In my > opinion, add_header() should have a flag at_top=False or similar, so > that one can get this behaviour (it?ll be a bit difficult with > __setitem__). What do you think about this? Is there a feasible way to > do this and change the library? Should I post it somewhere where the > devs can hear it and suggest that?\ > I see this in the docs at https://docs.python.org/3/library/email.message.html#email.message.EmailMessage.get_unixfrom : The following methods implement the mapping-like interface for accessing the message?s headers. Note that there are some semantic differences between these methods and a normal mapping (i.e. dictionary) interface. For example, in a dictionary there are no duplicate keys, but here there may be duplicate message headers. Also, in dictionaries there is no guaranteed order to the keys returned by keys(), but in an EmailMessage object, headers are always returned in the order they appeared in the original message, or in which they were added to the message later. Any header deleted and then re-added is always appended to the end of the header list. I suppose you already figured out that you can call __delitem__() to clear the headers and add them back in whatever order you like. I'm interested in learning more about your use case. Do you have a third party with fixed logic that requires the headers in a particular order? From ajay.patel305 at gmail.com Sat Sep 15 15:13:10 2018 From: ajay.patel305 at gmail.com (Ajay Patel) Date: Sun, 16 Sep 2018 00:43:10 +0530 Subject: No subject Message-ID: From python at mrabarnett.plus.com Sat Sep 15 15:39:19 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 15 Sep 2018 20:39:19 +0100 Subject: Copy constructor and assignment operator In-Reply-To: <442c9e7a-75cd-4c9d-add6-24d6e310ed62@googlegroups.com> References: <442c9e7a-75cd-4c9d-add6-24d6e310ed62@googlegroups.com> Message-ID: On 2018-09-15 19:47, Ajay Patel wrote: > > I have created below code and i want to restrict an object copy. > What are the methods called for copy constructor and assignment operator? Basically i don't want to allow below operation. > > p = Point(1,3) > p2 = Point(6,7) > > => How to disallow below operations? > p(p2) > p = p2 > > Please point out a documentation for the same if available. > > > class Point: > > def _init_(self, x = 0, y = 0): > self.x = x > self.y = y > > def _str_(self): > return "({0},{1})".format(self.x,self.y) > > def _repr_(self): > return "({0},{1})".format(self.x,self.y) > > def _call_(self,other): > print("_call_") > self.x = other.x > self.y = other.y > > def _setattr_(self, name, value): > print("_setattr_",name,value) > "__init__", etc, are referred to as "dunder" methods because they have double leading and trailing underscores. Those that you wrote have only single leading and trailing underscores. The term "copy constructor" is something from C++. It doesn't exist in Python. Assignment statements _never_ copy an object. If you want a copy of an object, you have to be explicit. Writing: p = p2 will merely make 'p' refer to the same object that 'p2' currently refers to. For making a copy of an object, have a look at the "copy" module. From benjaminbulley at gmail.com Sat Sep 15 17:22:01 2018 From: benjaminbulley at gmail.com (benjamin bulley) Date: Sat, 15 Sep 2018 22:22:01 +0100 Subject: dll file missing error Message-ID: I encounter a dll error message while trying to run python. I uninstalled the program just to reinstall to find the same problem. Please help as I am quite new to this. From python at mrabarnett.plus.com Sun Sep 16 11:58:22 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 16 Sep 2018 16:58:22 +0100 Subject: Copy constructor and assignment operator In-Reply-To: References: <442c9e7a-75cd-4c9d-add6-24d6e310ed62@googlegroups.com> Message-ID: <845538b8-6444-52c4-a882-a437e14f71ca@mrabarnett.plus.com> On 2018-09-16 08:48, Ajay Patel wrote: > Hello, > > Thanks for your reply. > > What happen if do copy using copy module? i can see address are > different when using copy module. > Which magic method will call when i an doing deepcopy? > Snippet>>>>>> > > >>> p =Point(4,5) > __setattr__ > __setattr__ > __setattr__ > >>> p > (4,5) > >>> id(p) > 3072575564 > >>> import copy > >>> p2 = copy.deepcopy(p) > >>> p > (4,5) > >>> id(p2) > 3072522924 > >>> > You don't necessarily have to do anything else; the copy/deepcopy operation will create a new instance and copy/deepcopy the appropriate attributes for you. However, if you want more control, you can define a couple of dunder methods to do it your own way. I'll quote from the documentation page on the 'copy' module: |"""|In order for a class to define its own copy implementation, it can define special methods |__copy__()| and |__deepcopy__()|. The former is called to implement the shallow copy operation; no additional arguments are passed. The latter is called to implement the deep copy operation; it is passed one argument, the memo dictionary. If the |__deepcopy__()| implementation needs to make a deep copy of a component, it should call the |deepcopy()| <#copy.deepcopy> function with the component as first argument and the memo dictionary as second argument.""" > > > On Sun, Sep 16, 2018 at 1:12 AM MRAB > wrote: > > On 2018-09-15 19:47, Ajay Patel wrote: > > > > I have created below code and i want to restrict an object copy. > > What are the methods called for copy constructor and assignment > operator? Basically i don't want to allow below operation. > > > > p = Point(1,3) > > p2 = Point(6,7) > > > > => How to disallow below operations? > > p(p2) > > p = p2 > > > > Please point out a documentation for the same if available. > > > > > > class Point: > > > >? ? ? ? ? def _init_(self, x = 0, y = 0): > >? ? ? ? ? ? ? ? ? self.x = x > >? ? ? ? ? ? ? ? ? self.y = y > > > >? ? ? ? ? def _str_(self): > >? ? ? ? ? ? ? ? ? return "({0},{1})".format(self.x,self.y) > > > >? ? ? ? ? def _repr_(self): > >? ? ? ? ? ? ? ? ? return "({0},{1})".format(self.x,self.y) > > > >? ? ? ? ? def _call_(self,other): > >? ? ? ? ? ? ? ? ? print("_call_") > >? ? ? ? ? ? ? ? ? self.x = other.x > >? ? ? ? ? ? ? ? ? self.y = other.y > > > >? ? ? ? ? def _setattr_(self, name, value): > >? ? ? ? ? ? ? ? ? print("_setattr_",name,value) > > > > "__init__", etc, are referred to as "dunder" methods because they > have > double leading and trailing underscores. Those that you wrote have > only > single leading and trailing underscores. > > The term "copy constructor" is something from C++. It doesn't > exist in > Python. > > Assignment statements _never_ copy an object. If you want a copy > of an > object, you have to be explicit. > > Writing: > > p = p2 > > will merely make 'p' refer to the same object that 'p2' currently > refers to. > > For making a copy of an object, have a look at the "copy" module. > -- > https://mail.python.org/mailman/listinfo/python-list > > > > -- > *Er. Ajay A Patel* > From ctrl.dash at gmail.com Sun Sep 16 13:09:53 2018 From: ctrl.dash at gmail.com (Darya Boot) Date: Sun, 16 Sep 2018 20:09:53 +0300 Subject: Subscribe Message-ID: <5FB9AF56-006D-475C-AE4C-8BBACD4F9C0D@gmail.com> From buck.2019 at gmail.com Sun Sep 16 18:39:29 2018 From: buck.2019 at gmail.com (Buck Evan) Date: Sun, 16 Sep 2018 15:39:29 -0700 Subject: Explicit vararg values Message-ID: I started to send this to python-ideas, but I'm having second thoughts. Does tihs have merit? --- I stumble on this a lot, and I see it in many python libraries: def f(*args, **kwargs): ... f(*[list comprehension]) f(**mydict) It always seems a shame to carefully build up an object in order to explode it, just to pack it into a near-identical object. Today I was fiddling with the new python3.7 inspect.signature functionality when I ran into this case: def f(**kwargs): pass sig = inspect.signature(f) print(sig.bind(a=1, b=2)) The output is "". I found this a bit humorous since anyone attempting to bind values in this way, using f(kwargs={'a': 1, 'b': 2}) will be sorely dissappointed. I also wondered why BoundArguments didn't print '**kwargs' since that's the __str__ of that parameter object. The syntax I'm proposing is: f(**kwargs={'a': 1, 'b': 2}) as a synonym of f(a=1, b=2) when an appropriate dictionary is already on hand. --- I can argue for this another way as well. 1) When both caller and callee have a known number of values to pass/receive, that's the usual syntax: def f(x) and f(1) 2) When the caller has a fixed set of values, but the callee wants to handle a variable number: def f(*args) and f(1) 3) Caller has a variable number of arguments (varargs) but the call-ee is fixed, that's the splat operator: def f(x) and f(*args) 4) When case 1 and 3 cross paths, and we have a vararg in both the caller and callee, right now we're forced to splat both sides: def f(*args) and f(*args), but I'd like the option of opting-in to passing along my list as-is with no splat or collection operations involved: def f(*args) and f(*args=args) Currently the pattern to handle case 4 neatly is to define two versions of a vararg function: def f(*arg, **kwargs): return _f(args, kwargs) return _f(args, kwargs): ... Such that when internal calllers hit case 4, there's a simple and efficient way forward -- use the internal de-vararg'd definition of f. External callers have no such option though, without breaking protected api convention. My proposal would simplify this implementation as well as allowing users to make use of a similar calling convention that was only provided privately before. Examples: log(*args) and _log(args) in logging.Logger format and vformat of strings.Formatter From python at mrabarnett.plus.com Sun Sep 16 20:39:30 2018 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 17 Sep 2018 01:39:30 +0100 Subject: dll file missing error In-Reply-To: References: Message-ID: On 2018-09-15 22:22, benjamin bulley wrote: > I encounter a dll error message while trying to run python. I uninstalled > the program just to reinstall to find the same problem. Please help as I am > quite new to this. > You haven't given any details. Which version of Windows? Which DLL? Which version of Python? If it's complaining about this "api-ms-win-crt-runtime-l1-1-0.dll", then you need the Windows Universal C Runtime: http://www.microsoft.com/en-us/download/details.aspx?id=48234 From python at mrabarnett.plus.com Sun Sep 16 20:40:59 2018 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 17 Sep 2018 01:40:59 +0100 Subject: Subscribe In-Reply-To: <5FB9AF56-006D-475C-AE4C-8BBACD4F9C0D@gmail.com> References: <5FB9AF56-006D-475C-AE4C-8BBACD4F9C0D@gmail.com> Message-ID: <9b6f68f2-f698-68d2-6ed6-da7c2cf8b9c5@mrabarnett.plus.com> On 2018-09-16 18:09, Darya Boot wrote: > If you want to subscribe to this list, then follow the instructions here: https://mail.python.org/mailman/listinfo/python-list From choihotv at gmail.com Mon Sep 17 00:59:14 2018 From: choihotv at gmail.com (YnIk) Date: Sun, 16 Sep 2018 21:59:14 -0700 Subject: Python in endless loop Message-ID: <5b9f3487.1c69fb81.575c7.5566@mx.google.com> Dear Python, Hello. This is an email concerning about my Python program(3.7.0). It keeps printing out stuff that?s too fast to read. If I try to write code, it just keeps on going. I have tried Ctrl+C, but even that?s not working. I searched through all my flies and can?t find one error that would cause this. I tried uninstalling and reinstalling the program multiple times, and that doesn?t work. What should I do? Thanks, Ed Sent from Mail for Windows 10 From syed.shujjat88 at hotmail.com Mon Sep 17 03:56:56 2018 From: syed.shujjat88 at hotmail.com (Syed Shujaat) Date: Mon, 17 Sep 2018 07:56:56 +0000 Subject: giving error during installation (ez_setup.py given error could not create ssl/tls secure channel) Message-ID: Hello, can you please help regarding this problem. ez_setup.py given error could not create ssl/tls secure channel Regards Syed Shujaat From jupiter.hce at gmail.com Mon Sep 17 04:06:07 2018 From: jupiter.hce at gmail.com (nobody) Date: Mon, 17 Sep 2018 01:06:07 -0700 (PDT) Subject: import inspect error Message-ID: I have following errors running on Ubuntu 18, any insight how to fix it? Thank you. Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import inspect Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/inspect.py", line 42, in from collections import namedtuple File "/usr/lib/python2.7/collections.py", line 22, in from keyword import iskeyword as _iskeyword File "keyword.py", line 3, in from inspect import currentframe, getframeinfo ImportError: cannot import name currentframe From rosuav at gmail.com Mon Sep 17 05:00:37 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 17 Sep 2018 19:00:37 +1000 Subject: import inspect error In-Reply-To: References: Message-ID: On Mon, Sep 17, 2018 at 6:06 PM, nobody wrote: > I have following errors running on Ubuntu 18, any insight how to fix it? Thank you. > > Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) > [GCC 7.3.0] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import inspect > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.7/inspect.py", line 42, in > from collections import namedtuple > File "/usr/lib/python2.7/collections.py", line 22, in > from keyword import iskeyword as _iskeyword > File "keyword.py", line 3, in > from inspect import currentframe, getframeinfo > ImportError: cannot import name currentframe You've made a file called keyword.py, which is shadowing the standard library module of that name. Rename or delete that file, and you should be able to use the original again. ChrisA From gherron at digipen.edu Mon Sep 17 05:13:28 2018 From: gherron at digipen.edu (Gary Herron) Date: Mon, 17 Sep 2018 02:13:28 -0700 Subject: import inspect error In-Reply-To: References: Message-ID: <7eda8b13-e853-cbeb-e2ca-3e6933c81b7f@digipen.edu> You appear to have a local file named keyword.py which is hiding a python installation file of the same name. Gary Herron On 09/17/2018 01:06 AM, jupiter.hce at gmail.com wrote: > I have following errors running on Ubuntu 18, any insight how to fix it? Thank you. > > Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) > [GCC 7.3.0] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import inspect > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.7/inspect.py", line 42, in > from collections import namedtuple > File "/usr/lib/python2.7/collections.py", line 22, in > from keyword import iskeyword as _iskeyword > File "keyword.py", line 3, in > from inspect import currentframe, getframeinfo > ImportError: cannot import name currentframe -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 From qsx at chaotikum.eu Mon Sep 17 05:48:58 2018 From: qsx at chaotikum.eu (Thomas Schneider) Date: Mon, 17 Sep 2018 11:48:58 +0200 Subject: Add header at top with email.message References: Message-ID: Jason Friedman writes: > I suppose you already figured out that you can call __delitem__() to > clear the headers and add them back in whatever order you like. Well, this would mean saving all headers, deleting all, inserting my own, and adding the saved original headers again. Seems complicated. > I'm interested in learning more about your use case. Do you have a > third party with fixed logic that requires the headers in a particular > order? Yes, RFC 5321, section 4.4[0] :) > When an SMTP server receives a message for delivery or further > processing, it MUST insert trace ("time stamp" or "Received") > information at the beginning of the message content, as discussed in > Section 4.1.1.4. To trace the path a message went, those headers do need to be in a particular order, or else they won?t make any sense. [0]: https://tools.ietf.org/html/rfc5321#section-4.4 From __peter__ at web.de Mon Sep 17 10:07:49 2018 From: __peter__ at web.de (Peter Otten) Date: Mon, 17 Sep 2018 16:07:49 +0200 Subject: Python in endless loop References: <5b9f3487.1c69fb81.575c7.5566@mx.google.com> Message-ID: YnIk wrote: > Dear Python, > Hello. This is an email concerning about my Python program(3.7.0). It > keeps printing out stuff that?s too fast to read. If I try to write code, > it just keeps on going. I have tried Ctrl+C, but even that?s not working. > I searched through all my flies and can?t find one error that would cause > this. I tried uninstalling and reinstalling the program multiple times, > and that doesn?t work. What should I do? Thanks, Ed Run the script from the command line and feed the output to the more utility: C:\> py path\to\myscript.py | more Do not type the C:\> which is a placeholder for the command prompt; you should be seeing something similar. Once you have a rough idea where the problem occurs you can add print statements to inspect the value of the problematic variables. A tad more advanced: your editor (which one?) may support setting "breakpoints" and running the script under a debugger step by step or until it hits a breakpoint. If you need help with debugging and your script is short you may also post it here or provide a link to the source code. From bgailer at gmail.com Mon Sep 17 10:23:03 2018 From: bgailer at gmail.com (Bob Gailer) Date: Mon, 17 Sep 2018 10:23:03 -0400 Subject: Python in endless loop In-Reply-To: <5b9f3487.1c69fb81.575c7.5566@mx.google.com> References: <5b9f3487.1c69fb81.575c7.5566@mx.google.com> Message-ID: On Sep 17, 2018 9:31 AM, "YnIk" wrote: > > Dear Python, > Hello. This is an email concerning about my Python program(3.7.0). It keeps printing out stuff that?s too fast to read. If I try to write code, it just keeps on going. I have tried Ctrl+C, but even that?s not working. I searched through all my flies and can?t find one error that would cause this. I tried uninstalling and reinstalling the program multiple times, and that doesn?t work. What should I do? What did you do to install python? What action(s) do you take after installation that lead to the problem? Where does the output appear? Normally output appears in a window. Does this window have a title; if so what is it? You try yo write code. That presumes some kind of editor or command window. How do you get this window; what is it's title? I assume you mean "files". Do you literally search the thousands of files that are a part of a Windows installation? If not, which files? What are you looking for (when you say "error")? Please be as explicit as possible. We don't have ESP or crystal balls. > Thanks, Ed > > Sent from Mail for Windows 10 > > -- > https://mail.python.org/mailman/listinfo/python-list From arj.python at gmail.com Mon Sep 17 11:26:42 2018 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Mon, 17 Sep 2018 19:26:42 +0400 Subject: Zen of The Python Mailing List Message-ID: change of subject, wanted to add this : previous messages are worth a read Abdur-Rahmaan Janhangeer Mauritius ---------- Forwarded message --------- From: Abdur-Rahmaan Janhangeer Date: Mon, 17 Sep 2018, 19:18 Subject: Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause To: Cc: python-ideas Zen of The Python Mailing List >>> import that on topic is better than off topic the dish of toxicity is made up of opinion attacking irony is it's fine herbs top posting should be counselled homeworks are not to be done mail clients are the tastes and colours of life a mailing list serves it's purpose, unless specified ideas are the flagship of focus balazing pingponging is sign of Zen explosion RTFM has kinder alternatives good english is preferred, but makes you not a better programmer From bgailer at gmail.com Mon Sep 17 11:35:30 2018 From: bgailer at gmail.com (Bob Gailer) Date: Mon, 17 Sep 2018 11:35:30 -0400 Subject: Experiences with a programming exercise In-Reply-To: References: Message-ID: On Sep 15, 2018 1:50 PM, "Alister via Python-list" wrote: > > On Sat, 15 Sep 2018 17:08:57 +0000, Stefan Ram wrote: > > > I gave two different functions: > > > > def triangle(): > > for i in range( 3 ): > > forward( 99 ); left( 360/3 ) > > > > def rectangle() > > for i in range( 4 ): > > forward( 99 ); left( 360/4 ) > > > > , and the exercise was to write a single definition for a function > > ?angle( n )? that can be called with ?3? to paint a triangle and with > > ?4? to paint a rectangle. Nearly all participants wrote something like > > this: > > > > def angle( n ): > > if n == 3: > > for i in range( 3 ): > > forward( 99 ); left( 360/3 ) > > if n == 4: > > for i in range( 4 ): > > forward( 99 ); left( 360/4 ) > > > > Now I have added the requirement that the solution should be as short > > as possible! My candidate for shortest expression: [( forward( 99 ), left( 360/n)) for x in 'a'*n] > > seems a good exercise & you are breaking the students in step by stem > which is also good > get something that works, then make it better > > i would suggest instead of the new requirement to be make it a short as > possible make it work with ANY number of sides. > > > > > -- > Max told his friend that he'd just as soon not go hiking in the > hills. > Said he, "I'm an anti-climb Max." > [So is that punchline.] > -- > https://mail.python.org/mailman/listinfo/python-list From jqian at tibco.com Mon Sep 17 12:01:47 2018 From: jqian at tibco.com (Jason Qian) Date: Mon, 17 Sep 2018 12:01:47 -0400 Subject: how to get string printed by PyErr_Print( ) Message-ID: Hey, Someone has discussed this issue before. Other than redirect stderr, does the new version python 3.7.0 has other way to retrieve the string whichPyErr_Print( ) ? if (PyErr_Occurred()) PyErr_Print(); //need to retrieve the error to string Thanks From dieter at handshake.de Tue Sep 18 02:08:17 2018 From: dieter at handshake.de (dieter) Date: Tue, 18 Sep 2018 08:08:17 +0200 Subject: giving error during installation (ez_setup.py given error could not create ssl/tls secure channel) References: Message-ID: <878t3zl4mm.fsf@handshake.de> Syed Shujaat writes: > can you please help regarding this problem. ez_setup.py given error could not create ssl/tls secure channel Apparently, "ez_setup.py" tries to upgrade a transport communication channel with SSL (= "Secure Socket Layer") or TLS (= "Transport Layer Security") and fails. Unfortunately, this may have many possible causes -- among others: * it may be a temporary problem on the server side (and go away automatically after perhaps an hour, a day) * the trusted certificate information on your host may be missing or outdated; as a consequence, the server certificate presented during SSL/TSL negociation could not be verified * the "ez_setup.py" may be too old and its connection information outdated. * ... What can you do? Each potential cause requires cause specific action. Temporary problem: retry after some time (an hour, a day). If the error persists, it is likely not a temporary problem. Trusted certificate information: it is usually stored at a central place on your host and shared by all applications. If you install a browser, it typically comes with up-to-date trusted certificate information. Up-to-date "ez_Setup.py": are you sure, you are using an up-to-date "ez_Setup.py". If not, search and download an up-to-date one. From roberto at leinardi.com Tue Sep 18 07:40:55 2018 From: roberto at leinardi.com (Roberto Leinardi) Date: Tue, 18 Sep 2018 13:40:55 +0200 Subject: PyLint and Mypy real-time (and on-demand) code inspection from within PyCharm/IDEA Message-ID: Hello there, I am the developer of pylint-pycharm and mypy-pycharm, two plugins providing both real-time and on-demand scanning of Python files with PyLint/Mypy from within PyCharm/IDEA. The real-time code inspection works automatically the same way like the PyCharm's build-in PEP8 check (you see the issues highlighted directly in your code while typing). The on-demand inspection has several options that go from just scanning the current file to scan the entire project. The plugins also offer an option to run a check on modified files before a VCS checkin. If you are familiar with Checkstyle-IDEA plugin for Java, they are very similar and offer the same features (and share a lot of the code). The plugins source code is available here: https://github.com/leinardi/pylint-pycharm https://github.com/leinardi/mypy-pycharm But they can also be easily installed from the official JetBrains Plugin Repository: 1. In PyCharm, open the Settings/Preferences dialog (CTRL+Alt+S), click Plugins. 2. Click Browse repositories. 3. In the Browse Repositories dialog that opens, right-click on the plugin named "Pylint" or "Mypy" and select Download and Install. 4. Confirm your intention to download and install the selected plugin. 5. Click Close. 6. Click OK in the Settings dialog and restart PyCharm for the changes to take effect. Thanks and enjoy linting! Roberto From vito.detullio at gmail.com Tue Sep 18 10:20:06 2018 From: vito.detullio at gmail.com (vito.detullio at gmail.com) Date: Tue, 18 Sep 2018 07:20:06 -0700 (PDT) Subject: transform a "normal" decorator in one for async functions Message-ID: <35adbe23-80e1-4951-af37-e2741651558e@googlegroups.com> Hi. Let's say I have this library that expose a decorator; it's meant to be used with normal functions. but I have to "apply" the decorator to an async function. >From what I understand I cannot "really" wait for this decorated async function, as it's not really "async", and, from a simple test I made, I see that the order of execution is not really "straight" (I have simplifield the example to the bone) import asyncio def deco(fun): # the "classic" decorator def wrap(*args, **kwargs): print('wrap begin') try: return fun(*args, **kwargs) finally: print('wrap end') return wrap @deco async def decorated_async(): print('a') await asyncio.sleep(1) print('b') loop = asyncio.get_event_loop() loop.run_until_complete(decorated_async()) loop.close() the output of this script is wrap begin wrap end a b while an "async-aware" decorator (with an "async" wrap that "await"s the fun call) would print the "wrap end" line at the end. I can easily rewrite my dumb decorator to handle async functions (I can just make an "async def wrap" and "return await fun"), but I cannot rewrite this library. is there a way to "convert" a "normal" decorator in one that can handle async functions? Thanks From none at gmail.com Tue Sep 18 11:01:36 2018 From: none at gmail.com (ast) Date: Tue, 18 Sep 2018 17:01:36 +0200 Subject: Permutations using a recursive generator Message-ID: <5ba11353$0$21602$426a34cc@news.free.fr> Hello I found a smart and very concise code to generate all permutations of a list. I put it here if someone is interested to figure out how it works def permut(li, prefix=[]): if len(li)==1: yield prefix + li else: for elt in li: li2 = li.copy() li2.remove(elt) yield from S(li2, prefix+[elt]) exemple of usage >>> list(permut(['a', 'b', 'c'])) [['a', 'b', 'c'], ['a', 'c', 'b'], ['b', 'a', 'c'], ['b', 'c', 'a'], ['c', 'a', 'b'], ['c', 'b', 'a']] >>> list(permut([0,1,2,3])) [[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 1, 3], [0, 2, 3, 1], [0, 3, 1, 2], [0, 3, 2, 1], [1, 0, 2, 3], [1, 0, 3, 2], [1, 2, 0, 3], [1, 2, 3, 0], [1, 3, 0, 2], [1, 3, 2, 0], [2, 0, 1, 3], [2, 0, 3, 1], [2, 1, 0, 3], [2, 1, 3, 0], [2, 3, 0, 1], [2, 3, 1, 0], [3, 0, 1, 2], [3, 0, 2, 1], [3, 1, 0, 2], [3, 1, 2, 0], [3, 2, 0, 1], [3, 2, 1, 0]] From none at gmail.com Tue Sep 18 11:05:31 2018 From: none at gmail.com (ast) Date: Tue, 18 Sep 2018 17:05:31 +0200 Subject: Permutations using a recursive generator In-Reply-To: <5ba11353$0$21602$426a34cc@news.free.fr> References: <5ba11353$0$21602$426a34cc@news.free.fr> Message-ID: <5ba1143e$0$14331$426a74cc@news.free.fr> Le 18/09/2018 ? 17:01, ast a ?crit?: error: permut instead of S > ??????????? yield from permut(li2, prefix+[elt]) From tjol at tjol.eu Tue Sep 18 11:09:53 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 18 Sep 2018 17:09:53 +0200 Subject: transform a "normal" decorator in one for async functions In-Reply-To: <35adbe23-80e1-4951-af37-e2741651558e@googlegroups.com> References: <35adbe23-80e1-4951-af37-e2741651558e@googlegroups.com> Message-ID: <605c8a20-122f-1f97-8bb6-085fc13f361b@tjol.eu> On 2018-09-18 16:20, vito.detullio at gmail.com wrote: > but I cannot rewrite this library. Perhaps not, but surely you can write your own decorator that does whatever this library's decorator does for async functions? Presumably you have the code... > is there a way to "convert" a "normal" decorator in one that can handle async functions? In general? No. From tjol at tjol.eu Tue Sep 18 11:21:10 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Tue, 18 Sep 2018 17:21:10 +0200 Subject: Permutations using a recursive generator In-Reply-To: <5ba1143e$0$14331$426a74cc@news.free.fr> References: <5ba11353$0$21602$426a34cc@news.free.fr> <5ba1143e$0$14331$426a74cc@news.free.fr> Message-ID: On 2018-09-18 17:05, ast wrote: > Le 18/09/2018 ? 17:01, ast a ?crit?: >> Hello >> >> I found a smart and very concise code to >> generate all permutations of a list. >> I put it here if someone is interested to >> figure out how it works When you say "found a [...] code" I hope you mean "wrote a function" rather than "discovered a bit of code and decided to share it without attribution or permission". >> >> >> def permut(li, prefix=[]): >> >> if len(li)==1: >> yield prefix + li >> else: >> for elt in li: >> li2 = li.copy() >> li2.remove(elt) >> yield from S(li2, prefix+[elt]) > > error: permut instead of S > >> ???????????? yield from permut(li2, prefix+[elt]) Nice. If you want to see more implementations of the same thing, have a look in the standard library docs ;-) https://docs.python.org/3/library/itertools.html#itertools.permutations From vito.detullio at gmail.com Tue Sep 18 11:36:01 2018 From: vito.detullio at gmail.com (vito.detullio at gmail.com) Date: Tue, 18 Sep 2018 08:36:01 -0700 (PDT) Subject: transform a "normal" decorator in one for async functions In-Reply-To: References: <35adbe23-80e1-4951-af37-e2741651558e@googlegroups.com> <605c8a20-122f-1f97-8bb6-085fc13f361b@tjol.eu> Message-ID: <20296422-59a0-4c0f-abab-e606d846f5a5@googlegroups.com> Il giorno marted? 18 settembre 2018 17:15:22 UTC+2, Thomas Jollans ha scritto: > > but I cannot rewrite this library. > > Perhaps not, but surely you can write your own decorator that does > whatever this library's decorator does for async functions? Presumably > you have the code... well, maybe? While I could have access to the sources, I don't want to "maintain" (part of) this library. Worst even if I need to maintain it in my project, and not upstream. > > is there a way to "convert" a "normal" decorator in one that can handle async functions? > In general? No. Ouch. I'm new to the "async" world, but so this mean that all of the (appliable) decorators present in the various libraries have to be "paired" with async versions? From chandankumarknh at gmail.com Tue Sep 18 12:45:38 2018 From: chandankumarknh at gmail.com (Chandan Kumar Abhimanyu) Date: Tue, 18 Sep 2018 22:15:38 +0530 Subject: missing- api-ms-win-crt-runtime-|1-1-0.dll Message-ID: how I download and install api-ms-win-crt-runtime-|1-1-0.dll .... when I am downloading by googling it is not installable file. -- *Chandan Kumar Abhimanyu* *+91 9876852058* *Department of Management Studies,* *Indian Institute of Technology (ISM), Dhanbad, * *Jharkhand- 826004, India.* From jkc061991 at gmail.com Tue Sep 18 13:48:23 2018 From: jkc061991 at gmail.com (Cruey Cruel) Date: Tue, 18 Sep 2018 23:18:23 +0530 Subject: Can't import array in 3.7 python version In-Reply-To: References: Message-ID: I have subscribe to python list, please provide me any resolution forpreviois below email On Tue, 18 Sep 2018, 23:07 Cruey Cruel, wrote: > Hi team, > Am facing issue in importing array. > > I use alatest version of pythonide and pycharm. > > Telle how can I fix this. > > Thanks and regards > Jignesh > From toby at tobiah.org Tue Sep 18 14:28:41 2018 From: toby at tobiah.org (Tobiah) Date: Tue, 18 Sep 2018 11:28:41 -0700 Subject: MIDI note timing Message-ID: I'd like to do some algorithmic composing using python. I've seen various libraries that seem to be capable of sending a MIDI message to a MIDI port, but I don't know where to get the timing from. Normally, with something like CSOUND, the program locks itself to the timing of the soundcard and presumably uses that for timing. Is there anything for python that could do this? I've seen rather ridiculous examples using sleeps for timing, but for musical applications the timing really needs to come form a hardware soundcard, especially as I'd like to play audio through the card at the same time and have it line up perfectly with the MIDI. Thanks for any suggestions. Toby From breamoreboy at gmail.com Tue Sep 18 14:35:04 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Tue, 18 Sep 2018 19:35:04 +0100 Subject: missing- api-ms-win-crt-runtime-|1-1-0.dll In-Reply-To: References: Message-ID: On 18/09/18 17:45, Chandan Kumar Abhimanyu wrote: > how I download and install api-ms-win-crt-runtime-|1-1-0.dll .... when I am > downloading by googling it is not installable file. > https://www.microsoft.com/en-us/download/details.aspx?id=49984 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From eryksun at gmail.com Tue Sep 18 14:42:06 2018 From: eryksun at gmail.com (eryk sun) Date: Tue, 18 Sep 2018 13:42:06 -0500 Subject: missing- api-ms-win-crt-runtime-|1-1-0.dll In-Reply-To: References: Message-ID: On Tue, Sep 18, 2018 at 11:45 AM, Chandan Kumar Abhimanyu wrote: > how I download and install api-ms-win-crt-runtime-|1-1-0.dll .... when I am > downloading by googling it is not installable file. The Universal C Runtime (CRT) is an OS component for Windows Vista and later. Make sure Windows Update is enabled and configured to install optional updates. That said, Python's installer should have installed the Universal CRT if it wasn't already installed. Maybe your system just needs to be restarted. From gheskett at shentel.net Tue Sep 18 14:43:50 2018 From: gheskett at shentel.net (Gene Heskett) Date: Tue, 18 Sep 2018 14:43:50 -0400 Subject: missing- api-ms-win-crt-runtime-|1-1-0.dll In-Reply-To: References: Message-ID: <201809181443.50164.gheskett@shentel.net> On Tuesday 18 September 2018 12:45:38 Chandan Kumar Abhimanyu wrote: > how I download and install api-ms-win-crt-runtime-|1-1-0.dll .... when > I am downloading by googling it is not installable file. > -- > *Chandan Kumar Abhimanyu* > *+91 9876852058* > *Department of Management Studies,* > *Indian Institute of Technology (ISM), Dhanbad, * > *Jharkhand- 826004, India.* I'd delete it and go get it from a more reputable site preferably the M$ site as its a freely distributall part for one of their C++ variations. Best fix instructions seems to be at: So apparently the | is a legal filename component, to a windows box. Windows never ceases to amaze me. 7 machines running here right now, but not a single windows install. -- 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 python at mrabarnett.plus.com Tue Sep 18 15:57:57 2018 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 18 Sep 2018 20:57:57 +0100 Subject: Can't import array in 3.7 python version In-Reply-To: References: Message-ID: <8253fa3a-0cda-c80b-7188-a42c99cf652d@mrabarnett.plus.com> On 2018-09-18 18:48, Cruey Cruel wrote: > I have subscribe to python list, please provide me any resolution > forpreviois below email > What error message does it print? It might be that you have a named a file the same as one of those in Python's standard library, e.g. "array.py". If that's not the problem, then you'll need to provide some more details. Copy the traceback and post it here. > On Tue, 18 Sep 2018, 23:07 Cruey Cruel, wrote: > >> Hi team, >> Am facing issue in importing array. >> >> I use alatest version of pythonide and pycharm. >> >> Telle how can I fix this. >> >> Thanks and regards >> Jignesh >> > From python at mrabarnett.plus.com Tue Sep 18 15:59:52 2018 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 18 Sep 2018 20:59:52 +0100 Subject: missing- api-ms-win-crt-runtime-|1-1-0.dll In-Reply-To: <201809181443.50164.gheskett@shentel.net> References: <201809181443.50164.gheskett@shentel.net> Message-ID: On 2018-09-18 19:43, Gene Heskett wrote: > On Tuesday 18 September 2018 12:45:38 Chandan Kumar Abhimanyu wrote: > >> how I download and install api-ms-win-crt-runtime-|1-1-0.dll .... when >> I am downloading by googling it is not installable file. >> -- >> *Chandan Kumar Abhimanyu* >> *+91 9876852058* >> *Department of Management Studies,* >> *Indian Institute of Technology (ISM), Dhanbad, * >> *Jharkhand- 826004, India.* > > > I'd delete it and go get it from a more reputable site preferably the M$ > site as its a freely distributall part for one of their C++ variations. > > Best fix instructions seems to be at: > > > > So apparently the | is a legal filename component, to a windows box. > Windows never ceases to amaze me. 7 machines running here right now, but > not a single windows install. > Either that, or it's a spelling mistake. Which do you think is more likely? :-) From eryksun at gmail.com Tue Sep 18 16:11:44 2018 From: eryksun at gmail.com (eryk sun) Date: Tue, 18 Sep 2018 15:11:44 -0500 Subject: missing- api-ms-win-crt-runtime-|1-1-0.dll In-Reply-To: <201809181443.50164.gheskett@shentel.net> References: <201809181443.50164.gheskett@shentel.net> Message-ID: On Tue, Sep 18, 2018 at 1:43 PM, Gene Heskett wrote: > > > > So apparently the | is a legal filename component, to a windows box. "l1-1-0" starts with "l" (ordinal 0x6c, i.e. lower-case "L"), not "|" (pipe, 0x7c). Other than the OS path separator, \ (backslash, 0x5c), the set of reserved characters is up to the file system. It's recommended to reserve NUL (0x00), / (slash, 0x2f) and the 5 wildcard characters: *?"<> (0x2a, 0x3f, 0x22, 0x3c, 0x3e). NTFS additionally reserves : (colon, 0x3a) as the delimeter for stream names and types, | (pipe, 0x7c) for no good reason, and control characters (0x01 - 0x1F). In contrast, if you're running Windows as a guest OS in a VirtualBox VM, its VboxSF file system (for sharing folders with the host OS) actually allows colon, pipe, and control characters in filenames. From gheskett at shentel.net Tue Sep 18 19:42:50 2018 From: gheskett at shentel.net (Gene Heskett) Date: Tue, 18 Sep 2018 19:42:50 -0400 Subject: missing- api-ms-win-crt-runtime-|1-1-0.dll In-Reply-To: References: <201809181443.50164.gheskett@shentel.net> Message-ID: <201809181942.50786.gheskett@shentel.net> On Tuesday 18 September 2018 15:59:52 MRAB wrote: > On 2018-09-18 19:43, Gene Heskett wrote: > > On Tuesday 18 September 2018 12:45:38 Chandan Kumar Abhimanyu wrote: > >> how I download and install api-ms-win-crt-runtime-|1-1-0.dll .... > >> when I am downloading by googling it is not installable file. > >> -- > >> *Chandan Kumar Abhimanyu* > >> *+91 9876852058* > >> *Department of Management Studies,* > >> *Indian Institute of Technology (ISM), Dhanbad, * > >> *Jharkhand- 826004, India.* > > > > I'd delete it and go get it from a more reputable site preferably > > the M$ site as its a freely distributall part for one of their C++ > > variations. > > > > Best fix instructions seems to be at: > > > > >-runtime-l1-1-0dll-error-3676874/> > > > > So apparently the | is a legal filename component, to a windows box. > > Windows never ceases to amaze me. 7 machines running here right now, > > but not a single windows install. > > Either that, or it's a spelling mistake. Which do you think is more > likely? :-) I'm fresh out of quarters to flip on that. The character, as it existed all over the net when I did the google thing, was an |, not a lowercase l, as you have it, exists 50+ times in the reading of google hits I did last night. So you'll have to ask M$ which it is. -- 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 vito.detullio at gmail.com Wed Sep 19 03:33:24 2018 From: vito.detullio at gmail.com (vito.detullio at gmail.com) Date: Wed, 19 Sep 2018 00:33:24 -0700 (PDT) Subject: transform a "normal" decorator in one for async functions In-Reply-To: <20296422-59a0-4c0f-abab-e606d846f5a5@googlegroups.com> References: <35adbe23-80e1-4951-af37-e2741651558e@googlegroups.com> <605c8a20-122f-1f97-8bb6-085fc13f361b@tjol.eu> <20296422-59a0-4c0f-abab-e606d846f5a5@googlegroups.com> Message-ID: <6be01dcf-f063-45f6-9e5d-157b2a615734@googlegroups.com> Il giorno marted? 18 settembre 2018 17:36:16 UTC+2, vito.d... at gmail.com ha scritto: > > > is there a way to "convert" a "normal" decorator in one that can handle async functions? > > In general? No. > Ouch. > > I'm new to the "async" world, but so this mean that all of the (appliable) decorators present in the various libraries have to be "paired" with async versions? I was also thinking: there are some decorator functions (and decorator functions factories) also in the stdlib (functools.wrap, property, classmethod ... you name it) so this means that also we need to check each of them if is applyable to async functions? From Harald.Winroth at elekta.com Wed Sep 19 06:00:56 2018 From: Harald.Winroth at elekta.com (Winroth, Harald) Date: Wed, 19 Sep 2018 10:00:56 +0000 Subject: Search box missing from 3.7.0 documentation home page docs.python.org/3 Message-ID: <8ceb4e9839c54f12aabc3e5ce0e7407d@elekta.com> I noticed the quick search box in the top-right corner of the pages on docs.python.org for Python version 3.7.0 is missing (but not for 3.6 or 3.8). Maybe you?re already aware of that. Best regards Harald Restricted Information and Basic Personal Data Harald Winroth | Senior Software Engineer Elekta Instrument, AB P.O. Box 7593, SE-103 93 Stockholm, Sweden Visiting Address: Kungstensgatan 18 Office: +46858725408 | Mobile: +46703485833 | Fax: +46858725500 Harald.Winroth at elekta.com | www.elekta.com Elekta Instrument AB, Reg No. 556492-0949 [cid:image36d565.JPG at 99fc2ae6.49b1ab87] ---------------------------- This message is confidential and may be legally privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system; you must not copy or disclose the contents of this message or any attachment to any other person. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Elekta. Elekta may monitor email traffic data. ---------------------------- From alon.najman at gmail.com Wed Sep 19 08:12:55 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Wed, 19 Sep 2018 05:12:55 -0700 (PDT) Subject: python3.7 problem with validation - it doesnt work Message-ID: python3.7 problem with validation - it doesn't work. I added 2 variables to the IF of the validation: global UserGmail global PassGmail here is the code: import sys import requests from lxml import html import requests import urllib.request, urllib.error, urllib.parse import _thread from PyQt5 import QtCore, QtGui, QtWidgets import time import threading import ctypes # An included library with Python install. global flag global loopexit global UserSymbol global RadioButtonBellow global UserSymbol global UserStockPrice global RadioButtonAbove global SMScheckBox global UserGmail global PassGmail UserSymbol=0 RadioButtonBellow=0 RadioButtonAbove=0 UserSymbol=0 UserStockPrice=0 UserGmail=0 PassGmail=0 loopexit=0 def get_quote(str): url="https://api.iextrading.com/1.0/stock/"+str+"/price" resource = urllib.request.urlopen(url) content = resource.read().decode(resource.headers.get_content_charset()) print (content) content=float(content) return content def myfunction(): import paramiko import sys global RadioButtonBellow global UserSymbol global UserStockPrice global RadioButtonAbove global UserGmail global PassGmail print(UserGmail+" "+PassGmail) from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(687, 571) self.radioButton = QtWidgets.QRadioButton(Dialog) self.radioButton.setGeometry(QtCore.QRect(80, 190, 191, 24)) font = QtGui.QFont() font.setPointSize(14) self.radioButton.setFont(font) self.radioButton.setObjectName("radioButton") self.buttonGroup_2 = QtWidgets.QButtonGroup(Dialog) self.buttonGroup_2.setObjectName("buttonGroup_2") self.buttonGroup_2.addButton(self.radioButton) self.checkBox = QtWidgets.QCheckBox(Dialog) self.checkBox.setGeometry(QtCore.QRect(290, 450, 131, 17)) font = QtGui.QFont() font.setPointSize(14) self.checkBox.setFont(font) self.checkBox.setObjectName("checkBox") self.checkBox_2 = QtWidgets.QCheckBox(Dialog) self.checkBox_2.setGeometry(QtCore.QRect(290, 480, 141, 17)) font = QtGui.QFont() font.setPointSize(14) self.checkBox_2.setFont(font) self.checkBox_2.setObjectName("checkBox_2") self.radioButton_2 = QtWidgets.QRadioButton(Dialog) self.radioButton_2.setGeometry(QtCore.QRect(300, 190, 186, 24)) font = QtGui.QFont() font.setPointSize(14) self.radioButton_2.setFont(font) self.radioButton_2.setObjectName("radioButton_2") self.buttonGroup_2.addButton(self.radioButton_2) self.pushButton = QtWidgets.QPushButton(Dialog) self.pushButton.setEnabled(True) self.pushButton.setGeometry(QtCore.QRect(60, 460, 72, 31)) font = QtGui.QFont() font.setPointSize(14) self.pushButton.setFont(font) self.pushButton.setObjectName("pushButton") self.radioButton_3 = QtWidgets.QRadioButton(Dialog) self.radioButton_3.setGeometry(QtCore.QRect(80, 250, 191, 24)) font = QtGui.QFont() font.setPointSize(14) self.radioButton_3.setFont(font) self.radioButton_3.setObjectName("radioButton_3") self.buttonGroup = QtWidgets.QButtonGroup(Dialog) self.buttonGroup.setObjectName("buttonGroup") self.buttonGroup.addButton(self.radioButton_3) self.radioButton_4 = QtWidgets.QRadioButton(Dialog) self.radioButton_4.setGeometry(QtCore.QRect(300, 250, 186, 24)) font = QtGui.QFont() font.setPointSize(14) self.radioButton_4.setFont(font) self.radioButton_4.setObjectName("radioButton_4") self.buttonGroup.addButton(self.radioButton_4) self.pushButton_2 = QtWidgets.QPushButton(Dialog) self.pushButton_2.setGeometry(QtCore.QRect(30, 20, 75, 31)) font = QtGui.QFont() font.setPointSize(14) self.pushButton_2.setFont(font) self.pushButton_2.setObjectName("pushButton_2") self.textEdit_4 = QtWidgets.QTextEdit(Dialog) self.textEdit_4.setGeometry(QtCore.QRect(310, 383, 221, 38)) font = QtGui.QFont() font.setPointSize(16) self.textEdit_4.setFont(font) self.textEdit_4.setObjectName("textEdit_4") self.textEdit_5 = QtWidgets.QTextEdit(Dialog) self.textEdit_5.setGeometry(QtCore.QRect(310, 340, 221, 38)) font = QtGui.QFont() font.setPointSize(16) self.textEdit_5.setFont(font) self.textEdit_5.setObjectName("textEdit_5") self.label = QtWidgets.QLabel(Dialog) self.label.setGeometry(QtCore.QRect(150, 80, 111, 16)) font = QtGui.QFont() font.setPointSize(14) self.label.setFont(font) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(Dialog) self.label_2.setGeometry(QtCore.QRect(410, 80, 131, 16)) font = QtGui.QFont() font.setPointSize(14) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(Dialog) self.label_3.setGeometry(QtCore.QRect(160, 350, 121, 20)) font = QtGui.QFont() font.setPointSize(14) self.label_3.setFont(font) self.label_3.setObjectName("label_3") self.label_4 = QtWidgets.QLabel(Dialog) self.label_4.setGeometry(QtCore.QRect(140, 390, 171, 20)) font = QtGui.QFont() font.setPointSize(14) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.label_5 = QtWidgets.QLabel(Dialog) self.label_5.setGeometry(QtCore.QRect(170, 30, 351, 31)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(18) self.label_5.setFont(font) self.label_5.setObjectName("label_5") self.pushButton_3 = QtWidgets.QPushButton(Dialog) self.pushButton_3.setGeometry(QtCore.QRect(150, 460, 72, 31)) font = QtGui.QFont() font.setPointSize(14) self.pushButton_3.setFont(font) self.pushButton_3.setObjectName("pushButton_3") self.textEdit = QtWidgets.QTextEdit(Dialog) self.textEdit.setGeometry(QtCore.QRect(80, 110, 221, 38)) font = QtGui.QFont() font.setPointSize(16) self.textEdit.setFont(font) self.textEdit.setObjectName("textEdit") self.textEdit_7 = QtWidgets.QTextEdit(Dialog) self.textEdit_7.setGeometry(QtCore.QRect(330, 110, 221, 38)) font = QtGui.QFont() font.setPointSize(16) self.textEdit_7.setFont(font) self.textEdit_7.setObjectName("textEdit_7") self.minimize = QtWidgets.QPushButton(Dialog) self.minimize.setGeometry(QtCore.QRect(564, 20, 91, 31)) font = QtGui.QFont() font.setPointSize(14) self.minimize.setFont(font) self.minimize.setObjectName("minimize") self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog) self.pushButton.clicked.connect(self.printMessage) self.radioButton.toggled.connect(self.myradioButton1_function) self.radioButton_2.toggled.connect(self.myradioButton2_function) self.pushButton_3.clicked.connect(self.stopButton) self.checkBox.stateChanged.connect(self.SMScheckBox) self.minimize.clicked.connect(self.Minimize) def Minimize(self): import win32gui, win32con import os import math import time time.sleep(2) Minimize = win32gui.GetForegroundWindow() win32gui.ShowWindow(Minimize, win32con.SW_MINIMIZE) def SMScheckBox(self): global SMScheckBox if self.checkBox.isChecked()==True: print("hi checkbox") else: print("no") def myradioButton1_function(self): global RadioButtonAbove if self.radioButton.isChecked(): print ('Above is Checked') RadioButtonAbove=self.radioButton.isChecked() RadioButtonBellow=self.radioButton_2.isChecked() self.pushButton.setDisabled(False) def myradioButton2_function(self): global RadioButtonBellow if self.radioButton_2.isChecked(): print ('Bellow is Checked') RadioButtonBellow=self.radioButton_2.isChecked() RadioButtonAbove=self.radioButton.isChecked() self.pushButton.setDisabled(False) def printMessage(self): global UserSymbol global UserStockPrice global RadioButtonBellow global RadioButtonAbove global UserGmail global PassGmail UserSymbol=self.textEdit.toPlainText() UserSymbol=UserSymbol[0:4] UserStockPrice=self.textEdit_7.toPlainText() UserGmail=self.textEdit_5.toPlainText() PassGmail=self.textEdit_4.toPlainText() #here is the IF of the validation! if PassGmail==0 or UserGmail==0 or UserSymbol==0 or UserStockPrice==0 or (RadioButtonAbove==0 and RadioButtonBellow==0): def Mbox(title, text, style): return ctypes.windll.user32.MessageBoxW(0, text, title, style) Mbox('you need to enter all data first', 'you need to choose Stock value,price,bellow/above price', 1 ) else: UserStockPrice=float(UserStockPrice) UserSymbol=str(UserSymbol) t = threading.Thread(target=myfunction) t.start() def stopButton(self): global loopexit loopexit=1 def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate Dialog.setWindowTitle(_translate("Dialog", "Dialog")) self.radioButton.setText(_translate("Dialog", "Above Price (x>)")) self.checkBox.setText(_translate("Dialog", "SMS ALERT")) self.checkBox_2.setText(_translate("Dialog", "GMAIL ALERT")) self.radioButton_2.setText(_translate("Dialog", "Bellow Price (x<)")) self.pushButton.setText(_translate("Dialog", "START")) self.radioButton_3.setText(_translate("Dialog", "get alert once a day")) self.radioButton_4.setText(_translate("Dialog", "get alert every time")) self.pushButton_2.setText(_translate("Dialog", "EXIT")) self.textEdit_4.setHtml(_translate("Dialog", "\n" "\n" "


")) self.textEdit_5.setHtml(_translate("Dialog", "\n" "\n" "


")) self.label.setText(_translate("Dialog", "SYMBOL:")) self.label_2.setText(_translate("Dialog", "PRICE :")) self.label_3.setText(_translate("Dialog", "User of Gmail:")) self.label_4.setText(_translate("Dialog", "Password of Gmail:")) self.label_5.setText(_translate("Dialog", "ALON STOCK MARKET APP")) self.pushButton_3.setText(_translate("Dialog", "STOP")) self.textEdit.setHtml(_translate("Dialog", "\n" "\n" "


")) self.textEdit_7.setHtml(_translate("Dialog", "\n" "\n" "


")) self.minimize.setText(_translate("Dialog", "Minimize")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Dialog = QtWidgets.QDialog() ui = Ui_Dialog() ui.setupUi(Dialog) Dialog.show() sys.exit(app.exec_()) From synch1216 at gmail.com Wed Sep 19 12:12:06 2018 From: synch1216 at gmail.com (synch1216 at gmail.com) Date: Wed, 19 Sep 2018 09:12:06 -0700 (PDT) Subject: Type error: not enough arguments for format string Message-ID: I'm just trying to follow along with the logging tutorial documentation and I am getting this error: import logging logging.basicConfig(format= '%(asctime)s % (message)s', datefmt='%m%d%Y %I:%M:%S %p') logging.warning('is when this event was logged') Error: C:\Users\Malcy\PycharmProjects\Udemy\venv\Scripts\python.exe C:/Users/Malcy/PycharmProjects/logging/logger.py Traceback (most recent call last): File "C:\Users\Malcy\AppData\Local\Continuum\anaconda2\Lib\logging\__init__.py", line 861, in emit msg = self.format(record) File "C:\Users\Malcy\AppData\Local\Continuum\anaconda2\Lib\logging\__init__.py", line 734, in format return fmt.format(record) File "C:\Users\Malcy\AppData\Local\Continuum\anaconda2\Lib\logging\__init__.py", line 469, in format s = self._fmt % record.__dict__ TypeError: not enough arguments for format string Logged from file logger.py, line 6 From saikiran29121 at gmail.com Wed Sep 19 12:19:52 2018 From: saikiran29121 at gmail.com (Singamaneni Saikiran) Date: Wed, 19 Sep 2018 21:49:52 +0530 Subject: About how to connect python 3.7 with geany Message-ID: It was showing some error please help me with a reply to solve this. saikiran From David.Raymond at tomtom.com Wed Sep 19 12:21:19 2018 From: David.Raymond at tomtom.com (David Raymond) Date: Wed, 19 Sep 2018 16:21:19 +0000 Subject: [SPAM] Type error: not enough arguments for format string In-Reply-To: References: Message-ID: My first bet at the culprit is the space between the % and (message)s, they should be together like you have them for asctime. -----Original Message----- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of synch1216 at gmail.com Sent: Wednesday, September 19, 2018 12:12 PM To: python-list at python.org Subject: [SPAM] Type error: not enough arguments for format string Importance: Low I'm just trying to follow along with the logging tutorial documentation and I am getting this error: import logging logging.basicConfig(format= '%(asctime)s % (message)s', datefmt='%m%d%Y %I:%M:%S %p') logging.warning('is when this event was logged') Error: C:\Users\Malcy\PycharmProjects\Udemy\venv\Scripts\python.exe C:/Users/Malcy/PycharmProjects/logging/logger.py Traceback (most recent call last): File "C:\Users\Malcy\AppData\Local\Continuum\anaconda2\Lib\logging\__init__.py", line 861, in emit msg = self.format(record) File "C:\Users\Malcy\AppData\Local\Continuum\anaconda2\Lib\logging\__init__.py", line 734, in format return fmt.format(record) File "C:\Users\Malcy\AppData\Local\Continuum\anaconda2\Lib\logging\__init__.py", line 469, in format s = self._fmt % record.__dict__ TypeError: not enough arguments for format string Logged from file logger.py, line 6 -- https://mail.python.org/mailman/listinfo/python-list From python at mrabarnett.plus.com Wed Sep 19 13:30:10 2018 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 19 Sep 2018 18:30:10 +0100 Subject: python3.7 problem with validation - it doesnt work In-Reply-To: References: Message-ID: On 2018-09-19 13:12, alon.najman at gmail.com wrote: > python3.7 problem with validation - it doesn't work. > In what way doesn't it work? Does your computer explode? [snip] > > def printMessage(self): > global UserSymbol > global UserStockPrice > global RadioButtonBellow > global RadioButtonAbove > global UserGmail > global PassGmail > UserSymbol=self.textEdit.toPlainText() > UserSymbol=UserSymbol[0:4] > UserStockPrice=self.textEdit_7.toPlainText() Here you set UserGmail and PassGmail to the contents of some text edits: > UserGmail=self.textEdit_5.toPlainText() > PassGmail=self.textEdit_4.toPlainText() > Judging by the names, I'd guess that they are strings. > > #here is the IF of the validation! Here your check whether they are 0, which is a number: > if PassGmail==0 or UserGmail==0 or UserSymbol==0 or UserStockPrice==0 or (RadioButtonAbove==0 and RadioButtonBellow==0): Strings aren't numbers, and numbers aren't strings. "0" != 0. > def Mbox(title, text, style): > return ctypes.windll.user32.MessageBoxW(0, text, title, style) Here you've indented the line more than the def Mbox, so this line is inside the function: > Mbox('you need to enter all data first', 'you need to choose Stock value,price,bellow/above price', 1 ) > You're not calling it. [snip] From grant.b.edwards at gmail.com Wed Sep 19 17:02:50 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 19 Sep 2018 21:02:50 +0000 (UTC) Subject: About how to connect python 3.7 with geany References: Message-ID: On 2018-09-19, Singamaneni Saikiran wrote: > It was showing some error please help me with a reply to solve this. You need to make changes to it. HTH... -- Grant Edwards grant.b.edwards Yow! I'm ANN LANDERS!! at I can SHOPLIFT!! gmail.com From cs at cskk.id.au Wed Sep 19 18:44:04 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Thu, 20 Sep 2018 08:44:04 +1000 Subject: Type error: not enough arguments for format string In-Reply-To: References: Message-ID: <20180919224404.GA87149@cskk.homeip.net> On 19Sep2018 09:12, synch1216 at gmail.com wrote: >I'm just trying to follow along with the logging tutorial documentation and I am getting this error: > >import logging > >logging.basicConfig(format= '%(asctime)s % (message)s', datefmt='%m%d%Y %I:%M:%S %p') Probably this: --------------------------^^ The space after the "%" in "% (message)s" is preventing correct recognision of the format. Cheers, Cameron Simpson From as at sci.fi Thu Sep 20 04:25:08 2018 From: as at sci.fi (Anssi Saari) Date: Thu, 20 Sep 2018 11:25:08 +0300 Subject: Type error: not enough arguments for format string References: <20180919224404.GA87149@cskk.homeip.net> Message-ID: Cameron Simpson writes: > On 19Sep2018 09:12, synch1216 at gmail.com wrote: >>I'm just trying to follow along with the logging tutorial documentation and I am getting this error: >> >>import logging >> >>logging.basicConfig(format= '%(asctime)s % (message)s', datefmt='%m%d%Y %I:%M:%S %p') > > Probably this: --------------------------^^ > > The space after the "%" in "% (message)s" is preventing correct > recognision of the format. Yes. It makes sense to copy-paste examples instead of typing them in. I guess the original is from https://docs.python.org/2/howto/logging.html#changing-the-format-of-displayed-messages and it doesn't have the extra space which is a problem here. From zwollo at gmail.com Thu Sep 20 15:44:10 2018 From: zwollo at gmail.com (zwollo at gmail.com) Date: Thu, 20 Sep 2018 12:44:10 -0700 (PDT) Subject: Python opportunity at the United Nations in Rome, Italy Message-ID: <0b61d5a4-0004-49af-9a94-05b4e8c28acf@googlegroups.com> Great opportunity to join an amazing organization! Do you love building IT Solutions in Python? Do you have Scrum experience? Want to live in Rome, Italy? Apply now, and become part of the United Nations World Food Programme. Apply via https://career5.successfactors.eu/career?career_ns=job_listing&company=C0000168410P&navBarLevel=JOB_SEARCH&rcm_site_locale=en_GB&career_job_req_id=88225 #unitednations #python #scrum #job #careeropportunities From jladasky at itu.edu Thu Sep 20 18:33:59 2018 From: jladasky at itu.edu (jladasky at itu.edu) Date: Thu, 20 Sep 2018 15:33:59 -0700 (PDT) Subject: About how to connect python 3.7 with geany In-Reply-To: References: Message-ID: <2cac2367-f5ca-440e-8874-2dd512c5cf8b@googlegroups.com> On Wednesday, September 19, 2018 at 2:00:13 PM UTC-7, Singamaneni Saikiran wrote: > It was showing some error please help me with a reply to solve this. > > saikiran What code did you try? What error did you receive? And finally, what operating system are you using? From ramaramsy at gmail.com Fri Sep 21 00:41:06 2018 From: ramaramsy at gmail.com (ramaramsy at gmail.com) Date: Thu, 20 Sep 2018 21:41:06 -0700 (PDT) Subject: cAN i BECOME A BILLIOANIRE IN PROGRAMMING PYTHON Message-ID: <8a6e6229-0cb2-48f6-93e9-7d5782e4a0e1@googlegroups.com> HEY THERE CAN SOMEONE ANSWER ME From ethan at stoneleaf.us Fri Sep 21 03:08:37 2018 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 21 Sep 2018 00:08:37 -0700 Subject: cAN i BECOME A BILLIOANIRE IN PROGRAMMING PYTHON In-Reply-To: <8a6e6229-0cb2-48f6-93e9-7d5782e4a0e1@googlegroups.com> References: <8a6e6229-0cb2-48f6-93e9-7d5782e4a0e1@googlegroups.com> Message-ID: <5BA498F5.8080408@stoneleaf.us> This thread is closed. -- ~Ethan~ Python List Moderator From spencer.graves at effectivedefense.org Fri Sep 21 09:22:35 2018 From: spencer.graves at effectivedefense.org (Spencer Graves) Date: Fri, 21 Sep 2018 08:22:35 -0500 Subject: Multiple problems with Python 3.7 under Windows 7 Home Premium Message-ID: <91e554a3-4541-0e13-d4ac-5557d629c316@effectivedefense.org> Hello: ????? I'm having a series of problems getting Python 3.7 to work on a machine running Windows 7 Home Premium with SP1. WEBINSTALL.EXE: ????? "python-3.7.0-amd64-webinstall.exe" stopped seemingly before it started.? I can try it again and give you a more precise error message if you want, but I want to describe some of the other problems I've had first. ????? "python-3.7.0-amd64.exe" acted like it installed properly, until I started using it.? IDLE seemed to work for me on some simple tasks, but I wanted to try PyAudio, and I've so far not been able to make that work. PYTHON - M PIP INSTALL PYAUDIO ????? "python -m pip install pyaudio" stopped with 'error: Microsoft visual C++14.0 is required.? Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools". ????? That web address "http://landinghub..." gave "404 NOT FOUND". However, I found elsewhere Microsoft Visual C++ Build Tools" and seemed to get them installed. ????? Then "python -m pip install pyaudio" stopped with "error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\c1.exe' failed with exit status 2". GCCWINBINARIES ????? Searching for "... exit status 2" led me to a suggestion to use "https://github.com/develersrl/gccwinbinaries".? That failed with "No Python installation found in the registried.? It won't be possible to install the bindings." WINDOWS APP CERTIFICATION KIT ????? Somehow, I got a notice to try "Windows App Certification Kit 10.0.17134.12".? I tried that with "program installer: python-3.7.0-amd64.exe" and "command:? python".? This moved along, then generated a popup saying "Modify setup", then stopped.? After waiting about 12 minutes, I clicked the "x" in the upper right. Then it moved again for a time until what looked like the same popup appeared during "Installed programs / In progress ...".? After clicking "x" in the upper right, I got, "Testing cannot continue unless an application is successfully installed, including a discoverable shortcut and an entry in add / remove programs." ????? I repeated "Windows App Certification Kit", except that this time when the "Modify setup" window appeared, I clicked "repair". It came to that same point and gave the same error. ????? Suggestion? ????? Thanks, ????? Spencer From jcasale at activenetwerx.com Fri Sep 21 12:30:19 2018 From: jcasale at activenetwerx.com (Joseph L. Casale) Date: Fri, 21 Sep 2018 16:30:19 +0000 Subject: Serializing complex objects Message-ID: I need to serialize a deep graph only for the purposes of visualizing it to observe primitive data types on properties throughout the hierarchy. In my scenario, I cannot attach a debugger to the process which would be most useful. Using json is not the easiest as I need to chase endless custom serialization handlers. Does anyone know of something useful in this case? Thanks, jlc From info at wingware.com Fri Sep 21 13:31:49 2018 From: info at wingware.com (Wingware) Date: Fri, 21 Sep 2018 13:31:49 -0400 Subject: ANN: Wing Python IDE 6.1.1 released Message-ID: <5BA52B05.8010209@wingware.com> Hi, We've just released Wing 6.1.1 , which improves PEP 8 reformatting, streamlines remote agent installation, improves robustness of remote development in the face of network failures, adds support for debugging PythonQt, optimizes multi-process debugging, and makes a number of other minor improvements.For details, see https://wingware.com/pub/wingide/6.1.1/CHANGELOG.txt Download Now About Wing Wing is a family of cross-platform Python IDEs 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, embedded scripting, and other applications. Wing 101 and Wing Personal omit some features and are free to download and use without a license. Wing Pro requires purchasing or upgrading a license, or obtaining a 30-day trial at startup. 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, Vagrant , Jupyter , Django 1.10+ and 2.0, and Windows Subsystem for Linux, improved mainloop 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. 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/2018-09-19 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 rhodri at kynesim.co.uk Fri Sep 21 13:39:06 2018 From: rhodri at kynesim.co.uk (Rhodri James) Date: Fri, 21 Sep 2018 18:39:06 +0100 Subject: Serializing complex objects In-Reply-To: References: Message-ID: On 21/09/18 17:30, Joseph L. Casale wrote: > I need to serialize a deep graph only for the purposes of visualizing it to > observe primitive data types on properties throughout the hierarchy. > In my scenario, I cannot attach a debugger to the process which would > be most useful. Using json is not the easiest as I need to chase endless > custom serialization handlers. > > Does anyone know of something useful in this case? Depending on what exactly your situation is, you may be able to use the pickle module (in the standard library) to dump your graph and reload it in a context you can get a debugger into. Would that be sufficient? -- Rhodri James *-* Kynesim Ltd From jcasale at activenetwerx.com Fri Sep 21 14:44:39 2018 From: jcasale at activenetwerx.com (Joseph L. Casale) Date: Fri, 21 Sep 2018 18:44:39 +0000 Subject: Serializing complex objects In-Reply-To: References: Message-ID: <0903171c6bc54f60bdab768427a45947@activenetwerx.com> -----Original Message----- From: Python-list On Behalf Of Rhodri James Sent: Friday, September 21, 2018 11:39 AM To: python-list at python.org Subject: Re: Serializing complex objects > Depending on what exactly your situation is, you may be able to use the > pickle module (in the standard library) to dump your graph and reload it > in a context you can get a debugger into. Would that be sufficient? Pickle cant serialize it (ctype pointers) and dill serializes it, but re-animating it fails without much useful guidance as to why, "EOFError: Ran out of input". From vhnguyenn at yahoo.com Fri Sep 21 17:29:41 2018 From: vhnguyenn at yahoo.com (Viet Nguyen) Date: Fri, 21 Sep 2018 14:29:41 -0700 (PDT) Subject: What is not working with my "map" usage? Message-ID: Hi, I want to add up all of the list elements. But when I use the "map" function, it didn't seem to work as I expect. Could someone point out how "map" can be applied here then? def add_all_elements (*args): total = 0 for i in args: print(type(i)) print("i = %s" % i) print("BEFORE total = %s" % total) total += int(i) print("AFTER total = %s\n" % total) print("FINAL total = %s\n" % total) return total alist = ['2', '09', '49'] ## this one works Okay add_all_elements(*alist) i = 2 BEFORE total = 0 AFTER total = 2 i = 09 BEFORE total = 2 AFTER total = 11 i = 49 BEFORE total = 11 AFTER total = 60 FINAL total = 60 ======== ## Why is this NOT Okay when I use map ?? What must I change ? >>> list(map(add_all_elements,alist)) i = 2 BEFORE total = 0 AFTER total = 2 FINAL total = 2 i = 09 BEFORE total = 0 AFTER total = 9 FINAL total = 9 i = 49 BEFORE total = 0 AFTER total = 49 FINAL total = 49 [2, 9, 49] Thanks, Viet From tjol at tjol.eu Fri Sep 21 17:32:30 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 21 Sep 2018 23:32:30 +0200 Subject: Serializing complex objects In-Reply-To: <0903171c6bc54f60bdab768427a45947@activenetwerx.com> References: <0903171c6bc54f60bdab768427a45947@activenetwerx.com> Message-ID: <316fde02-f070-afd6-87c1-aaa25001b7c6@tjol.eu> On 21/09/2018 20:44, Joseph L. Casale wrote: > -----Original Message----- > From: Python-list bounces+jcasale=activenetwerx.com at python.org> On Behalf Of Rhodri > James > Sent: Friday, September 21, 2018 11:39 AM > To: python-list at python.org > Subject: Re: Serializing complex objects > >> Depending on what exactly your situation is, you may be able to use the >> pickle module (in the standard library) to dump your graph and reload it >> in a context you can get a debugger into. Would that be sufficient? > > Pickle cant serialize it (ctype pointers) and dill serializes it, but re-animating > it fails without much useful guidance as to why, "EOFError: Ran out of input". > So parts of your structure have custom serialization handlers, and other parts are not serializable at all? Interesting. In any case you should be able to work around this with a custom Pickler. From alon.najman at gmail.com Fri Sep 21 17:54:44 2018 From: alon.najman at gmail.com (alon.najman at gmail.com) Date: Fri, 21 Sep 2018 14:54:44 -0700 (PDT) Subject: python3.7 error PYQT5 - NameError: name 'self' is not defined Message-ID: <813ac975-3bd1-4650-a4c1-4240d15f5c28@googlegroups.com> Hi when I disconnect the internet I get an error NameError: name 'self' is not defined. I really dont get it.. thanks all. Is that a bug? or my fault? Exception in thread Thread-1: Traceback (most recent call last): File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py", line 93, in secret print(ping('google.com')) File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py", line 72, in ping conn.connect((addr, 80)) socket.gaierror: [Errno 11001] getaddrinfo failed During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\Alon\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917, in _bootstrap_inner self.run() File "C:\Users\Alon\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py", line 95, in secret self.pushButton.setDisabled(True) NameError: name 'self' is not defined this is my code: import sys import requests from lxml import html import requests import urllib.request, urllib.error, urllib.parse import _thread from PyQt5 import QtCore, QtGui, QtWidgets import time import threading import ctypes # An included library with Python install. global flag global loopexit global UserSymbol global RadioButtonBellow global UserSymbol global UserStockPrice global RadioButtonAbove global SMScheckBox global varUser global varPass varUser=0 varPass=0 UserSymbol=0 RadioButtonBellow=0 RadioButtonAbove=0 UserSymbol=0 UserStockPrice=0 loopexit=0 from urllib.request import urlopen import time import random import struct import select import socket def chk(data): x = sum(x << 8 if i % 2 else x for i, x in enumerate(data)) & 0xFFFFFFFF x = (x >> 16) + (x & 0xFFFF) x = (x >> 16) + (x & 0xFFFF) return struct.pack('> 16) + (x & 0xFFFF) x = (x >> 16) + (x & 0xFFFF) return struct.pack(')")) self.checkBox.setText(_translate("AlonStockMarketApp", "SMS ALERT")) self.checkBox_2.setText(_translate("AlonStockMarketApp", "GMAIL ALERT")) self.radioButton_2.setText(_translate("AlonStockMarketApp", "Bellow Price (x<)")) self.pushButton.setText(_translate("AlonStockMarketApp", "START")) self.radioButton_3.setText(_translate("AlonStockMarketApp", "Get alert once a day")) self.radioButton_4.setText(_translate("AlonStockMarketApp", "Get alert every time")) self.pushButton_2.setText(_translate("AlonStockMarketApp", "EXIT")) self.textEdit_4.setHtml(_translate("AlonStockMarketApp", "\n" "\n" "


")) self.textEdit_5.setHtml(_translate("AlonStockMarketApp", "\n" "\n" "


")) self.label.setText(_translate("AlonStockMarketApp", "SYMBOL of stock:")) self.label_2.setText(_translate("AlonStockMarketApp", "PRICE :")) self.label_3.setText(_translate("AlonStockMarketApp", "User of Gmail:")) self.label_4.setText(_translate("AlonStockMarketApp", "Password of Gmail:")) self.label_5.setText(_translate("AlonStockMarketApp", "ALON STOCK MARKET APP")) self.pushButton_3.setText(_translate("AlonStockMarketApp", "STOP")) self.textEdit.setHtml(_translate("AlonStockMarketApp", "\n" "\n" "


")) self.textEdit_7.setHtml(_translate("AlonStockMarketApp", "\n" "\n" "


")) self.minimize.setText(_translate("AlonStockMarketApp", "Minimize")) self.pushButton_4.setText(_translate("AlonStockMarketApp", "Sign In")) self.textEdit_2.setHtml(_translate("AlonStockMarketApp", "\n" "\n" "


")) self.label_8.setText(_translate("AlonStockMarketApp", "Phone number (for SMS):")) self.label_7.setText(_translate("AlonStockMarketApp", "Password:")) self.label_6.setText(_translate("AlonStockMarketApp", "User:")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) AlonStockMarketApp = QtWidgets.QDialog() ui = Ui_AlonStockMarketApp() ui.setupUi(AlonStockMarketApp) AlonStockMarketApp.show() sys.exit(app.exec_()) From tjol at tjol.eu Fri Sep 21 17:56:10 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 21 Sep 2018 23:56:10 +0200 Subject: Multiple problems with Python 3.7 under Windows 7 Home Premium In-Reply-To: <91e554a3-4541-0e13-d4ac-5557d629c316@effectivedefense.org> References: <91e554a3-4541-0e13-d4ac-5557d629c316@effectivedefense.org> Message-ID: On 21/09/2018 15:22, Spencer Graves wrote: > WEBINSTALL.EXE: > > [...] Whatever, you managed to install Python, and it works, so everybody's happy, right? > PYTHON - M PIP INSTALL PYAUDIO > > > ????? "python -m pip install pyaudio" stopped with 'error: Microsoft > visual C++14.0 is required.? Get it with "Microsoft Visual C++ Build > Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools". > > > ????? That web address "http://landinghub..." gave "404 NOT FOUND". > However, I found elsewhere Microsoft Visual C++ Build Tools" and seemed > to get them installed. Well done! > > ????? Then "python -m pip install pyaudio" stopped with "error: command > 'C:\\Program Files (x86)\\Microsoft Visual > Studio\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\c1.exe' > failed with exit status 2". Okay, I get the feeling that installing pyaudio from source on Windows is quite involved. The lines of output before that would likely tell you more about what actually went wrong, but my guess is that due to dependencies you actually can't install pyaudio from source using pip on Windows at all. (You should be able to install it from a downloaded copy of the source, though. If you really want to go that route, I found this: https://smaudet.wordpress.com/2014/01/26/building-pyaudio-on-windows-7-x64-using-the-free-msvc-toolchains/) There appear to be pyaudio binaries for Python 3.6 on PyPI. The simplest solution to your problem would be to stick with Python 3.6 for now (as much as I hate to say it) - then you shouldn't need to faff around with C++ compilers. > > > GCCWINBINARIES > Yeah, you won't need these. Google led you down the garden path. (actually, I don't think anybody really needs these any more, do they?) > > > WINDOWS APP CERTIFICATION KIT > > > ????? Somehow, I got a notice to try "Windows App Certification Kit > 10.0.17134.12". What? Why? What is this? I don't even. Cheers Thomas From brian.j.oney at googlemail.com Fri Sep 21 17:59:44 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Fri, 21 Sep 2018 23:59:44 +0200 Subject: What is not working with my "map" usage? In-Reply-To: References: Message-ID: <18B70B14-E093-4C9C-8268-157A396329AC@gmail.com> Hi Viet, map applies the function to each of the elements of the list you provide. It would be roughly equivalent to: [add_all_elements(x) for x in alist] It may help you to consider the term and function "map" from the view of linear algebra. Apparently it's a common term: https://en.wikipedia.org/wiki/Map_%28higher-order_function%29?wprov=sfla1 HTH On September 21, 2018 11:29:41 PM GMT+02:00, Viet Nguyen via Python-list wrote: >Hi, > >I want to add up all of the list elements. But when I use the "map" >function, it didn't seem to work as I expect. Could someone point out >how "map" can be applied here then? > >def add_all_elements (*args): > total = 0 > for i in args: > print(type(i)) > print("i = %s" % i) > print("BEFORE total = %s" % total) > total += int(i) > print("AFTER total = %s\n" % total) > print("FINAL total = %s\n" % total) > return total > > >alist = ['2', '09', '49'] > > >## this one works Okay > >add_all_elements(*alist) > >i = 2 >BEFORE total = 0 >AFTER total = 2 > > >i = 09 >BEFORE total = 2 >AFTER total = 11 > > >i = 49 >BEFORE total = 11 >AFTER total = 60 > >FINAL total = 60 > >======== >## Why is this NOT Okay when I use map ?? What must I change ? > >>>> list(map(add_all_elements,alist)) > >i = 2 >BEFORE total = 0 >AFTER total = 2 > >FINAL total = 2 > > >i = 09 >BEFORE total = 0 >AFTER total = 9 > >FINAL total = 9 > > >i = 49 >BEFORE total = 0 >AFTER total = 49 > >FINAL total = 49 > >[2, 9, 49] > > >Thanks, >Viet >-- >https://mail.python.org/mailman/listinfo/python-list From tjol at tjol.eu Fri Sep 21 18:05:24 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Sat, 22 Sep 2018 00:05:24 +0200 Subject: What is not working with my "map" usage? In-Reply-To: References: Message-ID: On 21/09/2018 23:29, Viet Nguyen via Python-list wrote: > Hi, > > I want to add up all of the list elements. But when I use the "map" function, it didn't seem to work as I expect. Could someone point out how "map" can be applied here then? > > def add_all_elements (*args): > total = 0 > for i in args: > print(type(i)) > print("i = %s" % i) > print("BEFORE total = %s" % total) > total += int(i) > print("AFTER total = %s\n" % total) > print("FINAL total = %s\n" % total) > return total > > > alist = ['2', '09', '49'] > > > ## this one works Okay > > add_all_elements(*alist) > [...] >>>> list(map(add_all_elements,alist)) Read the output in both cases and try to figure out what 'args' is. Or you could print out 'args' at the top of your function to lend you a hand. That should help you understand what the difference between the two cases is, and what map() is doing. Good luck! Thomas From christopherrmullins at gmail.com Fri Sep 21 18:34:44 2018 From: christopherrmullins at gmail.com (Christopher Mullins) Date: Fri, 21 Sep 2018 15:34:44 -0700 Subject: python3.7 error PYQT5 - NameError: name 'self' is not defined In-Reply-To: <813ac975-3bd1-4650-a4c1-4240d15f5c28@googlegroups.com> References: <813ac975-3bd1-4650-a4c1-4240d15f5c28@googlegroups.com> Message-ID: > > Hi when I disconnect the internet I get an error NameError: name 'self' is > not defined. I really dont get it.. thanks all. Is that a bug? or my fault? Exception in thread Thread-1: > Traceback (most recent call last): > File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py", > line 93, in secret > print(ping('google.com')) > File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py", > line 72, in ping > conn.connect((addr, 80)) > socket.gaierror: [Errno 11001] getaddrinfo failed > During handling of the above exception, another exception occurred: > Traceback (most recent call last): > File > "C:\Users\Alon\AppData\Local\Programs\Python\Python37-32\lib\threading.py", > line 917, in _bootstrap_inner > self.run() > File > "C:\Users\Alon\AppData\Local\Programs\Python\Python37-32\lib\threading.py", > line 865, in run > self._target(*self._args, **self._kwargs) > File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py", > line 95, in secret > self.pushButton.setDisabled(True) > NameError: name 'self' is not defined Looks like `self` is supposed to be referring to an instance of the class `Ui_AlonStockMarketApp` (which has the pushButton attribute) but you've defined the secret function outside of that class. Try defining that function inside your class. HTH, Chris From torriem at gmail.com Fri Sep 21 19:58:40 2018 From: torriem at gmail.com (Michael Torrie) Date: Fri, 21 Sep 2018 17:58:40 -0600 Subject: python3.7 problem with validation - it doesnt work In-Reply-To: References: Message-ID: <467d8bd7-3194-fb65-b304-ceb06db0a566@gmail.com> On 09/19/2018 06:12 AM, alon.najman at gmail.com wrote: > python3.7 problem with validation - it doesn't work. I don't know what "validation" means, but MRAB has told you why it wasn't working. My question to you is why do you need that inner function anyway? An inner function is normally used to define a closure, where you can capture some state and preserve it for future use. Your inner function does not do this, and is therefore redundant, not to mention error-prone! From torriem at gmail.com Fri Sep 21 20:02:02 2018 From: torriem at gmail.com (Michael Torrie) Date: Fri, 21 Sep 2018 18:02:02 -0600 Subject: Multiple problems with Python 3.7 under Windows 7 Home Premium In-Reply-To: <91e554a3-4541-0e13-d4ac-5557d629c316@effectivedefense.org> References: <91e554a3-4541-0e13-d4ac-5557d629c316@effectivedefense.org> Message-ID: <61cebf4f-bbaf-7e4f-fc7a-e7bb05e0882d@gmail.com> On 09/21/2018 07:22 AM, Spencer Graves wrote: > PYTHON - M PIP INSTALL PYAUDIO > > > ????? "python -m pip install pyaudio" stopped with 'error: Microsoft > visual C++14.0 is required.? Get it with "Microsoft Visual C++ Build > Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools". You're going to want to wait until binary wheels of pyaudio for Python 3.7 and Windows 64-bit land in the PyPI repository. Unless you're already a visual studio user and have the where with all to build it from source. Python 3.7 is a recent release, so I'm not surprised that some packages don't yet have binary wheels in the repository. From francis at esmonde-white.com Fri Sep 21 20:35:33 2018 From: francis at esmonde-white.com (Francis Esmonde-White) Date: Fri, 21 Sep 2018 20:35:33 -0400 Subject: 2 Bugs: in Python 3 tutorial, and in bugs.python.org tracker registration system In-Reply-To: References: Message-ID: Hello, I came to report one bug (in the Python 3 tutorial documentation), and ran into another (functional in bugs.python.org bug tracker registration system). I have included details for both bugs below. Thanks in advance for your assistance, I am loving Python and the documentation! Warm regards, Francis Esmonde-White ############################### *Bug 1:* In the Python 3 tutorial section 9.8 for iterators , the example code for the iterator class Reverse has the iterator self.index defined only in the __init__. This approach will only allow the iterator to run once. Would it be better to show an example with the index defined as both a private field (self._index) and with the index value being populated in the __index__() function so that the method can be run more than once? I think that the code example should look like the following: class Reverse: """Iterator for looping over a sequence backwards.""" def __init__(self, data): self.data = data def __iter__(self): # Define the setup for the iteration here, # so that the index is always right when the iteration starts. self._index = len(self.data) return self def __next__(self): if self._index == 0: raise StopIteration self._index = self._index - 1 return self.data[self._index] ############################### *Bug 2:* I received errors when trying to confirm my registration for the bug tracker at bugs.python.org. I submitted the registration form, and immediately received the autogenerated registration confirmation email with the following title: Complete your registration to Python tracker -- key 6w7gUOVw7AR13ZivbxaDIWedYuNlsiwc - send a reply to report at bugs.python.org and maintain the subject line as is (the reply's additional "Re:" is ok), - or visit the following URL: https://bugs.python.org/?@action=confrego&otk=6w7gUOVw7AR13ZivbxaDIWedYuNlsiwc When I visit the URL, I get an error message: Invalid URL scheme in homepage URL [image: image.png] When I try reply-emailing to the reply-email address, I get an immediate error response: Failed issue tracker submission [image: image.png] The message header is as follows: An unexpected error occurred during the processing of your message. The tracker administrator is being notified. Return-Path: X-Original-To: report at bugs.python.org Delivered-To: roundup+tracker at psf.upfronthosting.co.za Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) by psf.upfronthosting.co.za (Postfix) with ESMTPS id 20182575F8 for ; Fri, 21 Sep 2018 20:14:55 +0200 (CEST) Received: by mail-io1-f41.google.com with SMTP id q5-v6so13115080iop.3 for ; Fri, 21 Sep 2018 11:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=esmonde-white.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=j+2C/XsoJvmbt6nnvO0Fa4MikEbIW3k/zd/YnMGZvuA=; b=mZnvJcVfxgR8U2qwjRQ6tQ44enty8yowgK6MU7wvzbNpMQHP7yinlzLAfIwpK1AMzj G0dn+xISNwbsXjXG5ECxs+hCVwZ1NNTtDJ9z8lZ6mLuNt56NC9ZdXHV4zuMb+CUjAqQn P/G9Ml9JfRumX5RPu38WChj5isbzRPZBKg37E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=j+2C/XsoJvmbt6nnvO0Fa4MikEbIW3k/zd/YnMGZvuA=; b=mwJ5HUkpeSaaL1hMQVJcHEx49qxtoncoexsN9kiHHfFS0wLXp4YHQUrQjPj+7TL30f HiqcMzApIkK28s3xaY7K4nHMgxVBXYSvGH9IuITyipIMZRXutaLDLVFnmTuGojRhE098 4zxzYhg7wdb4RzN6ErdBWOIp/lLQpzQVEPjq1ttS8+1G5axx3Hc0IIPSOCm5JhSokMxJ 7XcOuxEc9dAw3JG35kKqSZL12+Wy4rawCbr4NA3EzMtliNfr6eTrTYaAGQXVvIhDQw21 AziPw3nk4b4jJTfHUfR//fFevS5Lee6RbEoZkR6WJiEfc0Cf3T7vAmmbUzIyKoq6oukL Xcag== X-Gm-Message-State: APzg51BW8XYEje6RQgooxkKeoCrzW+raQNVcOCW2YGGWJTf85Gpt1AU9 ZIh4KDClWBI0FbsJic0pBPs3W94iWGAacb03RAaCDrngLgI= X-Google-Smtp-Source: ANB0VdZolOd9qeDV+t3/g0FwyhoMl60y57O9uRsfrCdXb+okMXSiUD2SmmQjBol22Lm5Y3pRiKyoRuJGODwAQFgjZr0= X-Received: by 2002:a6b:90d4:: with SMTP id s203-v6mr37864717iod.249.1537553692241; Fri, 21 Sep 2018 11:14:52 -0700 (PDT) MIME-Version: 1.0 References: <20180921181200.0F02E578D9 at psf.upfronthosting.co.za> In-Reply-To: <20180921181200.0F02E578D9 at psf.upfronthosting.co.za> From: Francis Esmonde-White Date: Fri, 21 Sep 2018 14:14:14 -0400 Message-ID: Subject: Re: Complete your registration to Python tracker -- key Zgn4fuEPaJDpJ9ZV00ClUdj92h7nEkRp To: report at bugs.python.org Content-Type: multipart/alternative; boundary="000000000000a649eb0576659d88" From python at mrabarnett.plus.com Fri Sep 21 20:57:28 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 22 Sep 2018 01:57:28 +0100 Subject: Multiple problems with Python 3.7 under Windows 7 Home Premium In-Reply-To: <61cebf4f-bbaf-7e4f-fc7a-e7bb05e0882d@gmail.com> References: <91e554a3-4541-0e13-d4ac-5557d629c316@effectivedefense.org> <61cebf4f-bbaf-7e4f-fc7a-e7bb05e0882d@gmail.com> Message-ID: <9d9eaff8-18aa-08bc-ad48-19b6b4c7e65f@mrabarnett.plus.com> On 2018-09-22 01:02, Michael Torrie wrote: > On 09/21/2018 07:22 AM, Spencer Graves wrote: >> PYTHON - M PIP INSTALL PYAUDIO >> >> >> ????? "python -m pip install pyaudio" stopped with 'error: Microsoft >> visual C++14.0 is required.? Get it with "Microsoft Visual C++ Build >> Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools". > > You're going to want to wait until binary wheels of pyaudio for Python > 3.7 and Windows 64-bit land in the PyPI repository. Unless you're > already a visual studio user and have the where with all to build it > from source. Python 3.7 is a recent release, so I'm not surprised that > some packages don't yet have binary wheels in the repository. > Christoph Gohlke's site appears to have a binary release for Python 3.7: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio From tjreedy at udel.edu Sat Sep 22 00:33:01 2018 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 22 Sep 2018 00:33:01 -0400 Subject: Multiple problems with Python 3.7 under Windows 7 Home Premium In-Reply-To: <9d9eaff8-18aa-08bc-ad48-19b6b4c7e65f@mrabarnett.plus.com> References: <91e554a3-4541-0e13-d4ac-5557d629c316@effectivedefense.org> <61cebf4f-bbaf-7e4f-fc7a-e7bb05e0882d@gmail.com> <9d9eaff8-18aa-08bc-ad48-19b6b4c7e65f@mrabarnett.plus.com> Message-ID: On 9/21/2018 8:57 PM, MRAB wrote: > On 2018-09-22 01:02, Michael Torrie wrote: >> On 09/21/2018 07:22 AM, Spencer Graves wrote: >>> PYTHON - M PIP INSTALL PYAUDIO >>> >>> >>> ?????? "python -m pip install pyaudio" stopped with 'error: Microsoft >>> visual C++14.0 is required.? Get it with "Microsoft Visual C++ Build >>> Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools". >> >> You're going to want to wait until binary wheels of pyaudio for Python >> 3.7 and Windows 64-bit land in the PyPI repository.? Unless you're >> already a visual studio user and have the where with all to build it >> from source.? Python 3.7 is a recent release, so I'm not surprised that >> some packages don't yet have binary wheels in the repository. >> > Christoph Gohlke's site appears to have a binary release for Python 3.7: > > https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio As I remember, he was building binaries for the 300 packages on the site well before the 3.7.0 release. -- Terry Jan Reedy From __peter__ at web.de Sat Sep 22 03:19:26 2018 From: __peter__ at web.de (Peter Otten) Date: Sat, 22 Sep 2018 09:19:26 +0200 Subject: 2 Bugs: in Python 3 tutorial, and in bugs.python.org tracker registration system References: Message-ID: Francis Esmonde-White wrote: > Hello, > > I came to report one bug (in the Python 3 tutorial documentation), and ran > into another (functional in bugs.python.org bug tracker registration > system). I have included details for both bugs below. > > Thanks in advance for your assistance, I am loving Python and the > documentation! > > Warm regards, > Francis Esmonde-White > > ############################### > > *Bug 1:* > In the Python 3 tutorial section 9.8 for iterators > , the example > code for the iterator class Reverse has the iterator self.index defined > only in the __init__. This approach will only allow the iterator to run > once. Would it be better to show an example with the index defined as both > a private field (self._index) and with the index value being populated in > the __index__() function so that the method can be run more than once? > > I think that the code example should look like the following: > > class Reverse: > """Iterator for looping over a sequence backwards.""" > def __init__(self, data): > self.data = data > > def __iter__(self): > # Define the setup for the iteration here, > # so that the index is always right when the iteration starts. > self._index = len(self.data) > return self > > def __next__(self): > if self._index == 0: > raise StopIteration > self._index = self._index - 1 > return self.data[self._index] No, "iterators" are meant to be one-off, and their __iter__ method should just return self, while "iterables" give you a new iterater on each invocation of __iter__. You can easily build an iterable on top of the Reverse class in the tutorial (see ReverseIterable below). You could also turn Reverse into an iterable, but your implementation is something in between with confusing behaviour. Compare: class Reverse: """Iterator for looping over a sequence backwards.""" def __init__(self, data): self.data = data self.index = len(data) def __iter__(self): return self def __next__(self): if self.index == 0: raise StopIteration self.index = self.index - 1 return self.data[self.index] class ReverseFrancis: """Iterator for looping over a sequence backwards.""" def __init__(self, data): self.data = data def __iter__(self): # Define the setup for the iteration here, # so that the index is always right when the iteration starts. self._index = len(self.data) return self def __next__(self): if self._index == 0: raise StopIteration self._index = self._index - 1 return self.data[self._index] class ReverseIterable: def __init__(self, data): self.data = data def __iter__(self): return Reverse(self.data) data = range(5) for class_ in Reverse, ReverseIterable, ReverseFrancis: print(class_.__name__) it = class_(data) for pair in zip(it, it): iter(it) print(*pair) $ python3 tmp.py | head Reverse 4 3 2 1 ReverseIterable 4 4 3 3 2 2 1 1 0 0 ReverseFrancis 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 Traceback (most recent call last): File "tmp.py", line 45, in print(*pair) BrokenPipeError: [Errno 32] Broken pipe $ From brian.j.oney at googlemail.com Sat Sep 22 06:08:43 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Sat, 22 Sep 2018 12:08:43 +0200 Subject: 2 Bugs: in Python 3 tutorial, and in bugs.python.org tracker registration system In-Reply-To: References: Message-ID: <875441C0-243F-4EA9-AC4D-F10CC5F1A431@gmail.com> That's one thing that confused me. Generators are supposed to be one-off iterators. Iterators, *I understood* as reusable iterables. From cs at cskk.id.au Sat Sep 22 06:19:36 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 22 Sep 2018 20:19:36 +1000 Subject: 2 Bugs: in Python 3 tutorial, and in bugs.python.org tracker registration system In-Reply-To: <875441C0-243F-4EA9-AC4D-F10CC5F1A431@gmail.com> References: <875441C0-243F-4EA9-AC4D-F10CC5F1A431@gmail.com> Message-ID: <20180922101936.GA45582@cskk.homeip.net> On 22Sep2018 12:08, Brian Oney wrote: >That's one thing that confused me. Generators are supposed to be one-off iterators. Iterators, *I understood* as reusable iterables. You've misread the grammar (the semantics). Iterators are one off - they're something that counts (for want of a better word which isn't "iterates") though something. An _iterable_ is something which can be iterated over, and therefore is something from which an iterator can be made to do that. So an iterator is what does the iterating, a single pass over whatever it is. An iterable is something you can iterate over, using an iterator. Cheers, Cameron Simpson From vhnguyenn at yahoo.com Sat Sep 22 08:38:34 2018 From: vhnguyenn at yahoo.com (Victor) Date: Sat, 22 Sep 2018 05:38:34 -0700 (PDT) Subject: What is not working with my "map" usage? In-Reply-To: References: Message-ID: <2040f461-061a-4a80-9254-53a3d7229754@googlegroups.com> Let me use a different input args and display them below. Basically, I am hoping to add up all elements of each nested list. So at first it should start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take the 1st element from each nested list to add up [1,2,3] = 6. How should it be corrected? Thx. >>> alist = [[1,11,111], [2,22,222], [3,33,333]] >>> list(map(add_all_elements,*alist)) My args = (1, 2, 3) i = 1 BEFORE total = 0 AFTER total = 1 i = 2 BEFORE total = 1 AFTER total = 3 i = 3 BEFORE total = 3 AFTER total = 6 FINAL total = 6 My args = (11, 22, 33) i = 11 BEFORE total = 0 AFTER total = 11 i = 22 BEFORE total = 11 AFTER total = 33 i = 33 BEFORE total = 33 AFTER total = 66 FINAL total = 66 My args = (111, 222, 333) i = 111 BEFORE total = 0 AFTER total = 111 i = 222 BEFORE total = 111 AFTER total = 333 i = 333 BEFORE total = 333 AFTER total = 666 FINAL total = 666 [6, 66, 666] From __peter__ at web.de Sat Sep 22 09:22:04 2018 From: __peter__ at web.de (Peter Otten) Date: Sat, 22 Sep 2018 15:22:04 +0200 Subject: What is not working with my "map" usage? References: <2040f461-061a-4a80-9254-53a3d7229754@googlegroups.com> Message-ID: Victor via Python-list wrote: > Let me use a different input args and display them below. Basically, I am > hoping to add up all elements of each nested list. So at first it should > start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take > the 1st element from each nested list to add up [1,2,3] = 6. How should > it be corrected? Thx. I see three options. You can (1) use a list comprehension [add_all_elements(*sub) for sub in alist] (2) replace map() with itertools.starmap() list(itertools.starmap(add_all_elements, alist)) (3) change your function's signature from add_all_elements(*args) to add_all_elements(args), either by modifying it directly or by wrapping it into another function list(map(lambda args: add_all_elements(*args), alist)) (3a) My personal preference would be to change the signature and then use the list comprehension def add_all_elements(args): ... [add_all_elements(sub) for sub in alist] From __peter__ at web.de Sat Sep 22 09:34:47 2018 From: __peter__ at web.de (Peter Otten) Date: Sat, 22 Sep 2018 15:34:47 +0200 Subject: 2 Bugs: in Python 3 tutorial, and in bugs.python.org tracker registration system References: <875441C0-243F-4EA9-AC4D-F10CC5F1A431@gmail.com> Message-ID: Brian Oney via Python-list wrote: > That's one thing that confused me. Generators are supposed to be one-off > iterators. Iterators, *I understood* as reusable iterables. The way I think about it, informally: iterables need and __iter__ method, iterators need a __next__ method. In practice all iterators are also iterables, and the convention is to have __iter__ return self, which makes them one-off. Generators are just iterators created in an elegant way, by a function containing yield-s. From buck.2019 at gmail.com Sat Sep 22 12:26:28 2018 From: buck.2019 at gmail.com (Buck Evan) Date: Sat, 22 Sep 2018 09:26:28 -0700 Subject: Explicit vararg values In-Reply-To: References: Message-ID: Received? On Sun, Sep 16, 2018 at 3:39 PM Buck Evan wrote: > I started to send this to python-ideas, but I'm having second thoughts. > Does tihs have merit? > > --- > I stumble on this a lot, and I see it in many python libraries: > > def f(*args, **kwargs): > ... > > f(*[list comprehension]) > f(**mydict) > > It always seems a shame to carefully build up an object in order to > explode it, just to pack it into a near-identical object. > > Today I was fiddling with the new python3.7 inspect.signature > functionality when I ran into this case: > > def f(**kwargs): pass > sig = inspect.signature(f) > print(sig.bind(a=1, b=2)) > > The output is "". I found this a > bit humorous since anyone attempting to bind values in this way, using > f(kwargs={'a': 1, 'b': 2}) will be sorely dissappointed. I also wondered > why BoundArguments didn't print '**kwargs' since that's the __str__ of that > parameter object. > > The syntax I'm proposing is: > f(**kwargs={'a': 1, 'b': 2}) > > as a synonym of f(a=1, b=2) when an appropriate dictionary is already on > hand. > > --- > I can argue for this another way as well. > > 1) > When both caller and callee have a known number of values to pass/receive, > that's the usual syntax: > def f(x) and f(1) > > 2) > When the caller has a fixed set of values, but the callee wants to handle > a variable number: def f(*args) and f(1) > > 3) > Caller has a variable number of arguments (varargs) but the call-ee is > fixed, that's the splat operator: def f(x) and f(*args) > > 4) > When case 1 and 3 cross paths, and we have a vararg in both the caller and > callee, right now we're forced to splat both sides: def f(*args) and > f(*args), but I'd like the option of opting-in to passing along my list > as-is with no splat or collection operations involved: def f(*args) and > f(*args=args) > > Currently the pattern to handle case 4 neatly is to define two versions of > a vararg function: > > def f(*arg, **kwargs): > return _f(args, kwargs) > > return _f(args, kwargs): > ... > > Such that when internal calllers hit case 4, there's a simple and > efficient way forward -- use the internal de-vararg'd definition of f. > External callers have no such option though, without breaking protected api > convention. > > My proposal would simplify this implementation as well as allowing users > to make use of a similar calling convention that was only provided > privately before. > > Examples: > > log(*args) and _log(args) in logging.Logger > format and vformat of strings.Formatter > From allan.sobrero at gmail.com Sat Sep 22 13:28:49 2018 From: allan.sobrero at gmail.com (Allan Sobrero) Date: Sat, 22 Sep 2018 14:28:49 -0300 Subject: Problema na DLL Message-ID: Ol?, estou tendo problemas para executar o Python, baixei a vers?o 64 bit pois nas configura??es de meu computador mostra 64x, por?m na hora de executar diz que n?o tenho o api-ms-win-crt-runtime-l1-1-0.dll From vhnguyenn at yahoo.com Sat Sep 22 14:18:50 2018 From: vhnguyenn at yahoo.com (Victor) Date: Sat, 22 Sep 2018 11:18:50 -0700 (PDT) Subject: What is not working with my "map" usage? In-Reply-To: References: <2040f461-061a-4a80-9254-53a3d7229754@googlegroups.com> Message-ID: <1ce9b636-aa1e-42bf-a8d2-aa0deed7511d@googlegroups.com> On Saturday, September 22, 2018 at 6:22:32 AM UTC-7, Peter Otten wrote: > Victor via Python-list wrote: > > > Let me use a different input args and display them below. Basically, I am > > hoping to add up all elements of each nested list. So at first it should > > start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take > > the 1st element from each nested list to add up [1,2,3] = 6. How should > > it be corrected? Thx. > > I see three options. You can > > (1) use a list comprehension > > [add_all_elements(*sub) for sub in alist] > > (2) replace map() with itertools.starmap() > > list(itertools.starmap(add_all_elements, alist)) > > (3) change your function's signature from add_all_elements(*args) to > add_all_elements(args), either by modifying it directly or by wrapping it > into another function > > list(map(lambda args: add_all_elements(*args), alist)) > > (3a) My personal preference would be to change the signature and then use > the list comprehension > > def add_all_elements(args): ... > [add_all_elements(sub) for sub in alist] Hi Peter, Thank you for your suggested solutions. They all work. But I just want to know what is wrong with my doing: list(map(add_all_elements,*alist)) Theoretically, each list element is passed to add_all_elements. And if my alist is [[1, 11, 111], [2, 22, 222], [3, 33, 333]], then the 1st list element must be this [1,11,111] passed as args into add_all_elements. In other words, the following should have happened: >>> add_all_elements (*[1,11,111]) My args = (1, 11, 111) i = 1 BEFORE total = 0 AFTER total = 1 i = 11 BEFORE total = 1 AFTER total = 12 i = 111 BEFORE total = 12 AFTER total = 123 FINAL total = 123 123 Again, thanks! From __peter__ at web.de Sat Sep 22 15:11:00 2018 From: __peter__ at web.de (Peter Otten) Date: Sat, 22 Sep 2018 21:11 +0200 Subject: What is not working with my "map" usage? References: <2040f461-061a-4a80-9254-53a3d7229754@googlegroups.com> <1ce9b636-aa1e-42bf-a8d2-aa0deed7511d@googlegroups.com> Message-ID: Victor via Python-list wrote: > On Saturday, September 22, 2018 at 6:22:32 AM UTC-7, Peter Otten wrote: >> Victor via Python-list wrote: >> >> > Let me use a different input args and display them below. Basically, I >> > am >> > hoping to add up all elements of each nested list. So at first it >> > should >> > start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to >> > take >> > the 1st element from each nested list to add up [1,2,3] = 6. How >> > should >> > it be corrected? Thx. >> >> I see three options. You can >> >> (1) use a list comprehension >> >> [add_all_elements(*sub) for sub in alist] >> >> (2) replace map() with itertools.starmap() >> >> list(itertools.starmap(add_all_elements, alist)) >> >> (3) change your function's signature from add_all_elements(*args) to >> add_all_elements(args), either by modifying it directly or by wrapping it >> into another function >> >> list(map(lambda args: add_all_elements(*args), alist)) >> >> (3a) My personal preference would be to change the signature and then use >> the list comprehension >> >> def add_all_elements(args): ... >> [add_all_elements(sub) for sub in alist] > > Hi Peter, > Thank you for your suggested solutions. They all work. But I just want > to know what is wrong with my doing: > > list(map(add_all_elements,*alist)) > > Theoretically, each list element is passed to add_all_elements. And if my > alist is [[1, 11, 111], [2, 22, 222], [3, 33, 333]], then the 1st list > element must be this [1,11,111] passed as args into add_all_elements. > > In other words, the following should have happened: > >>>> add_all_elements (*[1,11,111]) That's not what happens. Try it with a function that passes through its arguments unchanged: >>> items = [[1, 11, 111], [2, 22, 222], [3, 33, 333]] >>> list(map(lambda *args: args, *items)) [(1, 2, 3), (11, 22, 33), (111, 222, 333)] The star before items is evaluated directly rather than magically passed on to the call of add_all_elements. map(f, *items) is equivalent to map(f, items[0], items[1], items[2]) which calls f with f(items[0][0], items[1][0], items[2][0]) f(items[0][1], items[1][1], items[2][1]) f(items[0][2], items[1][2], items[2][2]) If you think of your list of lists as a matrix that matrix is effectively transposed (x and y axis are swapped). >>> list(map(lambda *args: sum(args), *items)) [6, 66, 666] In principle you could transpose the matrix twice >>> list(map(lambda *args: sum(args), *zip(*items))) [123, 246, 369] but that's not a very efficient approach. Another gotcha to be aware of is that map() (and zip()) stop when the shortest argument ends: >>> list(map(lambda *args: sum(args), [], *items)) [] >>> list(map(lambda *args: sum(args), [42], *items)) [48] >>> list(map(lambda *args: sum(args), [42, 42], *items)) [48, 108] >>> list(map(lambda *args: sum(args), [42, 42, 42, 42, 42], *items)) [48, 108, 708] From tjol at tjol.eu Sat Sep 22 15:12:16 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Sat, 22 Sep 2018 21:12:16 +0200 Subject: What is not working with my "map" usage? In-Reply-To: <1ce9b636-aa1e-42bf-a8d2-aa0deed7511d@googlegroups.com> References: <2040f461-061a-4a80-9254-53a3d7229754@googlegroups.com> <1ce9b636-aa1e-42bf-a8d2-aa0deed7511d@googlegroups.com> Message-ID: <539d5307-7e8c-5d4b-8336-65ea1718b275@tjol.eu> On 22/09/2018 20:18, Victor via Python-list wrote: > On Saturday, September 22, 2018 at 6:22:32 AM UTC-7, Peter Otten wrote: >> Victor via Python-list wrote: >> >>> Let me use a different input args and display them below. Basically, I am >>> hoping to add up all elements of each nested list. So at first it should >>> start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take >>> the 1st element from each nested list to add up [1,2,3] = 6. How should >>> it be corrected? Thx. >> >> I see three options. You can >> >> (1) use a list comprehension >> >> [add_all_elements(*sub) for sub in alist] >> >> (2) replace map() with itertools.starmap() >> >> list(itertools.starmap(add_all_elements, alist)) >> >> (3) change your function's signature from add_all_elements(*args) to >> add_all_elements(args), either by modifying it directly or by wrapping it >> into another function >> >> list(map(lambda args: add_all_elements(*args), alist)) >> >> (3a) My personal preference would be to change the signature and then use >> the list comprehension >> >> def add_all_elements(args): ... >> [add_all_elements(sub) for sub in alist] > > Hi Peter, > Thank you for your suggested solutions. They all work. But I just want to know what is wrong with my doing: > > list(map(add_all_elements,*alist)) > > Theoretically, each list element is passed to add_all_elements. And if my alist is [[1, 11, 111], [2, 22, 222], [3, 33, 333]], then the 1st list element must be this [1,11,111] passed as args into add_all_elements. Now, alist = [[1,11,111], [2,22,222], [3,33,333]] so `map(add_all_alements, *alist)` is equivalent to map(add_all_elements, [1,11,111], [2,22,222], [3,33,333]) According to the docs [1], map(function, iterable, ...) "applies function to every item of iterable, yielding the results. If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel." So map takes the first item(s) of the argument(s), and applies the function to them, followed by the second item(s), and so on. In other words: def map(function, *iterables): for args in zip(iterables): yield function(*args) [1] https://docs.python.org/3/library/functions.html#map Come to think of it, this suggests a rather silly alternative "solution": map(add_all_elements, *zip(*alist)) > > In other words, the following should have happened: > >>>> add_all_elements (*[1,11,111]) > My args = (1, 11, 111) > > i = 1 > BEFORE total = 0 > AFTER total = 1 > > i = 11 > BEFORE total = 1 > AFTER total = 12 > > i = 111 > BEFORE total = 12 > AFTER total = 123 > > FINAL total = 123 > > 123 > > Again, thanks! > From tjol at tjol.eu Sat Sep 22 15:23:30 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Sat, 22 Sep 2018 21:23:30 +0200 Subject: Problema na DLL In-Reply-To: References: Message-ID: On 22/09/2018 19:28, Allan Sobrero wrote: > Ol?, estou tendo problemas para executar o Python, baixei a vers?o 64 bit > pois nas configura??es de meu computador mostra 64x, por?m na hora de > executar diz que n?o tenho o api-ms-win-crt-runtime-l1-1-0.dll > https://support.microsoft.com/pt-pt/help/2999226/update-for-universal-c-runtime-in-windows The link above should solve your immediate problem. This is an English-language list. Resources and community mailing lists/forums in other languages can be found elsewhere. You may be interested in: https://python.org.br https://wiki.python.org/moin/PortugueseLanguage From vhnguyenn at yahoo.com Sat Sep 22 18:04:50 2018 From: vhnguyenn at yahoo.com (Victor) Date: Sat, 22 Sep 2018 15:04:50 -0700 (PDT) Subject: What is not working with my "map" usage? In-Reply-To: References: <2040f461-061a-4a80-9254-53a3d7229754@googlegroups.com> <1ce9b636-aa1e-42bf-a8d2-aa0deed7511d@googlegroups.com> <539d5307-7e8c-5d4b-8336-65ea1718b275@tjol.eu> Message-ID: <39610211-a5af-4c78-bd40-25e3b2b3094f@googlegroups.com> On Saturday, September 22, 2018 at 12:20:08 PM UTC-7, Thomas Jollans wrote: > On 22/09/2018 20:18, Victor via Python-list wrote: > > On Saturday, September 22, 2018 at 6:22:32 AM UTC-7, Peter Otten wrote: > >> Victor via Python-list wrote: > >> > >>> Let me use a different input args and display them below. Basically, I am > >>> hoping to add up all elements of each nested list. So at first it should > >>> start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take > >>> the 1st element from each nested list to add up [1,2,3] = 6. How should > >>> it be corrected? Thx. > >> > >> I see three options. You can > >> > >> (1) use a list comprehension > >> > >> [add_all_elements(*sub) for sub in alist] > >> > >> (2) replace map() with itertools.starmap() > >> > >> list(itertools.starmap(add_all_elements, alist)) > >> > >> (3) change your function's signature from add_all_elements(*args) to > >> add_all_elements(args), either by modifying it directly or by wrapping it > >> into another function > >> > >> list(map(lambda args: add_all_elements(*args), alist)) > >> > >> (3a) My personal preference would be to change the signature and then use > >> the list comprehension > >> > >> def add_all_elements(args): ... > >> [add_all_elements(sub) for sub in alist] > > > > Hi Peter, > > Thank you for your suggested solutions. They all work. But I just want to know what is wrong with my doing: > > > > list(map(add_all_elements,*alist)) > > > > Theoretically, each list element is passed to add_all_elements. And if my alist is [[1, 11, 111], [2, 22, 222], [3, 33, 333]], then the 1st list element must be this [1,11,111] passed as args into add_all_elements. > > Now, > > alist = [[1,11,111], [2,22,222], [3,33,333]] > > so `map(add_all_alements, *alist)` is equivalent to > > map(add_all_elements, > [1,11,111], > [2,22,222], > [3,33,333]) > > According to the docs [1], map(function, iterable, ...) > > "applies function to every item of iterable, yielding the results. If > additional iterable arguments are passed, function must take that many > arguments and is applied to the items from all iterables in parallel." > > So map takes the first item(s) of the argument(s), and applies the > function to them, followed by the second item(s), and so on. > > In other words: > > def map(function, *iterables): > for args in zip(iterables): > yield function(*args) > > > [1] https://docs.python.org/3/library/functions.html#map > > Come to think of it, this suggests a rather silly alternative "solution": > > map(add_all_elements, *zip(*alist)) > > > > > In other words, the following should have happened: > > > >>>> add_all_elements (*[1,11,111]) > > My args = (1, 11, 111) > > > > i = 1 > > BEFORE total = 0 > > AFTER total = 1 > > > > i = 11 > > BEFORE total = 1 > > AFTER total = 12 > > > > i = 111 > > BEFORE total = 12 > > AFTER total = 123 > > > > FINAL total = 123 > > > > 123 > > > > Again, thanks! > > Thanks all, I got it now! From dvl at psu.edu Sat Sep 22 20:24:48 2018 From: dvl at psu.edu (ROGER GRAYDON CHRISTMAN) Date: Sat, 22 Sep 2018 20:24:48 -0400 Subject: What is not working with my "map" usage? In-Reply-To: mailman.24.1537632002.7518.python-list@python.org References: Message-ID: <1537662287l.15204458l.0l@psu.edu> On Sat, Sep 22, 2018, Victor (vhnguyenn at yahoo.com) wrote Let me use a different input args and display them below. Basically, I am hoping to add up all elements of each nested list. So at first it should start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take the 1st element from each nested list to add up [1,2,3] = 6. How should it be corrected? Thx. > >> alist = [[1,11,111], [2,22,222], [3,33,333]] > >> list(map(add_all_elements,*alist) > > Try list(map(add_all_elements, alist)) instead. If you give a map a single list as a second argument, it will visit eachelement of that single list (which in this case are the sublists you want). But that * is replacing the single list with the list contents as separate arguments,so you are literally telling map to visit all three sublists in parallel,and it does exactly what you told it to. The * and ** prefixes really should be avoided as much as possible,unless you know exactly what you are getting out of them. Roger ChristmanPennsylvania State University From spencer.graves at prodsyse.com Sat Sep 22 23:48:50 2018 From: spencer.graves at prodsyse.com (Spencer Graves) Date: Sat, 22 Sep 2018 22:48:50 -0500 Subject: Multiple problems with Python 3.7 under Windows 7 Home Premium In-Reply-To: References: <91e554a3-4541-0e13-d4ac-5557d629c316@effectivedefense.org> <61cebf4f-bbaf-7e4f-fc7a-e7bb05e0882d@gmail.com> <9d9eaff8-18aa-08bc-ad48-19b6b4c7e65f@mrabarnett.plus.com> Message-ID: ????? Thanks very much to all who replied.? This problems was solved as follows:? First I downloaded "PyAudio?0.2.11?cp37?cp37m?win_amd64.whl" from "https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio" as suggested by MRAB and Terry Reedy.? Then I ran "python -m pip install PyAudio?0.2.11?cp37?cp37m?win_amd64.whl".? Then I ran the script at "https://stackoverflow.com/questions/35344649/reading-input-sound-signal-using-python#35390981". That produced "output.wav" containing 5 seconds of sound recorded from a radio connected to "audio in" on my Windows 7 machine. ????? Thanks again. ????? Spencer Graves On 2018-09-21 23:33, Terry Reedy wrote: > On 9/21/2018 8:57 PM, MRAB wrote: >> On 2018-09-22 01:02, Michael Torrie wrote: >>> On 09/21/2018 07:22 AM, Spencer Graves wrote: >>>> PYTHON - M PIP INSTALL PYAUDIO >>>> >>>> >>>> ?????? "python -m pip install pyaudio" stopped with 'error: >>>> Microsoft visual C++14.0 is required.? Get it with "Microsoft >>>> Visual C++ Build Tools": >>>> http://landinghub.visualstudio.com/visual-cpp-build-tools". >>> >>> You're going to want to wait until binary wheels of pyaudio for Python >>> 3.7 and Windows 64-bit land in the PyPI repository.? Unless you're >>> already a visual studio user and have the where with all to build it >>> from source.? Python 3.7 is a recent release, so I'm not surprised that >>> some packages don't yet have binary wheels in the repository. >>> >> Christoph Gohlke's site appears to have a binary release for Python 3.7: >> >> https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio > > As I remember, he was building binaries for the 300 packages on the > site well before the 3.7.0 release. > From torriem at gmail.com Sun Sep 23 00:16:13 2018 From: torriem at gmail.com (Michael Torrie) Date: Sat, 22 Sep 2018 22:16:13 -0600 Subject: Explicit vararg values In-Reply-To: References: Message-ID: On 09/16/2018 04:39 PM, Buck Evan wrote: > The syntax I'm proposing is: > f(**kwargs={'a': 1, 'b': 2}) > > as a synonym of f(a=1, b=2) when an appropriate dictionary is already on > hand. But if the kwargs dict already exists you can already unpack it: f(**kwargs) or f(**{'a': 1, 'b': 2}) So I guess I'm unsure of how your proposal differs from this existing syntax in use. From sjeik_appie at hotmail.com Sun Sep 23 10:45:02 2018 From: sjeik_appie at hotmail.com (Albert-Jan Roskam) Date: Sun, 23 Sep 2018 14:45:02 +0000 Subject: [OT] master/slave debate in Python Message-ID: *sigh*. I'm with Hettinger on this. https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ From tomusatov at gmail.com Sun Sep 23 14:59:24 2018 From: tomusatov at gmail.com (Musatov) Date: Sun, 23 Sep 2018 11:59:24 -0700 (PDT) Subject: P = (2^N) - Q Message-ID: <64d605f1-9fcd-41d9-85fc-953f2770bd09@googlegroups.com> If P is the set of primes, how do I write a program outputting the values of Q as an integer sequence with 1 integer of Q for each N? Let the first prime be P1 P1=2 so if N=0, Q=-1 as 2=(2^0) - (-1) Let the second prime be P2 P2=3 so if N=1, Q=-1 as 3=(2^1) - (-1) Let the third prime be P3 P3=5 so if N=2, Q=-1 as 5=(2^2) - (-1) Let the fourth prime be P4 P4=7 so N=3, Q=1 as 7=(2^3) - (1) etc. I want an integer sequence of Q beginning... -1,-1,-1,1... Does this make sense? From lutz.horn at posteo.de Sun Sep 23 15:15:24 2018 From: lutz.horn at posteo.de (Lutz Horn) Date: Sun, 23 Sep 2018 21:15:24 +0200 Subject: P = (2^N) - Q In-Reply-To: <64d605f1-9fcd-41d9-85fc-953f2770bd09@googlegroups.com> References: <64d605f1-9fcd-41d9-85fc-953f2770bd09@googlegroups.com> Message-ID: <2a371084-5c54-94ab-58e8-810ffd4b1767@posteo.de> Hi, > If P is the set of primes, how do I write a program ... 1. Do you plan to write this in Python? 2. What have you tried so far? 3. Does it work? Lutz From gheskett at shentel.net Sun Sep 23 15:42:56 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 23 Sep 2018 15:42:56 -0400 Subject: Need to find the centroid of a circular camera image Message-ID: <201809231542.56849.gheskett@shentel.net> Greetings from a very poor python programmer, begging hat in hand; I have an old lathe that has some bed wear, an linuxcnc has the facilities to correct that. But it takes me surveying the machine for errors as the carriage is moved up and down the bed. Obviously I have to know what the error is, before I can correct it. The best way is to mount a gunsighting laser in a 38 special caseing in a suitable adapter, and spin it in the lathes chuck, with a considerable neutral density filter in front of it, take a time exposure long enough to let the camera integrate the non-circular beam into a good circular pattern as the spindle turns at 500 to 1000 revs, then close the "shutter" save the image and locate the centroid of that saved image. Is there code to do that centroid math in somebodies "bottom desk drawer"? Something I could download and control with a bash script which I'm fair at? Thanks everybody. -- 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 python at mrabarnett.plus.com Sun Sep 23 15:45:19 2018 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 23 Sep 2018 20:45:19 +0100 Subject: P = (2^N) - Q In-Reply-To: <64d605f1-9fcd-41d9-85fc-953f2770bd09@googlegroups.com> References: <64d605f1-9fcd-41d9-85fc-953f2770bd09@googlegroups.com> Message-ID: On 2018-09-23 19:59, Musatov wrote: > If P is the set of primes, how do I write a program outputting the values of Q as an integer sequence with 1 integer of Q for each N? > > Let the first prime be P1 > > P1=2 > so if > N=0, Q=-1 > as > 2=(2^0) - (-1) > > Let the second prime be P2 > > P2=3 > so if > N=1, Q=-1 > as > 3=(2^1) - (-1) > > Let the third prime be P3 > > P3=5 > so if > N=2, Q=-1 > as > 5=(2^2) - (-1) > > Let the fourth prime be P4 > > P4=7 > so > N=3, Q=1 > as > 7=(2^3) - (1) > > etc. > > I want an integer sequence of Q beginning... > > -1,-1,-1,1... > > Does this make sense? > Re-arrange the equation to get Q = (2^N) - P. You should be able to work from that. From oscar.j.benjamin at gmail.com Sun Sep 23 16:24:23 2018 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Sun, 23 Sep 2018 21:24:23 +0100 Subject: Need to find the centroid of a circular camera image In-Reply-To: <201809231542.56849.gheskett@shentel.net> References: <201809231542.56849.gheskett@shentel.net> Message-ID: On Sun, 23 Sep 2018 at 20:45, Gene Heskett wrote: > > save the image and locate the centroid of that saved image. > > Is there code to do that centroid math in somebodies "bottom desk > drawer"? Something I could download and control with a bash script which > I'm fair at? This is easy enough to in OpenCV. The code at the top of this page does what you want: https://docs.opencv.org/3.4.2/dd/d49/tutorial_py_contour_features.html -- Oscar From tomusatov at gmail.com Sun Sep 23 16:52:36 2018 From: tomusatov at gmail.com (Musatov) Date: Sun, 23 Sep 2018 13:52:36 -0700 (PDT) Subject: P = (2^N) - Q In-Reply-To: References: <64d605f1-9fcd-41d9-85fc-953f2770bd09@googlegroups.com> Message-ID: <169e4609-34fa-4721-9054-f49fb004314a@googlegroups.com> Sometimes the simplest things... I am wondering about congruences/patterns in Q. From gheskett at shentel.net Sun Sep 23 21:29:43 2018 From: gheskett at shentel.net (Gene Heskett) Date: Sun, 23 Sep 2018 21:29:43 -0400 Subject: Need to find the centroid of a circular camera image In-Reply-To: References: <201809231542.56849.gheskett@shentel.net> Message-ID: <201809232129.43745.gheskett@shentel.net> On Sunday 23 September 2018 16:24:23 Oscar Benjamin wrote: > On Sun, 23 Sep 2018 at 20:45, Gene Heskett wrote: > > save the image and locate the centroid of that saved image. > > > > Is there code to do that centroid math in somebodies "bottom desk > > drawer"? Something I could download and control with a bash script > > which I'm fair at? > > This is easy enough to in OpenCV. The code at the top of this page > does what you want: > > https://docs.opencv.org/3.4.2/dd/d49/tutorial_py_contour_features.html > That looks like about what I'm looking for. Playing around this afternoon I find the laser isn't terribly well aligned, but neither is the chuck I've got it mounted in, so the beam path of the pattern 30" away ranges in the 10-12 mm diameter area. Way too big to just shine it straight onto the imaging chip. So I'll have to interpose a frosted surface, and focus the camera on that frosted surface in order to get that image path on the cameras imaging chip. Problems, but not insurmountable. Thank you very much, Oscar. -- 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 fetchinson at googlemail.com Mon Sep 24 04:48:37 2018 From: fetchinson at googlemail.com (Fetchinson .) Date: Mon, 24 Sep 2018 10:48:37 +0200 Subject: compiling 3.7.0 from source with custom libffi path Message-ID: I'm trying to compile python 3.7.0 from source with a custom libffi path and the compiler/linker doesn't seem to pick up the right version. The system libffi doesn't have the development files so I've installed the latest libffi (also from source) to /opt/custom but still I get INFO: Could not locate ffi libs and/or headers Failed to build these modules: _ctypes Although I compile python with --prefix=/opt/custom because that's the location I'd like to install it too. So how do I tell the build system where to find my custom libffi? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From tjol at tjol.eu Mon Sep 24 05:52:58 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 24 Sep 2018 11:52:58 +0200 Subject: compiling 3.7.0 from source with custom libffi path In-Reply-To: References: Message-ID: <22a379ae-9385-cfbc-643f-26a111bea333@tjol.eu> On 2018-09-24 10:48, Fetchinson . via Python-list wrote: > I'm trying to compile python 3.7.0 from source with a custom libffi > path and the compiler/linker doesn't seem to pick up the right > version. The system libffi doesn't have the development files so I've > installed the latest libffi (also from source) to /opt/custom but > still I get > > INFO: Could not locate ffi libs and/or headers Apparently the configure script uses pkg-config to locate libffi.[1] You should be able to get it to find your libffi by setting PKG_CONFIG_PATH appropriately (probably to "/opt/custom/lib/pkgconfig" ?) [1]: https://github.com/python/cpython/blob/v3.7.0/configure.ac#L2936 > > Failed to build these modules: > _ctypes > > Although I compile python with --prefix=/opt/custom because that's the > location I'd like to install it too. So how do I tell the build system > where to find my custom libffi? > > Cheers, > Daniel > > > From fetchinson at googlemail.com Mon Sep 24 08:14:26 2018 From: fetchinson at googlemail.com (Fetchinson .) Date: Mon, 24 Sep 2018 14:14:26 +0200 Subject: compiling 3.7.0 from source with custom libffi path In-Reply-To: <22a379ae-9385-cfbc-643f-26a111bea333@tjol.eu> References: <22a379ae-9385-cfbc-643f-26a111bea333@tjol.eu> Message-ID: >> I'm trying to compile python 3.7.0 from source with a custom libffi >> path and the compiler/linker doesn't seem to pick up the right >> version. The system libffi doesn't have the development files so I've >> installed the latest libffi (also from source) to /opt/custom but >> still I get >> >> INFO: Could not locate ffi libs and/or headers > > Apparently the configure script uses pkg-config to locate libffi.[1] You > should be able to get it to find your libffi by setting PKG_CONFIG_PATH > appropriately (probably to "/opt/custom/lib/pkgconfig" ?) > > [1]: https://github.com/python/cpython/blob/v3.7.0/configure.ac#L2936 Thanks, tried it, but still no luck, exact same error message. Cheers, Daniel >> >> Failed to build these modules: >> _ctypes >> >> Although I compile python with --prefix=/opt/custom because that's the >> location I'd like to install it too. So how do I tell the build system >> where to find my custom libffi? >> >> Cheers, >> Daniel >> >> >> > -- > https://mail.python.org/mailman/listinfo/python-list > -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From robin at reportlab.com Mon Sep 24 08:52:40 2018 From: robin at reportlab.com (Robin Becker) Date: Mon, 24 Sep 2018 13:52:40 +0100 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> On 23/09/2018 15:45, Albert-Jan Roskam wrote: > *sigh*. I'm with Hettinger on this. > > https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ > I am as well. Don't fix what is not broken. The semantics (in programming) might not be an exact match, but people have been using these sorts of terms for a long time without anyone objecting. This sort of language control is just thought control of the wrong sort. -- Robin Becker From tjol at tjol.eu Mon Sep 24 08:53:32 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 24 Sep 2018 14:53:32 +0200 Subject: compiling 3.7.0 from source with custom libffi path In-Reply-To: References: <22a379ae-9385-cfbc-643f-26a111bea333@tjol.eu> Message-ID: <38a15e71-b655-3500-94f4-65d00c174ca5@tjol.eu> On 2018-09-24 14:14, Fetchinson . via Python-list wrote: >>> I'm trying to compile python 3.7.0 from source with a custom libffi >>> path and the compiler/linker doesn't seem to pick up the right >>> version. The system libffi doesn't have the development files so I've >>> installed the latest libffi (also from source) to /opt/custom but >>> still I get >>> >>> INFO: Could not locate ffi libs and/or headers >> >> Apparently the configure script uses pkg-config to locate libffi.[1] You >> should be able to get it to find your libffi by setting PKG_CONFIG_PATH >> appropriately (probably to "/opt/custom/lib/pkgconfig" ?) >> >> [1]: https://github.com/python/cpython/blob/v3.7.0/configure.ac#L2936 > > Thanks, tried it, but still no luck, exact same error message. Is there a .pc file for libffi? Can you run pkg-config manually, to check if it works, and finds libffi in your environment? > > Cheers, > Daniel > > > >>> >>> Failed to build these modules: >>> _ctypes >>> >>> Although I compile python with --prefix=/opt/custom because that's the >>> location I'd like to install it too. So how do I tell the build system >>> where to find my custom libffi? >>> >>> Cheers, >>> Daniel >>> >>> >>> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > From mal at europython.eu Mon Sep 24 08:55:48 2018 From: mal at europython.eu (M.-A. Lemburg) Date: Mon, 24 Sep 2018 14:55:48 +0200 Subject: EuroPython 2019: Seeking venues Message-ID: <65111170-f6ab-7acc-ab7d-e21edd0859f4@europython.eu> Dear EuroPython'istas, We are in preparations of our venue RFP for the EuroPython 2019 edition and are asking for your help in finding the right locations for us to choose from. If you know of a larger venue - hotel or conference center - that can accommodate at least 1400 attendees, please send the venue details to board at europython.eu. We will then make sure to include them in our RFP once we send it out. The more venues we gather to reach out to, the better of a selection process we can guarantee, which in return, will ultimately result in a better conference experience for everybody involved. When sending us venue suggestions, please make sure to provide us with the following: name and URL of the venue, country and city, as well as the contact details of the sales person in charge of inquiries (full name, email and phone). We were planning to start the RFP process in the coming days, so please make sure you send us your recommendations as soon as possible. Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/178407491437/europython-2019-seeking-venues Tweet: https://twitter.com/europython/status/1044130171354316800 Thank you, -- EuroPython Society https://www.europython-society.org/ From leo at superlel.me Mon Sep 24 09:12:47 2018 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Mon, 24 Sep 2018 15:12:47 +0200 Subject: [OT] master/slave debate in Python In-Reply-To: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: <474ab617-82ae-ce3e-1997-b1885c19d2cd@superlel.me> On 24/09/2018 14:52, Robin Becker wrote: > On 23/09/2018 15:45, Albert-Jan Roskam wrote: >> *sigh*. I'm with Hettinger on this. >> >> https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ >> >> > I am as well. Don't fix what is not broken. The semantics (in > programming) might not be an exact match, but people have been using > these sorts of terms for a long time without anyone objecting. This sort > of language control is just thought control of the wrong sort. All receivable arguments have been told already, thanks to Terry, Steven, Raymond and others, who all managed to keep their capability to think rationally after the motive of this bug report. Hopefully we have competent core devs. From fetchinson at googlemail.com Mon Sep 24 10:30:41 2018 From: fetchinson at googlemail.com (Fetchinson .) Date: Mon, 24 Sep 2018 16:30:41 +0200 Subject: compiling 3.7.0 from source with custom libffi path In-Reply-To: <38a15e71-b655-3500-94f4-65d00c174ca5@tjol.eu> References: <22a379ae-9385-cfbc-643f-26a111bea333@tjol.eu> <38a15e71-b655-3500-94f4-65d00c174ca5@tjol.eu> Message-ID: On 9/24/18, Thomas Jollans wrote: > On 2018-09-24 14:14, Fetchinson . via Python-list wrote: >>>> I'm trying to compile python 3.7.0 from source with a custom libffi >>>> path and the compiler/linker doesn't seem to pick up the right >>>> version. The system libffi doesn't have the development files so I've >>>> installed the latest libffi (also from source) to /opt/custom but >>>> still I get >>>> >>>> INFO: Could not locate ffi libs and/or headers >>> >>> Apparently the configure script uses pkg-config to locate libffi.[1] You >>> should be able to get it to find your libffi by setting PKG_CONFIG_PATH >>> appropriately (probably to "/opt/custom/lib/pkgconfig" ?) >>> >>> [1]: https://github.com/python/cpython/blob/v3.7.0/configure.ac#L2936 >> >> Thanks, tried it, but still no luck, exact same error message. > > Is there a .pc file for libffi? Can you run pkg-config manually, to > check if it works, and finds libffi in your environment? Yes, there is a .pc for libffi and if I first export PKG_CONFIG_PATH=/opt/custom then pkg-config finds the necessary include path: [fetch at fetch]$ pkg-config libffi --cflags-only-I -I/opt/custom/lib/libffi-3.2.1/include And of course this path is correct: [fetch at fetch]$ ls /opt/custom/lib/libffi-3.2.1/include ffi.h ffitarget.h And also the configure script correctly creates the Makefile: [fetch at fetch]$ grep LIBFFI_INCLUDE Makefile LIBFFI_INCLUDEDIR= /opt/custom/lib/libffi-3.2.1/include So I'd say everything should work but it doesn't, I reran ./configure and also make of course. Cheers, Daniel >> >> Cheers, >> Daniel >> >> >> >>>> >>>> Failed to build these modules: >>>> _ctypes >>>> >>>> Although I compile python with --prefix=/opt/custom because that's the >>>> location I'd like to install it too. So how do I tell the build system >>>> where to find my custom libffi? >>>> >>>> Cheers, >>>> Daniel >>>> >>>> >>>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >>> >> >> > -- > https://mail.python.org/mailman/listinfo/python-list > -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From gheskett at shentel.net Mon Sep 24 10:52:32 2018 From: gheskett at shentel.net (Gene Heskett) Date: Mon, 24 Sep 2018 10:52:32 -0400 Subject: Need to find the centroid of a circular camera image In-Reply-To: References: <201809231542.56849.gheskett@shentel.net> Message-ID: <201809241052.32570.gheskett@shentel.net> On Sunday 23 September 2018 16:24:23 Oscar Benjamin wrote: > On Sun, 23 Sep 2018 at 20:45, Gene Heskett wrote: > > save the image and locate the centroid of that saved image. > > > > Is there code to do that centroid math in somebodies "bottom desk > > drawer"? Something I could download and control with a bash script > > which I'm fair at? > > This is easy enough to in OpenCV. The code at the top of this page > does what you want: > > https://docs.opencv.org/3.4.2/dd/d49/tutorial_py_contour_features.html I take it that this is python-2.7? code? Searching thru the python3 results in synaptic, on a stretch install on the rock64, python3 has not a p3 version of numpy or cv2. And I'd like to try and make it run on 3.5 since that seems to be the newest on stretch. That would tend to future-proof this past the final fixes and eventual demise of python-2. Is there hope for things like numpy and cv2 being ported to python 3? Or can numpy and cv2 be used against 3.5 as is? Thanks Oscar. -- 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 Mon Sep 24 10:55:23 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 25 Sep 2018 00:55:23 +1000 Subject: Need to find the centroid of a circular camera image In-Reply-To: <201809241052.32570.gheskett@shentel.net> References: <201809231542.56849.gheskett@shentel.net> <201809241052.32570.gheskett@shentel.net> Message-ID: On Tue, Sep 25, 2018 at 12:54 AM Gene Heskett wrote: > > On Sunday 23 September 2018 16:24:23 Oscar Benjamin wrote: > > > On Sun, 23 Sep 2018 at 20:45, Gene Heskett > wrote: > > > save the image and locate the centroid of that saved image. > > > > > > Is there code to do that centroid math in somebodies "bottom desk > > > drawer"? Something I could download and control with a bash script > > > which I'm fair at? > > > > This is easy enough to in OpenCV. The code at the top of this page > > does what you want: > > > > https://docs.opencv.org/3.4.2/dd/d49/tutorial_py_contour_features.html > > I take it that this is python-2.7? code? > > Searching thru the python3 results in synaptic, on a stretch install on > the rock64, python3 has not a p3 version of numpy or cv2. > > And I'd like to try and make it run on 3.5 since that seems to be the > newest on stretch. That would tend to future-proof this past the final > fixes and eventual demise of python-2. > > Is there hope for things like numpy and cv2 being ported to python 3? Or > can numpy and cv2 be used against 3.5 as is? Dunno about cv2, but numpy is certainly available for Python 3. ChrisA From tjol at tjol.eu Mon Sep 24 12:05:32 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 24 Sep 2018 18:05:32 +0200 Subject: compiling 3.7.0 from source with custom libffi path In-Reply-To: References: <22a379ae-9385-cfbc-643f-26a111bea333@tjol.eu> <38a15e71-b655-3500-94f4-65d00c174ca5@tjol.eu> Message-ID: <2c614ce1-8c52-6e7d-e861-c6347ec6d4be@tjol.eu> On 2018-09-24 16:30, Fetchinson . via Python-list wrote: > [fetch at fetch]$ grep LIBFFI_INCLUDE Makefile > LIBFFI_INCLUDEDIR= /opt/custom/lib/libffi-3.2.1/include > > So I'd say everything should work but it doesn't, I reran ./configure > and also make of course. I'm confused. ./configure succeeds? Then where's the error? From gheskett at shentel.net Mon Sep 24 12:06:19 2018 From: gheskett at shentel.net (Gene Heskett) Date: Mon, 24 Sep 2018 12:06:19 -0400 Subject: Need to find the centroid of a circular camera image In-Reply-To: References: <201809231542.56849.gheskett@shentel.net> <201809241052.32570.gheskett@shentel.net> Message-ID: <201809241206.19714.gheskett@shentel.net> On Monday 24 September 2018 10:55:23 Chris Angelico wrote: > On Tue, Sep 25, 2018 at 12:54 AM Gene Heskett wrote: > > On Sunday 23 September 2018 16:24:23 Oscar Benjamin wrote: > > > On Sun, 23 Sep 2018 at 20:45, Gene Heskett > > > > wrote: > > > > save the image and locate the centroid of that saved image. > > > > > > > > Is there code to do that centroid math in somebodies "bottom > > > > desk drawer"? Something I could download and control with a bash > > > > script which I'm fair at? > > > > > > This is easy enough to in OpenCV. The code at the top of this page > > > does what you want: > > > > > > https://docs.opencv.org/3.4.2/dd/d49/tutorial_py_contour_features. > > >html > > > > I take it that this is python-2.7? code? > > > > Searching thru the python3 results in synaptic, on a stretch install > > on the rock64, python3 has not a p3 version of numpy or cv2. > > > > And I'd like to try and make it run on 3.5 since that seems to be > > the newest on stretch. That would tend to future-proof this past the > > final fixes and eventual demise of python-2. > > > > Is there hope for things like numpy and cv2 being ported to python > > 3? Or can numpy and cv2 be used against 3.5 as is? > > Dunno about cv2, but numpy is certainly available for Python 3. What do they call it in debian stretch for arm64? > ChrisA Thanks ChrisA -- 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 tjol at tjol.eu Mon Sep 24 12:12:20 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 24 Sep 2018 18:12:20 +0200 Subject: Need to find the centroid of a circular camera image In-Reply-To: <201809241052.32570.gheskett@shentel.net> References: <201809231542.56849.gheskett@shentel.net> <201809241052.32570.gheskett@shentel.net> Message-ID: <3f5154f0-13ce-422f-665e-121c84cb3d24@tjol.eu> On 2018-09-24 16:52, Gene Heskett wrote: > On Sunday 23 September 2018 16:24:23 Oscar Benjamin wrote: > >> On Sun, 23 Sep 2018 at 20:45, Gene Heskett > wrote: >>> save the image and locate the centroid of that saved image. >>> >>> Is there code to do that centroid math in somebodies "bottom desk >>> drawer"? Something I could download and control with a bash script >>> which I'm fair at? >> >> This is easy enough to in OpenCV. The code at the top of this page >> does what you want: >> >> https://docs.opencv.org/3.4.2/dd/d49/tutorial_py_contour_features.html > > I take it that this is python-2.7? code? > > Searching thru the python3 results in synaptic, on a stretch install on > the rock64, python3 has not a p3 version of numpy or cv2. > > And I'd like to try and make it run on 3.5 since that seems to be the > newest on stretch. That would tend to future-proof this past the final > fixes and eventual demise of python-2. > > Is there hope for things like numpy and cv2 being ported to python 3? Or > can numpy and cv2 be used against 3.5 as is? Sure it can. Just use pip. There are even binary manylinux wheels! https://pypi.org/project/opencv-python/ There's a numpy in the stretch repos, https://packages.debian.org/stretch/python3-numpy - but indeed, the python3-opencv package doesn't arrive until buster. From dan at djph.net Mon Sep 24 12:30:10 2018 From: dan at djph.net (Dan Purgert) Date: Mon, 24 Sep 2018 16:30:10 -0000 (UTC) Subject: [OT] master/slave debate in Python References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: Robin Becker wrote: > [...] just thought control of the wrong sort.. Is there "thought control of the right sort"? -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From leo at superlel.me Mon Sep 24 12:38:00 2018 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Mon, 24 Sep 2018 18:38:00 +0200 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: <85f6e800-6e44-7e0e-3136-54cf8b1c45e3@superlel.me> On 24/09/2018 18:30, Dan Purgert wrote: > Robin Becker wrote: >> [...] just thought control of the wrong sort.. > > Is there "thought control of the right sort"? We may have to ask to Huxley From fetchinson at googlemail.com Mon Sep 24 14:41:31 2018 From: fetchinson at googlemail.com (Fetchinson .) Date: Mon, 24 Sep 2018 20:41:31 +0200 Subject: compiling 3.7.0 from source with custom libffi path In-Reply-To: <2c614ce1-8c52-6e7d-e861-c6347ec6d4be@tjol.eu> References: <22a379ae-9385-cfbc-643f-26a111bea333@tjol.eu> <38a15e71-b655-3500-94f4-65d00c174ca5@tjol.eu> <2c614ce1-8c52-6e7d-e861-c6347ec6d4be@tjol.eu> Message-ID: On 9/24/18, Thomas Jollans wrote: > On 2018-09-24 16:30, Fetchinson . via Python-list wrote: >> [fetch at fetch]$ grep LIBFFI_INCLUDE Makefile >> LIBFFI_INCLUDEDIR= /opt/custom/lib/libffi-3.2.1/include >> >> So I'd say everything should work but it doesn't, I reran ./configure >> and also make of course. > > I'm confused. ./configure succeeds? Then where's the error? Yes, ./configure succeeds, also make succeeds in general, so it produces a usable python executable but _ctypes is not compiled so _ctypes is not usable and can not be imported, libffi is only needed for _ctypes AFAIK. The error, or better said INFO message, comes from make: INFO: Could not locate ffi libs and/or headers Failed to build these modules: _ctypes But nevertheless make install also succeeds, the only thing is that _ctypes does not work. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From tjol at tjol.eu Mon Sep 24 14:43:43 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Mon, 24 Sep 2018 20:43:43 +0200 Subject: [OT] master/slave debate in Python In-Reply-To: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: On 24/09/2018 14:52, Robin Becker wrote: > On 23/09/2018 15:45, Albert-Jan Roskam wrote: >> *sigh*. I'm with Hettinger on this. >> >> https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ >> >> > I am as well. Don't fix what is not broken. The semantics (in > programming) might not be an exact match, but people have been using > these sorts of terms for a long time without anyone objecting. This sort > of language control is just thought control of the wrong sort. Never mind the justification and the overblown coverage in publications like the Register - if you look at the patches actually merged (mostly in https://github.com/python/cpython/pull/9101/files) they all look like entirely reasonable changes making docs, docstrings and comments clearer. From rosuav at gmail.com Mon Sep 24 15:45:13 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 25 Sep 2018 05:45:13 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: On Tue, Sep 25, 2018 at 5:02 AM Thomas Jollans wrote: > > On 24/09/2018 14:52, Robin Becker wrote: > > On 23/09/2018 15:45, Albert-Jan Roskam wrote: > >> *sigh*. I'm with Hettinger on this. > >> > >> https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ > >> > >> > > I am as well. Don't fix what is not broken. The semantics (in > > programming) might not be an exact match, but people have been using > > these sorts of terms for a long time without anyone objecting. This sort > > of language control is just thought control of the wrong sort. > > Never mind the justification and the overblown coverage in publications > like the Register - if you look at the patches actually merged (mostly > in https://github.com/python/cpython/pull/9101/files) they all look like > entirely reasonable changes making docs, docstrings and comments clearer. > That particular PR is mostly non-controversial (there's some that are under dispute, and dealt with elsewhere, and I'm ignoring those). "Master process" is only one possible usage model so "parent process" is more accurate anyway; "master and client" is mismatched; in fact, the only one I'd even slightly disagree with is "buildslaves", since that's a technically accurate term (they ARE slaved to the master buildbot process), and that one has been changed upstream to "workers", so there's no issues there. The trouble is that making changes like this with a view to eliminating the words "master" and "slave" from all docs and comments (rather than making them to improve clarity and accuracy) opens up the leverage that SJWs need. "Hey, you changed that because we hate slavery - now you'd better eliminate all references to 'black' because we hate racism". So clear boundaries need to be set. ChrisA From kirillbalunov at gmail.com Mon Sep 24 16:40:22 2018 From: kirillbalunov at gmail.com (Kirill Balunov) Date: Mon, 24 Sep 2018 23:40:22 +0300 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: ??, 24 ????. 2018 ?. ? 22:46, Chris Angelico : > > The trouble is that making changes like this with a view to > eliminating the words "master" and "slave" from all docs and comments > (rather than making them to improve clarity and accuracy) opens up the > leverage that SJWs need. "Hey, you changed that because we hate > slavery - now you'd better eliminate all references to 'black' because > we hate racism". So clear boundaries need to be set. > > It seems to me that the word "black" has immunity in the next two Python releases ;) So do not worry so much! But honestly, it's not pleasant to see how such holy things spread into the world of OSS, and this is apparently only the beginning. With kind regards, -gdg From porton at narod.ru Mon Sep 24 17:01:56 2018 From: porton at narod.ru (Victor Porton) Date: Tue, 25 Sep 2018 00:01:56 +0300 Subject: Recommended format for --log-level option Message-ID: What is the recommended format for --log-level (or --loglevel?) command line option? Is it a number or NOTSET|DEBUG|INFO|WARNING|ERROR|CRITICAL? Or should I accept both numbers and these string constants? -- Victor Porton - http://portonvictor.org From gheskett at shentel.net Mon Sep 24 17:15:48 2018 From: gheskett at shentel.net (Gene Heskett) Date: Mon, 24 Sep 2018 17:15:48 -0400 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: <201809241715.48856.gheskett@shentel.net> On Monday 24 September 2018 16:40:22 Kirill Balunov wrote: > ??, 24 ????. 2018 ?. ? 22:46, Chris Angelico : > > The trouble is that making changes like this with a view to > > eliminating the words "master" and "slave" from all docs and > > comments (rather than making them to improve clarity and accuracy) > > opens up the leverage that SJWs need. "Hey, you changed that because > > we hate slavery - now you'd better eliminate all references to > > 'black' because we hate racism". So clear boundaries need to be set. > At least forty Rogers on that. No one should get their political panties jammed in the crack over terminology thats likely older than they are. And anybody that does is nothing but a troublemaker, and probably should be /gently/ treated as such. > It seems to me that the word "black" has immunity in the next two > Python releases ;) So do not worry so much! > > But honestly, it's not pleasant to see how such holy things spread > into the world of OSS, and this is apparently only the beginning. Yes except the beginning was years, even many decades ago, the only thing really changed is the names we use to describe it. Each generation seems to be bent on makeing a bigger stink than their parents made. It isn't pretty, and is best handled by turning down ones hearing aid. Sometimes they are smart enough to realize they are being ignored and will adjust their attitude. > With kind regards, > -gdg -- 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 gheskett at shentel.net Mon Sep 24 19:23:38 2018 From: gheskett at shentel.net (Gene Heskett) Date: Mon, 24 Sep 2018 19:23:38 -0400 Subject: Need to find the centroid of a circular camera image In-Reply-To: References: <201809231542.56849.gheskett@shentel.net> <201809241206.19714.gheskett@shentel.net> Message-ID: <201809241923.38026.gheskett@shentel.net> On Monday 24 September 2018 18:47:08 Dennis Lee Bieber wrote: > On Mon, 24 Sep 2018 12:06:19 -0400, Gene Heskett > > > declaimed the following: > >On Monday 24 September 2018 10:55:23 Chris Angelico wrote: > >> On Tue, Sep 25, 2018 at 12:54 AM Gene Heskett > >> > > > >wrote: > >> > On Sunday 23 September 2018 16:24:23 Oscar Benjamin wrote: > >> > > On Sun, 23 Sep 2018 at 20:45, Gene Heskett > >> > > > >> > > >> > wrote: > >> > > > save the image and locate the centroid of that saved image. > >> > > > > >> > > > Is there code to do that centroid math in somebodies "bottom > >> > > > desk drawer"? Something I could download and control with a > >> > > > bash script which I'm fair at? > >> > > > >> > > This is easy enough to in OpenCV. The code at the top of this > >> > > page does what you want: > >> > > > >> > > https://docs.opencv.org/3.4.2/dd/d49/tutorial_py_contour_featur > >> > >es. html > >> > > >> > I take it that this is python-2.7? code? > >> > > >> > Searching thru the python3 results in synaptic, on a stretch > >> > install on the rock64, python3 has not a p3 version of numpy or > >> > cv2. > >> > > >> > And I'd like to try and make it run on 3.5 since that seems to be > >> > the newest on stretch. That would tend to future-proof this past > >> > the final fixes and eventual demise of python-2. > >> > > >> > Is there hope for things like numpy and cv2 being ported to > >> > python 3? Or can numpy and cv2 be used against 3.5 as is? > >> > >> Dunno about cv2, but numpy is certainly available for Python 3. > > > >What do they call it in debian stretch for arm64? > > Well, in Raspbian they show up as... > > > Linux raspberrypi 4.14.69-v7+ #1141 SMP Mon Sep 10 15:26:29 BST 2018 > armv7l > Thats a 32 bit kernel, the rt version has been tried and found wanting, very high throwaway percentages for keyboard and mouse events. > The programs included with the Debian GNU/Linux system are free > software; the exact distribution terms for each program are described > in the individual files in /usr/share/doc/*/copyright. > > Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent > permitted by applicable law. > Last login: Fri Sep 14 12:36:56 2018 from > fe80::c932:bd85:577:9922%eth0 pi at raspberrypi:~$ python3 --version > Python 3.5.3 > pi at raspberrypi:~$ python3 > Python 3.5.3 (default, Jan 19 2017, 14:11:04) > [GCC 6.3.0 20170124] on linux > Type "help", "copyright", "credits" or "license" for more information. > > >>> import numpy > > I don't remember installing numpy -- it just seems to be there... > > pi at raspberrypi:~$ sudo apt search numpy > Sorting... Done > Full Text Search... Done > > > > > python3-bottleneck/stable 1.2.0-6 armhf > Fast NumPy array functions written in C - Python 3 > > > > python3-numexpr/stable 2.6.1-4 armhf > Fast numerical array expression evaluator for Python 3 and NumPy > > python3-numexpr-dbg/stable 2.6.1-4 armhf > Fast numerical array expression evaluator for Python 3 and NumPy > (debug ext) > > python3-numpy/stable,now 1:1.12.1-3 armhf [installed] > Fast array facility to the Python 3 language > > python3-numpy-dbg/stable 1:1.12.1-3 armhf > Fast array facility to the Python 3 language (debug extension) > > python3-numpydoc/stable 0.6.0+ds1-1 all > Sphinx extension to support docstrings in Numpy format -- Python3 > > > > python3-rasterio/stable 0.36.0-1+b2 armhf > Python 3 API for using geospatial raster data with Numpy > > python3-scipy/stable 0.18.1-2 armhf > scientific tools for Python 3 > > python3-scipy-dbg/stable 0.18.1-2 armhf > scientific tools for Python 3 - debugging symbols > > python3-seaborn/stable 0.7.1-4 all > statistical visualization library > > python3-snuggs/stable 1.4.1-1 all > S-expressions for numpy - Python 3 version > > > > > Only hits for cv2 are Java > > pi at raspberrypi:~$ sudo apt search cv2 > Sorting... Done > Full Text Search... Done > libcv2.4/stable 2.4.9.1+dfsg1-2 all > computer vision library - libcv* translation package > > libopencv2.4-java/stable 2.4.9.1+dfsg1-2 all > Java bindings for the computer vision library > > libopencv2.4-jni/stable 2.4.9.1+dfsg1-2 armhf > Java jni library for the computer vision library > > pi at raspberrypi:~$ > > However, Raspbian is 32-bit Debian-based. I don't know what would be > needed to configure/install a pure 64-bit Debian on the RPi-3. > In all likelyhood, it won't be running on the pi-3b, but on a rock64, which is arm64. So its called armbian. > > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ On the rock64, python has numpy but not cv2, python3 has neither. And doesn't have pip or pip3 in the repo's. But on a swag, it did install python-cv2*, so maybe it will run this stuff after all. But despite a "sudo apt install cv2" pulling in 30 some packages, cv2 is not available to import, at least not by that name.. I might have to use a broken pi 3b, I think it has a blown gpio pin, but it otherwise still ran the last time it was powered up. All I need to do is find it. In that mess, it could be a chore. Organization has never been a strong point of mine... Thanks Dennis. -- 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 __peter__ at web.de Tue Sep 25 03:45:11 2018 From: __peter__ at web.de (Peter Otten) Date: Tue, 25 Sep 2018 09:45:11 +0200 Subject: Recommended format for --log-level option References: Message-ID: Victor Porton wrote: > What is the recommended format for --log-level (or --loglevel?) command > line option? > > Is it a number or NOTSET|DEBUG|INFO|WARNING|ERROR|CRITICAL? Not really a recommendation, but I use choices=["DEBUG", ..., "CRITICAL"], type=str.upper It's not clear to me what it means to set the logging level to NOTSET, so I left that one out. The type allows me to invoke the script ./script.py --log-level warning which I find more convenient to... type. When I don't need that level of detail I use level = logging.DEBUG if args.verbose else logging.ERROR or similar. > Or should I accept both numbers and these string constants? Well, I don't even remember those numbers ;) From robin at reportlab.com Tue Sep 25 04:38:50 2018 From: robin at reportlab.com (Robin Becker) Date: Tue, 25 Sep 2018 09:38:50 +0100 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: <51a61464-905e-bda4-37ce-28d5a0cba9c1@chamonix.reportlab.co.uk> On 24/09/2018 17:30, Dan Purgert wrote: > Robin Becker wrote: >> [...] just thought control of the wrong sort.. > > Is there "thought control of the right sort"? > > yes python is good python is good ........ -- Robin Becker From robin at reportlab.com Tue Sep 25 04:44:31 2018 From: robin at reportlab.com (Robin Becker) Date: Tue, 25 Sep 2018 09:44:31 +0100 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> On 24/09/2018 21:40, Kirill Balunov wrote: ... > It seems to me that the word "black" has immunity in the next two Python > releases ;) So do not worry so much! > apparently whitelist/blacklist is an issue so presumably white should also get immunity :) > But honestly, it's not pleasant to see how such holy things spread into the > world of OSS, and this is apparently only the beginning. +1 -- Robin Becker From cspealma at redhat.com Tue Sep 25 09:00:13 2018 From: cspealma at redhat.com (Calvin Spealman) Date: Tue, 25 Sep 2018 09:00:13 -0400 Subject: [OT] master/slave debate in Python In-Reply-To: <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> Message-ID: This entire conversation is inappropriate for this mailing list. Please leave this free for people who need to ask and give help with Python, regardless of which side of this argument you are on. On Tue, Sep 25, 2018 at 4:44 AM Robin Becker wrote: > On 24/09/2018 21:40, Kirill Balunov wrote: > ... > > It seems to me that the word "black" has immunity in the next two Python > > releases ;) So do not worry so much! > > > apparently whitelist/blacklist is an issue so presumably white should also > get immunity :) > > > But honestly, it's not pleasant to see how such holy things spread into > the > > world of OSS, and this is apparently only the beginning. > +1 > -- > Robin Becker > > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Tue Sep 25 09:12:50 2018 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 25 Sep 2018 23:12:50 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> Message-ID: On Tue, Sep 25, 2018 at 11:01 PM Calvin Spealman wrote: > > This entire conversation is inappropriate for this mailing list. Please > leave this free for people who need to ask and give help with Python, > regardless of which side of this argument you are on. Considering that the conversation is specifically about changes to the code and documentation of the language and its reference implementation, I don't see that it's off topic. ChrisA From jon+usenet at unequivocal.eu Tue Sep 25 11:53:05 2018 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Tue, 25 Sep 2018 15:53:05 -0000 (UTC) Subject: [OT] master/slave debate in Python References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> Message-ID: On 2018-09-25, Chris Angelico wrote: > On Tue, Sep 25, 2018 at 11:01 PM Calvin Spealman wrote: >> This entire conversation is inappropriate for this mailing list. Please >> leave this free for people who need to ask and give help with Python, >> regardless of which side of this argument you are on. > > Considering that the conversation is specifically about changes to the > code and documentation of the language and its reference > implementation, I don't see that it's off topic. Those things might be on topic on python-dev - although I am sure no-one would thank you for continuing this discussion there - but this is comp.lang.python/python-list and here this is off-topic. From rosuav at gmail.com Tue Sep 25 14:57:42 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 26 Sep 2018 04:57:42 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> Message-ID: On Wed, Sep 26, 2018 at 1:56 AM Jon Ribbens wrote: > > On 2018-09-25, Chris Angelico wrote: > > On Tue, Sep 25, 2018 at 11:01 PM Calvin Spealman wrote: > >> This entire conversation is inappropriate for this mailing list. Please > >> leave this free for people who need to ask and give help with Python, > >> regardless of which side of this argument you are on. > > > > Considering that the conversation is specifically about changes to the > > code and documentation of the language and its reference > > implementation, I don't see that it's off topic. > > Those things might be on topic on python-dev - although I am sure > no-one would thank you for continuing this discussion there - but > this is comp.lang.python/python-list and here this is off-topic. Okay. What *is* on-topic for python-list? """ This mailing list is a general discussion list for the Python programming language. """ (https://mail.python.org/mailman/listinfo/python-list) Is it off-topic because it's nothing to do with Python, or is it actually off-topic because it makes you afraid that people won't be bullied by the SJW brigade? ChrisA From jon+usenet at unequivocal.eu Tue Sep 25 15:54:41 2018 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Tue, 25 Sep 2018 19:54:41 -0000 (UTC) Subject: [OT] master/slave debate in Python References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> Message-ID: On 2018-09-25, Chris Angelico wrote: > On Wed, Sep 26, 2018 at 1:56 AM Jon Ribbens wrote: >> Those things might be on topic on python-dev - although I am sure >> no-one would thank you for continuing this discussion there - but >> this is comp.lang.python/python-list and here this is off-topic. > > Okay. What *is* on-topic for python-list? https://www.python.org/community/lists/#comp-lang-python says "Pretty much anything Python-related is fair game for discussion" *however* it also says "Most discussion on comp.lang.python is about developing with Python, not about development of the Python interpreter itself" and python-dev is clearly the on-topic place for such discussion. I suggest you also read what the above link says about flamebait, and the Python Community Code of Conduct at https://www.python.org/psf/codeofconduct/ From rosuav at gmail.com Tue Sep 25 16:03:21 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 26 Sep 2018 06:03:21 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> Message-ID: On Wed, Sep 26, 2018 at 5:56 AM Jon Ribbens wrote: > > On 2018-09-25, Chris Angelico wrote: > > On Wed, Sep 26, 2018 at 1:56 AM Jon Ribbens wrote: > >> Those things might be on topic on python-dev - although I am sure > >> no-one would thank you for continuing this discussion there - but > >> this is comp.lang.python/python-list and here this is off-topic. > > > > Okay. What *is* on-topic for python-list? > > https://www.python.org/community/lists/#comp-lang-python says > > "Pretty much anything Python-related is fair game for discussion" So.... fair game. Also, read the rest of that sentence. > *however* it also says > > "Most discussion on comp.lang.python is about developing with > Python, not about development of the Python interpreter itself" > > and python-dev is clearly the on-topic place for such discussion. That isn't stating that it's off-topic to discuss the state of the interpreter and/or language. > I suggest you also read what the above link says about flamebait, You mean this? "Rudeness and personal attacks, even in reaction to blatant flamebait, are strongly frowned upon." I was neither rude, nor personally attacking anyone. > and the Python Community Code of Conduct at > https://www.python.org/psf/codeofconduct/ If you want to accuse me of a CoC violation, say exactly what you're accusing me of. To my knowledge, I have not violated it by discussing this documentation change. Be specific, and don't treat the CoC as an arbitrary weapon to be threatened. ChrisA From tjol at tjol.eu Tue Sep 25 18:46:08 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Wed, 26 Sep 2018 00:46:08 +0200 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> Message-ID: <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> On 25/09/18 20:57, Chris Angelico wrote: > > Is it off-topic because it's nothing to do with Python, or is it > actually off-topic because it makes you afraid that people won't be > bullied by the SJW brigade? I have to say I find these unspecified attacks on "SJWs" rather disturbing. Assuming for a moment that "SJW" is a viable insult (that's the way you appear to be using it, though I wouldn't use it myself, in that way or probably at all) - Who is the "SJW brigade" of whom you speak? Is it Victor? Surely not. Guido? No, right? e Victor's anonymous source? Isn't that a bit harsh, considering you know nothing about them? Some unspecified possible future threat? Now this seems more likely, but it's also rather silly, don't you think? All the best, Thomas PS: I'm not a great fan of it, but I think we all know that off-topic is in a way what this list excels at. From rosuav at gmail.com Tue Sep 25 19:10:13 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 26 Sep 2018 09:10:13 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: On Wed, Sep 26, 2018 at 8:47 AM Thomas Jollans wrote: > > On 25/09/18 20:57, Chris Angelico wrote: > > > > Is it off-topic because it's nothing to do with Python, or is it > > actually off-topic because it makes you afraid that people won't be > > bullied by the SJW brigade? > > > I have to say I find these unspecified attacks on "SJWs" rather > disturbing. Assuming for a moment that "SJW" is a viable insult (that's > the way you appear to be using it, though I wouldn't use it myself, in > that way or probably at all) - Yes, it's an insult. It's the people who believe that they can cure social problems by making demands, usually about the trappings rather than the actual problems. For example, excising the terms "master" and "slave" from documentation, rather than actually doing anything about real slavery where it still happens. Or demanding that we talk about "persons of colour" or whatever the latest term is, rather than actually treating people equally. > Who is the "SJW brigade" of whom you speak? > > Is it Victor? Surely not. > > Guido? No, right? > e > Victor's anonymous source? Isn't that a bit harsh, considering you know > nothing about them? What I know about them is that they (and I am assuming there are multiple people, because there are reports of multiple reports, if that makes sense) are agitating for changes to documentation without any real backing. I'm also talking about an anonymous person who caused *me* personal harm by the exact same thing. I won't go into details because the person wouldn't go into details about the offense I had purportedly done, so I'm going to leave this as a vague and meaningless thing, just like I was given... except that when I was given it, it came with a punishment. > Some unspecified possible future threat? Now this seems more likely, but > it's also rather silly, don't you think? The current threat is extremely likely to be continued in the future, yes, and it's not silly to assume that it will. ChrisA From ian.g.kelly at gmail.com Wed Sep 26 00:09:12 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 25 Sep 2018 22:09:12 -0600 Subject: [OT] master/slave debate in Python In-Reply-To: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> Message-ID: On Mon, Sep 24, 2018 at 6:55 AM Robin Becker wrote: > > On 23/09/2018 15:45, Albert-Jan Roskam wrote: > > *sigh*. I'm with Hettinger on this. > > > > https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ > > > I am as well. Don't fix what is not broken. The semantics (in programming) might not be an exact match, but people have been using > these sorts of terms for a long time without anyone objecting. Then you haven't been paying attention. I've been hearing complaints about this with regard to computing in general for literally decades. From ian.g.kelly at gmail.com Wed Sep 26 00:34:04 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 25 Sep 2018 22:34:04 -0600 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: Chris Angelico wrote: > > I was neither rude, nor personally attacking anyone. Actually, the "SJW brigade" remark was quite rude, and a clear attack on anybody who supports this change. > Yes, it's an insult. It's the people who believe that they can cure > social problems by making demands, usually about the trappings rather > than the actual problems. For example, excising the terms "master" and > "slave" from documentation, rather than actually doing anything about > real slavery where it still happens. So, Chris, what have *you personally* done about real slavery where it still happens? If, as I'm guessing, the answer is "nothing" then it seems to me that you don't have much of a leg to stand on to level this accusation. In any case, this is not about ending slavery. This is about treating others with empathy and recognizing that words can be hurtful even when not intended to be. Just because there are large, difficult problems in the world does not mean that smaller problems should not be addressed. > What I know about them is that they (and I am assuming there are > multiple people, because there are reports of multiple reports, if > that makes sense) are agitating for changes to documentation without > any real backing. The terminology should be changed because it's offensive, full stop. It may be normalized to many who are accustomed to it, but that doesn't make it any less offensive. Imagine if the terminology were instead "dominant / submissive". Without meaning to assume too much, might the cultural context surrounding those terms make you feel uncomfortable when using them? Would you desire for something else to be used in their place? Well, there are plenty of people who feel exactly that way about "master / slave". > I'm also talking about an anonymous person who caused *me* personal > harm by the exact same thing. I won't go into details because the > person wouldn't go into details about the offense I had purportedly > done, so I'm going to leave this as a vague and meaningless thing, > just like I was given... except that when I was given it, it came with > a punishment. Sorry to hear that. However, your personal pain from some other unrelated issue has nothing to do with whether this terminology should be changed. > > Some unspecified possible future threat? Now this seems more likely, but > > it's also rather silly, don't you think? > > The current threat is extremely likely to be continued in the future, > yes, and it's not silly to assume that it will. "Threat?" What is so threatening about asking people to use different terminology? Here's the reality: the change may be difficult for some while it's happening, because people don't like being told that the way they're accustomed to doing something is harmful. But a few years from now, after everything has settled, nobody will be looking back at this and saying "oh, I wish we still used master/slave in the documentation. Primary/replica (or whatever else replaces it) just doesn't sound as good." Honestly, it's absurd that this is even a debate. Let's just make the change and get it over with. From rosuav at gmail.com Wed Sep 26 00:45:16 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 26 Sep 2018 14:45:16 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: On Wed, Sep 26, 2018 at 2:36 PM Ian Kelly wrote: > So, Chris, what have *you personally* done about real slavery where it > still happens? > > If, as I'm guessing, the answer is "nothing" then it seems to me that > you don't have much of a leg to stand on to level this accusation. Am I demanding that the terminology be changed? No? Then I don't think the accusation applies. > Imagine if the terminology were instead "dominant / submissive". > Without meaning to assume too much, might the cultural context > surrounding those terms make you feel uncomfortable when using them? > Would you desire for something else to be used in their place? Well, > there are plenty of people who feel exactly that way about "master / > slave". I wouldn't care. > Here's the reality: the change may be difficult for some while it's > happening, because people don't like being told that the way they're > accustomed to doing something is harmful. But a few years from now, > after everything has settled, nobody will be looking back at this and > saying "oh, I wish we still used master/slave in the documentation. > Primary/replica (or whatever else replaces it) just doesn't sound as > good." > > Honestly, it's absurd that this is even a debate. Let's just make the > change and get it over with. And what happens when "replica" becomes pejorative? Do we change words again? ChrisA From ian.g.kelly at gmail.com Wed Sep 26 00:56:09 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 25 Sep 2018 22:56:09 -0600 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: On Tue, Sep 25, 2018 at 10:48 PM Chris Angelico wrote: > > On Wed, Sep 26, 2018 at 2:36 PM Ian Kelly wrote: > > So, Chris, what have *you personally* done about real slavery where it > > still happens? > > > > If, as I'm guessing, the answer is "nothing" then it seems to me that > > you don't have much of a leg to stand on to level this accusation. > > Am I demanding that the terminology be changed? No? Then I don't think > the accusation applies. You're objecting to people trying to do *something* positive on the grounds that they're not doing *more* while you yourself are doing *nothing*. That's pretty hypocritical. > > Imagine if the terminology were instead "dominant / submissive". > > Without meaning to assume too much, might the cultural context > > surrounding those terms make you feel uncomfortable when using them? > > Would you desire for something else to be used in their place? Well, > > there are plenty of people who feel exactly that way about "master / > > slave". > > I wouldn't care. Then why not just use those terms instead? > > Here's the reality: the change may be difficult for some while it's > > happening, because people don't like being told that the way they're > > accustomed to doing something is harmful. But a few years from now, > > after everything has settled, nobody will be looking back at this and > > saying "oh, I wish we still used master/slave in the documentation. > > Primary/replica (or whatever else replaces it) just doesn't sound as > > good." > > > > Honestly, it's absurd that this is even a debate. Let's just make the > > change and get it over with. > > And what happens when "replica" becomes pejorative? Do we change words again? I think it's pretty obvious why "slave" has a negative connotation. Why on Earth would "replica" ever become pejorative? I suppose in that case we would curse Philip K. Dick and start over again. From robin at reportlab.com Wed Sep 26 03:27:19 2018 From: robin at reportlab.com (Robin Becker) Date: Wed, 26 Sep 2018 08:27:19 +0100 Subject: [OT] master/slave debate in Python In-Reply-To: <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: On 25/09/2018 23:46, Thomas Jollans wrote: .......... > > I have to say I find these unspecified attacks on "SJWs" rather disturbing. Assuming for a moment that "SJW" is a viable insult > (that's the way you appear to be using it, though I wouldn't use it myself, in that way or probably at all) - > > Who is the "SJW brigade" of whom you speak? > ....... It didn't take me very long to find a connection between this thread and this phrase "I?m Tired of Being Tolerant" on these issues I am with the Voltaireans. -- Robin Becker From vito.detullio at gmail.com Wed Sep 26 03:50:08 2018 From: vito.detullio at gmail.com (vito.detullio at gmail.com) Date: Wed, 26 Sep 2018 00:50:08 -0700 (PDT) Subject: clever exit of nested loops Message-ID: Hi Today I've added a couple of lines in my source code, and I'm very ashamed of it. it "runs", and I know what it does (for now), but it's "too clever". I have "abused" the "else" clause of the loops to makes a break "broke" more loops for i in range(10): print(f'i: {i}') for j in range(10): print(f'\tj: {j}') for k in range(10): print(f'\t\tk: {k}') if condition(i, j, k): break else: # if there weren't breaks in the inner loop, continue # then make anoter outer loop, break # else break also the outer one else: continue break the "magic" is in that repeated block... it's so convoluted to read... still it's very useful to omit "signals" variables or the need to refactor it in a function with an explicit return or other solutions. is there any chance to extends the python grammar to allow something like for i in range(10) and not break: print(f'i: {i}') for j in range(10) and not break: print(f'\tj: {j}') for k in range(10): print(f'\t\tk: {k}') if condition(i, j, k): break with the semantics of break a loop if an inner loop "broke"? From dpalao.python at gmail.com Wed Sep 26 03:58:07 2018 From: dpalao.python at gmail.com (David Palao) Date: Wed, 26 Sep 2018 09:58:07 +0200 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: Hello, My opinion is that the terms "master/slave" describe well some situations. They could be seen by some people as offensive (although unfortunately sometimes true, even today) when applied to persons. But it is not offensive when applied to processes in a computer. They are not living entities. I would say that when talking about programming, the terms have a perfect meaning. Otherwise, what is the correct way to use the words master and slave? Not using them? Best El dom., 23 sept. 2018 a las 17:00, Albert-Jan Roskam () escribi?: > > *sigh*. I'm with Hettinger on this. > > https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Wed Sep 26 04:29:29 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 26 Sep 2018 18:29:29 +1000 Subject: clever exit of nested loops In-Reply-To: References: Message-ID: On Wed, Sep 26, 2018 at 5:56 PM wrote: > > Hi > Today I've added a couple of lines in my source code, and I'm very ashamed of it. > it "runs", and I know what it does (for now), but it's "too clever". > I have "abused" the "else" clause of the loops to makes a break "broke" more loops > > > for i in range(10): > print(f'i: {i}') > for j in range(10): > print(f'\tj: {j}') > for k in range(10): > print(f'\t\tk: {k}') > > if condition(i, j, k): > break > > else: # if there weren't breaks in the inner loop, > continue # then make anoter outer loop, > break # else break also the outer one > > else: > continue > break > > the "magic" is in that repeated block... it's so convoluted to read... still it's very useful to omit "signals" variables or the need to refactor it in a function with an explicit return or other solutions. > > is there any chance to extends the python grammar to allow something like > > > for i in range(10) and not break: > print(f'i: {i}') > for j in range(10) and not break: > print(f'\tj: {j}') > for k in range(10): > print(f'\t\tk: {k}') > > if condition(i, j, k): > break > > > with the semantics of break a loop if an inner loop "broke"? > Hmm. I'm not enamoured of it. My normal solution is to put the whole thing into a function and use "return" to bail out. But sometimes that's not possible; sometimes you do need a better solution. I'm not sure this one is it, though. ChrisA From brian.j.oney at googlemail.com Wed Sep 26 04:41:24 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Wed, 26 Sep 2018 10:41:24 +0200 Subject: [OT] master/slave debate in Python In-Reply-To: <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: <1537951284.1656.7.camel@gmail.com> > PS: I'm not a great fan of it, but I think we all know that off-topic is > in a way what this list excels at. +1 An open source community thrives on being open. It also welcomes those who like to pick a fight for various, usually personal reasons. Has any heard of that Python language? I hear they named it after a person's pretty snake. No? Okay. "I have a vewwy great fwiend in Wome called 'Biggus Dickus'" ... "Can I go now, sir?" From __peter__ at web.de Wed Sep 26 05:10:08 2018 From: __peter__ at web.de (Peter Otten) Date: Wed, 26 Sep 2018 11:10:08 +0200 Subject: clever exit of nested loops References: Message-ID: vito.detullio at gmail.com wrote: > Hi > Today I've added a couple of lines in my source code, and I'm very ashamed > of it. it "runs", and I know what it does (for now), but it's "too > clever". I have "abused" the "else" clause of the loops to makes a break > "broke" more loops > > > for i in range(10): > print(f'i: {i}') > for j in range(10): > print(f'\tj: {j}') > for k in range(10): > print(f'\t\tk: {k}') > > if condition(i, j, k): > break > > else: # if there weren't breaks in the inner loop, > continue # then make anoter outer loop, > break # else break also the outer one > > else: > continue > break > > the "magic" is in that repeated block... it's so convoluted to read... > still it's very useful to omit "signals" variables or the need to refactor > it in a function with an explicit return or other solutions. > > is there any chance to extends the python grammar to allow something like > > > for i in range(10) and not break: I think that is much too close to a logical expression. If I were to add a way to break out of an inner loop I'd introduce a fullblown (intra-function) goto. So far I'm happy with generators; in my actual use cases something like def g(): for i in range(10): print(f'i: {i}') for j in range(10): print(f'\tj: {j}') for k in range(10): print(f'\t\tk: {k}') yield i, j, k for i, j, k in g(): if condition(i, j, k): break looks natural. Another option might be a dedicated exception: class Break(Exception): pass try: for i in range(10): print(f'i: {i}') for j in range(10): print(f'\tj: {j}') for k in range(10): print(f'\t\tk: {k}') if condition(i, j, k): raise Break except Break: pass From darcy at vex.net Wed Sep 26 06:46:26 2018 From: darcy at vex.net (D'Arcy Cain) Date: Wed, 26 Sep 2018 06:46:26 -0400 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: <10e0528f-01d6-4261-b758-93052837e117@vex.net> On 9/26/18 3:58 AM, David Palao wrote: > Hello, > My opinion is that the terms "master/slave" describe well some situations. > They could be seen by some people as offensive (although unfortunately > sometimes true, even today) when applied to persons. But it is not > offensive when applied to processes in a computer. They are not living > entities. Exactly. It's like the word "bitch". It's a perfectly good word when used correctly but extremely offensive when applied to women. Maybe we should change the name of the language because calling someone a snake is pejorative. I bet the PC police could find many words in the language that are offensive when applied to people. Where is Lenny Bruce when we need him? -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:darcy at Vex.Net VoIP: sip:darcy at Vex.Net From leo at superlel.me Wed Sep 26 06:59:01 2018 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Wed, 26 Sep 2018 12:59:01 +0200 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: On 26/09/2018 06:34, Ian Kelly wrote: > Chris Angelico wrote: >> What I know about them is that they (and I am assuming there are >> multiple people, because there are reports of multiple reports, if >> that makes sense) are agitating for changes to documentation without >> any real backing. > > The terminology should be changed because it's offensive, full stop. > It may be normalized to many who are accustomed to it, but that > doesn't make it any less offensive. Come on ! I have nothing to add to what Terry said: https://bugs.python.org/msg324773 Now, the bug report is still pointing out some places in the code where the master/slave terminology is misused, for _technical_ reasons. And none of us should be blinded by the non-technical motive of the bug-report. We should do what we have to do, and just let sink the rest of it. > Imagine if the terminology were instead "dominant / submissive". > Without meaning to assume too much, might the cultural context > surrounding those terms make you feel uncomfortable when using them? I couldn't care less as well. The meaning of words is given by the context. From grawburg at myglnc.com Wed Sep 26 07:12:34 2018 From: grawburg at myglnc.com (Brian Grawburg) Date: Wed, 26 Sep 2018 07:12:34 -0400 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: This is right next to the objection of the use male and female to describe the two parts of a connector. I lament that snowflakes and such are trying desperately to enforce their quest for radical egalitarianism and see hidden agendas behind just about everything---except their own, of course. Brian Grawburg Wilson, NC From ian.g.kelly at gmail.com Wed Sep 26 09:31:05 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 26 Sep 2018 07:31:05 -0600 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: On Wed, Sep 26, 2018 at 2:01 AM David Palao wrote: > > Hello, > My opinion is that the terms "master/slave" describe well some situations. > They could be seen by some people as offensive (although unfortunately > sometimes true, even today) when applied to persons. But it is not > offensive when applied to processes in a computer. They are not living > entities. > > I would say that when talking about programming, the terms have a > perfect meaning. Care to give an example? The distinctive part of the definition of "slave" is that it refers to someone who is owned and/or held captive, and forced to work against their will. I can think of no situation in programming in which the word is particularly apt, because the trait of "lack of freedom" is just not something that comes up. There is always a word choice available that is not only more sensitive, but more accurate as well. > Otherwise, what is the correct way to use the words > master and slave? Not using them? That would be my recommendation. Instead you could use "primary / replica" or "primary / secondary" or "manager / subordinate" or "client / agent" or whatever other word pair is appropriate for the particular situation. From rosuav at gmail.com Wed Sep 26 09:46:06 2018 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 26 Sep 2018 23:46:06 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: On Wed, Sep 26, 2018 at 11:33 PM Ian Kelly wrote: > > On Wed, Sep 26, 2018 at 2:01 AM David Palao wrote: > > > > Hello, > > My opinion is that the terms "master/slave" describe well some situations. > > They could be seen by some people as offensive (although unfortunately > > sometimes true, even today) when applied to persons. But it is not > > offensive when applied to processes in a computer. They are not living > > entities. > > > > I would say that when talking about programming, the terms have a > > perfect meaning. > > Care to give an example? The distinctive part of the definition of > "slave" is that it refers to someone who is owned and/or held captive, > and forced to work against their will. I can think of no situation in > programming in which the word is particularly apt, because the trait > of "lack of freedom" is just not something that comes up. There is > always a word choice available that is not only more sensitive, but > more accurate as well. Lack of freedom? That's exactly what happens *frequently* in any job-farming situation. For instance, suppose you have an embarrassingly parallel task to perform - let's say it's some kind of search for correctness, where as soon as you attempt something, you know whether it's correct or not. (Examples include crypto, searching for prime numbers, finding patterns, etc, etc.) A master process hands out tasks to slave processes; the slaves have no freedom, but must simply do as they're told. Or you can slave a number of backup database servers to a master, where the master is in charge of everything, and the slaves simply follow orders, thus creating perfect replicas. While it's sometimes correct to talk about "primary" and "replica", it's also accurate to describe *all* the nodes as replicas (since they're all identical); and it's entirely possible to have more than one master, so there isn't really a "primary". So there certainly are situations in which "slave" is absolutely precisely correct. Technically, *all* computers lack freedom. But in order to make a useful distinction here, it's easiest to define "slave" as something that follows the orders of another program, having no *human* interaction - in other words, "autonomy" really means "taking orders from a human". So it's really a hierarchy, with humans at the top, and a cascade of masters giving orders to slaves, and sometimes those slaves are themselves the masters of other slaves. (Consider the Gospel of Matthew, chapter 8, in which Jesus talks to a centurion about the meaning of authority; the centurion, being a military man, understands that being a master does not mean he never takes orders.) The terms "master" and "slave" refer to a specific relationship between two programs or machines, just as "server" and "client" do (my program could be an X11 client and an HTTP server, for instance). Actually, "server" literally means the same thing as "servant" or "slave", and the only reason it hasn't been excised from the language is that somehow the non-offensive meaning has become sufficiently dominant that people would laugh at the implication that it should be removed. So rather than removing every trace of the word "slave", how about instead we go the other way: use it in so many contexts that it loses its sting everywhere except when referring to humans. In fact, make it such that a human slave is "a person being treated like a computer", and thus obviously lacking in basic human rights. ChrisA From ian.g.kelly at gmail.com Wed Sep 26 11:26:30 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 26 Sep 2018 09:26:30 -0600 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: On Wed, Sep 26, 2018 at 7:49 AM Chris Angelico wrote: > > On Wed, Sep 26, 2018 at 11:33 PM Ian Kelly wrote: > > > > Care to give an example? The distinctive part of the definition of > > "slave" is that it refers to someone who is owned and/or held captive, > > and forced to work against their will. I can think of no situation in > > programming in which the word is particularly apt, because the trait > > of "lack of freedom" is just not something that comes up. There is > > always a word choice available that is not only more sensitive, but > > more accurate as well. > > Lack of freedom? That's exactly what happens *frequently* in any > job-farming situation. For instance, suppose you have an > embarrassingly parallel task to perform - let's say it's some kind of > search for correctness, where as soon as you attempt something, you > know whether it's correct or not. (Examples include crypto, searching > for prime numbers, finding patterns, etc, etc.) A master process hands > out tasks to slave processes; the slaves have no freedom, but must > simply do as they're told. The master also must do what it's told. This isn't a characterization of the relationship between processes; it's just the nature of programming. I see you addressed that point below, but note that subordinate processes *can* often reject tasks. It might be because "I ran out of memory", or it might be because "I'm already doing something", or even because "I hadn't heard from you in a while so I assumed there was a connectivity problem or that your process died, and I correspondingly initiated an election among my peers and now I'm the master node". > Or you can slave a number of backup > database servers to a master, where the master is in charge of > everything, and the slaves simply follow orders, thus creating perfect > replicas. While it's sometimes correct to talk about "primary" and > "replica", it's also accurate to describe *all* the nodes as replicas > (since they're all identical); and it's entirely possible to have more > than one master, so there isn't really a "primary". So there certainly > are situations in which "slave" is absolutely precisely correct. Your conclusion does not follow. Just because "primary" is not always the best term does not mean that "slave" automatically fills the role. > Technically, *all* computers lack freedom. But in order to make a > useful distinction here, it's easiest to define "slave" as something > that follows the orders of another program, having no *human* > interaction - in other words, "autonomy" really means "taking orders > from a human". So it's really a hierarchy, with humans at the top, and > a cascade of masters giving orders to slaves, and sometimes those > slaves are themselves the masters of other slaves. (Consider the > Gospel of Matthew, chapter 8, in which Jesus talks to a centurion > about the meaning of authority; the centurion, being a military man, > understands that being a master does not mean he never takes orders.) > The terms "master" and "slave" refer to a specific relationship > between two programs or machines, just as "server" and "client" do (my > program could be an X11 client and an HTTP server, for instance). > Actually, "server" literally means the same thing as "servant" or > "slave", and the only reason it hasn't been excised from the language > is that somehow the non-offensive meaning has become sufficiently > dominant that people would laugh at the implication that it should be > removed. "Servant" and "slave" do not have the same connotation. While it's generally rude or offensive to refer to an individual as a servant, the use of the word is not seen as a slight to an entire subculture. > So rather than removing every trace of the word "slave", how about > instead we go the other way: use it in so many contexts that it loses > its sting everywhere except when referring to humans. In fact, make it > such that a human slave is "a person being treated like a computer", > and thus obviously lacking in basic human rights. How about we also plaster the swastika (another symbol that carries "another meaning") all over everything, all while insisting that it's just a good luck symbol and that it shouldn't be associated with Nazis forever, and force anybody who finds it offensive to "get over it" or suffer in silence. I don't mean to Godwin the thread, but this is no different than what you're proposing. Also: a human slave is not "a person being treated like a computer" and I find it highly disrespectful that you would move to trivialize slavery like that. From p.f.moore at gmail.com Wed Sep 26 11:40:50 2018 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 26 Sep 2018 16:40:50 +0100 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: On Wed, 26 Sep 2018 at 16:30, Ian Kelly wrote: > Also: a human slave is not "a person being treated like a computer" > and I find it highly disrespectful that you would move to trivialize > slavery like that. I have no idea what it must feel like to be a slave (other than the trite and obvious idea that "it must be awful"). Unfortunately, debates like this do nothing to help me understand or empathise with the people suffering in that way, or people dealing with the aftermath of historical cases. I'm more than happy to ensure that we are not causing pain or being disrespectful of the suffering of others, but rather than simply making the whole issue feel like a censorship debate, I'd rather we were helping people to understand and empathise, so that they would *of their own accord* act in an appropriate way. Self-censorship based on understanding and empathy is far more reasonable than any sort of externally-imposed rules. But discussing what it means to be a slave, or the implications of slavery on our culture(s) is way off-topic for this list, so I'd prefer not to debate it further here. I'm sure anyone interested in understanding more can easily find more appropriate forums to participate in. Paul From marko at pacujo.net Wed Sep 26 11:59:16 2018 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 26 Sep 2018 18:59:16 +0300 Subject: [OT] master/slave debate in Python References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: <87tvmcw8q3.fsf@elektro.pacujo.net> Ian Kelly : > The terminology should be changed because it's offensive, full stop. > It may be normalized to many who are accustomed to it, but that > doesn't make it any less offensive. > > Imagine if the terminology were instead "dominant / submissive". > Without meaning to assume too much, might the cultural context > surrounding those terms make you feel uncomfortable when using them? > Would you desire for something else to be used in their place? Well, > there are plenty of people who feel exactly that way about "master / > slave". I'm not a great fan of word taboos. In particular, you can't ban a word just because someone gets offended by it. > Honestly, it's absurd that this is even a debate. Let's just make the > change and get it over with. I agree that this debate sounds absurd, satirical even. Marko From breamoreboy at gmail.com Wed Sep 26 15:06:09 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Wed, 26 Sep 2018 20:06:09 +0100 Subject: clever exit of nested loops In-Reply-To: References: Message-ID: On 26/09/18 08:50, vito.detullio at gmail.com wrote: > Hi > Today I've added a couple of lines in my source code, and I'm very ashamed of it. > it "runs", and I know what it does (for now), but it's "too clever". > I have "abused" the "else" clause of the loops to makes a break "broke" more loops > > > for i in range(10): > print(f'i: {i}') > for j in range(10): > print(f'\tj: {j}') > for k in range(10): > print(f'\t\tk: {k}') > > if condition(i, j, k): > break > > else: # if there weren't breaks in the inner loop, > continue # then make anoter outer loop, > break # else break also the outer one > > else: > continue > break > > the "magic" is in that repeated block... it's so convoluted to read... still it's very useful to omit "signals" variables or the need to refactor it in a function with an explicit return or other solutions. > > is there any chance to extends the python grammar to allow something like > > > for i in range(10) and not break: > print(f'i: {i}') > for j in range(10) and not break: > print(f'\tj: {j}') > for k in range(10): > print(f'\t\tk: {k}') > > if condition(i, j, k): > break > > > with the semantics of break a loop if an inner loop "broke"? > > > To me the Ned Batchelder presentation https://www.youtube.com/watch?v=EnSu9hHGq5o "Loop like a Native" is the definitive way on how to deal with loops in Python. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From Joseph.Schachner at Teledyne.com Wed Sep 26 15:07:52 2018 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Wed, 26 Sep 2018 19:07:52 +0000 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: This really is an amazing discussion. I actually do understand why "master" and "slave" might make people uncomfortable, although the meaning is quite clear. Perhaps we need a currently used alternative: 1) Captain and Private 2) Manager and employee 3) CEO and Peon 4) Controller and Controlled 5) Commander and executer You might not like any of these. That's OK, my goal was just to show that the relationship can be expressed without using outdated terms that some find objectionable. These all have pretty much the same relationship (first one says what to do, second one does it) but I think any one of them feels more "comfortable" now-a-days than Master and Slave. --- Joe S. -----Original Message----- From: Paul Moore Sent: Wednesday, September 26, 2018 11:41 AM To: Ian Kelly Cc: Python Subject: Re: [OT] master/slave debate in Python On Wed, 26 Sep 2018 at 16:30, Ian Kelly wrote: > Also: a human slave is not "a person being treated like a computer" > and I find it highly disrespectful that you would move to trivialize > slavery like that. I have no idea what it must feel like to be a slave (other than the trite and obvious idea that "it must be awful"). Unfortunately, debates like this do nothing to help me understand or empathise with the people suffering in that way, or people dealing with the aftermath of historical cases. I'm more than happy to ensure that we are not causing pain or being disrespectful of the suffering of others, but rather than simply making the whole issue feel like a censorship debate, I'd rather we were helping people to understand and empathise, so that they would *of their own accord* act in an appropriate way. Self-censorship based on understanding and empathy is far more reasonable than any sort of externally-imposed rules. But discussing what it means to be a slave, or the implications of slavery on our culture(s) is way off-topic for this list, so I'd prefer not to debate it further here. I'm sure anyone interested in understanding more can easily find more appropriate forums to participate in. Paul From rosuav at gmail.com Wed Sep 26 15:29:05 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 27 Sep 2018 05:29:05 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: On Thu, Sep 27, 2018 at 1:28 AM Ian Kelly wrote: > > On Wed, Sep 26, 2018 at 7:49 AM Chris Angelico wrote: > > > > On Wed, Sep 26, 2018 at 11:33 PM Ian Kelly wrote: > > > > > > Care to give an example? The distinctive part of the definition of > > > "slave" is that it refers to someone who is owned and/or held captive, > > > and forced to work against their will. I can think of no situation in > > > programming in which the word is particularly apt, because the trait > > > of "lack of freedom" is just not something that comes up. There is > > > always a word choice available that is not only more sensitive, but > > > more accurate as well. > > > > Lack of freedom? That's exactly what happens *frequently* in any > > job-farming situation. For instance, suppose you have an > > embarrassingly parallel task to perform - let's say it's some kind of > > search for correctness, where as soon as you attempt something, you > > know whether it's correct or not. (Examples include crypto, searching > > for prime numbers, finding patterns, etc, etc.) A master process hands > > out tasks to slave processes; the slaves have no freedom, but must > > simply do as they're told. > > The master also must do what it's told. This isn't a characterization > of the relationship between processes; it's just the nature of > programming. > > I see you addressed that point below, but note that subordinate > processes *can* often reject tasks. It might be because "I ran out of > memory", or it might be because "I'm already doing something", or even > because "I hadn't heard from you in a while so I assumed there was a > connectivity problem or that your process died, and I correspondingly > initiated an election among my peers and now I'm the master node". Yes, I do address the point, and what you've said here is proof that "master" and "slave" indicate a relationship, not a permanent situation. Computers and software can adopt an Elbonian approach to slavery: http://dilbert.com/strip/2010-08-28 > > Or you can slave a number of backup > > database servers to a master, where the master is in charge of > > everything, and the slaves simply follow orders, thus creating perfect > > replicas. While it's sometimes correct to talk about "primary" and > > "replica", it's also accurate to describe *all* the nodes as replicas > > (since they're all identical); and it's entirely possible to have more > > than one master, so there isn't really a "primary". So there certainly > > are situations in which "slave" is absolutely precisely correct. > > Your conclusion does not follow. Just because "primary" is not always > the best term does not mean that "slave" automatically fills the role. No, it doesn't follow. I described some situations where it IS correct, but there are of course times when it isn't. That's simply the nature of technical terminology. > "Servant" and "slave" do not have the same connotation. While it's > generally rude or offensive to refer to an individual as a servant, > the use of the word is not seen as a slight to an entire subculture. And "server" doesn't have the same connotation either, yet they all ultimately mean the same thing. > > So rather than removing every trace of the word "slave", how about > > instead we go the other way: use it in so many contexts that it loses > > its sting everywhere except when referring to humans. In fact, make it > > such that a human slave is "a person being treated like a computer", > > and thus obviously lacking in basic human rights. > > How about we also plaster the swastika (another symbol that carries > "another meaning") all over everything, all while insisting that it's > just a good luck symbol and that it shouldn't be associated with Nazis > forever, and force anybody who finds it offensive to "get over it" or > suffer in silence. I don't mean to Godwin the thread, but this is no > different than what you're proposing. Only if you can demonstrate that you're using it in a technically-accurate way. > Also: a human slave is not "a person being treated like a computer" > and I find it highly disrespectful that you would move to trivialize > slavery like that. Actually, if a human slave is being treated as someone who has no will, no autonomy, no power to choose anything, s/he IS being treated as a computer, and my point is to highlight that. Think about how you treat your computers - you have the power to discard them if they do not work correctly, or even if you just want to get a newer one. You have the power to kick them across the room and nobody will arrest you. Maybe you don't do those things (I would hope you don't kick computers around), but the computer has no say in that. Am I trivializing slavery? Or am I using a descriptive term that is actually more accurate than you dare acknowledge? ChrisA From David.Raymond at tomtom.com Wed Sep 26 15:54:46 2018 From: David.Raymond at tomtom.com (David Raymond) Date: Wed, 26 Sep 2018 19:54:46 +0000 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: ...Think about how you treat your computers - you have the power to discard them if they do not work correctly, or even if you just want to get a newer one. You have the power to kick them across the room and nobody will arrest you. Maybe you don't do those things (I would hope you don't kick computers around), but the computer has no say in that... ...At least, not yet... HAL.open(ship.pod_bay.doors) From dan at djph.net Wed Sep 26 16:05:05 2018 From: dan at djph.net (Dan Purgert) Date: Wed, 26 Sep 2018 20:05:05 -0000 (UTC) Subject: [OT] master/slave debate in Python References: Message-ID: David Raymond wrote: > [...] > HAL.open(ship.pod_bay.doors) I'm sorry Dave, I'm afraid I can't do that. -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281 From larry.martell at gmail.com Wed Sep 26 17:07:07 2018 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 26 Sep 2018 17:07:07 -0400 Subject: [OT] master/slave debate in Python In-Reply-To: <1537951284.1656.7.camel@gmail.com> References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> <1537951284.1656.7.camel@gmail.com> Message-ID: On Wed, Sep 26, 2018 at 4:41 AM, Brian Oney via Python-list wrote: > "I have a vewwy great fwiend in Wome called 'Biggus Dickus'" > ... > "Can I go now, sir?" He has a wife, you know. You know what she's called? She's called... 'Incontinentia'. 'Incontinentia Buttocks'. From rosuav at gmail.com Wed Sep 26 17:07:26 2018 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 27 Sep 2018 07:07:26 +1000 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: On Thu, Sep 27, 2018 at 7:05 AM Ian Kelly wrote: > > On Tue, Sep 25, 2018 at 10:48 PM Chris Angelico wrote: > > > > On Wed, Sep 26, 2018 at 2:36 PM Ian Kelly wrote: > > > So, Chris, what have *you personally* done about real slavery where it > > > still happens? > > > > > > If, as I'm guessing, the answer is "nothing" then it seems to me that > > > you don't have much of a leg to stand on to level this accusation. > > > > Am I demanding that the terminology be changed? No? Then I don't think > > the accusation applies. > > You're objecting to people trying to do *something* positive on the > grounds that they're not doing *more* while you yourself are doing > *nothing*. That's pretty hypocritical. You're assuming that it's something positive that's being done. That is an unproven assertion. I'm objecting to people creating churn on the grounds that they're not accomplishing anything. ChrisA From ian.g.kelly at gmail.com Wed Sep 26 17:43:51 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 26 Sep 2018 15:43:51 -0600 Subject: [OT] master/slave debate in Python In-Reply-To: References: Message-ID: On Wed, Sep 26, 2018 at 3:10 PM Brian Grawburg wrote: > > This is right next to the objection of the use male and female to describe the two parts of a connector. I lament that snowflakes and such are trying desperately to enforce their quest for radical egalitarianism and see hidden agendas behind just about everything---except their own, of course. The only person who has said *anything* about "hidden agendas" here is you. Projecting much? From nad at python.org Wed Sep 26 22:21:30 2018 From: nad at python.org (Ned Deily) Date: Wed, 26 Sep 2018 22:21:30 -0400 Subject: [RELEASE] Python 3.7.1rc1 and 3.6.7rc1 now available for testing Message-ID: <5C0A8514-FE4D-46DB-A4A3-8EC5F36D8F9B@python.org> Python 3.7.1rc1 and 3.6.7rc1 are now available. 3.7.1rc1 is the release preview of the first maintenance release of Python 3.7, the latest feature release of Python. 3.6.7rc1 is the release preview of the next maintenance release of Python 3.6, the previous feature release of Python. Assuming no critical problems are found prior to 2018-10-06, no code changes are planned between these release candidates and the final releases. These release candidates are intended to give you the opportunity to test the new security and bug fixes in 3.7.1 and 3.6.7. We strongly encourage you to test your projects and report issues found to bugs.python.org as soon as possible. Please keep in mind that these are preview releases and, thus, their use is not recommended for production environments. You can find these releases and more information here: https://www.python.org/downloads/release/python-371rc1/ https://www.python.org/downloads/release/python-367rc1/ -- Ned Deily nad at python.org -- [] From Cecil at decebal.nl Thu Sep 27 01:14:47 2018 From: Cecil at decebal.nl (Cecil Westerhof) Date: Thu, 27 Sep 2018 07:14:47 +0200 Subject: ipython and prompt-toolkit Message-ID: <87efdfjzco.fsf@munus.decebal.nl> For a long time I cannot update prompt-toolkit, because ipython requires a version lower as 2. That is why I still use 1.0.15 instead of 2.0.4. Any chance that ipython will be updated concerning this dependency? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From john_ladasky at sbcglobal.net Thu Sep 27 04:00:36 2018 From: john_ladasky at sbcglobal.net (John Ladasky) Date: Thu, 27 Sep 2018 01:00:36 -0700 (PDT) Subject: clever exit of nested loops In-Reply-To: References: Message-ID: On Wednesday, September 26, 2018 at 12:50:20 AM UTC-7, vito.d... at gmail.com wrote: > I have "abused" the "else" clause of the loops to makes a break "broke" more loops I did this once upon a time. In recent years, when I start writing tricky nested loops, I frequently find myself reaching for itertools.product() to flatten the loops instead. This code accomplishes the same task as yours. I'll leave it to you to decide whether you prefer it. There are things that I dislike about it, but the flow control part is clear. from itertools import product msgs = ("i: {}", "\tj: {}", "\t\tk: {}") old = 3*[None] for new in product(range(10), repeat=3): for n, (msg, changed) in enumerate(zip(msgs, [x!=y for x, y in zip(old, new)])): if changed: print(msg.format(new[n])) if condition(*new): # your condition() took three separate arguments break old = new From auriocus at gmx.de Thu Sep 27 05:13:07 2018 From: auriocus at gmx.de (Christian Gollwitzer) Date: Thu, 27 Sep 2018 11:13:07 +0200 Subject: clever exit of nested loops In-Reply-To: References: Message-ID: Am 26.09.18 um 12:28 schrieb Bart: > On 26/09/2018 10:10, Peter Otten wrote: >> ???? class Break(Exception): >> ???????? pass >> >> ???? try: >> ???????? for i in range(10): >> ???????????? print(f'i: {i}') >> ???????????? for j in range(10): >> ???????????????? print(f'\tj: {j}') >> ???????????????? for k in range(10): >> ???????????????????? print(f'\t\tk: {k}') >> >> ???????????????????? if condition(i, j, k): >> ???????????????????????? raise Break >> ???? except Break: >> ???????? pass >> > > For all such 'solutions', the words 'sledgehammer' and 'nut' spring to > mind. > > Remember the requirement is very simple, to 'break out of a nested loop' > (and usually this will be to break out of the outermost loop). What > you're looking is a statement which is a minor variation on 'break'. Which is exactly what it does. "raise Break" is a minor variation on "break". > Not > to have to exercise your imagination in devising the most convoluted > code possible. To the contrary, I do think this solution looks not "convoluted" but rather clear. Also, in Python some other "exceptions" are used for a similar purpose - for example "StopIteration" to signal that an iterator is exhausted. One might consider to call these "signals" instead of "exceptions", because there is nothing exceptional, apart from the control flow. Christian From tjol at tjol.eu Thu Sep 27 06:27:38 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Thu, 27 Sep 2018 12:27:38 +0200 Subject: clever exit of nested loops In-Reply-To: References: Message-ID: On 2018-09-26 21:06, Mark Lawrence wrote: > > To me the Ned Batchelder presentation > https://www.youtube.com/watch?v=EnSu9hHGq5o "Loop like a Native" is the > definitive way on how to deal with loops in Python. > Hear, hear. Great talk. From ndbecker2 at gmail.com Thu Sep 27 06:41:55 2018 From: ndbecker2 at gmail.com (Neal Becker) Date: Thu, 27 Sep 2018 06:41:55 -0400 Subject: clever exit of nested loops References: Message-ID: Christian Gollwitzer wrote: > Am 26.09.18 um 12:28 schrieb Bart: >> On 26/09/2018 10:10, Peter Otten wrote: >>> class Break(Exception): >>> pass >>> >>> try: >>> for i in range(10): >>> print(f'i: {i}') >>> for j in range(10): >>> print(f'\tj: {j}') >>> for k in range(10): >>> print(f'\t\tk: {k}') >>> >>> if condition(i, j, k): >>> raise Break >>> except Break: >>> pass >>> >> >> For all such 'solutions', the words 'sledgehammer' and 'nut' spring to >> mind. >> >> Remember the requirement is very simple, to 'break out of a nested loop' >> (and usually this will be to break out of the outermost loop). What >> you're looking is a statement which is a minor variation on 'break'. > > Which is exactly what it does. "raise Break" is a minor variation on > "break". > >> Not >> to have to exercise your imagination in devising the most convoluted >> code possible. > > To the contrary, I do think this solution looks not "convoluted" but > rather clear. Also, in Python some other "exceptions" are used for a > similar purpose - for example "StopIteration" to signal that an iterator > is exhausted. One might consider to call these "signals" instead of > "exceptions", because there is nothing exceptional, apart from the > control flow. > > Christian > > I've done the same before myself (exit from nested blocks to a containing block using exception), but it does violate the principle "Exceptions should be used for exceptional conditions). From ajay.patel305 at gmail.com Thu Sep 27 07:23:49 2018 From: ajay.patel305 at gmail.com (Ajay Patel) Date: Thu, 27 Sep 2018 16:53:49 +0530 Subject: Which class method is being called when we declare below expression? Message-ID: Hello gauys, Which list class method will call for below codes? L = [1,2,3] And L =[] Thanks, Ajay From ian.g.kelly at gmail.com Thu Sep 27 09:10:34 2018 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 27 Sep 2018 07:10:34 -0600 Subject: [OT] master/slave debate in Python In-Reply-To: References: <5664d7bf-8125-439b-ad1e-027fe43331ec@chamonix.reportlab.co.uk> <033a6535-6fa6-8b76-eacb-fe4cf0768ba8@chamonix.reportlab.co.uk> <85123874-33c9-4959-39ef-9ecb4a3246c7@tjol.eu> Message-ID: On Wed, Sep 26, 2018 at 3:18 PM Chris Angelico wrote: > > On Thu, Sep 27, 2018 at 7:05 AM Ian Kelly wrote: > > > > You're objecting to people trying to do *something* positive on the > > grounds that they're not doing *more* while you yourself are doing > > *nothing*. That's pretty hypocritical. > > You're assuming that it's something positive that's being done. That > is an unproven assertion. I'm objecting to people creating churn on > the grounds that they're not accomplishing anything. The goal is promoting respect and dignity within the workplace, and more generally within our field. If you can't see how this advances that, then I have nothing further to say. You might ask yourself, though: why are you so invested in this that you would not only refuse to change anything yourself, but also would throw up a resistance when others try to make a simple documentation rewording? One other thing. This is difficult for me to respond to, but I feel it has to be done: > Actually, if a human slave is being treated as someone who has no > will, no autonomy, no power to choose anything, s/he IS being treated > as a computer, and my point is to highlight that. Think about how you > treat your computers - you have the power to discard them if they do > not work correctly, or even if you just want to get a newer one. You > have the power to kick them across the room and nobody will arrest > you. Maybe you don't do those things (I would hope you don't kick > computers around), but the computer has no say in that. Am I > trivializing slavery? Or am I using a descriptive term that is > actually more accurate than you dare acknowledge? Yes, you can kick your computer across the room if it's not working. The difference with a computer is that you don't have to; computers are never willfully disobedient. Computers never have to be "broken" in order to have value. Computers also don't have feelings or experience pain. You can't punish a defiant computer by whipping it, or starving it, or preventing it from sleeping, or making it sit in its own waste. You can't punish it by separating it from its family or keeping it in total isolation. You can't even just sell its family to another computer-owner without even considering how it will feel about that. You can't force a computer to adopt your own religion. You can't lie to your computer in order to manipulate it. You can't make it a promise of freedom that you know you will never keep. If you think that a slave just means somebody who has no choice but to do what they're told, then yes, I think that you're trivializing the condition of slavery, and by comparing the victim to a simple object like a computer, the very language that you're choosing is dehumanizing. From cl at isbd.net Thu Sep 27 12:47:54 2018 From: cl at isbd.net (Chris Green) Date: Thu, 27 Sep 2018 17:47:54 +0100 Subject: What's needed for jpegtran in Python 3? Message-ID: I'm converting an existing Python2 program to Python3, it uses jpegtran and I can't find what to install to get this in Python3. Can anyone advise what I need to install in Python3? -- Chris Green ? From rosuav at gmail.com Thu Sep 27 13:06:22 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 28 Sep 2018 03:06:22 +1000 Subject: What's needed for jpegtran in Python 3? In-Reply-To: References: Message-ID: On Fri, Sep 28, 2018 at 2:51 AM Chris Green wrote: > > I'm converting an existing Python2 program to Python3, it uses > jpegtran and I can't find what to install to get this in Python3. > > Can anyone advise what I need to install in Python3? > Do you mean this? https://pypi.org/project/jpegtran-cffi/ I can't find anything called just "jpegtran" for either Py2 or Py3, but that one claims to work on 3.3+ as well as 2.6 and 2.7. ChrisA From cl at isbd.net Thu Sep 27 13:45:42 2018 From: cl at isbd.net (Chris Green) Date: Thu, 27 Sep 2018 18:45:42 +0100 Subject: What's needed for jpegtran in Python 3? References: Message-ID: <6jhv7f-o37.ln1@esprimo.zbmc.eu> Chris Angelico wrote: > On Fri, Sep 28, 2018 at 2:51 AM Chris Green wrote: > > > > I'm converting an existing Python2 program to Python3, it uses > > jpegtran and I can't find what to install to get this in Python3. > > > > Can anyone advise what I need to install in Python3? > > > > Do you mean this? > > https://pypi.org/project/jpegtran-cffi/ > > I can't find anything called just "jpegtran" for either Py2 or Py3, > but that one claims to work on 3.3+ as well as 2.6 and 2.7. > I think that must be what I have already installed, it doesn't make the module available in Python 3, it just says this when I try and install it:- root at t470:~# pip install jpegtran-cffi Requirement already satisfied: jpegtran-cffi in /usr/local/lib/python2.7/dist-packages Requirement already satisfied: cffi>=0.8 in /usr/lib/python2.7/dist-packages (from jpegtran-cffi) root at t470:~# Python 3 isn't going to find that is it? When I run my program it says:- chris$ picimport.py Traceback (most recent call last): File "/home/chris/bin/picimport.py", line 28, in from jpegtran import JPEGImage ModuleNotFoundError: No module named 'jpegtran' chris$ -- Chris Green ? From rosuav at gmail.com Thu Sep 27 13:55:25 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 28 Sep 2018 03:55:25 +1000 Subject: What's needed for jpegtran in Python 3? In-Reply-To: <6jhv7f-o37.ln1@esprimo.zbmc.eu> References: <6jhv7f-o37.ln1@esprimo.zbmc.eu> Message-ID: On Fri, Sep 28, 2018 at 3:51 AM Chris Green wrote: > > Chris Angelico wrote: > > On Fri, Sep 28, 2018 at 2:51 AM Chris Green wrote: > > > > > > I'm converting an existing Python2 program to Python3, it uses > > > jpegtran and I can't find what to install to get this in Python3. > > > > > > Can anyone advise what I need to install in Python3? > > > > > > > Do you mean this? > > > > https://pypi.org/project/jpegtran-cffi/ > > > > I can't find anything called just "jpegtran" for either Py2 or Py3, > > but that one claims to work on 3.3+ as well as 2.6 and 2.7. > > > I think that must be what I have already installed, it doesn't make > the module available in Python 3, it just says this when I try and > install it:- > > root at t470:~# pip install jpegtran-cffi > Requirement already satisfied: jpegtran-cffi in /usr/local/lib/python2.7/dist-packages > Requirement already satisfied: cffi>=0.8 in /usr/lib/python2.7/dist-packages (from jpegtran-cffi) > root at t470:~# > > Python 3 isn't going to find that is it? Ah! Correct. What you need to do is use pip from your Python 3 installation. The safest way is: python3 -m pip install jpegtran-cffi but you may be able to abbreviate it to just: pip3 install jpegtran-cffi ie just change "pip" to "pip3". ChrisA From john_ladasky at sbcglobal.net Thu Sep 27 14:03:56 2018 From: john_ladasky at sbcglobal.net (John Ladasky) Date: Thu, 27 Sep 2018 11:03:56 -0700 (PDT) Subject: What's needed for jpegtran in Python 3? In-Reply-To: <6jhv7f-o37.ln1@esprimo.zbmc.eu> References: <6jhv7f-o37.ln1@esprimo.zbmc.eu> Message-ID: <4bd1742c-1440-4666-b8c7-d8806351cb51@googlegroups.com> On Thursday, September 27, 2018 at 10:48:16 AM UTC-7, Chris Green wrote: > I think that must be what I have already installed, it doesn't make > the module available in Python 3, it just says this when I try and > install it:- > > root at t470:~# pip install jpegtran-cffi > Requirement already satisfied: jpegtran-cffi in /usr/local/lib/python2.7/dist-packages > Requirement already satisfied: cffi>=0.8 in /usr/lib/python2.7/dist-packages (from jpegtran-cffi) > root at t470:~# > > Python 3 isn't going to find that is it? When I run my program it > says:- > > chris$ picimport.py > Traceback (most recent call last): > File "/home/chris/bin/picimport.py", line 28, in > from jpegtran import JPEGImage > ModuleNotFoundError: No module named 'jpegtran' > chris$ It appears that you are working in Linux. Many of the command-line Linux utilities are written in Python 2.7. In a few years that may change, for now Py 2.7 is the system Python. On a Linux system, when you type "python" you will start the system's Py 2.7 interpreter. When you type "pip" you will start the installer for Py 2.7. So you installed jpegtran, but you installed it for Py 2.7. Linux (Ubuntu, at least, I'm not sure about other distros) also ships with a version of Python 3, but it's not the default. If you want to invoke Py 3.x from a Linux command prompt, you need to type "python3". If you want to install packages for your Python 3 platform, you need to install python3-pip, a system package which is not included in (Ubuntu) Linux by default. You can access that package from the command line by typing "pip3" where you would have typed "pip". It's good that you want to use Py 3, in a few years the changeover will be complete. The one thing you did not show was your text for picimport.py, which I expect is trying to use Py 3. From cl at isbd.net Thu Sep 27 14:07:59 2018 From: cl at isbd.net (Chris Green) Date: Thu, 27 Sep 2018 19:07:59 +0100 Subject: JPEGImage() hangs Message-ID: I have a program which uses jpegtran-cffi 0.5.2 and, while it seems to work OK most of the time it's hanging very solidly on one jpeg file which seems to be OK when viewed with other programs. I'm simply doing:- img = JPEGImage(srcFullFn) I have checked that that srcFullFn points to a real jpeg file and I have checked that it's actually a jpeg:- chris$ file 102_PANA/P1020466.JPG 102_PANA/P1020466.JPG: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=15, manufacturer=Panasonic, model=DMC-TZ60, orientation=upper-left, xresolution=214, yresolution=222, resolutionunit=2, software=Ver.1.0 , datetime=2018:09:26 10:55:31], baseline, precision 8, 4896x3672, frames 3 Even running in the Python console hangs:- chris$ python Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from jpegtran import JPEGImage >>> x = JPEGImage("102_PANA/P1020466.JPG") ... and that's it, CTRL/C and CTRL/Z won't break it, I have to 'kill -9' the process Does anyone have any idea what may be wrong? -- Chris Green ? From brian.j.oney at googlemail.com Thu Sep 27 16:37:15 2018 From: brian.j.oney at googlemail.com (Brian Oney) Date: Thu, 27 Sep 2018 22:37:15 +0200 Subject: JPEGImage() hangs In-Reply-To: References: Message-ID: <1538080635.2728.1.camel@gmail.com> Could you please try another tool like `convert'? E.g. $ convert 102_PANA/P1020466.JPG test.png What does that say? From rosuav at gmail.com Thu Sep 27 18:55:07 2018 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 28 Sep 2018 08:55:07 +1000 Subject: Which class method is being called when we declare below expression? In-Reply-To: References: Message-ID: On Fri, Sep 28, 2018 at 8:52 AM Ajay Patel wrote: > > Hello gauys, > > Which list class method will call for below codes? > > L = [1,2,3] > And > L =[] None. Simple assignment does not call any methods. It just takes the value on the right hand side and says, hey, "L", you now mean that thing, k? k. :) With *augmented* assignment (eg "x += 1"), there are methods that get called, and with non-assignment operators (eg "x + 1"), similarly. Generally the left hand side defines the behaviour. But simple assignment is defined purely within the language, as are a handful of other operators ("x is y", "x and y"). Keeps things simple and predictable! ChrisA From tjol at tjol.eu Thu Sep 27 19:24:42 2018 From: tjol at tjol.eu (Thomas Jollans) Date: Fri, 28 Sep 2018 01:24:42 +0200 Subject: ipython and prompt-toolkit In-Reply-To: <87efdfjzco.fsf@munus.decebal.nl> References: <87efdfjzco.fsf@munus.decebal.nl> Message-ID: <0e93dc9e-4236-7d57-d974-a05c74b29585@tjol.eu> On 27/09/2018 07:14, Cecil Westerhof wrote: > For a long time I cannot update prompt-toolkit, because ipython > requires a version lower as 2. That is why I still use 1.0.15 instead > of 2.0.4. Any chance that ipython will be updated concerning this > dependency? > Well this is an interesting coincidence! I just had a look, and it turns out that the IPython 7.0 branch uses prompt_toolkit 2.0 (the change[1] is dated 29 December 2017). IPython 7.0 was released just a few hours ago, shortly after you sent this mail! [1] https://github.com/ipython/ipython/commit/8e256bd37373f98580ba1ef1d3fcfd7976802238 From greg.ewing at canterbury.ac.nz Thu Sep 27 19:43:21 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Fri, 28 Sep 2018 11:43:21 +1200 Subject: clever exit of nested loops In-Reply-To: References: Message-ID: Neal Becker wrote: > but it does violate the principle "Exceptions should > be used for exceptional conditions). Python doesn't really go in for that philosophy. Exceptions are often used for flow control, e.g. StopIteration. -- Greg From jfong at ms4.hinet.net Thu Sep 27 23:49:43 2018 From: jfong at ms4.hinet.net (Jach Fong) Date: Fri, 28 Sep 2018 11:49:43 +0800 Subject: How to change '\\' to '\' Message-ID: I get a string item, for example path[0], from path = os.get_exec_path() It's something like "\\Borland\\Bcc55\\Include", a Python string. I want to use this "string" in a subprocess command as a parameter. Obviously this command can only recognize "\Borland\Bcc55\Include". I know there must have an easy way to convert it, but just can't figure it out:-( --Jach --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From greg.ewing at canterbury.ac.nz Fri Sep 28 02:02:50 2018 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Fri, 28 Sep 2018 18:02:50 +1200 Subject: How to change '\\' to '\' In-Reply-To: References: Message-ID: Jach Fong wrote: > I get a string item, for example path[0], from path = os.get_exec_path() > It's something like "\\Borland\\Bcc55\\Include" It doesn't actually have double backslashes in it, that's just a result of how the string is being displayed. No conversion is needed. -- Greg From ben+python at benfinney.id.au Fri Sep 28 02:29:09 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 28 Sep 2018 16:29:09 +1000 Subject: Which class method is being called when we declare below expression? References: Message-ID: <86bm8i5e4q.fsf@benfinney.id.au> Ajay Patel writes: > L = [1,2,3] That's not an expression; it is an assignment statement. The right-hand side is an expression. It will (at the top level) create a list. To create a new instance of the 'list' type, Python will call the type's '__new__' method. This is termed the constructor for that type. The constructor returns a new instance of the type; in this case, it returns a new instance of 'list'. That object is the result of evaluating the right-hand side of the expression. The statement then assigns the reference 'L' to that object. > And > L =[] All the above description also applies to that assignment statement. -- \ ?If you go parachuting, and your parachute doesn't open, and | `\ you friends are all watching you fall, I think a funny gag | _o__) would be to pretend you were swimming.? ?Jack Handey | Ben Finney From jfong at ms4.hinet.net Fri Sep 28 03:42:36 2018 From: jfong at ms4.hinet.net (Jach Fong) Date: Fri, 28 Sep 2018 15:42:36 +0800 Subject: How to change '\\' to '\' In-Reply-To: References: Message-ID: <49556cf8-34c3-d5cb-1cef-ec13ab7de8fa@ms4.hinet.net> Yes, you are right, it's just the way Python display the '\'. Thank you. Gregory Ewing at 2018/9/28 PM 02:02 wrote: > Jach Fong wrote: >> I get a string item, for example path[0], from path = os.get_exec_path() >> It's something like "\\Borland\\Bcc55\\Include" > > It doesn't actually have double backslashes in it, that's just a > result of how the string is being displayed. No conversion is > needed. > --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From cl at isbd.net Fri Sep 28 09:24:44 2018 From: cl at isbd.net (Chris Green) Date: Fri, 28 Sep 2018 14:24:44 +0100 Subject: What's needed for jpegtran in Python 3? References: <6jhv7f-o37.ln1@esprimo.zbmc.eu> Message-ID: Chris Angelico wrote: > On Fri, Sep 28, 2018 at 3:51 AM Chris Green wrote: > > > > Chris Angelico wrote: > > > On Fri, Sep 28, 2018 at 2:51 AM Chris Green wrote: > > > > > > > > I'm converting an existing Python2 program to Python3, it uses > > > > jpegtran and I can't find what to install to get this in Python3. > > > > > > > > Can anyone advise what I need to install in Python3? > > > > > > > > > > Do you mean this? > > > > > > https://pypi.org/project/jpegtran-cffi/ > > > > > > I can't find anything called just "jpegtran" for either Py2 or Py3, > > > but that one claims to work on 3.3+ as well as 2.6 and 2.7. > > > > > I think that must be what I have already installed, it doesn't make > > the module available in Python 3, it just says this when I try and > > install it:- > > > > root at t470:~# pip install jpegtran-cffi > > Requirement already satisfied: jpegtran-cffi in /usr/local/lib/python2.7/dist-packages > > Requirement already satisfied: cffi>=0.8 in /usr/lib/python2.7/dist-packages > (from jpegtran-cffi) > > root at t470:~# > > > > Python 3 isn't going to find that is it? > > Ah! Correct. What you need to do is use pip from your Python 3 > installation. The safest way is: > > python3 -m pip install jpegtran-cffi > > but you may be able to abbreviate it to just: > > pip3 install jpegtran-cffi > > ie just change "pip" to "pip3". > OK, yes, after a bit of trouble (I needed python3-cffi as well) I've got it installed now, thank you! -- Chris Green ? From grant.b.edwards at gmail.com Fri Sep 28 09:31:02 2018 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 28 Sep 2018 13:31:02 +0000 (UTC) Subject: cx_Freeze window app path question Message-ID: [I tried without success to post this question to the cx_Freeze mailing list (which seems to have suddenly died at the beginning of the year).] You freeze an app on Windows producing a 'build' directory. The contents of that build directory get installed in some arbitrary location. When you run the .exe from that arbitrary location, is it guaranteed that it won't try to find/use python modules or libraries from outside that installed build directory tree? -- Grant Edwards grant.b.edwards Yow! As President I have at to go vacuum my coin gmail.com collection! From cl at isbd.net Fri Sep 28 09:40:32 2018 From: cl at isbd.net (Chris Green) Date: Fri, 28 Sep 2018 14:40:32 +0100 Subject: JPEGImage() hangs References: <1538080635.2728.1.camel@gmail.com> Message-ID: Brian Oney wrote: > Could you please try another tool like `convert'? E.g. > > $ convert 102_PANA/P1020466.JPG test.png > > > What does that say? Well, after having returned home with the laptop where this was failing and doing exactly the same thing again, it now works. However it did take several seconds before the >>> prompt appeared. The problem seems to be intermittent as I'm calling the function while importing images from a camera SD card and, sometimes, the import hangs but most times it works OK. I'll see if I can see anything common to when it hangs. -- Chris Green ? From cl at isbd.net Fri Sep 28 10:01:41 2018 From: cl at isbd.net (Chris Green) Date: Fri, 28 Sep 2018 15:01:41 +0100 Subject: JPEGImage() hangs References: <1538080635.2728.1.camel@gmail.com> Message-ID: <5ro18f-n4f.ln1@esprimo.zbmc.eu> Chris Green wrote: > Brian Oney wrote: > > Could you please try another tool like `convert'? E.g. > > > > $ convert 102_PANA/P1020466.JPG test.png > > > > > > What does that say? > > Well, after having returned home with the laptop where this was > failing and doing exactly the same thing again, it now works. However > it did take several seconds before the >>> prompt appeared. > > The problem seems to be intermittent as I'm calling the function while > importing images from a camera SD card and, sometimes, the import > hangs but most times it works OK. > > I'll see if I can see anything common to when it hangs. > ... and the result is that it now hangs several images later in the sequence! It's almost as if some resource is running out. If I try convert on the 'problem' image it too hangs absolutely solidly needing a 'kill -9'. After some experimentation.... OK, it's some sort of file accessibility problem between the SD card and the computer:- Running 'convert 102_PANA/P1020493.JPG /tmp/xyz.png' hangs So 'kill -9' the convert Run 'cp 102_PANA/P1020493.JPG /tmp/fred' takes several seconds but returns Running 'convert 102_PANA/P1020493.JPG /tmp/xyz.png' now works My python program that uses jpegtran now also works OK Wierd! However it would seem it's not an issue with Python or the jpegtran module. -- Chris Green ? From mal at europython.eu Fri Sep 28 10:09:11 2018 From: mal at europython.eu (M.-A. Lemburg) Date: Fri, 28 Sep 2018 16:09:11 +0200 Subject: EuroPython 2019: RFP for Venues Message-ID: <7e058e60-fc5b-5c34-d7ea-6602f84ec0c2@europython.eu> Dear EuroPython'istas, We are happy to announce that we have started the RFP for venues to host the EuroPython 2019 conference. We have sent out the details to almost 40 venues. For more details about the RFP, please see our blog post: https://www.europython-society.org/post/178541594370/europython-2019-rfp-for-venues Many thanks to everyone who had submitted contact details and venue suggestions after our call. We have tried to include all of them in the list of direct recipients. Feel free to forward the blog post to additional suitable venues. Many thanks, -- EuroPython Society Board https://www.europython-society.org/ From praveenjain04121997 at gmail.com Fri Sep 28 13:07:00 2018 From: praveenjain04121997 at gmail.com (praveenjain04121997 at gmail.com) Date: Fri, 28 Sep 2018 10:07:00 -0700 (PDT) Subject: I am not able to run Python in Powershell In-Reply-To: References: Message-ID: <2d35795c-353c-4811-a3ea-8057d1e07a7c@googlegroups.com> On Friday, 1 September 2017 19:37:41 UTC+1, The Cat Gamer wrote: > fter I installed Python I try to open it in Powershell, by typing > python/python.exe. > It gives me an error: > python : The term 'python' is not recognized as the name of a cmdlet, > function, script file, or operable program. Check the spelling of the name, > or if a path was included, verify that the path is correct and try again. > At line:1 char:1 > + python > + ~~~~~~ > + CategoryInfo : ObjectNotFound: (python:String) [], > CommandNotFoundException > + FullyQualifiedErrorId : CommandNotFoundException > This happens with version 3 and version 2. The newest versions and the > older versions none of them makes me able to open Python in Windows > Powershell. Are you guys aware of a fix? > > (I already tried the environment fix and that didnt work as well) From cl at isbd.net Fri Sep 28 14:00:29 2018 From: cl at isbd.net (Chris Green) Date: Fri, 28 Sep 2018 19:00:29 +0100 Subject: What's an elegant way to test for list index existing? Message-ID: I have a list created by:- fld = shlex.split(ln) It may contain 3, 4 or 5 entries according to data read into ln. What's the neatest way of setting the fourth and fifth entries to an empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels clumsy somehow. -- Chris Green ? From pkpearson at nowhere.invalid Fri Sep 28 14:08:31 2018 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 28 Sep 2018 18:08:31 GMT Subject: JPEGImage() hangs References: <1538080635.2728.1.camel@gmail.com> <5ro18f-n4f.ln1@esprimo.zbmc.eu> Message-ID: On Fri, 28 Sep 2018 15:01:41 +0100, Chris Green wrote: > Chris Green wrote: >> Brian Oney wrote: >> > Could you please try another tool like `convert'? E.g. >> > >> > $ convert 102_PANA/P1020466.JPG test.png >> > >> > >> > What does that say? >> >> Well, after having returned home with the laptop where this was >> failing and doing exactly the same thing again, it now works. However >> it did take several seconds before the >>> prompt appeared. >> >> The problem seems to be intermittent as I'm calling the function while >> importing images from a camera SD card and, sometimes, the import >> hangs but most times it works OK. >> >> I'll see if I can see anything common to when it hangs. >> > ... and the result is that it now hangs several images later in the > sequence! It's almost as if some resource is running out. > > If I try convert on the 'problem' image it too hangs absolutely > solidly needing a 'kill -9'. > > After some experimentation.... OK, it's some sort of file > accessibility problem between the SD card and the computer:- > > Running 'convert 102_PANA/P1020493.JPG /tmp/xyz.png' hangs > > So 'kill -9' the convert > > Run 'cp 102_PANA/P1020493.JPG /tmp/fred' takes several seconds but returns [snip] If copying that particular file takes longer than copying other files, I'd start to suspect that it's stored in a failing spot in memory. Is 102_PANA/P1020493.JPG being read from a camera's flash memory? Does "convert" hang on /tmp/fred? Does 102_PANA/P1020493.JPG have an unusual size? Can you use smartctl to ask the storage device if it's encountering many errors? -- To email me, substitute nowhere->runbox, invalid->com. From cl at isbd.net Fri Sep 28 15:12:15 2018 From: cl at isbd.net (Chris Green) Date: Fri, 28 Sep 2018 20:12:15 +0100 Subject: JPEGImage() hangs References: <1538080635.2728.1.camel@gmail.com> <5ro18f-n4f.ln1@esprimo.zbmc.eu> Message-ID: Peter Pearson wrote: > On Fri, 28 Sep 2018 15:01:41 +0100, Chris Green wrote: > > Chris Green wrote: > >> Brian Oney wrote: > >> > Could you please try another tool like `convert'? E.g. > >> > > >> > $ convert 102_PANA/P1020466.JPG test.png > >> > > >> > > >> > What does that say? > >> > >> Well, after having returned home with the laptop where this was > >> failing and doing exactly the same thing again, it now works. However > >> it did take several seconds before the >>> prompt appeared. > >> > >> The problem seems to be intermittent as I'm calling the function while > >> importing images from a camera SD card and, sometimes, the import > >> hangs but most times it works OK. > >> > >> I'll see if I can see anything common to when it hangs. > >> > > ... and the result is that it now hangs several images later in the > > sequence! It's almost as if some resource is running out. > > > > If I try convert on the 'problem' image it too hangs absolutely > > solidly needing a 'kill -9'. > > > > After some experimentation.... OK, it's some sort of file > > accessibility problem between the SD card and the computer:- > > > > Running 'convert 102_PANA/P1020493.JPG /tmp/xyz.png' hangs > > > > So 'kill -9' the convert > > > > Run 'cp 102_PANA/P1020493.JPG /tmp/fred' takes several seconds but returns > [snip] > > If copying that particular file takes longer than copying other files, > I'd start to suspect that it's stored in a failing spot in memory. Is > 102_PANA/P1020493.JPG being read from a camera's flash memory? Does > "convert" hang on /tmp/fred? Does 102_PANA/P1020493.JPG have an unusual > size? Can you use smartctl to ask the storage device if it's > encountering many errors? > Thanks, that sounds like a good explanation. The SD card has been in use for quite a while so it might have some problems. I think I'll retire it and see how things go. -- Chris Green ? From jladasky at itu.edu Fri Sep 28 17:35:38 2018 From: jladasky at itu.edu (jladasky at itu.edu) Date: Fri, 28 Sep 2018 14:35:38 -0700 (PDT) Subject: What's an elegant way to test for list index existing? In-Reply-To: References: Message-ID: <2be83e60-9807-4117-88c2-d2c8c3a497fb@googlegroups.com> On Friday, September 28, 2018 at 11:03:17 AM UTC-7, Chris Green wrote: > I have a list created by:- > > fld = shlex.split(ln) > > It may contain 3, 4 or 5 entries according to data read into ln. > What's the neatest way of setting the fourth and fifth entries to an > empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels > clumsy somehow. How about this? from itertools import chain, repeat temp = shlex.split(ln) fld = list(chain(temp, repeat("", 5-len(temp)))) From rowen at uw.edu Fri Sep 28 20:29:15 2018 From: rowen at uw.edu (Russell Owen) Date: Fri, 28 Sep 2018 17:29:15 -0700 Subject: Anaconda with Python 3.7 References: <5B8D0122.1030408@gmail.com> Message-ID: <0001HW.215EFEDB05E2601C700000A242CF@news.gmane.org> On Sep 3, 2018, gvim wrote (in article <5B8D0122.1030408 at gmail.com>): > Anyone have any idea when Anaconda might ship a version compatible with > Python 3.7. I sent them 2 emails but no reply. I heard a rumor today that it will be a few more months. They are short on resources and are also dealing with issues with dependency management. In any case miniconda is available for 3.7 so it is worth checking to see if it has the packages that you need. (And if it?s just missing a few you can see if pip will install those). -- Russell From cs at cskk.id.au Fri Sep 28 22:04:42 2018 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 29 Sep 2018 12:04:42 +1000 Subject: JPEGImage() hangs In-Reply-To: References: Message-ID: <20180929020442.GA91566@cskk.homeip.net> On 28Sep2018 20:12, Chris Green wrote: >Peter Pearson wrote: >> On Fri, 28 Sep 2018 15:01:41 +0100, Chris Green wrote: >> > Chris Green wrote: >> >> Brian Oney wrote: >> >> > Could you please try another tool like `convert'? E.g. >> >> > >> >> > $ convert 102_PANA/P1020466.JPG test.png >> >> > >> >> > What does that say? >> >> >> >> Well, after having returned home with the laptop where this was >> >> failing and doing exactly the same thing again, it now works. However >> >> it did take several seconds before the >>> prompt appeared. >> >> >> >> The problem seems to be intermittent as I'm calling the function while >> >> importing images from a camera SD card and, sometimes, the import >> >> hangs but most times it works OK. Can you separate the conversion from the copy? Copy the images off, run convert against the copies? That would give you more info as to whether it was the copy (implying an issue with the SD card as Peter suggests) or some pathologial image data (eg spinning out convert). Also, you can strace the hanging process; I'm a big fan of this for diagnostic purposes. A "hanging" process will normally be either spinning (using lots of CPU, or a mix of CPU and OS calls), or blocked (using no CPU at all while it waits for a OS call to complete). If it is blocked doing a read() then you immediately suspect the device from which the read is taking place. WRT to the strace, find the pid with "ps" then: strace -p pid-of-process It is usually astonishingly helpful in telling you about the underlying activity causing the problem. Also, if the SD card is emitting errors these should show in the output of dmesg. (OTOH if the SD cards internals are taking forever, perhaps doing repeated _internal_ access to the data) then this may not be apparent. Cheers, Cameron Simpson From rosuav at gmail.com Fri Sep 28 22:35:31 2018 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 29 Sep 2018 12:35:31 +1000 Subject: What's an elegant way to test for list index existing? In-Reply-To: References: Message-ID: On Sat, Sep 29, 2018 at 12:21 PM Chris Green wrote: > > I have a list created by:- > > fld = shlex.split(ln) > > It may contain 3, 4 or 5 entries according to data read into ln. > What's the neatest way of setting the fourth and fifth entries to an > empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels > clumsy somehow. shlex.split(ln) + ["", ""] ChrisA From ben+python at benfinney.id.au Fri Sep 28 23:08:58 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 29 Sep 2018 13:08:58 +1000 Subject: Which class method is being called when we declare below expression? References: <86bm8i5e4q.fsf@benfinney.id.au> Message-ID: <867ej557at.fsf@benfinney.id.au> Ben Finney writes: > Ajay Patel writes: > > > L = [1,2,3] > > That's not an expression; it is an assignment statement. > > The right-hand side is an expression. [?] in this case, [the object] a new > instance of 'list' [?] is the result of evaluating the right-hand side > of the expression. I goofed there. That should end with "[?] evaluating the expression on the right-hand side". > The statement then assigns the reference 'L' to that object. -- \ ?We have clumsy, sputtering, inefficient brains?. It is a | `\ *struggle* to be rational and objective, and failures are not | _o__) evidence for an alternative reality.? ?Paul Z. Myers, 2010-10-14 | Ben Finney From 2QdxY4RzWzUUiLuE at potatochowder.com Fri Sep 28 23:08:59 2018 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Fri, 28 Sep 2018 23:08:59 -0400 Subject: What's an elegant way to test for list index existing? In-Reply-To: References: Message-ID: <8688bbd7-1dda-62b5-d481-82b683ebb218@potatochowder.com> On 9/28/18 2:00 PM, Chris Green wrote: > I have a list created by:- > > fld = shlex.split(ln) > > It may contain 3, 4 or 5 entries according to data read into ln. > What's the neatest way of setting the fourth and fifth entries to an > empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels > clumsy somehow. Do you care whether there are more than 5 entries in the list? If not, then just add two empty strings to the end of the list: fld.extend(["", ""]) If fld already contained 5 entries, then the extra two empty strings may or may not affect the subsequent logic. If possible extra entries bother you, then truncate the list: fld = (fld + ["", ""])[:5] Or add empty strings as long as the list contains 5 entries: while len(fld) < 5: fld.append("") Which one is "better" or "best"? Your call, depending on what your criteria are. I think the last one expresses the intent the most clearly, but YMMV. From glenpop54 at gmail.com Sat Sep 29 01:33:58 2018 From: glenpop54 at gmail.com (Glen D souza) Date: Sat, 29 Sep 2018 11:03:58 +0530 Subject: What's an elegant way to test for list index existing? In-Reply-To: <2be83e60-9807-4117-88c2-d2c8c3a497fb@googlegroups.com> References: <2be83e60-9807-4117-88c2-d2c8c3a497fb@googlegroups.com> Message-ID: i have a approach, it may not be best fld = [ ] for data in shlex.split(ln): fld.append(data) On Sat, 29 Sep 2018 at 07:52, wrote: > On Friday, September 28, 2018 at 11:03:17 AM UTC-7, Chris Green wrote: > > I have a list created by:- > > > > fld = shlex.split(ln) > > > > It may contain 3, 4 or 5 entries according to data read into ln. > > What's the neatest way of setting the fourth and fifth entries to an > > empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels > > clumsy somehow. > > How about this? > > from itertools import chain, repeat > temp = shlex.split(ln) > fld = list(chain(temp, repeat("", 5-len(temp)))) > -- > https://mail.python.org/mailman/listinfo/python-list > From ben+python at benfinney.id.au Sat Sep 29 01:35:10 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 29 Sep 2018 15:35:10 +1000 Subject: What's an elegant way to test for list index existing? References: Message-ID: <86zhw050j5.fsf@benfinney.id.au> Chris Green writes: > I have a list created by:- > > fld = shlex.split(ln) > > It may contain 3, 4 or 5 entries according to data read into ln. Because of what an index means for the 'list' type, that's equivalent to saying "the result of `len(fld)` may be 3, 4, or 5". > What's the neatest way of setting the fourth and fifth entries to an > empty string if they don't (yet) exist? You have the right idea: testing the length of the object is a correct and expressive way to ask "is there an item at this index in the list". > Using 'if len(fld) < 4:' feels clumsy somehow. One reason I finx that clumsy is that you're testing against a hard-coded value; and you'd have to write a loop to get the value each time. You can use a comprehension, iterating over the full range of index you want:: words = shlex.split(line) padding_length = 5 words_padded = [ (words[index] if index < len(words)) for index in range(padding_length)] That accomplishes the construction of the padded list in a single expression, hopefully expressive, and definitely making use of whatever optimisations the in-built comprehension mechanics provide. -- \ ?Pray, v. To ask that the laws of the universe be annulled in | `\ behalf of a single petitioner confessedly unworthy.? ?Ambrose | _o__) Bierce, _The Devil's Dictionary_, 1906 | Ben Finney From glenpop54 at gmail.com Sat Sep 29 01:45:50 2018 From: glenpop54 at gmail.com (Glen D souza) Date: Sat, 29 Sep 2018 11:15:50 +0530 Subject: What's an elegant way to test for list index existing? In-Reply-To: References: <2be83e60-9807-4117-88c2-d2c8c3a497fb@googlegroups.com> Message-ID: fld = [ ] data = shlex.split(ln) for item in data: fld.append(item) fld = fld + [0] * (5 - len(data)) On Sat, 29 Sep 2018 at 11:03, Glen D souza wrote: > i have a approach, it may not be best > > fld = [ ] > for data in shlex.split(ln): > fld.append(data) > > > > On Sat, 29 Sep 2018 at 07:52, wrote: > >> On Friday, September 28, 2018 at 11:03:17 AM UTC-7, Chris Green wrote: >> > I have a list created by:- >> > >> > fld = shlex.split(ln) >> > >> > It may contain 3, 4 or 5 entries according to data read into ln. >> > What's the neatest way of setting the fourth and fifth entries to an >> > empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels >> > clumsy somehow. >> >> How about this? >> >> from itertools import chain, repeat >> temp = shlex.split(ln) >> fld = list(chain(temp, repeat("", 5-len(temp)))) >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From __peter__ at web.de Sat Sep 29 03:23:06 2018 From: __peter__ at web.de (Peter Otten) Date: Sat, 29 Sep 2018 09:23:06 +0200 Subject: What's an elegant way to test for list index existing? References: <2be83e60-9807-4117-88c2-d2c8c3a497fb@googlegroups.com> Message-ID: jladasky at itu.edu wrote: > On Friday, September 28, 2018 at 11:03:17 AM UTC-7, Chris Green wrote: >> I have a list created by:- >> >> fld = shlex.split(ln) >> >> It may contain 3, 4 or 5 entries according to data read into ln. >> What's the neatest way of setting the fourth and fifth entries to an >> empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels >> clumsy somehow. > > How about this? > > from itertools import chain, repeat > temp = shlex.split(ln) > fld = list(chain(temp, repeat("", 5-len(temp)))) If you are OK with silently dropping extra entries fld = list(islice(chain(shlex.split(ln), repeat("")), 5)) or its non-itertools equivalent fld = (shlex.split(ln) + [""] * 5)[:5] are also possible. Personally I consider none of these to be elegant. If you are going to unpack the fld entries I'd do it in a function with default values: >>> def use_args(foo, bar, baz, ham="", spam=""): ... print("\n".join("{} = {!r}".format(*p) for p in locals().items())) ... >>> use_args(*shlex.split("a b c")) spam = '' ham = '' baz = 'c' foo = 'a' bar = 'b' >>> use_args(*shlex.split("a b c d")) spam = '' ham = 'd' baz = 'c' foo = 'a' bar = 'b' This has the advantage that it fails for the unforeseen cases: >>> use_args(*shlex.split("a b c d e f")) Traceback (most recent call last): File "", line 1, in TypeError: use_args() takes from 3 to 5 positional arguments but 6 were given >>> use_args(*shlex.split("a b")) Traceback (most recent call last): File "", line 1, in TypeError: use_args() missing 1 required positional argument: 'baz' From cl at isbd.net Sat Sep 29 04:34:55 2018 From: cl at isbd.net (Chris Green) Date: Sat, 29 Sep 2018 09:34:55 +0100 Subject: JPEGImage() hangs References: <20180929020442.GA91566@cskk.homeip.net> Message-ID: Cameron Simpson wrote: > On 28Sep2018 20:12, Chris Green wrote: > >Peter Pearson wrote: > >> On Fri, 28 Sep 2018 15:01:41 +0100, Chris Green wrote: > >> > Chris Green wrote: > >> >> Brian Oney wrote: > >> >> > Could you please try another tool like `convert'? E.g. > >> >> > > >> >> > $ convert 102_PANA/P1020466.JPG test.png > >> >> > > >> >> > What does that say? > >> >> > >> >> Well, after having returned home with the laptop where this was > >> >> failing and doing exactly the same thing again, it now works. However > >> >> it did take several seconds before the >>> prompt appeared. > >> >> > >> >> The problem seems to be intermittent as I'm calling the function while > >> >> importing images from a camera SD card and, sometimes, the import > >> >> hangs but most times it works OK. > > Can you separate the conversion from the copy? Copy the images off, run convert > against the copies? That would give you more info as to whether it was the copy > (implying an issue with the SD card as Peter suggests) or some pathologial > image data (eg spinning out convert). > > Also, you can strace the hanging process; I'm a big fan of this for diagnostic > purposes. A "hanging" process will normally be either spinning (using lots of > CPU, or a mix of CPU and OS calls), or blocked (using no CPU at all while it > waits for a OS call to complete). If it is blocked doing a read() then you > immediately suspect the device from which the read is taking place. > It's blocked, I watched using top and it's using no CPU. So, definitely points at a dodgy SD card. -- Chris Green ? From cl at isbd.net Sat Sep 29 04:37:17 2018 From: cl at isbd.net (Chris Green) Date: Sat, 29 Sep 2018 09:37:17 +0100 Subject: What's an elegant way to test for list index existing? References: <86zhw050j5.fsf@benfinney.id.au> <8736ts26g2.fsf@nightsong.com> Message-ID: Thanks all, several possible ways of doing it there. -- Chris Green ? From alister.ware at ntlworld.com Sat Sep 29 05:27:10 2018 From: alister.ware at ntlworld.com (Alister) Date: Sat, 29 Sep 2018 09:27:10 GMT Subject: What's an elegant way to test for list index existing? References: Message-ID: On Fri, 28 Sep 2018 19:00:29 +0100, Chris Green wrote: > I have a list created by:- > > fld = shlex.split(ln) > > It may contain 3, 4 or 5 entries according to data read into ln. What's > the neatest way of setting the fourth and fifth entries to an empty > string if they don't (yet) exist? Using 'if len(fld) < 4:' feels clumsy > somehow. how about simply adding 2 or more null entries to the list then slicing? string = "a b c" a=string.split() (a+['',''])[0:5] -- QOTD: If you're looking for trouble, I can offer you a wide selection. From ben+python at benfinney.id.au Sat Sep 29 07:25:15 2018 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 29 Sep 2018 21:25:15 +1000 Subject: What's an elegant way to test for list index existing? References: <86zhw050j5.fsf@benfinney.id.au> Message-ID: <86tvm84kbo.fsf@benfinney.id.au> Ben Finney writes: > You can use a comprehension, iterating over the full range of index you > want:: > > words = shlex.split(line) > padding_length = 5 > words_padded = [ > (words[index] if index < len(words)) > for index in range(padding_length)] That omits the important case you were concerned with: when `index < len(words)` is false. In other words, that example fails to actually pad the resulting list. Try this instead:: words = shlex.split(line) padding_length = 5 padding_value = None words_padded = [ (words[index] if index < len(words) else padding_value) for index in range(padding_length)] -- \ ?When a well-packaged web of lies has been sold to the masses | `\ over generations, the truth will seem utterly preposterous and | _o__) its speaker a raving lunatic.? ?Dresden James | Ben Finney From __peter__ at web.de Sat Sep 29 08:10:42 2018 From: __peter__ at web.de (Peter Otten) Date: Sat, 29 Sep 2018 14:10:42 +0200 Subject: What's an elegant way to test for list index existing? References: <86zhw050j5.fsf@benfinney.id.au> <86tvm84kbo.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: > Ben Finney writes: > >> You can use a comprehension, iterating over the full range of index you >> want:: >> >> words = shlex.split(line) >> padding_length = 5 >> words_padded = [ >> (words[index] if index < len(words)) >> for index in range(padding_length)] > > That omits the important case you were concerned with: when `index < > len(words)` is false. In other words, that example fails to actually pad > the resulting list. It would if it weren't a syntax error. No harm done ;) > Try this instead:: > > words = shlex.split(line) > padding_length = 5 > padding_value = None > words_padded = [ > (words[index] if index < len(words) else padding_value) > for index in range(padding_length)] > From cspealma at redhat.com Sat Sep 29 09:45:38 2018 From: cspealma at redhat.com (Calvin Spealman) Date: Sat, 29 Sep 2018 09:45:38 -0400 Subject: I am not able to run Python in Powershell In-Reply-To: <2d35795c-353c-4811-a3ea-8057d1e07a7c@googlegroups.com> References: <2d35795c-353c-4811-a3ea-8057d1e07a7c@googlegroups.com> Message-ID: Did you actually confirm the PATH variable contains the right path? echo $env:Path And look for a path entry that mentions Python. Then, make sure you can actually find python.exe in that location. As long as you keep the PATH option checked with the Python installer it absolutely should work from PowerShell. What version of Python did you install? Have you also tried to invoke Python from the Command Prompt to determine if the issue only affects PowerShell or not? On Fri, Sep 28, 2018 at 1:10 PM wrote: > On Friday, 1 September 2017 19:37:41 UTC+1, The Cat Gamer wrote: > > fter I installed Python I try to open it in Powershell, by typing > > python/python.exe. > > It gives me an error: > > python : The term 'python' is not recognized as the name of a cmdlet, > > function, script file, or operable program. Check the spelling of the > name, > > or if a path was included, verify that the path is correct and try again. > > At line:1 char:1 > > + python > > + ~~~~~~ > > + CategoryInfo : ObjectNotFound: (python:String) [], > > CommandNotFoundException > > + FullyQualifiedErrorId : CommandNotFoundException > > This happens with version 3 and version 2. The newest versions and the > > older versions none of them makes me able to open Python in Windows > > Powershell. Are you guys aware of a fix? > > > > (I already tried the environment fix and that didnt work as well) > > -- > https://mail.python.org/mailman/listinfo/python-list > From __peter__ at web.de Sun Sep 30 04:03:41 2018 From: __peter__ at web.de (Peter Otten) Date: Sun, 30 Sep 2018 10:03:41 +0200 Subject: What's an elegant way to test for list index existing? References: <2be83e60-9807-4117-88c2-d2c8c3a497fb@googlegroups.com> Message-ID: Glen D souza wrote: > fld = [ ] > data = shlex.split(ln) > for item in data: > fld.append(item) > fld = fld + [0] * (5 - len(data)) There's no need to make a copy of data, one item at the time. It's a tedious way to build a new list, and you are throwing it away in the next line anyway, as adding first_list + second_list creates a new list containing the items of both. So: data = shlex.split(ln) fld = data + [""] * (5 - len(data)) # the OP wants strings From cl at isbd.net Sun Sep 30 06:13:34 2018 From: cl at isbd.net (Chris Green) Date: Sun, 30 Sep 2018 11:13:34 +0100 Subject: What's an elegant way to test for list index existing? References: <2be83e60-9807-4117-88c2-d2c8c3a497fb@googlegroups.com> Message-ID: Glen D souza wrote: > i have a approach, it may not be best > > fld = [ ] > for data in shlex.split(ln): > fld.append(data) > It's certainly simple! :-) I (OP) have actually done something quite similar:- fld = shlex.split(ln) fld.append(999) fld.append(999) It means I can test for '999' as when read from ln they are text fields and it's text I have created so (unless I get *very* confused) it will never be 999. -- Chris Green ? From cl at isbd.net Sun Sep 30 06:14:37 2018 From: cl at isbd.net (Chris Green) Date: Sun, 30 Sep 2018 11:14:37 +0100 Subject: What's an elegant way to test for list index existing? References: Message-ID: Chris Angelico wrote: > On Sat, Sep 29, 2018 at 12:21 PM Chris Green wrote: > > > > I have a list created by:- > > > > fld = shlex.split(ln) > > > > It may contain 3, 4 or 5 entries according to data read into ln. > > What's the neatest way of setting the fourth and fifth entries to an > > empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels > > clumsy somehow. > > shlex.split(ln) + ["", ""] > Now that *is* neat, I will probably do this. -- Chris Green ? From cl at isbd.net Sun Sep 30 10:32:22 2018 From: cl at isbd.net (Chris Green) Date: Sun, 30 Sep 2018 15:32:22 +0100 Subject: What's an elegant way to test for list index existing? References: <6P1sD.365050$tw.86326@fx11.am4> Message-ID: Bart wrote: > On 30/09/2018 11:14, Chris Green wrote: > > Chris Angelico wrote: > >> On Sat, Sep 29, 2018 at 12:21 PM Chris Green wrote: > >>> > >>> I have a list created by:- > >>> > >>> fld = shlex.split(ln) > >>> > >>> It may contain 3, 4 or 5 entries according to data read into ln. > >>> What's the neatest way of setting the fourth and fifth entries to an > >>> empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels > >>> clumsy somehow. > >> > >> shlex.split(ln) + ["", ""] > >> > > Now that *is* neat, I will probably do this. > > Won't it give you 7 entries, when shlex.split(ln) returns 5? > > Or doesn't that matter? (In which case that's something not mentioned in > the specification.) No, it doesn't matter, I just need at least 5. -- Chris Green ? From alister.ware at ntlworld.com Sun Sep 30 12:15:05 2018 From: alister.ware at ntlworld.com (Alister) Date: Sun, 30 Sep 2018 16:15:05 GMT Subject: What's an elegant way to test for list index existing? References: <6P1sD.365050$tw.86326@fx11.am4> Message-ID: On Sun, 30 Sep 2018 11:45:21 +0100, Bart wrote: > On 30/09/2018 11:14, Chris Green wrote: >> Chris Angelico wrote: >>> On Sat, Sep 29, 2018 at 12:21 PM Chris Green wrote: >>>> >>>> I have a list created by:- >>>> >>>> fld = shlex.split(ln) >>>> >>>> It may contain 3, 4 or 5 entries according to data read into ln. >>>> What's the neatest way of setting the fourth and fifth entries to an >>>> empty string if they don't (yet) exist? Using 'if len(fld) < 4:' >>>> feels clumsy somehow. >>> >>> shlex.split(ln) + ["", ""] >>> >> Now that *is* neat, I will probably do this. > > Won't it give you 7 entries, when shlex.split(ln) returns 5? > > Or doesn't that matter? (In which case that's something not mentioned in > the specification.) if only 5 entries are required than simply prune off the extra using a slice as I suggested yesterday -- DalNet is like the special olympics of IRC. There's a lot of drooling goin' on and everyone is a 'winner'. From steve+comp.lang.python at pearwood.info Sun Sep 30 12:30:43 2018 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Sun, 30 Sep 2018 16:30:43 +0000 (UTC) Subject: So apparently I've been banned from this list Message-ID: I've been unexpectedly in hospital for the past two weeks, without internet or email. Just before my unexpected hospital stay, I was apparently banned (without warning) by Ethan Furman in what seems to me to be an act of retaliation for my protest against his overzealous and hostile tone-policing against a newcomer to the list, Reto Brunner: https://mail.python.org/pipermail/python-list/2018-September/737020.html (I did make one mistake in that post: I claimed that I hadn't said anything at the time on Ethan's last round of bans. That was incorrect, I actually did make an objection at the time.) Since I'm still catching up on emails, I have just come across Ethan's notice to me (copied below). Notwithstanding Ethan's comment about having posted the suspension notice on the list, I see no sign that he actually did so. At the risk of further retaliation from the moderators, I am ignoring the ban in this instance for the purposes of transparency and openness. (I don't know if this will show up on the mailing list or the newsgroup.) Since I believe this ban is illegitimate, I intend to challenge it if possible. In the meantime, I may not reply on-list to any responses. Subject: Fwd: Temporary Suspension To: From: Ethan Furman Date: Tue, 11 Sep 2018 11:22:40 -0700 In-Reply-To: Steven, you've probably already seen this on Python List, but I forgot to email it directly to you. My apologies. -- ~Ethan~ Python List Moderator -------- Forwarded Message -------- Subject: Temporary Suspension Date: Mon, 10 Sep 2018 07:09:04 -0700 From: Ethan Furman To: Python List Moderators As a list moderator, my goal for this list is to keep the list a useful resource -- but what does "useful" mean? To me it means a place that python users can go to ask questions, get answers, offer advice, and all without sarcasm, name-calling, and deliberate mis-understandings. Conversations should stay mostly on-topic. Due to hostile and inappropriate posts*, Steven D'Aprano is temporarily suspended from Python List for a period of two months. This suspension, along with past suspensions, is being taken only after careful consideration and consultation with other Python moderators. -- ~Ethan~ Python List Moderator * posts in question: [1] https://mail.python.org/pipermail/python-list/2018-July/735735.html [2] https://mail.python.org/pipermail/python-list/2018-September/737020.html -- Steven D'Aprano From rosuav at gmail.com Sun Sep 30 12:49:19 2018 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 1 Oct 2018 02:49:19 +1000 Subject: So apparently I've been banned from this list In-Reply-To: References: Message-ID: On Mon, Oct 1, 2018 at 2:34 AM Steven D'Aprano wrote: > Subject: Fwd: Temporary Suspension > To: > From: Ethan Furman > Date: Tue, 11 Sep 2018 11:22:40 -0700 > In-Reply-To: > > Steven, you've probably already seen this on Python List, but I forgot > to email it directly to you. My apologies. > > -- > ~Ethan~ > Python List Moderator > > > -------- Forwarded Message -------- > Subject: Temporary Suspension > Date: Mon, 10 Sep 2018 07:09:04 -0700 > From: Ethan Furman > To: Python List Moderators > I don't recall seeing the twice-forwarded message here. Is it possible that the message about the suspension was sent only to -owner and not to the list? Was it meant to be sent to the whole list? ChrisA From breamoreboy at gmail.com Sun Sep 30 15:39:29 2018 From: breamoreboy at gmail.com (Mark Lawrence) Date: Sun, 30 Sep 2018 20:39:29 +0100 Subject: So apparently I've been banned from this list In-Reply-To: References: Message-ID: On 30/09/18 17:30, Steven D'Aprano wrote: > I've been unexpectedly in hospital for the past two weeks, without > internet or email. Just before my unexpected hospital stay, I was > apparently banned (without warning) by Ethan Furman in what seems to me > to be an act of retaliation for my protest against his overzealous and > hostile tone-policing against a newcomer to the list, Reto Brunner: > > https://mail.python.org/pipermail/python-list/2018-September/737020.html > > (I did make one mistake in that post: I claimed that I hadn't said > anything at the time on Ethan's last round of bans. That was incorrect, I > actually did make an objection at the time.) > > Since I'm still catching up on emails, I have just come across Ethan's > notice to me (copied below). > > Notwithstanding Ethan's comment about having posted the suspension notice > on the list, I see no sign that he actually did so. At the risk of > further retaliation from the moderators, I am ignoring the ban in this > instance for the purposes of transparency and openness. (I don't know if > this will show up on the mailing list or the newsgroup.) > > Since I believe this ban is illegitimate, I intend to challenge it if > possible. In the meantime, I may not reply on-list to any responses. > > > > Subject: Fwd: Temporary Suspension > To: > From: Ethan Furman > Date: Tue, 11 Sep 2018 11:22:40 -0700 > In-Reply-To: > > Steven, you've probably already seen this on Python List, but I forgot > to email it directly to you. My apologies. > > -- > ~Ethan~ > Python List Moderator > > > -------- Forwarded Message -------- > Subject: Temporary Suspension > Date: Mon, 10 Sep 2018 07:09:04 -0700 > From: Ethan Furman > To: Python List Moderators > > As a list moderator, my goal for this list is to keep the list a useful > resource -- but what does "useful" mean? To me it means a place that > python users can go to ask questions, get answers, offer advice, and all > without sarcasm, name-calling, and deliberate mis-understandings. > Conversations should stay mostly on-topic. > > Due to hostile and inappropriate posts*, Steven D'Aprano is temporarily > suspended from Python List for a period of two months. > > This suspension, along with past suspensions, is being taken only after > careful consideration and consultation with other Python moderators. > > -- > ~Ethan~ > Python List Moderator > > > * posts in question: > > [1] https://mail.python.org/pipermail/python-list/2018-July/735735.html > [2] https://mail.python.org/pipermail/python-list/2018-September/737020.html > Personally I think Ethan Furman should be removed from his position as a moderator as he's less than useless at the job. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From kliateni at gmail.com Sun Sep 30 16:49:56 2018 From: kliateni at gmail.com (Karim) Date: Sun, 30 Sep 2018 22:49:56 +0200 Subject: So apparently I've been banned from this list In-Reply-To: References: Message-ID: On 30/09/2018 18:30, Steven D'Aprano wrote: > I've been unexpectedly in hospital for the past two weeks, without > internet or email. Just before my unexpected hospital stay, I was > apparently banned (without warning) by Ethan Furman in what seems to me > to be an act of retaliation for my protest against his overzealous and > hostile tone-policing against a newcomer to the list, Reto Brunner: > > https://mail.python.org/pipermail/python-list/2018-September/737020.html > > (I did make one mistake in that post: I claimed that I hadn't said > anything at the time on Ethan's last round of bans. That was incorrect, I > actually did make an objection at the time.) > > Since I'm still catching up on emails, I have just come across Ethan's > notice to me (copied below). > > Notwithstanding Ethan's comment about having posted the suspension notice > on the list, I see no sign that he actually did so. At the risk of > further retaliation from the moderators, I am ignoring the ban in this > instance for the purposes of transparency and openness. (I don't know if > this will show up on the mailing list or the newsgroup.) > > Since I believe this ban is illegitimate, I intend to challenge it if > possible. In the meantime, I may not reply on-list to any responses. > > > > Subject: Fwd: Temporary Suspension > To: > From: Ethan Furman > Date: Tue, 11 Sep 2018 11:22:40 -0700 > In-Reply-To: > > Steven, you've probably already seen this on Python List, but I forgot > to email it directly to you. My apologies. > > -- > ~Ethan~ > Python List Moderator > > > -------- Forwarded Message -------- > Subject: Temporary Suspension > Date: Mon, 10 Sep 2018 07:09:04 -0700 > From: Ethan Furman > To: Python List Moderators > > As a list moderator, my goal for this list is to keep the list a useful > resource -- but what does "useful" mean? To me it means a place that > python users can go to ask questions, get answers, offer advice, and all > without sarcasm, name-calling, and deliberate mis-understandings. > Conversations should stay mostly on-topic. > > Due to hostile and inappropriate posts*, Steven D'Aprano is temporarily > suspended from Python List for a period of two months. > > This suspension, along with past suspensions, is being taken only after > careful consideration and consultation with other Python moderators. > > -- > ~Ethan~ > Python List Moderator > > > * posts in question: > > [1] https://mail.python.org/pipermail/python-list/2018-July/735735.html > [2] https://mail.python.org/pipermail/python-list/2018-September/737020.html Hi, I hope you are getting better. Cheers Karim From max at zettlmeissl.de Sun Sep 30 22:28:30 2018 From: max at zettlmeissl.de (=?UTF-8?Q?Max_Zettlmei=C3=9Fl?=) Date: Mon, 1 Oct 2018 04:28:30 +0200 Subject: So apparently I've been banned from this list In-Reply-To: References: Message-ID: On Sun, Sep 30, 2018 at 6:30 PM, Steven D'Aprano wrote: > Notwithstanding Ethan's comment about having posted the suspension notice > on the list, I see no sign that he actually did so. At the risk of > further retaliation from the moderators, I am ignoring the ban in this > instance for the purposes of transparency and openness. (I don't know if > this will show up on the mailing list or the newsgroup.) [...] > > -------- Forwarded Message -------- > Subject: Temporary Suspension > Date: Mon, 10 Sep 2018 07:09:04 -0700 > From: Ethan Furman > To: Python List Moderators > > As a list moderator, my goal for this list is to keep the list a useful > resource -- but what does "useful" mean? To me it means a place that > python users can go to ask questions, get answers, offer advice, and all > without sarcasm, name-calling, and deliberate mis-understandings. > Conversations should stay mostly on-topic. > > Due to hostile and inappropriate posts*, Steven D'Aprano is temporarily > suspended from Python List for a period of two months. > > This suspension, along with past suspensions, is being taken only after > careful consideration and consultation with other Python moderators. > > -- > ~Ethan~ > Python List Moderator > > > * posts in question: > > [1] https://mail.python.org/pipermail/python-list/2018-July/735735.html > [2] https://mail.python.org/pipermail/python-list/2018-September/737020.html > I can assure you that I did not receive Ethan's message via the mailing list. First of all I would have noticed it, if it would have been a separate thread. But I also just went over all the messages and tried to find it. It never arrived in my mailbox.