Re: loop

2014-03-24 Thread Marko Rauhamaa
Chris Angelico : > On Mon, Mar 24, 2014 at 11:35 AM, wrote: >> I'm trying to create a for loop that starts at 100 and goes to 10Mllion. > > That sounds like a logarithmic scale. How about: for i in [ 100, 1000, 1, 10, 100, 1000, 1 ]: ... Marko -- https://

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mar 23, 2014 11:56 PM, "Mark H Harris" wrote: > > On 3/22/14 4:46 AM, Steven D'Aprano wrote: >> >> On Fri, 21 Mar 2014 23:51:38 -0500, Mark H Harris wrote: >> >>> Lambda is a problem, if only because it causes confusion. What's the >>> problem? Glad you asked. The constructs DO NOT work the wa

Re: loop

2014-03-24 Thread Mark Lawrence
On 24/03/2014 07:47, Marko Rauhamaa wrote: Chris Angelico : On Mon, Mar 24, 2014 at 11:35 AM, wrote: I'm trying to create a for loop that starts at 100 and goes to 10Mllion. That sounds like a logarithmic scale. How about: for i in [ 100, 1000, 1, 10, 100, 1000, 100

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Steven D'Aprano
On Mon, 24 Mar 2014 00:52:52 -0500, Mark H Harris wrote: > On 3/22/14 4:46 AM, Steven D'Aprano wrote: >> On Fri, 21 Mar 2014 23:51:38 -0500, Mark H Harris wrote: >> >>> Lambda is a problem, if only because it causes confusion. What's the >>> problem? Glad you asked. The constructs DO NOT work the

Asyncio (or something better) for control of a vacuum system/components.

2014-03-24 Thread Shishir
Dear All, I apologise in advance a) if this is not the proper list for asking the question, b) the length of the post. I am writing a software to control and monitor a vacuum furnace+attachments. It has a few mass flow controllers, a butterfly valve, a labjack unit for analog/digital outputs etc.

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Marko Rauhamaa
Ian Kelly : > If lambda were going to be deprecated and removed then it already > would have happened in Python 3, because Guido tried to do precisely > that. I'm not sure what the reasons were for keeping it in the end > (according to PEP 3099 it was because nobody suggested a suitable > replacem

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark Lawrence
On 24/03/2014 05:52, Mark H Harris wrote: How so? Read Guido's argument above. Another way to answer this question is that I have been programming with Python for almost a decade and I've not used lambda. In fact, I have gone out of my way to NOT use lambda because I am fully aware that the

Re: loop

2014-03-24 Thread Marko Rauhamaa
Mark Lawrence : > On 24/03/2014 07:47, Marko Rauhamaa wrote: >> for i in [ 100, 1000, 1, 10, 100, 1000, 1 ]: > > Why the overhead of creating a list when you could use a tuple? :) Once in college, we were given assembly programming assignments. The textbook defined an

Re: Asyncio (or something better) for control of a vacuum system/components.

2014-03-24 Thread Marko Rauhamaa
Shishir : > The problem is that self.execute() blocks and the asyncio framework > has no way to know how to reschedule it or bypass it. This can be > avoided if I depended on I/O from a file descriptor, on which I can > apply poll()/select(). But the channel handler that I have is more > generic (

gdb python how to output integer for examine memory

2014-03-24 Thread Wesley
Hi all, I am trying to use gdb debug python script. I am using gdb7.7 and python2.7.6, here is my simple test script: import time def next(i): time.sleep(10) i = 1 - i i = 1 while True: next(i) When this script running, gdb attach to it, and here is snippet: (gdb) py-bt #5 Frame 0

Re: Writing an OPC client with Python ?

2014-03-24 Thread sales09
OPC Python Example: Get OPC data into Python http://www.opclabs.com/products/quickopc/languages-and-tools/python -- https://mail.python.org/mailman/listinfo/python-list

Re: Python OPC -wrapper for data collection, anyone seen it ?

2014-03-24 Thread sales09
What about (our) QuickOPC: http://www.opclabs.com/products/quickopc/languages-and-tools/python -- https://mail.python.org/mailman/listinfo/python-list

Re: OPC for Python ?? (Win32)

2014-03-24 Thread sales09
QuickOPC: Get OPC data into Python http://www.opclabs.com/products/quickopc/languages-and-tools/python -- https://mail.python.org/mailman/listinfo/python-list

Re: Python in Process Control?

2014-03-24 Thread sales09
Get OPC data into Python: http://www.opclabs.com/products/quickopc/languages-and-tools/python -- https://mail.python.org/mailman/listinfo/python-list

Re: loop

2014-03-24 Thread Chris Angelico
On Mon, Mar 24, 2014 at 9:04 PM, Marko Rauhamaa wrote: > Once in college, we were given assembly programming assignments. The > textbook defined an imagined 18-bit CPU and an instruction set. > > A fellow student was given the task to write a subroutine that > calculates the factorial of the argum

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Mon, Mar 24, 2014 at 8:49 PM, Steven D'Aprano wrote: > I'm too lazy to do this the > right way, but there are at least 99 mentions of "lambda" in the 3.3 > standard library: > > steve@runes:/usr/local/lib/python3.3$ grep lambda *.py | wc -l > 99 I'm not too lazy to do it the right way, but I d

Memory error

2014-03-24 Thread Jamie Mitchell
Hello all, I'm afraid I am new to all this so bear with me... I am looking to find the statistical significance between two large netCDF data sets. Firstly I've loaded the two files into python: swh=netCDF4.Dataset('/data/cr1/jmitchel/Q0/swh/controlperiod/averages/swh_control_concat.nc', 'r')

Re: Memory error

2014-03-24 Thread Jamie Mitchell
On Monday, March 24, 2014 11:32:31 AM UTC, Jamie Mitchell wrote: > Hello all, > > > > I'm afraid I am new to all this so bear with me... > > > > I am looking to find the statistical significance between two large netCDF > data sets. > > > > Firstly I've loaded the two files into python: >

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Mon, Mar 24, 2014 at 8:55 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> If lambda were going to be deprecated and removed then it already >> would have happened in Python 3, because Guido tried to do precisely >> that. I'm not sure what the reasons were for keeping it in the end >> (according to

Re:gdb python how to output integer for examine memory

2014-03-24 Thread Dave Angel
Wesley Wrote in message: > Hi all, > I am trying to use gdb debug python script. > I am using gdb7.7 and python2.7.6, here is my simple test script: > import time > > def next(i): > time.sleep(10) > i = 1 - i > > i = 1 > while True: > next(i) > When this script running, gdb attac

Re: Asyncio (or something better) for control of a vacuum system/components.

2014-03-24 Thread mauro
Hav you considered the option of a SCADA solution? There are many commercials solutions but also a few open source options such us: http://openscada.org/ http://pvbrowser.de/pvbrowser/index.php You may also ask the vacuum system provider, they should be aware of SCADA solutions supporting their

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Marko Rauhamaa
Chris Angelico : > Similarly, there are plenty of cases where a nameless function is MUCH > clearer than breaking it out into a separate def and then using the > name once. Do you name the function for what it does internally? > > def get_oneth_element_index(item): > return item[1].index > L.s

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Mon, Mar 24, 2014 at 11:36 PM, Marko Rauhamaa wrote: >> def get_oneth_element_index(item): >> return item[1].index >> L.sort(key=get_oneth_element_index) >> >> Or do you just shortcut the whole thing by inlining it? >> >> L.sort(key=lambda item:item[1].index) > > I still prefer the "def" va

Re: gdb python how to output integer for examine memory

2014-03-24 Thread Wesley
Hi Dave, Thanks for your response. It's just a simple script for test:-) My concern is use gdb to monitor variable in memory within python process. For details, in my origin post, just wanna why cannot output interger value from the address. Maybe here is not right for gdb python question..but

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Steven D'Aprano
On Mon, 24 Mar 2014 22:49:38 +1100, Chris Angelico wrote: > On Mon, Mar 24, 2014 at 8:55 PM, Marko Rauhamaa > wrote: >> You never *need* (Python's) lambda for anything. Inner functions are >> more capable and almost always more readable. It doesn't hurt to have >> lambda, but I don't find any us

Re: Question about Source Control

2014-03-24 Thread Rustom Mody
On Monday, March 17, 2014 6:36:33 PM UTC+5:30, Frank Millman wrote: > Hi all > I know I *should* be using a Source Control Management system, but at > present I am not. I tried to set up Mercurial a couple of years ago, but I > think I set it up wrongly, as I got myself confused and found it mor

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark Lawrence
On 24/03/2014 12:36, Marko Rauhamaa wrote: Chris Angelico : Similarly, there are plenty of cases where a nameless function is MUCH clearer than breaking it out into a separate def and then using the name once. Do you name the function for what it does internally? def get_oneth_element_index(it

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Steven D'Aprano
On Mon, 24 Mar 2014 23:53:12 +1100, Chris Angelico wrote: > On Mon, Mar 24, 2014 at 11:36 PM, Marko Rauhamaa > wrote: >>> def get_oneth_element_index(item): >>> return item[1].index >>> L.sort(key=get_oneth_element_index) >>> >>> Or do you just shortcut the whole thing by inlining it? >>> >>>

TypeError in HMAC module.

2014-03-24 Thread Prabir Kr Sarkar
Hi, I am trying to create a hashed message for authentication for a REST API call. I have got the key from a keyring as :- key = keyring.get_password('AWS_keyring','username') & calculating the signature as :- signature = hmac(key, message.encode('UTF-8'), hashlib.sha1).digest().encode('base64

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark Lawrence
On 24/03/2014 14:39, Steven D'Aprano wrote: On Mon, 24 Mar 2014 23:53:12 +1100, Chris Angelico wrote: On Mon, Mar 24, 2014 at 11:36 PM, Marko Rauhamaa wrote: def get_oneth_element_index(item): return item[1].index L.sort(key=get_oneth_element_index) Or do you just shortcut the whole thi

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Rustom Mody
On Monday, March 24, 2014 7:34:59 PM UTC+5:30, Steven D'Aprano wrote: > On Mon, 24 Mar 2014 22:49:38 +1100, Chris Angelico wrote: > > wrote: > >> You never *need* (Python's) lambda for anything. Inner functions are > >> more capable and almost always more readable. It doesn't hurt to have > >> la

String modifying error, trying to delete data in string

2014-03-24 Thread mikie
Here is some code: import socket,sys s=socket.socket() port=int(sys.argv[1]) s.bind(("127.0.0.1",port)) s.listen(2) cls,addr=s.accept() data=cls.recv(1024) f=data.pop("Proxy-Connection") cls.close() Im trying to delete some headers

Re: String modifying error, trying to delete data in string

2014-03-24 Thread Mark Lawrence
On 24/03/2014 16:20, mikie wrote: Here is some code: import socket,sys s=socket.socket() port=int(sys.argv[1]) s.bind(("127.0.0.1",port)) s.listen(2) cls,addr=s.accept() data=cls.recv(1024) f=data.pop("Proxy-Connection") cl

Re: String modifying error, trying to delete data in string

2014-03-24 Thread Steven D'Aprano
On Mon, 24 Mar 2014 09:20:26 -0700, mikie wrote: > Im trying to delete some headers in the request but get an error saying: > 'str' object has no attribute 'pop' What sort of object is data? What do you expect it to be, and what it is actually? Given that you are calling data.pop("Proxy-Connect

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mon, Mar 24, 2014 at 3:55 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> If lambda were going to be deprecated and removed then it already >> would have happened in Python 3, because Guido tried to do precisely >> that. I'm not sure what the reasons were for keeping it in the end >> (according to

Merge/append CSV files with different headers

2014-03-24 Thread Vincent Davis
I have several csv file I need to append (vertically). They have different but overlapping headers. For example; file1 headers ['a', 'b', 'c'] file2 headers ['d', 'e'] file3 headers ['c', 'd'] Is there a better way than this import csv def merge_csv(fileList, newFileName): allHeaders = set([])

Re: Merge/append CSV files with different headers

2014-03-24 Thread Mark Lawrence
On 24/03/2014 17:50, Vincent Davis wrote: I have several csv file I need to append (vertically). They have different but overlapping headers. For example; file1 headers ['a', 'b', 'c'] file2 headers ['d', 'e'] file3 headers ['c', 'd'] Is there a better way than this import csv def merge_csv(file

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 4:58 AM, Mark Lawrence wrote: Where do you get reduce from if it's not in the standard library? That was "a" proposal for 3000. Its there, but its not on the built-ins; ie., you have to import it. The confusion: why reduce, why not filter, nor map? {rhetorical} As for lambd

Re: TypeError in HMAC module.

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 2:15 AM, Prabir Kr Sarkar wrote: > Hi, >I am trying to create a hashed message for authentication for a REST API > call. I have got the key from a keyring as :- > > key = keyring.get_password('AWS_keyring','username') > > & calculating the signature as :- > signature =

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 1:04 AM, Steven D'Aprano wrote: >> But which of these is truly more readable? >> >> squares = [] >> for n in range(30): >> squares.append(n * n) >> >> squares = [n * n for n in range(30)] > > Readable for whom? > > List comprehension syntax is often completely obscure t

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark Lawrence
On 24/03/2014 18:58, Mark H Harris wrote: On 3/24/14 4:58 AM, Mark Lawrence wrote: Where do you get reduce from if it's not in the standard library? That was "a" proposal for 3000. Its there, but its not on the built-ins; ie., you have to import it. The confusion: why reduce, why not filt

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mon, Mar 24, 2014 at 12:58 PM, Mark H Harris wrote: > That is what we mean by confusing. Or another really great example is this > thread. Somebody asks about a language feature and somebody else helpfully > answers the question by providing them with a similar lambda!! That is not in fact how

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 5:58 AM, Mark H Harris wrote: > Its there, but its not on the built-ins; ie., you have to import it. The > confusion: why reduce, why not filter, nor map? {rhetorical} In other languages with those three, and without list/array comprehensions, I've used filter occasional

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mon, Mar 24, 2014 at 1:12 PM, Chris Angelico wrote: > Incidentally, I've often modified my loop counter, in C or REXX or any > other language. About the only situation where I actually miss it in > Python, though, is iterating over a list and mutating the list on the > way through; and even tha

Re: Merge/append CSV files with different headers

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 4:50 AM, Vincent Davis wrote: > I have several csv file I need to append (vertically). They have different > but overlapping headers. For example; > file1 headers ['a', 'b', 'c'] > file2 headers ['d', 'e'] > file3 headers ['c', 'd'] > > Is there a better way than this Summ

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 6:13 AM, Mark Lawrence wrote: >> That was "a" proposal for 3000. Its there, but its not on the >> built-ins; ie., you have to import it. The confusion: why reduce, why >> not filter, nor map? {rhetorical} > > > So it is in the standard library then. And I'm not confu

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 4:49 AM, Steven D'Aprano wrote: There's no doubt that lambda is less-often useful than is the def statement. But not only is it still useful, but there is a continual stream of people asking for Python to make it *more useful* by allowing the body of a lambda to be a full block, not ju

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 6:42 AM, Ian Kelly wrote: > On Mon, Mar 24, 2014 at 1:12 PM, Chris Angelico wrote: >> Incidentally, I've often modified my loop counter, in C or REXX or any >> other language. About the only situation where I actually miss it in >> Python, though, is iterating over a list

advice on sub-classing multiprocessing.Process and multiprocessing.BaseManager

2014-03-24 Thread Matt Newville
I'm maintaining a python interface to a C library for a distributed control system (EPICS, sort of a SCADA system) that does a large amount of relatively light-weight network I/O. In order to keep many connections open and responsive, and to provide a simple interface, the python library keeps a

How to clear all content in a Tk()

2014-03-24 Thread eneskristo
I have this program, and since I want to change stuff dynamically, I want to fully clear the root = Tk(), without deleting it. Is there a way to do so? -- https://mail.python.org/mailman/listinfo/python-list

Re: Memory error

2014-03-24 Thread Gary Herron
On 03/24/2014 04:32 AM, Jamie Mitchell wrote: Hello all, I'm afraid I am new to all this so bear with me... I am looking to find the statistical significance between two large netCDF data sets. Firstly I've loaded the two files into python: swh=netCDF4.Dataset('/data/cr1/jmitchel/Q0/swh/cont

Python developer salary survey - results

2014-03-24 Thread victor . olex
PyStreet's February salary survey attracted respondents from 37 countries. Median annual salary in the U.S.: $95,000 Median annual salary worldwide: $50,000 Complete study: http://bit.ly/1dgCw3p -- https://mail.python.org/mailman/listinfo/python-list

Re: Merge/append CSV files with different headers

2014-03-24 Thread Vincent Davis
Thanks for the feedback. Vincent Davis 720-301-3003 On Mon, Mar 24, 2014 at 1:44 PM, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 4:50 AM, Vincent Davis > wrote: > > I have several csv file I need to append (vertically). They have > different > > but overlapping headers. For example; > > f

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 4:03 AM, Ian Kelly wrote: The difference does not really lie in the lambda construct per se but in the binding style of closures. Functional languages tend to go one way here; imperative languages tend to go the other. {snip} The result may be more surprising to users accustomed to

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Marko Rauhamaa
Mark H Harris : >Yes, its about closures, totally; the most confusing aspect of > lambda in python is not only the syntax but the idea of scope and > closure (for that syntax). Everyone is confused by this initially, not > because its complicated, but because its confusing. An example: > >>

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Steven D'Aprano
On Tue, 25 Mar 2014 06:22:28 +1100, Chris Angelico wrote: > Aside: You'll often hear people talking about "map-reduce" with big > data. Python supports that. Look! > map.__reduce__ > > > Oh wait, that's nothing to do with reduce()... > > *ducks for cover* Ha ha, very funny :-P http://c

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 8:43 AM, Mark H Harris wrote: >> adders[n] = (lambda b: lambda a: b + a)(n) > >Now, here is where I talk about confusion; explaining why the first > lambda above does not work because of scope and closure, and then even > worse, explaining why the second "double

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 9:58 AM, Steven D'Aprano wrote: > On Tue, 25 Mar 2014 06:22:28 +1100, Chris Angelico wrote: > >> Aside: You'll often hear people talking about "map-reduce" with big >> data. Python supports that. Look! >> > map.__reduce__ >> >> >> Oh wait, that's nothing to do with red

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 6:01 PM, Chris Angelico wrote: Easy fix. Use the "explicit capture" notation: adders[n] = lambda a, n=n: a+n And there you are, out of your difficulty at once! Yes, yes, yes, and example: adders= list(range(4)) for n in adders: >adders[n] = lambda a, n=n: a+n >

Re: Reading in cooked mode (was Re: Python MSI not installing, log file showing name of a Viatnemese communist revolutionary)

2014-03-24 Thread Mark H Harris
On 3/24/14 6:30 PM, Dennis Lee Bieber wrote: {And I recall standard practice was to hit \r, to return the carriage, \n for next line, and one RUBOUT to provide a delay while the carriage returned to the left} Yes, yes... I remember well, there had to be a delay (of some type) to wait for the h

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 10:44 AM, Mark H Harris wrote: > On 3/24/14 6:01 PM, Chris Angelico wrote: > >> Easy fix. Use the "explicit capture" notation: >> adders[n] = lambda a, n=n: a+n >> And there you are, out of your difficulty at once! >But, and this is the big (WHY?) is that necessary? In

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Ian Kelly
On Mon, Mar 24, 2014 at 3:43 PM, Mark H Harris wrote: > On 3/24/14 4:03 AM, Ian Kelly wrote: >> >> >> The difference does not really lie in the lambda construct per se but in >> the binding style of closures. Functional languages tend to go one way >> here; imperative languages tend to go the othe

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 5:43 PM, Marko Rauhamaa wrote: Mark H Harris: Yes, its about closures, totally; the most confusing aspect of lambda in python is not only the syntax but the idea of scope and closure (for that syntax). Everyone is confused by this initially, not because its complicated, but be

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 10:56 AM, Mark H Harris wrote: > What is needed is the explicit closure "grab" recommended by ChrisA. Which does work. You do know why, right? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 7:11 PM, Chris Angelico wrote: On Tue, Mar 25, 2014 at 10:56 AM, Mark H Harris wrote: What is needed is the explicit closure "grab" recommended by ChrisA. Which does work. You do know why, right? Sure. ... but again, that's not the point. The point is NOT can you explain why it

Re: advice on sub-classing multiprocessing.Process and multiprocessing.BaseManager

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 7:24 AM, Matt Newville wrote: > I'm maintaining a python interface to a C library for a distributed > control system (EPICS, sort of a SCADA system) that does a large > amount of relatively light-weight network I/O. In order to keep many > connections open and responsive,

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 11:16 AM, Mark H Harris wrote: > On 3/24/14 7:11 PM, Chris Angelico wrote: >> >> On Tue, Mar 25, 2014 at 10:56 AM, Mark H Harris >> wrote: >>> >>> What is needed is the explicit closure "grab" recommended by ChrisA. >> >> >> Which does work. You do know why, right? > > > Su

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark Lawrence
On 25/03/2014 00:16, Mark H Harris wrote: On 3/24/14 7:11 PM, Chris Angelico wrote: On Tue, Mar 25, 2014 at 10:56 AM, Mark H Harris wrote: What is needed is the explicit closure "grab" recommended by ChrisA. Which does work. You do know why, right? Sure. ... but again, that's not the poin

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 7:32 PM, Mark Lawrence wrote: marcus I'd vote to have lambda taken out of the language if it meant avoiding tedious threads like this one :( Dude, you remind me of Eeyore; "days, weeks, months, who knows..." Its just a conversation. Don't setup a polling booth yet. Its all i

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Terry Reedy
On 3/24/2014 7:07 PM, Chris Angelico wrote: On Tue, Mar 25, 2014 at 9:58 AM, Steven D'Aprano wrote: On Tue, 25 Mar 2014 06:22:28 +1100, Chris Angelico wrote: Aside: You'll often hear people talking about "map-reduce" with big data. Python supports that. Look! map.__reduce__ Oh wait, that

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Terry Reedy
On 3/24/2014 7:56 PM, Mark H Harris wrote: Of course the problem is that the closure A function is not a closure unless defined within another function. In the examples I remember, there was no nesting. > grabs the *last* number in the list which is used for each of the adder[] functio

Re: Python developer salary survey - results

2014-03-24 Thread Wesley
在 2014年3月25日星期二UTC+8上午4时57分49秒,victo...@vtenterprise.com写道: > PyStreet's February salary survey attracted respondents from 37 countries. > > > > Median annual salary in the U.S.: $95,000 > > Median annual salary worldwide: $50,000 > > > > Complete study: http://bit.ly/1dgCw3p I am below th

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Terry Reedy
On 3/24/2014 8:28 PM, Chris Angelico wrote: Pure functional programming, from what I understand, doesn't *have* variables other than function arguments. function *parameters*, if in the 'variable = name' camp So the way to implement "x = 1" is to call a subfunction with a parameter named '

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 12:31 PM, Terry Reedy wrote: > On 3/24/2014 8:28 PM, Chris Angelico wrote: > >> Pure functional programming, from what I understand, doesn't *have* >> variables other than function arguments. > > > function *parameters*, if in the 'variable = name' camp > > >> So the way to

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Steven D'Aprano
On Mon, 24 Mar 2014 14:47:11 -0500, Mark H Harris wrote: > On 3/24/14 4:49 AM, Steven D'Aprano wrote: >> There's no doubt that lambda is less-often useful than is the def >> statement. But not only is it still useful, but there is a continual >> stream of people asking for Python to make it *more

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/22/14 3:59 PM, vasudevram wrote: Thanks to all those who answered. - Vasudev I am wondering if the question was answered? x = [[1,2],[3,4],[5,6]] import ast ast.dump(ast.parse('[x for x in x for x in x]')) > "Module(body= > [Expr(value=ListComp(elt=Name(id='x', ctx=Load()), > g

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark Lawrence
On 25/03/2014 01:45, Steven D'Aprano wrote: (1) People who just want to get the job done, without learning a bunch of theory, *won't care* how their sort key function is written. They're looking for a recipe that they can copy and paste, and whether you write it like this: data.sort(key=la

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 12:45 PM, Steven D'Aprano wrote: > Programming is a skill, like writing iambic pentameter. Should liberal > arts courses ban the use of iambic pentameter by poets because some > people find it confusing and can't count syllables or tell the difference > between stressed and

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 8:20 PM, Terry Reedy wrote: On 3/24/2014 7:56 PM, Mark H Harris wrote: the list which is used for each of the adder[] functions created. Wrong. Functions look up global and nonlocal names, such as n, when the function is called. hi Terry, yeah, I know; this is what's *wrong* al

Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 5:28:11 AM UTC+5:30, Ian wrote: > On Mon, Mar 24, 2014 at 3:43 PM, Mark H Harris wrote: > > On 3/24/14 4:03 AM, Ian Kelly wrote: > >> The difference does not really lie in the lambda construct per se but in > >> the binding style of closures. Functional languages tend to

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 2:00 PM, Rustom Mody wrote: > Yeah: Its 2014 (at least out here)... > About time we started using unicode in earnest dont you think?? We do. > Id like to see the following spellings corrected: > lambda to λ > in to ∈ > (preferably with the 'in' predicate and the 'in' in '

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Mark H Harris
On 3/24/14 10:00 PM, Rustom Mody wrote: About time we started using unicode in earnest dont you think?? Id like to see the following spellings corrected: lambda to λ great idea! {snip} [And now I hand it over to our very dear resident troll to explain the glories of the FSR] Now, that'

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Mark H Harris
On 3/24/14 10:17 PM, Chris Angelico wrote: On Tue, Mar 25, 2014 at 2:00 PM, Rustom Mody wrote: Yeah: Its 2014 (at least out here)... About time we started using unicode in earnest dont you think?? We do. Id like to see the following spellings corrected: lambda to λ in to ∈ (preferably with

Re: advice on sub-classing multiprocessing.Process and multiprocessing.BaseManager

2014-03-24 Thread matt . newville
On Monday, March 24, 2014 7:19:56 PM UTC-5, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 7:24 AM, Matt Newville > > > I'm maintaining a python interface to a C library for a distributed > > control system (EPICS, sort of a SCADA system) that does a large > > amount of relatively light-weight ne

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Mark H Harris
On 3/24/14 10:25 PM, Mark H Harris wrote: but, rats, can't find \ lambda Ok, there we go -> λ and ∈ and ∉ and ∀ no problem. -- https://mail.python.org/mailman/listinfo/python-list

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Roy Smith
In article , Chris Angelico wrote: > On Tue, Mar 25, 2014 at 2:00 PM, Rustom Mody wrote: > > Yeah: Its 2014 (at least out here)... > > About time we started using unicode in earnest dont you think?? > > We do. > > > Id like to see the following spellings corrected: > > lambda to λ > > in to

Re: advice on sub-classing multiprocessing.Process and multiprocessing.BaseManager

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 2:27 PM, wrote: > Thanks for the reply. I find that appreciation is greatly (perhaps > infinitely) delayed whenever I reply "X is probably not what you want to do" > without further explanation to a question of "can I get some advice on how to > do X?". So, I do thank

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 8:47:35 AM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 2:00 PM, Rustom Mody wrote: > > Yeah: Its 2014 (at least out here)... > > About time we started using unicode in earnest dont you think?? > We do. > > Id like to see the following spellings corrected:

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 12:28:16 AM UTC+5:30, Mark H. Harris wrote: > On 3/24/14 4:58 AM, Mark Lawrence wrote: > > Where do you get reduce from if it's not in the standard library? > That was "a" proposal for 3000. Its there, but its not on the > built-ins; ie., you have to import it. The

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-24 Thread Mark H Harris
On 3/24/14 8:45 PM, Steven D'Aprano wrote: Your insistence that lambda is confusing is awfully condescending. People are not as dumb as you insist, and they are perfectly capable of learning lambda without a comp sci degree. Like any technical jargon, there is vocabulary and meaning to learn, bu

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 2:29 PM, Roy Smith wrote: > I started programming on 029 keypunches and ASR-33 teletypes. If you asked > me to > type most of the punctuation we take for granted today (not to mention lower > case > letters), I would have looked at you as if you had asked me to type some

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 2:43 PM, Rustom Mody wrote: > What you are missing is that programmers spend > 90% of their time reading code > 10% writing code > > You may well be in the super-whiz category (not being sarcastic here) > All that will change is upto 70-30. (ecause you rarely make a mistake

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 8:47:35 AM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 2:00 PM, Rustom Mody wrote: > > Yeah: Its 2014 (at least out here)... > > About time we started using unicode in earnest dont you think?? > We do. > > Id like to see the following spellings corrected:

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Mark H Harris
On 3/24/14 10:51 PM, Chris Angelico wrote: Supporting both may look tempting, but you effectively create two ways of spelling the exact same thing; it'd be like C's trigraphs. Do you know what ??= is, This was a fit for me, back in the day IBM (system36 & system38). When we started supporting

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 9:29:57 AM UTC+5:30, Mark H. Harris wrote: > On 3/24/14 10:51 PM, Chris Angelico wrote: > > Supporting both may look tempting, but you effectively create two ways > > of spelling the exact same thing; it'd be like C's trigraphs. Do you > > know what ??= is, > This was a

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 2:56 PM, Rustom Mody > I don't know about the difference between {} in set theory and Python, >> but the multiple uses of () actually boil down to two: > > In set theory {} makes sets > In python {} makes dictionaries That's a backward-compatibility issue. Braces in Python

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 2:59 PM, Mark H Harris wrote: > I personally think the answer is extended key maps triggered by meta keys > shift ctrl opt alt command | which call up full alternate mappings of > Greek|Latin|Math|symbols &c which can be chosen by mouse|pointing device. > > > The mac calls

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 3:08 PM, Rustom Mody wrote: > And Chris is right in (rephrasing) we may have unicode-happy OSes and > languages. We cant reasonably have unicode-happy keyboards. > [What would a million-key keyboard look like? Lets leave the cost aside...] Actually, it wouldn't be that bad

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 9:59:48 AM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 3:08 PM, Rustom Mody wrote: > > And Chris is right in (rephrasing) we may have unicode-happy OSes and > > languages. We cant reasonably have unicode-happy keyboards. > > [What would a million-key keyboa

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-24 Thread Chris Angelico
On Tue, Mar 25, 2014 at 4:00 PM, Rustom Mody wrote: > Its already there -- and even easier > Switch to cyrillic-jis-russian (whatever that is!) > and I get л from k Л from K How quickly can you switch, type one letter (to generate one Cyrillic character), and switch back? If you can do that more

  1   2   >