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 21:39:33 -0500, Mark H Harris wrote: > 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 >>

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:15:11 PM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 5:35 PM, Rustom Mody wrote: > > I dont think we are anywhere near making real suggestions for real changes > > which would need to talk of compatibility, portability, editor support > > and all such oth

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 5:41 PM, Rustom Mody wrote: > ALl of which is isomorphic to Steven's point that forty is less > eyeballable than 40 > > And mine that ∅ is more eyeballable than set([]) I don't disagree that it is; the short tokens are easier to read in quantity. I just don't think that it

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

2014-03-24 Thread Mark H Harris
On 3/25/14 12:08 AM, Chris Angelico wrote: How quickly can you switch, type one letter (to generate one Cyrillic character), and switch back? Ok.. after installing Ukelete from Summer Institute of Linguistics SIL I can now edit the installed keymaps and select them from input sources at the t

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 5:35 PM, Rustom Mody wrote: > I dont think we are anywhere near making real suggestions for real changes > which would need to talk of compatibility, portability, editor support > and all such other good stuff. > > Just a bit of brainstorming to see how an alternative pytho

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:03:24 PM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 5:10 PM, Rustom Mody wrote: > > Something that Chris may relate to: > > You type a music score into lilypond > > Then call lilypond to convert it into standard western staff notation > > Why not put up

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

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 11:42:50 AM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 25, 2014 at 4:47 PM, Steven D'Aprano wrote: > > On Tue, 25 Mar 2014 14:57:02 +1100, Chris Angelico wrote: > >> No, I'm not missing that. But the human brain is a tokenizer, just as > >> Python is. Once you know wha

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 5:10 PM, Rustom Mody wrote: > Something that Chris may relate to: > > You type a music score into lilypond > Then call lilypond to convert it into standard western staff notation > > Why not put up the lilypond (ASCII) directly on the piano/organ when you play? > > This is

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 19:16:15 -0500, 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. ...

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 5:04 PM, Steven D'Aprano wrote: >> I can get up a character map on any platform fairly easily, and if not, >> I can always Google the name of the character I want and copy and paste >> from fileformat.info or some other handy site. It's not that hard. But >> if I want to sa

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 17:58:11 -0600, Ian Kelly wrote: > On Mon, Mar 24, 2014 at 3:43 PM, Mark H Harris > wrote: >>Aside from the sin of spelling out "lambda," >> should be ( \x y -> x + y ) a b ) but, neither here nor >> there... > > Well no, it *should* be λx y . x + y but app

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 18:44:37 -0500, 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! > > Yes, yes, yes, and example: > > adder

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:56 PM, Mark H Harris wrote: > On 3/25/14 12:48 AM, Chris Angelico wrote: >> >> Yup. Welcome to timezones. I'm UTC +11 here, although we'll drop back >> to +10 shortly as DST finishes (yay!). It's currently 0547 UTC, so >> you're presumably five hours behind UTC, which wou

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

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 11:17:51 AM UTC+5:30, Steven D'Aprano wrote: > On Tue, 25 Mar 2014 14:57:02 +1100, Chris Angelico wrote: > > 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 catego

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:47 PM, Steven D'Aprano wrote: > On Tue, 25 Mar 2014 14:57:02 +1100, Chris Angelico wrote: >> No, I'm not missing that. But the human brain is a tokenizer, just as >> Python is. Once you know what a token means, you comprehend it as that >> token, and it takes up space in

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

2014-03-24 Thread Steven D'Aprano
On Tue, 25 Mar 2014 00:14:42 -0500, Mark H Harris wrote: > On 3/25/14 12:08 AM, Chris Angelico wrote: > >> How quickly can you switch, type one letter (to generate one Cyrillic >> character), and switch back? > > ... very fast. > > Is not this nicer? > > >>> Π = pi That's the product operato

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

2014-03-24 Thread Steven D'Aprano
On Tue, 25 Mar 2014 15:19:50 +1100, Chris Angelico wrote: > 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

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

2014-03-24 Thread Mark H Harris
On 3/25/14 12:48 AM, Chris Angelico wrote: (Especially since your mailer is putting the dates as mm/dd/yy, which is an abomination peculiar to Americans.) I did not know that; so is 25 Mar 2014 the preferred way? marcus -- 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 Mark H Harris
On 3/25/14 12:48 AM, Chris Angelico wrote: Yup. Welcome to timezones. I'm UTC +11 here, although we'll drop back to +10 shortly as DST finishes (yay!). It's currently 0547 UTC, so you're presumably five hours behind UTC, which would put you east coast USA, most likely. (Especially since your mail

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:42 PM, Rustom Mody wrote: > You are not counting mouse > For an emacs user > Looking at mouse counts as 3 keystrokes > Touching is more like 5-8 > https://sites.google.com/site/steveyegge2/effective-emacs I think the cost of the mouse varies according to technology. I'm

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

2014-03-24 Thread Steven D'Aprano
On Tue, 25 Mar 2014 14:57:02 +1100, Chris Angelico wrote: > 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) >>

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

2014-03-24 Thread Mark H Harris
On 3/25/14 12:42 AM, Rustom Mody wrote: You are not counting mouse For an emacs user Looking at mouse counts as 3 keystrokes ha! I would not be surprised that just "thinking" about the mouse might be worth 3 key-strokes for an emacs user! I use vi all the time; emacs less; depends on the

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:34 PM, Mark H Harris wrote: > Because the character selector is up on the gui (for me, far left) and the > two strokes are {mouse click the Π } and {mouse click the insert}; rather > than {p} {i} . There is of course a brief time-lag because my right hand > has to move t

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

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 11:04:40 AM UTC+5:30, Mark H. Harris wrote: > On 3/25/14 12:27 AM, Chris Angelico wrote: > >> my pdeclib constants extension will have alternate spellings for Π and > >> Γ > >> and Δ and others... > > That's good! (Although typing Π quicker than pi is majorly pushing

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 4:28 PM, Steven D'Aprano wrote: > On Tue, 25 Mar 2014 06:57:19 +1100, Chris Angelico wrote: > >> Can you imagine a high level language without a simple notation for >> variable assignment? Certainly not. > > I don't know... what a stack based or concatenative language like

Re: Question about Source Control

2014-03-24 Thread Frank Millman
"Rustom Mody" wrote in message news:19d3ddc9-0fb9-476d-a117-e5f174eca...@googlegroups.com... > 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

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

2014-03-24 Thread Mark H Harris
On 3/25/14 12:28 AM, Rustom Mody wrote: π = pi sin(π/4) 0.7071067811865475 cos(π/4) 0.7071067811865476 Looks better in emacs Input with tex mode -- 1 char to switch slightly verbose to type -- \pi gives π \Pi gives Π Whoohoo... yes, way more betterer/ :) -- https://mail.python.org/mailma

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

2014-03-24 Thread Mark H Harris
On 3/25/14 12:27 AM, Chris Angelico wrote: my pdeclib constants extension will have alternate spellings for Π and Γ and Δ and others... That's good! (Although typing Π quicker than pi is majorly pushing it. Well, I'll tell ya, its exactly the same--- two key-strokes, believe it or not.

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:23 PM, Rustom Mody wrote: > So let me talk of which input methods I use -- devanagari and tex. > I have devanagari-itrans set up in emacs as default (other) input method > So Ctrl-\ (ie 1½ keystrokes) puts emacs into devanagari mode Yes, but putting emacs into a differen

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

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 10:44:42 AM UTC+5:30, Mark H. Harris wrote: > On 3/25/14 12:08 AM, Chris Angelico wrote: > > How quickly can you switch, type one letter (to generate one Cyrillic > > character), and switch back? > ... very fast. > Is not this nicer? > >>> Π = pi > >>> sin(Π/4) > 0

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:57:19 +1100, Chris Angelico wrote: > Can you imagine a high level language without a simple notation for > variable assignment? Certainly not. I don't know... what a stack based or concatenative language like Forth, Postscript, Joy or Factor count as high-level? I'm prett

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:14 PM, Mark H Harris wrote: > On 3/25/14 12:08 AM, Chris Angelico wrote: > >> How quickly can you switch, type one letter (to generate one Cyrillic >> character), and switch back? > > > ... very fast. > > Is not this nicer? > Π = pi sin(Π/4) > 0.70710678118

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

2014-03-24 Thread Rustom Mody
On Tuesday, March 25, 2014 10:38:43 AM UTC+5:30, Chris Angelico wrote: > 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

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

2014-03-24 Thread Mark H Harris
On 3/25/14 12:08 AM, Chris Angelico wrote: How quickly can you switch, type one letter (to generate one Cyrillic character), and switch back? ... very fast. Is not this nicer? >>> Π = pi >>> >>> sin(Π/4) 0.7071067811865475 >>> >>> cos(Π/4) 0.7071067811865476 >>> my pdeclib constants exte

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

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 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 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 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 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 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 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 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 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: 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 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: 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: 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 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: 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 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: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 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 '

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: 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

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 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 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 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 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 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: 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 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: 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 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 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 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: 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 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: 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 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 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 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: 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 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: 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 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 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 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 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: 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

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: 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

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

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

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

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: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: 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 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: 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 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 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 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: 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 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: 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

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: 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

  1   2   >