Re: Write this accumuator in a functional style

2017-07-11 Thread Gregory Ewing
Steve D'Aprano wrote: - Greg's dict comprehension version requires N+1 passes through the data, one to convert to a list, and 1 per each possible key. Just to be clear, my solution was a response to the requirement that it be written in a purely functional style. It's not now I would actually

Re: Write this accumuator in a functional style

2017-07-11 Thread Steve D'Aprano
On Tue, 11 Jul 2017 04:58 pm, Chris Angelico wrote: > On Tue, Jul 11, 2017 at 4:11 PM, Steven D'Aprano wrote: [...] >> accumulator = {'blue': [], 'green': [], 'red': []} >> for parrot in parrots: >> accumulator[parrot.colour].append(parrot) [...] > It's a partitioning filter. (Three way, not

Re: Compiling Python 3.6.1 on macOS 10.12.5

2017-07-11 Thread Pavol Lisy
On 7/10/17, Nigel Palmer wrote: > Hi > > I am trying to compile Python 3.6.1 on macOS 10.12.5 with xcode 8.8.3 using > the instructions at > https://docs.python.org/devguide/setup.html#build-dependencies but I am > getting the error > > ./python.exe -E -S -m sysconfig --generate-posix-vars ;\ >

Re: Write this accumuator in a functional style

2017-07-11 Thread Pavol Lisy
On 7/11/17, Steven D'Aprano wrote: > I have a colleague who is allergic to mutating data structures. Yeah, I > know, he needs to just HTFU but I thought I'd humour him. > > Suppose I have an iterator that yields named tuples: > > Parrot(colour='blue', species='Norwegian', status='tired and shagged

Re: Test 0 and false since false is 0

2017-07-11 Thread Steve D'Aprano
On Tue, 11 Jul 2017 11:16 pm, Albert-Jan Roskam wrote: > >>> False == 0 > True > >>> False is 0 > False > > > => Just wondering: Is this 'is' test depending on an implementation detail > of cPython (small ints, I forgot how small 0-255 maybe, are singletons)? No. But the test 0 is 0 will b

Re: Better Regex and exception handling for this small code

2017-07-11 Thread Cameron Simpson
On 11Jul2017 22:01, Ganesh Pal wrote: I am trying to open a file and check if there is a pattern has changed after the task got completed? file data: #tail -f /file.txt .. Note: CRC:algo = 2, spl

Re: ezdxf type of spline

2017-07-11 Thread Pavol Lisy
It seems to be: http://pythonhosted.org/ezdxf/entities.html?highlight=spline#Spline -> https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-Core/files/GUID-58316136-30EB-499C-ACAD-31D0C653B2B2-htm.html -> https://en.wikipedia.org/wiki/Non-unifo

RE: Compiling Python 3.6.1 on macOS 10.12.5

2017-07-11 Thread Nigel Palmer
Hi The python process only goes to around 4.8 MB before it dies and the machine has 4GB of RAM so I do not think it’s a memory issue. Thanks, Nigel -Original Message- From: INADA Naoki [mailto:songofaca...@gmail.com] Sent: 11 July 2017 02:57 To: Nigel Palmer Cc: python-list@python.org

Re: Write this accumuator in a functional style

2017-07-11 Thread Ian Kelly
On Tue, Jul 11, 2017 at 12:47 AM, Wolfgang Maier wrote: > On 07/11/2017 08:11 AM, Steven D'Aprano wrote: >> >> I have a colleague who is allergic to mutating data structures. Yeah, I >> know, he needs to just HTFU but I thought I'd humour him. >> >> Suppose I have an iterator that yields named tup

Re: Better Regex and exception handling for this small code

2017-07-11 Thread Ganesh Pal
I am trying to open a file and check if the pattern i.e initiator_crc has changed after the task got completed? * On Tue, Jul 11, 2017 at 10:01 PM, Ganesh Pal wrote: > Dear Python friends > > I am trying to open a file and check if there is a pattern has changed > after the task got complet

Better Regex and exception handling for this small code

2017-07-11 Thread Ganesh Pal
Dear Python friends I am trying to open a file and check if there is a pattern has changed after the task got completed? file data: #tail -f /file.txt .. Note: CRC:algo = 2, split_crc = 1, unused =

Re: Compiling Python 3.6.1 on macOS 10.12.5

2017-07-11 Thread Viktor Hagström
>Why are you trying to compile Python manually? You should use Homebrew to >install Python in 99% of cases. (The package is python3) I'm not the person you answered, but I can explain why I do things that are not "optimal" or "easy" or "best". I am interested, I want to learn something, I think

Re: Test 0 and false since false is 0

2017-07-11 Thread Grant Edwards
On 2017-07-11, Albert-Jan Roskam wrote: > From: Python-list on > behalf of Dan Sommers > Sent: Friday, July 7, 2017 2:46 AM > To: python-list@python.org > Subject: Re: Test 0 and false since false is 0 >   > On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote: > >> I have tried or condit

Re: Test 0 and false since false is 0

2017-07-11 Thread Rhodri James
On 11/07/17 14:16, Albert-Jan Roskam wrote: From: Python-list on behalf of Dan Sommers Sent: Friday, July 7, 2017 2:46 AM To: python-list@python.org Subject: Re: Test 0 and false since false is 0 On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote: I have tried or conditions of v

RE: Compiling Python 3.6.1 on macOS 10.12.5

2017-07-11 Thread Nigel Palmer
Hi Chris I am planning on embedding Python into a C++ application and I wanted to have my own build of Python to do that. I know that eventually I will need to use --enable-shared or --enable-framework but for now I am trying to get a the simpler static build to compile first. Thanks, Nigel F

Re: Test 0 and false since false is 0

2017-07-11 Thread Albert-Jan Roskam
From: Python-list on behalf of Dan Sommers Sent: Friday, July 7, 2017 2:46 AM To: python-list@python.org Subject: Re: Test 0 and false since false is 0   On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote: > I have tried or conditions of v == False etc but then the 0's being > false als

Re: Compiling Python 3.6.1 on macOS 10.12.5

2017-07-11 Thread Viktor Hagström
>Why are you trying to compile Python manually? You should use Homebrew to >install Python in 99% of cases. (The package is python3) I'm not the person you answered, but I can explain why I do things that are not "optimal" or "easy" or "best". I am interested, I want to learn something, I think

Re: Can anybody help me retrieve how to retrieve output from this Python code below!

2017-07-11 Thread Peter Otten
ksatish@gmail.com wrote: [snip code] Wasn't there any documentation to go with that script? That's the preferable method to use software written by someone else ;) Anyway -- First you have to undo what was probably changed by yourself: $ diff -u json2csv_orig.py json2csv.py --- json2csv_o

Can anybody help me retrieve how to retrieve output from this Python code below!

2017-07-11 Thread ksatish . dtc
try: import unicodecsv as csv except ImportError: import csv import json import operator import os from collections import OrderedDict import logging logging.basicConfig(level=logging.DEBUG) class Json2Csv(object): """Process a JSON object to a CSV file""" collection = None

Re: Compiling Python 3.6.1 on macOS 10.12.5

2017-07-11 Thread Viktor Hagström
>Why are you trying to compile Python manually? You should use Homebrew to >install Python in 99% of cases. (The package is python3) I'm not the person you answered, but I can explain why I do things that are not "optimal" or "easy" or "best". I am interested, I want to learn something, I think

Re: Write this accumuator in a functional style

2017-07-11 Thread Alain Ketterlin
Steven D'Aprano writes: > I have a colleague who is allergic to mutating data structures. Yeah, I > know, he needs to just HTFU but I thought I'd humour him. > > Suppose I have an iterator that yields named tuples: > > Parrot(colour='blue', species='Norwegian', status='tired and shagged out') >

Re: Write this accumuator in a functional style

2017-07-11 Thread Terry Reedy
On 7/11/2017 2:11 AM, Steven D'Aprano wrote: I have a colleague who is allergic to mutating data structures. Yeah, I know, he needs to just HTFU but I thought I'd humour him. Suppose I have an iterator that yields named tuples: Parrot(colour='blue', species='Norwegian', status='tired and shagge

Re: Write this accumuator in a functional style

2017-07-11 Thread Peter Otten
Steven D'Aprano wrote: > I have a colleague who is allergic to mutating data structures. Yeah, I > know, he needs to just HTFU but I thought I'd humour him. > > Suppose I have an iterator that yields named tuples: > > Parrot(colour='blue', species='Norwegian', status='tired and shagged out') >

Re: Write this accumuator in a functional style

2017-07-11 Thread Chris Angelico
On Tue, Jul 11, 2017 at 4:11 PM, Steven D'Aprano wrote: > I have a colleague who is allergic to mutating data structures. Yeah, I > know, he needs to just HTFU but I thought I'd humour him. > > Suppose I have an iterator that yields named tuples: > > Parrot(colour='blue', species='Norwegian', stat