Re: Reading in cooked mode
Cameron Simpson : > Plenty of people use editors that consider end-of-line to be a > separator and not a terminator, leading to supposed text files lacking > trailing newlines (or end-of-line of OS). I use an editor (emacs) that considers the end-of-line to be a byte among others. > I consider this sloppy and error prone. If any editor, emacs is smart, but it generally doesn't insert characters on its own. I like it that way. > So I'm happy to write code that errors if a line lacks a trailing > newline, and thus I consider the newline to be an intergral part of > the line. For sure, any file reader must think the situation through. Note, for example, that CPython doesn't require the source code file to end in a newline. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Help needed to create a Python extension library for an existing shared memory hash table library
Simon Hardy-Francis wrote: > Hi Python fans, I just released my first open source project ever called > SharedHashFile [1]. It's a shared memory hash table written in C. Some guy > on Quora asked [2] whether there's an extension library for Python coming > out. I would like to do one but I know little about Python. I was wondering > if anybody in this group has experience writing extension libraries for > Python? There are, as far as I know, a number of tools that can help you to create extension modules from C/C++ libraries (i.e. Python bin- dings for the library). One that I have used successfully with a largish C++ library of mine is shortly described here http://www.riverbankcomputing.com/software/sip/intro and the documentation and download are at http://pyqt.sourceforge.net/Docs/sip4/ http://www.riverbankcomputing.com/software/sip/download Since I haven't used any of the alternatives I can't comment on how good they are. A list of them can be found here https://wiki.python.org/moin/IntegratingPythonWithOtherLanguages Regards, Jens -- \ Jens Thoms Toerring ___ [email protected] \__ http://toerring.de -- https://mail.python.org/mailman/listinfo/python-list
Re: Help needed to create a Python extension library for an existing shared memory hash table library
On Sunday, March 23, 2014 6:37:11 PM UTC+5:30, Jens Thoms Toerring wrote: > Simon Hardy-Francis wrote: > > Hi Python fans, I just released my first open source project ever called > > SharedHashFile [1]. It's a shared memory hash table written in C. Some guy > > on Quora asked [2] whether there's an extension library for Python coming > > out. I would like to do one but I know little about Python. I was wondering > > if anybody in this group has experience writing extension libraries for > > Python? > There are, as far as I know, a number of tools that can help you > to create extension modules from C/C++ libraries (i.e. Python bin- > dings for the library). One that I have used successfully with a > largish C++ library of mine is shortly described here > http://www.riverbankcomputing.com/software/sip/intro > and the documentation and download are at > http://pyqt.sourceforge.net/Docs/sip4/ > http://www.riverbankcomputing.com/software/sip/download > Since I haven't used any of the alternatives I can't comment on > how good they are. A list of them can be found here > https://wiki.python.org/moin/IntegratingPythonWithOtherLanguages Thats an old looking list -- pyrex is on, boost is not Worst of all the basic builting extending/embedding seems to be not mentioned! Heres a list I posted recently https://mail.python.org/pipermail/python-list/2013-June/650250.html If it looks ok, maybe it should go up on that wiki -- https://mail.python.org/mailman/listinfo/python-list
Install CVXOPT in Windows 64 bit
Hello! I need to urgently install CVOXPT in my pc. However, it seems that it only works under 32 bit versions. Does anyone know about a way around this? Your advise will be much appreciated! Ines -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
> From: Dave Angel >To: [email protected] >Sent: Sunday, March 23, 2014 3:18 AM >Subject: Re: Question about Source Control > > >Albert-Jan Roskam Wrote in message: >> > >In addition to posting in html format, you have also set the font >size too small for me to easily read. Reason number 12 for >posting in text mode in a text newsgroup. Ooops, sorry. Below is the email again, hopefully more readable. One more thing (so this is not entirely a double post!). While reading these books I found that the authors were pretty religious about Clean Commits. I mean, ok, it's not a good idea to do one huge monolithic commit each month, but I felt they were exaggerating. But maybe I'm wrong and clean commits become more important when the number of collaborators get bigger. It's just so easy to fix something, and e.g. correct that typo in a docstring while you're at it. regards, Albert-Jan Hi, I can recommend the book "Pragmatic Guide to Git". Very practical and to the point: http://www.amazon.com/Pragmatic-Guide-Git-Programmers/dp/1934356727/ref=sr_1_1/184-0142481-0484062?ie=UTF8&qid=1395518159&sr=8-1&keywords=pragmatic+guide+to+git I addition, I read a big fat super-exhaustive book, I believe it' s this one (there are two Git books with a bat!): http://www.amazon.com/Version-Control-Git-collaborative-development/dp/1449316387/ref=sr_1_2/184-0142481-0484062?ie=UTF8&qid=1395518159&sr=8-2&keywords=pragmatic+guide+to+git The former is for common tasks that are not common enough to remember right away. The latter is for reference. I only have experience with git and subversion. I like git much better. But any SCM is better than none at all. Regards, Albert-Jan -- https://mail.python.org/mailman/listinfo/python-list
Re: Install CVXOPT in Windows 64 bit
On 23/03/2014 14:00, [email protected] wrote: Hello! I need to urgently install CVOXPT in my pc. However, it seems that it only works under 32 bit versions. Does anyone know about a way around this? Your advise will be much appreciated! Ines http://www.lfd.uci.edu/~gohlke/pythonlibs/#cvxopt -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
python installation on windows
Hi Everybody actually i want to run python on web browser. I downloaded python and installed but i'm not able to run it in browser but it running using command prompt. so i trying to install mod_wsgi 3.4. So i downloaded precompiled version mod_wsgi-3.4.ap22.win32-py2.6 and copied mod_wsgi.so file to C:\wamp\bin\apache\Apache2.2.11\modules after i'm trying to run .\configure on path C:\Documents and Settings\Rahul\Desktop\mod_wsgi-3.4.ap22.win32-py2.6 but it giving me error that .\configure is not recognized as internal or external command. So please suggest me what can i do for that, i'm so beginner to python and installing and configuring modules for apache. Thanks Rahul -- https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
On Saturday, March 22, 2014 6:21:30 AM UTC-5, tad na wrote:
> I am trying to get all the element data from the rss below.
>
> The only thing I am pulling is the first element.
> I don't understand why the for loop does not go through the entire rss.
> Here is my code
> try:
> from urllib2 import urlopen
> except ImportError:
> from urllib.request import urlopen
> from bs4 import BeautifulSoup
> soup = BeautifulSoup(urlopen('http://bl.ocks.org/mbostock.rss'))
> #print soup.find_all('item')
> #print (soup)
> for item in soup.find_all('item'):
> #for item in soup:
> title = soup.find('title').text
> link = soup.find('link').text
> item = soup.find('item').text
> print item
> print title
> print link
OK . second problem :)
I can print the date. not sure how to do this one..
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen
import urllib2
from bs4 import BeautifulSoup
soup = BeautifulSoup(urlopen('http://bl.ocks.org/mbostock.rss'))
#print soup.find_all('item')
#print (soup)
data = soup.find_all("item")
x=0
for item in soup.find_all('item'):
title = item.find('title').text
link = item.find('link').text
date = item.find('pubDate')
# print date
print('+')
print data[x].title.text
print data[x].link.text
print data[x].guid.text
print data[x].pubDate
x = x + 1
--
https://mail.python.org/mailman/listinfo/python-list
Re: python installation on windows
On Sunday, March 23, 2014 12:09:09 PM UTC-5, [email protected] wrote: > Hi Everybody > > > > actually i want to run python on web browser. I downloaded python and > installed but i'm not able to run it in browser but it running using command > prompt. so i trying to install mod_wsgi 3.4. So i downloaded precompiled > version mod_wsgi-3.4.ap22.win32-py2.6 and copied mod_wsgi.so file to > C:\wamp\bin\apache\Apache2.2.11\modules after i'm trying to run .\configure > on path C:\Documents and Settings\Rahul\Desktop\mod_wsgi-3.4.ap22.win32-py2.6 > but it giving me error that .\configure is not recognized as internal or > external command. > > > > So please suggest me what can i do for that, i'm so beginner to python and > installing and configuring modules for apache. > > > > Thanks > > Rahul To set up a web browser: 1.open a dos window 2.navigate to dir you want "served" 3.type "python -m SimpleHTTPServer &." -- https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
On Sunday, March 23, 2014 12:29:40 PM UTC-5, tad na wrote:
> On Saturday, March 22, 2014 6:21:30 AM UTC-5, tad na wrote:
>
> > I am trying to get all the element data from the rss below.
>
> >
>
> > The only thing I am pulling is the first element.
>
>
>
> > I don't understand why the for loop does not go through the entire rss.
>
>
>
> > Here is my code
>
> > try:
>
> > from urllib2 import urlopen
>
> > except ImportError:
>
> > from urllib.request import urlopen
>
> > from bs4 import BeautifulSoup
>
> > soup = BeautifulSoup(urlopen('http://bl.ocks.org/mbostock.rss'))
>
> > #print soup.find_all('item')
>
> > #print (soup)
>
> > for item in soup.find_all('item'):
>
> > #for item in soup:
>
> > title = soup.find('title').text
>
> > link = soup.find('link').text
>
> > item = soup.find('item').text
>
> > print item
>
> > print title
>
> > print link
>
> OK . second problem :)
>
> I can print the date. not sure how to do this one..
>
> try:
>
> from urllib2 import urlopen
>
> except ImportError:
>
> from urllib.request import urlopen
>
> import urllib2
>
> from bs4 import BeautifulSoup
>
>
>
> soup = BeautifulSoup(urlopen('http://bl.ocks.org/mbostock.rss'))
>
> #print soup.find_all('item')
>
> #print (soup)
>
> data = soup.find_all("item")
>
>
>
> x=0
>
> for item in soup.find_all('item'):
>
> title = item.find('title').text
>
> link = item.find('link').text
>
> date = item.find('pubDate')
>
># print date
>
> print('+')
>
> print data[x].title.text
>
> print data[x].link.text
>
> print data[x].guid.text
>
> print data[x].pubDate
>
> x = x + 1
meant to say CANNOT print the date
--
https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
On 23/03/2014 17:30, tad na wrote: Would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
On Mar 23, 2014 11:31 AM, "tad na" wrote:
> OK . second problem :)
> I can print the date. not sure how to do this one..
Why not? What happens when you try?
> try:
> from urllib2 import urlopen
> except ImportError:
> from urllib.request import urlopen
> import urllib2
> from bs4 import BeautifulSoup
>
> soup = BeautifulSoup(urlopen('http://bl.ocks.org/mbostock.rss'))
> #print soup.find_all('item')
> #print (soup)
> data = soup.find_all("item")
>
> x=0
> for item in soup.find_all('item'):
> title = item.find('title').text
> link = item.find('link').text
> date = item.find('pubDate')
># print date
> print('+')
> print data[x].title.text
> print data[x].link.text
> print data[x].guid.text
> print data[x].pubDate
> x = x + 1
data[x] should be the same object as item, no? If you want to keep track of
the current iteration index, a cleaner way to do that is by using enumerate:
for x, item in enumerate(soup.find_all('item')):
As far as printing the pubDate goes, why not start by getting its text
property as you do with the other tags? From there you can either print the
string out directly or parse it into a datetime object.
--
https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
On Sunday, March 23, 2014 12:40:04 PM UTC-5, Mark Lawrence wrote: > On 23/03/2014 17:30, tad na wrote: > Would you please use the mailing list > https://mail.python.org/mailman/listinfo/python-list or read and action > this https://wiki.python.org/moin/GoogleGroupsPython to prevent us > seeing double line spacing and single line paragraphs, thanks. > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > Mark Lawrence > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com mark not sure what i did wrong. The double line in the code is mine. it helps me keep things separate. -- https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
On 23/03/2014 17:30, tad na wrote: On Sunday, March 23, 2014 12:29:40 PM UTC-5, tad na wrote: On Saturday, March 22, 2014 6:21:30 AM UTC-5, tad na wrote: I am trying to get all the element data from the rss below. The only thing I am pulling is the first element. I don't understand why the for loop does not go through the entire rss. Here is my code I've snipped the bulk of the message, but imagine what the above looks like when its been back and forth through gg a few times, it's effectively unreadable. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: python installation on windows
On Sunday, March 23, 2014 12:33:02 PM UTC-5, tad na wrote: > On Sunday, March 23, 2014 12:09:09 PM UTC-5, [email protected] wrote: > > Hi Everybody > > actually i want to run python on web browser. I downloaded python and > > installed but i'm not able to run it in browser but it running using > > command prompt. so i trying to install mod_wsgi 3.4. So i downloaded > > precompiled version mod_wsgi-3.4.ap22.win32-py2.6 and copied mod_wsgi.so > > file to C:\wamp\bin\apache\Apache2.2.11\modules after i'm trying to run > > .\configure on path C:\Documents and > > Settings\Rahul\Desktop\mod_wsgi-3.4.ap22.win32-py2.6 but it giving me error > > that .\configure is not recognized as internal or external command. > > So please suggest me what can i do for that, i'm so beginner to python and > > installing and configuring modules for apache. > > Thanks > > Rahul > To set up a web browser: > 1.open a dos window > 2.navigate to dir you want "served" > 3.type "python -m SimpleHTTPServer &." 4. open browser and type http://localhost:/ -- https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
On Sunday, March 23, 2014 12:49:11 PM UTC-5, Ian wrote:
> On Mar 23, 2014 11:31 AM, "tad na" wrote:
> > OK . second problem :)
> > I can print the date. not sure how to do this one..
> Why not? What happens when you try?
> > try:
> > from urllib2 import urlopen
> > except ImportError:
> > from urllib.request import urlopen
> > import urllib2
> > from bs4 import BeautifulSoup
> > soup = BeautifulSoup(urlopen('http://bl.ocks.org/mbostock.rss'))
> > #print soup.find_all('item')
> > #print (soup)
> > data = soup.find_all("item")
> > x=0
> > for item in soup.find_all('item'):
> > title = item.find('title').text
> > link = item.find('link').text
> > date = item.find('pubDate')
> > # print date
> > print('+')
> > print data[x].title.text
> > print data[x].link.text
> > print data[x].guid.text
> > print data[x].pubDate
> > x = x + 1
> data[x] should be the same object as item, no? If you want to keep track of
> the current iteration index, a cleaner way to do that is by using enumerate:
> for x, item in enumerate(soup.find_all('item')):
> As far as printing the pubDate goes, why not start by getting its text
> property as you do with the other tags? From there you can either print the
> string out directly or parse it into a datetime object.
This is the error I get with
1. print data[x].pubDate.text
AttributeError: 'NoneType' object has no attribute 'text'
2. print data[x].pubDate
It results in "None"
--
https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
[email protected] writes: > I am trying to get all the element data from the rss below. […] > from bs4 import BeautifulSoup > > soup = BeautifulSoup(urlopen('http://bl.ocks.org/mbostock.rss')) RSS is not HTML; so BeautifulSoup is not a good tool to use for parsing RSS. Instead, you will do better if you use one of the libraries already written for RSS parsing https://wiki.python.org/moin/RssLibraries>. -- \ “To be is to do” —Plato | `\ “To do is to be” —Aristotle | _o__)“Do be do be do” —Sinatra | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: help with for loop----python 2.7.2
On Mar 23, 2014 3:56 PM, "tad na" wrote: > > This is the error I get with > 1. print data[x].pubDate.text > AttributeError: 'NoneType' object has no attribute 'text' > 2. print data[x].pubDate > It results in "None" So the problem is that it's not even finding the pubDate tag in the first place. Some sites on the Web suggest that beautiful soup normalizes all tags to lowercase; try looking for the pubdate tag instead. -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
On Mon, Mar 24, 2014 at 1:58 AM, Albert-Jan Roskam wrote: > One more thing (so this is not entirely a double post!). While reading these > books I found that the authors were pretty religious about Clean Commits. I > mean, ok, it's not a good idea to do one huge monolithic commit each month, > but I felt they were exaggerating. But maybe I'm wrong and clean commits > become more important when the number of collaborators get bigger. It's just > so easy to fix something, and e.g. correct that typo in a docstring while > you're at it. > It's important even with a single editor. When you go back and look at a commit, you should be able to read the summary and know immediately whether a particular line in it should have been edited or not. Combining changes into a single commit makes that harder. Commits are cheap. Do more of 'em rather than less. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
On 24Mar2014 09:56, Chris Angelico wrote: > On Mon, Mar 24, 2014 at 1:58 AM, Albert-Jan Roskam wrote: > > One more thing (so this is not entirely a double post!). While reading > > these books I found that the authors were pretty religious about Clean > > Commits. I mean, ok, it's not a good idea to do one huge monolithic commit > > each month, but I felt they were exaggerating. But maybe I'm wrong and > > clean commits become more important when the number of collaborators get > > bigger. It's just so easy to fix something, and e.g. correct that typo in a > > docstring while you're at it. > > > > It's important even with a single editor. When you go back and look at > a commit, you should be able to read the summary and know immediately > whether a particular line in it should have been edited or not. > Combining changes into a single commit makes that harder. > > Commits are cheap. Do more of 'em rather than less. I'm particularly fond of "hg record" (or the similar extension, "hg crecord"), which lets you commit just parts of a modified file. When I'm in a debugging branch, it gradually turns into a huge diff. "hg record" lets me commit specific parts of a diff in a single commit. Every so often I spent a little while cleaning out related changes that are going to stay so that the final diffness consists of debug statements and hacks-in-progress; much smaller. So I'll pick a file and run an "hg record that-file" and pick all the diff parts that involve, say, removing some parameter. And in goes a single commit with just that feature change. Lather, rinse, repeat for other small concrete changes. And then my "hg diff" is back to being managably readable. Cheers, -- Cameron Simpson Wagner's music is better than it sounds.- Mark Twain -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
On Mon, Mar 24, 2014 at 11:19 AM, Cameron Simpson wrote: > I'm particularly fond of "hg record" (or the similar extension, "hg > crecord"), which lets you commit just parts of a modified file. > > When I'm in a debugging branch, it gradually turns into a huge diff. > "hg record" lets me commit specific parts of a diff in a single > commit. Every so often I spent a little while cleaning out related > changes that are going to stay so that the final diffness consists > of debug statements and hacks-in-progress; much smaller. > > So I'll pick a file and run an "hg record that-file" and pick all > the diff parts that involve, say, removing some parameter. And in > goes a single commit with just that feature change. Lather, rinse, > repeat for other small concrete changes. > > And then my "hg diff" is back to being managably readable. > Absolutely agree. With git, the same functionality can be done by making use of the staging area; you can either add an entire file (all its changes), or do a partial add with "git add -p" or (more conveniently, but requires a GUI) "git gui". I do that *very* frequently. The only thing I would really like is a simple way to say "stage/commit the lines from here to there"; with git gui, I can either stage an entire hunk (everything until the next point where there's enough unchanged lines that the context breaks) or a single line (either an insertion or a removal). Gets tedious when you want to stage half of a large hunk. But other than that, yes, the functionality is awesome, letting you fidget your edits into readable commits. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
loop
Hello, I'm trying to create a for loop that starts at 100 and goes to 10Mllion. The increments are like this: 100, 1000, 1, . Basicaly adding a zero each iteration. I'm having problems trying to do it. Can somebody help me -- https://mail.python.org/mailman/listinfo/python-list
Re: loop
On 2014-03-24 00:35, [email protected] wrote: Hello, I'm trying to create a for loop that starts at 100 and goes to 10Mllion. The increments are like this: 100, 1000, 1, . Basicaly adding a zero each iteration. I'm having problems trying to do it. Can somebody help me Probably better to use a 'while' loop instead, multiplying by 10 on each iteration until the number exceeds 10 million. -- https://mail.python.org/mailman/listinfo/python-list
Re: loop
On Mon, Mar 24, 2014 at 11:35 AM, wrote: > Hello, > > I'm trying to create a for loop that starts at 100 and goes to 10Mllion. The > increments are like this: 100, 1000, 1, . Basicaly adding a zero each > iteration. I'm having problems trying to do it. Can somebody help me > That sounds like a logarithmic scale. Look at this: >>> 10**2 100 >>> 10**3 1000 ... >>> 10**7 1000 Do you know how to iterate from 2 to 7 inclusive? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: loop
On 24/03/2014 00:35, [email protected] wrote: Hello, I'm trying to create a for loop that starts at 100 and goes to 10Mllion. The increments are like this: 100, 1000, 1, . Basicaly adding a zero each iteration. I'm having problems trying to do it. Can somebody help me Start by rereading this http://docs.python.org/3/tutorial/controlflow.html#for-statements, give it another go and if you have problems post your code inline here and we'll help you out. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: loop
Thanks!! -- https://mail.python.org/mailman/listinfo/python-list
Re: loop
for i in (10**p for p in range(3, 8)): print(i) -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
On 24Mar2014 11:30, Chris Angelico wrote: > On Mon, Mar 24, 2014 at 11:19 AM, Cameron Simpson wrote: > > I'm particularly fond of "hg record" (or the similar extension, "hg > > crecord"), which lets you commit just parts of a modified file. > > > > When I'm in a debugging branch, it gradually turns into a huge diff. > > [...] Every so often I spent a little while cleaning out related > > changes that are going to stay so that the final diffness consists > > of debug statements and hacks-in-progress; much smaller. [...] > > Absolutely agree. With git, the same functionality can be done by > making use of the staging area; you can either add an entire file (all > its changes), or do a partial add with "git add -p" or (more > conveniently, but requires a GUI) "git gui". [...] > The only thing I would really like is a simple way to say > "stage/commit the lines from here to there"; with git gui, I can > either stage an entire hunk (everything until the next point where > there's enough unchanged lines that the context breaks) or a single > line (either an insertion or a removal). Gets tedious when you want to > stage half of a large hunk. [...] "hg record" has the same issue; you get to approve or ignore single diff chunks. However, there's no fundamental technical reason you can't pick and choose arbitrary lines. Based on things I've experienced use "hg record", it pretty clearly walks the user through the diff picking/rejecting chunks, and then temporarily replaces the target file(s) with versions containing only the selected diff chunks, and commits the files. Then it restores the original modified file, whose diff from the "tip" is now reduced. With some work, that could be done on a line-by-line basis. Cheers, -- Cameron Simpson I've always been a big Greenaway fan - I've seen and enjoyed "The Falls" for crying out loud.- Peter Alexander Merel -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
On 3/23/2014 6:56 PM, Chris Angelico wrote: On Mon, Mar 24, 2014 at 1:58 AM, Albert-Jan Roskam wrote: One more thing (so this is not entirely a double post!). While reading these books I found that the authors were pretty religious about Clean Commits. I mean, ok, it's not a good idea to do one huge monolithic commit each month, but I felt they were exaggerating. But maybe I'm wrong and clean commits become more important when the number of collaborators get bigger. It's just so easy to fix something, and e.g. correct that typo in a docstring while you're at it. It's important even with a single editor. When you go back and look at a commit, you should be able to read the summary and know immediately whether a particular line in it should have been edited or not. Combining changes into a single commit makes that harder. Commits are cheap. Do more of 'em rather than less. With multiple branches (as with 2.7, 3.4, and default for cpython) and multiple active developers (20?) commiting to those brances, commits are definitely not free. I would not exactly call them as cheap as you seem to imply either. That said, I have occasionally pushed interim changes that put code in an improved and stable state. N. Coughlan has suggested improving the cpython infrastructure and procedures to reduce the cost of commits to encourage more people to make more commits (in the sense of more lines changed, not more pieces) and improve cpython faster. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
On 24/03/2014 01:26, Terry Reedy wrote: On 3/23/2014 6:56 PM, Chris Angelico wrote: On Mon, Mar 24, 2014 at 1:58 AM, Albert-Jan Roskam wrote: One more thing (so this is not entirely a double post!). While reading these books I found that the authors were pretty religious about Clean Commits. I mean, ok, it's not a good idea to do one huge monolithic commit each month, but I felt they were exaggerating. But maybe I'm wrong and clean commits become more important when the number of collaborators get bigger. It's just so easy to fix something, and e.g. correct that typo in a docstring while you're at it. It's important even with a single editor. When you go back and look at a commit, you should be able to read the summary and know immediately whether a particular line in it should have been edited or not. Combining changes into a single commit makes that harder. Commits are cheap. Do more of 'em rather than less. With multiple branches (as with 2.7, 3.4, and default for cpython) and multiple active developers (20?) commiting to those brances, commits are definitely not free. I would not exactly call them as cheap as you seem to imply either. That said, I have occasionally pushed interim changes that put code in an improved and stable state. And consider that this has been simplified, at one point four branches plus default were being supported at the same time. N. Coughlan has suggested improving the cpython infrastructure and procedures to reduce the cost of commits to encourage more people to make more commits (in the sense of more lines changed, not more pieces) and improve cpython faster. Excellent. The most frustrating part of CPython development from my viewpoint is the massive number of open issues on the bug tracker that have patches, but simply sit there for years doing nothing except gather dust. Anything that can be done to improve this situation is IMHO long overdue and extremely welcome. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
On Mon, Mar 24, 2014 at 12:26 PM, Terry Reedy wrote: > With multiple branches (as with 2.7, 3.4, and default for cpython) and > multiple active developers (20?) commiting to those brances, commits are > definitely not free. I would not exactly call them as cheap as you seem to > imply either. That said, I have occasionally pushed interim changes that put > code in an improved and stable state. > > N. Coughlan has suggested improving the cpython infrastructure and > procedures to reduce the cost of commits to encourage more people to make > more commits (in the sense of more lines changed, not more pieces) and > improve cpython faster. When I call them cheap, what I mean is that there's little difference between a single commit and 2-3 commits as a group. Yes, there's a bit more difference when you're cherry-picking them to other branches, and maybe an infrastructure/procedure change could help with that; but once they're there in history, it doesn't hurt to have three separate commits doing related work, keeping the distinct parts distinct. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python installation on windows
On Sun, 23 Mar 2014 17:09:09 -, wrote: Hi Everybody actually i want to run python on web browser. Actually you don't. You want to run Python on a web server, which fortunately is a good deal easier. I downloaded python and installed but i'm not able to run it in browser but it running using command prompt. so i trying to install mod_wsgi 3.4. So i downloaded precompiled version mod_wsgi-3.4.ap22.win32-py2.6 and copied mod_wsgi.so file to C:\wamp\bin\apache\Apache2.2.11\modules after i'm trying to run .\configure on path C:\Documents and Settings\Rahul\Desktop\mod_wsgi-3.4.ap22.win32-py2.6 but it giving me error that .\configure is not recognized as internal or external command. So please suggest me what can i do for that, i'm so beginner to python and installing and configuring modules for apache. The ".\configure" thing is for Linux installations using autotools; it's not going to work on Windows. I don't run Apache on Windows, so I'm just guessing from the documentation here, but the mod_wsgi "Installation on Windows" page says to "follow the instructions for loading mod_wsgi in the Quick Installation Guide." The "Quick Installation Guide" page has instructions for editing the Apache config files. No mention of running ".\configure" -- why are you doing that? Try just editing the config files as the documentation suggests and see if that works. -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list
Re: loop
[email protected] writes: > I'm trying to create a for loop that starts at 100 and goes to > 10Mllion. The increments are like this: 100, 1000, 1, . > Basicaly adding a zero each iteration. I'm having problems trying to > do it. Can somebody help me Welcome. What have you tried so far? We're not in the practice of just writing the code for you; please show us what you have written that we can try running it, and how it's behaving differently from what you expect. -- \ “Oh, I love your magazine. My favorite section is ‘How To | `\ Increase Your Word Power’. That thing is really, really, | _o__) really... good.” —Homer, _The Simpsons_ | Ben Finney -- 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)
On Sun, 23 Mar 2014 02:46:28 -, Ian Kelly wrote: On Sat, Mar 22, 2014 at 6:32 PM, Rhodri James wrote: On Sat, 22 Mar 2014 05:26:26 -, Rustom Mody wrote: Well almost... Except that the 'loop' I am talking of is one of def loop(): return [yield (lambda: x) for x in [1,2,3]] or return (yield (lambda: x) for x in [1,2,3]) or just plain ol (lambda x: for x in [1,2,3]) IOW loop is an imperative construct, comprehensions are declarative I'm sorry, you've made a logical leap too far here. I understand loops being imperative, but how are comprehensions declarative? What do they declare that the loop equivalent doesn't. I'm with Rustom on this point. A list comprehension is a syntax for building a list by declaring a transformation from some other iterable object. Forget comprehensions for a moment and think of literals. Would you not consider this to be declarative? x = [1, 2, 3] I'm not sure I would. I look at that line of code and think of it as "Create a list...", very much in an imperative manner. Then again, compared with C structs and typedefs and actual honest-to-God type declarations, there's precious little in Python I would consider truly declarative. -- Rhodri James *-* Wildebeest Herder to the Masses -- https://mail.python.org/mailman/listinfo/python-list
Re: Reading in cooked mode (was Re: Python MSI not installing, log file showing name of a Viatnemese communist revolutionary)
On Sun, 23 Mar 2014 12:37:43 +1100, Chris Angelico wrote:
> On Sun, Mar 23, 2014 at 12:07 PM, Steven D'Aprano
> wrote:
>> On Sun, 23 Mar 2014 02:09:20 +1100, Chris Angelico wrote:
>>
>>> On Sun, Mar 23, 2014 at 1:50 AM, Steven D'Aprano
>>> wrote:
Line endings are terminators: they end the line. Whether you consider
the terminator part of the line or not is a matter of opinion (is the
cover of a book part of the book?) but consider this:
If you say that the end of lines are *not* part of the line, then
that implies that some parts of the file are not inside any line
at all. And that would be just weird.
>>>
>>> Not so weird IMO. A file is not a concatenation of lines; it is a
>>> stream of bytes.
>>
>> But a *text file* is a concatenation of lines. The "text file" model is
>> important enough that nearly all programming languages offer a
>> line-based interface to files, and some (Python at least, possibly
>> others) make it the default interface so that iterating over the file
>> gives you lines rather than bytes -- even in "binary" mode.
>
> And lines are delimited entities. A text file is a sequence of lines,
> separated by certain characters.
Are they really separated, or are they terminated?
a\nb\n
Three lines or two? If you say three, then you consider \n to be a
separator; if you say two, you consider it a terminator.
The thing is, both points of view are valid. If \n is a terminator, then
the above is valid text, but this may not be:
a\nb\nc
since the last line is unterminated. (You might be generous and allow
that every line must be terminated except possibly the last. Or you might
be strict and consider the last line to be broken.)
In practice, most people swap between one point of view and the other
without warning: I might say that "a\nb\n" has two lines terminated with
\n, and then an instant later say that the file ends with a blank line,
which means it has three lines, not two. Or you might say that "a\nb\n"
has three lines separated by \n, and an instant later claim that the last
line contains the letter "b". So common language about text files tends
to be inconsistent and flip-flop between the two points of view, a bit
like the Necker Cube optical illusion.
Given that the two points of view are legitimate and useful, how should a
programming language treat lines? If the language treats the newline as
separator, and strips it, then those who want to treat it as terminator
are screwed -- you cannot tell if the last line is terminated or not. But
if the language treats the newline as a terminator, and so part of the
line, it is easy for the caller to remove it. The decision ought to be a
no-brainer: keep the newline in place, let the user strip it if they
don't want it.
Here's another thought for you: words are separated by spaces. Nobody
ever considers the space to be part of the word[1]. I think that nearly
everyone agrees that both "spam eggs" and "spam eggs" contain two
words, "spam" and "eggs". I don't think anyone would say that the second
example includes seven words, five of which are blank. Would we like to
say that "spam\n\n\n\n\n\neggs" contains two lines rather than seven?
>>> (Both interpretations make sense. I just wish the most obvious form of
>>> iteration gave the cleaner/tidier version, or at very least that there
>>> be some really obvious way to ask for lines-without-endings.)
>>
>> There is: call strip('\n') on the line after reading it. Perl and Ruby
>> spell it chomp(). Other languages may spell it differently. I don't
>> know of any language that automatically strips newlines, probably
>> because you can easily strip the newline from the line, but if the
>> language did it for you, you cannot reliably reverse it.
>
> That's not a tidy way to iterate, that's a way to iterate and then do
> stuff. Compare:
>
> for line in f:
> # process line with newline
>
> for line in f:
> line = line.strip("\n")
> # process line without newline, as long as it doesn't have \r\n or
> something
With universal newline support, you can completely ignore the difference
in platform-specific end-of-line markers. By default, Python will convert
them to and from \n when you read or write a text file, and you'll never
see any difference. Just program using \n in your source code, and let
Python do the right thing. (If you need to handle end of line markers
yourself, you can easily disable universal newline support.)
f = (line.rstrip('\n') for line in f)
for line in f:
# process line
Everything[1] in computer science can be solved by an additional layer of
indirection :-)
[...]
> So why is the delimiter excluded when you treat the file as CSV, but
> included when you treat the file as lines of text?
Because reading lines of text is more general than reading CSV records.
Therefore it has to make fewer modifications to the raw content.
I once had a Pascal compiler t
Re: Reading in cooked mode (was Re: Python MSI not installing, log file showing name of a Viatnemese communist revolutionary)
On Mon, Mar 24, 2014 at 1:37 PM, Steven D'Aprano
wrote:
> On Sun, 23 Mar 2014 12:37:43 +1100, Chris Angelico wrote:
>> And lines are delimited entities. A text file is a sequence of lines,
>> separated by certain characters.
>
> Are they really separated, or are they terminated?
>
> a\nb\n
>
> Three lines or two? If you say three, then you consider \n to be a
> separator; if you say two, you consider it a terminator.
>
> The thing is, both points of view are valid. If \n is a terminator, then
> the above is valid text, but this may not be:
>
> a\nb\nc
>
> since the last line is unterminated. (You might be generous and allow
> that every line must be terminated except possibly the last. Or you might
> be strict and consider the last line to be broken.)
It is a problem, and the correct usage depends on context.
I'd normally say that the first consists of two lines, the first being
"a" and the second being "b", and there is no third blank line. The
first line still doesn't consist of "a\n", though. It's more like how
environment variables are provided to a C program: separated by \0 and
the last one has to be terminated too.
In some situations, you would completely ignore the "c" in the last
example. When you're watching a growing log file, buffering might mean
that you see half of a line. When you're reading MUD text from a
socket, a partial line probably means it's broken across two packets,
and the rest of the line is coming. Either way, you don't process the
"c" in case it's the beginning of a line; you wait till you see the
"\n" separator that says that you now have a complete line. Got some
out-of-band indication that there won't be any more (like an EOF
signal)? Assume that "c" is the whole line, or assume the file is
damaged, and proceed accordingly.
> Given that the two points of view are legitimate and useful, how should a
> programming language treat lines? If the language treats the newline as
> separator, and strips it, then those who want to treat it as terminator
> are screwed -- you cannot tell if the last line is terminated or not.
That's my point, though. If you want to treat a file as lines, you
usually won't care whether the last one is terminated or not. You'll
have some means of defining lines, which might mean discarding the
last, or whatever it is, but the stream "a\nb\nc" will either become
["a", "b", "c"] or ["a", "b"] or ValueError or something, and that
list of lines is really all you care about. Universal newlines, as you
mention, means that "a\r\nb\r\n" will become the exact same thing as
"a\nb\n", and there's no way to recreate that difference - because it
*does not matter*.
> Here's another thought for you: words are separated by spaces. Nobody
> ever considers the space to be part of the word[1]. I think that nearly
> everyone agrees that both "spam eggs" and "spam eggs" contain two
> words, "spam" and "eggs". I don't think anyone would say that the second
> example includes seven words, five of which are blank. Would we like to
> say that "spam\n\n\n\n\n\neggs" contains two lines rather than seven?
Ahh, that's a tricky one. For the simple concept of iterating over the
lines in a file, I would have to say that it's seven lines, five of
which are blank, same as "spam eggs".split(" ") returns a
seven-element list. The tricky bit is that the term "word" means
"*non-empty* sequence of characters", which means that after splitting
on spaces, you discard all empty tokens in the list; but normally
"line" does NOT have that non-empty qualifier. However, a double
newline often means "paragraph break" as opposed to "line break", so
there's additional meaning applied there; that might be four
paragraphs, the last one unterminated (and a paragraph might well be
terminated by a single newline rather than two), and in some cases
might be squished to just two paragraphs because the paragraph itself
is required to be non-empty.
> With universal newline support, you can completely ignore the difference
> in platform-specific end-of-line markers. By default, Python will convert
> them to and from \n when you read or write a text file, and you'll never
> see any difference. Just program using \n in your source code, and let
> Python do the right thing. (If you need to handle end of line markers
> yourself, you can easily disable universal newline support.)
So why should we have to explicitly disable universal newlines to undo
the folding of \r\n and \n down to a single "end of line" indication,
but automatically get handling of \n or absence at the end of the
file? Surely that's parallel. In each case, you're taking the set of
lines as your important content, and folding together distinctions
that don't matter.
> I once had a Pascal compiler that would insert spaces, indentation, even
> change the case of words. Regardless of what you actually typed, it would
> pretty-print your code, then write the pretty-printed output when you
> saved. Likewise, if you read in a P
Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)
On Mon, Mar 24, 2014 at 1:35 PM, Rhodri James wrote: >> Would you not consider this to be declarative? >> >>x = [1, 2, 3] > > > I'm not sure I would. I look at that line of code and think of it as > "Create a list...", very much in an imperative manner. Then again, compared > with C structs and typedefs and actual honest-to-God type declarations, > there's precious little in Python I would consider truly declarative. I'm in the declarative group here. Yes, it has to be implemented as creating a list and adding three elements to it, but conceptually, it means "Bind x to a new list with these elements". And as long as that's the end result, I don't care how it's done; the interpreter's most welcome to have a "template list" that it copies, or maybe a literal tuple that gets passed to the list() constructor, or whatever's most efficient. It gets a bit messier when there's stuff with side effects, though. This has to be a bit more imperative: x = [foo(y), bar(y), quux(y)] That means "Call foo, bar, and quux, in that order, each with y as an argument, and bind x to a new list with their return values". And if Python had a simple notation for calling a series of functions, that could be written something like this: funcs = [foo, bar, quux] x = funcs(y) which is looking more declarative again. It's now "Take this list of functions and call them all, and bind x to a list of their return values". (This could be done, with a callable subclass of list. Call it a sort of "implicit map" if you like.) Python doesn't have that syntax, but it does have this: x = [f(y) for f in funcs] and I'd say that's reasonably declarative; it should be read like the previous one: "Take this list of funcs, call each one, and bind x to a list of their return values". And I could imagine a parallel-processing version of a list comp that functions like multiprocessing.Pool.map() and doesn't promise order, which would *definitely* be declarative. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python installation on windows
On 3/23/14 4:07 PM, tad na wrote: On Sunday, March 23, 2014 12:33:02 PM UTC-5, tad na wrote: To set up a web browser: 1.open a dos window 2.navigate to dir you want "served" 3.type "python -m SimpleHTTPServer &." 4. open browser and type http://localhost:/ That is very ~cool. I learn something around here everyday. But, the OP did not ask how to run a web server on python (above); he asked how to run python on a web browser (I think he meant web server). Anyway, the PSF runs python (the interpreter) from a web server (I can access the python interpreter from my browser from the PSF site). How is that done simply, is possibly what the OP wants to know (me too). marcus -- 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)
On Mon, Mar 24, 2014 at 1:35 PM, Rhodri James wrote: > I'm not sure I would. I look at that line of code and think of it as > "Create a list...", very much in an imperative manner. Then again, compared > with C structs and typedefs and actual honest-to-God type declarations, > there's precious little in Python I would consider truly declarative. By the way: Python does have a difference between "declarative" and "imperative". def f(): # Imperative global x # Declarative x += 1 # Imperative Declaratives control things, imperatives become byte code. Everything in the byte code is imperative. "LOAD_GLOBAL" means "fetch this global and put it on the stack". "INPLACE_ADD" means "iadd the top two stack elements and push the result onto the stack". "STORE_GLOBAL" means "pop the top stack element and store it in this global". Very very imperative, and there's none of that created by the "global" statement. So in that sense, yes, "x = [1, 2, 3]" is imperative; it loads three constants, builds a list, and stores it. But digging into the byte code isn't really helpful; it's much more useful to look at the source code and how the programmer thinks about it. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: loop
On 3/23/14 7:59 PM, anton wrote: for i in (10**p for p in range(3, 8)): print(i) Never do their home-work for them; but, in this case, what the heck. :) -- https://mail.python.org/mailman/listinfo/python-list
Re: python installation on windows
On Mon, Mar 24, 2014 at 2:28 PM, Mark H Harris wrote: > Anyway, the PSF runs python (the interpreter) from a web server (I can > access the python interpreter from my browser from the PSF site). > > How is that done simply, is possibly what the OP wants to know (me too). That's a much MUCH harder thing to do than running Python code in your web server, because of trust issues. I don't know how it's set up, but there'll be something in there to protect the server against malicious or accidental insanity (spinning with "while True: pass", trying to read/write files, trying to execute commands, using up all of RAM with "x = []\nwhile True: x.append(1)", etc, etc, etc). That's actually a very hard problem to solve, not something where you can just say "Here, this is how to run Python via a browser". ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reading in cooked mode (was Re: Python MSI not installing, log file showing name of a Viatnemese communist revolutionary)
On 3/23/14 10:17 PM, Chris Angelico wrote:
Newline style IS relevant. You're saying that this will copy a file perfectly:
out = open("out", "w")
for line in open("in"):
out.write(line)
but it wouldn't if the iteration and write stripped and recreated
newlines? Incorrect, because this version will collapse \r\n into \n.
It's still a *text file copy*. (And yes, I know about 'with'. Shut
up.) It's idempotent, not byte-for-byte perfect.
Which was my point in the first place about new-line standards. We all
know why its important to collapse \r\n into \n, but why(?) in a
general way would this be the universal desired end? (rhetorical) Your
example of byte-for-byte perfect copy is one good case (they are not).
Another might be controller code (maybe ancient) where the \r is
'required' and collapsing it to \n won't work on the device (tty, or
other).
There does need to be a text file standard where what is desired is a
file of "lines". Iterating over the file object should return the
"lines" on any system platform, without the user being required to strip
off the line-end (newline \n) delimiter U+000a. The delimiter does not
matter.
What python has done by collapsing the \r\n into \n is to hide the real
problem (non standard delimiters between platforms) and in the process
actually 'removes' possibly important information (\r). {lossy}
We don't really use real tty devices any longer which require one code
to bring the print head carriage back (\r) and one code to index the
paper platten (\n). Screen I/O doesn't work that way any longer either.
Its time to standardize the newline and/or file text line end delimiters.
marcus
--
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)
On Monday, March 24, 2014 8:57:32 AM UTC+5:30, Chris Angelico wrote: > On Mon, Mar 24, 2014 at 1:35 PM, Rhodri James wrote: > >> Would you not consider this to be declarative? > >>x = [1, 2, 3] > > I'm not sure I would. I look at that line of code and think of it as > > "Create a list...", very much in an imperative manner. Then again, compared > > with C structs and typedefs and actual honest-to-God type declarations, > > there's precious little in Python I would consider truly declarative. > I'm in the declarative group here. Yes, it has to be implemented as > creating a list and adding three elements to it, but conceptually, it > means "Bind x to a new list with these elements". And as long as > that's the end result, I don't care how it's done; the interpreter's > most welcome to have a "template list" that it copies, or maybe a > literal tuple that gets passed to the list() constructor, or > whatever's most efficient. > It gets a bit messier when there's stuff with side effects, though. > This has to be a bit more imperative: > x = [foo(y), bar(y), quux(y)] > That means "Call foo, bar, and quux, in that order, each with y as an > argument, and bind x to a new list with their return values". And if > Python had a simple notation for calling a series of functions, that > could be written something like this: > funcs = [foo, bar, quux] > x = funcs(y) > which is looking more declarative again. It's now "Take this list of > functions and call them all, and bind x to a list of their return > values". (This could be done, with a callable subclass of list. Call > it a sort of "implicit map" if you like.) Python doesn't have that > syntax, but it does have this: > x = [f(y) for f in funcs] > and I'd say that's reasonably declarative; it should be read like the > previous one: "Take this list of funcs, call each one, and bind x to a > list of their return values". And I could imagine a > parallel-processing version of a list comp that functions like > multiprocessing.Pool.map() and doesn't promise order, which would > *definitely* be declarative. You have described nicely a slippery slope! The list [(1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4)] looks neater written (and *thought of* ) as [(x,y) for x in range(1,4) for y in range(1,5)] Neat! So I play around... Change it to [(x,y) for x in range(1,1) for y in range(1,1)] and I dont have an answer but a thrashing machine!! (*) IOW everything we write/read as programmers has a declarative and an imperative side. Which one one wants to focus on requires good sense and taste. (*) Example also shows inter alia how some things -- range -- have gone from imperative to declarative from python 2 to 3. Some people have made languages whose main focus is generalizing this idea to more dimensions and restrictions: http://www.irisa.fr/cosi/Rajopadhye/dag-talk.ps -- https://mail.python.org/mailman/listinfo/python-list
Re: Question about Source Control
On 3/23/2014 10:04 PM, Chris Angelico wrote: On Mon, Mar 24, 2014 at 12:26 PM, Terry Reedy wrote: With multiple branches (as with 2.7, 3.4, and default for cpython) and multiple active developers (20?) commiting to those brances, commits are definitely not free. I would not exactly call them as cheap as you seem to imply either. That said, I have occasionally pushed interim changes that put code in an improved and stable state. N. Coughlan has suggested improving the cpython infrastructure and procedures to reduce the cost of commits to encourage more people to make more commits (in the sense of more lines changed, not more pieces) and improve cpython faster. When I call them cheap, what I mean is that there's little difference between a single commit and 2-3 commits as a group. Yes, there's a bit more difference when you're cherry-picking them to other branches, and maybe an infrastructure/procedure change could help with that; but once they're there in history, it doesn't hurt to have three separate commits doing related work, keeping the distinct parts distinct. Every commit to a 3.x maintenance branch (now 3.4) must be forward merged into the 3.(x+1) default (now the future 3.5), even if it is just a null merge. The point of this policy is to keep the repository in a coherent state. If a bug were fixed in maintenance but not default, it would create a regression situation, the same as if it were fixed in default and then broken again by a separate patch. Part of the planned (hoped-for) change (using a system that is already working for another project with even more code and committers) is to automatically test patches on the buildbots before they are committed to the central repository, rather than after. Each would be tested and accepted or rejected separately. So each commit would have to stand on its own even more than now. -- Terry Jan Reedy -- 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)
On Mon, Mar 24, 2014 at 3:14 PM, Rustom Mody wrote: > Neat! So I play around... Change it to > [(x,y) for x in range(1,1) for y in range(1,1)] > and I dont have an answer but a thrashing machine!! (*) Yes, because you used square brackets, which means that the list has to be fully realized. As you comment, range changed from returning a list to returning an iterable, and this action is similarly cheap: >>> ((x,y) for x in range(1,1) for y in range(1,1)) at 0x7f53ed61b360> You can take a few elements from that cheaply: >>> [next(_),next(_),next(_)] [(1, 1), (1, 2), (1, 3)] If you like thinking in "lazy lists", you can probably think just as easily with generators; you can't pull up arbitrary elements from it, or query its length, but for many purposes a generator will do. 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)
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 way most people
would expect them to, having limited knowledge of python!
One of the best links for understanding what is wrong with lambda is
here, from Guido, (by the way I agree totally with his assessment, there
is no point really in writing it out again):
http://www.artima.com/weblogs/viewpost.jsp?thread=98196
Why is that a problem? Would you consider it a problem that people who
don't understand BASIC can't understand BASIC? ("I don't get the
difference between GOTO and GOSUB. {snip}
The problem is ignorance, not the calculator, and not lambda.
You're argument, based on analogy, is also a red herring, as well a
straw man. Lambda is a problem of confusion for scientists and other
mathematicians (amateur and otherwise) who may be confused because
python's lambda does not do precisely what they might expect from other
functional programming languages, nor does it match precisely with the
lambda calculus. Its also confusing to sophisticated users of all
stripes who may not be aware of "lambda" at all.
You've told us that "most people" (which people? dentists? lawyers?
illiterate tribesmen from the Amazon? professional programmers?) are
surprised by lamba's behaviour, but you haven't actually told us what
behaviour is surprising, or what "most people" expect lambda to do.
Perhaps you ought to?
I love your rhetoric, actually, but red herrings all . . .
Here is a link that advocates lambda (map, filter, and reduce) as a
very powerful construct for doing various things: I agree:
http://www.secnetix.de/olli/Python/lambda_functions.hawk
Its a great link, but the important sentence for this discussion is
this unique quote, about "lambda,"
>"This is not exactly the same as lambda in functional
programming languages, but it is a very powerful concept . . ."
People who understand lambda from functional languages must hassle
with the fact that lambda is different in python, and people who do not
understand functional programming languages (nor the lambda calculus)
are confused by the syntax, also just what it does.
Python is not a pure functional language, but you can write functional
code in it. If you want a pure functional language, you know where to
find one.
Yes, that's obvious; but you're missing the point. Python is not a
functional language, and implying that it can be used as one is
misleading at best (maybe a lie at worst) just because it has a
construct for generating a dynamic anonymous function.
(I wonder whether, say, Haskell has the people coming along and demanding
that it should become more like Python?)
Another straw man.
Well, number one, I'm not demanding anything. Number two, everyone
who uses Haskell (for whatever reason) knows well from the start that
its a pure functional programming language. That is the advertisement,
and that is the expectation. No one expects anything different.
I can see uses for python's lambda. But, honestly, I think python could
deprecate its use and in five years just remove it from the language;
along with filter, map, and reduce !
Python could deprecate many things. It would make Python a worse language.
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 BDFL hates it. Reduce is no
longer in the standard library (although you can import it) and there
are equally good ways to do what lambda was designed for without the
hassle nor confusion.
By the way, are you aware that lambda is *identical* to def except for
three things?
- lambda is an expression, not a statement like def;
- the body of a function created with lambda is limited to a
single expression, not a block;
- the function object created with lambda has a generic name.
Absolutely, thank you for pointing those out ! You forgot that
lambdas can be used in expressions while def functions may not... but
you really have proved my point. There is so little difference between
the two that (for the sake of clarity and reducing confusion) it might
be good to just remove the lambda thing altogether. Just say'in.
So unless the surprising behaviour about lambda that you're about to tell
us about relates to one of those three things, I *guarantee* that
functions created with def have the same surprising behaviour.
No, the surprising behavior is that python lambda does not work
exactly the way that lambda works in functional programming languages
(see the two links provided) the confusion it creates for "normal" users
does not warrant its inclusion in the language.
how? Py extension does not depend on py version
I found an extension on this blog http://www.cnblogs.com/DxSoft/archive/2011/04/08/2009132.html or you can download the extension directly from http://files.cnblogs.com/DxSoft/PyFetion.rar I found that I can do "from DxVcl import *" in py 2.5/2.6/2.7. When I try this in py24, a msgbox says "no python25.dll is found". However "Dependency Walker" shows that DxVcl does not has the python??.dll dependency. Is this a dark side of python which is not in official python doc? So, to the end, My question is: how can I write such an extension(i.e. not DLL foe ctypes) in C/C++? Thanks Lee -- https://mail.python.org/mailman/listinfo/python-list
solutions manual and test bank
solutions(dot)for(dot)student(at)hotmail.com s o l u t i o n s . f o r . s t u d e n t @ h o t m a i l . c o m We're a team found for providing solution manuals to help students in their study. We sell the books in a soft copy, PDF format. We will do our best to find any book or solution manual for you. Before purchase, we will give you a full details and sample of solution manual you want Just email us: s o l u t i o n s . f o r . s t u d e n t @ h o t m a i l . c o m List of some books we have = A Course in Modern Mathematical Physics by Peter Szekeres A First Course in Abstract Algebra By John B. Fraleigh A First Course in Differential Equations with Modeling Applications , 9th ed 2008 , by Zill A First Course In Probability , 7th ed , by sheldon ross A first course in probability 6th edition by Ross A First Course in Probability, 5th ed , by Sheldon Ross & Prentice Hall & scanned A First Course in String Theory by Barton Zwiebach A Modern Theory of Integration , by Robert G.Bartle A Practical Introduction to Data Structures and Algorithm Analysis Second Edition by Clifford A. Shaffer A Quantum Approach to Condensed Matter Physics by Philip L. Taylor A Short Introduction to Quantum Information and Quantum Computation by Michel Le Bellac Accompany Digital Systems Principles and Applications, 10th Edition By Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss Accompany Electric Machinery and Power System Fundamentals, First Edition by Stephen J. Chapman Accompany Electronic Devices and Circuit Theory, 8Ed By Robert L. Boylestad; Louis Nashelsky; Franz J. Monseen Accompany Elementary Statistics Ninth Edition by MILTON LOYER Accompany Engineering circuit analysis, 6th edition By Hayt Accompany Foundations of Electromagnetic Theory 2nd Ed. by John R. Reitz, Frederick J. Milford Accompany Fundamentals of Fluid Mechanics, 5th Edition by Bruce R. Munson, Donald F. Young, Theodore H. Okiishi Accompany Introduction to algorithms By Sussman J Accompany Millman micro Electronics Digital and Analog Circuits and Systems , by Thomas V. Papathomas Accompany Physics for Poets Second Edition By Robert H. March Accompany Principles of geotechnical engineering, sixth edition by braja M. DAS Accompany Problem Solving and Programming Concepts , 9th ed , by Maureen Sprankle , Jim Hubbard Adaptive Control, 2nd Edition, By Karl Johan Astrom,Bjorn Wittenmark Adaptive filter thoery 4th edition By Simon Haykin Advanced Accounting Guerrero Vol. 1 & 2 , REVISED EDITION 2008 , by P.P. GUERRERO & J.F. PERALTA Advanced Digital Design with the Verilog HDL by Michael D. Ciletti (Selected problems) Advanced engineering electromagnetics by Constantine A. Balanis Advanced Engineering Mathematics , 8 ed , by Erwin Kreyszig Advanced Engineering Mathematics 8 Edition By Erwin Kreyszig Advanced Engineering Mathematics 9 Edition By Erwin Kreyszig Advanced Macroeconomics , 1996 edition , by Romer David Advanced Modern Engineering Mathematics , 4th ed 2011 , by Glyn James Advanced Modern Engineering Mathematics 3rd Edition by Glyn James Agamata Management Advisory Services , 2007 edition , by Franklin T. Agamata, MBA, CPA Aircraft Structures for Engineering Students Fourth Edition by T. H. G. Megson (2007) Algebra and Trigonometry and Precalculus, 3rd Edition by Penna & Bittinger Beecher an introduction to database systems , 8th ed , by c. j. date An introduction to database systems 8th edition By C J Date An Introduction to Mathematical Statistics and Its Applications , 4th ed , by richard J. Larsen & morris L. Marx An Introduction to Ordinary Differential Equations By James C. Robinson (with Matlab files) An Introduction to Signals and Noise in Electrical Communication , 4th ed , by A. Bruce Carlson & Paul B. Crilly & Janet C. Rutledge An Introduction to Signals and Systems By John Stuller An Introduction to The Finite Element Method (Third Edition) By J. N. REDDY Analysis and design of analog integrated circuits 4th edition by Srikanth Vaidianathan and Haoyuee Wang Analytical Mechanics, 7th Edition By Fowles & Cassiday Antenna Theory Analysis and Design, 2nd Edition Balanis Antennas for all Applications 3rd edition by John D. Kraus & Ronald J. Marhefka Anton Calculus 8th edition, Exercises solutions Applied Linear Statistical Models , 5th ed , by Applied Linear Statistical & Applied Linear Statistical & Applied Linear Statistical & Applied Linear Statistical Applied Numerical Analysis 7th Edition By Curtis F. Gerald,Patrick O. Wheatley Applied Numerical Methods with Matlab for engieers and Scientists , by Steven C. Chapra Applied Partial Differential Equations with Fourier Series and Boundary Value Problems 4th Edition by Richard Haberman Applied Quantum Mechanics by A. F. J. Levi Applied Statistics and Probability for Engineers , 2003 edition , by Douglas C. Montgomery, George C. Runger Applied Statistics And Probability For Engineers 3rd edition By Montgomery,Runger Appli
