Re: What does a list comprehension do

2015-11-25 Thread dieter
Antoon Pardon writes: > Op 20-11-15 om 08:49 schreef dieter: >> In addition, the last few days have had two discussions in this list >> demonstrating the conceptial difficulties of late binding -- one of them: >> >> Why does "[lambda x: i * x for i in range(4)]" gives >> a list of ess

Re: Help needed with compiling python

2015-11-25 Thread Cecil Westerhof
On Wednesday 25 Nov 2015 23:58 CET, Laura Creighton wrote: > In a message of Wed, 25 Nov 2015 22:52:23 +0100, Cecil Westerhof > writes: >> >> My system python was all-ready damaged: that is why I wanted to >> build myself. > > Your Suse system probably wants to use python for something. If your >

Re: Help needed with compiling python

2015-11-25 Thread Cecil Westerhof
On Wednesday 25 Nov 2015 23:39 CET, Zachary Ware wrote: > On Wed, Nov 25, 2015 at 3:52 PM, Cecil Westerhof wrote: >> My system python was all-ready damaged: that is why I wanted to >> build myself. > > Then you should try to repair the system Python install via the > system package manager. It's

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Marko Rauhamaa
Steven D'Aprano : > Making tuples mutable would break their use as dictionary keys, which is a > *critical* use. No, it wouldn't. Any object that provides __hash__() and __eq__() can be used as a key. Nothing prevents using mutable objects as keys in Python. Egon Spengler: There's something

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Larry Hudson via Python-list
On 11/25/2015 12:32 AM, Chris Angelico wrote: On Wed, Nov 25, 2015 at 7:14 PM, Antoon Pardon wrote: [snip] "Oh come on. It's basic arithmetic. You should be able to add 7 and 7... the result's 14!" "But it's so confusing. Why can't it be 16? It'd be more convenient for me if it were 16." N

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Marko Rauhamaa
BartC : > Clearly a huge amount of programming can be done without having to deal > with first-class functions (or constructing functions at run-time; that > sounds fun). (Or without using OOP, another thing I can't stand.) Even the lowliest code monkeys deal with on-the-fly functions and OOP nowa

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Mark Lawrence
On 26/11/2015 05:08, Ben Finney wrote: Ned Batchelder writes: For someone who claims to be interested in language design, you're remarkably dismissive of pretty much the entire industry. I don't think it's worth the effort to try to change your mind. +1. BartC, when you want to join us in d

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ben Finney
Ned Batchelder writes: > For someone who claims to be interested in language design, you're > remarkably dismissive of pretty much the entire industry. I don't > think it's worth the effort to try to change your mind. +1. BartC, when you want to join us in discussions on good faith – that is, h

Semantics of collection types (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?))

2015-11-25 Thread Ben Finney
Ian Kelly writes: > On Wed, Nov 25, 2015 at 5:52 PM, Random832 wrote: > > On 2015-11-25, Ben Finney wrote: > >> That is, the ‘2’ in ‘cartesian_point = (2, 3)’ means something > >> different than in ‘cartesian_point = (3, 2)’. > >> > >> Whereas the ‘2’ in ‘test_scores = [2, 3]’ means exactly the

Re: What is a function parameter =[] for?

2015-11-25 Thread Alan Bawden
Chris Angelico writes: > On Thu, Nov 26, 2015 at 1:08 PM, Alan Bawden wrote: >> (Note that nothing in the documentation I can find actually _guarantees_ >> that a Python implementation will only have one unique empty tuple, but >> I wouldn't be suprised if the following is nonetheless true in al

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 5:52 PM, Random832 wrote: > On 2015-11-25, Ben Finney wrote: >> That is, the ‘2’ in ‘cartesian_point = (2, 3)’ means something different >> than in ‘cartesian_point = (3, 2)’. >> >> Whereas the ‘2’ in ‘test_scores = [2, 3]’ means exactly the same as in >> ‘test_scores = [3

Re: What is a function parameter =[] for?

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 1:46 PM, Ian Kelly wrote: > On Wed, Nov 25, 2015 at 7:25 PM, Chris Angelico wrote: >> On Thu, Nov 26, 2015 at 1:08 PM, Alan Bawden wrote: >>> (Note that nothing in the documentation I can find actually _guarantees_ >>> that a Python implementation will only have one uniqu

Re: What is a function parameter =[] for?

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 7:25 PM, Chris Angelico wrote: > On Thu, Nov 26, 2015 at 1:08 PM, Alan Bawden wrote: >> (Note that nothing in the documentation I can find actually _guarantees_ >> that a Python implementation will only have one unique empty tuple, but >> I wouldn't be suprised if the foll

Re: What is a function parameter =[] for?

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 1:08 PM, Alan Bawden wrote: > (Note that nothing in the documentation I can find actually _guarantees_ > that a Python implementation will only have one unique empty tuple, but > I wouldn't be suprised if the following is nonetheless true in all > current implementations: >

Re: What is a function parameter =[] for?

2015-11-25 Thread Alan Bawden
Steven D'Aprano writes: > In fact, it's easy to find cases even now where the compiler is > insufficiently smart to recognise all the possible optimizations available. > There's no tuple simpler than the empty tuple, but Python 3.3 at least > fails to optimize that case: > > py> dis(compile("()",

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Steven D'Aprano
On Thu, 26 Nov 2015 12:20 am, BartC wrote: > On 25/11/2015 10:52, Steven D'Aprano wrote: >> On Wed, 25 Nov 2015 07:14 pm, Antoon Pardon wrote: > >>> What exactly is your point? >> >> That there is a simple analogy between the distinction between code >> inside/outside a for-loop, and code inside/

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ned Batchelder
On Wednesday, November 25, 2015 at 8:23:36 PM UTC-5, BartC wrote: > On 26/11/2015 00:31, Steven D'Aprano wrote: > > On Thu, 26 Nov 2015 09:41 am, BartC wrote: > > > >> Maybe you're too familiar with it. But the idea of executing the > >> function and other definitions in a file, instead of they jus

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 26/11/2015 00:31, Steven D'Aprano wrote: On Thu, 26 Nov 2015 09:41 am, BartC wrote: Maybe you're too familiar with it. But the idea of executing the function and other definitions in a file, instead of they just being there, is novel. It really, truly isn't. Your viewpoint is clouded by t

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread TP
On Wed, Nov 25, 2015 at 12:42 PM, ryguy7272 wrote: > Hello experts. I'm looking at this url: > https://en.wikipedia.org/wiki/Wikipedia:Unusual_place_names Wildly offtopic but interesting, easy way to grab/analyze Wikipedia data using F# instead of Python http://evelinag.com/blog/2015/11-18-f-tac

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Grobu
Chris, Marko, thank you both for your links and explanations! -- https://mail.python.org/mailman/listinfo/python-list

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Steven D'Aprano
On Thu, 26 Nov 2015 01:34 am, BartC wrote: > On 25/11/2015 13:53, Marko Rauhamaa wrote: >> BartC : >> >>> Using tuples in the same way that other languages implement records is >>> going to be difficult if you can't change the values of the fields! >> >> Guido could decide tomorrow that tuples are

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Random832
On 2015-11-25, Ben Finney wrote: > That is, the ‘2’ in ‘cartesian_point = (2, 3)’ means something different > than in ‘cartesian_point = (3, 2)’. > > Whereas the ‘2’ in ‘test_scores = [2, 3]’ means exactly the same as in > ‘test_scores = [3, 2]’. > > If each position in the sequence gives the valu

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Steven D'Aprano
On Thu, 26 Nov 2015 09:41 am, BartC wrote: > Maybe you're too familiar with it. But the idea of executing the > function and other definitions in a file, instead of they just being > there, is novel. It really, truly isn't. Your viewpoint is clouded by too much immersion in crippled languages. *

Re: What is a function parameter =[] for?

2015-11-25 Thread Steven D'Aprano
On Thu, 26 Nov 2015 05:27 am, Antoon Pardon wrote: > Op 25-11-15 om 18:40 schreef Steven D'Aprano: >> On Wed, 25 Nov 2015 08:56 pm, Antoon Pardon wrote: >> >>> Since (x, y, z) is not a fixed value, it is not a literal. >> >> Right. And therefore, (x, y, z) syntax is not syntax for a literal. Hen

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 10:53 AM, Marko Rauhamaa wrote: > Regular expressions can handle any regular language just fine. They are > commonly used to define the lexical tokens of a language. Not sure about _defining_ them, but they're certainly often used to _recognize_ them, eg in syntax highligh

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Marko Rauhamaa
Grobu : > Sorry, I wasn't aware of regex being on the dark side :-) No, regular expressions are great for many purposes. Parsing context-free syntax isn't one of them. See: https://en.wikipedia.org/wiki/Chomsky_hierarchy#The_hierarchy> Most modern programming languages including HTML are con

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 10:44 AM, Grobu wrote: > On 26/11/15 00:06, Chris Angelico wrote: >> >> On Thu, Nov 26, 2015 at 9:48 AM, ryguy7272 wrote: >>> >>> Thanks!! Is that regex? Can you explain exactly what it is doing? >>> Also, it seems to pick up a lot more than just the list I wanted, but >

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Grobu
On 26/11/15 00:06, Chris Angelico wrote: On Thu, Nov 26, 2015 at 9:48 AM, ryguy7272 wrote: Thanks!! Is that regex? Can you explain exactly what it is doing? Also, it seems to pick up a lot more than just the list I wanted, but that's ok, I can see why it does that. Can you just please expla

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 10:37 AM, ryguy7272 wrote: > Wow! Awesome! I bookmarked that link! > Thanks for everything!!! Also bookmark this link: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags And read it before you do any parsing of HTML using

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread ryguy7272
On Wednesday, November 25, 2015 at 6:34:00 PM UTC-5, Grobu wrote: > On 25/11/15 23:48, ryguy7272 wrote: > >> re.findall( r'\]+title="(.+?)"', html ) > [ ... ] > > Thanks!! Is that regex? Can you explain exactly what it is doing? > > Also, it seems to pick up a lot more than just the list I wanted

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Grobu
On 25/11/15 23:48, ryguy7272 wrote: re.findall( r'\]+title="(.+?)"', html ) [ ... ] Thanks!! Is that regex? Can you explain exactly what it is doing? Also, it seems to pick up a lot more than just the list I wanted, but that's ok, I can see why it does that. Can you just please explain wha

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 9:48 AM, ryguy7272 wrote: > Thanks!! Is that regex? Can you explain exactly what it is doing? > Also, it seems to pick up a lot more than just the list I wanted, but that's > ok, I can see why it does that. > > Can you just please explain what it's doing??? It's a trap!

Re: Help needed with compiling python

2015-11-25 Thread Laura Creighton
In a message of Wed, 25 Nov 2015 22:52:23 +0100, Cecil Westerhof writes: > >My system python was all-ready damaged: that is why I wanted to build >myself. Your Suse system probably wants to use python for something. If your system python is damaged, you badly need to fix that, using the system p

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread ryguy7272
On Wednesday, November 25, 2015 at 5:30:14 PM UTC-5, Grobu wrote: > Hi > > It seems that links on that Wikipedia page follow the structure : > > > You could extract a list of link titles with something like : > re.findall( r'\]+title="(.+?)"', html ) > > HTH, > > -Grobu- > > > On 25/11/15 21

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 22:16, Marko Rauhamaa wrote: BartC : I'm interested in language design because that's what I've done on and off for over 30 years. And I'm discussing some design decisions in Python. That *is* a fun ambition, useful or not. (At the moment, it's mostly fun. But in the past I ac

Re: Help needed with compiling python

2015-11-25 Thread Zachary Ware
On Wed, Nov 25, 2015 at 3:52 PM, Cecil Westerhof wrote: > My system python was all-ready damaged: that is why I wanted to build > myself. Then you should try to repair the system Python install via the system package manager. It's not worth the hassle to try to replace it; it almost certainly wo

Re: What is a function parameter =[] for?

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 2:05 PM, Antoon Pardon wrote: > Op 25-11-15 om 21:39 schreef Ian Kelly: >> On Wed, Nov 25, 2015 at 11:27 AM, Antoon Pardon >> wrote: >>> I don't know what you are talking about. The first thing I have argued >>> is that () is a literal. Then I have expaned that to that som

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Grobu
Hi It seems that links on that Wikipedia page follow the structure : You could extract a list of link titles with something like : re.findall( r'\]+title="(.+?)"', html ) HTH, -Grobu- On 25/11/15 21:55, MRAB wrote: On 2015-11-25 20:42, ryguy7272 wrote: Hello experts. I'm looking at this

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Marko Rauhamaa
BartC : > I'm interested in language design because that's what I've done on and > off for over 30 years. And I'm discussing some design decisions in > Python. That *is* a fun ambition, useful or not. However, while I'm very choosy and critical when it comes to my programming tools, I'm extremel

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 9:04 AM, ryguy7272 wrote: > Ok, I guess that makes sense. So, I just tried the script below, and got > nothing... > > import requests > from bs4 import BeautifulSoup > > r = > requests.get("https://en.wikipedia.org/wiki/Wikipedia:Unusual_place_names";) > soup = Beautiful

Re: What is a function parameter =[] for?

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 8:05 AM, Antoon Pardon wrote: > Op 25-11-15 om 21:39 schreef Ian Kelly: >> On Wed, Nov 25, 2015 at 11:27 AM, Antoon Pardon >> wrote: >>> I don't know what you are talking about. The first thing I have argued >>> is that () is a literal. Then I have expaned that to that som

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread ryguy7272
On Wednesday, November 25, 2015 at 3:42:21 PM UTC-5, ryguy7272 wrote: > Hello experts. I'm looking at this url: > https://en.wikipedia.org/wiki/Wikipedia:Unusual_place_names > > I'm trying to figure out how to list all 'a title' elements. For instance, I > see the following: > Accident > href=

Re: Help needed with compiling python

2015-11-25 Thread Cecil Westerhof
On Wednesday 25 Nov 2015 21:49 CET, Zachary Ware wrote: > On Wed, Nov 25, 2015 at 2:23 PM, Cecil Westerhof wrote: >> I wanted to install python myself. I started with 2.7.10. If that >> works I also will install 3.5.0. >> >> I did: >> ./configure --prefix=/usr >> make >> make altinstall >> >> I h

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 20:50, Mark Lawrence wrote: On 25/11/2015 17:18, BartC wrote: Can you please let us know what you're taking, what it costs and where we can get it, as we would also like to live in cloud cuckoo land, provided that The Price Is Right™. And I would really like to know what your p

Re: What is a function parameter =[] for?

2015-11-25 Thread Antoon Pardon
Op 25-11-15 om 21:39 schreef Ian Kelly: > On Wed, Nov 25, 2015 at 11:27 AM, Antoon Pardon > wrote: >> I don't know what you are talking about. The first thing I have argued >> is that () is a literal. Then I have expaned that to that something >> like (3, 5, 8) is a literal. I never argued that tu

Re: Multiplication [was Re: Late-binding of function defaults]

2015-11-25 Thread Marko Rauhamaa
Steven D'Aprano : > But by this time, we had already learned in secondary school that you can > use any of the following to write multiplication: > > x × y Not where I lived. (Those x's would have been a nightmare for the teacher who had to mark people's test answers.) > x ⋅ y Yes. After all, i

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Marko Rauhamaa
Ben Finney : > Perhaps it would be easier if you point out that ‘x’ doesn't mean > multiply either, and they've *already* been substituting that symbol > instead of the correct ‘×’ for multiply. In my childhood, we always used '·' for the multiplication sign until senior high school, when the vec

Re: Screen scraper to get all 'a title' elements

2015-11-25 Thread MRAB
On 2015-11-25 20:42, ryguy7272 wrote: Hello experts. I'm looking at this url: https://en.wikipedia.org/wiki/Wikipedia:Unusual_place_names I'm trying to figure out how to list all 'a title' elements. For instance, I see the following: Accident Ala-Lemu Alert Apocalypse Peaks So, I tried putti

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Mark Lawrence
On 25/11/2015 17:18, BartC wrote: On 25/11/2015 15:13, Ned Batchelder wrote: On Wednesday, November 25, 2015 at 8:20:59 AM UTC-5, BartC wrote: Accept that some things /are/ a source of confusion. When, in writing documentation, I find something hard to explain something, then I try and make it

Re: Help needed with compiling python

2015-11-25 Thread Zachary Ware
On Wed, Nov 25, 2015 at 2:23 PM, Cecil Westerhof wrote: > I wanted to install python myself. I started with 2.7.10. If that > works I also will install 3.5.0. > > I did: > ./configure --prefix=/usr > make > make altinstall > > I have: > /usr/bin/python2.7 > > But when I execute thi

Screen scraper to get all 'a title' elements

2015-11-25 Thread ryguy7272
Hello experts. I'm looking at this url: https://en.wikipedia.org/wiki/Wikipedia:Unusual_place_names I'm trying to figure out how to list all 'a title' elements. For instance, I see the following: Accident Ala-Lemu Alert Apocalypse Peaks So, I tried putting a script together to get 'title'. He

Re: list slice and generators

2015-11-25 Thread Pavlos Parissis
On 25/11/2015 11:07 πμ, Peter Otten wrote: > Pavlos Parissis wrote: > >> Hi, >> >> Do you see any possible dangerous hidden bug in the below code(using >> python2.7 and python3.4)? >> >> My goal is to avoid go through the metrics list twice. But, I don't >> know if there will be a problem with doi

Re: What is a function parameter =[] for?

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 11:27 AM, Antoon Pardon wrote: > I don't know what you are talking about. The first thing I have argued > is that () is a literal. Then I have expaned that to that something > like (3, 5, 8) is a literal. I never argued that tuple expressions > in general are literals. And

Help needed with compiling python

2015-11-25 Thread Cecil Westerhof
I wanted to install python myself. I started with 2.7.10. If that works I also will install 3.5.0. I did: ./configure --prefix=/usr make make altinstall I have: /usr/bin/python2.7 But when I execute this, I get: Could not find platform dependent libraries Consider settin

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ben Finney
Laura Creighton writes: > The great sticking point for the children I am teaching is '*' means > multiplication. […] that one can swap out a particular convention 'x > means multiply' and swap in another one '* means multiply' while > leaving the underlying truth unchanged. Perhaps it would be e

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ben Finney
Chris Angelico writes: > This is a distinction I generally make. Putting it another way: a list > has the same meaning regardless of how many items are on it (for > instance, a shopping list is still a shopping list whether it has five > or fifty items on it), where a tuple is a package where eac

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Emile van Sebille
On 11/25/2015 5:20 AM, BartC wrote: it seems to be more lucrative to write thicker user manuals, and provide longer training courses, than to make software simpler. If that were true, certainly by now the sufficiently thick manual would provide crystal clear explanations. :) I-don't-think-

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Emile van Sebille
On 11/25/2015 4:25 AM, Antoon Pardon wrote: I think there are reasons to find the above behaviour bizarre. I personnaly don't find it bizarre, but that is because I'm familiar with what is going on. Which I suspect is necessary. >but if someone expects the compilor to take a snapshot of L and

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 18:03, Ian Kelly wrote: On Wed, Nov 25, 2015 at 10:18 AM, BartC wrote: We have no way of evaluating their power or simplicity, since they are not available to us. I'll see if I can rustle up a comparison so that Python users can see what they're missing! Unless you're going to

Re: Multiplication [was Re: Late-binding of function defaults]

2015-11-25 Thread Laura Creighton
In a message of Thu, 26 Nov 2015 05:09:13 +1100, "Steven D'Aprano" writes: >On Thu, 26 Nov 2015 02:59 am, Laura Creighton wrote: > >> The great sticking point for the children I am teaching is >> '*' means multiplication. You can really see that some people >> have to make extensive mental modific

Re: What is a function parameter =[] for?

2015-11-25 Thread Jussi Piitulainen
Marko Rauhamaa writes: > Jussi Piitulainen writes: > >> You know, people have developed further ways to talk about these >> things precisely because substitution semantics is inadequate for >> what they wanted to talk about. > > "Assignment" is what everybody uses and understands. You can tell tha

Re: list slice and generators

2015-11-25 Thread Peter Otten
Ian Kelly wrote: > On Wed, Nov 25, 2015 at 10:44 AM, Ian Kelly wrote: >> On Wed, Nov 25, 2015 at 3:07 AM, Peter Otten <__pete...@web.de> wrote: elif name in METRICS_AVG: >>> # writing a function that calculates the average without >>> # materialising the list left as

Re: What is a function parameter =[] for?

2015-11-25 Thread Antoon Pardon
Op 25-11-15 om 18:40 schreef Steven D'Aprano: > On Wed, 25 Nov 2015 08:56 pm, Antoon Pardon wrote: > >> Since (x, y, z) is not a fixed value, it is not a literal. > > Right. And therefore, (x, y, z) syntax is not syntax for a literal. Hence > why the Python docs call it a tuple display instead of

Re: list slice and generators

2015-11-25 Thread Peter Otten
Ian Kelly wrote: >>assert metrics > > metrics is always going to be an itertools.chain object at this > assert, so how could the assertion ever fail? Should an assertion ever fail? >From your reaction I conclude that it was puzzling and a comment like # always true in a boolean context would

Multiplication [was Re: Late-binding of function defaults]

2015-11-25 Thread Steven D'Aprano
On Thu, 26 Nov 2015 02:59 am, Laura Creighton wrote: > The great sticking point for the children I am teaching is > '*' means multiplication. You can really see that some people > have to make extensive mental modifications in order to handle > the concept that mathematical truths are expressed i

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 10:18 AM, BartC wrote: >> We have no way of evaluating their power or simplicity, >> since they are not available to us. > > I'll see if I can rustle up a comparison so that Python users can see what > they're missing! Unless you're going to make the actual languages avail

Re: list slice and generators

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 10:44 AM, Ian Kelly wrote: > On Wed, Nov 25, 2015 at 3:07 AM, Peter Otten <__pete...@web.de> wrote: >>> elif name in METRICS_AVG: >> # writing a function that calculates the average without >> # materialising the list left as an exercise ;) > >

Re: What is a function parameter =[] for?

2015-11-25 Thread Steven D'Aprano
On Wed, 25 Nov 2015 08:56 pm, Antoon Pardon wrote: > Since (x, y, z) is not a fixed value, it is not a literal. Right. And therefore, (x, y, z) syntax is not syntax for a literal. Hence why the Python docs call it a tuple display instead of a tuple literal -- no matter what x, y, z are. Even if t

Re: list slice and generators

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 3:07 AM, Peter Otten <__pete...@web.de> wrote: > to get down to one intermediate list. Avoiding the last one is a bit tricky: > > metrics = (converter(x.metric(name)) for x in self._server_per_proc) > metrics = (x for x in metrics if x is not None) > try: > # if there is

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 15:13, Ned Batchelder wrote: On Wednesday, November 25, 2015 at 8:20:59 AM UTC-5, BartC wrote: Accept that some things /are/ a source of confusion. When, in writing documentation, I find something hard to explain something, then I try and make it simpler in the program. But not eno

Re: What is a function parameter =[] for?

2015-11-25 Thread Marko Rauhamaa
Jussi Piitulainen : > Marko Rauhamaa writes: >> As far as the words "variable" and "binding" go, they are present in >> lambda calculus (1929 and on): > > So it's more than ten years earlier than I thought. Old enough, > anyway. Strictly speaking, that a Wikipedia article uses the words > "variabl

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 2:13 AM, Ned Batchelder wrote: > I agree with you: there are things about Python that surprise people. > That's because it's a programming language, and very very little about > programming languages is obvious. The best we can hope for is "familiar," > and even then, fami

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Arie van Wingerden
>and even then, familiar to who? High school algebra students will at >first be baffled by "x = x + 1", an equation which is clearly >unsatisfiable. Some languages are "better" in that specific case in my opinion (mind te double quotes :-) - Ada and Pascal use := instead of = which is simpler t

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Laura Creighton
In a message of Wed, 25 Nov 2015 07:13:41 -0800, Ned Batchelder writes: >That's because it's a programming language, and very very little about >programming languages is obvious. The best we can hope for is "familiar," >and even then, familiar to who? High school algebra students will at >first b

Re: Futex hang when running event loop on a separated thread

2015-11-25 Thread Zachary Ware
On Wed, Nov 25, 2015 at 8:10 AM, Marc Aymerich wrote: > problem solved ! > Just found out that threads should be started by fuse.init() in order > to run when fuse is backgrounded. Glad you found it; I would not have, not being a pyfuse user :) -- Zach -- https://mail.python.org/mailman/listin

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ned Batchelder
On Wednesday, November 25, 2015 at 8:20:59 AM UTC-5, BartC wrote: > Accept that some things /are/ a source of confusion. When, in writing > documentation, I find something hard to explain something, then I try > and make it simpler in the program. But not enough of that goes on: it > seems to be

Re: What is a function parameter =[] for?

2015-11-25 Thread Jussi Piitulainen
Marko Rauhamaa writes: > Jussi Piitulainen writes: > >> In point d, McCarthy refers to variables as variables; I'm sure this >> would go back to Church and 1940's at least, so I expect they used >> this word already back then. But the ability to store new content to >> the data structure that asso

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 13:53, Marko Rauhamaa wrote: BartC : Using tuples in the same way that other languages implement records is going to be difficult if you can't change the values of the fields! Guido could decide tomorrow that tuples are mutable. (Could that be done without breaking existing co

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Antoon Pardon
Op 25-11-15 om 14:24 schreef Chris Angelico: > On Wed, Nov 25, 2015 at 11:25 PM, Antoon Pardon > wrote: >>> But there's a big difference between those who guess wrong from a position >>> of ignorance, and then make an honest attempt to understand the behaviour >>> and why it actually does make sen

Re: Futex hang when running event loop on a separated thread

2015-11-25 Thread Marc Aymerich
On Tue, Nov 24, 2015 at 9:17 PM, Marc Aymerich wrote: > On Tue, Nov 24, 2015 at 8:41 PM, Zachary Ware > wrote: >> On Tue, Nov 24, 2015 at 12:37 PM, Marc Aymerich wrote: >>> still it appears to work only if the main thread is in the foreground >>> (as of calling Thread() with deamon=True), I don'

Re: What is a function parameter =[] for?

2015-11-25 Thread Marko Rauhamaa
Chris Angelico : > On Wed, Nov 25, 2015 at 11:48 PM, Marko Rauhamaa wrote: >> I think "binding" is too fancy a word to be used with conventional >> programming languages like Python. If your programming language has >> an assignment statement, "binding" is even nonsensical. Consider: >> >>def

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Marko Rauhamaa
BartC : > Using tuples in the same way that other languages implement records is > going to be difficult if you can't change the values of the fields! Guido could decide tomorrow that tuples are mutable. The decision is more or less arbitrary, and has to do with dictionary keys, I bet (not a part

What does a list comprehension do (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?))

2015-11-25 Thread Antoon Pardon
Op 20-11-15 om 08:49 schreef dieter: > In addition, the last few days have had two discussions in this list > demonstrating the conceptial difficulties of late binding -- one of them: > > Why does "[lambda x: i * x for i in range(4)]" gives > a list of essentially the same functions? C

Re: What is a function parameter =[] for?

2015-11-25 Thread Chris Angelico
On Wed, Nov 25, 2015 at 11:48 PM, Marko Rauhamaa wrote: > I think "binding" is too fancy a word to be used with conventional > programming languages like Python. If your programming language has an > assignment statement, "binding" is even nonsensical. Consider: > >def f(x): >x += 1 >

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Chris Angelico
On Thu, Nov 26, 2015 at 12:06 AM, Marko Rauhamaa wrote: > However, tuples are a way to represent records, groupings of related > values, where the semantics of each value is determined by its position > in the tuple. The members in a tuple are typically of different data > types. > > Lists are col

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 13:06, Marko Rauhamaa wrote: BartC : Then, from the point of view of a beginner, you have two distinct ways of representing a list of objects: a tuple and a list. Exactly why there have to be two is never really made clear beyond the inadequate explanation that one is immutable a

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Chris Angelico
On Wed, Nov 25, 2015 at 11:35 PM, BartC wrote: > One gotcha at least is well known. Where, in a language of the least > surprises, you might write: > > d1 = date (25,12,2010) > d2 = d1 > d2.year += 1 > > You would expect d1 and d2 to represent a period one year apart. In Python, > they would bo

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 10:52, Steven D'Aprano wrote: On Wed, 25 Nov 2015 07:14 pm, Antoon Pardon wrote: What exactly is your point? That there is a simple analogy between the distinction between code inside/outside a for-loop, and code inside/outside a function. If you can understand why this loops f

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Chris Angelico
On Wed, Nov 25, 2015 at 11:25 PM, Antoon Pardon wrote: >> But there's a big difference between those who guess wrong from a position >> of ignorance, and then make an honest attempt to understand the behaviour >> and why it actually does make sense and is even sometimes useful (even if >> they don

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Marko Rauhamaa
BartC : > That was in preference to other choices which I found difficult and > also elitist because of the advanced knowledge of CS and mathematics > that it seemed you were expected to know. Python is not a toy. It is a tool for advanced programmers. Mathematics has barely any touching point,

Re: What is a function parameter =[] for?

2015-11-25 Thread Marko Rauhamaa
Jussi Piitulainen : > In point d, McCarthy refers to variables as variables; I'm sure this > would go back to Church and 1940's at least, so I expect they used > this word already back then. But the ability to store new content to > the data structure that associates variables with stuff must be n

Re: readline and TAB-completion?

2015-11-25 Thread Ulli Horlacher
Peter Otten <__pete...@web.de> wrote: > > Is there a way to make TAB-completion work for other directories, too? > > Remove "/" from the set of delimiters: > > readline.set_completer_delims( > "".join(c for c in readline.get_completer_delims() if c != "/")) Great! > > murksigkeiten > > I

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 08:32, Chris Angelico wrote: On Wed, Nov 25, 2015 at 7:14 PM, Antoon Pardon wrote: What exactly is your point? People's confusions don't disappear because you as an expert have a good understanding of what is going on and so are no longer confused. Some aspects in the langauage a

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Antoon Pardon
Op 25-11-15 om 11:52 schreef Steven D'Aprano: > On Wed, 25 Nov 2015 07:14 pm, Antoon Pardon wrote: > >> Op 20-11-15 om 01:33 schreef Steven D'Aprano: >>> On Fri, 20 Nov 2015 07:57 am, Marko Rauhamaa wrote: >>> Laura Creighton : > My experience says that the people who are confused wan

Re: What is a function parameter =[] for?

2015-11-25 Thread Jussi Piitulainen
Antoon Pardon writes: > Op 25-11-15 om 01:55 schreef Laura Creighton: >> If I had a time machine, I would go back to early days of Python and >> ban the use of the term 'assignment' and 'value' both. I would >> insist that the term 'binding' be used instead, though if you want to >> use the verb

Re: Returning a result from 3 items in a list

2015-11-25 Thread Mark Lawrence
On 25/11/2015 10:26, Cai Gengyang wrote: But true, I will try to research my questions more in depth before posting here. Please also research how to intersperse your answers or bottom post. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our langua

Re: if else python

2015-11-25 Thread Thomas 'PointedEars' Lahn
Scott Montreuil wrote: > I have an if statement which seems to run both commands and I cannot > figure out why. (just learning so I may be missing something obvious) Any > ideas? Use a Python IDE and debugger. I recommend PyDev, but YMMV. > while True: > global latit,longt,jlatit,jlongt

Re: Is there an meaning of '[[]]' in a list?

2015-11-25 Thread Antoon Pardon
Op 23-11-15 om 09:57 schreef Peter Otten: > Quivis wrote: > >> On Thu, 19 Nov 2015 12:40:17 +0100, Peter Otten wrote: >> >>> those questions that are a little harder >> And just how is he going to determine what is hard? > Note that I said "a little harder", not "hard". > > Write down your next ten

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Steven D'Aprano
On Wed, 25 Nov 2015 07:43 pm, Marko Rauhamaa wrote: > One psychological problem I'm seeing in many answers here is that people > seem to want to defend the honor of Python. No, your other honour! (It's an Oglaf reference, and *definitely* not safe for work. I'm not even going to link to it.)

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Steven D'Aprano
On Wed, 25 Nov 2015 07:14 pm, Antoon Pardon wrote: > Op 20-11-15 om 01:33 schreef Steven D'Aprano: >> On Fri, 20 Nov 2015 07:57 am, Marko Rauhamaa wrote: >> >>> Laura Creighton : >>> My experience says that the people who are confused want lists to behave like tuples. period. i.e. they d

  1   2   >