From victorhooi at gmail.com Wed Jul 1 00:06:43 2015 From: victorhooi at gmail.com (Victor Hooi) Date: Tue, 30 Jun 2015 21:06:43 -0700 (PDT) Subject: Parsing logfile with multi-line loglines, separated by timestamp? In-Reply-To: References: Message-ID: <51f65e41-76e9-48c4-8f79-ba4ac060bbe3@googlegroups.com> Aha, cool, that's a good idea =) - it seems I should spend some time getting to know generators/iterators. Also, sorry if this is basic, but once I have the "block" list itself, what is the best way to parse each relevant line? In this case, the first line is a timestamp, the next two lines are system stats, and then a newline, and then one line for each block device. I could just hardcode in the lines, but that seems ugly: for block in parse_iostat(f): for i, line in enumerate(block): if i == 0: print("timestamp is {}".format(line)) elif i == 1 or i == 2: print("system stats: {}".format(line)) elif i >= 4: print("disk stats: {}".format(line)) Is there a prettier or more Pythonic way of doing this? Thanks, Victor On Wednesday, 1 July 2015 02:03:01 UTC+10, Chris Angelico wrote: > On Wed, Jul 1, 2015 at 1:47 AM, Skip Montanaro wrote: > > Maybe define a class which wraps a file-like object. Its next() method (or > > is it __next__() method?) can just buffer up lines starting with one which > > successfully parses as a timestamp, accumulates all the rest, until a blank > > line or EOF is seen, then return that, either as a list of strings, one > > massive string, or some higher level representation (presumably an instance > > of another class) which represents one "paragraph" of iostat output. > > next() in Py2, __next__() in Py3. But I'd do it, instead, as a > generator - that takes care of all the details, and you can simply > yield useful information whenever you have it. Something like this > (untested): > > def parse_iostat(lines): > """Parse lines of iostat information, yielding ... something > > lines should be an iterable yielding separate lines of output > """ > block = None > for line in lines: > line = line.strip() > try: > tm = datetime.datetime.strptime(line, "%m/%d/%Y %I:%M:%S %p") > if block: yield block > block = [tm] > except ValueError: > # It's not a new timestamp, so add it to the existing block > block.append(line) > if block: yield block > > This is a fairly classic line-parsing generator. You can pass it a > file-like object, a list of strings, or anything else that it can > iterate over; it'll yield some sort of aggregate object representing > each time's block. In this case, all it does is append strings to a > list, so this will result in a series of lists of strings, each one > representing a single timestamp; you can parse the other lines in any > way you like and aggregate useful data. Usage would be something like > this: > > with open("logfile") as f: > for block in parse_iostat(f): > # do stuff with block > > This will work quite happily with an ongoing stream, too, so if you're > working with a pipe from a currently-running process, it'll pick stuff > up just fine. (However, since it uses the timestamp as its signature, > it won't yield anything till it gets the *next* timestamp. If the > blank line is sufficient to denote the end of a block, you could > change the loop to look for that instead.) > > Hope that helps! > > ChrisA From moller at mollerware.com Wed Jul 1 00:33:54 2015 From: moller at mollerware.com (Chris Moller) Date: Wed, 01 Jul 2015 00:33:54 -0400 Subject: Capturing PyRun_String stdout Message-ID: <55936DB2.8040703@mollerware.com> I sent this to the wrong list a few hours ago. I hope I've gotten it right this time... ===================================================== I expect this has been asked before, but I can't find out much about it... I'm trying to embed Python in a GTK+/C app as a scripting language and I need to capture the output of PyRun_String(), PyEval_EvalCode(), or whatever as a char * (or wchar_t * or whatever) rather than have it go to stdout. I'm using Python 3.3.2 under plain C, not C++ And, while I'm interrupting everyone's evening, another question: if I pass Py_single_input to PyRun_String() or Py_CompileString()/PyEval_EvalCode(), it accepts statements like "a=10" and can then properly do stuff like "print(a)". If I use Py_eval_input instead, I get error messages. In both cases, I'm using the same global_dict and local_dict, if that makes any difference. What am I doing wrong? Thanks, Chris Moller -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Wed Jul 1 01:03:06 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 1 Jul 2015 15:03:06 +1000 Subject: Parsing logfile with multi-line loglines, separated by timestamp? In-Reply-To: <51f65e41-76e9-48c4-8f79-ba4ac060bbe3@googlegroups.com> References: <51f65e41-76e9-48c4-8f79-ba4ac060bbe3@googlegroups.com> Message-ID: On Wed, Jul 1, 2015 at 2:06 PM, Victor Hooi wrote: > Aha, cool, that's a good idea =) - it seems I should spend some time getting to know generators/iterators. > > Also, sorry if this is basic, but once I have the "block" list itself, what is the best way to parse each relevant line? > > In this case, the first line is a timestamp, the next two lines are system stats, and then a newline, and then one line for each block device. > > I could just hardcode in the lines, but that seems ugly: > > for block in parse_iostat(f): > for i, line in enumerate(block): > if i == 0: > print("timestamp is {}".format(line)) > elif i == 1 or i == 2: > print("system stats: {}".format(line)) > elif i >= 4: > print("disk stats: {}".format(line)) > > Is there a prettier or more Pythonic way of doing this? This is where you get into the nitty-gritty of writing a text parser. Most of the work is in figuring out exactly what pieces of information matter to you. I recommend putting most of the work into the parse_iostat() function, and then yielding some really nice tidy package that can be interpreted conveniently. ChrisA From pkpearson at nowhere.invalid Wed Jul 1 01:50:17 2015 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 1 Jul 2015 05:50:17 GMT Subject: Matplotlib X-axis timezone trouble References: Message-ID: On 30 Jun 2015 00:56:26 GMT, Peter Pearson wrote: > The following code produces a plot with a line running from (9:30, 0) to > (10:30, 1), not from (8:30, 0) to (9:30, 1) as I desire. > > If I use timezone None instead of pacific, the plot is as desired, but > of course that doesn't solve the general problem of which this is a > much-reduced example. > > If I use timezone US/Central, I get the same (bad) plot. > > import matplotlib.pyplot as plt > import datetime > import pytz > pacific = pytz.timezone("US/Pacific") > fig = plt.figure() > plt.plot([datetime.datetime(2014, 10, 7, 8, 30, tzinfo=pacific), > datetime.datetime(2014, 10, 7, 9, 30, tzinfo=pacific)], > [0,1], marker="o", color="green") > fig.autofmt_xdate() > plt.show() > > Does anybody know why this shift is occurring? Is Matplotlib > confused about what timezone to use in labeling the axis? How > would I tell it what timezone to use (preferably explicitly in > the code, not in matplotlibrc)? Progress report: I might be wrong in blaming the axis formatting. It looks as if the datetimes themselves are being created wrong. https://docs.python.org/2/library/datetime.html gives an example like this: >>> # Daylight Saving Time >>> dt1 = datetime(2006, 11, 21, 16, 30, tzinfo=gmt1) >>> dt1.dst() datetime.timedelta(0) >>> dt1.utcoffset() datetime.timedelta(0, 3600) >>> dt2 = datetime(2006, 6, 14, 13, 0, tzinfo=gmt1) >>> dt2.dst() datetime.timedelta(0, 3600) >>> dt2.utcoffset() datetime.timedelta(0, 7200) ... implying that adjustment for DST is made during the datetime constructor. But look: >>> from datetime import datetime >>> import pytz >>> pacific = pytz.timezone("US/Pacific") >>> dt1 = datetime(2006, 11, 21, 16, 30, tzinfo=pacific) # no DST >>> dt2 = datetime(2006, 6, 14, 13, 0, tzinfo=pacific) # yes DST >>> dt1.dst() datetime.timedelta(0) >>> dt2.dst() datetime.timedelta(0) >>> dt1.utcoffset() datetime.timedelta(-1, 57600) >>> dt2.utcoffset() datetime.timedelta(-1, 57600) The dst() values are equal, and the utcoffset() values are equal, even though one datetime is during DST and the other is not -- exactly the opposite of the example. The debugging tool pdb can't step into datetime.datetime(), so I'm kinda stuck here. -- To email me, substitute nowhere->runbox, invalid->com. From rosuav at gmail.com Wed Jul 1 03:15:38 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 1 Jul 2015 17:15:38 +1000 Subject: Matplotlib X-axis timezone trouble In-Reply-To: References: Message-ID: On Wed, Jul 1, 2015 at 3:50 PM, Peter Pearson wrote: > But look: > > >>> from datetime import datetime > >>> import pytz > >>> pacific = pytz.timezone("US/Pacific") > >>> dt1 = datetime(2006, 11, 21, 16, 30, tzinfo=pacific) # no DST > >>> dt2 = datetime(2006, 6, 14, 13, 0, tzinfo=pacific) # yes DST > >>> dt1.dst() > datetime.timedelta(0) > >>> dt2.dst() > datetime.timedelta(0) > >>> dt1.utcoffset() > datetime.timedelta(-1, 57600) > >>> dt2.utcoffset() > datetime.timedelta(-1, 57600) > > The dst() values are equal, and the utcoffset() values are equal, even > though one datetime is during DST and the other is not -- exactly the > opposite of the example. Just to confirm, they are still showing the times as 16:30 and 13:00, right? Interestingly, when I tried this (pytz version 2015.4, Python 2.7.9, Debian Jessie), I saw utcoffset() showing (-1, 58020) for both. That seems... odd. And I can't fault your dates - those definitely ought to be easily inside and easily outside the DST boundaries. When I try those dates in an unrelated time converter, they do show seven- and eight- hour offsets to UTC. Maybe we're both misunderstanding the meaning of utcoffset()? ChrisA From alister.nospam.ware at ntlworld.com Wed Jul 1 04:06:20 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Wed, 1 Jul 2015 08:06:20 +0000 (UTC) Subject: Pure Python Data Mangling or Encrypting References: <558bc912$0$2899$c3e8da3$76491128@news.astraweb.com> <558c1a7e$0$1668$c3e8da3$5496439d@news.astraweb.com> <558d86b0$0$1659$c3e8da3$5496439d@news.astraweb.com> <558ef059$0$1673$c3e8da3$5496439d@news.astraweb.com> <5592065e$0$1675$c3e8da3$5496439d@news.astraweb.com> <5592e71e$0$1674$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, 30 Jun 2015 23:25:01 +0000, Jon Ribbens wrote: > On 2015-06-30, Steven D'Aprano wrote: >> I don't think there has been much research into keeping at least *some* >> security even when keys have been compromised, apart from as it relates >> to two-factor authentication. > > That's because "the key" is all the secret part. If an attacker knows > the algorithm, and the key, and the ciphertext, then *by definition* all > is lost. If you mean keeping the algorithm secret too then that's just > considered bad crypto. > >> In the past, and still today among people who don't understand >> Kerckhoffs' principle, people have tried to keep the cipher secret and >> not have a key at all. E.g. atbash, or caesar cipher, which once upon a >> time were cutting edge ciphers, as laughably insecure as they are >> today. If the method was compromised, all was lost. > > Caesar cipher has a key. It's just very small, so is easy to guess. > >> Today, if the key is compromised, all is lost. Is it possible that >> there are ciphers that are resistant to discovery of the key? Obviously >> if you know the key you can read encrypted messages, that's what the >> key is for, but there are scenarios where you would want security to >> degrade gracefully instead of in a brittle all-or-nothing manner: >> >> - even if the attacker can read my messages, he cannot tamper with >> them or write new ones as me. > > I suppose that could be achieved by having separate encryption and > signing keys, but you could do the same but better by encrypting with > multiple algorithms. It's not an unstudied area: > https://en.wikipedia.org/wiki/Multiple_encryption "The kipper flies at Midnight" (from almost every WWII spy movie ever) even if this message is decoded it is meaningless unless the attacker also has the meanings of the Code phrases (which would mean your agent had been captured anyway) -- That's the funniest thing I've ever heard and I will _not_ condone it. -- DyerMaker, 17 March 2000 MegaPhone radio show From bc at freeuk.com Wed Jul 1 04:59:49 2015 From: bc at freeuk.com (BartC) Date: Wed, 01 Jul 2015 09:59:49 +0100 Subject: win32print Message-ID: I need to print a text file to whatever printer in Windows is called 'Generic/Text Only'. I looked for a Python solution and come across Tim Golden's win32print module which looks perfect, eg: http://timgolden.me.uk/pywin32-docs/win32print.html However, that tells me everything I need to know except how or where to download it! Is this something that actually can be downloaded somewhere? (Or is it obsolete, or a project that I have to build myself? In which case it'll probably be easier to write my own Win32 code but I was trying to avoid that.) -- Bartc From breamoreboy at yahoo.co.uk Wed Jul 1 06:15:00 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 01 Jul 2015 11:15:00 +0100 Subject: win32print In-Reply-To: References: Message-ID: On 01/07/2015 09:59, BartC wrote: > I need to print a text file to whatever printer in Windows is called > 'Generic/Text Only'. I looked for a Python solution and come across Tim > Golden's win32print module which looks perfect, eg: > > http://timgolden.me.uk/pywin32-docs/win32print.html > > However, that tells me everything I need to know except how or where to > download it! > > Is this something that actually can be downloaded somewhere? (Or is it > obsolete, or a project that I have to build myself? In which case it'll > probably be easier to write my own Win32 code but I was trying to avoid > that.) > That's the standard pywin32 docs that happen to be on Tim's site. Get the latest pywin32 here http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From bc at freeuk.com Wed Jul 1 07:02:36 2015 From: bc at freeuk.com (BartC) Date: Wed, 01 Jul 2015 12:02:36 +0100 Subject: win32print In-Reply-To: References: Message-ID: On 01/07/2015 11:15, Mark Lawrence wrote: > On 01/07/2015 09:59, BartC wrote: >> I need to print a text file to whatever printer in Windows is called >> 'Generic/Text Only'. I looked for a Python solution and come across Tim >> Golden's win32print module which looks perfect, eg: >> >> http://timgolden.me.uk/pywin32-docs/win32print.html >> >> However, that tells me everything I need to know except how or where to >> download it! > That's the standard pywin32 docs that happen to be on Tim's site. Get > the latest pywin32 here > http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/ Yes, I ended up there at one point, but didn't see a win32print.py file, only a win32print.cpp one. I think messing about with C++ compilers and makefiles (that never work properly under Windows) defeats the object of trying to use Python for this purpose! Presumably, nowhere on the internet is there a ready-to-use copy of win32print.py that someone else could just download with little effort? (Anyway, never mind; I'm looking at a solution now that involves invoking Windows' rundll32 and notepad to do the job. And it saves the problem of instructing someone on the end of a telephone how to install even Python let alone locating the add-ons. This is task that, in the eighties, would have involved sending a string, a byte at a time, to the parallel port, perhaps 3 lines of code. It's great that in 2015 everything is so much simpler!) -- Bartc From mail at timgolden.me.uk Wed Jul 1 07:28:10 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 1 Jul 2015 12:28:10 +0100 Subject: win32print In-Reply-To: References: Message-ID: <5593CECA.5090103@timgolden.me.uk> On 01/07/2015 12:02, BartC wrote: > On 01/07/2015 11:15, Mark Lawrence wrote: >> On 01/07/2015 09:59, BartC wrote: >>> I need to print a text file to whatever printer in Windows is called >>> 'Generic/Text Only'. I looked for a Python solution and come across Tim >>> Golden's win32print module which looks perfect, eg: >>> >>> http://timgolden.me.uk/pywin32-docs/win32print.html >>> >>> However, that tells me everything I need to know except how or where to >>> download it! > >> That's the standard pywin32 docs that happen to be on Tim's site. Get >> the latest pywin32 here >> http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/ > > Yes, I ended up there at one point, but didn't see a win32print.py file, > only a win32print.cpp one. I think messing about with C++ compilers and > makefiles (that never work properly under Windows) defeats the object of > trying to use Python for this purpose! > > Presumably, nowhere on the internet is there a ready-to-use copy of > win32print.py that someone else could just download with little effort? > > (Anyway, never mind; I'm looking at a solution now that involves > invoking Windows' rundll32 and notepad to do the job. And it saves the > problem of instructing someone on the end of a telephone how to install > even Python let alone locating the add-ons. > > This is task that, in the eighties, would have involved sending a > string, a byte at a time, to the parallel port, perhaps 3 lines of code. > It's great that in 2015 everything is so much simpler!) > If I can interrupt your Jeremiad for a moment, this page might help: http://timgolden.me.uk/python/win32_how_do_i/print.html and it (and the docs you found above) relies on this download page: http://sourceforge.net/projects/pywin32/files/pywin32/ which, as you can see, has been available for every then-valid version of Python for some years now. TJG From mal at europython.eu Wed Jul 1 08:00:01 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Wed, 01 Jul 2015 14:00:01 +0200 Subject: EuroPython 2015 Keynote: Carrie Anne Philbin Message-ID: <5593D641.1020900@europython.eu> We are pleased to introduce our next keynote speaker for EuroPython 2015: *Carrie Anne Philbin*. She will be giving her keynote on Thursday, July 23, to start the EuroPython Educational Summit: *** https://ep2015.europython.eu/en/events/educational-summit/ *** About Carrie Anne Philbin ------------------------- Carrie Anne is leading the education mission for the Raspberry Pi Foundation, but is also known as an award winning secondary Computing & ICT Teacher, Author, YouTuber: * Author of "Adventures in Raspberry Pi", a computing book for teenagers wanting to get started with Raspberry Pi and programming. Winner of Teach Secondary magazine?s Technology & Innovation Best Author award 2014. * Creator of a YouTube video series for teenage girls called "The Geek Gurl Diaries", which has won a Talk Talk Digital Hero Award. The episodes include interviews with women working in technology and hands on computer science based tutorials. * Vice chair of the Computing At Schools (CAS) initiative to get more girls and minority groups into computing, which created a workshop based hack day for teenagers concentrating on delivering good content to include all and "Hack the Curric" bringing academics, educators and industry experts together to create inclusive resources for the new Computing curriculum. In 2012, she became a Google Certified Teacher and KS3 ICT subject Leader at a school in East London. She has a blended and open approach to teaching as can be seen on her website ICT with Miss P. She became a Skype Moment Maker and ambassador for technology. She is an evangelist and often speaks at conferences like BETT, Raspberry Jamboree, YRS, PyCon UK and now EuroPython. The Keynote: Designed for Education: A Python Solution ------------------------------------------------------- The problem of introducing children to programming and computer science has seen growing attention in the past few years. Initiatives like Raspberry Pi, Code Club, code.org, (and many more) have been created to help solve this problem. With the introduction of a national computing curriculum in the UK, teachers have been searching for a text based programming language to help teach computational thinking as a follow on from visual languages like Scratch. The educational community has been served well by Python, benefiting from its straight-forward syntax, large selection of libraries, and supportive community. Education-focused summits are now a major part of most major Python Conferences. Assistance in terms of documentation and training is invaluable, but perhaps there are technical means of improving the experience of those using Python in education. Clearly the needs of teachers and their students are different to those of the seasoned programmer. Children are unlikely to come to their teachers with frustrations about the Global Interpreter Lock! But issues such as usability of IDEs or comprehensibility of error messages are of utmost importance. In this keynote, Carrie Anne will discuss existing barriers to Python becoming the premier language of choice for teaching computer science, and how learning Python could be helped immensely through tooling and further support from the Python developer community. EuroPython Educational Summit ----------------------------- We will have Educational Summit focused talks, trainings, birds of a feather sessions to debate and also Educational Sprints for the building of education focused projects during the weekend. EuroPython 2015 Educational Summit *** https://ep2015.europython.eu/en/events/educational-summit/ *** In 2012, she became a Google Certified Teacher and KS3 ICT subject Leader at a school in East London. She has a blended and open approach to teaching as can be seen on her website ICT with Miss P. She became a Skype Moment Maker and ambassador for technology. She is an evangelist and often speaks at conferences like BETT, Raspberry Jamboree, YRS, PyCon UK and now EuroPython. The Keynote: Designed for Education: A Python Solution ------------------------------------------------------- The problem of introducing children to programming and computer science has seen growing attention in the past few years. Initiatives like Raspberry Pi, Code Club, code.org, (and many more) have been created to help solve this problem. With the introduction of a national computing curriculum in the UK, teachers have been searching for a text based programming language to help teach computational thinking as a follow on from visual languages like Scratch. The educational community has been served well by Python, benefiting from its straight-forward syntax, large selection of libraries, and supportive community. Education-focused summits are now a major part of most major Python Conferences. Assistance in terms of documentation and training is invaluable, but perhaps there are technical means of improving the experience of those using Python in education. Clearly the needs of teachers and their students are different to those of the seasoned programmer. Children are unlikely to come to their teachers with frustrations about the Global Interpreter Lock! But issues such as usability of IDEs or comprehensibility of error messages are of utmost importance. In this keynote, Carrie Anne will discuss existing barriers to Python becoming the premier language of choice for teaching computer science, and how learning Python could be helped immensely through tooling and further support from the Python developer community. EuroPython Educational Summit ----------------------------- We will have Educational Summit focused talks, trainings, birds of a feather sessions to debate and also Educational Sprints for the building of education focused projects during the weekend. EuroPython 2015 Educational Summit *** https://ep2015.europython.eu/en/events/educational-summit/ *** Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From beliavsky at aol.com Wed Jul 1 09:02:48 2015 From: beliavsky at aol.com (beliavsky at aol.com) Date: Wed, 1 Jul 2015 06:02:48 -0700 (PDT) Subject: Python programming classes for children Message-ID: <240465ee-f83f-434f-8e51-db8be42fa7f7@googlegroups.com> My 11yo son is taking the online class "Intermediate Programming with Python" http://www.artofproblemsolving.com/school/course/catalog/python2 offered by the Art of Problem Solving company (AoPS). Classes meet for 1.5 hours a week for 12 weeks. During the classes the instructor "lectures" (types into a console -- there is no sound) and students type answers to questions. There are weekly programming assignments. AoPS is a U.S. company whose focus is preparing students for math competitions. Are there other groups offering Python courses for pre-college students? From bc at freeuk.com Wed Jul 1 09:10:27 2015 From: bc at freeuk.com (BartC) Date: Wed, 01 Jul 2015 14:10:27 +0100 Subject: win32print In-Reply-To: References: Message-ID: <9FRkx.15072$hX5.3745@fx09.am4> On 01/07/2015 12:28, Tim Golden wrote: > On 01/07/2015 12:02, BartC wrote: >> Yes, I ended up there at one point, but didn't see a win32print.py file, >> Presumably, nowhere on the internet is there a ready-to-use copy of >> win32print.py that someone else could just download with little effort? > If I can interrupt your Jeremiad for a moment, this page might help: > > http://timgolden.me.uk/python/win32_how_do_i/print.html > > and it (and the docs you found above) relies on this download page: > > http://sourceforge.net/projects/pywin32/files/pywin32/ > > which, as you can see, has been available for every then-valid version > of Python for some years now. OK, thanks, that now works. (I need to click on a .exe file not on .zip, and choose a version that corresponds with what's in the registry, which was 3.1 in my case, not 3.12 nor 3.4 which are also installed. This would be a better basis for solving the problem (driving a bar-code printer). Although it's still not certain how I might distribute the result (just copy the whole directory Python 3.1 tree onto a memory stick perhaps and send that). -- Bartc From zljubisic at gmail.com Wed Jul 1 10:18:01 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Wed, 1 Jul 2015 07:18:01 -0700 (PDT) Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> Message-ID: On Wednesday, 1 July 2015 01:43:19 UTC+2, Cameron Simpson wrote: > On 30Jun2015 08:34, zljubisic at gmail.com wrote: > >I would like to download a file (http://video.hrt.hr/2906/otv296.mp4) > >If the connection is OK, I can download the file with: > > > >import urllib.request > >urllib.request.urlretrieve(remote_file, local_file) > > > >Sometimes when I am connected on week wireless (not mine) network I get WinError 10054 exception (windows 7). > > > >When it happens, I would like to resume download instead of doing everything from very beginning. > > > >How to do that? > > > >I read about Range header and chunks, but this server doesn't have any headers. > > > >What options do I have with this particular file? > > You need to use a Range: header. I don't know what you mean when you say "this > server doesn't have any headers". All HTTP requests and responses use headers. > Possibly you mean you code isn't setting any headers. > > What you need to do is separate your call to urlretrieve into a call to > construct a Request object, add a Range header, then fetch the URL using the > Request object, appending the results (if successful) to the end of your local > file. > > If you go to: > > https://docs.python.org/3/library/urllib.request.html#urllib.request.urlretrieve > > and scroll up you will find example code doing that kind of thing in the > examples above. > > Cheers, > Cameron Simpson > > The British Interplanetary Society? How many planets are members then? > - G. Robb Hi, if I understood you correctly (I am not sure about which example you are refering), I should do the following: 1. check already downloaded file size in bytes = downloaded 2. url = 'http://video.hrt.hr/2906/otv296.mp4' 3. req = urllib.request.Request(url) 4. req.add_header('Range', downloaded) 5. urllib.request.urlretrieve(url, 'otv296.mp4') Is that what you were saying? Regards. From randall at tnr.cc Wed Jul 1 10:38:19 2015 From: randall at tnr.cc (Randall Smith) Date: Wed, 01 Jul 2015 09:38:19 -0500 Subject: Pure Python Data Mangling or Encrypting In-Reply-To: References: <558bc912$0$2899$c3e8da3$76491128@news.astraweb.com> <558c1a7e$0$1668$c3e8da3$5496439d@news.astraweb.com> <558d86b0$0$1659$c3e8da3$5496439d@news.astraweb.com> <558ef059$0$1673$c3e8da3$5496439d@news.astraweb.com> <5592065e$0$1675$c3e8da3$5496439d@news.astraweb.com> <5592dd34$0$1675$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 06/30/2015 01:33 PM, Chris Angelico wrote: > From the software's point of view, it has two distinct > modes: server, in which it listens on a socket and receives data, and > client, in which it connects to other people's sockets and sends data. > As such, the "server" mode is the only one that receives untrusted > data from another user and stores it on the hard disk. That's close. There are 3 types: storage nodes, client nodes, and control nodes. Communication: storage node <--> control node storage node <--> storage node client node --> storage node client node --> control node Data is uploaded by clients and distributed among storage nodes. Everything is coordinated by the control nodes (plural for redundancy). -Randall From ian.g.kelly at gmail.com Wed Jul 1 11:10:15 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Jul 2015 09:10:15 -0600 Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> Message-ID: On Wed, Jul 1, 2015 at 8:18 AM, wrote: > if I understood you correctly (I am not sure about which example you are refering), I should do the following: > 1. check already downloaded file size in bytes = downloaded > 2. url = 'http://video.hrt.hr/2906/otv296.mp4' > 3. req = urllib.request.Request(url) > 4. req.add_header('Range', downloaded) You need to use the correct format for the Range header; see RFC 7233. If you have 500 bytes and want the rest of the file, then the value for the Range header would be "bytes=500-", not just "500". You can build that string using string formatting, e.g. "bytes={}-".format(downloaded) > 5. urllib.request.urlretrieve(url, 'otv296.mp4') A couple of problems with this. One is that it doesn't use the Request object that you just constructed, so it wouldn't pass the Range header. The other is that it will overwrite that file, not append to it. You should use the urllib.request.urlopen function, and pass it the Request object rather than the URL. You can then open your local file in append mode, read the file data from the HTTPResponse object returned by urlopen, and write it to the local file. From alister.ware at ntlworld.com Wed Jul 1 11:10:29 2015 From: alister.ware at ntlworld.com (Alister) Date: Wed, 01 Jul 2015 16:10:29 +0100 Subject: EuroPython 2015 Keynote: Carrie Anne Philbin In-Reply-To: References: Message-ID: On 01/07/15 13:00, M.-A. Lemburg wrote: > We are pleased to introduce our next keynote speaker for EuroPython > 2015: *Carrie Anne Philbin*. She will be giving her keynote on Thursday, > July 23, to start the EuroPython Educational Summit: > > *** https://ep2015.europython.eu/en/events/educational-summit/ *** > > > About Carrie Anne Philbin > ------------------------- > > Carrie Anne is leading the education mission for the Raspberry Pi > Foundation, but is also known as an award winning secondary Computing > & ICT Teacher, Author, YouTuber: > > * Author of "Adventures in Raspberry Pi", a computing book for > teenagers wanting to get started with Raspberry Pi and > programming. Winner of Teach Secondary magazine?s Technology & > Innovation Best Author award 2014. > > * Creator of a YouTube video series for teenage girls called "The > Geek Gurl Diaries", which has won a Talk Talk Digital Hero > Award. The episodes include interviews with women working in > technology and hands on computer science based tutorials. > > * Vice chair of the Computing At Schools (CAS) initiative to get more > girls and minority groups into computing, which created a workshop > based hack day for teenagers concentrating on delivering good > content to include all and "Hack the Curric" bringing academics, > educators and industry experts together to create inclusive > resources for the new Computing curriculum. > > In 2012, she became a Google Certified Teacher and KS3 ICT subject > Leader at a school in East London. She has a blended and open approach > to teaching as can be seen on her website ICT with Miss P. She became > a Skype Moment Maker and ambassador for technology. She is an > evangelist and often speaks at conferences like BETT, Raspberry > Jamboree, YRS, PyCon UK and now EuroPython. > > > The Keynote: Designed for Education: A Python Solution > ------------------------------------------------------- > > The problem of introducing children to programming and computer > science has seen growing attention in the past few years. Initiatives > like Raspberry Pi, Code Club, code.org, (and many more) have been > created to help solve this problem. With the introduction of a > national computing curriculum in the UK, teachers have been searching > for a text based programming language to help teach computational > thinking as a follow on from visual languages like Scratch. > > The educational community has been served well by Python, benefiting > from its straight-forward syntax, large selection of libraries, and > supportive community. Education-focused summits are now a major part > of most major Python Conferences. Assistance in terms of documentation > and training is invaluable, but perhaps there are technical means of > improving the experience of those using Python in education. Clearly > the needs of teachers and their students are different to those of the > seasoned programmer. Children are unlikely to come to their teachers > with frustrations about the Global Interpreter Lock! But issues such > as usability of IDEs or comprehensibility of error messages are of > utmost importance. > > In this keynote, Carrie Anne will discuss existing barriers to Python > becoming the premier language of choice for teaching computer science, > and how learning Python could be helped immensely through tooling and > further support from the Python developer community. > > EuroPython Educational Summit > ----------------------------- > > We will have Educational Summit focused talks, trainings, birds of a > feather sessions to debate and also Educational Sprints for the > building of education focused projects during the weekend. > > EuroPython 2015 Educational Summit > > *** https://ep2015.europython.eu/en/events/educational-summit/ *** > > > In 2012, she became a Google Certified Teacher and KS3 ICT subject > Leader at a school in East London. She has a blended and open approach > to teaching as can be seen on her website ICT with Miss P. She became > a Skype Moment Maker and ambassador for technology. She is an > evangelist and often speaks at conferences like BETT, Raspberry > Jamboree, YRS, PyCon UK and now EuroPython. > > > The Keynote: Designed for Education: A Python Solution > ------------------------------------------------------- > > The problem of introducing children to programming and computer > science has seen growing attention in the past few years. Initiatives > like Raspberry Pi, Code Club, code.org, (and many more) have been > created to help solve this problem. With the introduction of a > national computing curriculum in the UK, teachers have been searching > for a text based programming language to help teach computational > thinking as a follow on from visual languages like Scratch. > > The educational community has been served well by Python, benefiting > from its straight-forward syntax, large selection of libraries, and > supportive community. Education-focused summits are now a major part > of most major Python Conferences. Assistance in terms of documentation > and training is invaluable, but perhaps there are technical means of > improving the experience of those using Python in education. Clearly > the needs of teachers and their students are different to those of the > seasoned programmer. Children are unlikely to come to their teachers > with frustrations about the Global Interpreter Lock! But issues such > as usability of IDEs or comprehensibility of error messages are of > utmost importance. > > In this keynote, Carrie Anne will discuss existing barriers to Python > becoming the premier language of choice for teaching computer science, > and how learning Python could be helped immensely through tooling and > further support from the Python developer community. > > EuroPython Educational Summit > ----------------------------- > > We will have Educational Summit focused talks, trainings, birds of a > feather sessions to debate and also Educational Sprints for the > building of education focused projects during the weekend. > > EuroPython 2015 Educational Summit > > *** https://ep2015.europython.eu/en/events/educational-summit/ *** > > Enjoy, > -- > EuroPython 2015 Team > http://ep2015.europython.eu/ > http://www.europython-society.org/ > forwarded to comp.sys.raspberry-pi as I think tey would be interested as well From gvanem at yahoo.no Wed Jul 1 11:44:42 2015 From: gvanem at yahoo.no (Gisle Vanem) Date: Wed, 01 Jul 2015 17:44:42 +0200 Subject: Py_InitializeEx() in CygWin64's Python2.7 Message-ID: <55940AEA.9050900@yahoo.no> I've written a C-program that embeds Python 2.7. It has worked fine for several years using MingW or MSVC. Now I'd like to support the python2.7.exe that comes with CygWin64. But it seems to fail inside 'Py_InitializeEx(0)' where it just prints: ImportError: No module named site What? Does really all Pythons needs a 'PYTHONPATH' set to point to the site.py? Or is it only CygWin that is special here? Since if I do a "set PYTHONPATH=/usr/lib/python2.7" in my shell, my program works. These are some of the func-ptr and arguments I use during init: Py_SetProgramName ("/cygdrive/f/gv/VC_project/EnvTool/src/envtool.exe") Py_SetPythonHome ("/usr/lib/python2.7") Py_InitializeEx(0) << libpython2.7.dll chokes inside here for a mysterious reason. I maybe naively assumes calling 'Py_SetPythonHome' is doing part of what parsing the PYTHONPATH should do. But it doesn't seems so. If I from my cmd-line do a: c:\> f:\CygWin64\bin\python2.7.exe -c "import sys; print (sys.modules)" I can see: So what could be the reason it's not able to load and parse it without a 'PYTHONPATH' set explicit? -- --gv From mail at timgolden.me.uk Wed Jul 1 12:19:23 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 01 Jul 2015 17:19:23 +0100 Subject: Python programming classes for children In-Reply-To: <240465ee-f83f-434f-8e51-db8be42fa7f7@googlegroups.com> References: <240465ee-f83f-434f-8e51-db8be42fa7f7@googlegroups.com> Message-ID: <5594130B.3080101@timgolden.me.uk> On 01/07/2015 14:02, beliavsky--- via Python-list wrote: > My 11yo son is taking the online class "Intermediate Programming with > Python" > http://www.artofproblemsolving.com/school/course/catalog/python2 > offered by the Art of Problem Solving company (AoPS). Classes meet > for 1.5 hours a week for 12 weeks. During the classes the instructor > "lectures" (types into a console -- there is no sound) and students > type answers to questions. There are weekly programming assignments. > AoPS is a U.S. company whose focus is preparing students for math > competitions. > > Are there other groups offering Python courses for pre-college > students? > I realise that this may not be the answer you want but: pretty much the whole of the UK Primary & Secondary education system, at one level or another! TJG From pkpearson at nowhere.invalid Wed Jul 1 12:36:22 2015 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 1 Jul 2015 16:36:22 GMT Subject: Datetime timezone trouble (was: Matplotlib X-axis timezone trouble) References: Message-ID: On Wed, 1 Jul 2015 17:15:38 +1000, Chris Angelico wrote: > > Interestingly, when I tried this (pytz version 2015.4, Python 2.7.9, > Debian Jessie), I saw utcoffset() showing (-1, 58020) for both. That > seems... odd. And I can't fault your dates - those definitely ought to > be easily inside and easily outside the DST boundaries. When I try > those dates in an unrelated time converter, they do show seven- and > eight- hour offsets to UTC. Maybe we're both misunderstanding the > meaning of utcoffset()? Here's a very simple demonstration that either something is wrong or I don't understand how datetime and tzinfo are supposed to work: $ python Python 2.7.3 (default, Mar 13 2014, 11:03:55) >>> from pytz import timezone >>> from datetime import datetime >>> pacific = timezone("US/Pacific") >>> print(datetime(2014, 7, 7, 12, tzinfo=pacific)) 2014-07-07 12:00:00-08:00 >>> print(datetime(2014, 1, 7, 12, tzinfo=pacific)) 2014-01-07 12:00:00-08:00 >>> The "-08:00" is appropriate in the second (January) case, but the first case is in July, and should have "-07:00". -- To email me, substitute nowhere->runbox, invalid->com. From ian.g.kelly at gmail.com Wed Jul 1 12:55:02 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Jul 2015 10:55:02 -0600 Subject: Datetime timezone trouble (was: Matplotlib X-axis timezone trouble) In-Reply-To: References: Message-ID: On Wed, Jul 1, 2015 at 10:36 AM, Peter Pearson wrote: > On Wed, 1 Jul 2015 17:15:38 +1000, Chris Angelico wrote: >> >> Interestingly, when I tried this (pytz version 2015.4, Python 2.7.9, >> Debian Jessie), I saw utcoffset() showing (-1, 58020) for both. That >> seems... odd. And I can't fault your dates - those definitely ought to >> be easily inside and easily outside the DST boundaries. When I try >> those dates in an unrelated time converter, they do show seven- and >> eight- hour offsets to UTC. Maybe we're both misunderstanding the >> meaning of utcoffset()? > > Here's a very simple demonstration that either something is wrong > or I don't understand how datetime and tzinfo are supposed to work: > > $ python > Python 2.7.3 (default, Mar 13 2014, 11:03:55) >>>> from pytz import timezone >>>> from datetime import datetime >>>> pacific = timezone("US/Pacific") >>>> print(datetime(2014, 7, 7, 12, tzinfo=pacific)) > 2014-07-07 12:00:00-08:00 >>>> print(datetime(2014, 1, 7, 12, tzinfo=pacific)) > 2014-01-07 12:00:00-08:00 >>>> > > The "-08:00" is appropriate in the second (January) case, but the > first case is in July, and should have "-07:00". Use this instead: >>> print(pacific.localize(datetime(2014, 7, 7, 12))) 2014-07-07 12:00:00-07:00 See http://pytz.sourceforge.net/#localized-times-and-date-arithmetic From rosuav at gmail.com Wed Jul 1 13:08:34 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 2 Jul 2015 03:08:34 +1000 Subject: Datetime timezone trouble (was: Matplotlib X-axis timezone trouble) In-Reply-To: References: Message-ID: On Thu, Jul 2, 2015 at 2:36 AM, Peter Pearson wrote: > On Wed, 1 Jul 2015 17:15:38 +1000, Chris Angelico wrote: >> >> Interestingly, when I tried this (pytz version 2015.4, Python 2.7.9, >> Debian Jessie), I saw utcoffset() showing (-1, 58020) for both. That >> seems... odd. And I can't fault your dates - those definitely ought to >> be easily inside and easily outside the DST boundaries. When I try >> those dates in an unrelated time converter, they do show seven- and >> eight- hour offsets to UTC. Maybe we're both misunderstanding the >> meaning of utcoffset()? > > Here's a very simple demonstration that either something is wrong > or I don't understand how datetime and tzinfo are supposed to work: > > $ python > Python 2.7.3 (default, Mar 13 2014, 11:03:55) >>>> from pytz import timezone >>>> from datetime import datetime >>>> pacific = timezone("US/Pacific") >>>> print(datetime(2014, 7, 7, 12, tzinfo=pacific)) > 2014-07-07 12:00:00-08:00 >>>> print(datetime(2014, 1, 7, 12, tzinfo=pacific)) > 2014-01-07 12:00:00-08:00 >>>> > > The "-08:00" is appropriate in the second (January) case, but the > first case is in July, and should have "-07:00". Interesting. I poked around with the docstring for pytz.timezone and replicated it more exactly, and this appears to work: $ python Python 2.7.9 (default, Mar 1 2015, 12:57:24) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from pytz import timezone >>> from datetime import datetime >>> pacific = timezone("US/Pacific") >>> utc = timezone("UTC") >>> print(datetime(2014, 7, 7, 12, tzinfo=utc).astimezone(pacific)) 2014-07-07 05:00:00-07:00 >>> print(datetime(2014, 1, 7, 12, tzinfo=utc).astimezone(pacific)) 2014-01-07 04:00:00-08:00 Clearly I do not understand what's going on here. ChrisA From random832 at fastmail.us Wed Jul 1 14:26:25 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Wed, 01 Jul 2015 14:26:25 -0400 Subject: Recreate file associations? In-Reply-To: References: <1435586604.265153.310526457.172CA608@webmail.messagingengine.com> Message-ID: <1435775185.1890861.312824065.59C029D8@webmail.messagingengine.com> On Mon, Jun 29, 2015, at 14:25, Terry Reedy wrote: > Registry => Windows. > Did you check [X] Make this my default python? I didn't see any such checkbox, in any of installers I ran. (And, yes, I assumed windows was implied by my subject - other systems python runs on either don't have a notion of "file associations" or don't use them as the mechanism for executing python scripts) From pkpearson at nowhere.invalid Wed Jul 1 15:09:03 2015 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 1 Jul 2015 19:09:03 GMT Subject: Datetime timezone trouble (was: Matplotlib X-axis timezone trouble) References: Message-ID: On Wed, 1 Jul 2015 10:55:02 -0600, Ian Kelly wrote: > On Wed, Jul 1, 2015 at 10:36 AM, Peter Pearson [wrote]: [snip] >> Here's a very simple demonstration that either something is wrong >> or I don't understand how datetime and tzinfo are supposed to work: >> >> $ python >> Python 2.7.3 (default, Mar 13 2014, 11:03:55) >>>>> from pytz import timezone >>>>> from datetime import datetime >>>>> pacific = timezone("US/Pacific") >>>>> print(datetime(2014, 7, 7, 12, tzinfo=pacific)) >> 2014-07-07 12:00:00-08:00 >>>>> print(datetime(2014, 1, 7, 12, tzinfo=pacific)) >> 2014-01-07 12:00:00-08:00 >>>>> >> >> The "-08:00" is appropriate in the second (January) case, but the >> first case is in July, and should have "-07:00". > > Use this instead: > >>>> print(pacific.localize(datetime(2014, 7, 7, 12))) > 2014-07-07 12:00:00-07:00 > > See http://pytz.sourceforge.net/#localized-times-and-date-arithmetic Excellent. Thank you. To summarize, for any similarly afflicted person who finds this thread: - http://pytz.sourceforge.net/#localized-times-and-date-arithmetic says: Unfortunately using the tzinfo argument of the standard datetime constructors ??does not work?? with pytz for many timezones. It is safe for timezones without daylight saving transitions though, such as UTC: - PEP 0431 says (approximately) that datetime doesn't work as well as we might like with DST, but will be slow to change. - The "localize" function is pytz's way of working around this shortcoming of datetime's -- To email me, substitute nowhere->runbox, invalid->com. From zljubisic at gmail.com Wed Jul 1 15:24:46 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Wed, 1 Jul 2015 12:24:46 -0700 (PDT) Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> Message-ID: <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> Currently I am executing the following code: import os import urllib.request def Download(rfile, lfile): retval = False if os.path.isfile(lfile): lsize = os.stat(lfile).st_size else: lsize = 0 req = urllib.request.Request(rfile) req.add_header('Range', "bytes={}-".format(lsize)) with urllib.request.urlopen(req) as response, open(lfile, 'ab') as out_file: data = response.read() # a `bytes` object out_file.write(data) if response.headers.headers['Content-Length'] == os.stat(lfile).st_size: retval = True return retval Download('http://video.hrt.hr/2906/otv296.mp4', 'otv296.mp4') The internet connection here is very slow so execution will last for say an hour. In meantime, can I upgrade the procedure in a way to write to file chunk by chunk instead of the whole file? Furthermore, how to know whether the file is fully completed or not? I trid with "if response.headers.headers['Content-Length'] == os.stat(lfile).st_size:", but I believe there is a better way. Big regards. From rosuav at gmail.com Wed Jul 1 15:28:36 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 2 Jul 2015 05:28:36 +1000 Subject: Python 3 resuma a file download In-Reply-To: <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> Message-ID: On Thu, Jul 2, 2015 at 5:24 AM, wrote: > with urllib.request.urlopen(req) as response, open(lfile, 'ab') as out_file: > data = response.read() # a `bytes` object > out_file.write(data) > If a file is big enough to want to resume the download once, you almost certainly want to be able to resume it a second time. I would recommend not attempting to do the entire read and write as a single operation - read chunks and write them to the disk. This will attempt to read the entire response into a gigantic in-memory bytestring, and only then start writing. ChrisA From zljubisic at gmail.com Wed Jul 1 15:31:46 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Wed, 1 Jul 2015 12:31:46 -0700 (PDT) Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> Message-ID: <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> But how to read chunks? From __peter__ at web.de Wed Jul 1 15:51:56 2015 From: __peter__ at web.de (Peter Otten) Date: Wed, 01 Jul 2015 21:51:56 +0200 Subject: Python 3 resuma a file download References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> Message-ID: zljubisic at gmail.com wrote: > But how to read chunks? Instead of > data = response.read() # a `bytes` object > out_file.write(data) use a loop: CHUNKSIZE = 16*1024 # for example while True: data = response.read(CHUNKSIZE) if not data: break out_file.write(data) This can be simplified: shutil.copyfileobj(response, out_file) https://docs.python.org/dev/library/shutil.html#shutil.copyfileobj From zljubisic at gmail.com Wed Jul 1 15:59:21 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Wed, 1 Jul 2015 12:59:21 -0700 (PDT) Subject: Python 3 resuma a file download In-Reply-To: <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> Message-ID: <482382f0-8ea4-4085-ae73-0d24e4fd8917@googlegroups.com> New version with chunks: import os import urllib.request def Download(rfile, lfile): retval = False if os.path.isfile(lfile): lsize = os.stat(lfile).st_size else: lsize = 0 req = urllib.request.Request(rfile) req.add_header('Range', "bytes={}-".format(lsize)) response = urllib.request.urlopen(req) with open(lfile, 'ab') as out_file: while True: try: chunk = response.read(8192) if not chunk: break out_file.write(chunk) except ConnectionResetError as e: print('Exception ConnectionResetError {0}'.format(os.stat(lfile).st_size)) if response.headers.headers['Content-Length'] == os.stat(lfile).st_size: retval = True return retval Download('http://video.hrt.hr/2906/otv296.mp4', 'c:\\Users\\zoran\\hrt\\sync\\otv296.mp4') From python.list at tim.thechases.com Wed Jul 1 16:04:19 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 1 Jul 2015 15:04:19 -0500 Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> Message-ID: <20150701150419.1fd24fac@bigbox.christie.dr> On 2015-07-01 21:51, Peter Otten wrote: > use a loop: > > CHUNKSIZE = 16*1024 # for example > while True: > data = response.read(CHUNKSIZE) > if not data: > break > out_file.write(data) > > > This can be simplified: > > shutil.copyfileobj(response, out_file) It's these little corners of Python that make me wonder how many times I've written that `while` loop when I could have just used a tested function from the stdlib. Sigh. -tkc From __peter__ at web.de Wed Jul 1 16:06:51 2015 From: __peter__ at web.de (Peter Otten) Date: Wed, 01 Jul 2015 22:06:51 +0200 Subject: Python 3 resuma a file download References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> <482382f0-8ea4-4085-ae73-0d24e4fd8917@googlegroups.com> Message-ID: zljubisic at gmail.com wrote: > New version with chunks: > > import os > import urllib.request > > def Download(rfile, lfile): > > retval = False > > if os.path.isfile(lfile): > lsize = os.stat(lfile).st_size > else: > lsize = 0 > > req = urllib.request.Request(rfile) > req.add_header('Range', "bytes={}-".format(lsize)) > > > response = urllib.request.urlopen(req) > > with open(lfile, 'ab') as out_file: > while True: > try: > chunk = response.read(8192) > if not chunk: break > out_file.write(chunk) > except ConnectionResetError as e: > print('Exception ConnectionResetError > {0}'.format(os.stat(lfile).st_size)) Catching the exception inside the while-True loop is not a good idea. > if response.headers.headers['Content-Length'] == > os.stat(lfile).st_size: > retval = True > > return retval > > Download('http://video.hrt.hr/2906/otv296.mp4', > 'c:\\Users\\zoran\\hrt\\sync\\otv296.mp4') From john_ladasky at sbcglobal.net Wed Jul 1 17:02:58 2015 From: john_ladasky at sbcglobal.net (John Ladasky) Date: Wed, 1 Jul 2015 14:02:58 -0700 (PDT) Subject: Python programming classes for children In-Reply-To: <240465ee-f83f-434f-8e51-db8be42fa7f7@googlegroups.com> References: <240465ee-f83f-434f-8e51-db8be42fa7f7@googlegroups.com> Message-ID: <1c0271fb-0bc2-4a1a-9540-8a69662693f1@googlegroups.com> On Wednesday, July 1, 2015 at 6:03:06 AM UTC-7, beli... at aol.com wrote: > My 11yo son is taking the online class "Intermediate Programming with Python" http://www.artofproblemsolving.com/school/course/catalog/python2 offered by the Art of Problem Solving company (AoPS). Classes meet for 1.5 hours a week for 12 weeks. During the classes the instructor "lectures" (types into a console -- there is no sound) and students type answers to questions. There are weekly programming assignments. AoPS is a U.S. company whose focus is preparing students for math competitions. > > Are there other groups offering Python courses for pre-college students? I would recommend that you investigate web sites which match tutors to students. Find a Python tutor who can come to your home, or meet your son at a nearby public library. I love technology, but it's not good for everything. I have taught Python to a range of students, from middle-school age through working professionals. I am also married to an elementary school teacher, and we sometimes discuss teaching methods and strategies. I can't imagine that this remote, text-only method of teaching would be very effective, especially for a student that young. If you have been programming for a while, you take some things for granted that kids have to learn, and be shown, with great patience. For example, my youngest students often have trouble at first understanding the difference between variable names and their contents, especially when the variables are strings. The only way that I agree to teach is face-to-face. I have had a few potential students ask me to tutor over Skype, and I have always declined. I bring a laptop, and the student sits at their own computer. I have broad goals for a lesson when I arrive. However I will, and indeed I must, deviate from my plans when the student doesn't understand a concept. Occasionally I type on my own laptop, when instant visual feedback is needed. But mostly, I converse with the student, and look over their shoulders as they develop their code. I let them make mistakes. I ask them to run their buggy code, and when it doesn't work the way that they intended, I ask them if they can figure out why. One more thing: I do NOT teach my students Python 2. I have been working with a QA Engineer whose company uses Python 2, but all of my other students are free to choose to learn only Python 3. Python 3 has been available for about five years now, and most new code is being developed in Py3. I will not handicap my students by teaching them an obsolescent version of Python. From hinaimran.mehr at gmail.com Wed Jul 1 17:57:14 2015 From: hinaimran.mehr at gmail.com (hinaimran.mehr at gmail.com) Date: Wed, 1 Jul 2015 14:57:14 -0700 (PDT) Subject: how to fix TypeError: format requires a mapping Message-ID: <96b5ec30-2da2-4b87-ab76-55967fa6d6d3@googlegroups.com> I am pulling my hair with this problem right now, I have the following Data structure [ References: <558b7e85$0$1648$c3e8da3$5496439d@news.astraweb.com> <558bc912$0$2899$c3e8da3$76491128@news.astraweb.com> <558c1a7e$0$1668$c3e8da3$5496439d@news.astraweb.com> <558d86b0$0$1659$c3e8da3$5496439d@news.astraweb.com> Message-ID: Randall Smith wrote: > Worse case, something that looks like this would land on the disk. > > crc32 checksum + translation table + malware It would be safer to add something to both the beginning *and* end of the file. Some file formats, e.g. zip, pdf, are designed to be read starting from the end. So I would suggest something like crc32 checksum + payload + translation table -- Greg From cs at zip.com.au Wed Jul 1 18:50:10 2015 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 2 Jul 2015 08:50:10 +1000 Subject: Python 3 resuma a file download In-Reply-To: References: Message-ID: <20150701225010.GA42225@cskk.homeip.net> On 01Jul2015 21:51, Peter Otten <__peter__ at web.de> wrote: >zljubisic at gmail.com wrote: > >> But how to read chunks? > >Instead of > >> data = response.read() # a `bytes` object >> out_file.write(data) > >use a loop: > >CHUNKSIZE = 16*1024 # for example >while True: > data = response.read(CHUNKSIZE) > if not data: > break > out_file.write(data) It might be worth noting here that Peter's "chunk" is just an arbitrary amount of data to read in a unit. I'm only mentioning this because the HTTP specification has a "chunked-encoding" used to return binary files, and we are not talking about _those_ chunks. Cheers, Cameron Simpson Life is uncertain. Eat dessert first. - Jim Blandy From bob at mellowood.ca Wed Jul 1 20:12:36 2015 From: bob at mellowood.ca (bvdp) Date: Wed, 1 Jul 2015 17:12:36 -0700 (PDT) Subject: "normalizing" a value Message-ID: Not sure what this is called (and I'm sure it's not normalize). Perhaps "scaling"? Anyway, I need to convert various values ranging from around -50 to 50 to an 0 to 12 range (this is part of a MIDI music program). I have a number of places where I do: while x < 0: x += 12 while x >= 12: x -= 12 Okay, that works. Just wondering if there is an easier (or faster) way to accomplish this. From python at mrabarnett.plus.com Wed Jul 1 20:30:45 2015 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 02 Jul 2015 01:30:45 +0100 Subject: "normalizing" a value In-Reply-To: References: Message-ID: <55948635.50801@mrabarnett.plus.com> On 2015-07-02 01:12, bvdp wrote: > Not sure what this is called (and I'm sure it's not normalize). Perhaps "scaling"? > > Anyway, I need to convert various values ranging from around -50 to 50 to an 0 to 12 range (this is part of a MIDI music program). I have a number of places where I do: > > while x < 0: x += 12 > while x >= 12: x -= 12 > > Okay, that works. Just wondering if there is an easier (or faster) way to accomplish this. > That's called "modular arithmetic". Use the modulo operator, '%': x = x % 12 or just: x %= 12 From no.email at nospam.invalid Wed Jul 1 20:36:21 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Wed, 01 Jul 2015 17:36:21 -0700 Subject: "normalizing" a value References: Message-ID: <87a8vfqttm.fsf@nightsong.com> bvdp writes: > while x < 0: x += 12 > while x >= 12: x -= 12 > Okay, that works. Just wondering if there is an easier (or faster) way > to accomplish this. x = x % 12 should be the same as the above. But are you sure that's really what you want? From denismfmcmahon at gmail.com Wed Jul 1 21:06:23 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 2 Jul 2015 01:06:23 +0000 (UTC) Subject: "normalizing" a value References: Message-ID: On Wed, 01 Jul 2015 17:12:36 -0700, bvdp wrote: > Not sure what this is called (and I'm sure it's not normalize). Perhaps > "scaling"? > > Anyway, I need to convert various values ranging from around -50 to 50 > to an 0 to 12 range (this is part of a MIDI music program). I have a > number of places where I do: > > while x < 0: x += 12 while x >= 12: x -= 12 > > Okay, that works. Just wondering if there is an easier (or faster) way > to accomplish this. Are you sure it works? Do you simply want to reduce it to the arbitrary range, or do you want to also retain the relationship between different x values such that if x1 < x2, f(x1) < f(x2)? Consider the following x values: -11, -12, -13, 11, 12, 13 -11 -> 1 -12 -> 0 -13 -> 11 11 -> 11 12 -> 0 13 -> 1 So -13 gives the same output value as 11 in your current code. Is this what you want? You could try the following: # step 1, limit x to the range -50 .. 50 if x < -50: x = -50.0 ix x >= 50: x = 50.0 # step 2, scale x to the range 0 .. 12 x = x * 0.12 + 6.0 If you want an integer value, you need to determine which method is most relevant. I would suggest rounding. -- Denis McMahon, denismfmcmahon at gmail.com From vek.m1234 at gmail.com Wed Jul 1 21:11:40 2015 From: vek.m1234 at gmail.com (Veek M) Date: Thu, 02 Jul 2015 06:41:40 +0530 Subject: Javascript website scraping using WebKit and Selenium tools Message-ID: I tried scraping a javascript website using two tools, both didn't work. The website link is: http://xdguo.taobao.com/category-499399872.htm The relevant text I'm trying to extract is 'GY-68...':
GY-68 BMP180 ?? BOSCH?? ??????? ??
BMP085
I'm trying to match the class="item " bit as a preliminary venture: from pyvirtualdisplay import Display from selenium import webdriver import time display = Display(visible=0, size=(800, 600)) display.start() browser = webdriver.Firefox() browser.get('http://xdguo.taobao.com/category-499399872.htm') print browser.title time.sleep(120) content = browser.find_element_by_class_name('item ') print content browser.quit() display.stop() I get: selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"class name","selector":"item "} I also tried using WebKit - i know the site renders okay in WebKit because i tested with rekonq Here, i get the page (in Chinese) but the actual/relevant data is not there. WebKit's supposed to run the Javascript and give me the final results but I don't think that's happening. import sys from io import StringIO from PyQt4.QtGui import * from PyQt4.QtCore import * from PyQt4.QtWebKit import * from lxml import html from lxml import etree #Take this class for granted.Just use result of rendering. class Render(QWebPage): def __init__(self, url): self.app = QApplication(sys.argv) QWebPage.__init__(self) self.loadFinished.connect(self._loadFinished) self.mainFrame().load(QUrl(url)) self.app.exec_() def _loadFinished(self, result): self.frame = self.mainFrame() self.app.quit() url = 'http://xdguo.taobao.com/category-499399872.htm' r = Render(url) #returns a Render object result = r.frame.toHtml() #returns a QString result_utf8 = result.toUtf8() #returns a QByteArray of utf8 data #QByteArray->str->unicode #contents = StringIO(unicode(result_utf8.data(), "utf-8")) data = result_utf8.data() #returns byte string print(data) element = html.fromstring(data) print(element.tag) for img in element.xpath('//dl[@class="item "]/dt[@class="photo"]/a/img'): print(img.get('alt')) #archive_links = html.fromstring(str(result.toAscii())) #print archive_links.xpath("/html/body/div[2]/div[3]/div[2]/div[2]/div[1]/div/div /div/div/div/div[2]/div[2]/dl[1]/dt/a/img") Basically I want a list of parts the seller has to offer that I can grep, sort, uniq. I also tried elinks and lynx with ECMAScript but that was too basic and didn't work. From denismfmcmahon at gmail.com Wed Jul 1 21:20:09 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 2 Jul 2015 01:20:09 +0000 (UTC) Subject: how to fix TypeError: format requires a mapping References: <96b5ec30-2da2-4b87-ab76-55967fa6d6d3@googlegroups.com> Message-ID: On Wed, 01 Jul 2015 14:57:14 -0700, hinaimran.mehr wrote: > I am pulling my hair with this problem right now, > > I have the following Data structure > > [ u'resource_id': u'id', u'timestamp': u'2015-06-30T15:53:55', > u'counter_volume': 0.043}] This isn't a print out of any python data structure that I recognise. I assume you have a list of dictionaries, and that each dictionary represents one sample. > I need to make it something like this to put in EON pubnub charting > libaray (see link: http://www.pubnub.com/developers/eon/chart/spline/) > > message: { > columns: [ > ["y": 0.043, "x": "2015-06-30T15:53:55"], > ["y": 0.045, "x": "2015-06-30T15:53:55"] > ] > > Now I have the following code > > data = cclient.samples.list(meter_name ='cpu_util', limit=2) > > result_rows = [] > for row in data: > formatted = """["y": %(counter_volume)0.3f, "x": > "%(timestamp)s"]""" % (row) > result_rows.append(formatted) > > print(',\n'.join(result_rows)) > > > clean_json(data) I assume you want the output as json. The solution may be to put the data into a suitable structure and dump the structure to json. import json thing = {} msg = {} cols = [] for row in data: col = {} col['x'] = row['timestamp'] col['y'] = row['counter_volume'] cols.append(col) msg['columns'] = cols thing['message'] = msg print thing print json.dumps(thing) -- Denis McMahon, denismfmcmahon at gmail.com From random832 at fastmail.us Wed Jul 1 21:27:36 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Wed, 01 Jul 2015 21:27:36 -0400 Subject: "normalizing" a value In-Reply-To: References: Message-ID: <1435800456.1334531.313151433.0039725C@webmail.messagingengine.com> On Wed, Jul 1, 2015, at 20:12, bvdp wrote: > Not sure what this is called (and I'm sure it's not normalize). Perhaps > "scaling"? > > Anyway, I need to convert various values ranging from around -50 to 50 to > an 0 to 12 range (this is part of a MIDI music program). I have a number > of places where I do: > > while x < 0: x += 12 > while x >= 12: x -= 12 And this gives you what you want? With e.g. 13=1, 14=2, 22=10, 23=11, 24=0, 25 = 1, etc. Seems unusual that that's what you would want. Also note this gives an 0 to 11 range for the results, not 0 to 12. Anyway, x %= 12 will give the same results. From bob at mellowood.ca Wed Jul 1 21:49:34 2015 From: bob at mellowood.ca (bvdp) Date: Wed, 1 Jul 2015 18:49:34 -0700 (PDT) Subject: "normalizing" a value In-Reply-To: References: Message-ID: <948e2800-e52b-429a-9e00-f268fcff5085@googlegroups.com> On Wednesday, July 1, 2015 at 6:27:57 PM UTC-7, rand... at fastmail.us wrote: > On Wed, Jul 1, 2015, at 20:12, bvdp wrote: > > Not sure what this is called (and I'm sure it's not normalize). Perhaps > > "scaling"? > > > > Anyway, I need to convert various values ranging from around -50 to 50 to > > an 0 to 12 range (this is part of a MIDI music program). I have a number > > of places where I do: > > > > while x < 0: x += 12 > > while x >= 12: x -= 12 > > And this gives you what you want? With e.g. 13=1, 14=2, 22=10, 23=11, > 24=0, 25 = 1, etc. Seems unusual that that's what you would want. > > Also note this gives an 0 to 11 range for the results, not 0 to 12. > > Anyway, x %= 12 will give the same results. Thanks guys. Yes, that is exactly what I want. I have a number of places where a MIDI note value is being generated. MIDI should be 0..127, but the process creates notes outside the range. Guess that's another question: if the value I have is <0 or >127 I add/subtract 12 'til it's in range. Don't see using modulo working on this??? As far as the original question: Yes, that's what I need. At times I need to take a note (say 14) and map it into a single octave range. So, the 12 becomes 2. Both 14 and 2 are numeric values for note "d", just an octave apart. Interesting that negative values translate properly. That's an non-intuitive result to me. Guess I should have studied that math stuff harder way back when! From arsh840 at gmail.com Wed Jul 1 21:49:48 2015 From: arsh840 at gmail.com (Great Avenger Singh) Date: Wed, 1 Jul 2015 18:49:48 -0700 (PDT) Subject: Python programming classes for children In-Reply-To: <240465ee-f83f-434f-8e51-db8be42fa7f7@googlegroups.com> References: <240465ee-f83f-434f-8e51-db8be42fa7f7@googlegroups.com> Message-ID: <368564a3-320b-4a55-9005-18ef355862f2@googlegroups.com> On Wednesday, 1 July 2015 18:33:06 UTC+5:30, beli... at aol.com wrote: > Are there other groups offering Python courses for pre-college students? Some months ago I took one course from Edx, They provide very good material and every each topic assignment is given, You can try following: https://www.edx.org/course/introduction-computer-science-mitx-6-00-1x-0 From arsh840 at gmail.com Wed Jul 1 21:54:01 2015 From: arsh840 at gmail.com (Great Avenger Singh) Date: Wed, 1 Jul 2015 18:54:01 -0700 (PDT) Subject: Python programming classes for children In-Reply-To: <368564a3-320b-4a55-9005-18ef355862f2@googlegroups.com> References: <240465ee-f83f-434f-8e51-db8be42fa7f7@googlegroups.com> <368564a3-320b-4a55-9005-18ef355862f2@googlegroups.com> Message-ID: On Thursday, 2 July 2015 07:20:03 UTC+5:30, Great Avenger Singh wrote: > On Wednesday, 1 July 2015 18:33:06 UTC+5:30, beli... at aol.com wrote: > > > Are there other groups offering Python courses for pre-college students? > > Some months ago I took one course from Edx, They provide very good material and every each topic assignment is given, > > You can try following: > > https://www.edx.org/course/introduction-computer-science-mitx-6-00-1x-0 If your son has already gotten basic programming concepts like execution of instruction that's fine. Otherwise give also try to this: https://code.org/ From steve at pearwood.info Wed Jul 1 22:15:11 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Thu, 02 Jul 2015 12:15:11 +1000 Subject: "normalizing" a value References: Message-ID: <55949eaf$0$1642$c3e8da3$5496439d@news.astraweb.com> On Thu, 2 Jul 2015 10:12 am, bvdp wrote: > Not sure what this is called (and I'm sure it's not normalize). Perhaps > "scaling"? Could be normalising, could be scaling. > Anyway, I need to convert various values ranging from around -50 to 50 to > an 0 to 12 range (this is part of a MIDI music program). I have a number > of places where I do: You say "around" -50 to 50. Can you get 51? 151? How do you want to treat such out of range numbers? Are the values integer valued, or can they include fractional values like 27.356? > while x < 0: x += 12 > while x >= 12: x -= 12 > > Okay, that works. Just wondering if there is an easier (or faster) way to > accomplish this. One approach is to just re-scale the numbers from the range -50...50 to 0...12 inclusive. That is: before => after -50 => 0 0 => 6 50 => 12 and everything in between is scaled equivalently. Given x between -50 and 50 inclusive, calculate: y = (x+50)/100.0*12 (Note that in Python 2, you need to make at least one of those values a float, otherwise you may get unexpected results.) That will give you y values from the range 0.0 to 12.0 inclusive. If x is less than -50.0 or more than +50.0 y will likewise be out of range. You can clip the result: y = min(12.0, max(0.0, y)) If your x values are integer values (no fractional values) between -50 and +50 you can use clock arithmetic. Think of a clock marked 0 to 12 (so there are 13 values), once you reach 12 adding 1 takes you back to 0. 0, 13, 26, 39 => 0 1, 14, 27, 40 => 1 2, 15, 28, 41 => 2 ... 12, 25, 38, 51 => 12 Extending that to negative values in the most obvious fashion: -1, -14, -27, -40 => 12 ... -12, -25, -38, -51 => 1 -13, -26, -39, -52 => 0 We can do that easily with the % (modulo) operator: y = x % y Modulo even works with non-integer values: py> 13.5 % 13 0.5 -- Steven From random832 at fastmail.us Wed Jul 1 22:23:05 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Wed, 01 Jul 2015 22:23:05 -0400 Subject: "normalizing" a value In-Reply-To: <948e2800-e52b-429a-9e00-f268fcff5085@googlegroups.com> References: <948e2800-e52b-429a-9e00-f268fcff5085@googlegroups.com> Message-ID: <1435803785.1346111.313173769.4BE4E5DF@webmail.messagingengine.com> On Wed, Jul 1, 2015, at 21:49, bvdp wrote: > Interesting that negative values translate properly. That's an > non-intuitive result to me. Guess I should have studied that math stuff > harder way back when! There are multiple interpretations of the operation, and not all languages behave the same way as Python does with negative operands. Python is the odd one out when one considers C/C++, C#, and Java which all behave a different way. In general, almost all languages behave in a way so that given q, r = a // b, a % b; q * b + r == a. However, this simply changes the question to how division results involving negative operands are rounded. Here's an article by GvR about why python behaves the way it does: http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html From bob at mellowood.ca Wed Jul 1 22:41:26 2015 From: bob at mellowood.ca (bvdp) Date: Wed, 1 Jul 2015 19:41:26 -0700 (PDT) Subject: "normalizing" a value In-Reply-To: References: <948e2800-e52b-429a-9e00-f268fcff5085@googlegroups.com> Message-ID: <7016792e-ac01-4ee5-a644-1bea9a204d8c@googlegroups.com> On Wednesday, July 1, 2015 at 7:23:19 PM UTC-7, rand... at fastmail.us wrote: > On Wed, Jul 1, 2015, at 21:49, bvdp wrote: > > Interesting that negative values translate properly. That's an > > non-intuitive result to me. Guess I should have studied that math stuff > > harder way back when! > > There are multiple interpretations of the operation, and not all > languages behave the same way as Python does with negative operands. > Python is the odd one out when one considers C/C++, C#, and Java which > all behave a different way. > > In general, almost all languages behave in a way so that given q, r = a > // b, a % b; q * b + r == a. However, this simply changes the question > to how division results involving negative operands are rounded. > > Here's an article by GvR about why python behaves the way it does: > http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html Interesting link. Thanks. I always thought that modulo was modulo. Guess this is another example of why converting code between languages is hard :) Anyway, far as shoving my MIDI notes into a single octave, x % 12 seems to be perfect. From bob at mellowood.ca Wed Jul 1 22:42:40 2015 From: bob at mellowood.ca (bvdp) Date: Wed, 1 Jul 2015 19:42:40 -0700 (PDT) Subject: "normalizing" a value In-Reply-To: <55949eaf$0$1642$c3e8da3$5496439d@news.astraweb.com> References: <55949eaf$0$1642$c3e8da3$5496439d@news.astraweb.com> Message-ID: <29e00fb7-ac8f-41d7-b59b-4e0a39c77496@googlegroups.com> On Wednesday, July 1, 2015 at 7:15:28 PM UTC-7, Steven D'Aprano wrote: > On Thu, 2 Jul 2015 10:12 am, bvdp wrote: > > > Not sure what this is called (and I'm sure it's not normalize). Perhaps > > "scaling"? > > > Could be normalising, could be scaling. > > > Anyway, I need to convert various values ranging from around -50 to 50 to > > an 0 to 12 range (this is part of a MIDI music program). I have a number > > of places where I do: > > You say "around" -50 to 50. Can you get 51? 151? How do you want to treat > such out of range numbers? > > Are the values integer valued, or can they include fractional values like > 27.356? > > > while x < 0: x += 12 > > while x >= 12: x -= 12 > > > > Okay, that works. Just wondering if there is an easier (or faster) way to > > accomplish this. > > > One approach is to just re-scale the numbers from the range -50...50 to > 0...12 inclusive. That is: > > before => after > -50 => 0 > 0 => 6 > 50 => 12 > > > and everything in between is scaled equivalently. Given x between -50 and 50 > inclusive, calculate: > > y = (x+50)/100.0*12 > > > (Note that in Python 2, you need to make at least one of those values a > float, otherwise you may get unexpected results.) > > That will give you y values from the range 0.0 to 12.0 inclusive. If x is > less than -50.0 or more than +50.0 y will likewise be out of range. You can > clip the result: > > y = min(12.0, max(0.0, y)) > > If your x values are integer values (no fractional values) between -50 and > +50 you can use clock arithmetic. Think of a clock marked 0 to 12 (so there > are 13 values), once you reach 12 adding 1 takes you back to 0. > > 0, 13, 26, 39 => 0 > 1, 14, 27, 40 => 1 > 2, 15, 28, 41 => 2 > ... > 12, 25, 38, 51 => 12 > > > Extending that to negative values in the most obvious fashion: > > -1, -14, -27, -40 => 12 > ... > -12, -25, -38, -51 => 1 > -13, -26, -39, -52 => 0 > > > We can do that easily with the % (modulo) operator: > > y = x % y > > > Modulo even works with non-integer values: > > py> 13.5 % 13 > 0.5 > > > > -- > Steven Thanks for this Steven. However, I think it's not correct in this case. Like I said in another message X%12 is working just fine. No matter what the value is. From arsh840 at gmail.com Wed Jul 1 22:52:57 2015 From: arsh840 at gmail.com (Great Avenger Singh) Date: Wed, 1 Jul 2015 19:52:57 -0700 (PDT) Subject: Installing Pybison Message-ID: Hello Everyone, I am installing Pybison from following Source: https://github.com/smvv/pybison After installing all required dependencies I am able to run "sodo python setup.py install" without any errors. I am getting following error while Running "python -c import bison" Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/bison.py", line 23, in from bison_ import ParserEngine ImportError: /usr/local/lib/python2.7/dist-packages/bison_.so: undefined symbol: py_callback From breamoreboy at yahoo.co.uk Thu Jul 2 00:41:31 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 02 Jul 2015 05:41:31 +0100 Subject: "normalizing" a value In-Reply-To: References: Message-ID: On 02/07/2015 01:12, bvdp wrote: > Not sure what this is called (and I'm sure it's not normalize). Perhaps "scaling"? > > Anyway, I need to convert various values ranging from around -50 to 50 to an 0 to 12 range (this is part of a MIDI music program). I have a number of places where I do: > > while x < 0: x += 12 > while x >= 12: x -= 12 > > Okay, that works. Just wondering if there is an easier (or faster) way to accomplish this. > Further to other answers have you tried looking for a library, or even just a recipe, that has already been written and tested that does this for you? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From dieter at handshake.de Thu Jul 2 01:48:20 2015 From: dieter at handshake.de (dieter) Date: Thu, 02 Jul 2015 07:48:20 +0200 Subject: Javascript website scraping using WebKit and Selenium tools References: Message-ID: <87bnfvp0t7.fsf@handshake.de> Veek M writes: > I tried scraping a javascript website using two tools, both didn't work. The > website link is: http://xdguo.taobao.com/category-499399872.htm The relevant > text I'm trying to extract is 'GY-68...': > >
> >
>
> id="4002-6778075404" data-spm-anchor-id="a1z10.5-c.w4002-6778075404.11"> > src="//img.alicdn.com/bao/uploaded/i4/TB1HMt3FFXXXXaFaVXXXXXXXXXX_!!0- > item_pic.jpg_240x240.jpg" alt="GY-68 BMP180 ?? BOSCH?? ??????? ?? > BMP085"> > >
> ... When I try to access the link above, I am redirected to a login page - which, of course, may look very different from what you expect. You may need to pass on authentication information along with your request in order to get the page you are expecting. Note also, that todays sites often heavily use Javascript - which means that a page only gets the final look when the Javascript has been executed. Once the problems to get the "final" HTML code solved, I would use "lxml" and its "xpath" support to locate any relevant HTML information. From dieter at handshake.de Thu Jul 2 01:51:24 2015 From: dieter at handshake.de (dieter) Date: Thu, 02 Jul 2015 07:51:24 +0200 Subject: Installing Pybison References: Message-ID: <877fqjp0o3.fsf@handshake.de> Great Avenger Singh writes: > I am installing Pybison from following Source: > > https://github.com/smvv/pybison > > After installing all required dependencies I am able to run "sodo python setup.py install" without any errors. > > I am getting following error while Running "python -c import bison" > > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python2.7/dist-packages/bison.py", line 23, in > from bison_ import ParserEngine > ImportError: /usr/local/lib/python2.7/dist-packages/bison_.so: undefined symbol: py_callback This likely means that some required external (C-level) library is either missing on your system or cannot be found. Typical approach to resolve an issue of this kind: look for installation instructions, especially instructions telling about external dependencies. Ensure, all dependencies are installed. In case, they are installed in non-standard locations, use "LD_LIBRARY_PATH" to make those installations known. From vek.m1234 at gmail.com Thu Jul 2 02:31:46 2015 From: vek.m1234 at gmail.com (Veek M) Date: Thu, 02 Jul 2015 12:01:46 +0530 Subject: Javascript website scraping using WebKit and Selenium tools References: Message-ID: dieter wrote: > Once the problems to get the "final" HTML code solved, > I would use "lxml" and its "xpath" support to locate any > relevant HTML information. Hello Dieter, yes - you are correct. (though I don't think there's any auth to browse - nice that you actually tried) He's using jsonP and updating his html. I decided to manually mangle it. urllib to download, re to nuke the jsonp(".........stuff i want......") and then lxml. It works and I got the text. Now i need to translate - many thanks. I should have checked first using HTTP Headers to see what he was downloading - i'm an ass. Oh well solved :) From telmo.bacile at gmail.com Thu Jul 2 03:29:30 2015 From: telmo.bacile at gmail.com (telmo bacile) Date: Thu, 2 Jul 2015 00:29:30 -0700 Subject: error with pillow: decoder not avaliable Message-ID: Hi list, im new in this list. Im trying to run a python code that was made originally with pil using pillow, The problem is that i get this error: IOError: decoder jpeg not available Any idea why this code is not working with pillow? import math from PIL import Image imageFile = 'test.jpg' im = Image.open(imageFile) rgbHistogram = im.histogram() print 'Snannon Entropy for Red, Green, Blue:' for rgb in range(3): totalPixels = sum(rgbHistogram[rgb * 256 : (rgb + 1) * 256]) ent = 0.0 for col in range(rgb * 256, (rgb + 1) * 256): freq = float(rgbHistogram[col]) / totalPixels if freq > 0: ent = ent + freq * math.log(freq, 2) ent = -ent print ent From breamoreboy at yahoo.co.uk Thu Jul 2 03:42:44 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 02 Jul 2015 08:42:44 +0100 Subject: error with pillow: decoder not avaliable In-Reply-To: References: Message-ID: On 02/07/2015 08:29, telmo bacile wrote: > Hi list, im new in this list. > Im trying to run a python code that was made originally with pil using pillow, > > The problem is that i get this error: > > IOError: decoder jpeg not available > Any idea why this code is not working with pillow? > > import math > from PIL import Image > imageFile = 'test.jpg' > im = Image.open(imageFile) > rgbHistogram = im.histogram() > print 'Snannon Entropy for Red, Green, Blue:' > for rgb in range(3): > totalPixels = sum(rgbHistogram[rgb * 256 : (rgb + 1) * 256]) > ent = 0.0 > for col in range(rgb * 256, (rgb + 1) * 256): > freq = float(rgbHistogram[col]) / totalPixels > if freq > 0: > ent = ent + freq * math.log(freq, 2) > ent = -ent > print ent > Searching for "python pil ioerror decoder jpeg not available" on google gives 3,930 results of which this is the first http://stackoverflow.com/questions/8915296/python-image-library-fails-with-message-decoder-jpeg-not-available-pil -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From hinaimran.mehr at gmail.com Thu Jul 2 03:44:03 2015 From: hinaimran.mehr at gmail.com (Hina Imran) Date: Thu, 2 Jul 2015 00:44:03 -0700 (PDT) Subject: how to fix TypeError: format requires a mapping In-Reply-To: <96b5ec30-2da2-4b87-ab76-55967fa6d6d3@googlegroups.com> References: <96b5ec30-2da2-4b87-ab76-55967fa6d6d3@googlegroups.com> Message-ID: <70d8719f-9922-43d1-b80b-b570cb583cd5@googlegroups.com> you are right the data is a list of dictionaries. When I try your solution I get an error Traceback (most recent call last): File "data.py", line 45, in col['x'] = row['timestamp'] TypeError: 'OldSample' object has no attribute '__getitem__' On Wednesday, July 1, 2015 at 11:57:39 PM UTC+2, Hina Imran wrote: > I am pulling my hair with this problem right now, > > I have the following Data structure > > [ > I need to make it something like this to put in EON pubnub charting libaray (see link: http://www.pubnub.com/developers/eon/chart/spline/) > > message: { > columns: [ > ["y": 0.043, "x": "2015-06-30T15:53:55"], > ["y": 0.045, "x": "2015-06-30T15:53:55"] > ] > > Now I have the following code > > data = cclient.samples.list(meter_name ='cpu_util', limit=2) > > result_rows = [] > for row in data: > formatted = """["y": %(counter_volume)0.3f, "x": "%(timestamp)s"]""" % (row) > result_rows.append(formatted) > > print(',\n'.join(result_rows)) > > > clean_json(data) From hinaimran.mehr at gmail.com Thu Jul 2 04:37:20 2015 From: hinaimran.mehr at gmail.com (Hina Imran) Date: Thu, 2 Jul 2015 01:37:20 -0700 (PDT) Subject: TypeError: 'OldSample' object has no attribute '__getitem__' Message-ID: <0e0006e1-1b68-42fb-96b6-c7e06694b46e@googlegroups.com> The data set looks something like this, The data is from openstack ceilometer python API [ ] My code looks something like this auth=v2.Password(auth_url="http://", username="user", password="pass", tenant_id='id') # Pubnub instance initilize sess = session.Session(auth=auth,verify=False) # token = auth.get_token(sess) cclient = client.get_client(2, ceilometer_url="http:", token=token,verify=False) data = cclient.samples.list(meter_name ='cpu_util') thing = {} msg = {} cols = [] def __unicode__(self): return unicode(self.data) for row in data: col = {} col['x'] = row['timestamp'] col['y'] = row['counter_volume'] cols.append(col) msg['columns'] = cols thing['message'] = msg print thing print json.dumps(thing) My intended out out something like this message: { columns: [ ["x": 123, "y": "456"], ["y": 0.045, "x": "2015-06-30T15:53:55"] ] **here x is counter_volume and Y is timestamp** I need the output in this way because I want to plug this data into EON pubnub Charting Library. Problem is that no matter what I do it keeps on throwing me errors.I guess I need to learn some more how to manipulate list of dictionaries. From floorent1993 at gmail.com Thu Jul 2 05:10:20 2015 From: floorent1993 at gmail.com (Florent Quesselaire) Date: Thu, 2 Jul 2015 11:10:20 +0200 Subject: Pylint bug in python35 b2 Message-ID: i installed python35 b2 and tested to pip install / easy install pylint plgin but i got an : AttributeError : 'Call' object has no attribute "starargs". i feel this error more python side than pylint side because it is the same version who works fine in 3.4.3 The exe installer is amazing. thanks. Regards, Florent Quesselaire -------------- next part -------------- An HTML attachment was scrubbed... URL: From vek.m1234 at gmail.com Thu Jul 2 05:14:19 2015 From: vek.m1234 at gmail.com (Veek M) Date: Thu, 02 Jul 2015 14:44:19 +0530 Subject: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop? Message-ID: I travel to 'item-name', how do i quickly travel to c-price and then print both values of text. I tried: for anchor in element.xpath('//a[@class="item-name"]'): #Travel to item-name but when i getparent and then call xpath I get a whole bunch of span elements as a list - why? Shouldn't xpath start it's traversal from the current element (parent to 'a') and go downwards. Also why aren't contents of span text? print shows them to be Elements so.. cprice.text should work.. elements text [, , , , , , , , , , , , , , , , , , , , , , , ] Traceback (most recent call last): File "fooxxx.py", line 47, in text = anchor.text + " " + cprice.text + "\n" AttributeError: 'list' object has no attribute 'text' deathstar>
\u675c\u90a6\u7ebf/\u5f69\u6392\u7ebf/40P-40p/\u53cc\u5934/\u516c\u5bf9\u516c/1P-1P/\u957f10CM/10\u5398\u7c73 \u6279\u53d1
? 2.35
import sys, re import codecs import requests from lxml import html from lxml import etree url = 'http://xdguo.taobao.com/i/asynSearch.htm?_ksTS=1435804975003_695&callback=jsonp696&mid=w-6778075404-0&wid=6778075404&path=/&pageNo=' user_agent = ('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) ' 'Gecko/20111108 Iceweasel/3.5.16 (like Firefox/3.5.16)') def get_page(s, url): print(url) r = s.get(url, headers = { 'User-Agent' : user_agent, 'Keep-Alive' : '3600', 'Connection' : 'keep-alive', }) s.encoding='gbk' text = r.text return text # Open output file fh=codecs.open('/tmp/out', 'wb') # Download s = requests.Session() contents = get_page(s, url + str(1)) # Extract frag frag = re.findall('jsonp[0-9]+\("(.+?)"\)', contents, re.S)[0] element = html.fromstring(frag) # Clean frag frag = re.sub(r'\\', '', frag) print frag # Get a element and parse frag element = html.fromstring(frag) # Extract text from frag for anchor in element.xpath('//a[@class="item-name"]'): #Travel to a tag parent = anchor.getparent() # go one up print(type(parent)) cprice = parent.xpath('//span[@class="c-price"]') # This acts weird! print(cprice) text = anchor.text + " " + cprice.text + "\n" fh.write(text.encode('gbk')) # Close output and exit fh.close() sys.exit() From __peter__ at web.de Thu Jul 2 05:25:23 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 02 Jul 2015 11:25:23 +0200 Subject: TypeError: 'OldSample' object has no attribute '__getitem__' References: <0e0006e1-1b68-42fb-96b6-c7e06694b46e@googlegroups.com> Message-ID: Hina Imran wrote: > The data set looks something like this, The data is from openstack > ceilometer python API > > [ > { > counter_name': cpu_util', > user_id': 7b', > resource_id': ef', > timestamp': 2015-07-02T08:13:55', > counter_volume': 0.774, > resource_metadata': > { > ramdisk_id': None', > flavor.vcpus': 1', > OS-EXT-AZ.availability_zone': nova', > display_name': ubuntu-io', > flavor.id': 596642d8-', > status': active', ephemeral_gb': 0', > flavor.name': m1.small.io', > disk_gb': 20', > kernel_id': None', > image.id': 5776a360-', > flavor.ram': 2048', > host': host', > flavor.ephemeral': 0', > image.name': ubuntu-io', > image_ref_url': http://b8dc', > image.links': > [ > { > 'href': 'http://19', > 'rel': 'bookmark' > } > ]", > cpu_number': 1', > flavor.disk': 20', > root_gb': 20', > name': > instance-000000d3', > memory_mb': 2048', > instance_type': > 596642d', vcpus': 1', > image_ref': 5776a36', > flavor.links': > [ > { > 'href': > 'http://192.168.26.1', > 'rel': 'bookmark' } > ]" > }, > source': openstack', > counter_unit': %', > recorded_at': > 2015-07-02T08:13:55.485000', > project_id': 1670f', > message_id': 4849', > 4counter_type': gauge' > }>] > > My code looks something like this > > > > auth=v2.Password(auth_url="http://", username="user", password="pass", > tenant_id='id') > > # Pubnub instance initilize > > > > sess = session.Session(auth=auth,verify=False) # > token = auth.get_token(sess) > > cclient = client.get_client(2, ceilometer_url="http:", > token=token,verify=False) > > > data = cclient.samples.list(meter_name ='cpu_util') > > > thing = {} > msg = {} > cols = [] > > def __unicode__(self): > return unicode(self.data) > > for row in data: > col = {} > col['x'] = row['timestamp'] > col['y'] = row['counter_volume'] > cols.append(col) > > > > msg['columns'] = cols > > thing['message'] = msg > > print thing > > print json.dumps(thing) > > My intended out out something like this > > message: { > columns: [ > ["x": 123, "y": "456"], > ["y": 0.045, "x": "2015-06-30T15:53:55"] > ] > **here x is counter_volume and Y is timestamp** > I need the output in this way because I want to plug this data into EON > pubnub Charting Library. Problem is that no matter what I do it keeps on > throwing me errors.I guess I need to learn some more how to manipulate > list of dictionaries. The problem is that you are not working with a dict, data seems to be a sequence of OldSample instances. Try changing > col = {} > col['x'] = row['timestamp'] > col['y'] = row['counter_volume'] to col = {} col['x'] = row.timestamp col['y'] = row.counter_volume If that works you can simplify it to col = {"x": row.timestamp, "y": row.counter_volume} From vek.m1234 at gmail.com Thu Jul 2 05:34:25 2015 From: vek.m1234 at gmail.com (Veek M) Date: Thu, 02 Jul 2015 15:04:25 +0530 Subject: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop? References: Message-ID: never mind fixed.. it's returning a list so whatever[0].text and relative-path for the xpath From ahlusar.ahluwalia at gmail.com Thu Jul 2 06:50:54 2015 From: ahlusar.ahluwalia at gmail.com (Saran Ahluwalia) Date: Thu, 2 Jul 2015 06:50:54 -0400 Subject: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop? In-Reply-To: References: Message-ID: <6EFD3762-D42A-46C4-9F87-EA8B51D1C334@gmail.com> So what did you do to resolve this? Please provide your fix. This is an excellent case study for others. Sent from my iPhone > On Jul 2, 2015, at 5:34 AM, Veek M wrote: > > never mind fixed.. > > it's returning a list so whatever[0].text and relative-path for the xpath > > > > > -- > https://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Thu Jul 2 10:07:05 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 02 Jul 2015 16:07:05 +0200 Subject: Pylint bug in python35 b2 References: Message-ID: Florent Quesselaire wrote: > i installed python35 b2 > and tested to pip install / easy install pylint plgin > but i got an : > > AttributeError : 'Call' object has no attribute "starargs". > > i feel this error more python side than pylint side because it is the same > version who works fine in 3.4.3 That looks like a change in the ast that breaks backwards compatibility rather than a bug: $ python3.4 Python 3.4.0 (default, Jun 19 2015, 14:20:21) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ast >>> module = ast.parse("f(*x)") >>> module.body[0].value <_ast.Call object at 0x7f082ce07860> >>> _.starargs <_ast.Name object at 0x7f082cd8c240> >>> _.id 'x' >>> $ python3.5 Python 3.5.0b2+ (3.5:9aee273bf8b7+, Jun 25 2015, 09:25:29) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ast >>> module = ast.parse("f(*x)") >>> call = module.body[0].value >>> call.starargs Traceback (most recent call last): File "", line 1, in AttributeError: 'Call' object has no attribute 'starargs' >>> call.args [<_ast.Starred object at 0x7f6e633cb208>] >>> call.args[0].value.id 'x' pylint likely needs an update to support 3.5 anyway as there is some new syntax. From steve at pearwood.info Thu Jul 2 10:52:55 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 03 Jul 2015 00:52:55 +1000 Subject: Bug in floating point multiplication Message-ID: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Despite the title, this is not one of the usual "Why can't Python do maths?" "bug" reports. Can anyone reproduce this behaviour? If so, please reply with the version of Python and your operating system. Printing sys.version will probably do. x = 1 - 1/2**53 assert x == 0.9999999999999999 for i in range(1, 1000000): if int(i*x) == i: print(i); break Using Jython and IronPython, the loop runs to completion. That is the correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and 3.3 on Centos and Debian, it prints 2049 and breaks. That should not happen. If you can reproduce that (for any value of i, not necessarily 2049), please reply. See also http://bugs.python.org/issue24546 for more details. -- Steven From skip.montanaro at gmail.com Thu Jul 2 11:05:42 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 2 Jul 2015 10:05:42 -0500 Subject: "normalizing" a value In-Reply-To: References: Message-ID: This looks like a straightforward linear transformation issue to me (like Fahrenheit to Celsius). Add 50 to all input values, giving you values in the range 0 to 100. Then scale them into your 0 to 12 range by multiplying them by 12/100: >>> for n in range(-50, 50, 3): ... print n, n + 50, (n + 50) * 12 / 100 ... -50 0 0.0 -47 3 0.36 -44 6 0.72 -41 9 1.08 -38 12 1.44 ... 34 84 10.08 37 87 10.44 40 90 10.8 43 93 11.16 46 96 11.52 49 99 11.88 Did I misread your request in some way? Skip From michael.poeltl at univie.ac.at Thu Jul 2 11:10:50 2015 From: michael.poeltl at univie.ac.at (Michael Poeltl) Date: Thu, 2 Jul 2015 17:10:50 +0200 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20150702151050.GN6546@horus> hi Steven, I'm running python-3.4.2 on a linuxmint16 box and CANNOT reproduce it is just that int(i*x) == i is never True! hope that helps regards Michael * Steven D'Aprano [2015-07-02 16:56]: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > > > Using Jython and IronPython, the loop runs to completion. That is the > correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and > 3.3 on Centos and Debian, it prints 2049 and breaks. That should not > happen. If you can reproduce that (for any value of i, not necessarily > 2049), please reply. > > See also http://bugs.python.org/issue24546 for more details. > > > > -- > Steven > > -- > https://mail.python.org/mailman/listinfo/python-list -- Michael Poeltl Computational Materials Physics at University Wien, Sensengasse 8/12, A-1090 Wien, AUSTRIA http://cmp.univie.ac.at/ http://homepage.univie.ac.at/michael.poeltl/ using elinks-0.12, mutt-1.5.21, and vim-7.3, with python-3.4.2, on linux mint 16 (petra) :-) fon: +43-1-4277-51409 "Lehrend lernen wir!" From toddrjen at gmail.com Thu Jul 2 11:13:31 2015 From: toddrjen at gmail.com (Todd) Date: Thu, 2 Jul 2015 17:13:31 +0200 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: The loop runs to completion for me on openSUSE Tumbleweed and both Python 2.7 64bits and Python 3.4 64bits. On Thu, Jul 2, 2015 at 4:52 PM, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version > of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > > > Using Jython and IronPython, the loop runs to completion. That is the > correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and > 3.3 on Centos and Debian, it prints 2049 and breaks. That should not > happen. If you can reproduce that (for any value of i, not necessarily > 2049), please reply. > > See also http://bugs.python.org/issue24546 for more details. > > > > -- > Steven > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent.vande.vyvre at telenet.be Thu Jul 2 11:15:04 2015 From: vincent.vande.vyvre at telenet.be (Vincent Vande Vyvre) Date: Thu, 02 Jul 2015 17:15:04 +0200 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55955578.5000501@telenet.be> Le 02/07/2015 16:52, Steven D'Aprano a ?crit : > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > > > Using Jython and IronPython, the loop runs to completion. That is the > correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and > 3.3 on Centos and Debian, it prints 2049 and breaks. That should not > happen. If you can reproduce that (for any value of i, not necessarily > 2049), please reply. > > See also http://bugs.python.org/issue24546 for more details. > > > Hi, vincent at tiemoko:~$ python3 Python 3.2.3 (default, Jun 18 2015, 21:46:42) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i) ... break ... 2049 >>> ------------------------------------------------------------------------------- vincent at djoliba:~$ python3 Python 3.4.0 (default, Jun 19 2015, 14:20:21) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i) ... break ... >>> Both on Ubuntu. Vincent From rosuav at gmail.com Thu Jul 2 11:21:10 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Jul 2015 01:21:10 +1000 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Jul 3, 2015 at 12:52 AM, Steven D'Aprano wrote: > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > I suspect for Py2 you need to say 1/2.0, or insist on a future directive. Otherwise the assertion fails, x is simply 1, and the loop instantly halts, none of which is buggy behaviour. Testing on a 64-bit Debian Jessie, these all run to completion: Python 3.6.0a0 (default:5c901b39c6b7, Jun 28 2015, 09:13:39) Python 3.5.0b1+ (default:7255af1a1c50+, May 26 2015, 00:39:06) Python 3.4.2 (default, Oct 8 2014, 10:45:20) Python 2.7.9 (default, Mar 1 2015, 12:57:24) Testing on a 32-bit Debian Jessie, these all print 2049 and stop: Python 3.4.2 (default, Oct 8 2014, 13:14:40) Python 3.3.3 (default, Dec 31 2013, 19:11:08) Python 2.7.9 (default, Mar 1 2015, 18:22:53) Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) (2.6.6 isn't actually supported on Jessie, it just happens to be laying around.) On 32-bit AntiX, these both print 2049 and stop: Python 3.4.3+ (default, Jun 2 2015, 14:09:35) Python 2.7.10 (default, Jun 1 2015, 16:21:46) Looks like it's an issue with 32-bit builds only. And not on Windows - I spun up a Win 7 VM and tested it to completion: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32 Over-eager optimization somewhere? ChrisA From robin at reportlab.com Thu Jul 2 11:24:29 2015 From: robin at reportlab.com (Robin Becker) Date: Thu, 02 Jul 2015 16:24:29 +0100 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559557AD.10500@chamonix.reportlab.co.uk> On 02/07/2015 15:52, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 ... as stated the above fails since it produces x==1L for python 2.7 (Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.) If I convert old style x = 1.0 - 1.0/2**53 then the assertion succeeds and the loop does not print. -- Robin Becker From robin at reportlab.com Thu Jul 2 11:24:29 2015 From: robin at reportlab.com (Robin Becker) Date: Thu, 02 Jul 2015 16:24:29 +0100 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559557AD.10500@chamonix.reportlab.co.uk> On 02/07/2015 15:52, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 ... as stated the above fails since it produces x==1L for python 2.7 (Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.) If I convert old style x = 1.0 - 1.0/2**53 then the assertion succeeds and the loop does not print. -- Robin Becker From no.email at nospam.invalid Thu Jul 2 11:26:06 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 02 Jul 2015 08:26:06 -0700 Subject: Bug in floating point multiplication References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87a8vepomp.fsf@nightsong.com> Steven D'Aprano writes: > x = 1 - 1/2**53 > assert x == 0.9999999999999999 In Python 2.x I don't see how that assert can possibly succeed, since x is the integer 1. But I tested it anyway on 2.7.5 under Fedora 19 and it threw an assertion error. I changed it to say 1 - 1/2.0**53 and then the loop runs to completion. sys.version is: 2.7.5 (default, Nov 3 2014, 14:33:39) \n[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] From ian.g.kelly at gmail.com Thu Jul 2 11:28:42 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 2 Jul 2015 09:28:42 -0600 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: On my Chromebook, using Python 2.7.6 from the Ubuntu Trusty distribution, I get AssertionError, and x == 1. In Python 3.4.0 on the same system, the code runs to completion. Both Pythons appear to be 64-bit builds. On my Mint 17.1 desktop (which should be using the same packages), I get the same results. On Thu, Jul 2, 2015 at 8:52 AM, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > > > Using Jython and IronPython, the loop runs to completion. That is the > correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and > 3.3 on Centos and Debian, it prints 2049 and breaks. That should not > happen. If you can reproduce that (for any value of i, not necessarily > 2049), please reply. > > See also http://bugs.python.org/issue24546 for more details. > > > > -- > Steven > > -- > https://mail.python.org/mailman/listinfo/python-list From robin at reportlab.com Thu Jul 2 11:29:40 2015 From: robin at reportlab.com (Robin Becker) Date: Thu, 02 Jul 2015 16:29:40 +0100 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559558E4.3040407@chamonix.reportlab.co.uk> $ uname -a Linux everest 4.0.6-1-ARCH #1 SMP PREEMPT Tue Jun 23 14:40:31 CEST 2015 i686 GNU/Linux robin at everest:~ $ python2 Python 2.7.10 (default, May 26 2015, 04:28:58) [GCC 5.1.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = 1.0 - 1.0/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i); break ... 2049 >>> robin at everest:~ $ python Python 3.4.3 (default, Mar 26 2015, 07:36:01) [GCC 4.9.2 20150304 (prerelease)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> KeyboardInterrupt >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): File "", line 1 for i in range(1, 1000000): ^ IndentationError: unexpected indent >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i); break ... 2049 >>> robin at everest:~/devel/filps -- Robin Becker From robin at reportlab.com Thu Jul 2 11:29:40 2015 From: robin at reportlab.com (Robin Becker) Date: Thu, 02 Jul 2015 16:29:40 +0100 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559558E4.3040407@chamonix.reportlab.co.uk> $ uname -a Linux everest 4.0.6-1-ARCH #1 SMP PREEMPT Tue Jun 23 14:40:31 CEST 2015 i686 GNU/Linux robin at everest:~ $ python2 Python 2.7.10 (default, May 26 2015, 04:28:58) [GCC 5.1.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = 1.0 - 1.0/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i); break ... 2049 >>> robin at everest:~ $ python Python 3.4.3 (default, Mar 26 2015, 07:36:01) [GCC 4.9.2 20150304 (prerelease)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> KeyboardInterrupt >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): File "", line 1 for i in range(1, 1000000): ^ IndentationError: unexpected indent >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i); break ... 2049 >>> robin at everest:~/devel/filps -- Robin Becker From ian.g.kelly at gmail.com Thu Jul 2 11:32:43 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 2 Jul 2015 09:32:43 -0600 Subject: Bug in floating point multiplication In-Reply-To: References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Jul 2, 2015 at 9:28 AM, Ian Kelly wrote: > On my Chromebook, using Python 2.7.6 from the Ubuntu Trusty > distribution, I get AssertionError, and x == 1. > > In Python 3.4.0 on the same system, the code runs to completion. Both > Pythons appear to be 64-bit builds. > > On my Mint 17.1 desktop (which should be using the same packages), I > get the same results. Apologies for the accidental top-posting. Also, the full sys.version string for the 2.7.6 Python is: 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] From rosuav at gmail.com Thu Jul 2 11:34:55 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Jul 2015 01:34:55 +1000 Subject: Bug in floating point multiplication In-Reply-To: <87a8vepomp.fsf@nightsong.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> <87a8vepomp.fsf@nightsong.com> Message-ID: On Fri, Jul 3, 2015 at 1:26 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> x = 1 - 1/2**53 >> assert x == 0.9999999999999999 > > In Python 2.x I don't see how that assert can possibly succeed, since > x is the integer 1. But I tested it anyway on 2.7.5 under Fedora 19 > and it threw an assertion error. >From previous discussions I happen to know that Steven normally runs everything with "from __future__ import division" active (and possibly others? not sure), so just assume he means to work with floats here. Steven, I think this is one of the downsides of using future directives by default - you forget that your code can't always be copied and pasted to other people :) ChrisA From ian.g.kelly at gmail.com Thu Jul 2 11:38:03 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 2 Jul 2015 09:38:03 -0600 Subject: Bug in floating point multiplication In-Reply-To: <87a8vepomp.fsf@nightsong.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> <87a8vepomp.fsf@nightsong.com> Message-ID: On Thu, Jul 2, 2015 at 9:26 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> x = 1 - 1/2**53 >> assert x == 0.9999999999999999 > > In Python 2.x I don't see how that assert can possibly succeed, since > x is the integer 1. But I tested it anyway on 2.7.5 under Fedora 19 > and it threw an assertion error. Oh, duh. That was the problem on my 2.7.6 test as well. I added from __future__ import division, and now it runs to completion. From steve at pearwood.info Thu Jul 2 11:41:51 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 03 Jul 2015 01:41:51 +1000 Subject: Bug in floating point multiplication References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> <87a8vepomp.fsf@nightsong.com> Message-ID: <55955bbe$0$1646$c3e8da3$5496439d@news.astraweb.com> On Fri, 3 Jul 2015 01:34 am, Chris Angelico wrote: > From previous discussions I happen to know that Steven normally runs > everything with "from __future__ import division" active (and possibly > others? not sure), so just assume he means to work with floats here. > Steven, I think this is one of the downsides of using future > directives by default - you forget that your code can't always be > copied and pasted to other people :) /me hangs his head in shame Yes, you've diagnosed the problem correctly. Sorry for the confusion. -- Steven From steve at pearwood.info Thu Jul 2 11:42:16 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 03 Jul 2015 01:42:16 +1000 Subject: Bug in floating point multiplication References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55955bd7$0$1646$c3e8da3$5496439d@news.astraweb.com> On Fri, 3 Jul 2015 12:52 am, Steven D'Aprano wrote: > x = 1 - 1/2**53 Ooops, sorry I forgot that I had already run "from __future__ import division". Otherwise that line needs to be: x = 1 - 1.0/2**53 -- Steven From toddrjen at gmail.com Thu Jul 2 11:45:28 2015 From: toddrjen at gmail.com (Todd) Date: Thu, 2 Jul 2015 17:45:28 +0200 Subject: Bug in floating point multiplication In-Reply-To: <559558E4.3040407@chamonix.reportlab.co.uk> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> <559558E4.3040407@chamonix.reportlab.co.uk> Message-ID: On Thu, Jul 2, 2015 at 5:29 PM, Robin Becker wrote: > > > $ uname -a > Linux everest 4.0.6-1-ARCH #1 SMP PREEMPT Tue Jun 23 14:40:31 CEST 2015 > i686 GNU/Linux > I am wondering if this is a 32bit vs. 64bit thing. Has anyone gotten this problem to work on a 64bit python? -------------- next part -------------- An HTML attachment was scrubbed... URL: From buzzard at invalid.invalid Thu Jul 2 12:08:25 2015 From: buzzard at invalid.invalid (duncan smith) Date: Thu, 02 Jul 2015 17:08:25 +0100 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559561fd$0$16022$862e30e2@ngroups.net> On 02/07/15 15:52, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > > > Using Jython and IronPython, the loop runs to completion. That is the > correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and > 3.3 on Centos and Debian, it prints 2049 and breaks. That should not > happen. If you can reproduce that (for any value of i, not necessarily > 2049), please reply. > > See also http://bugs.python.org/issue24546 for more details. > > > Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "copyright", "credits" or "license()" for more information. >>> from __future__ import division >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): if int(i*x) == i: print(i); break >>> Python 3.4.0 (default, Jun 19 2015, 14:20:21) [GCC 4.8.2] on linux Type "copyright", "credits" or "license()" for more information. >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): if int(i*x) == i: print(i); break >>> Ubuntu 14.04 Duncan From python at mrabarnett.plus.com Thu Jul 2 12:20:27 2015 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 02 Jul 2015 17:20:27 +0100 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559564CB.5090200@mrabarnett.plus.com> On 2015-07-02 15:52, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > > > Using Jython and IronPython, the loop runs to completion. That is the > correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and > 3.3 on Centos and Debian, it prints 2049 and breaks. That should not > happen. If you can reproduce that (for any value of i, not necessarily > 2049), please reply. > > See also http://bugs.python.org/issue24546 for more details. > These are all on Windows 8.1 with CPython from www.python.org. With "x = 1 - 1.0/2**53" (needed for Python 2.x) they all passed. 2.5.4 (r254:67916, Dec 23 2008, 15:19:34) [MSC v.1400 64 bit (AMD64)] 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] 2.7.7 (default, Jun 1 2014, 14:21:57) [MSC v.1500 64 bit (AMD64)] 2.7.7 (default, Jun 1 2014, 14:17:13) [MSC v.1500 32 bit (Intel)] 3.1.4 (default, Jun 12 2011, 14:16:16) [MSC v.1500 64 bit (AMD64)] 3.1.4 (default, Jun 12 2011, 15:05:44) [MSC v.1500 32 bit (Intel)] 3.2.5 (default, May 15 2013, 23:07:10) [MSC v.1500 64 bit (AMD64)] 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:35:05) [MSC v.1600 64 bit (AMD64)] 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] 3.5.0b2 (v3.5.0b2:7a088af5615b, May 31 2015, 06:22:19) [MSC v.1900 64 bit (AMD64)] 3.5.0b2 (v3.5.0b2:7a088af5615b, May 31 2015, 06:08:44) [MSC v.1900 32 bit (Intel)] From vek.m1234 at gmail.com Thu Jul 2 12:22:56 2015 From: vek.m1234 at gmail.com (Veek M) Date: Thu, 02 Jul 2015 21:52:56 +0530 Subject: requests.Session() how do you set 'replace' on the encoding? Message-ID: I'm getting a Unicode error: Traceback (most recent call last): File "fooxxx.py", line 56, in parent = anchor.getparent() UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in position 8: illegal multibyte sequence I'm doing: s = requests.Session() to suck data in, so.. how do i 'replace' chars that fit gbk From breamoreboy at yahoo.co.uk Thu Jul 2 12:40:19 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 02 Jul 2015 17:40:19 +0100 Subject: Pylint bug in python35 b2 In-Reply-To: References: Message-ID: On 02/07/2015 15:07, Peter Otten wrote: > Florent Quesselaire wrote: > >> i installed python35 b2 >> and tested to pip install / easy install pylint plgin >> but i got an : >> >> AttributeError : 'Call' object has no attribute "starargs". >> >> i feel this error more python side than pylint side because it is the same >> version who works fine in 3.4.3 > > That looks like a change in the ast that breaks backwards compatibility > rather than a bug: > Hardly surprising as there are no guarantees. From https://docs.python.org/3/library/ast.html "The abstract syntax itself might change with each Python release; this module helps to find out programmatically what the current grammar looks like." -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From python.list at tim.thechases.com Thu Jul 2 12:59:49 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 2 Jul 2015 11:59:49 -0500 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20150702115949.1729213b@bigbox.christie.dr> On 2015-07-03 00:52, Steven D'Aprano wrote: > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break tkc at debian:~$ python Python 2.7.9 (default, Mar 1 2015, 12:57:24) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 Traceback (most recent call last): File "", line 1, in AssertionError >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i); break ... 1 >>> x 1 >>> ^D tkc at debian:~$ python3 Python 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i); break ... >>> ^D tkc at debian:~$ uname -a Linux bigbox 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt9-3~deb8u1 (2015-04-24) x86_64 GNU/Linux Weird that on 2.7, the assert fails. -tkc From bob at mellowood.ca Thu Jul 2 13:03:41 2015 From: bob at mellowood.ca (bvdp) Date: Thu, 2 Jul 2015 10:03:41 -0700 (PDT) Subject: "normalizing" a value In-Reply-To: References: <948e2800-e52b-429a-9e00-f268fcff5085@googlegroups.com> Message-ID: <4c0721c0-b5f5-4e0d-9db4-822f838f3708@googlegroups.com> On Wednesday, July 1, 2015 at 8:37:18 PM UTC-7, Dennis Lee Bieber wrote: > On Wed, 1 Jul 2015 18:49:34 -0700 (PDT), bvdp declaimed > the following: > > > > >Thanks guys. Yes, that is exactly what I want. I have a number of places where a MIDI note value is being generated. MIDI should be 0..127, but the process creates notes outside the range. Guess that's another question: if the value I have is <0 or >127 I add/subtract 12 'til it's in range. Don't see using modulo working on this??? > > > >As far as the original question: Yes, that's what I need. At times I need to take a note (say 14) and map it into a single octave range. So, the 12 becomes 2. Both 14 and 2 are numeric values for note "d", just an octave apart. > > > > Modulo will give you the "note", but throws out the octave. > > Your original post specified -50..50, which spans only 101 values, whereas > MIDI spans 128 values -- so what do you really consider out of range? And > what MIDI value is -50 supposed to map against. Is input 0 supposed to > represent middle-C with negative values being notes on the bass clef and > positive values being treble clef? > > MIDI middle-C is note 60. Presuming your 0 is supposed to be middle-C, I'd > do the transformation as: > > midiNote = invalue + 60 > if midiNote < 0: midiNote = midiNote % 12 > if midiNote > 127: midiNote = (midiNote % 12) + 115 > > which actually means input values of -60..+67 are shifted directly to a > midi note number, and values outside of that range are shadowed as the > lowest or highest octave. > > >>> for i in range(-70, 80, 4): > ... midiNote = i + 60 > ... if midiNote < 0: midiNote = midiNote % 12 > ... if midiNote > 127: midiNote = ((midiNote - 5) % 12) + 113 > ... print i, midiNote, "CcDdEFfGgAaB"[midiNote % 12], divmod(midiNote, > 12) > ... > -70 2 D (0, 2) > -66 6 f (0, 6) > -62 10 a (0, 10) > -58 2 D (0, 2) > -54 6 f (0, 6) > -50 10 a (0, 10) > -46 14 D (1, 2) > -42 18 f (1, 6) > -38 22 a (1, 10) > -34 26 D (2, 2) > -30 30 f (2, 6) > -26 34 a (2, 10) > -22 38 D (3, 2) > -18 42 f (3, 6) > -14 46 a (3, 10) > -10 50 D (4, 2) > -6 54 f (4, 6) > -2 58 a (4, 10) > 2 62 D (5, 2) > 6 66 f (5, 6) > 10 70 a (5, 10) > 14 74 D (6, 2) > 18 78 f (6, 6) > 22 82 a (6, 10) > 26 86 D (7, 2) > 30 90 f (7, 6) > 34 94 a (7, 10) > 38 98 D (8, 2) > 42 102 f (8, 6) > 46 106 a (8, 10) > 50 110 D (9, 2) > 54 114 f (9, 6) > 58 118 a (9, 10) > 62 122 D (10, 2) > 66 126 f (10, 6) > 70 118 a (9, 10) > 74 122 D (10, 2) > 78 114 f (9, 6) > >>> > > The oddity for the >127 case is that 127 is not an even octave break point. > divmod() gives you the "octave" and the note. > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ Thanks. I like your solution for values <0 >127. Makes more sense than mindlessly adding/subtracting 12 to bring into range. In this case I'm just trying to take an out-of-range note to the top/bottom of the valid midi range. From jason.swails at gmail.com Thu Jul 2 13:29:35 2015 From: jason.swails at gmail.com (Jason Swails) Date: Thu, 2 Jul 2015 13:29:35 -0400 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Jul 2, 2015 at 10:52 AM, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version > of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > > > Using Jython and IronPython, the loop runs to completion. That is the > correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and > 3.3 on Centos and Debian, it prints 2049 and breaks. That should not > happen. If you can reproduce that (for any value of i, not necessarily > 2049), please reply. > ? As others have suggested, this is almost certainly a 32-bit vs. 64-bit issue. Consider the following C program: // maths.h #include #include int main() { double x; int i; x = 1-pow(0.5, 53); for (i = 1; i < 1000000; i++) { if ((int)(i*x) == i) { printf("%d\n", i); break; } } return 0; } For the most part, this should be as close to an exact transliteration of your Python code as possible. Here's what I get when I try compiling and running it on my 64-bit (Gentoo) Linux machine with 32-bit compatible libs: swails at batman ~/test $ gcc maths.c swails at batman ~/test $ ./a.out swails at batman ~/test $ gcc -m32 maths.c swails at batman ~/test $ ./a.out 2049 That this happens at the C level in 32-bit mode is highly suggestive, I think, since I believe these are the actual machine ops that CPython float maths execute under the hood. All the best, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From irmen.NOSPAM at xs4all.nl Thu Jul 2 13:49:49 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Thu, 02 Jul 2015 19:49:49 +0200 Subject: Bug in floating point multiplication In-Reply-To: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559579bb$0$2921$e4fe514c@news.xs4all.nl> On 2-7-2015 16:52, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0.9999999999999999 > for i in range(1, 1000000): > if int(i*x) == i: > print(i); break I can't reproduce it with any of the pythons I have here, they all run to completion: Tested on Mac OSX 10.10.4, with a 64-bit core2duo processor. Below are all 64-bit python implementations: 2.6.9 (apple supplied), 2.7.6 (apple supplied), 3.4.3 (homebrew), and pypy-2.6.0 (homebrew). I don't have any 32 bit Python implementations on the mac. Tested on windows 7, with a 64-bit core2quad processor, but using 32-bit python implementations from python.org: 2.7.9, 3.3.3, 3.4.2, and pypy-2.5.1. Irmen de Jong From zljubisic at gmail.com Thu Jul 2 16:27:24 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Thu, 2 Jul 2015 13:27:24 -0700 (PDT) Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> Message-ID: This is my final version which doesn't work. :( Actually, it works with another file on another server, but doesn't work with mp4 files on this particular server. I really don't know what to do? Regards. import os import urllib.request def Download(rfile, lfile): retval = False if os.path.isfile(lfile): lsize = os.stat(lfile).st_size else: lsize = 0 req = urllib.request.Request(rfile) rfsize = urllib.request.urlopen(req).length req.add_header('Range', "bytes={}-".format(lsize)) response = urllib.request.urlopen(req) with open(lfile, 'ab') as out_file: while True: try: chunk = response.read(64 * 1024) # chunk = response.read(128) if not chunk: break out_file.write(chunk) out_file.flush() lfsize = os.stat(lfile).st_size print("{0:.2f}".format(lfsize / rfsize * 100)) except ConnectionResetError as e: print('Exception ConnectionResetError {0}'.format(os.stat(lfile).st_size)) response = urllib.request.urlopen(req) if lfsize == rfsize: retval = True return retval while not Download('http://video.hrt.hr/2906/otv296.mp4', 'otv296.mp4'): print('1') From laurent.pointal at free.fr Thu Jul 2 17:12:32 2015 From: laurent.pointal at free.fr (Laurent Pointal) Date: Thu, 02 Jul 2015 23:12:32 +0200 Subject: Bug in floating point multiplication References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5595a940$0$3070$426a74cc@news.free.fr> Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version > of Python and your operating system. Printing sys.version will probably > do. On Kubuntu 15.04, it works. Python 3.4.3 (default, Mar 26 2015, 22:03:40) [GCC 4.9.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> x = 1 - 1/2**53 >>> assert x == 0.9999999999999999 >>> for i in range(1, 1000000): ... if int(i*x) == i: ... print(i); break ... >>> A+ Laurent. From irmen.NOSPAM at xs4all.nl Thu Jul 2 17:31:09 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Thu, 02 Jul 2015 23:31:09 +0200 Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> Message-ID: <5595ad9b$0$2917$e4fe514c@news.xs4all.nl> On 2-7-2015 22:27, zljubisic at gmail.com wrote: > This is my final version which doesn't work. :( > Actually, it works with another file on another server, but doesn't work with mp4 files on this particular server. > > I really don't know what to do? Do you really need to download these files using Python? Why not use a tool such as curl or wget: $ wget --continue http://video.hrt.hr/2906/otv296.mp4 will download it and you'll be able to resume a partial download with that command as well. Irmen From python at mrabarnett.plus.com Thu Jul 2 18:07:39 2015 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 02 Jul 2015 23:07:39 +0100 Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> Message-ID: <5595B62B.4050402@mrabarnett.plus.com> On 2015-07-02 21:27, zljubisic at gmail.com wrote: > This is my final version which doesn't work. :( > Actually, it works with another file on another server, but doesn't work with mp4 files on this particular server. > > I really don't know what to do? > > Regards. > > import os > import urllib.request > > def Download(rfile, lfile): > > retval = False > > if os.path.isfile(lfile): > lsize = os.stat(lfile).st_size > else: > lsize = 0 > > req = urllib.request.Request(rfile) > > rfsize = urllib.request.urlopen(req).length > > req.add_header('Range', "bytes={}-".format(lsize)) > > response = urllib.request.urlopen(req) > > with open(lfile, 'ab') as out_file: > while True: > try: > chunk = response.read(64 * 1024) > # chunk = response.read(128) > if not chunk: break > out_file.write(chunk) > out_file.flush() > > > lfsize = os.stat(lfile).st_size > > print("{0:.2f}".format(lfsize / rfsize * 100)) > except ConnectionResetError as e: > print('Exception ConnectionResetError {0}'.format(os.stat(lfile).st_size)) > response = urllib.request.urlopen(req) > > > if lfsize == rfsize: > retval = True > > return retval > > > while not Download('http://video.hrt.hr/2906/otv296.mp4', 'otv296.mp4'): > print('1') > If a ConnectionResetError is raised, it'll restart the request from the beginning, but continue appending to the same file. You should reset the writing too. From ben.a.elam at gmail.com Thu Jul 2 18:33:52 2015 From: ben.a.elam at gmail.com (Ben Elam) Date: Thu, 2 Jul 2015 15:33:52 -0700 (PDT) Subject: Mysterious tkinter bug: tk.Button doesn't think it passed event <1> Message-ID: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '<3>' but not event '<1>'. That is, the function the event is passed to receives the event and can even print the address of the event object, but a callback later produces an error suggesting that no event was actually passed to the function. Also, tk.Label handles '<1>' without problem. What gives? Code, errors, and slightly more details here: http://ingcake.github.io/2015/07/02/tkinter-feature-request---clickable-button/ I hope I'm just doing something dumb; any help would be much appreciated. From tjreedy at udel.edu Thu Jul 2 18:54:20 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 2 Jul 2015 18:54:20 -0400 Subject: Mysterious tkinter bug: tk.Button doesn't think it passed event <1> In-Reply-To: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> References: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> Message-ID: On 7/2/2015 6:33 PM, Ben Elam wrote: > I've stripped things down to the least amount of code necessary to > reproduce the error. I can make tk.Button handle event '<3>' but not > event '<1>'. That is, the function the event is passed to receives > the event and can even print the address of the event object, but a > callback later produces an error suggesting that no event was > actually passed to the function. Also, tk.Label handles '<1>' without > problem. What gives? > > Code, errors, and slightly more details here: > > http://ingcake.github.io/2015/07/02/tkinter-feature-request---clickable-button/ This page has 'slightly more details' but no code or error messages and no clickable links, just some red highlights for a few things like buttons.py. So I cannot investigate. -- Terry Jan Reedy From python at mrabarnett.plus.com Thu Jul 2 19:42:01 2015 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 03 Jul 2015 00:42:01 +0100 Subject: Mysterious tkinter bug: tk.Button doesn't think it passed event <1> In-Reply-To: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> References: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> Message-ID: <5595CC49.7030504@mrabarnett.plus.com> On 2015-07-02 23:33, Ben Elam wrote: > I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '<3>' but not event '<1>'. That is, the function the event is passed to receives the event and can even print the address of the event object, but a callback later produces an error suggesting that no event was actually passed to the function. Also, tk.Label handles '<1>' without problem. What gives? > > Code, errors, and slightly more details here: > > http://ingcake.github.io/2015/07/02/tkinter-feature-request---clickable-button/ > > I hope I'm just doing something dumb; any help would be much appreciated. > For a start, you're binding buttonHandler1 to button1 twice: 1. Passed via the 'command' keyword on line 13. 2 Via 'bind' on line 14. In 1, no argument will be passed. The handler you've defined expects an argument, so there'll be an exception, although the program will continue afterwards. In 2, an event argument will be passed. From ben.a.elam at gmail.com Thu Jul 2 22:59:32 2015 From: ben.a.elam at gmail.com (Ben Elam) Date: Thu, 2 Jul 2015 19:59:32 -0700 (PDT) Subject: Mysterious tkinter bug: tk.Button doesn't think it passed event <1> In-Reply-To: References: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> Message-ID: On Thursday, July 2, 2015 at 5:54:50 PM UTC-5, Terry Reedy wrote: > On 7/2/2015 6:33 PM, Ben Elam wrote: > > I've stripped things down to the least amount of code necessary to > > reproduce the error. I can make tk.Button handle event '<3>' but not > > event '<1>'. That is, the function the event is passed to receives > > the event and can even print the address of the event object, but a > > callback later produces an error suggesting that no event was > > actually passed to the function. Also, tk.Label handles '<1>' without > > problem. What gives? > > > > Code, errors, and slightly more details here: > > > > http://ingcake.github.io/2015/07/02/tkinter-feature-request---clickable-button/ > > This page has 'slightly more details' but no code or error messages and > no clickable links, just some red highlights for a few things like > buttons.py. So I cannot investigate. > > -- > Terry Jan Reedy Are you running, say NoScript? You'll need to allow javascript from github. From ben.a.elam at gmail.com Thu Jul 2 23:02:07 2015 From: ben.a.elam at gmail.com (Ben Elam) Date: Thu, 2 Jul 2015 20:02:07 -0700 (PDT) Subject: Mysterious tkinter bug: tk.Button doesn't think it passed event <1> In-Reply-To: References: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> Message-ID: <56185f35-7a89-4a9e-bd19-35bb19c71621@googlegroups.com> On Thursday, July 2, 2015 at 6:42:22 PM UTC-5, MRAB wrote: > On 2015-07-02 23:33, Ben Elam wrote: > > I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '<3>' but not event '<1>'. That is, the function the event is passed to receives the event and can even print the address of the event object, but a callback later produces an error suggesting that no event was actually passed to the function. Also, tk.Label handles '<1>' without problem. What gives? > > > > Code, errors, and slightly more details here: > > > > http://ingcake.github.io/2015/07/02/tkinter-feature-request---clickable-button/ > > > > I hope I'm just doing something dumb; any help would be much appreciated. > > > For a start, you're binding buttonHandler1 to button1 twice: > > 1. Passed via the 'command' keyword on line 13. > > 2 Via 'bind' on line 14. > > In 1, no argument will be passed. The handler you've defined expects an > argument, so there'll be an exception, although the program will > continue afterwards. > > In 2, an event argument will be passed. That was indeed the issue! "I'm dumb" it is! Thanks. From ben.a.elam at gmail.com Thu Jul 2 23:06:54 2015 From: ben.a.elam at gmail.com (Ben Elam) Date: Thu, 2 Jul 2015 20:06:54 -0700 (PDT) Subject: Mysterious tkinter bug: tk.Button doesn't think it passed event <1> In-Reply-To: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> References: <4b8f3595-56a5-4b2a-bf39-e42abfa46a95@googlegroups.com> Message-ID: On Thursday, July 2, 2015 at 5:34:19 PM UTC-5, Ben Elam wrote: > I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '<3>' but not event '<1>'. That is, the function the event is passed to receives the event and can even print the address of the event object, but a callback later produces an error suggesting that no event was actually passed to the function. Also, tk.Label handles '<1>' without problem. What gives? > > Code, errors, and slightly more details here: > > http://ingcake.github.io/2015/07/02/tkinter-feature-request---clickable-button/ > > I hope I'm just doing something dumb; any help would be much appreciated. Pulled the original post because dumb. For posterity, here is a gist with the original code, along with the original error messages: https://gist.github.com/ingcake/aa4e01687dd81890c8fd From victorhooi at gmail.com Thu Jul 2 23:51:01 2015 From: victorhooi at gmail.com (Victor Hooi) Date: Thu, 2 Jul 2015 20:51:01 -0700 (PDT) Subject: Creating JSON from iostat lines ; Adding timezone information to naive datetimes? Message-ID: <582b2518-50d1-4a85-98a3-cb8f63d5c52d@googlegroups.com> I just want to run some things past you guys, to make sure I'm doing it right. I'm using Python to parse disk metrics out of iostat output. The device lines look like this: Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 My goal is JSON output for each metric that look like the below (this is for InfluxDB): { "measurement": "read_requests", "tags": { "project": "SOME_PROJECT", "hostname": "server1.newyork.com", }, "time": timestamp.isoformat(), "fields": { "value": 0.00 } } To create the above, I am using the following code: disk_stat_headers = ['device', 'read_requests_merged', 'write_requests_merged', 'read_requests', 'write_requests', 'read_sectors', 'write_sectors', 'average_request_size', 'average_queue_length', 'average_wait', 'average_service_time', 'utilisation'] ...... elif i >= 5 and line: disk_stats = {} device = line.split()[0] disk_stats[device] = dict(zip(disk_stat_headers, line.split()[1:])) json_points = [] for disk_name, metrics in disk_stats.items(): print(disk_name) print(metrics) for key, value in metrics.items(): json_points.append({ "measurement": key, "tags": { "project": project, "hostname": hostname, }, "time": timestamp.isoformat(), "fields": { "value": value } }) Is there any issue with the above? Or can you see a better way to do this? (I'm calling split() twice, not sure if that's worse than storing it in a variable) Second question - the timestamps in isotat are timezone-naive. I'm using the below to add the right timezone (EDT in this case) to them, which depends on the pytz library: from pytz import timezone eastern = timezone('US/Eastern') timestamp = eastern.localize(line) Is the above an appropriate way of doing this? Or is there an easier way just using the Python stdlib's? From nad at acm.org Fri Jul 3 01:07:31 2015 From: nad at acm.org (Ned Deily) Date: Thu, 02 Jul 2015 22:07:31 -0700 Subject: Bug in floating point multiplication References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> <559579bb$0$2921$e4fe514c@news.xs4all.nl> Message-ID: In article <559579bb$0$2921$e4fe514c at news.xs4all.nl>, Irmen de Jong wrote: > Tested on Mac OSX 10.10.4, with a 64-bit core2duo processor. Below are all > 64-bit python > implementations: > 2.6.9 (apple supplied), 2.7.6 (apple supplied), 3.4.3 (homebrew), and > pypy-2.6.0 > (homebrew). I don't have any 32 bit Python implementations on the mac. Sure you do! $ /usr/bin/python2.7 -c 'import sys;print(sys.maxsize)' 9223372036854775807 $ arch -i386 /usr/bin/python2.7 -c 'import sys;print(sys.maxsize)' 2147483647 -- Ned Deily, nad at acm.org From dieter at handshake.de Fri Jul 3 01:59:24 2015 From: dieter at handshake.de (dieter) Date: Fri, 03 Jul 2015 07:59:24 +0200 Subject: requests.Session() how do you set 'replace' on the encoding? References: Message-ID: <87pp49aiir.fsf@handshake.de> Veek M writes: > I'm getting a Unicode error: > > Traceback (most recent call last): > File "fooxxx.py", line 56, in > parent = anchor.getparent() > UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in position > 8: illegal multibyte sequence You give us very little context. Using "getparent" seems to indicate that you are doing something with hierarchies, likely some XML processing. In this case, the XML document likely specified "gbk" as document encoding (otherwise, you would get the default "utf-8") -- and it got it wrong (which should not happen). In general: when you need control over encoding handling because deep in a framework an econding causes problems (as apparently in your case), you can usually first take the plain text, fix any encoding problems and only then pass the fixed text to your framework. > I'm doing: > s = requests.Session() > to suck data in, so.. how do i 'replace' chars that fit gbk It does not seem that the problem occurs inside the "requests" module. Thus, you have a chance to "intercept" the downloaded text and fix encoding problems. From drekin at gmail.com Fri Jul 3 06:28:32 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Fri, 3 Jul 2015 12:28:32 +0200 Subject: An asyncio example Message-ID: Hello, I'm experimenting with asyncio. I have composed the following code. There is a server handler and a client handler. I didn't want to split the code into two files so I just used a socketpair, inspired by example https://docs.python.org/3/library/asyncio-stream.html#register-an-open-socket-to-wait-for-data-using-streams . However, my code doesn't work ? it blocks because both sides are trying to read more data. But if I close the writer on one side (the commented line), whole connection is closed. So 1) is there a way to close just one direction of the connection? 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, is that desired behavior? And why? 3) Are there some other issues with my code with respect to ?best practices? how to write a code like this? Here is the code: import asyncio import socket async def server(reader, writer): print("starting server") request = (await reader.read()).decode() print("got request {!r}".format(request)) response = "RESPONSE" writer.write(response.encode()) print("response sent") async def client(reader, writer): print("starting client") request = "REQUEST" writer.write(request.encode()) # writer.close() print("request sent") response = (await reader.read()).decode() print("got response {!r}".format(response)) async def connect(loop): serversock, clientsock = socket.socketpair() reader, writer = await asyncio.open_connection(sock=serversock, loop=loop) server_coro = server(reader, writer) reader, writer = await asyncio.open_connection(sock=clientsock, loop=loop) client_coro = client(reader, writer) server_task = loop.create_task(server_coro) client_task = loop.create_task(client_coro) return client_task loop = asyncio.get_event_loop() task = loop.run_until_complete(connect(loop)) loop.run_until_complete(task) Thank you, Adam Barto? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Fri Jul 3 10:31:15 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 3 Jul 2015 08:31:15 -0600 Subject: An asyncio example In-Reply-To: References: Message-ID: On Fri, Jul 3, 2015 at 4:28 AM, Adam Barto? wrote: > Hello, > > I'm experimenting with asyncio. I have composed the following code. There is > a server handler and a client handler. I didn't want to split the code into > two files so I just used a socketpair, inspired by example > https://docs.python.org/3/library/asyncio-stream.html#register-an-open-socket-to-wait-for-data-using-streams > . However, my code doesn't work ? it blocks because both sides are trying to > read more data. But if I close the writer on one side (the commented line), > whole connection is closed. So > > 1) is there a way to close just one direction of the connection? No. SOCK_STREAM sockets are always bidirectional. > 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, > is that desired behavior? And why? I don't think so. When I tried this locally (using Python 3.4.0, so replacing "async def" with "def" and "await" with "yield from" and "loop.create_task" with "asyncio.async") pressing Ctrl-C did interrupt the loop. > 3) Are there some other issues with my code with respect to ?best practices? > how to write a code like this? There are a couple of approaches you could take. Since your protocol is so far text-based, I would suggest adding '\n' to the ends of your messages and using reader.readline instead of reader.read. Alternatively, since the writer isn't planning to write anything further after its one message, just call writer.write_eof() (not writer.close) after the call to write. From ian.g.kelly at gmail.com Fri Jul 3 10:38:26 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 3 Jul 2015 08:38:26 -0600 Subject: An asyncio example In-Reply-To: References: Message-ID: On Fri, Jul 3, 2015 at 8:31 AM, Ian Kelly wrote: > On Fri, Jul 3, 2015 at 4:28 AM, Adam Barto? wrote: >> Hello, >> >> I'm experimenting with asyncio. I have composed the following code. There is >> a server handler and a client handler. I didn't want to split the code into >> two files so I just used a socketpair, inspired by example >> https://docs.python.org/3/library/asyncio-stream.html#register-an-open-socket-to-wait-for-data-using-streams >> . However, my code doesn't work ? it blocks because both sides are trying to >> read more data. But if I close the writer on one side (the commented line), >> whole connection is closed. So >> >> 1) is there a way to close just one direction of the connection? > > No. SOCK_STREAM sockets are always bidirectional. > >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, >> is that desired behavior? And why? > > I don't think so. When I tried this locally (using Python 3.4.0, so > replacing "async def" with "def" and "await" with "yield from" and > "loop.create_task" with "asyncio.async") pressing Ctrl-C did interrupt > the loop. > >> 3) Are there some other issues with my code with respect to ?best practices? >> how to write a code like this? > > There are a couple of approaches you could take. Since your protocol > is so far text-based, I would suggest adding '\n' to the ends of your > messages and using reader.readline instead of reader.read. > Alternatively, since the writer isn't planning to write anything > further after its one message, just call writer.write_eof() (not > writer.close) after the call to write. Sorry, the latter approach doesn't work; it's basically equivalent to calling close. In any case, I suggest using reader.readline. From oscar.j.benjamin at gmail.com Fri Jul 3 11:13:58 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Fri, 3 Jul 2015 16:13:58 +0100 Subject: Bug in floating point multiplication In-Reply-To: References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2 July 2015 at 18:29, Jason Swails wrote: > > As others have suggested, this is almost certainly a 32-bit vs. 64-bit > issue. Consider the following C program: > > // maths.h > #include > #include > > int main() { > double x; > int i; > x = 1-pow(0.5, 53); > > for (i = 1; i < 1000000; i++) { > if ((int)(i*x) == i) { > printf("%d\n", i); > break; > } > } > > return 0; > } > > For the most part, this should be as close to an exact transliteration of > your Python code as possible. > > Here's what I get when I try compiling and running it on my 64-bit (Gentoo) > Linux machine with 32-bit compatible libs: > > swails at batman ~/test $ gcc maths.c > swails at batman ~/test $ ./a.out > swails at batman ~/test $ gcc -m32 maths.c > swails at batman ~/test $ ./a.out > 2049 I was unable to reproduce this on my system. In both cases the loops run to completion. A look at the assembly generated by gcc shows that something different goes on there though. The loop in the 64 bit one (in the main function) looks like: $ objdump -d a.out | less ... 400555: pxor %xmm0,%xmm0 400559: cvtsi2sdl -0xc(%rbp),%xmm0 40055e: mulsd -0x8(%rbp),%xmm0 400563: cvttsd2si %xmm0,%eax 400567: cmp -0xc(%rbp),%eax 40056a: jne 400582 40056c: mov -0xc(%rbp),%eax 40056f: mov %eax,%esi 400571: mov $0x400624,%edi 400576: mov $0x0,%eax 40057b: callq 400410 400580: jmp 40058f 400582: addl $0x1,-0xc(%rbp) 400586: cmpl $0xf423f,-0xc(%rbp) 40058d: jle 400555 ... Where is the 32 bit one looks like: $ objdump -d a.out.32 | less ... 804843e: fildl -0x14(%ebp) 8048441: fmull -0x10(%ebp) 8048444: fnstcw -0x1a(%ebp) 8048447: movzwl -0x1a(%ebp),%eax 804844b: mov $0xc,%ah 804844d: mov %ax,-0x1c(%ebp) 8048451: fldcw -0x1c(%ebp) 8048454: fistpl -0x20(%ebp) 8048457: fldcw -0x1a(%ebp) 804845a: mov -0x20(%ebp),%eax 804845d: cmp -0x14(%ebp),%eax 8048460: jne 8048477 8048462: sub $0x8,%esp 8048465: pushl -0x14(%ebp) 8048468: push $0x8048520 804846d: call 80482f0 8048472: add $0x10,%esp 8048475: jmp 8048484 8048477: addl $0x1,-0x14(%ebp) 804847b: cmpl $0xf423f,-0x14(%ebp) 8048482: jle 804843e ... So the 64 bit one is using SSE instructions and the 32-bit one is using x87. That could explain the difference you see at the C level but I don't see it on this CPU (/proc/cpuinfo says Intel(R) Core(TM) i5-3427U CPU @ 1.80GHz). -- Oscar From marko at pacujo.net Fri Jul 3 11:14:21 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 03 Jul 2015 18:14:21 +0300 Subject: An asyncio example References: Message-ID: <87vbe1qnn6.fsf@elektro.pacujo.net> >> 1) is there a way to close just one direction of the connection? > > No. SOCK_STREAM sockets are always bidirectional. socket.shutdown(socket.SHUT_WR) does the trick. I think the asyncio.StreamWriter.write_eof() is the high-level equivalent. Marko From irmen.NOSPAM at xs4all.nl Fri Jul 3 12:27:27 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Fri, 03 Jul 2015 18:27:27 +0200 Subject: Bug in floating point multiplication In-Reply-To: References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> <559579bb$0$2921$e4fe514c@news.xs4all.nl> Message-ID: <5596b7ed$0$2851$e4fe514c@news.xs4all.nl> On 3-7-2015 7:07, Ned Deily wrote: > In article <559579bb$0$2921$e4fe514c at news.xs4all.nl>, > Irmen de Jong wrote: >> Tested on Mac OSX 10.10.4, with a 64-bit core2duo processor. Below are all >> 64-bit python >> implementations: >> 2.6.9 (apple supplied), 2.7.6 (apple supplied), 3.4.3 (homebrew), and >> pypy-2.6.0 >> (homebrew). I don't have any 32 bit Python implementations on the mac. > > Sure you do! > > $ /usr/bin/python2.7 -c 'import sys;print(sys.maxsize)' > 9223372036854775807 > $ arch -i386 /usr/bin/python2.7 -c 'import sys;print(sys.maxsize)' > 2147483647 > Woops! Totally forgot about the multiarch thing. Thanks for reminding me. It doesn't change the outcome of the test though, when running the little test code with the 32-bit versions they both (2.6 and 2.7) ran to completion. Irmen From drekin at gmail.com Fri Jul 3 13:38:07 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Fri, 3 Jul 2015 19:38:07 +0200 Subject: An asyncio example Message-ID: Ian Kelly: >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, >> is that desired behavior? And why? > > I don't think so. When I tried this locally (using Python 3.4.0, so > replacing "async def" with "def" and "await" with "yield from" and > "loop.create_task" with "asyncio.async") pressing Ctrl-C did interrupt > the loop. > Ok, I'll try to get more information and I'll eventually raise an issue. >> 3) Are there some other issues with my code with respect to ?best practices? >> how to write a code like this? > > There are a couple of approaches you could take. Since your protocol > is so far text-based, I would suggest adding '\n' to the ends of your > messages and using reader.readline instead of reader.read. > For now, there is no protocol at all. I just wanted to first send all the data (of arbitrary size) and then wait for whole response. If there is really no way to close just one direction of a socket, maybe the easiest way is to have two socket pairs? Marko Rauhamaa: >>> 1) is there a way to close just one direction of the connection? >> >> No. SOCK_STREAM sockets are always bidirectional. > > socket.shutdown(socket.SHUT_WR) does the trick. > > I think the asyncio.StreamWriter.write_eof() is the high-level > equivalent. You are right that writer.write_eof() behaves like writer.transport.get_extra_info("socket").shutdown(socket.SHUT_WR) ? the server resumes and sends the response. However, the client still reads empty bytes afterwards. -------------- next part -------------- An HTML attachment was scrubbed... URL: From marko at pacujo.net Fri Jul 3 16:01:29 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 03 Jul 2015 23:01:29 +0300 Subject: An asyncio example References: Message-ID: <87r3op80yu.fsf@elektro.pacujo.net> Adam Barto? : > Marko Rauhamaa: >> socket.shutdown(socket.SHUT_WR) does the trick. >> >> I think the asyncio.StreamWriter.write_eof() is the high-level >> equivalent. > > You are right that writer.write_eof() behaves like > writer.transport.get_extra_info("socket").shutdown(socket.SHUT_WR) ? > the server resumes and sends the response. However, the client still > reads empty bytes afterwards. Reading empty bytes means the peer has shut down its end of the connection. Marko From drekin at gmail.com Fri Jul 3 16:30:47 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Fri, 3 Jul 2015 22:30:47 +0200 Subject: An asyncio example Message-ID: >> Marko Rauhamaa: >>> socket.shutdown(socket.SHUT_WR) does the trick. >>> >>> I think the asyncio.StreamWriter.write_eof() is the high-level >>> equivalent. >> >> You are right that writer.write_eof() behaves like >> writer.transport.get_extra_info("socket").shutdown(socket.SHUT_WR) ? >> the server resumes and sends the response. However, the client still >> reads empty bytes afterwards. > > Reading empty bytes means the peer has shut down its end of the > connection. But it didn't or had sent a response before. My code suppose to be like this: 1) The client sends a request message. 2) The client closes the writing direction of the socket. 3) The server reads the request message. 4) The server sends a response message and possibly closes the other direction of the socket. 5) The client reads data ? it should read the response sent by the server but gets empty bytes instead. -------------- next part -------------- An HTML attachment was scrubbed... URL: From drekin at gmail.com Fri Jul 3 16:33:58 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Fri, 3 Jul 2015 22:33:58 +0200 Subject: An asyncio example Message-ID: On Fri, Jul 3, 2015 at 7:38 PM, Adam Barto? wrote: > Ian Kelly: > > >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the > loop, > >> is that desired behavior? And why? > > > > I don't think so. When I tried this locally (using Python 3.4.0, so > > replacing "async def" with "def" and "await" with "yield from" and > > "loop.create_task" with "asyncio.async") pressing Ctrl-C did interrupt > > the loop. > > > Ok, I'll try to get more information and I'll eventually raise an issue. > I tried it on Python 3.4.1 and Ctrl-C doesn't interrupt the loop. Maybe it has something to do with the fact I'm on Windows. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Fri Jul 3 17:31:33 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 3 Jul 2015 17:31:33 -0400 Subject: An asyncio example In-Reply-To: References: Message-ID: On 7/3/2015 4:33 PM, Adam Barto? wrote: > > On Fri, Jul 3, 2015 at 7:38 PM, Adam Barto? > wrote: > > Ian Kelly: > > >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, > >> is that desired behavior? And why? > > > > I don't think so. When I tried this locally (using Python 3.4.0, so > > replacing "async def" with "def" and "await" with "yield from" and > > "loop.create_task" with "asyncio.async") pressing Ctrl-C did > interrupt > > the loop. > > > Ok, I'll try to get more information and I'll eventually raise an issue. > > > I tried it on Python 3.4.1 and Ctrl-C doesn't interrupt the loop. > Maybe it has something to do with the fact I'm on Windows. Please try with 3.4.3, which has further asyncio changes. -- Terry Jan Reedy From djacobfeuerborn at gmail.com Fri Jul 3 20:11:10 2015 From: djacobfeuerborn at gmail.com (Dennis Jacobfeuerborn) Date: Fri, 3 Jul 2015 17:11:10 -0700 (PDT) Subject: Searching for a usable X509 implementation Message-ID: <46c64c5f-e5b5-4865-83e0-2474ebe4f8bd@googlegroups.com> Hi, I'm trying to implement certificate functionality in a python app but after fighting with pyOpenSSL and M2Crypto I'm thinking about writing wrapper functions for the OpenSSL command line tool instead or switching the app to another language all together. Apparently PyOpenSSL has no way to save a public key to a file which is baffling. M2Crypto has that ability but apparently no usable way to verify a certificate? Is there really no usable module out there to enable straightforward certificate handling? Regards, Dennis From carl at oddbird.net Fri Jul 3 20:24:37 2015 From: carl at oddbird.net (Carl Meyer) Date: Fri, 03 Jul 2015 18:24:37 -0600 Subject: Searching for a usable X509 implementation In-Reply-To: <46c64c5f-e5b5-4865-83e0-2474ebe4f8bd@googlegroups.com> References: <46c64c5f-e5b5-4865-83e0-2474ebe4f8bd@googlegroups.com> Message-ID: <559727C5.2020507@oddbird.net> Hi Dennis, On 07/03/2015 06:11 PM, Dennis Jacobfeuerborn wrote: > Hi, I'm trying to implement certificate functionality in a python app > but after fighting with pyOpenSSL and M2Crypto I'm thinking about > writing wrapper functions for the OpenSSL command line tool instead > or switching the app to another language all together. My X.509 needs have never been more than basic, but PyOpenSSL has always had what I need. > Apparently PyOpenSSL has no way to save a public key to a file which > is baffling. M2Crypto has that ability but apparently no usable way > to verify a certificate? Is dump_certificate what you need? See https://pyopenssl.readthedocs.org/en/latest/api/crypto.html#OpenSSL.crypto.dump_certificate or this example for detailed usage: https://github.com/msabramo/pyOpenSSL/blob/master/examples/mk_simple_certs.py > Is there really no usable module out there to enable straightforward > certificate handling? I'm not aware of anything better than PyOpenSSL. Carl -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: OpenPGP digital signature URL: From jason.swails at gmail.com Fri Jul 3 21:12:39 2015 From: jason.swails at gmail.com (Jason Swails) Date: Fri, 3 Jul 2015 21:12:39 -0400 Subject: Bug in floating point multiplication In-Reply-To: References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Jul 3, 2015 at 11:13 AM, Oscar Benjamin wrote: > On 2 July 2015 at 18:29, Jason Swails wrote: > > > > As others have suggested, this is almost certainly a 32-bit vs. 64-bit > > issue. Consider the following C program: > > > > // maths.h > > #include > > #include > > > > int main() { > > double x; > > int i; > > x = 1-pow(0.5, 53); > > > > for (i = 1; i < 1000000; i++) { > > if ((int)(i*x) == i) { > > printf("%d\n", i); > > break; > > } > > } > > > > return 0; > > } > > > > For the most part, this should be as close to an exact transliteration of > > your Python code as possible. > > > > Here's what I get when I try compiling and running it on my 64-bit > (Gentoo) > > Linux machine with 32-bit compatible libs: > > > > swails at batman ~/test $ gcc maths.c > > swails at batman ~/test $ ./a.out > > swails at batman ~/test $ gcc -m32 maths.c > > swails at batman ~/test $ ./a.out > > 2049 > > I was unable to reproduce this on my system. In both cases the loops > run to completion. A look at the assembly generated by gcc shows that > something different goes on there though. > > The loop in the 64 bit one (in the main function) looks like: > > $ objdump -d a.out | less > ... > 400555: pxor %xmm0,%xmm0 > 400559: cvtsi2sdl -0xc(%rbp),%xmm0 > 40055e: mulsd -0x8(%rbp),%xmm0 > 400563: cvttsd2si %xmm0,%eax > 400567: cmp -0xc(%rbp),%eax > 40056a: jne 400582 > 40056c: mov -0xc(%rbp),%eax > 40056f: mov %eax,%esi > 400571: mov $0x400624,%edi > 400576: mov $0x0,%eax > 40057b: callq 400410 > 400580: jmp 40058f > 400582: addl $0x1,-0xc(%rbp) > 400586: cmpl $0xf423f,-0xc(%rbp) > 40058d: jle 400555 > ... > > Where is the 32 bit one looks like: > > $ objdump -d a.out.32 | less > ... > 804843e: fildl -0x14(%ebp) > 8048441: fmull -0x10(%ebp) > 8048444: fnstcw -0x1a(%ebp) > 8048447: movzwl -0x1a(%ebp),%eax > 804844b: mov $0xc,%ah > 804844d: mov %ax,-0x1c(%ebp) > 8048451: fldcw -0x1c(%ebp) > 8048454: fistpl -0x20(%ebp) > 8048457: fldcw -0x1a(%ebp) > 804845a: mov -0x20(%ebp),%eax > 804845d: cmp -0x14(%ebp),%eax > 8048460: jne 8048477 > 8048462: sub $0x8,%esp > 8048465: pushl -0x14(%ebp) > 8048468: push $0x8048520 > 804846d: call 80482f0 > 8048472: add $0x10,%esp > 8048475: jmp 8048484 > 8048477: addl $0x1,-0x14(%ebp) > 804847b: cmpl $0xf423f,-0x14(%ebp) > 8048482: jle 804843e > ... > > So the 64 bit one is using SSE instructions and the 32-bit one is > using x87. That could explain the difference you see at the C level > but I don't see it on this CPU (/proc/cpuinfo says Intel(R) Core(TM) > i5-3427U CPU @ 1.80GHz). > ?Hmm. Well that could explain why you don't get the same results as me. My CPU is a AMD FX(tm)-6100 Six-Core Processor ? (from /proc/cpuinfo). My objdump looks the same as yours for the 64-bit version, but for 32-bit it looks like: ... 804843a: db 44 24 14 fildl 0x14(%esp) ?? ? 804843e: dc 4c 24 18 fmull 0x18(%esp) ? 8048442: dd 5c 24 08 fstpl 0x8(%esp) ? 8048446: f2 0f 2c 44 24 08 cvttsd2si 0x8(%esp),%eax ? 804844c: 3b 44 24 14 cmp 0x14(%esp),%eax ? 8048450: 75 16 jne 8048468 ? 8048452: 8b 44 24 14 mov 0x14(%esp),%eax ? 8048456: 89 44 24 04 mov %eax,0x4(%esp) ? 804845a: c7 04 24 10 85 04 08 movl $0x8048510,(%esp) ? 8048461: e8 8a fe ff ff call 80482f0 ? 8048466: eb 0f jmp 8048477 ? 8048468: 83 44 24 14 01 addl $0x1,0x14(%esp) ? 804846d: 81 7c 24 14 3f 42 0f cmpl $0xf423f,0x14(%esp) ? 8048474: 00 ? 8048475: 7e c3 jle 804843a ...? ? However, I have no experience looking at raw assembler, so I can't discern what it is I'm even looking at (nor do I know what explicit SSE instructions look like in assembler). I have a Mac that runs an Intel Core i5, and, like you, both 32- and 64-bit versions run to completion. Which is at least consistent with what others are seeing with Python. All the best, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From telmo.bacile at gmail.com Fri Jul 3 21:17:41 2015 From: telmo.bacile at gmail.com (telmo bacile) Date: Fri, 3 Jul 2015 18:17:41 -0700 Subject: calculating entropy of image or alternative? Message-ID: Hi list, I found a code that calculates entropy of images with python that can be used for classifying interesting images from uninteresting ones. Interesting images has more structured patterns while uninsteresting are more noisy or completely homogeneous. I was thinking this code (entropy of image) can be used for measuring the level of disorder of a group of points in the image. For example: Imagine that we have 3 images, each image has 6 dots, the first one has very ordered dots , the second one have dots a little bit disordered and the third one has very dissordered dots. Then entropy of each image should measure the level of dissorganization of the dots. But the wierd thing is that when i experimented with this i got resuts without sense. The result i get is that the image with intermedium dissorder has less entropy that the very ordered image . Do anybody have an idea why im getting this result? Maybe im misunderstanding something. Is it possible to use entropy of image to measure the level of dissorganization of a group of points in an image? If not , is there is another method for doing this? thanks in advance T. here is the code: import math from PIL import Image imageFile = 'int2.jpg' print imageFile im = Image.open(imageFile) rgbHistogram = im.histogram() print 'Snannon Entropy for Red, Green, Blue:' for rgb in range(3): totalPixels = sum(rgbHistogram[rgb * 256 : (rgb + 1) * 256]) ent = 0.0 for col in range(rgb * 256, (rgb + 1) * 256): freq = float(rgbHistogram[col]) / totalPixels if freq > 0: ent = ent + freq * math.log(freq, 2) ent = -ent print ent From flebber.crue at gmail.com Fri Jul 3 22:01:56 2015 From: flebber.crue at gmail.com (Sayth Renshaw) Date: Fri, 3 Jul 2015 19:01:56 -0700 (PDT) Subject: Should iPython Notebook replace Idle Message-ID: <6a451676-8487-4482-a903-4ad21b3f2470@googlegroups.com> In future releases of Python should ipython Notebooks replace idle as the default tool for new users to learn python? This would as I see it have many benefits? 1. A nicer more usual web interface for new users. 2. Would allow the python documentation and tutorials to be distributed as ipython notebooks which would allow new users to play and interact with the tutorials as they proceed. No download separate code retyping just edit run and play. 3. Would allow teachers to setup notebooks knowing that all users have the same default environment, no need for setting up virtualenvs etc. 4. Strengthen the learning base and for new python developers as a whole. Thoughts? Sayth From jason.swails at gmail.com Fri Jul 3 23:15:06 2015 From: jason.swails at gmail.com (Jason Swails) Date: Fri, 3 Jul 2015 23:15:06 -0400 Subject: Should iPython Notebook replace Idle In-Reply-To: <6a451676-8487-4482-a903-4ad21b3f2470@googlegroups.com> References: <6a451676-8487-4482-a903-4ad21b3f2470@googlegroups.com> Message-ID: On Fri, Jul 3, 2015 at 10:01 PM, Sayth Renshaw wrote: > In future releases of Python should ipython Notebooks replace idle as the > default tool for new users to learn python? > This would as I see it have many benefits? > > 1. A nicer more usual web interface for new users. > 2. Would allow the python documentation and tutorials to be distributed as > ipython notebooks which would allow new users to play and interact with the > tutorials as they proceed. No download separate code retyping just edit run > and play. > 3. Would allow teachers to setup notebooks knowing that all users have the > same default environment, no need for setting up virtualenvs etc. > 4. Strengthen the learning base and for new python developers as a whole. > > Thoughts? > IPython and IDLE are different. IPython is *just* an interactive Python interpreter with a ton of tweaks and enhancements. IDLE, by contrast, is both an upscale interpreter (not *nearly* as feature-complete as IPython), but it's also an IDE. AFAICT, IPython does not do this. Also, look at the IPython dependencies for its core functionalities: - jinja2 - sphinx - pyzmq - pygments - tornado - PyQt | PySide None of these are part of the Python standard library. By contrast, IDLE is built entirely with stdlib components (tkinter for the GUI). AFAIK, nothing in the stdlib depends on anything outside of it. And addition to the Python stdlib imposes some pretty serious restrictions on a library. If the IPython team agreed to release their tools with the stdlib instead of IDLE, they'd have to give up a lot of control over their project: - License - Release schedule - Development environment Everything gets swallowed into Python. I can't imagine this ever happening. All the best, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From okkpiyush at gmail.com Sat Jul 4 00:05:16 2015 From: okkpiyush at gmail.com (PIYUSH KUMAR) Date: Fri, 3 Jul 2015 21:05:16 -0700 (PDT) Subject: installing libraries like numpy scipy matplotlib Message-ID: <44a89c97-38bb-4087-973a-0da56488b824@googlegroups.com> I have never used linux in my life.. only windows based computing.. So I have problems in installing third party libraries in python. I know this one is very basic and there are very experienced programmers in this group. So can somebody just explain me how many softwares or other python packages I have to install before installing any of these. Any of the documentations couldn't been able to help me. I have checked many websites but got confused everytime. I also had problems installing PYKE last month. Please be very basic while explaining. Thankyou very much :) From 4kir4.1i at gmail.com Sat Jul 4 00:29:45 2015 From: 4kir4.1i at gmail.com (Akira Li) Date: Sat, 04 Jul 2015 07:29:45 +0300 Subject: Matplotlib X-axis timezone trouble References: Message-ID: <87twtk4kau.fsf@gmail.com> Peter Pearson writes: > The following code produces a plot with a line running from (9:30, 0) to > (10:30, 1), not from (8:30, 0) to (9:30, 1) as I desire. > > If I use timezone None instead of pacific, the plot is as desired, but > of course that doesn't solve the general problem of which this is a > much-reduced example. > > If I use timezone US/Central, I get the same (bad) plot. > > import matplotlib.pyplot as plt > import datetime > import pytz > pacific = pytz.timezone("US/Pacific") > fig = plt.figure() > plt.plot([datetime.datetime(2014, 10, 7, 8, 30, tzinfo=pacific), > datetime.datetime(2014, 10, 7, 9, 30, tzinfo=pacific)], > [0,1], marker="o", color="green") > fig.autofmt_xdate() > plt.show() > > Does anybody know why this shift is occurring? Is Matplotlib > confused about what timezone to use in labeling the axis? How > would I tell it what timezone to use (preferably explicitly in > the code, not in matplotlibrc)? > Your pytz usage is incorrect. Don't pass a pytz tzinfo object to the datetime construtor directly, use `.localize()` method instead. Read the note at the very beginning of pytz docs http://pytz.sourceforge.net/ From robert.kern at gmail.com Sat Jul 4 00:49:12 2015 From: robert.kern at gmail.com (Robert Kern) Date: Sat, 04 Jul 2015 05:49:12 +0100 Subject: calculating entropy of image or alternative? In-Reply-To: References: Message-ID: On 2015-07-04 02:17, telmo bacile wrote: > Hi list, I found a code that calculates entropy of images with > python that can be used for classifying interesting images from > uninteresting ones. Interesting images has more structured patterns > while uninsteresting are more noisy or completely homogeneous. > > I was thinking this code (entropy of image) can be used for measuring > the level of disorder of a group of points in the image. > For example: > Imagine that we have 3 images, each image has 6 dots, the first one > has very ordered dots , the second one have dots a little bit > disordered and the third one has very dissordered dots. > Then entropy of each image should measure the level of > dissorganization of the dots. > > But the wierd thing is that when i experimented with this i got resuts > without sense. > The result i get is that the image with intermedium dissorder has > less entropy that the very ordered image . Do anybody have an idea > why im getting this result? There is no single quantity that is "The Entropy" of a given image. Images don't have "An Entropy". Probability distributions do. Images aren't probability distributions, but there are several distributions of quantities that will be associated with an image. The entropy of each of these distributions will each tell you something different about the image. What you are calculating is the entropy of the distribution of intensities of the R, G, and B channels. This entropy quantity is related, more or less, to the variety of colors that are in the image. This distribution (and thus the entropy computed from it) doesn't take into account the spatial layout of the pixels. You could take a spatially well-ordered image and rearrange the pixels completely randomly; the entropy quantity that your code is computing will be exactly the same because the pixels contribute to the histogram in the same way. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From ian.g.kelly at gmail.com Sat Jul 4 01:58:45 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 3 Jul 2015 23:58:45 -0600 Subject: An asyncio example In-Reply-To: <87vbe1qnn6.fsf@elektro.pacujo.net> References: <87vbe1qnn6.fsf@elektro.pacujo.net> Message-ID: On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa wrote: > >>> 1) is there a way to close just one direction of the connection? >> >> No. SOCK_STREAM sockets are always bidirectional. > > socket.shutdown(socket.SHUT_WR) does the trick. > > I think the asyncio.StreamWriter.write_eof() is the high-level > equivalent. I stand corrected. And you're also correct about write_eof: it causes shutdown(SHUT_WR) to be called on the underlying socket once the buffer has been written. https://hg.python.org/cpython/file/34460219c0e0/Lib/asyncio/selector_events.py#l737 That said, just replacing the writer.close() with writer.write_eof() in the OP's code doesn't seem to work; the server response comes back empty. This works: >>> sock1, sock2 = socket.socketpair() >>> sock1.send(b'REQUEST') 7 >>> sock1.shutdown(socket.SHUT_WR) >>> sock2.recv(100) b'REQUEST' >>> sock2.send(b'RESPONSE') 8 >>> sock1.recv(100) b'RESPONSE' And this works: import asyncio import socket def server(sock): request = yield from asyncio.get_event_loop().sock_recv(sock, 100) print("got request {!r}".format(request)) yield from asyncio.get_event_loop().sock_sendall(sock, b'RESPONSE') def client(sock): yield from asyncio.get_event_loop().sock_sendall(sock, b'REQUEST') sock.shutdown(socket.SHUT_WR) response = yield from asyncio.get_event_loop().sock_recv(sock, 100) print("got response {!r}".format(response)) asyncio.get_event_loop().stop() def connect(): clientsock, serversock = socket.socketpair() clientsock.setblocking(False) serversock.setblocking(False) asyncio.async(client(clientsock)) asyncio.async(server(serversock)) connect() asyncio.get_event_loop().run_forever() I'm wondering whether there might be a bug in the higher-level transport code that interferes with reading after calling write_eof. From drekin at gmail.com Sat Jul 4 02:45:14 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Sat, 4 Jul 2015 08:45:14 +0200 Subject: An asyncio example In-Reply-To: References: Message-ID: > > On Fri, Jul 3, 2015 at 7:38 PM, Adam Barto? wrote: >> >>> Ian Kelly: >>> >> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the >>> loop >>> >> >> is that desired behavior? And why? >>> >> > >>> >> > I don't think so. When I tried this locally (using Python 3.4.0, so >>> >> > replacing "async def" with "def" and "await" with "yield from" and >>> >> > "loop.create_task" with "asyncio.async") pressing Ctrl-C did interrupt >>> >> > the loop >>> >> > >>> >> Ok, I'll try to get more information and I'll eventually raise an issue. >>> >> >> I tried it on Python 3.4.1 and Ctrl-C doesn't interrupt the loop. Maybe >> it has something to do with the fact I'm on Windows. > > > Please try with 3.4.3, which has further asyncio changes. > I originally tried with 3.5.0b2. -------------- next part -------------- An HTML attachment was scrubbed... URL: From drekin at gmail.com Sat Jul 4 03:04:07 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Sat, 4 Jul 2015 09:04:07 +0200 Subject: An asyncio example In-Reply-To: References: Message-ID: On Sat, Jul 4, 2015 at 8:45 AM, Adam Barto? wrote: > On Fri, Jul 3, 2015 at 7:38 PM, Adam Barto? wrote: >>> >>>> Ian Kelly: >>>> >>> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the >>>> loop >>>> >>> >> is that desired behavior? And why? >>>> >>> > >>>> >>> > I don't think so. When I tried this locally (using Python 3.4.0, so >>>> >>> > replacing "async def" with "def" and "await" with "yield from" and >>>> >>> > "loop.create_task" with "asyncio.async") pressing Ctrl-C did interrupt >>>> >>> > the loop >>>> >>> > >>>> >>> Ok, I'll try to get more information and I'll eventually raise an issue. >>>> >>> >>> I tried it on Python 3.4.1 and Ctrl-C doesn't interrupt the loop. Maybe >>> it has something to do with the fact I'm on Windows. >> >> >> Please try with 3.4.3, which has further asyncio changes. >> > > I originally tried with 3.5.0b2. > > This is a minimal example: import asyncio async def wait(): await asyncio.sleep(5) loop = asyncio.get_event_loop() loop.run_until_complete(wait()) Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs after those five seconds. It's 3.5.0b2 on Windows. Is it a bug? -------------- next part -------------- An HTML attachment was scrubbed... URL: From drekin at gmail.com Sat Jul 4 07:07:50 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Sat, 4 Jul 2015 13:07:50 +0200 Subject: An asyncio example In-Reply-To: References: Message-ID: > > On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa > wrote: > > > >>> 1) is there a way to close just one direction of the connection? > >> > >> No. SOCK_STREAM sockets are always bidirectional. > > > > socket.shutdown(socket.SHUT_WR) does the trick. > > > > I think the asyncio.StreamWriter.write_eof() is the high-level > > equivalent. > > I stand corrected. And you're also correct about write_eof: it causes > shutdown(SHUT_WR) to be called on the underlying socket once the > buffer has been written. > > > https://hg.python.org/cpython/file/34460219c0e0/Lib/asyncio/selector_events.py#l737 > > That said, just replacing the writer.close() with writer.write_eof() > in the OP's code doesn't seem to work; the server response comes back > empty. > > This works: > > >>> sock1, sock2 = socket.socketpair() > >>> sock1.send(b'REQUEST') > 7 > >>> sock1.shutdown(socket.SHUT_WR) > >>> sock2.recv(100) > b'REQUEST' > >>> sock2.send(b'RESPONSE') > 8 > >>> sock1.recv(100) > b'RESPONSE' > > And this works: > > import asyncio > import socket > > def server(sock): > request = yield from asyncio.get_event_loop().sock_recv(sock, 100) > print("got request {!r}".format(request)) > yield from asyncio.get_event_loop().sock_sendall(sock, b'RESPONSE') > > def client(sock): > yield from asyncio.get_event_loop().sock_sendall(sock, b'REQUEST') > sock.shutdown(socket.SHUT_WR) > response = yield from asyncio.get_event_loop().sock_recv(sock, 100) > print("got response {!r}".format(response)) > asyncio.get_event_loop().stop() > > def connect(): > clientsock, serversock = socket.socketpair() > clientsock.setblocking(False) > serversock.setblocking(False) > asyncio.async(client(clientsock)) > asyncio.async(server(serversock)) > > connect() > asyncio.get_event_loop().run_forever() > > I'm wondering whether there might be a bug in the higher-level > transport code that interferes with reading after calling write_eof. There is a bug. See http://bugs.python.org/issue24539 . -------------- next part -------------- An HTML attachment was scrubbed... URL: From mal at europython.eu Sat Jul 4 07:35:52 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Sat, 04 Jul 2015 13:35:52 +0200 Subject: EuroPython 2015 Keynote: Holger Krekel Message-ID: <5597C518.3020701@europython.eu> We are pleased to introduce our next keynote speaker for EuroPython 2015: Holger Krekel. He will be giving a keynote on Wednesday, July 22. About Holger Krekel ------------------- Holger is a prolific Python developer with a strong interest in communication: ?Socially this means engaging and co-organizing neighborhoods and technically it means i am interested in distributed systems and thriving to make available and built better communication machines for other people.? He also is a proud father and loves to dance to ?electronic swing? music. Python projects --------------- You will probably know Holger as author of the well-known pytest testing framework and co-founder the PyPy project: ?When i discovered Python I was thrilled by its high-level constructs and introspection facilities. I am still thrilled by the idea of dynamically deploying and executing high level programs on the net. In my view, Python and testing are a wonderfully productive combination for writing software. Out of this conviction, I founded and co-developed the PyPy project and maintain the pytest and tox testing tools. I also maintain a number of other projects, among the more popular are execnet for ad-hoc cross-interpreter communication and the py lib. Most of my code you find at bitbucket/hpk42.? The coding culture in almost all his projects consists of test- and documentation-driven development and applying meta programming techniques. The Keynote: Towards a more effective, decentralized web -------------------------------------------------------- In this talk, Holger will discuss the recent rise of immutable state concepts in languages and network protocols: ?The advent of hash-based data structures and replication strategies are shaking the client/server web service paradigm which rests on managing mutable state through HTTP. By contrast, building on git, bittorrent and other content addressed data structures provides for a more secure, efficient decentralized communication topology. There are projects, thoughts and talk to create new web standards to bring such technologies to mass deployment and fuel a new wave of decentralization. What can Python bring to the table?? Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From auriocus at gmx.de Sat Jul 4 08:18:24 2015 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sat, 04 Jul 2015 14:18:24 +0200 Subject: calculating entropy of image or alternative? In-Reply-To: References: Message-ID: Am 04.07.15 um 03:17 schrieb telmo bacile: > Hi list, I found a code that calculates entropy of images with > python that can be used for classifying interesting images from > uninteresting ones. Interesting images has more structured patterns > while uninsteresting are more noisy or completely homogeneous. > > I was thinking this code (entropy of image) can be used for measuring > the level of disorder of a group of points in the image. > For example: > Imagine that we have 3 images, each image has 6 dots, the first one > has very ordered dots , the second one have dots a little bit > disordered and the third one has very dissordered dots. > Then entropy of each image should measure the level of > dissorganization of the dots. Your question is not a Python question, it is about image processing. Therefore x-post and fup to comp.dsp. Since you seem to be using the mailing list, you can access comp.dsp via Google Groups: https://groups.google.com/forum/#!forum/comp.dsp > But the wierd thing is that when i experimented with this i got resuts > without sense. > The result i get is that the image with intermedium dissorder has > less entropy that the very ordered image . Do anybody have an idea > why im getting this result? Your model is too simple. Entropy by itself is not defined on bytes, but on a stream of symbols. Your program simply takes each pixel as a symbol. Therefore, the order is not considered at all! You could randomly shuffle all pixels, and still get the exact same result. Only the relative frequencies of the color is respected. In order to improve on that, and to take into account the distribution you would need to build a model. For example, you could predict each pixel value from the previous line and then send it to the encoder resp. the entropy calculation. This is what PNG does, for instance. As a rough estimate, you could compress your image using PNG and compare the file size. > Maybe im misunderstanding something. Is it possible to use entropy of > image to measure the level of dissorganization of a group of points in > an image? If not , is there is another method for doing this? In principle yes.... Christian > thanks in advance > > T. > > > > here is the code: > > import math > from PIL import Image > imageFile = 'int2.jpg' > print imageFile > im = Image.open(imageFile) > rgbHistogram = im.histogram() > print 'Snannon Entropy for Red, Green, Blue:' > for rgb in range(3): > totalPixels = sum(rgbHistogram[rgb * 256 : (rgb + 1) * 256]) > ent = 0.0 > for col in range(rgb * 256, (rgb + 1) * 256): > freq = float(rgbHistogram[col]) / totalPixels > if freq > 0: > ent = ent + freq * math.log(freq, 2) > ent = -ent > print ent > From drekin at gmail.com Sat Jul 4 08:20:01 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Sat, 4 Jul 2015 14:20:01 +0200 Subject: An asyncio example In-Reply-To: References: Message-ID: On Sat, Jul 4, 2015 at 1:07 PM, Adam Barto? wrote: > On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa >> wrote: >> > >> >>> 1) is there a way to close just one direction of the connection? >> >> >> >> No. SOCK_STREAM sockets are always bidirectional. >> > >> > socket.shutdown(socket.SHUT_WR) does the trick. >> > >> > I think the asyncio.StreamWriter.write_eof() is the high-level >> > equivalent. >> >> I stand corrected. And you're also correct about write_eof: it causes >> shutdown(SHUT_WR) to be called on the underlying socket once the >> buffer has been written. >> >> >> https://hg.python.org/cpython/file/34460219c0e0/Lib/asyncio/selector_events.py#l737 >> >> That said, just replacing the writer.close() with writer.write_eof() >> in the OP's code doesn't seem to work; the server response comes back >> empty. >> >> This works: >> >> >>> sock1, sock2 = socket.socketpair() >> >>> sock1.send(b'REQUEST') >> 7 >> >>> sock1.shutdown(socket.SHUT_WR) >> >>> sock2.recv(100) >> b'REQUEST' >> >>> sock2.send(b'RESPONSE') >> 8 >> >>> sock1.recv(100) >> b'RESPONSE' >> >> And this works: >> >> import asyncio >> import socket >> >> def server(sock): >> request = yield from asyncio.get_event_loop().sock_recv(sock, 100) >> print("got request {!r}".format(request)) >> yield from asyncio.get_event_loop().sock_sendall(sock, b'RESPONSE') >> >> def client(sock): >> yield from asyncio.get_event_loop().sock_sendall(sock, b'REQUEST') >> sock.shutdown(socket.SHUT_WR) >> response = yield from asyncio.get_event_loop().sock_recv(sock, 100) >> print("got response {!r}".format(response)) >> asyncio.get_event_loop().stop() >> >> def connect(): >> clientsock, serversock = socket.socketpair() >> clientsock.setblocking(False) >> serversock.setblocking(False) >> asyncio.async(client(clientsock)) >> asyncio.async(server(serversock)) >> >> connect() >> asyncio.get_event_loop().run_forever() >> >> I'm wondering whether there might be a bug in the higher-level >> transport code that interferes with reading after calling write_eof. > > > There is a bug. See http://bugs.python.org/issue24539 . > > The following code also works. import asyncio import socket async def server(reader, writer): print("server is starting") print("server is going to receive a request") request = (await reader.read()).decode() print("server received request {!r}".format(request)) response = "RESPONSE" writer.write(response.encode()) print("server sent response {!r}".format(response)) writer.write_eof() print("server sent EOF") print("server is finishing") async def client(reader, writer): print("client is starting") request = "REQUEST" writer.write(request.encode()) print("client sent request {!r}".format(request)) writer.write_eof() print("client sent EOF") print("client is going to receive a response") response = (await reader.read()).decode() print("client received response {!r}".format(response)) print("client is finishing") class FixedStreamReaderProtocol(asyncio.StreamReaderProtocol): def eof_received(self): super().eof_received() return True # keep alive async def open_connection(*, loop, sock): reader = asyncio.StreamReader(loop=loop) protocol = FixedStreamReaderProtocol(reader, loop=loop) transport, _ = await loop.create_connection(lambda: protocol, sock=sock) writer = asyncio.StreamWriter(transport, protocol, reader, loop) return reader, writer async def connect(loop): serversock, clientsock = socket.socketpair() reader, writer = await open_connection(sock=serversock, loop=loop) server_coro = server(reader, writer) reader, writer = await open_connection(sock=clientsock, loop=loop) client_coro = client(reader, writer) server_task = loop.create_task(server_coro) client_task = loop.create_task(client_coro) return server_task, client_task loop = asyncio.get_event_loop() server_task, client_task = loop.run_until_complete(connect(loop)) loop.run_until_complete(server_task) loop.run_until_complete(client_task) -------------- next part -------------- An HTML attachment was scrubbed... URL: From jt at toerring.de Sat Jul 4 10:58:26 2015 From: jt at toerring.de (Jens Thoms Toerring) Date: 4 Jul 2015 14:58:26 GMT Subject: installing libraries like numpy scipy matplotlib References: <44a89c97-38bb-4087-973a-0da56488b824@googlegroups.com> Message-ID: PIYUSH KUMAR wrote: > I have never used linux in my life.. only windows based computing.. So I > have problems in installing third party libraries in python. It depends. One question is if there's already a ready-for-use package for the third party library you want to install. If that is the case then the next question is which distro you're using - there are different package-management systems. Since you mentioned Pyke: if you got Ubuntu or Debian there's a package for it you can simply install it using the command sudo apt-get install python-pyke (The 'sudo' bit is for temporarily assuming the permissions to install the package, you're going to be asked for your password. 'apt-get' is the program for installing and de- installing packages. And 'python-pyke' is the name of the package._ If you also want the documentation installed add 'python-pyke-doc'. If you have some other distribution there might be a different program for installing new packages. And there's basically always also some program with a graphical user interface, wrapped around that and which shows you which packages exist (thousands). If there's no package for what you want you need to download the sources and install them yourself. For the details there usually is a file named README.txt and/or INSTALL.txt (or similar). Often all you need to use is the three commands ./configure make sudo make install If what you want to install depends on further software you also need to install that before creating and installing of what you need will succeed. So, again check if a ready-made package for that dependencies available or download, compile and install that. This can, in some cases, become a bit of work if A need B, B in turn need C and D, D needs E etc.;-) > So can somebody just explain me how many softwares or other python packages > I have to install before installing any of these. Sorry, but I don't understand this sentence. But in case for what you want to install there's a package for your distro you don't need to worry at all - all dependencies will get installed automatically (so if you want to install package A and that needs package B, B will installed automatically before A is installed). > I also had problems installing PYKE last month. What were these problems? Best regards, Jens -- \ Jens Thoms Toerring ___ jt at toerring.de \__________________________ http://toerring.de From pkpearson at nowhere.invalid Sat Jul 4 13:37:07 2015 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 4 Jul 2015 17:37:07 GMT Subject: Matplotlib X-axis timezone trouble [SOLVED] References: Message-ID: On Sat, 04 Jul 2015 07:29:45 +0300, Akira Li <4kir4.1i at gmail.com> wrote: > Peter Pearson writes: > >> The following code produces a plot with a line running from (9:30, 0) to >> (10:30, 1), not from (8:30, 0) to (9:30, 1) as I desire. >> >> If I use timezone None instead of pacific, the plot is as desired, but >> of course that doesn't solve the general problem of which this is a >> much-reduced example. >> >> If I use timezone US/Central, I get the same (bad) plot. >> >> import matplotlib.pyplot as plt >> import datetime >> import pytz >> pacific = pytz.timezone("US/Pacific") >> fig = plt.figure() >> plt.plot([datetime.datetime(2014, 10, 7, 8, 30, tzinfo=pacific), >> datetime.datetime(2014, 10, 7, 9, 30, tzinfo=pacific)], >> [0,1], marker="o", color="green") >> fig.autofmt_xdate() >> plt.show() >> >> Does anybody know why this shift is occurring? Is Matplotlib >> confused about what timezone to use in labeling the axis? How >> would I tell it what timezone to use (preferably explicitly in >> the code, not in matplotlibrc)? >> > > Your pytz usage is incorrect. > > Don't pass a pytz tzinfo object to the datetime construtor directly, use > `.localize()` method instead. Read the note at the very beginning of > pytz docs http://pytz.sourceforge.net/ Exactly. Thank you. For newcomers, the denouement of this thread is this: * Matplotlib had nothing to do with this problem, it was correctly displaying bad datetime.datetime values. * Python's datetime.datetime(..., tzinfo=timezone) is unreliable if timezone has daylight-saving time. * pytz's creators provide the localize() method specifically to remedy this problem. If you want to create a datetime object that has a timezone that might have daylight-saving time, use localize(). -- To email me, substitute nowhere->runbox, invalid->com. From sturla.molden at gmail.com Sat Jul 4 15:15:33 2015 From: sturla.molden at gmail.com (Sturla Molden) Date: Sat, 4 Jul 2015 19:15:33 +0000 (UTC) Subject: Should iPython Notebook replace Idle References: <6a451676-8487-4482-a903-4ad21b3f2470@googlegroups.com> Message-ID: <884302195457729835.344588sturla.molden-gmail.com@news.gmane.org> Jason Swails wrote: > Everything gets swallowed into Python. I can't imagine this ever happening. IPython's successor Jupyter is also an REPL environment for Julia and R, and many other languages will also be supported (e.g. Java and C++). Having this swallowed into Python is probably never going to happen. IIRC, the current release is the last to be named IPython. Sturla From tjreedy at udel.edu Sat Jul 4 16:22:41 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 4 Jul 2015 16:22:41 -0400 Subject: An asyncio example In-Reply-To: References: Message-ID: On 7/4/2015 3:04 AM, Adam Barto? wrote: > This is a minimal example: > > import asyncio > > async def wait(): > await asyncio.sleep(5) > > loop = asyncio.get_event_loop() > loop.run_until_complete(wait()) > > Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs > after those five seconds. It's 3.5.0b2 on Windows. Is it a bug? I asked on pydev list and was pointed to https://bugs.python.org/issue23057 (where treated as missing feature ). It is desired that this stop immediately on Windows as on Unix. I suggest you post your minimal example there. User interest in an issue being fixed and willingness to test patches can help motivate. Even more minimal: import asyncio loop = asyncio.get_event_loop() loop.run_forever also not interruptible, -- Terry Jan Reedy From tjreedy at udel.edu Sat Jul 4 16:29:22 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 4 Jul 2015 16:29:22 -0400 Subject: installing libraries like numpy scipy matplotlib In-Reply-To: References: <44a89c97-38bb-4087-973a-0da56488b824@googlegroups.com> Message-ID: On 7/4/2015 10:58 AM, Jens Thoms Toerring wrote: > PIYUSH KUMAR wrote: >> I have never used linux in my life.. only windows based computing.. So I >> have problems in installing third party libraries in python. The numpy and scipy projects create Windows binararies for all recent releases that are available on pypi.python.org and installed with pip install scipy for instance. Many other ditto. http://www.lfd.uci.edu/~gohlke/pythonlibs/ provides binaries for about a hundred popular packages. pip can access these also (see page header). -- Terry Jan Reedy From lac at openend.se Sat Jul 4 18:54:03 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 05 Jul 2015 00:54:03 +0200 Subject: Bug in floating point multiplication In-Reply-To: Message from "Steven D'Aprano" of "Fri, 03 Jul 2015 00:52:55 +1000." <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507042254.t64Ms3qW031538@theraft.openend.se> In a message of Fri, 03 Jul 2015 00:52:55 +1000, "Steven D'Aprano" writes: >Despite the title, this is not one of the usual "Why can't Python do >maths?" "bug" reports. > >Can anyone reproduce this behaviour? If so, please reply with the version of >Python and your operating system. Printing sys.version will probably do. > > >x = 1 - 1/2**53 >assert x == 0.9999999999999999 >for i in range(1, 1000000): > if int(i*x) == i: > print(i); break > > >Using Jython and IronPython, the loop runs to completion. That is the >correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and >3.3 on Centos and Debian, it prints 2049 and breaks. That should not >happen. If you can reproduce that (for any value of i, not necessarily >2049), please reply. > >See also http://bugs.python.org/issue24546 for more details. > > > >-- >Steven PyPy says: Python 2.7.9 (2.5.1+dfsg-1, Mar 27 2015, 19:45:43) [PyPy 2.5.1 with GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>> x = 1 - 1/2**53 >>>> assert x == 0.9999999999999999 Traceback (most recent call last): File "", line 1, in AssertionError >>>> for i in range(1, 1000000): .... if int(i*x) == i: .... print(i); break .... .... 1 >>>> So the loop terminates, but there is an Assertion Error. Did you want that? Laura From flebber.crue at gmail.com Sat Jul 4 20:08:54 2015 From: flebber.crue at gmail.com (Sayth Renshaw) Date: Sat, 4 Jul 2015 17:08:54 -0700 (PDT) Subject: Should iPython Notebook replace Idle In-Reply-To: References: <6a451676-8487-4482-a903-4ad21b3f2470@googlegroups.com> Message-ID: <4cb71077-97e8-4248-b9c0-0039b7c337fb@googlegroups.com> On Sunday, 5 July 2015 05:16:04 UTC+10, Sturla Molden wrote: > Jason Swails wrote: > > > Everything gets swallowed into Python. I can't imagine this ever happening. > > IPython's successor Jupyter is also an REPL environment for Julia and R, > and many other languages will also be supported (e.g. Java and C++). > Having this swallowed into Python is probably never going to happen. IIRC, > the current release is the last to be named IPython. > > Sturla Yeah I listened to the recent podcast talk python I believe and the creators of ipython & notebooks were on there and they were putting further improvements into it as they are using it in education for python and wanted to address some of the pain points so that it would be an improved environment for python. It will probably be that the learning environment for python but just not by default. sayth From flebber.crue at gmail.com Sat Jul 4 20:23:04 2015 From: flebber.crue at gmail.com (Sayth Renshaw) Date: Sat, 4 Jul 2015 17:23:04 -0700 (PDT) Subject: Can't call file from another - well correctly Message-ID: <0daf99ba-055c-473e-9517-61d64c4da7cb@googlegroups.com> I was playing with odo(blaze http://blaze.pydata.org/en/latest/) and wanted to use it with a current script I have been using on the command line. So my 2 scripts are below, I will explain here hopefully to keep question clearer what I have done. Script 2 works for me from the command line as python clean.py some.csv i wanted to use my script to fix up a bad csv and then use odo to a dataframe and hopefully build upon this later. When I run script 1 I get the error I need more than 1 value to unpack, which makes sense in that I have Script and Filename. ##Error### C:\Users\sayth\Repos\Notebooks>python odo_test.py Traceback (most recent call last): File "odo_test.py", line 3, in import clean File "C:\Users\sayth\Repos\Notebooks\clean.py", line 9, in SCRIPT, FILENAME = argv ValueError: need more than 1 value to unpack But if I change script2 to have just FILENAME = argv I get this error and I am not sure what to do. ##Error### C:\Users\sayth\Repos\Notebooks>python odo_test.py Traceback (most recent call last): File "odo_test.py", line 3, in import clean File "C:\Users\sayth\Repos\Notebooks\clean.py", line 62, in MY_FILE = out_file_name(FILENAME) File "C:\Users\sayth\Repos\Notebooks\clean.py", line 15, in out_file_name file_parts = file_name.split(".",) AttributeError: 'list' object has no attribute 'split' What can i do? ######Scripts ####### # Script 1 from odo import odo import pandas as pd import clean print(argv) myFile = race_table('20150704RHIL0.csv') odo(myFile, pd.DataFrame) # Script 2 import csv import re from sys import argv SCRIPT, FILENAME = argv #FILENAME = argv def out_file_name(file_name): """take an input file and keep the name with appended _clean""" file_parts = file_name.split(".",) output_file = file_parts[0] + '_clean.' + file_parts[1] return output_file def race_table(text_file): """utility to reorganise poorly made csv entry""" output_table = [] for record in text_file: if record[0] == 'Meeting': meeting = record[3] rail = record[6] weather = record[7] track = record[8] elif record[0] == 'Race': date = record[13] race = record[1] benchmark = record[4] distance = record[5] elif record[0] == 'Horse': number = record[1] name = record[2] jockey = record[6] barrier = record[7] weight = record[8] results = record[9] res_split = re.split('[- ]', results) starts = res_split[0] wins = res_split[1] seconds = res_split[2] thirds = res_split[3] try: prizemoney = res_split[4] except IndexError: prizemoney = 0 trainer = record[4] location = record[5] b_rating = record[15] sex = record[16] print(name, wins, seconds) output_table.append((meeting, date, rail, weather, track, distance, benchmark, race, number, name, sex, b_rating, weight, barrier, starts, wins, seconds, thirds, prizemoney, trainer, location, jockey )) return output_table MY_FILE = out_file_name(FILENAME) # with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: # for line in race_table(f_in.readline()): # new_row = line with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: CONTENT = csv.reader(f_in) # print(content) FILE_CONTENTS = race_table(CONTENT) # print new_name # f_out.write(str(FILE_CONTENTS)) headers = ['MEETING', 'DATE', 'RAIL', 'WEATHER', 'TRACK', 'DISTANCE', 'BENCHMARK', 'RACE', 'NUMBER', 'NAME', 'SEX', 'B_RATING', 'WEIGHT', 'BARRIER', 'STARTS', 'WINS', 'SECONDS', 'THIRDS', 'PRIZEMONEY', 'TRAINER', 'LOCATION', 'JOCKEY'] f_csv = csv.writer(f_out) f_csv.writerow(headers) f_csv.writerows(FILE_CONTENTS) # Old implementation for reference # input_table = [[item.strip(' "') for item in record.split(',')] # for record in text_file.splitlines()] # At this point look at input_table to find the record indices # identity = string.maketrans("", "") # print(input_table) # input_table = [s.translate(identity, ",'") for s # in input_table] if __name__ == '__main__': main() many thanks for your time. Sayth From lac at openend.se Sat Jul 4 20:27:22 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 05 Jul 2015 02:27:22 +0200 Subject: Searching for a usable X509 implementation In-Reply-To: Message from Dennis Jacobfeuerborn of "Fri, 03 Jul 2015 17:11:10 -0700." <46c64c5f-e5b5-4865-83e0-2474ebe4f8bd@googlegroups.com> References: <46c64c5f-e5b5-4865-83e0-2474ebe4f8bd@googlegroups.com> Message-ID: <201507050027.t650RMAp021068@theraft.openend.se> In a message of Fri, 03 Jul 2015 17:11:10 -0700, Dennis Jacobfeuerborn writes: >Hi, >I'm trying to implement certificate functionality in a python app but after fighting with pyOpenSSL and M2Crypto I'm thinking about writing wrapper functions for the OpenSSL command line tool instead or switching the app to another language all together. > >Apparently PyOpenSSL has no way to save a public key to a file which is baffling. M2Crypto has that ability but apparently no usable way to verify a certificate? PyOpenSSL does, you must have missed it when looking. You are looking for OpenSSL.crypto.dump_certificate(type, cert) Dump the certificate cert into a buffer string encoded with the type type. Laura From flebber.crue at gmail.com Sat Jul 4 22:38:39 2015 From: flebber.crue at gmail.com (Sayth Renshaw) Date: Sat, 4 Jul 2015 19:38:39 -0700 (PDT) Subject: Can't call file from another - well correctly In-Reply-To: <0daf99ba-055c-473e-9517-61d64c4da7cb@googlegroups.com> References: <0daf99ba-055c-473e-9517-61d64c4da7cb@googlegroups.com> Message-ID: On Sunday, 5 July 2015 10:23:17 UTC+10, Sayth Renshaw wrote: > I was playing with odo(blaze http://blaze.pydata.org/en/latest/) and wanted to use it with a current script I have been using on the command line. > > So my 2 scripts are below, I will explain here hopefully to keep question clearer what I have done. Script 2 works for me from the command line as > > python clean.py some.csv > > i wanted to use my script to fix up a bad csv and then use odo to a dataframe and hopefully build upon this later. > > When I run script 1 I get the error I need more than 1 value to unpack, which makes sense in that I have Script and Filename. > > ##Error### > C:\Users\sayth\Repos\Notebooks>python odo_test.py > Traceback (most recent call last): > File "odo_test.py", line 3, in > import clean > File "C:\Users\sayth\Repos\Notebooks\clean.py", line 9, in > SCRIPT, FILENAME = argv > ValueError: need more than 1 value to unpack > > But if I change script2 to have just FILENAME = argv I get this error and I am not sure what to do. > > ##Error### > C:\Users\sayth\Repos\Notebooks>python odo_test.py > Traceback (most recent call last): > File "odo_test.py", line 3, in > import clean > File "C:\Users\sayth\Repos\Notebooks\clean.py", line 62, in > MY_FILE = out_file_name(FILENAME) > File "C:\Users\sayth\Repos\Notebooks\clean.py", line 15, in out_file_name > file_parts = file_name.split(".",) > AttributeError: 'list' object has no attribute 'split' > > What can i do? > > ######Scripts ####### > > # Script 1 > > from odo import odo > import pandas as pd > import clean > > print(argv) > myFile = race_table('20150704RHIL0.csv') > > > odo(myFile, pd.DataFrame) > > # Script 2 > > import csv > import re > from sys import argv > SCRIPT, FILENAME = argv > #FILENAME = argv > > > def out_file_name(file_name): > """take an input file and keep the name with appended _clean""" > file_parts = file_name.split(".",) > output_file = file_parts[0] + '_clean.' + file_parts[1] > return output_file > > > def race_table(text_file): > """utility to reorganise poorly made csv entry""" > output_table = [] > for record in text_file: > if record[0] == 'Meeting': > meeting = record[3] > rail = record[6] > weather = record[7] > track = record[8] > elif record[0] == 'Race': > date = record[13] > race = record[1] > benchmark = record[4] > distance = record[5] > elif record[0] == 'Horse': > number = record[1] > name = record[2] > jockey = record[6] > barrier = record[7] > weight = record[8] > results = record[9] > res_split = re.split('[- ]', results) > starts = res_split[0] > wins = res_split[1] > seconds = res_split[2] > thirds = res_split[3] > try: > prizemoney = res_split[4] > except IndexError: > prizemoney = 0 > trainer = record[4] > location = record[5] > b_rating = record[15] > sex = record[16] > print(name, wins, seconds) > output_table.append((meeting, date, rail, weather, track, distance, > benchmark, race, number, name, sex, b_rating, > weight, barrier, starts, wins, seconds, > thirds, prizemoney, trainer, location, jockey > )) > return output_table > > MY_FILE = out_file_name(FILENAME) > > # with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: > # for line in race_table(f_in.readline()): > # new_row = line > with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: > CONTENT = csv.reader(f_in) > # print(content) > FILE_CONTENTS = race_table(CONTENT) > # print new_name > # f_out.write(str(FILE_CONTENTS)) > headers = ['MEETING', 'DATE', 'RAIL', 'WEATHER', 'TRACK', 'DISTANCE', > 'BENCHMARK', 'RACE', 'NUMBER', 'NAME', 'SEX', 'B_RATING', > 'WEIGHT', 'BARRIER', 'STARTS', 'WINS', 'SECONDS', 'THIRDS', > 'PRIZEMONEY', 'TRAINER', 'LOCATION', 'JOCKEY'] > > f_csv = csv.writer(f_out) > f_csv.writerow(headers) > f_csv.writerows(FILE_CONTENTS) > > > # Old implementation for reference > # input_table = [[item.strip(' "') for item in record.split(',')] > # for record in text_file.splitlines()] > # At this point look at input_table to find the record indices > # identity = string.maketrans("", "") > # print(input_table) > # input_table = [s.translate(identity, ",'") for s > # in input_table] > > if __name__ == '__main__': > main() > > > many thanks for your time. > > Sayth Solved it, well to sum extent by putting the whole clean.py into a function that called the others and then just called that. Sayth From zljubisic at gmail.com Sun Jul 5 01:31:02 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Sat, 4 Jul 2015 22:31:02 -0700 (PDT) Subject: Python 3 resuma a file download In-Reply-To: References: <9a629cf3-e256-494a-8ff8-3f1f6fc2218c@googlegroups.com> <4a7fae78-276e-42c6-9d84-1fddbeb99853@googlegroups.com> <36d1cf6d-9b99-4d38-8f07-83443bcd2f60@googlegroups.com> Message-ID: I have a working solution. :) The function below will download a file securely. Thank anyone who helped. I wouldn't be able to write this function without your help. I hope, someone else will benefit from our united work. Best regards. import os import urllib.request def Download(rfile, lfile): lsize = -1 rsize = -2 while True: try: if os.path.isfile(lfile): lsize = os.stat(lfile).st_size else: lsize = 0 req = urllib.request.Request(rfile) rsize = urllib.request.urlopen(req).length if lsize == rsize: break req.add_header('Range', "bytes={}-".format(lsize)) response = urllib.request.urlopen(req) with open(lfile, 'ab') as out_file: chunk = response.read(64 * 1024) if not chunk: break out_file.write(chunk) out_file.flush() lsize = os.stat(lfile).st_size prc_dloaded = round(lsize / rsize * 100, 2) print(prc_dloaded) if prc_dloaded == 100: break except ConnectionResetError as e: print('Exception ConnectionResetError {0} %'.format(prc_dloaded)) if lsize == rsize: retval = True else: retval = False return retval while not Download('http://video.hrt.hr/2906/otv296.mp4', 'otv296.mp4'): print('1') From lac at openend.se Sun Jul 5 01:33:13 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 05 Jul 2015 07:33:13 +0200 Subject: Searching for a usable X509 implementation In-Reply-To: Message from Laura Creighton of "Sun, 05 Jul 2015 02:27:22 +0200." <201507050027.t650RMAp021068@theraft.openend.se> References: <46c64c5f-e5b5-4865-83e0-2474ebe4f8bd@googlegroups.com><201507050027.t650RMAp021068@theraft.openend.se> Message-ID: <201507050533.t655XDl7020386@theraft.openend.se> In a message of Sun, 05 Jul 2015 02:27:22 +0200, Laura Creighton writes: >In a message of Fri, 03 Jul 2015 17:11:10 -0700, Dennis Jacobfeuerborn writes: >>Hi, >>I'm trying to implement certificate functionality in a python app but after fighting with pyOpenSSL and M2Crypto I'm thinking about writing wrapper functions for the OpenSSL command line tool instead or switching the app to another language all together. >> >>Apparently PyOpenSSL has no way to save a public key to a file which is baffling. M2Crypto has that ability but apparently no usable way to verify a certificate? > >PyOpenSSL does, you must have missed it when looking. >You are looking for OpenSSL.crypto.dump_certificate(type, cert) > Dump the certificate cert into a buffer string encoded with the type type. > >Laura Excuse me. I misunderstood your mail. You only want to save the public key, and not a certificate or a certificate request. I don't see a way to do this in PEM or ASN.1 format. For an RSA key in PEM format you can do: from OpenSSL.crypto import _new_mem_buf, _lib, _bio_to_string def dump_rsa_public_key(pkey): bio = _new_mem_buf() result = _lib.PEM_write_bio_RSAPublicKey(bio, _lib.EVP_PKEY_get1_RSA(pkey._ pkey)) # if result == 0: ERROR! Figure out what you want to do here ... return _bio_to_string(bio) There are similar things for other formats and DSA keys. The original version of PyOpenSSL was written by Martin Sj?gren, when he was working for me, and we had no need for such a thing at the time, since we just saved full certificates. You are right that it is very odd that nobody else has needed them since then, and this probably should be added to PyOpenSSL. Laura From lac at openend.se Sun Jul 5 02:25:38 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 05 Jul 2015 08:25:38 +0200 Subject: Looking up a dictionary _key_ by key? In-Reply-To: Message from Paul Rubin of "Tue, 23 Jun 2015 18:06:45 -0700." <87a8vpykwq.fsf@nightsong.com> References: <851th2t05t.fsf@benfinney.id.au> <87a8vpykwq.fsf@nightsong.com> Message-ID: <201507050625.t656PcIU030601@theraft.openend.se> In a message of Tue, 23 Jun 2015 18:06:45 -0700, Paul Rubin writes: >Chris Angelico writes: >>> Would I have to do an O(n) search to find my key? >> Iterate over it - it's an iterable view in Py3 - and compare. > >I think the question was whether the O(n) search could be avoided, not >how to do it. I don't see a way to avoid it. There is fundamental >brokenness in having unequal objects compare as equal, and the breakage >messes up the dictionary when those objects are used as keys. > >Solution is to either fix the object equality test, or wrap them in >something (maybe a tuple containing the objects and the distinguishing >fields that are missing from the original object's equality method) that >treats unequal objects as unequal. >-- >https://mail.python.org/mailman/listinfo/python-list This just showed up in my mailbox: Subject: [ANN] pyskiplist-1.0.0 From: Geert Jansen PySkipList is a fast, pure Python implementation of an indexable skiplist. It implements a SkipList data structure that provides an always sorted, list-like data structure for (key, value) pairs. ... more details including timing. For the full text see https://github.com/geertj/pyskiplist It's also available on PyPI. Looks to me as if he's fixed the 0(n) problem .... Laura From __peter__ at web.de Sun Jul 5 03:38:24 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 05 Jul 2015 09:38:24 +0200 Subject: Bug in floating point multiplication References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> <201507042254.t64Ms3qW031538@theraft.openend.se> Message-ID: Laura Creighton wrote: > In a message of Fri, 03 Jul 2015 00:52:55 +1000, "Steven D'Aprano" writes: >>Despite the title, this is not one of the usual "Why can't Python do >>maths?" "bug" reports. >> >>Can anyone reproduce this behaviour? If so, please reply with the version >>of Python and your operating system. Printing sys.version will probably >>do. >> >> >>x = 1 - 1/2**53 >>assert x == 0.9999999999999999 >>for i in range(1, 1000000): >> if int(i*x) == i: >> print(i); break >> >> >>Using Jython and IronPython, the loop runs to completion. That is the >>correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and >>3.3 on Centos and Debian, it prints 2049 and breaks. That should not >>happen. If you can reproduce that (for any value of i, not necessarily >>2049), please reply. >> >>See also http://bugs.python.org/issue24546 for more details. >> >> >> >>-- >>Steven > > PyPy says: > Python 2.7.9 (2.5.1+dfsg-1, Mar 27 2015, 19:45:43) > [PyPy 2.5.1 with GCC 4.9.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>>> x = 1 - 1/2**53 >>>>> assert x == 0.9999999999999999 > Traceback (most recent call last): > File "", line 1, in > AssertionError >>>>> for i in range(1, 1000000): > .... if int(i*x) == i: > .... print(i); break > .... > .... > 1 >>>>> > > So the loop terminates, but there is an Assertion Error. Did you want > that? No. Steven's environment implies from __future__ import division which he forgot to mention in the original post: >>>> x = 1-1/2**53 >>>> x 1 >>>> from __future__ import division >>>> x = 1-1/2**53 >>>> x 0.9999999999999999 From c.buhtz at posteo.jp Sun Jul 5 05:04:10 2015 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Sun, 5 Jul 2015 11:04:10 +0200 Subject: understanding why there is no setup.py uninstall Message-ID: <3mPPH002XKzFpWF@dovecot04.posteo.de> This question is not technical. I know that there is no 'uninstall' Option in a setup.py. I know this discussions and workarounds for that problem, too. I want to understand the design concept behind it. Why isn't there no uninstall routine implemented? For me as a user and admin it feels quite dirty when installing something with the setup.py but then not being able to remove it clean like I would do it with packages of my system-package-manager (e.g. with apt-get on a debianized system). From germanocarella.list at gmail.com Sun Jul 5 05:55:52 2015 From: germanocarella.list at gmail.com (germano carella) Date: Sun, 05 Jul 2015 11:55:52 +0200 Subject: Writing a python editor for blind developers Message-ID: <5598FF28.9000300@gmail.com> Hi to all, I'm new of this list. I'm Germano from Italy. I'm 39 and I'm a blind developer. I'm writing a python editor accessible to screen readers, with autocompletion support. So, when I write something, a context menu displays all option I can use. To do this, I'm using inspect module and pkgutil, and parsing docstring of builtin functions 'cause inspect.getargspec doesn't work with builtins. Now, when I instantiate a class, for example, I'd like to receive option on methods when I write name. ... I tired to use code.InteractiveConsole running in background. In this way, I can run source code every time I press enter and code.InteractiveConsole executes it in background. The problem is when I'm writing a function: InteractiveConsole executes it, but doesn't update her locals since I finish to write the function; so I can't retrieve local variables. There is an other way can you suggest me? Thanks! Germano From memilanuk at gmail.com Sun Jul 5 07:26:21 2015 From: memilanuk at gmail.com (memilanuk) Date: Sun, 05 Jul 2015 04:26:21 -0700 Subject: installing libraries like numpy scipy matplotlib In-Reply-To: References: <44a89c97-38bb-4087-973a-0da56488b824@googlegroups.com> Message-ID: On 07/04/2015 07:58 AM, Jens Thoms Toerring wrote: > PIYUSH KUMAR wrote: >> I have never used linux in my life.. only windows based computing.. So I >> have problems in installing third party libraries in python. > > It depends. One question is if there's already a ready-for-use > package for the third party library you want to install. If that > is the case then the next question is which distro you're using I could be wrong, but I think the point was that he's not using Linux, while the majority of instructions for getting and using various scientific libraries for Python assume that the user *is* using Linux. One option would be to run Linux from a VM... but another would be to use a 'packaged' version of Python such as Anaconda * or Enthought ** - they come ready to go with all the more popular scientific packages installed. They go to some lengths to address issues of package compatibility and dependencies - something that can be more of a pain on Windows than on Linux. * http://continuum.io/downloads ** https://www.enthought.com/products/epd/ -- Shiny! Let's be bad guys. Reach me @ memilanuk (at) gmail dot com From jt at toerring.de Sun Jul 5 08:21:26 2015 From: jt at toerring.de (Jens Thoms Toerring) Date: 5 Jul 2015 12:21:26 GMT Subject: installing libraries like numpy scipy matplotlib References: <44a89c97-38bb-4087-973a-0da56488b824@googlegroups.com> Message-ID: memilanuk wrote: > On 07/04/2015 07:58 AM, Jens Thoms Toerring wrote: > > PIYUSH KUMAR wrote: > >> I have never used linux in my life.. only windows based computing.. So I > >> have problems in installing third party libraries in python. > > > > It depends. One question is if there's already a ready-for-use > > package for the third party library you want to install. If that > > is the case then the next question is which distro you're using > I could be wrong, but I think the point was that he's not using Linux, > while the majority of instructions for getting and using various > scientific libraries for Python assume that the user *is* using Linux. Reading it the first time I understood it too mean that the OP is completely new to Linux (otherwise why mention Linux at all and not ask directly "How do I install something under Windows?"). But on second reading I see that it could also have beenmeant the other way round and it's not about Linux at all;-) Best regards, Jens -- \ Jens Thoms Toerring ___ jt at toerring.de \__________________________ http://toerring.de From drekin at gmail.com Sun Jul 5 10:29:19 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Sun, 5 Jul 2015 16:29:19 +0200 Subject: An asyncio example Message-ID: Terry Reedy wrote: > I suggest you post your minimal example there. User interest in an > issue being fixed and willingness to test patches can help motivate. I've done it. Thank you for help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at skjoldebrand.eu Sun Jul 5 12:45:26 2015 From: martin at skjoldebrand.eu (Martin S) Date: Sun, 05 Jul 2015 18:45:26 +0200 Subject: bottle app "crashes" Message-ID: <1744901.sz0qzmb0Nj@homedragon> Hi all, Last summer I fumbled together a small appplication that calculates both LASK and Elo ratings for chess. I managed to "webify" it using Bottle. This works nicely on my laptop for testing. However ... (you knew there would be a however right) Once I log off (or my user session times out) my server where I've started the application with python3 LASKweb.py & the application dies within a minute, resulting in clients getting 404 errors when accessing the page (a simple table that's processed by the application). I've tried installting bottle deamon but I keep getting errors to the effect that it doesn't recognize bottledeamon. Also I've tried to run as a wsgi application, but I seem to missunderstand what modifications I need to do the get it to run (I get server misconfiguration errors on the latter). Do anyone have a pointer to an idiot proof instruction on how to deploy a simple bottle application to a live server. /Martin S From larry at hastings.org Sun Jul 5 13:20:07 2015 From: larry at hastings.org (Larry Hastings) Date: Sun, 05 Jul 2015 10:20:07 -0700 Subject: [RELEASED] Python 3.5.0b3 is now available Message-ID: <55996747.2030203@hastings.org> On behalf of the Python development community and the Python 3.5 release team, I'm relieved to announce the availability of Python 3.5.0b3. Python 3.5 has now entered "feature freeze". By default new features may no longer be added to Python 3.5. This is a preview release, and its use is not recommended for production settings. An important reminder for Windows users about Python 3.5.0b3: if installing Python 3.5.0b2 as a non-privileged user, you may need to escalate to administrator privileges to install an update to your C runtime libraries. You can find Python 3.5.0b2 here: https://www.python.org/downloads/release/python-350b3/ Happy hacking, //arry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Sun Jul 5 16:36:25 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 5 Jul 2015 15:36:25 -0500 Subject: (side-)effects and ... In-Reply-To: References: Message-ID: <20150705153625.263a3b21@bigbox.christie.dr> On 2015-07-05 20:29, Stefan Ram wrote: > But why do we not have a common and well-known term for > the counterpart, that something does not modify the state > of the world, but that the state of the world does > influence the value (behaviour) of a call such as > ?datetime.datetime.now().time()?? I believe the term is "idempotent" https://en.wikipedia.org/wiki/Idempotent_function#Computer_science_meaning -tkc From python.list at tim.thechases.com Sun Jul 5 16:37:56 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 5 Jul 2015 15:37:56 -0500 Subject: (side-)effects and ... In-Reply-To: <20150705153625.263a3b21@bigbox.christie.dr> References: <20150705153625.263a3b21@bigbox.christie.dr> Message-ID: <20150705153756.43b466f9@bigbox.christie.dr> On 2015-07-05 15:36, Tim Chase wrote: > On 2015-07-05 20:29, Stefan Ram wrote: > > But why do we not have a common and well-known term for > > the counterpart, that something does not modify the state > > of the world, but that the state of the world does > > influence the value (behaviour) of a call such as > > ?datetime.datetime.now().time()?? > > I believe the term is "idempotent" > > https://en.wikipedia.org/wiki/Idempotent_function#Computer_science_meaning Though I've also heard the term "pure function" for a similar meaning. https://en.wikipedia.org/wiki/Pure_function -tkc From tjreedy at udel.edu Sun Jul 5 19:12:40 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 5 Jul 2015 19:12:40 -0400 Subject: (side-)effects and ... In-Reply-To: References: Message-ID: On 7/5/2015 4:29 PM, Stefan Ram wrote: > And this is the intention of my post: Maybe there is such > a term, and I just missed to learn it so far? So, > do you know a term for the phenomenon that can be found > in Python but not in mathematics and consists in the state > of the world influencing the value of an expressions? non-determinate state-dependent In mathematics, 'pure' functions defined in terms of named functions, such as def f(x): return exp(sin(2*pi*x) + cos(2*pi*x)) are actually namespace dependent, but this is not counted as the local namespace (which here must contain exp, pi, sin, and cos) is considered to be write-once, read-forever. -- Terry Jan Reedy From robert.kern at gmail.com Sun Jul 5 19:44:19 2015 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 06 Jul 2015 00:44:19 +0100 Subject: (side-)effects and ... In-Reply-To: <20150705153625.263a3b21@bigbox.christie.dr> References: <20150705153625.263a3b21@bigbox.christie.dr> Message-ID: On 2015-07-05 21:36, Tim Chase wrote: > On 2015-07-05 20:29, Stefan Ram wrote: >> But why do we not have a common and well-known term for >> the counterpart, that something does not modify the state >> of the world, but that the state of the world does >> influence the value (behaviour) of a call such as >> ?datetime.datetime.now().time()?? > > I believe the term is "idempotent" > > https://en.wikipedia.org/wiki/Idempotent_function#Computer_science_meaning No, "idempotent" means that if it changes the state, then applying it twice or more has the same effect as applying it once. For example, calling object.__setattr__(self, attr, y) with the same arguments is idempotent; whether you execute that once, twice or N times, afterwards, `getattr(self, attr) is y`. But calling it the first time probably did make a change of state. This is unlike functions like list.append(self, x) which will give you different results depending on the number of times you call it, even if the arguments are the same. Functions that don't change state at all are naturally idempotent, but many idempotent functions do change state. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From rosuav at gmail.com Sun Jul 5 20:38:54 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Jul 2015 10:38:54 +1000 Subject: (side-)effects and ... In-Reply-To: References: Message-ID: On Mon, Jul 6, 2015 at 6:29 AM, Stefan Ram wrote: > But why do we not have a common and well-known term for > the counterpart, that something does not modify the state > of the world, but that the state of the world does > influence the value (behaviour) of a call such as > ?datetime.datetime.now().time()?? > > And this is the intention of my post: Maybe there is such > a term, and I just missed to learn it so far? So, > do you know a term for the phenomenon that can be found > in Python but not in mathematics and consists in the state > of the world influencing the value of an expressions? The Pike optimizer short-cuts this by flagging such functions as "have side effects". As far as optimizers are concerned, there's not a lot of difference between print() and time(); both of them need to be called every time they're written (unlike, for instance, math.sin(1) which can be called once and then replaced with its result, as it's a pure function). Not sure this helps, but it might indicate why there's no real term for it - "side effects" kinda can be stretched to mean both directions. ChrisA From ron3200 at gmail.com Sun Jul 5 22:50:56 2015 From: ron3200 at gmail.com (Ron Adam) Date: Sun, 05 Jul 2015 22:50:56 -0400 Subject: (side-)effects and ... In-Reply-To: References: Message-ID: On 07/05/2015 04:29 PM, Stefan Ram wrote: > But why do we not have a common and well-known term for > the counterpart, that something does not modify the state > of the world, but that the state of the world does > influence the value (behaviour) of a call such as > ?datetime.datetime.now().time()?? > > And this is the intention of my post: Maybe there is such > a term, and I just missed to learn it so far? So, > do you know a term for the phenomenon that can be found > in Python but not in mathematics and consists in the state > of the world influencing the value of an expressions? Variables that are changed from an outside environment are "Volatile". https://en.wikipedia.org/wiki/Volatile_%28computer_programming%29 It isn't used in python, though I think maybe it should be. Cheers, Ron From rosuav at gmail.com Mon Jul 6 04:23:24 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Jul 2015 18:23:24 +1000 Subject: understanding why there is no setup.py uninstall In-Reply-To: <3mPPH002XKzFpWF@dovecot04.posteo.de> References: <3mPPH002XKzFpWF@dovecot04.posteo.de> Message-ID: On Sun, Jul 5, 2015 at 7:04 PM, wrote: > This question is not technical. > I know that there is no 'uninstall' Option in a setup.py. > I know this discussions and workarounds for that problem, too. > > > I want to understand the design concept behind it. > > Why isn't there no uninstall routine implemented? > > For me as a user and admin it feels quite dirty when installing > something with the setup.py but then not being able to remove it clean > like I would do it with packages of my system-package-manager (e.g. with > apt-get on a debianized system). If you want a package manager, don't use setup.py itself - use pip, which does have an uninstallation feature. Alternatively, use a virtual environment, which means installations happen there rather than into the system directory - you can clean it up just by wiping out one tree. ChrisA From kwpolska at gmail.com Mon Jul 6 04:25:54 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Mon, 6 Jul 2015 10:25:54 +0200 Subject: understanding why there is no setup.py uninstall In-Reply-To: <3mPPH002XKzFpWF@dovecot04.posteo.de> References: <3mPPH002XKzFpWF@dovecot04.posteo.de> Message-ID: On 5 July 2015 at 11:04, wrote: > This question is not technical. > I know that there is no 'uninstall' Option in a setup.py. > I know this discussions and workarounds for that problem, too. > > > I want to understand the design concept behind it. > > Why isn't there no uninstall routine implemented? > > For me as a user and admin it feels quite dirty when installing > something with the setup.py but then not being able to remove it clean > like I would do it with packages of my system-package-manager (e.g. with > apt-get on a debianized system). > -- > https://mail.python.org/mailman/listinfo/python-list Don?t use setup.py, use pip. If you are working with a pypi package, just use pip install foo. If you have a local package, you can point pip to a tarball, or to an unpacked directory: $ pip install foo-0.1.0.tar.gz $ pip install /home/kwpolska/bar $ cd baz; pip install . pip has an uninstall option. (It should also work with packages installed with plain setup.py.) -- Chris Warrick PGP: 5EAAEA16 From jonas at wielicki.name Mon Jul 6 04:26:33 2015 From: jonas at wielicki.name (Jonas Wielicki) Date: Mon, 6 Jul 2015 10:26:33 +0200 Subject: Bug in floating point multiplication In-Reply-To: References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559A3BB9.3050802@wielicki.name> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 02.07.2015 19:29, Jason Swails wrote: > // maths.h #include #include > > int main() { double x; int i; x = 1-pow(0.5, 53); > > for (i = 1; i < 1000000; i++) { if ((int)(i*x) == i) { > printf("%d\n", i); break; } } > > return 0; } Does not show the problem on either -m32 or normal on my Fedora 22, 64-bit with any of: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (inside a qemu though, where it shows "Intel Core Processor (Haswell)") Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz Unfortunately, I fried my AMD Bulldozer last week, so I cannot check there. regards, jonas -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCgAGBQJVmjunAAoJEMBiAyWXYliKzDwP+wcCn9AW7EdZ/gHEmw6vW9sL MFUszpPQ3+HYPLuMn35tAy31GDozCBHze8AISHzL0oWCj6u1x7z4gxY0MKaAsRuh Gp5R5W+KHpE0tYps65SHUFUxCvf5YSR4vao6PeUMsSNxdCZ5HVa6dPpdYe0wWho4 D+6HV5RT7LCKC4+u1iNrJL3ldBPCH73+0FY0IajC0/w3QDCOpQEUVRKDCQdARq3W I4FYeU3I3jfUH7694gUgRDECYt16k53G3dU2J5r+ZXmFX6SUWxgL3McXdxpUpGZo VnPGcvMeWEq1qRxkREphGtgaMz+NxX8im9jp9RZX3KD7uWSecEt4SrQJavLejRWg vb0i+pe3Df64bT+1in4JxHV6UlEdULA+0/pP+S9OyYzydKDzPBWBuFe23WjsdDJi sdRrUHCAyAr7sulfOiU92q+/ROgCW+sCD83TNFQdQ/kNsaXioYmW3Rc7jOoWPetN Uqq6ezZqkfUmichqggZi5ogyDUyfLvfHoe3dpecun95ArTcsZXpVW8kddP3kYANv 3zldmQfTjCzDWc2EPCpRfs9gFn7AaWM9t4jiyIStTQoYId7mHcRbTmb2DwT/XsPY Ulopha+6PhkGw0ejmbFYx2juvOZlSegTRhHnRe/+9QRtfpyqOFjHB92ai+g3H/g6 NSN8EA+7w3sc8/r31k7O =7GrS -----END PGP SIGNATURE----- From breamoreboy at yahoo.co.uk Mon Jul 6 04:33:17 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 06 Jul 2015 09:33:17 +0100 Subject: understanding why there is no setup.py uninstall In-Reply-To: <3mPPH002XKzFpWF@dovecot04.posteo.de> References: <3mPPH002XKzFpWF@dovecot04.posteo.de> Message-ID: On 05/07/2015 10:04, c.buhtz at posteo.jp wrote: > This question is not technical. > I know that there is no 'uninstall' Option in a setup.py. > I know this discussions and workarounds for that problem, too. > > > I want to understand the design concept behind it. I haven't the faintest idea, sorry :( > > Why isn't there no uninstall routine implemented? > > For me as a user and admin it feels quite dirty when installing > something with the setup.py but then not being able to remove it clean > like I would do it with packages of my system-package-manager (e.g. with > apt-get on a debianized system). > pip (un)install xyz suits me fine on Windows, but then I'm a one stop shop. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From ben+python at benfinney.id.au Mon Jul 6 04:34:11 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 06 Jul 2015 18:34:11 +1000 Subject: understanding why there is no setup.py uninstall References: <3mPPH002XKzFpWF@dovecot04.posteo.de> Message-ID: <85vbdxy9a4.fsf@benfinney.id.au> writes: > I want to understand the design concept behind it. > Why isn't there no uninstall routine implemented? What form of answer are you looking for? Will you be disappointed if the answer entails (as I fear it must) ?because no-one put in the sustained effort to make it work?? If you merely want to know the sequence of events that led to the situation, you'll need to go digging through the history of Distutils. If, on the other hand, you are feeling wronged and want someone to take responsibility and justify their actions: > For me as a user and admin it feels quite dirty when installing > something with the setup.py but then not being able to remove it clean > like I would do it with packages of my system-package-manager (e.g. > with apt-get on a debianized system). ? then I think you'll find it more productive to realise we *do* have a better system now. Part of the better system is that we have the Python Packaging Authority which didn't exist when Distutils was designed. Read the documents there and I hope you'll be glad at the improvement! More specifically, an important part of the better system is that we now have Pip , which is the PyPA recommended tool for end-users to install *and* uninstall Python packages. Hopefully by the time you're done with that, you won't need anyone to justify their actions to you any more :-) -- \ ?I used to be an airline pilot. I got fired because I kept | `\ locking the keys in the plane. They caught me on an 80 foot | _o__) stepladder with a coathanger.? ?Steven Wright | Ben Finney From joseph.lee22590 at gmail.com Mon Jul 6 04:42:47 2015 From: joseph.lee22590 at gmail.com (Joseph Lee) Date: Mon, 6 Jul 2015 01:42:47 -0700 Subject: Writing a python editor for blind developers In-Reply-To: <5598FF28.9000300@gmail.com> References: <5598FF28.9000300@gmail.com> Message-ID: <002e01d0b7c7$bcd5fda0$3681f8e0$@gmail.com> Hi Germano and others, First, sorry for this abrupt post without an intro (I'll write a more proper intro next time) and a possible repeat message. Second, as a blind developer and a regular contributor to a Python-based screen reader, I can say that many of us (blind devs) use IDE's nor Python-specific editors. For our Python tasks, we use a regular text editor such as Notepad++, and some had success with Visual Studio Python plug-in and/or Eclipse. Some people were looking at making IDLE itself accessible to no avail (the way IDLE displays its output is such that it makes it hard for screen readers to use their display parsing techniques to tell a programmer what's on screen). This gets more interesting when blind Pythoneers (such as myself) write GUI apps such as those using WXPython (NonVisual Desktop Access, or NVDA, the Python-based screen reader is a WXPython app) and PyQT (apps powered by QT 5 is accessible). There exists a list like this for blind Pythoneers at: http://www.freelists.org/list/pythonvis For more info on NVDA, go to: http://www.nvaccess.org P.S. A very short intro: I'm Joseph, a blind Pythoneer and regular code and translations contributor to NonVisual Desktop Access (NVDA) screen reader project. I have studied computer science (no degree) and have been speaking Python for about three years and spoke C++ prior to joining NVDA project in 2012. In NVDA project, I tend to work mostly on supporting new operating systems, translations, braille display input/output and touchscreen support. Cheers, Josep -----Original Message----- From: Python-list [mailto:python-list-bounces+joseph.lee22590=gmail.com at python.org] On Behalf Of germano carella Sent: Sunday, July 5, 2015 2:56 AM To: python-list at python.org Subject: Writing a python editor for blind developers Hi to all, I'm new of this list. I'm Germano from Italy. I'm 39 and I'm a blind developer. I'm writing a python editor accessible to screen readers, with autocompletion support. So, when I write something, a context menu displays all option I can use. To do this, I'm using inspect module and pkgutil, and parsing docstring of builtin functions 'cause inspect.getargspec doesn't work with builtins. Now, when I instantiate a class, for example, I'd like to receive option on methods when I write name. ... I tired to use code.InteractiveConsole running in background. In this way, I can run source code every time I press enter and code.InteractiveConsole executes it in background. The problem is when I'm writing a function: InteractiveConsole executes it, but doesn't update her locals since I finish to write the function; so I can't retrieve local variables. There is an other way can you suggest me? Thanks! Germano -- https://mail.python.org/mailman/listinfo/python-list From jacob at blindza.co.za Mon Jul 6 05:33:14 2015 From: jacob at blindza.co.za (Jacob Kruger) Date: Mon, 6 Jul 2015 11:33:14 +0200 Subject: Writing a python editor for blind developers In-Reply-To: <5598FF28.9000300@gmail.com> References: <5598FF28.9000300@gmail.com> Message-ID: <077420C6F9C34C768FA14B18BF4855FC@JacobPC> Germano, answering email at top of mail, since think that's the preferred method for some of us. I am also a 100% blind developer, and python is also one of my focus areas. While don't think can really help with this part of development as of yet, I would be more than willing to help with feedback, etc., and can also put you in touch with various other blind developers who do also work with python, etc. For example, AFAIK, the primary blind programmers mailing list is program-l at freelists.org, and besides me, there are a few other python developers on that list as well. Stay well Jacob Kruger Blind Biker Skype: BlindZA "Roger Wilco wants to welcome you...to the space janitor's closet..." ----- Original Message ----- From: "germano carella" To: Sent: Sunday, July 05, 2015 11:55 AM Subject: Writing a python editor for blind developers > Hi to all, > I'm new of this list. > I'm Germano from Italy. I'm 39 and I'm a blind developer. > I'm writing a python editor accessible to screen readers, with > autocompletion support. > So, when I write something, a context menu displays all option I can use. > To do this, I'm using inspect module and pkgutil, and parsing docstring of > builtin functions 'cause inspect.getargspec doesn't work with builtins. > Now, when I instantiate a class, for example, I'd like to receive option > on methods when I write name. ... > I tired to use code.InteractiveConsole running in background. > In this way, I can run source code every time I press enter and > code.InteractiveConsole executes it in background. > The problem is when I'm writing a function: InteractiveConsole executes > it, but doesn't update her locals since I finish to write the function; so > I can't retrieve local variables. > There is an other way can you suggest me? > Thanks! > Germano > -- > https://mail.python.org/mailman/listinfo/python-list > From vek.m1234 at gmail.com Mon Jul 6 05:36:29 2015 From: vek.m1234 at gmail.com (Veek M) Date: Mon, 06 Jul 2015 15:06:29 +0530 Subject: requests.Session() how do you set 'replace' on the encoding? References: Message-ID: dieter wrote: > Veek M writes: >> UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in >> position 8: illegal multibyte sequence > > You give us very little context. It's a longish chunk of code: basically, i'm trying to download using the 'requests.Session' module and that should give me Unicode once it's told what encoding is being used 'gbk'. def get_page(s, url): print(url) r = s.get(url, headers = { 'User-Agent' : user_agent, 'Keep-Alive' : '3600', 'Connection' : 'keep-alive', }) s.encoding='gbk' text = r.text return text # Open output file fh=codecs.open('/tmp/out', 'wb') fh.write(header) # Download s = requests.Session() ------------ If 'text' is NOT proper unicode because the server introduced some junk, then when i do anchor.getparent() on my 'text' it'll traceback.. ergo the question, how do i set a replacement char within 'requests' > In general: when you need control over encoding handling because > deep in a framework an econding causes problems (as apparently in > your case), you can usually first take the plain text, > fix any encoding problems and only then pass the fixed text to > your framework. > >> I'm doing: >> s = requests.Session() >> to suck data in, so.. how do i 'replace' chars that fit gbk > > It does not seem that the problem occurs inside the "requests" module. > Thus, you have a chance to "intercept" the downloaded text > and fix encoding problems. Okay, so i should use the 'raw' method in requests and then clean up the raw-text and then convert that to unicode.. vs trying to do it using 'requests'? The thing is 'codec's has a xmlcharrefreplace_errors(...) etc so i figured if output has clean up, input ought to have it :p From vek.m1234 at gmail.com Mon Jul 6 05:40:34 2015 From: vek.m1234 at gmail.com (Veek M) Date: Mon, 06 Jul 2015 15:10:34 +0530 Subject: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop? References: Message-ID: Saran Ahluwalia wrote: > So what did you do to resolve this? Please provide your fix. This is an > excellent case study for others. it's provided, what part didn't you understand? Try googling relative-path, wth? From breamoreboy at yahoo.co.uk Mon Jul 6 06:19:19 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 06 Jul 2015 11:19:19 +0100 Subject: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop? In-Reply-To: References: Message-ID: On 06/07/2015 10:40, Veek M wrote: > Saran Ahluwalia wrote: > >> So what did you do to resolve this? Please provide your fix. This is an >> excellent case study for others. > it's provided, what part didn't you understand? Try googling relative-path, > wth? > If it's provided why have you snipped it this time around? May I most humbly suggest that the next time you ask, please ensure that you tell us what you've googled for prior to putting your question. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From lac at openend.se Mon Jul 6 08:28:57 2015 From: lac at openend.se (Laura Creighton) Date: Mon, 06 Jul 2015 14:28:57 +0200 Subject: (side-)effects and ... In-Reply-To: Message from ram@zedat.fu-berlin.de (Stefan Ram) of "05 Jul 2015 20:29:11 +0000." References: Message-ID: <201507061228.t66CSvw2019266@fido.openend.se> > And this is the intention of my post: Maybe there is such > a term, and I just missed to learn it so far? So, > do you know a term for the phenomenon that can be found > in Python but not in mathematics and consists in the state > of the world influencing the value of an expressions? In the world of control logic, this sort of thing is needed a whole lot. One common way to go after this behaviour (the temperature of the room determines whether the heater or the air conditioner goes on, for instance) is to use Fuzzy Control Logic. https://en.wikipedia.org/wiki/Fuzzy_control_system https://en.wikipedia.org/wiki/Fuzzy_logic Python has a bunch of packages for doing this, but I haven't ever used them, so cannot comment on how good any of them are. Laura From lac at openend.se Mon Jul 6 08:55:05 2015 From: lac at openend.se (Laura Creighton) Date: Mon, 06 Jul 2015 14:55:05 +0200 Subject: (side-)effects and ... In-Reply-To: Message from ram@zedat.fu-berlin.de (Stefan Ram) of "05 Jul 2015 20:29:11 +0000." References: Message-ID: <201507061255.t66Ct59a019994@fido.openend.se> In a message of 05 Jul 2015 20:29:11 +0000, Stefan Ram writes: > But why do we not have a common and well-known term for > the counterpart, that something does not modify the state > of the world, but that the state of the world does > influence the value (behaviour) of a call such as > ?datetime.datetime.now().time()?? ... to continue from the earlier post, I had a phone call and wrapped it up too soon .... However, fuzzy logic is only one way to get such an effect. You can get the same using Neural Nets and some sort of learning algorithm. https://en.wikipedia.org/wiki/Artificial_neural_network Or you can try some sort of Genetic algorithm see: https://en.wikipedia.org/wiki/Genetic_algorithm These ways to go after the same problem And we have Python packages for this, too. The thing is that these things, aside from being suitable for a whole lot of problems where you really want the outside environment to influence the result of your code, don't have a lot in common. So, among practicioners of these arts -- mostly found designing AI and control systems -- there doesn't seem to be a pressing need for a general term that includes any of these. And, at least in the area of control systems, there is a real problem with the testing of such things. They have this unfortunate habit of producing results that were undreamed of by their creators, which is not what you want in the control system for your high-speed train -- or especially if you are the insurance underwriters for that same train. So there is rather more effort spent on going the other way -- writing code that does the job but which is less and less dependent on outside factors than in finding ways to include more outside factors in the code we already have. Laura From oscar.j.benjamin at gmail.com Mon Jul 6 09:14:10 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Mon, 06 Jul 2015 13:14:10 +0000 Subject: Writing a python editor for blind developers In-Reply-To: <5598FF28.9000300@gmail.com> References: <5598FF28.9000300@gmail.com> Message-ID: Hi Germano, You may want to use the jedi package which you can find at this link: https://pypi.python.org/pypi/jedi/ I'm not personally involved with the jedi package but I use it within my own editor Vim and my understanding is that it should be useful for Python autocompletion support in any IDE. It uses static analysis to infer the types of variables e.g. an instance of a class so that it can complete the methods for that class. -- Oscar On Mon, 6 Jul 2015 at 09:22 germano carella wrote: > Hi to all, > I'm new of this list. > I'm Germano from Italy. I'm 39 and I'm a blind developer. > I'm writing a python editor accessible to screen readers, with > autocompletion support. > So, when I write something, a context menu displays all option I can use. > To do this, I'm using inspect module and pkgutil, and parsing docstring > of builtin functions 'cause inspect.getargspec doesn't work with builtins. > Now, when I instantiate a class, for example, I'd like to receive option > on methods when I write name. ... > I tired to use code.InteractiveConsole running in background. > In this way, I can run source code every time I press enter and > code.InteractiveConsole executes it in background. > The problem is when I'm writing a function: InteractiveConsole executes > it, but doesn't update her locals since I finish to write the function; > so I can't retrieve local variables. > There is an other way can you suggest me? > Thanks! > Germano > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar.j.benjamin at gmail.com Mon Jul 6 11:44:00 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Mon, 06 Jul 2015 15:44:00 +0000 Subject: Bug in floating point multiplication In-Reply-To: References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, 4 Jul 2015 at 02:12 Jason Swails wrote: > On Fri, Jul 3, 2015 at 11:13 AM, Oscar Benjamin < > oscar.j.benjamin at gmail.com> wrote: > >> On 2 July 2015 at 18:29, Jason Swails wrote: >> >> Where is the 32 bit one looks like: >> >> $ objdump -d a.out.32 | less >> ... > > 804843e: fildl -0x14(%ebp) >> 8048441: fmull -0x10(%ebp) >> 8048444: fnstcw -0x1a(%ebp) >> 8048447: movzwl -0x1a(%ebp),%eax >> 804844b: mov $0xc,%ah >> 804844d: mov %ax,-0x1c(%ebp) >> 8048451: fldcw -0x1c(%ebp) >> 8048454: fistpl -0x20(%ebp) >> 8048457: fldcw -0x1a(%ebp) >> 804845a: mov -0x20(%ebp),%eax >> 804845d: cmp -0x14(%ebp),%eax >> 8048460: jne 8048477 >> 8048462: sub $0x8,%esp >> 8048465: pushl -0x14(%ebp) >> 8048468: push $0x8048520 >> 804846d: call 80482f0 >> 8048472: add $0x10,%esp >> 8048475: jmp 8048484 >> 8048477: addl $0x1,-0x14(%ebp) >> 804847b: cmpl $0xf423f,-0x14(%ebp) >> 8048482: jle 804843e >> ... >> >> So the 64 bit one is using SSE instructions and the 32-bit one is >> using x87. That could explain the difference you see at the C level >> but I don't see it on this CPU (/proc/cpuinfo says Intel(R) Core(TM) >> i5-3427U CPU @ 1.80GHz). >> > > ?Hmm. Well that could explain why you don't get the same results as me. > My CPU is a > AMD FX(tm)-6100 Six-Core Processor > ? (from /proc/cpuinfo). My objdump looks the same as yours for the 64-bit > version, but for 32-bit it looks like: > So if we have different generated machine instructions it suggests a difference in the way it was compiled rather than in the hardware itself. (Although it could be that the compilers were changed because the hardware was inconsistent in this particular usage). > However, I have no experience looking at raw assembler, so I can't discern > what it is I'm even looking at (nor do I know what explicit SSE > instructions look like in assembler). > The give away is that SSE instructions use the XMM registers so where you see %xmm0 etc data is being loaded ready for SSE instructions. I'll translate the important part of the 32 bit code below: ... 804843a: db 44 24 14 fildl 0x14(%esp) ?? FILDL - F is for float and indicates that this is an x87 instruction. LD is for load and indicates that we want to load from memory to the x87 register stack. The I is for integer: we're loading from int format. I can't remember what the L suffix means. This instruction will load the integer from the memory stack at offset 0x14 from the stack pointer (esp) pushing it onto the x87 stack. Since the x87 stack uses 80-bit extended-real precision format internally this instruction performs a format conversion. The conversion should be lossless as 80-bit FP uses a 64 bit mantissa so it should be able to represent any 64-bit signed or unsigned integer (we're only using 32 bits in this example). ? 804843e: dc 4c 24 18 fmull 0x18(%esp) FMULL (x87 multiply) - This multiplies the top of the x87 stack (the number we previously stored) by the 64 bit float at 0x18 stack offset. In context that's the number 1-.5**53 which was presumably calculated earlier. The top of the x87 stack is overwritten with the result. This calculation is performed using 80-bit floating point with a 64 bit mantissa. ? 8048442: dd 5c 24 08 fstpl 0x8(%esp) FSTPL (x87 store and pop) - Pop the top of the x87 stack pushing to the memory stack. This is storing the result of the multiplication back to RAM (0x8 from stack) as a 64 bit float. Since it was internally stored as an 80-bit float there is a format conversion here that can lose precision. Rounding can occur according to the settings in the x87 control word. ? 8048446: f2 0f 2c 44 24 08 cvttsd2si 0x8(%esp),%eax This converts the 64 bit float stored at 0x8 from stack to a signed int, truncating if inexact, and stores the result in register eax. This operation is guaranteed to truncate (rather than floor etc) if it needs to round. ? 804844c: 3b 44 24 14 cmp 0x14(%esp),%eax This compares the result of the above processing (now stored in eax) with the int we started with (still at offset 0x14 from stack). The cmp instruction sets flags ready for the jne instruction below. ? 8048450: 75 16 jne 8048468 JNE (jump if not equal) - this is the branching instruction. If the previously compared values are unequal we skip forward to 8048468 otherwise we execute the instructions below which call printf and jmp (break) out of the loop. ? 8048452: 8b 44 24 14 mov 0x14(%esp),%eax ? 8048456: 89 44 24 04 mov %eax,0x4(%esp) ? 804845a: c7 04 24 10 85 04 08 movl $0x8048510,(%esp) ? 8048461: e8 8a fe ff ff call 80482f0 ? 8048466: eb 0f jmp 8048477 This is where the jne goes. We increment the int and jump (jle) back to the top of the loop (unless the loop is finished). ? 8048468: 83 44 24 14 01 addl $0x1,0x14(%esp) ? 804846d: 81 7c 24 14 3f 42 0f cmpl $0xf423f,0x14(%esp) ? 8048474: 00 ? 8048475: 7e c3 jle 804843a ...? ? My suspicion falls on the FSTPL instruction. The rounding behaviour there depends on the rounding flags set in the x87 control word which have not been explicitly controlled here. The calculation we want to perform cannot be performed exactly in 64 bit floating point: >>> from fractions import Fraction as F >>> x = 1-.5**53 >>> F(x)*F(2049) == F(x*2049) False This is because the true result cannot be represented as a 64 bit float. Instead the result comes out to the nearest available float: >>> float(F(x)*F(2049)) == x*2049 True This means that the x87 register will be storing a higher precision result in its 80 bit format. This result will have to be rounded by the FSTPL instruction. If you look at the assembly output I showed you'll see the instructions FNSTCW/FLDCW (x87 store/load control word) which are used to manipulate the control word to tell the FPU how to perform this kind of rounding. The fact that we don't see it in your compiled output could indicate a C compiler bug which could in turn explain the different behaviour people see from Python. To understand exactly why 2049 is the number where it fails consider that it is the smallest integer that requires 12 bits of mantissa in floating point format. The number 1-.5**53 has a mantissa that is 53 ones: >>> x = 1-.5**53 >>> x.hex() '0x1.fffffffffffffp-1' When extended to 80 bit real-extended format with a 64 bit mantissa it will have 11 trailing zeros. So I think multiplication of x with any integer less than 2049 can be performed exactly by the FMULL instruction. I haven't fully considered what impact that would have but it seems reasonable that this is why 2049 is the first number that fails. -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Mon Jul 6 12:29:16 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 6 Jul 2015 11:29:16 -0500 Subject: (side-)effects and ... In-Reply-To: References: <20150705153625.263a3b21@bigbox.christie.dr> Message-ID: <20150706112916.1635bd9d@bigbox.christie.dr> On 2015-07-06 00:44, Robert Kern wrote: >> I believe the term is "idempotent" > > No, "idempotent" means that if it changes the state, then applying > it twice or more has the same effect as applying it once. Ah, thanks for the clarification. -tkc From webuser1200 at gmail.com Mon Jul 6 14:36:50 2015 From: webuser1200 at gmail.com (webuser1200 at gmail.com) Date: Mon, 6 Jul 2015 11:36:50 -0700 (PDT) Subject: Best practices for writing jobs run through cron Message-ID: I needed help/advice with a few things: 1. Is there a good example of a well written command line task that gets run routinely from the shell. Job would handle logging and be able to redirect stdout to a stdout file and stderr to a stderr file. 2. I was going to setup a dict with all jobs and a unique identifier for each job. Then I would use the filesystem to capture output form each job. Jobs output would be redirected to _yyyymmddhhmmss_start.stdout and _yyyymmddhhmmss_end.stderr 3. Each script would know it's job id and would load the setup dict at start time and see if it still needs to be run or not. If not and it is still trying to run, and error would be sent. 4. A web interface would look at the file system and generate a list of job runs and show errors etc. 5. A task would run end of the week which archive old runs of jobs by moving directories over to an archive folder. I'd like to lean towards simplicity... Are there other examples that I should be looking at? Any thoughts on the above setup? Regards, WU From jason.swails at gmail.com Mon Jul 6 14:46:13 2015 From: jason.swails at gmail.com (Jason Swails) Date: Mon, 6 Jul 2015 14:46:13 -0400 Subject: Bug in floating point multiplication In-Reply-To: References: <55955048$0$1662$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jul 6, 2015 at 11:44 AM, Oscar Benjamin wrote: > On Sat, 4 Jul 2015 at 02:12 Jason Swails wrote: > >> On Fri, Jul 3, 2015 at 11:13 AM, Oscar Benjamin < >> oscar.j.benjamin at gmail.com> wrote: >> >>> On 2 July 2015 at 18:29, Jason Swails wrote: >>> >>> Where is the 32 bit one looks like: >>> >>> $ objdump -d a.out.32 | less >>> ... >>> >> 804843e: fildl -0x14(%ebp) >>> 8048441: fmull -0x10(%ebp) >>> 8048444: fnstcw -0x1a(%ebp) >>> 8048447: movzwl -0x1a(%ebp),%eax >>> 804844b: mov $0xc,%ah >>> 804844d: mov %ax,-0x1c(%ebp) >>> 8048451: fldcw -0x1c(%ebp) >>> 8048454: fistpl -0x20(%ebp) >>> 8048457: fldcw -0x1a(%ebp) >>> 804845a: mov -0x20(%ebp),%eax >>> 804845d: cmp -0x14(%ebp),%eax >>> 8048460: jne 8048477 >>> 8048462: sub $0x8,%esp >>> 8048465: pushl -0x14(%ebp) >>> 8048468: push $0x8048520 >>> 804846d: call 80482f0 >>> 8048472: add $0x10,%esp >>> 8048475: jmp 8048484 >>> 8048477: addl $0x1,-0x14(%ebp) >>> 804847b: cmpl $0xf423f,-0x14(%ebp) >>> 8048482: jle 804843e >>> ... >>> >>> So the 64 bit one is using SSE instructions and the 32-bit one is >>> using x87. That could explain the difference you see at the C level >>> but I don't see it on this CPU (/proc/cpuinfo says Intel(R) Core(TM) >>> i5-3427U CPU @ 1.80GHz). >>> >> >> ?Hmm. Well that could explain why you don't get the same results as me. >> My CPU is a >> AMD FX(tm)-6100 Six-Core Processor >> ? (from /proc/cpuinfo). My objdump looks the same as yours for the >> 64-bit version, but for 32-bit it looks like: >> > > So if we have different generated machine instructions it suggests a > difference in the way it was compiled rather than in the hardware itself. > (Although it could be that the compilers were changed because the hardware > was inconsistent in this particular usage). > ?I had assumed that the different compilations resulted from different underlying hardware (i.e., the instructions used on the Intel chip were either unavailable, or somehow deemed heuristically inferior on the AMD chip).? > > >> However, I have no experience looking at raw assembler, so I can't >> discern what it is I'm even looking at (nor do I know what explicit SSE >> instructions look like in assembler). >> > > The give away is that SSE instructions use the XMM registers so where you > see %xmm0 etc data is being loaded ready for SSE instructions. I'll > translate the important part of the 32 bit code below: > ?Oh of course. I *have* seen/worked with code that uses routines from xmmintrin.h, so I should've been able to piece the xmm together with the SSE instructions. ? > [ > ?snip]? > This means that the x87 register will be storing a higher precision result > in its 80 bit format. This result will have to be rounded by the FSTPL > instruction. > > If you look at the assembly output I showed you'll see the instructions > FNSTCW/FLDCW (x87 store/load control word) which are used to manipulate the > control word to tell the FPU how to perform this kind of rounding. The fact > that we don't see it in your compiled output could indicate a C compiler > bug which could in turn explain the different behaviour people see from > Python. > > To understand exactly why 2049 is the number where it fails consider that > it is the smallest integer that requires 12 bits of mantissa in floating > point format. The number 1-.5**53 has a mantissa that is 53 ones: > > >>> x = 1-.5**53 > >>> x.hex() > '0x1.fffffffffffffp-1' > > When extended to 80 bit real-extended format with a 64 bit mantissa it > will have 11 trailing zeros. So I think multiplication of x with any > integer less than 2049 can be performed exactly by the FMULL instruction. I > haven't fully considered what impact that would have but it seems > reasonable that this is why 2049 is the first number that fails. > ?Wow. Great discussion and description -- I'm convinced.? Thanks a lot, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Mon Jul 6 15:05:54 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 06 Jul 2015 12:05:54 -0700 Subject: (side-)effects and ... In-Reply-To: References: Message-ID: <559AD192.5040902@stoneleaf.us> On 07/05/2015 01:29 PM, Stefan Ram wrote: > The function ?datetime.datetime.now().time()? does not yield > a value that is determined by the expression ?time()?; > instead its value can /differ/ between two calls even when the > call ?time()? does not differ. In mathematics, however, a > call to a function that is given by a term such as ?cos( 0 )? > always has the /same/ value. The input to time() is the result of datetime.datetime.now(); is it datetime.datetime.now() that is being influenced by the world. -- ~Ethan~ From juanny.gee at gmail.com Mon Jul 6 15:16:41 2015 From: juanny.gee at gmail.com (Juan Gutierrez) Date: Mon, 6 Jul 2015 12:16:41 -0700 (PDT) Subject: Best practices for writing jobs run through cron In-Reply-To: References: Message-ID: <1c7c07c8-8735-42b1-8a6b-463fe3b5467c@googlegroups.com> Hi WU, It sounds like you want to add a lot of helpful transparency into your task runner which is awesome, however, have you taken a look at Celery? http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html Celery also comes with a monitoring tool (Flower - http://celery.readthedocs.org/en/latest/userguide/monitoring.html?highlight=flower#flower-real-time-celery-web-monitor) This may satisfy what you're looking for without having to write your own management and monitoring system. Hope this helps! From dfnsonfsduifb at gmx.de Mon Jul 6 15:24:59 2015 From: dfnsonfsduifb at gmx.de (Johannes Bauer) Date: Mon, 06 Jul 2015 21:24:59 +0200 Subject: Searching for a usable X509 implementation In-Reply-To: References: <46c64c5f-e5b5-4865-83e0-2474ebe4f8bd@googlegroups.com><201507050027.t650RMAp021068@theraft.openend.se> Message-ID: On 05.07.2015 07:33, Laura Creighton wrote: > For an RSA key in PEM format you can do: > from OpenSSL.crypto import _new_mem_buf, _lib, _bio_to_string > > def dump_rsa_public_key(pkey): > bio = _new_mem_buf() > result = _lib.PEM_write_bio_RSAPublicKey(bio, _lib.EVP_PKEY_get1_RSA(pkey._ > pkey)) > # if result == 0: ERROR! Figure out what you want to do here ... > return _bio_to_string(bio) Oooooh, hacky :-) > The original version of PyOpenSSL was written by Martin Sj?gren, when > he was working for me, and we had no need for such a thing at the time, > since we just saved full certificates. You are right that it is very > odd that nobody else has needed them since then, and this probably > should be added to PyOpenSSL. Sadly my impression is that pyOpenSSL development is slow at best. I've had an issue with it a while back and was missing some feature which someone else had already suggested. It kindof was some back and forth in their bugtracker and then all discussion died. IIRC (and my memory may be wrong) it was about the ability to check signatures of one certificate against a well-defined truststore (especially against only one to identify parent certificates by crypto). I was frustrated back then about the indecisiveness and wrote my own wrapper around the functions I needed and was done with it. Best regards, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht ?ffentlich! Ah, der neueste und bis heute genialste Streich unsere gro?en Kosmologen: Die Geheim-Vorhersage. - Karl Kaos ?ber R?diger Thomas in dsa From none at mailinator.com Mon Jul 6 15:28:54 2015 From: none at mailinator.com (mm0fmf) Date: Mon, 06 Jul 2015 20:28:54 +0100 Subject: bottle app "crashes" In-Reply-To: References: Message-ID: On 05/07/2015 17:45, Martin S wrote: > Hi all, > > Last summer I fumbled together a small appplication that calculates both LASK > and Elo ratings for chess. I managed to "webify" it using Bottle. This works > nicely on my laptop for testing. > [snip] > > Do anyone have a pointer to an idiot proof instruction on how to deploy a > simple bottle application to a live server. > > /Martin S > I use bottle as it comes to provide 2 apps that face straight onto the web. I have to say that I have only done half the job because I never got as far as daemonising them. I simply run them from a "screen" session. This is fine as they run on my own teeny-tiny Linux VM (256MB ram/5GB disk with 1 Xeon core). I simply log in and type "screen python3 myapp.py" and remember to exit with ctrl-A D. One of them has been up for about 3 months now without issue. That might not explain why you are seeing problems but could give you a solution that works whilst you fix the underlying issue. Or not in my case! Andy From mvoicem at gmail.com Mon Jul 6 16:09:40 2015 From: mvoicem at gmail.com (m) Date: Mon, 06 Jul 2015 22:09:40 +0200 Subject: bottle app "crashes" In-Reply-To: References: Message-ID: <559ae082$0$27507$65785112@news.neostrada.pl> W dniu 06.07.2015 o 21:28, mm0fmf pisze: > On 05/07/2015 17:45, Martin S wrote: >> > Hi all, >> > >> > Last summer I fumbled together a small appplication that calculates both LASK >> > and Elo ratings for chess. I managed to "webify" it using Bottle. This works >> > nicely on my laptop for testing. >> > > [snip] > >> > >> > Do anyone have a pointer to an idiot proof instruction on how to deploy a >> > simple bottle application to a live server. >> > >> > /Martin S >> > > I use bottle as it comes to provide 2 apps that face straight onto the > web. I have to say that I have only done half the job because I never > got as far as daemonising them. I simply run them from a "screen" > session. This is fine as they run on my own teeny-tiny Linux VM (256MB > ram/5GB disk with 1 Xeon core). > > I simply log in and type "screen python3 myapp.py" and remember to exit > with ctrl-A D. I would suggest using supervisor. p. m. From agustin.cruz at gmail.com Mon Jul 6 17:31:37 2015 From: agustin.cruz at gmail.com (Agustin Cruz) Date: Mon, 6 Jul 2015 14:31:37 -0700 (PDT) Subject: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi Message-ID: <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> I'm working on a Python - Raspberry Pi project in which I need to take about 30 images per second (no movie) and stack each 2D image to a 3D array using numpy array, without saving each 2D capture as a file (because is slow). I found this Python code to take images as fast as possible, but i don't know how to stack all images fast to a 3D stack of images. import io import time import picamera #from PIL import Image def outputs(): stream = io.BytesIO() for i in range(40): # This returns the stream for the camera to capture to yield stream # Once the capture is complete, the loop continues here # (read up on generator functions in Python to understand # the yield statement). Here you could do some processing # on the image... #stream.seek(0) #img = Image.open(stream) # Finally, reset the stream for the next capture stream.seek(0) stream.truncate() with picamera.PiCamera() as camera: camera.resolution = (640, 480) camera.framerate = 80 time.sleep(2) start = time.time() camera.capture_sequence(outputs(), 'jpeg', use_video_port=True) finish = time.time() print('Captured 40 images at %.2ffps' % (40 / (finish - start))) Does anyone of you know how to stack the 2D images taken in this code to a 3D numpy array using Python and the Raspberry Pi camera module? Without saving each 2D capture as a file Best regards, Agust?n From breamoreboy at yahoo.co.uk Mon Jul 6 17:59:53 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 06 Jul 2015 22:59:53 +0100 Subject: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi In-Reply-To: <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> References: <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> Message-ID: On 06/07/2015 22:31, Agustin Cruz wrote: > I'm working on a Python - Raspberry Pi project in which I need to take about 30 images per second (no movie) and stack each 2D image to a 3D array using numpy array, without saving each 2D capture as a file (because is slow). > > I found this Python code to take images as fast as possible, but i don't know how to stack all images fast to a 3D stack of images. > > import io > import time > import picamera > #from PIL import Image > > def outputs(): > stream = io.BytesIO() > for i in range(40): > # This returns the stream for the camera to capture to > yield stream > # Once the capture is complete, the loop continues here > # (read up on generator functions in Python to understand > # the yield statement). Here you could do some processing > # on the image... > #stream.seek(0) > #img = Image.open(stream) > # Finally, reset the stream for the next capture > stream.seek(0) > stream.truncate() > > with picamera.PiCamera() as camera: > camera.resolution = (640, 480) > camera.framerate = 80 > time.sleep(2) > start = time.time() > camera.capture_sequence(outputs(), 'jpeg', use_video_port=True) > finish = time.time() > print('Captured 40 images at %.2ffps' % (40 / (finish - start))) > > Does anyone of you know how to stack the 2D images taken in this code to a 3D numpy array using Python and the Raspberry Pi camera module? Without saving each 2D capture as a file > > Best regards, Agust?n > http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is the first hit on google for "numpy 3d array stack". -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From agustin.cruz at gmail.com Mon Jul 6 19:16:05 2015 From: agustin.cruz at gmail.com (Agustin Cruz) Date: Mon, 6 Jul 2015 16:16:05 -0700 (PDT) Subject: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi In-Reply-To: References: <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> Message-ID: <9647ca9f-3b8c-48e2-b422-338654c3b4fb@googlegroups.com> On Monday, July 6, 2015 at 6:00:42 PM UTC-4, Mark Lawrence wrote: > On 06/07/2015 22:31, Agustin Cruz wrote: > > I'm working on a Python - Raspberry Pi project in which I need to take about 30 images per second (no movie) and stack each 2D image to a 3D array using numpy array, without saving each 2D capture as a file (because is slow). > > > > I found this Python code to take images as fast as possible, but i don't know how to stack all images fast to a 3D stack of images. > > > > import io > > import time > > import picamera > > #from PIL import Image > > > > def outputs(): > > stream = io.BytesIO() > > for i in range(40): > > # This returns the stream for the camera to capture to > > yield stream > > # Once the capture is complete, the loop continues here > > # (read up on generator functions in Python to understand > > # the yield statement). Here you could do some processing > > # on the image... > > #stream.seek(0) > > #img = Image.open(stream) > > # Finally, reset the stream for the next capture > > stream.seek(0) > > stream.truncate() > > > > with picamera.PiCamera() as camera: > > camera.resolution = (640, 480) > > camera.framerate = 80 > > time.sleep(2) > > start = time.time() > > camera.capture_sequence(outputs(), 'jpeg', use_video_port=True) > > finish = time.time() > > print('Captured 40 images at %.2ffps' % (40 / (finish - start))) > > > > Does anyone of you know how to stack the 2D images taken in this code to a 3D numpy array using Python and the Raspberry Pi camera module? Without saving each 2D capture as a file > > > > Best regards, Agust?n > > > > http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is > the first hit on google for "numpy 3d array stack". > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence Hi Mark, I know the dstack function can do the job, but i don't know how to implement it in this case. From tjreedy at udel.edu Mon Jul 6 19:52:38 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 6 Jul 2015 19:52:38 -0400 Subject: Writing a python editor for blind developers In-Reply-To: <002e01d0b7c7$bcd5fda0$3681f8e0$@gmail.com> References: <5598FF28.9000300@gmail.com> <002e01d0b7c7$bcd5fda0$3681f8e0$@gmail.com> Message-ID: On 7/6/2015 4:42 AM, Joseph Lee wrote: > Some people were looking at making IDLE itself accessible to > no avail (the way IDLE displays its output is such that it makes it hard for > screen readers to use their display parsing techniques to tell a programmer > what's on screen). Idle itself is not the issue. It (currently) displays output (and gets input) by calling tkinter wrapper functions that interface to the cross-platform tcl/tk gui framework. I believe that just about everything written to tk can be read back by other functions. If there is an accessibility module written in Python, I imagine that an alternate tkinter-based backend could be written. I imagine that the reader could then be incorporated into a tkinter app with an import and startup call. I would be willing to help with the tkinter part of such a backend, and test with Idle. -- Terry Jan Reedy From zhouwtlord at gmail.com Mon Jul 6 21:23:42 2015 From: zhouwtlord at gmail.com (Weitao) Date: Tue, 7 Jul 2015 09:23:42 +0800 Subject: Best practices for writing jobs run through cron In-Reply-To: <1c7c07c8-8735-42b1-8a6b-463fe3b5467c@googlegroups.com> References: <1c7c07c8-8735-42b1-8a6b-463fe3b5467c@googlegroups.com> Message-ID: <32B81626-7E83-4B1F-B23F-962EE5994B6D@gmail.com> BTW?You can also manage your celery cron against Django admin page?if you want. Django+Celery will give you more. ???? iPhone > ? 2015?7?7??03:16?Juan Gutierrez ??? > > Hi WU, > > It sounds like you want to add a lot of helpful transparency into your task runner which is awesome, however, have you taken a look at Celery? > > http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html > > Celery also comes with a monitoring tool (Flower - http://celery.readthedocs.org/en/latest/userguide/monitoring.html?highlight=flower#flower-real-time-celery-web-monitor) > > This may satisfy what you're looking for without having to write your own management and monitoring system. > > Hope this helps! > -- > https://mail.python.org/mailman/listinfo/python-list From ryanshuell at gmail.com Mon Jul 6 23:17:34 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Mon, 6 Jul 2015 20:17:34 -0700 (PDT) Subject: Trying to import numpy Message-ID: I'm trying to use numpy. I get this error: >>> import numpy as np Traceback (most recent call last): File "", line 1, in import numpy as np ImportError: No module named numpy I followed the instructions here. https://pip.pypa.io/en/latest/installing.html In the c-prompt, I get this error. C:\>python get-pip.py python: can't open file 'get-pip.py': [Errno 2] No such file or directory In python 2.7, I get this error. >>> python get-pip.py SyntaxError: invalid syntax I would say 100% of my errors come from importing python modules. If this every worked, I could do some real work. Instead, I spend 100% of my time trying to make thing that don't work, work. I've already added ';C:\Python27' to the Path under Variable Name. Of course, this makes no difference whatsoever. Ugh. Any thoughts? Anyone? Thanks. From jsf80238 at gmail.com Mon Jul 6 23:57:21 2015 From: jsf80238 at gmail.com (Jason Friedman) Date: Mon, 6 Jul 2015 21:57:21 -0600 Subject: bottle app "crashes" In-Reply-To: <1744901.sz0qzmb0Nj@homedragon> References: <1744901.sz0qzmb0Nj@homedragon> Message-ID: > Last summer I fumbled together a small appplication that calculates both LASK > and Elo ratings for chess. I managed to "webify" it using Bottle. This works > nicely on my laptop for testing. > > Once I log off (or my user session times out) my server where I've started the > application with python3 LASKweb.py & the application dies within a minute, > resulting in clients getting 404 errors when accessing the page (a simple > table that's processed by the application). Similar to other answers here, I do not know why your application stops serving, but I have had success using waitress (https://pypi.python.org/pypi/waitress) with bottle (http://bottlepy.org/docs/dev/deployment.html#switching-the-server-backend). From torriem at gmail.com Tue Jul 7 00:38:15 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 06 Jul 2015 22:38:15 -0600 Subject: Trying to import numpy In-Reply-To: References: Message-ID: <559B57B7.7070702@gmail.com> On 07/06/2015 09:17 PM, ryguy7272 wrote: > I followed the instructions here. > https://pip.pypa.io/en/latest/installing.html > > > In the c-prompt, I get this error. > C:\>python get-pip.py > python: can't open file 'get-pip.py': [Errno 2] No such file or directory Is get-pip.py located in c:\? You have to specify the path to the location where you saved get-pip.py: C:\>python \path\to\get-pip.py Where \path\to is the path of where ever you placed the downloaded file. You did download get-pip.py, right? It's not clear from your post. I can safely say that importing modules works very well for most people. I assume you mean that you have errors trying to download and install third-party modules. Hopefully we can get you over this hurdle. From rosuav at gmail.com Tue Jul 7 01:04:46 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 7 Jul 2015 15:04:46 +1000 Subject: Trying to import numpy In-Reply-To: References: Message-ID: On Tue, Jul 7, 2015 at 1:17 PM, ryguy7272 wrote: > I would say 100% of my errors come from importing python modules. If this every worked, I could do some real work. Instead, I spend 100% of my time trying to make thing that don't work, work. > I could equally say that 100% of your errors come from working on Windows, and that if you were on a different OS, you could do some real work. Or I could probably point out that 100% of your errors come from using the internet, and that if you had a completely stand-alone system, you could do some real work. You're blaming importing on circumstantial evidence here, and that's not exactly fair. Start by making sure you have Python 2.7.9 or better (and yes, 3.4 counts as "better"). It should come with pip already installed. ChrisA From dieter at handshake.de Tue Jul 7 01:38:19 2015 From: dieter at handshake.de (dieter) Date: Tue, 07 Jul 2015 07:38:19 +0200 Subject: requests.Session() how do you set 'replace' on the encoding? References: Message-ID: <87lheseddg.fsf@handshake.de> Veek M writes: > dieter wrote: > >> Veek M writes: >>> UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in >>> position 8: illegal multibyte sequence >> >> You give us very little context. > > It's a longish chunk of code: basically, i'm trying to download using the > 'requests.Session' module and that should give me Unicode once it's told > what encoding is being used 'gbk'. > > def get_page(s, url): > print(url) > r = s.get(url, headers = { > 'User-Agent' : user_agent, > 'Keep-Alive' : '3600', > 'Connection' : 'keep-alive', > }) > s.encoding='gbk' It looks strange that you can set "s.encoding" after you have called "s.get" - but, as you apparently get an error related to the "gbk" encoding, it seems to work. > text = r.text > return text > > # Open output file > fh=codecs.open('/tmp/out', 'wb') > fh.write(header) > > # Download > s = requests.Session() > ------------ > > If 'text' is NOT proper unicode because the server introduced some junk, > then when i do anchor.getparent() on my 'text' it'll traceback.. > ergo the question, how do i set a replacement char within 'requests' I see the following options for you: * you look at the code (of "requests.Session"), determine where the "s.encoding" is taken care of and look around whether there it also support a replacement strategy. Then, you use this knowledge to set up your replacement. * you avoid the "unicode" translating functionality of "requests.Session". If it does not immediately supports this, you can trick it using the "iso-8859-1" encoding (this maps bytes to the first 256 unicode codepoints in a one-to-one way) and then do the unicode handling in your own code -- with facilities you already know of (including replacement) * you contact the website administrator and ask him why the delivered pages do not contain valid "gbk" content. From trentonwesley10 at gmail.com Tue Jul 7 02:08:48 2015 From: trentonwesley10 at gmail.com (trentonwesley10 at gmail.com) Date: Mon, 6 Jul 2015 23:08:48 -0700 (PDT) Subject: Why pay DICE When TheGongzuo.com is !! FREE !! Message-ID: <51204369-c3e0-4c83-b0d3-345b63046425@googlegroups.com> Greetings! You been Invited as a Beta User for TheGongzuo.com ( Absolutely Extended Trial). We bring to you TheGongzuo.com, Top notch highly talented IT (Information Technology / Software Industry) skilled Professional Candidates, where you can find more than a resume. ________________________________________ For a NO COST TRIAL all you have to do is: * Register & Post only 1 Active Job. * Start interacting with more 100,000 IT professionals and Innovators/Ideators. ________________________________________ Before you get started , there are few things you should know, 1. We are getting better :- We will be updating our site with new material daily basis and we welcome your feedback on newly added material. Please send us your feedback by using Feedback option on the site or send us an email @ support at thegongzuo.com. 2. We like Criticism :- As a fresh site, We are sure you can find lots to Criticize - remember , though we would prefer constructive criticism, so we can make site better. Please send us your valuable criticism by email @ support at thegongzuo.com. ________________________________________ Please make us a part of your distribution list, We will start sending resumes to you. If you do not wish to be a part of our mailing list just reply to us with unsubscribe from this list or else it will consider it as your consent to be part of our distribution list. ________________________________________ Thanks for trying TheGongzuo.com and please let us know , What you think ! Thanks, TheGongzuo.com Team ! From breamoreboy at yahoo.co.uk Tue Jul 7 02:49:25 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 07 Jul 2015 07:49:25 +0100 Subject: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi In-Reply-To: <9647ca9f-3b8c-48e2-b422-338654c3b4fb@googlegroups.com> References: <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> <9647ca9f-3b8c-48e2-b422-338654c3b4fb@googlegroups.com> Message-ID: On 07/07/2015 00:16, Agustin Cruz wrote: > On Monday, July 6, 2015 at 6:00:42 PM UTC-4, Mark Lawrence wrote: >> On 06/07/2015 22:31, Agustin Cruz wrote: >>> I'm working on a Python - Raspberry Pi project in which I need to take about 30 images per second (no movie) and stack each 2D image to a 3D array using numpy array, without saving each 2D capture as a file (because is slow). >>> >>> I found this Python code to take images as fast as possible, but i don't know how to stack all images fast to a 3D stack of images. >>> >>> import io >>> import time >>> import picamera >>> #from PIL import Image >>> >>> def outputs(): >>> stream = io.BytesIO() >>> for i in range(40): >>> # This returns the stream for the camera to capture to >>> yield stream >>> # Once the capture is complete, the loop continues here >>> # (read up on generator functions in Python to understand >>> # the yield statement). Here you could do some processing >>> # on the image... >>> #stream.seek(0) >>> #img = Image.open(stream) >>> # Finally, reset the stream for the next capture >>> stream.seek(0) >>> stream.truncate() >>> >>> with picamera.PiCamera() as camera: >>> camera.resolution = (640, 480) >>> camera.framerate = 80 >>> time.sleep(2) >>> start = time.time() >>> camera.capture_sequence(outputs(), 'jpeg', use_video_port=True) >>> finish = time.time() >>> print('Captured 40 images at %.2ffps' % (40 / (finish - start))) >>> >>> Does anyone of you know how to stack the 2D images taken in this code to a 3D numpy array using Python and the Raspberry Pi camera module? Without saving each 2D capture as a file >>> >>> Best regards, Agust?n >>> >> >> http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is >> the first hit on google for "numpy 3d array stack". >> >> -- >> My fellow Pythonistas, ask not what our language can do for you, ask >> what you can do for our language. >> >> Mark Lawrence > > Hi Mark, > I know the dstack function can do the job, but i don't know how to implement it in this case. > Sadly I don't know how either, but if I can find the above link in seconds, I'm fairly certain that with a little searching you could find something. Specific sites like nullege or koders might offer solutions. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Tue Jul 7 03:00:42 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 07 Jul 2015 08:00:42 +0100 Subject: Trying to import numpy In-Reply-To: References: Message-ID: On 07/07/2015 04:17, ryguy7272 wrote: > I'm trying to use numpy. I get this error: >>>> import numpy as np > > Traceback (most recent call last): > File "", line 1, in > import numpy as np > ImportError: No module named numpy > > > > I followed the instructions here. > https://pip.pypa.io/en/latest/installing.html > > > In the c-prompt, I get this error. > C:\>python get-pip.py > python: can't open file 'get-pip.py': [Errno 2] No such file or directory > > > In python 2.7, I get this error. >>>> python get-pip.py > SyntaxError: invalid syntax Upgrade your installation to one that comes with pip, either the later versions of 2.7 or 3.4 will do. > > > I would say 100% of my errors come from importing python modules. If this every worked, I could do some real work. Instead, I spend 100% of my time trying to make thing that don't work, work. > Complete nonsense that I'm not wasting my time commenting on. > > I've already added ';C:\Python27' to the Path under Variable Name. Of course, this makes no difference whatsoever. Ugh. > > Any thoughts? Anyone? > A bad workman always blames his tools, usually as a result of failing to RTFM. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From oscar.j.benjamin at gmail.com Tue Jul 7 06:12:50 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Tue, 07 Jul 2015 10:12:50 +0000 Subject: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi In-Reply-To: <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> References: <161f3646-9739-4c14-af41-b07498a83d26@googlegroups.com> Message-ID: On Mon, 6 Jul 2015 at 22:36 Agustin Cruz wrote: > I'm working on a Python - Raspberry Pi project in which I need to take > about 30 images per second (no movie) and stack each 2D image to a 3D array > using numpy array, without saving each 2D capture as a file (because is > slow). > > I found this Python code to take images as fast as possible, but i don't > know how to stack all images fast to a 3D stack of images. > What does the code below actually do? Does it save the images as files? Do you know how to modify the code so that you get each image as a matrix (2D array)? > > import io > import time > import picamera > #from PIL import Image > > def outputs(): > stream = io.BytesIO() > for i in range(40): > # This returns the stream for the camera to capture to > yield stream > # Once the capture is complete, the loop continues here > # (read up on generator functions in Python to understand > # the yield statement). Here you could do some processing > # on the image... > #stream.seek(0) > #img = Image.open(stream) > I guess the commented lines above do what you want. From the Image object there will be some way to retrieve a matrix representing the image. Is the image black and white? If it's RGB then you would have size 640x480x3 3D array. > # Finally, reset the stream for the next capture > stream.seek(0) > stream.truncate() > > with picamera.PiCamera() as camera: > camera.resolution = (640, 480) > camera.framerate = 80 > time.sleep(2) > start = time.time() > camera.capture_sequence(outputs(), 'jpeg', use_video_port=True) > finish = time.time() > print('Captured 40 images at %.2ffps' % (40 / (finish - start))) > > Does anyone of you know how to stack the 2D images taken in this code to a > 3D numpy array using Python and the Raspberry Pi camera module? Without > saving each 2D capture as a file > I can't immediately see how to access the 2D images from the code above. See if you can change it so that it gets the image matrix for each image (and e.g. prints out the matrix). Then change it so that you build a list of the 2D matrices then you can just do: video = numpy.dstack(list_of_images) And video should be a 3D array. (I'm assuming black and white images here). -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at stroeder.com Tue Jul 7 09:45:45 2015 From: michael at stroeder.com (=?UTF-8?Q?Michael_Str=c3=b6der?=) Date: Tue, 07 Jul 2015 15:45:45 +0200 Subject: ANN: python-ldap 2.4.20 Message-ID: Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.20 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stuff (e.g. processing LDIF, LDAP URLs and LDAPv3 schema). Project's web site: http://www.python-ldap.org/ Checksums: $ md5sum python-ldap-2.4.20.tar.gz f98ecd0581766a43954ba0f218053032 $ sha1sum python-ldap-2.4.20.tar.gz 3051f2b53ce73a60b852b7f4e994e4b14b7de7b4 $ sha256sum python-ldap-2.4.20.tar.gz 4b8891539a3171d993cf7896b632ff088a4c707ae85ac3c77db1454f7949f3e2 Ciao, Michael. ---------------------------------------------------------------- Released 2.4.20 2015-07-07 Changes since 2.4.19: * New wrapping of OpenLDAP's function ldap_sasl_bind_s() allows to intercept the SASL handshake (thanks to Ren? Kijewski) Modules/ * Added exceptions ldap.VLV_ERROR, ldap.X_PROXY_AUTHZ_FAILURE and ldap.AUTH_METHOD_NOT_SUPPORTED Lib/ * Abandoned old syntax when raising ValueError in modules ldif and ldapurl, more information in some exceptions. * ldap.ldapobject.LDAPObject: New convenience methods for SASL GSSAPI or EXTERNAL binds * Refactored parts in ldif.LDIFParser: - New class attributes line_counter and byte_counter contain amount of LDIF data read so far - Renamed some internally used methods - Added support for parsing change records currently limited to changetype: modify - New separate methods parse_entry_records() (also called by parse()) and parse_change_records() - Stricter order checking of dn:, changetype:, etc. - Removed non-existent 'AttrTypeandValueLDIF' from ldif.__all__ * New mix-in class ldap.controls.openldap.SearchNoOpMixIn adds convience method noop_search_st() to LDAPObject class * Added new modules which implement the control classes for Virtual List View (see draft-ietf-ldapext-ldapv3-vlv) and Server-side Sorting (see RFC 2891) (thanks to Benjamin Dauvergne) Note: This is still experimental! Even the API can change later. From nickgeovanis at gmail.com Tue Jul 7 09:57:22 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Tue, 7 Jul 2015 06:57:22 -0700 (PDT) Subject: pygtk2 and colors Message-ID: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> Morning- With python 2.7.5, pygtk 2.24, gtk 2.24: The following snippet successfully sets the line_width but not the foreground color, and I can't figure-out why. The color human-name and the result returned by gtk.gdk.color_parse are correct. Clues? Thanks. self.gc.set_line_attributes(myclass.board_line_width, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_BEVEL) fg = gtk.gdk.color_parse(myclass.board_foreground) self.gc.set_foreground(fg) From hemla21 at gmail.com Tue Jul 7 10:02:02 2015 From: hemla21 at gmail.com (hemla21 at gmail.com) Date: Tue, 7 Jul 2015 07:02:02 -0700 (PDT) Subject: Creating a Virtual Environment Message-ID: <821783f8-f5ae-4f57-94a2-734bf60986b7@googlegroups.com> Dear all, I have made a python program which I would like to be able to install on to linux machine. I want my python code to be able to use a standalone python with the libraries installed. The code works with python3.4 and above and uses h5py and numpy packages. I was looking at the options I had and understood that it is a good idea to use virtualenv. I followed the following steps: 1. I installed anaconda3 python in to my home directory. I prepended the path to PATH, so python now refers to the anaconda version. The reason I am trying to use anaconda3 is because it has all the packages I need already installed. source $HOME/anaconda3/bin/activate ~/anaconda3 2. Then I try to create a virtualenv by running the following command in the destination directory. virtualenv -p /home/albert/anaconda3/bin/python3 --always-copy . This will give the following error: Running virtualenv with interpreter /home/albert/anaconda3/bin/python3 Using base prefix '/home/albert/anaconda3' New python executable in ./bin/python3 Traceback (most recent call last): File "/usr/lib/python3.3/site-packages/virtualenv.py", line 2308, in main() File "/usr/lib/python3.3/site-packages/virtualenv.py", line 821, in main symlink=options.symlink) File "/usr/lib/python3.3/site-packages/virtualenv.py", line 956, in create_environment site_packages=site_packages, clear=clear, symlink=symlink)) File "/usr/lib/python3.3/site-packages/virtualenv.py", line 1247, in install_python shutil.copyfile(executable, py_executable) File "/home/albert/anaconda3/lib/python3.4/shutil.py", line 109, in copyfile with open(dst, 'wb') as fdst: PermissionError: [Errno 13] Permission denied: './bin/python3' If I run the same command using the administrator I get : Using base prefix '/home/albert/anaconda3' New python executable in ./bin/python3 Not overwriting existing python script ./bin/python (you must use ./bin/python3) Traceback (most recent call last): File "/usr/lib/python3.3/site-packages/virtualenv.py", line 2308, in main() File "/usr/lib/python3.3/site-packages/virtualenv.py", line 821, in main symlink=options.symlink) File "/usr/lib/python3.3/site-packages/virtualenv.py", line 956, in create_environment site_packages=site_packages, clear=clear, symlink=symlink)) File "/usr/lib/python3.3/site-packages/virtualenv.py", line 1377, in install_python shutil.copyfile(py_executable_base, full_pth) File "/home/albert/anaconda3/lib/python3.4/shutil.py", line 108, in copyfile with open(src, 'rb') as fsrc: FileNotFoundError: [Errno 2] No such file or directory: 'python3' I get exactly the same error, even if I use compile python from source ( not using anaconda version). So my questions are: 1. Is virtualenv a good idea? 2. which python should I be using to create my virtualenv? System python? python compiled in user home directory? anaconda3? I?d really appreciate your help. Thank you very much in Advance, From bkimstunnaboss at gmail.com Tue Jul 7 10:47:12 2015 From: bkimstunnaboss at gmail.com (bkimstunnaboss at gmail.com) Date: Tue, 7 Jul 2015 07:47:12 -0700 (PDT) Subject: pygtk2 and colors In-Reply-To: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> References: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> Message-ID: <106c414d-0c57-42b2-98be-caa90e8f223d@googlegroups.com> Hi Nick, Doing colors with pygtk2 is a real pain... But to change the foreground, what you wanna do is to get a copy of the style of the widget, set the color values on it, and then set it back as the style. Like so... color = gtk.gdk.color_parse('#ac0102') style = self.get_style().copy() style.fg[gtk.STATE_NORMAL] = color style.fg[gtk.STATE_PRELIGHT] = color self.set_style(style) Very unpythonic imo... From rosuav at gmail.com Tue Jul 7 10:54:36 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 Jul 2015 00:54:36 +1000 Subject: pygtk2 and colors In-Reply-To: <106c414d-0c57-42b2-98be-caa90e8f223d@googlegroups.com> References: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> <106c414d-0c57-42b2-98be-caa90e8f223d@googlegroups.com> Message-ID: On Wed, Jul 8, 2015 at 12:47 AM, wrote: > Hi Nick, > Doing colors with pygtk2 is a real pain... I understand there's a different set of GTK bindings, pygobject. But I've not used it, so I don't know if it's more pythonic in style. Might be worth considering. ChrisA From toby at tobiah.org Tue Jul 7 11:56:00 2015 From: toby at tobiah.org (Tobiah) Date: Tue, 07 Jul 2015 08:56:00 -0700 Subject: windows and file names > 256 bytes References: Message-ID: On 06/24/2015 10:45 AM, Albert-Jan Roskam wrote: > Hi, > > Consider the following calls, where very_long_path is more than 256 bytes: > [1] os.mkdir(very_long_path) > [2] os.getsize(very_long_path) > [3] shutil.rmtree(very_long_path) > > I am using Python 2.7 and [1] and [2] fail under Windows XP [3] fails the prefix) > > My questions: > 1. How can I get the file size of very long paths under XP? As a workaround, could you use multiple calls to os.chdir() to get to where you need to do your operations, then use relative paths from there? Tobiah From tjreedy at udel.edu Tue Jul 7 12:32:44 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 7 Jul 2015 12:32:44 -0400 Subject: Trying to import numpy In-Reply-To: References: Message-ID: On 7/7/2015 9:23 AM, Dennis Lee Bieber wrote: > On Mon, 6 Jul 2015 20:17:34 -0700 (PDT), ryguy7272 > declaimed the following: > >> I'm trying to use numpy. I get this error: >>>>> import numpy as np >> >> Traceback (most recent call last): >> File "", line 1, in > > I have no experience with whatever provides "pyshell". I'd suggest > running from a Windows command line to reduce dependencies. The command line interactive interpreter gives as the pseudofile name for exceptions. When code is run from Idle's Shell, , where n is the line number, is used instead. This is irrelevant to the numpy import failure. -- Terry Jan Reedy From cousinstanley at gmail.com Tue Jul 7 12:54:03 2015 From: cousinstanley at gmail.com (Cousin Stanley) Date: Tue, 07 Jul 2015 09:54:03 -0700 Subject: pygtk2 and colors References: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> Message-ID: > With python 2.7.5, pygtk 2.24, gtk 2.24: > The following snippet successfully sets the line_width > but not the foreground color, and I can't figure-out why. > > The color human-name and the result returned > by gtk.gdk.color_parse are correct. Clues? Thanks. > > self.gc.set_line_attributes(myclass.board_line_width, gtk.gdk.LINE_SOLID, > > gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_BEVEL) > > fg = gtk.gdk.color_parse(myclass.board_foreground) > > self.gc.set_foreground(fg) > You might try .... self.set_rgb_fg_color( fg ) Example from ... http://www.linuxplanet.com/linuxplanet/tutorials/6750/2/ -- Stanley C. Kitching Human Being Phoenix, Arizona From nickgeovanis at gmail.com Tue Jul 7 13:25:03 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Tue, 7 Jul 2015 10:25:03 -0700 (PDT) Subject: pygtk2 and colors In-Reply-To: References: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> Message-ID: <97288ef7-1d9e-4afc-b4e3-534582ccd059@googlegroups.com> On Tuesday, July 7, 2015 at 11:54:21 AM UTC-5, Cousin Stanley wrote: > You might try .... > > self.set_rgb_fg_color( fg ) Well thanks, that works. Yet set_rgb_bg_color() does not. And I notice that the example at the link you sent doesn't set the background color either. Do I have a color overlay or masking issue? I guess what bothers me is that this is such a basic thing, the reference doc is almost useless on the subject, the usual response is "look at this example", and each example does it differently than every other example. From laurent.pointal at free.fr Tue Jul 7 13:53:27 2015 From: laurent.pointal at free.fr (Laurent Pointal) Date: Tue, 07 Jul 2015 19:53:27 +0200 Subject: Trying to import numpy References: Message-ID: <559c1217$0$3365$426a74cc@news.free.fr> ryguy7272 wrote: > I'm trying to use numpy. I get this error: >>>> import numpy as np > > Traceback (most recent call last): > File "", line 1, in > import numpy as np > ImportError: No module named numpy > > > > I followed the instructions here. > https://pip.pypa.io/en/latest/installing.html ?download numpy installer from official site http://www.scipy.org/scipylib/download.html ==> http://sourceforge.net/projects/numpy/files/NumPy/1.9.2/ Choose the installer version for your Python2.7: ==> http://sourceforge.net/projects/numpy/files/NumPy/1.9.2/numpy-1.9.2-win32-superpack-python2.7.exe/download And install it with the installer. A+ Laurent. From rosuav at gmail.com Tue Jul 7 13:57:51 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 Jul 2015 03:57:51 +1000 Subject: pygtk2 and colors In-Reply-To: <97288ef7-1d9e-4afc-b4e3-534582ccd059@googlegroups.com> References: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> <97288ef7-1d9e-4afc-b4e3-534582ccd059@googlegroups.com> Message-ID: On Wed, Jul 8, 2015 at 3:25 AM, wrote: > On Tuesday, July 7, 2015 at 11:54:21 AM UTC-5, Cousin Stanley wrote: >> You might try .... >> >> self.set_rgb_fg_color( fg ) > > Well thanks, that works. Yet set_rgb_bg_color() does not. And I notice that the example at the link you sent doesn't set the background color either. Do I have a color overlay or masking issue? Part of your confusion may be because "background" isn't necessarily what you think it is. In GTK, there are several different ways styles can be set, and probably you _are_ setting the background color, but it's not having any visible change. Try playing around with some of the other settable colors, and see if one of them helps you. ChrisA From nickgeovanis at gmail.com Tue Jul 7 15:37:30 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Tue, 7 Jul 2015 12:37:30 -0700 (PDT) Subject: pygtk2 and colors In-Reply-To: References: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> <97288ef7-1d9e-4afc-b4e3-534582ccd059@googlegroups.com> Message-ID: <654cbc5a-9142-4276-9b53-4e2d3a685c12@googlegroups.com> On Tuesday, July 7, 2015 at 12:58:12 PM UTC-5, Chris Angelico wrote: > > Part of your confusion may be because "background" isn't necessarily > what you think it is. Indeed. Yet "foreground" _is_ what I think it is :-) I would argue that we have here a clumsy intrusion of OO inheritance into a context which doesn't consistently support it. I don't mind inheritance; I do mind clumsiness and inconsistency. From fabiofz at gmail.com Tue Jul 7 15:49:06 2015 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Tue, 7 Jul 2015 16:49:06 -0300 Subject: PyDev 4.2.0 Released Message-ID: Release Highlights: ------------------------------- * New search page for Python contents * Text-searches using a Lucene index allows for fast matches. * Matches can be flattened and grouped by project, folders and modules. * Results page allows additional filtering based on module name. * Further improvements on code completion unpacking compound types. * Not adding auto 'import' token in cython files (to accept cimport). * PyDev Mylyn integration no longer depends on a specific PyDev release. * Fixed halting condition when unable to create native file watches. * Vertical indent guide no longer slows down the editor on Linux (PyDev-582). What is PyDev? --------------------------- PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and IronPython development. It comes with goodies such as code completion, syntax highlighting, syntax analysis, code analysis, refactor, debug, interactive console, etc. Details on PyDev: http://pydev.org Details on its development: http://pydev.blogspot.com What is LiClipse? --------------------------- LiClipse is a PyDev standalone with goodies such as support for Multiple cursors, theming, TextMate bundles and a number of other languages such as Django Templates, Jinja2, Kivy Language, Mako Templates, Html, Javascript, etc. It's also a commercial counterpart which helps supporting the development of PyDev. Details on LiClipse: http://www.liclipse.com/ Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer LiClipse http://www.liclipse.com PyDev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com PyVmMonitor - Python Profiler http://www.pyvmmonitor.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From c.buhtz at posteo.jp Tue Jul 7 16:31:04 2015 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Tue, 7 Jul 2015 22:31:04 +0200 Subject: understanding why there is no setup.py uninstall In-Reply-To: <85vbdxy9a4.fsf@benfinney.id.au> References: <3mPPH002XKzFpWF@dovecot04.posteo.de> <85vbdxy9a4.fsf@benfinney.id.au> Message-ID: <3mQwQN6Y1xzFpW6@dovecot04.posteo.de> On 2015-07-06 18:34 Ben Finney wrote: > Part of the better system is that we have the Python Packaging > Authority which didn't exist when Distutils was > designed. Read the documents there and I hope you'll be glad at the > improvement! > ... Thank you very much for that explanation. I haven't read something like this before about that topic. Now it is much easier for me evaluate the different systems/possibilities for that task. From lac at openend.se Tue Jul 7 17:09:12 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 07 Jul 2015 23:09:12 +0200 Subject: understanding why there is no setup.py uninstall In-Reply-To: Message from of "Tue, 07 Jul 2015 22:31:04 +0200." <3mQwQN6Y1xzFpW6@dovecot04.posteo.de> References: <3mPPH002XKzFpWF@dovecot04.posteo.de> <85vbdxy9a4.fsf@benfinney.id.au><3mQwQN6Y1xzFpW6@dovecot04.posteo.de> Message-ID: <201507072109.t67L9CfK000883@fido.openend.se> In a message of Tue, 07 Jul 2015 22:31:04 +0200, c.buhtz at posteo.jp writes: >On 2015-07-06 18:34 Ben Finney wrote: >> Part of the better system is that we have the Python Packaging >> Authority which didn't exist when Distutils was >> designed. Read the documents there and I hope you'll be glad at the >> improvement! >> ... > >Thank you very much for that explanation. I haven't read something like >this before about that topic. Now it is much easier for me evaluate the >different systems/possibilities for that task. > Know that the new thing on the block is wheels. http://pythonwheels.com/ It's supposed to address the problems other systems have. It's too new for me to have an opinion. But I have a serious opinion about easy_install. It never worked properly. However, if you are about to evaluate it --- You may run into this problem. Lots of messages like this: (Because easy_install assumed you must have this, which isn't true of a lot of distributions) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 43, > in _execfile > exec(code, globals, locals) > File "/tmp/easy_install-PGpger/bioread-0.9.5/setup.py", line 3, in > > ImportError: No module named ez_setup > If you get this, then install this one. https://pypi.python.org/pypi/ez_setup (Just to save you some hassle if you collide with this problem in your evaluations). Laura From vinay_sajip at yahoo.co.uk Tue Jul 7 19:32:29 2015 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 7 Jul 2015 23:32:29 +0000 (UTC) Subject: ANN: distlib 0.2.1 released on PyPI Message-ID: <1521363010.1182798.1436311949075.JavaMail.yahoo@mail.yahoo.com> I've just released version 0.2.1 of distlib on PyPI [1]. For newcomers, distlib is a library of packaging functionality which is intended to be usable as the basis for third-party packaging tools. The main changes in this release are as follows: ??? Fixed issue #58: Return a Distribution instance or None from locate(). ??? Fixed issue #59: Skipped special keys when looking for versions. ??? Improved behaviour of PyPIJSONLocator to be analogous to that of other ??? locators. ??? Added resource iterator functionality. ??? Fixed issue #71: Updated launchers to decode shebangs using UTF-8. ??? This allows non-ASCII pathnames to be correctly handled. ??? Ensured that the executable written to shebangs is normcased. ??? Changed ScriptMaker to work better under Jython. ??? Changed the mode setting method to work better under Jython. ??? Changed get_executable() to return a normcased value. ??? Handled multiple-architecture wheel filenames correctly. A more detailed change log is available at [2]. Please try it out, and if you find any problems or have any suggestions for improvements, please give some feedback using the issue tracker! [3] Regards, Vinay Sajip [1] https://pypi.python.org/pypi/distlib/0.2.1 [2] https://goo.gl/K5Spsp [3] https://bitbucket.org/pypa/distlib/issues/new -------------- next part -------------- An HTML attachment was scrubbed... URL: From zljubisic at gmail.com Wed Jul 8 01:10:45 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Tue, 7 Jul 2015 22:10:45 -0700 (PDT) Subject: No Content-Length header, nor length property Message-ID: <8e4d5054-c4c1-4132-876a-ba356224c379@googlegroups.com> Hi, if I put the link in the browser, I will be offered to save the file to the local disk. If I execute these few lines of code, I will get None: import urllib.request url = 'http://radio.hrt.hr/prvi-program/aod/download/118467/' site = urllib.request.urlopen(url) print('File size:', site.length) Why I can't get the size of this particular file? On other servers, the same procedure would return file size in bytes, but not for this file? Does it depend on server itself, or there is a way to get remote file size before downloading? Regards. From kevin.p.dwyer at gmail.com Wed Jul 8 01:28:07 2015 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Wed, 08 Jul 2015 06:28:07 +0100 Subject: No Content-Length header, nor length property References: <8e4d5054-c4c1-4132-876a-ba356224c379@googlegroups.com> Message-ID: zljubisic at gmail.com wrote: > Hi, > > if I put the link in the browser, I will be offered to save the file to > the local disk. > > If I execute these few lines of code, I will get None: > > import urllib.request > > url = 'http://radio.hrt.hr/prvi-program/aod/download/118467/' > site = urllib.request.urlopen(url) > print('File size:', site.length) > > Why I can't get the size of this particular file? > On other servers, the same procedure would return file size in bytes, but > not for this file? > > Does it depend on server itself, or there is a way to get remote file size > before downloading? > > Regards. Hello, urlopen returns an HttpResponse object(https://docs.python.org/3/library/http.client.html#httpresponse-objects). You need to call read() on the return value to get the page content, or you could consider the getheader method to check for a Content- Length header. Hope that helps, Kev From zljubisic at gmail.com Wed Jul 8 02:15:43 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Tue, 7 Jul 2015 23:15:43 -0700 (PDT) Subject: No Content-Length header, nor length property In-Reply-To: References: <8e4d5054-c4c1-4132-876a-ba356224c379@googlegroups.com> Message-ID: <87eae205-9cc6-4160-beec-769f544ac275@googlegroups.com> > Hello, > > urlopen returns an HttpResponse > object(https://docs.python.org/3/library/http.client.html#httpresponse-objects). You need to call read() on the return value to get the page > content, or you could consider the getheader method to check for a Content- > Length header. > > Hope that helps, > > Kev Kev, did you mean? import urllib.request url = 'http://radio.hrt.hr/prvi-program/aod/download/118467/' site = urllib.request.urlopen(url) print( site.getheader('Content-Length')) # None x = site.read(1) # No 'Content-Length' header print('File size:', site.length) I am still not getting anywhere. :( Regards. From kevin.p.dwyer at gmail.com Wed Jul 8 02:50:09 2015 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Wed, 08 Jul 2015 07:50:09 +0100 Subject: No Content-Length header, nor length property References: <8e4d5054-c4c1-4132-876a-ba356224c379@googlegroups.com> <87eae205-9cc6-4160-beec-769f544ac275@googlegroups.com> Message-ID: zljubisic at gmail.com wrote: > > >> Hello, >> >> urlopen returns an HttpResponse >> object(https://docs.python.org/3/library/http.client.html#httpresponse-objects). >> You need to call read() on the return value to get the page content, or >> you could consider the getheader method to check for a Content- Length >> header. >> >> Hope that helps, >> >> Kev > > Kev, did you mean? > > import urllib.request > > url = 'http://radio.hrt.hr/prvi-program/aod/download/118467/' > site = urllib.request.urlopen(url) > > print( site.getheader('Content-Length')) # None > x = site.read(1) # No 'Content-Length' header > > print('File size:', site.length) > > I am still not getting anywhere. :( > > Regards. Ah - looking at the response headers, they include "Transfer-Encoding chunked" - I don't think urlopen handles chunked responses by default, though I could be wrong, I don't have time to check the docs right now. The requests library (https://pypi.python.org/pypi/requests) seems to handle them - http://docs.python-requests.org/en/latest/user/advanced/#chunk-encoded-requests From jon+usenet at unequivocal.co.uk Wed Jul 8 06:00:14 2015 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Wed, 8 Jul 2015 10:00:14 +0000 (UTC) Subject: No Content-Length header, nor length property References: <8e4d5054-c4c1-4132-876a-ba356224c379@googlegroups.com> Message-ID: On 2015-07-08, zljubisic at gmail.com wrote: > Why I can't get the size of this particular file? > On other servers, the same procedure would return file size in > bytes, but not for this file? > > Does it depend on server itself, or there is a way to get remote > file size before downloading? Yes, it depends on whether the server sends a Content-Length header, and no, if the server does not send the header then there is no way to determine the file size without downloading it all. From martin at skjoldebrand.eu Wed Jul 8 12:59:55 2015 From: martin at skjoldebrand.eu (Martin S) Date: Wed, 08 Jul 2015 18:59:55 +0200 Subject: bottle app "crashes" In-Reply-To: References: <1744901.sz0qzmb0Nj@homedragon> Message-ID: <7080708.LbXVgrAija@homedragon> On Monday 06 July 2015 21.57.21 Jason Friedman wrote: > > Last summer I fumbled together a small appplication that calculates both > > LASK and Elo ratings for chess. I managed to "webify" it using Bottle. > > This works nicely on my laptop for testing. > > > > Once I log off (or my user session times out) my server where I've started > > the application with python3 LASKweb.py & the application dies within a > > minute, resulting in clients getting 404 errors when accessing the page > > (a simple table that's processed by the application). > > Similar to other answers here, I do not know why your application > stops serving, but I have had success using waitress > (https://pypi.python.org/pypi/waitress) with bottle > (http://bottlepy.org/docs/dev/deployment.html#switching-the-server-backend). Now it seems to be working properly. Thanks all. /Martin S From steveburrus28 at gmail.com Wed Jul 8 14:07:07 2015 From: steveburrus28 at gmail.com (Steve Burrus) Date: Wed, 8 Jul 2015 11:07:07 -0700 (PDT) Subject: Idle Not Working. Message-ID: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> I need some deg4ree of help w ith the Idle Python Editor. I am using 64 bit win 10 beta preview and every time that I try to bring up Idle I cannot! Now I am using both 32 and 64 bit versions of Idle [for some reason] Can someone please help me with this? From sohcahtoa82 at gmail.com Wed Jul 8 14:44:28 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Wed, 8 Jul 2015 11:44:28 -0700 (PDT) Subject: Idle Not Working. In-Reply-To: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> References: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> Message-ID: <9a75c148-303a-4daa-b483-a3161dec72e9@googlegroups.com> Help us help you. "every time I try to bring up Idle I cannot" does not tell us the problem. Do you get error messages? What do they say? From memilanuk at gmail.com Wed Jul 8 16:51:56 2015 From: memilanuk at gmail.com (memilanuk) Date: Wed, 08 Jul 2015 13:51:56 -0700 Subject: Creating a Virtual Environment In-Reply-To: <821783f8-f5ae-4f57-94a2-734bf60986b7@googlegroups.com> References: <821783f8-f5ae-4f57-94a2-734bf60986b7@googlegroups.com> Message-ID: Generally when using Anaconda, they recommend you use their tool (conda) which works very well. It kind of incorporates the functions of pip and virtualenv together. If you already have the path to the anaconda python prepended to your path, the source...activate command shouldn't really be doing anything unless you specifically created an environment (using conda) named 'anaconda' - but it would stowed under ~/anaconda3/envs/'... Have you looked at the conda docs yet? http://conda.pydata.org/docs/index.html How to go from something local in an isolated virtual environment (whether created with virtualenv or conda) to something you can distribute is a separate question, which I can't really help much. From tjreedy at udel.edu Wed Jul 8 16:57:58 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 8 Jul 2015 16:57:58 -0400 Subject: Idle Not Working. In-Reply-To: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> References: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> Message-ID: On 7/8/2015 2:07 PM, Steve Burrus wrote: > I need some deg4ree of help w ith the Idle Python Editor. I am using > 64 bit win 10 beta preview I am waiting for MS to install the activate the actual release on my personal machine. > and every time that I try to bring up Idle I cannot! Does python itself (which version?) work? I do not know if versions before 3.5 are expected to work on Win 10. We developers have no way of testing yet, at least not on the buildbot testers. > Now I am using both 32 and 64 bit versions of Idle There are no such things. Idle is python code that runs on whatever version of Python you have. As far as I know, you cannot easily install both 32 and 64 bit versions of x.y on the same machine. -- Terry Jan Reedy From ian.g.kelly at gmail.com Wed Jul 8 17:09:18 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 8 Jul 2015 15:09:18 -0600 Subject: Idle Not Working. In-Reply-To: References: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> Message-ID: On Wed, Jul 8, 2015 at 2:57 PM, Terry Reedy wrote: > On 7/8/2015 2:07 PM, Steve Burrus wrote: >> Now I am using both 32 and 64 bit versions of Idle > > There are no such things. Idle is python code that runs on whatever version > of Python you have. As far as I know, you cannot easily install both 32 and > 64 bit versions of x.y on the same machine. Sure you can, just put them in different directories. I don't recall whether Python installs anything to C:\Windows\System, but the 32-bit version would just go into C:\Windows\SysWOW64 instead, so there's no conflict there. The py launcher will prefer the 64-bit version but can be directed to invoke the 32-bit version instead. From breamoreboy at yahoo.co.uk Wed Jul 8 17:12:02 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Jul 2015 22:12:02 +0100 Subject: Idle Not Working. In-Reply-To: <9a75c148-303a-4daa-b483-a3161dec72e9@googlegroups.com> References: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> <9a75c148-303a-4daa-b483-a3161dec72e9@googlegroups.com> Message-ID: On 08/07/2015 19:44, sohcahtoa82 at gmail.com wrote: > Help us help you. "every time I try to bring up Idle I cannot" does not tell us the problem. > > Do you get error messages? What do they say? > Would you please be kind enough to quote context when replying. Pythonistas might be smart, but apart from myself and Steven D'Aprano I'm not aware of anyone who can read minds. Thank you. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From rosuav at gmail.com Wed Jul 8 17:15:03 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 9 Jul 2015 07:15:03 +1000 Subject: Idle Not Working. In-Reply-To: References: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> <9a75c148-303a-4daa-b483-a3161dec72e9@googlegroups.com> Message-ID: On Thu, Jul 9, 2015 at 7:12 AM, Mark Lawrence wrote: > Would you please be kind enough to quote context when replying. Pythonistas > might be smart, but apart from myself and Steven D'Aprano I'm not aware of > anyone who can read minds. Thank you. Hey! I'm right here... ChrisA From breamoreboy at yahoo.co.uk Wed Jul 8 17:38:26 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Jul 2015 22:38:26 +0100 Subject: Idle Not Working. In-Reply-To: References: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> <9a75c148-303a-4daa-b483-a3161dec72e9@googlegroups.com> Message-ID: On 08/07/2015 22:15, Chris Angelico wrote: > On Thu, Jul 9, 2015 at 7:12 AM, Mark Lawrence wrote: >> Would you please be kind enough to quote context when replying. Pythonistas >> might be smart, but apart from myself and Steven D'Aprano I'm not aware of >> anyone who can read minds. Thank you. > > Hey! I'm right here... > > ChrisA > I do apologise. Apart from myself, Steven D'Aprano and Chris Angelico I'm not aware of anyone who can read minds. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From sohcahtoa82 at gmail.com Wed Jul 8 18:36:50 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Wed, 8 Jul 2015 15:36:50 -0700 (PDT) Subject: Idle Not Working. In-Reply-To: References: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> <9a75c148-303a-4daa-b483-a3161dec72e9@googlegroups.com> Message-ID: On Wednesday, July 8, 2015 at 2:12:29 PM UTC-7, Mark Lawrence wrote: > On 08/07/2015 19:44, sohcahtoa82 at gmail.com wrote: > > Help us help you. "every time I try to bring up Idle I cannot" does not tell us the problem. > > > > Do you get error messages? What do they say? > > > > Would you please be kind enough to quote context when replying. > Pythonistas might be smart, but apart from myself and Steven D'Aprano > I'm not aware of anyone who can read minds. Thank you. > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence Oops. I usually do, but for some reason Google Groups didn't this time. My apologies. From lac at openend.se Wed Jul 8 18:47:01 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 09 Jul 2015 00:47:01 +0200 Subject: Idle Not Working. In-Reply-To: Message from sohcahtoa82@gmail.com of "Wed, 08 Jul 2015 15:36:50 -0700." References: <4d3e7843-f26b-4741-94f8-bdcb452980a4@googlegroups.com> <9a75c148-303a-4daa-b483-a3161dec72e9@googlegroups.com> Message-ID: <201507082247.t68Ml1p8004072@fido.openend.se> In a message of Wed, 08 Jul 2015 15:36:50 -0700, sohcahtoa82 at gmail.com writes: >Oops. I usually do, but for some reason Google Groups didn't this time. My apologies. This isn't google groups. And this may be your problem. Do not include such things as attatchments which may get removed. Include them as inlined text in your mail. Laura Creighton From zljubisic at gmail.com Thu Jul 9 02:02:03 2015 From: zljubisic at gmail.com (zljubisic at gmail.com) Date: Wed, 8 Jul 2015 23:02:03 -0700 (PDT) Subject: No Content-Length header, nor length property In-Reply-To: References: <8e4d5054-c4c1-4132-876a-ba356224c379@googlegroups.com> <87eae205-9cc6-4160-beec-769f544ac275@googlegroups.com> Message-ID: <721fe346-e333-480d-b806-c1d8f036350d@googlegroups.com> > Ah - looking at the response headers, they include "Transfer-Encoding > chunked" - I don't think urlopen handles chunked responses by default, > though I could be wrong, I don't have time to check the docs right now. > > The requests library (https://pypi.python.org/pypi/requests) seems to handle > them - http://docs.python-requests.org/en/latest/user/advanced/#chunk-encoded-requests Hi, looks like - as Jon stated - server doesn't use Content-length header, so there is no way to continue a partial download, nor to know in advance what is the file size. :( I don't see any other option here. Regards. From webkoros at gmail.com Thu Jul 9 05:28:17 2015 From: webkoros at gmail.com (Benj) Date: Thu, 9 Jul 2015 02:28:17 -0700 (PDT) Subject: Good python news sites Message-ID: <579b10c8-6ce5-4e7f-b652-63a5f13f4d2c@googlegroups.com> Hello, could you please recommend some python news sites: sites that post news, code samples, good practices, new libraries... things like that, to follow daily. Thanks, Benj From vek.m1234 at gmail.com Thu Jul 9 06:20:59 2015 From: vek.m1234 at gmail.com (Veek M) Date: Thu, 09 Jul 2015 15:50:59 +0530 Subject: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop? References: Message-ID: Mark Lawrence wrote: > > If it's provided why have you snipped it this time around? May I most > humbly suggest that the next time you ask, please ensure that you tell > us what you've googled for prior to putting your question. > umm.. I can't determine what you mean by 'snipped it'. 1. I posted a Question. (I figured out the answer). 2. I posted a quick reply stating it was 'fixed' and a brief answer. 3. Saran posted wondering what the answer was. 4. I said: wth, the answer is answered, what is not clear and that Saran should google my keyword. 5. You posted about something being snipped somewhere. 6. This is in reply to (5) - i am confused, I am letting the matter rest since it doesn't seem very important :) Ciao! From vek.m1234 at gmail.com Thu Jul 9 06:25:45 2015 From: vek.m1234 at gmail.com (Veek M) Date: Thu, 09 Jul 2015 15:55:45 +0530 Subject: requests.Session() how do you set 'replace' on the encoding? References: Message-ID: dieter wrote: > > It looks strange that you can set "s.encoding" after you have > called "s.get" - but, as you apparently get an error related to > the "gbk" encoding, it seems to work. Ooo! Sorry, typo - that was outside the function but before the call. Unfortunately whilst improving my function for Usenet, i screwed it up even further. (just ignore that, as you have) to the rest of your answer - many thanks, will do. From joel.goldstick at gmail.com Thu Jul 9 07:47:06 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Thu, 9 Jul 2015 07:47:06 -0400 Subject: Good python news sites In-Reply-To: <579b10c8-6ce5-4e7f-b652-63a5f13f4d2c@googlegroups.com> References: <579b10c8-6ce5-4e7f-b652-63a5f13f4d2c@googlegroups.com> Message-ID: On Thu, Jul 9, 2015 at 5:28 AM, Benj wrote: > Hello, > could you please recommend some python news sites: sites that post news, code samples, good practices, new libraries... things like that, to follow daily. > > Thanks, > Benj > -- > https://mail.python.org/mailman/listinfo/python-list I like the weekly email newsletter you can get from pycoders.com -- Joel Goldstick http://joelgoldstick.com From irmen.NOSPAM at xs4all.nl Thu Jul 9 13:24:11 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Thu, 09 Jul 2015 19:24:11 +0200 Subject: Good python news sites In-Reply-To: <579b10c8-6ce5-4e7f-b652-63a5f13f4d2c@googlegroups.com> References: <579b10c8-6ce5-4e7f-b652-63a5f13f4d2c@googlegroups.com> Message-ID: <559eae3a$0$2892$e4fe514c@news.xs4all.nl> On 9-7-2015 11:28, Benj wrote: > Hello, > could you please recommend some python news sites: sites that post news, code samples, good practices, new libraries... things like that, to follow daily. > > Thanks, > Benj > There's a lot of stuff appearing on the Python subReddit; https://www.reddit.com/r/python If it's all good practice there is left as an exercise for the reader, but I like it. Then there's Planet Python, a blog aggregator; http://planetpython.org/ It has an RSS feed you can feed into your favorite aggregator tool. Irmen From cyril.scetbon at free.fr Thu Jul 9 15:08:05 2015 From: cyril.scetbon at free.fr (Cyril Scetbon) Date: Thu, 9 Jul 2015 21:08:05 +0200 Subject: module dependencies issues Message-ID: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> Hi, I use pip to install modules and setuptools to install dependencies, and generate a console_script using the entry_point parameter of setup. Here is the issue : my current sources depend on modules, let's say A=1.0, B=1.0, C=2.0. And C depends on B=1.1 I have no problem with using pip to install dependencies. However setuptools complain that 2 versions are conflicting : Installed /private/tmp/test/my-module Processing dependencies for my-module==0.0.1 error: B 1.0 is installed but B==1.1 is required by set(['C']) Forcing my-module to use B=1.1 fixes the issue. However it's just a sample and my code is using a lot of modules that use other shared modules too. Is there a way to let dependencies use their own version of the modules they need while the current use another version ? Currently every time we need to upgrade one module, we need to make sure dependencies use this new version too :( Thanks -- Cyril SCETBON From rosuav at gmail.com Thu Jul 9 15:50:00 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Jul 2015 05:50:00 +1000 Subject: module dependencies issues In-Reply-To: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> Message-ID: On Fri, Jul 10, 2015 at 5:08 AM, Cyril Scetbon wrote: > Forcing my-module to use B=1.1 fixes the issue. However it's just a sample and my code is using a lot of modules that use other shared modules too. Is there a way to let dependencies use their own version of the modules they need while the current use another version ? > Currently every time we need to upgrade one module, we need to make sure dependencies use this new version too :( > First off, does your module *really* need B==1.0, or can it handle B>=1.0? If it can, the solution is easy. ChrisA From cyril.scetbon at free.fr Thu Jul 9 15:55:30 2015 From: cyril.scetbon at free.fr (Cyril Scetbon) Date: Thu, 9 Jul 2015 21:55:30 +0200 Subject: module dependencies issues In-Reply-To: References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> Message-ID: <85B68343-326C-4768-A236-3459299AD129@free.fr> It's just a sample. I'd like to get a general answer. So think about the worst case. > On Jul 9, 2015, at 21:50, Chris Angelico wrote: > > On Fri, Jul 10, 2015 at 5:08 AM, Cyril Scetbon wrote: >> Forcing my-module to use B=1.1 fixes the issue. However it's just a sample and my code is using a lot of modules that use other shared modules too. Is there a way to let dependencies use their own version of the modules they need while the current use another version ? >> Currently every time we need to upgrade one module, we need to make sure dependencies use this new version too :( >> > > First off, does your module *really* need B==1.0, or can it handle > B>=1.0? If it can, the solution is easy. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From mal at europython.eu Thu Jul 9 15:55:51 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Thu, 09 Jul 2015 21:55:51 +0200 Subject: EuroPython 2015 Keynote: Mandy Waite Message-ID: <559ED1C7.6080409@europython.eu> We are pleased to introduce our final keynote speaker for EuroPython 2015: Mandy Waite. She will be giving her keynote on Friday, July 24. About Mandy Waite ----------------- Mandy works at Google as a Developer Advocate for Google Cloud Platform and to make the world a better place for developers building applications for the Cloud: ?I came to Google from Sun Microsystems where I worked with partners on performance and optimisation of large scale applications and services before moving on to building an ecosystem of Open Source applications for OpenSolaris. In my spare time I?m learning Japanese and play the guitar.? The Keynote: So, I have all these Docker containers, now what? -------------------------------------------------------------- You?ve solved the issue of process-level reproducibility by packaging up your apps and execution environments into a number of Docker containers. But once you have a lot of containers running, you?ll probably need to coordinate them across a cluster of machines while keeping them healthy and making sure they can find each other. Trying to do this imperatively can quickly turn into an unmanageable mess! Wouldn?t it be helpful if you could declare to your cluster what you want it to do, and then have the cluster assign the resources to get it done and to recover from failures and scale on demand? Kubernetes (http://kubernetes.io) is an open source, cross platform cluster management and container orchestration platform that simplifies the complex tasks of deploying and managing your applications in Docker containers. You declare a desired state, and Kubernetes does all the work needed to create and maintain it. In this talk, we?ll look at the basics of Kubernetes and at how to map common applications to these concepts. This will include a hands-on demonstration and visualization of the steps involved in getting an application up and running on Kubernetes. Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From rosuav at gmail.com Thu Jul 9 15:59:59 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Jul 2015 05:59:59 +1000 Subject: module dependencies issues In-Reply-To: <85B68343-326C-4768-A236-3459299AD129@free.fr> References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> Message-ID: On Fri, Jul 10, 2015 at 5:55 AM, Cyril Scetbon wrote: > It's just a sample. I'd like to get a general answer. So think about the worst case. (Please don't top-post on this list.) The worst case is virtually impossible to handle. Somewhere along the way, you need to say "import B" and Python has to go and fetch up some module. There has to be exactly one module under that name. This isn't a packaging issue, it's an issue with how Python references modules: there can be only one! Highlander: The System Modules Dictionary! How do you expect the end result to work? Will it be that your code imports one version of a module, but other code imports another? You would have to rename one of them or something. ChrisA From skip.montanaro at gmail.com Thu Jul 9 16:16:54 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 9 Jul 2015 15:16:54 -0500 Subject: Readline -- cannot bind to both Ctrl-tab and tab at the same time? In-Reply-To: References: <55904328$0$1636$c3e8da3$5496439d@news.astraweb.com> Message-ID: I thought this thread had died down. I guess not quite... It makes perfect sense to me that TAB and Ctrl-TAB would generate the same keycode, as TAB is itself a control character (Ctrl-I). As the Ctrl modifier bit is effectively already set, I don't think you can really set it a second time and be able to detect it. Skip -------------- next part -------------- An HTML attachment was scrubbed... URL: From piotr at tynecki.pl Thu Jul 9 16:18:29 2015 From: piotr at tynecki.pl (piotr at tynecki.pl) Date: Thu, 9 Jul 2015 13:18:29 -0700 (PDT) Subject: =?ISO-8859-2?Q?PyCon_PL_2015_=2D_Zosta=B3_nieca=B3y_tydzie=F1_dla_Call_f?= =?ISO-8859-2?Q?or_Proposals?= Message-ID: <7f3e9296-ca32-4904-838a-7c3e686d9d53@googlegroups.com> Cze?? Polska Spo?eczno?ci Pythona! Jaki? czas temu uruchomiono PyCon PL 2015 - Call for Proposals, czyli nab?r na propozycje prelekcji, warsztat?w, paneli dyskusyjnych oraz innych aktywno?ci konferencyjnych. Zaakceptowani prowadz?cy, kt?rzy spe?ni? warunki Call for Proposals, otrzymaj? darmowy bilet na konferencj?. Termin zg?osze? mija z dniem 15 lipca 2015. PyCon PL 2015 to ?sma edycja najwi?kszej konferencji pythonowej w Europie ?rodkowo-Wschodniej. W ubieg?ym roku wzi??o w niej udzia? ponad 500 os?b. Na tegorocznej edycji organizatorzy spodziewaj? si? nawet 700 uczestnik?w! Konferencja integruje ?rodowiska programist?w Pythona, naukowc?w oraz biznesu, wykorzystuj?ce ten j?zyk we w?asnych projektach. Sta?ym elementem wydarzenia s? ciekawe wyst?pienia, w tym prelekcje specjalnych go?ci zza granicy, warsztaty, "piorunuj?ce wyst?pienia" oraz inne atrakcje wpasowuj?ce si? w lu?ny, weekendowy klimat wydarzenia. PyCon PL 2015 odb?dzie si? w dniach od 15 do 18 pa?dziernika 2015 r. w czterogwiazdkowym gigancie "Ossa Congress & Spa" w miejscowo?ci Ossa. Zach?cam Was do wyst?pienia przed mi?dzynarodow? spo?eczno?ci?, do dzielenia si? wiedz? i nabytym do?wiadczeniem. W tym celu wystarczy zg?osi? propozycj? wyst?pienia w specjalnym formularzu Call for Proposals (http://goo.gl/forms/kh4kBkVF9G). Wyboru wyst?pie? dokona Komitet Programowy PyCon PL 2015, w sk?ad w kt?rego wchodz? przedstawiciele lokalnych, polskich ?rodowisk Pythona. Wi?cej informacji: http://pl.pycon.org/2015/, https://www.facebook.com/PyConPL From piotr at tynecki.pl Thu Jul 9 16:33:25 2015 From: piotr at tynecki.pl (piotr at tynecki.pl) Date: Thu, 9 Jul 2015 13:33:25 -0700 (PDT) Subject: PyCon PL 2015 - Call for Proposal is waiting for you Message-ID: <062d1833-63b9-4c03-95fb-30ace9d55587@googlegroups.com> Python Hackers, PyCon PL 2015 is pleased to announce that its Call for Proposals will be closed soon! We encourage you all to come and share experience with a varied audience of ethusiastic Pythonistas that the conference attracts each year. Talks and workshops from all Python-related areas are welcome, both in Polish and English. The deadline for proposals is July 15th, 2015. You can submit yours by filling in this form: http://goo.gl/forms/kh4kBkVF9G PyCon PL is renowed for its unique atmosphere, owed to accomodating all participants in the same hotel, which helds the conference. It fosters superb networking opportunities as well as a great fun in the evenings. This year we invite you to a comfortable four-star hotel in the middle of beautiful and green area, located 60km from Warsaw. We will arrange inexpensive bus transport from Warsaw to the hotel for those who need it. More information on Call for Proposals and the conference itself can be found on its website. Hope to meet you in Poland this autumn! Feel free to meet us on: http://pl.pycon.org/2015/ https://www.facebook.com/PyConPL From marko at pacujo.net Thu Jul 9 16:36:38 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 09 Jul 2015 23:36:38 +0300 Subject: module dependencies issues References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> Message-ID: <87wpy96pbd.fsf@elektro.pacujo.net> Chris Angelico : > How do you expect the end result to work? Will it be that your code > imports one version of a module, but other code imports another? You > would have to rename one of them or something. At work, we have created an analogous component system that has solved this issue the way I think it should be solved. Component B ver 1.1 must declare (ABI) backward-compatibility with B ver 1.0. That allows the component system to resolve such natural dependency discrepancies in a safe manner. The application (or component) C, which was created at B ver 1.0 time, can't depend on >= B-1.0 because C has no way of knowing if, say, B-2.0 will be backward-compatible with B-1.0. The compatibility declaration belongs to B. Marko From marko at pacujo.net Thu Jul 9 16:42:26 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 09 Jul 2015 23:42:26 +0300 Subject: Readline -- cannot bind to both Ctrl-tab and tab at the same time? References: <55904328$0$1636$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87si8x6p1p.fsf@elektro.pacujo.net> Skip Montanaro : > It makes perfect sense to me that TAB and Ctrl-TAB would generate the > same keycode, as TAB is itself a control character (Ctrl-I). As the > Ctrl modifier bit is effectively already set, I don't think you can > really set it a second time and be able to detect it. If you input a character stream, that's the case since the characters are Unicode code points. AFAIK, Unicode doesn't have Ctrl-TAB as a separate code point. However, X11 key events come with modifiers. Thus, CAPS-A, LeftShift-A, RightShift-A, CAPS-LeftShift-RightShift-A and the plain A are different key events (provided the physical keyboard plays along). Marko From rosuav at gmail.com Thu Jul 9 16:47:33 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Jul 2015 06:47:33 +1000 Subject: module dependencies issues In-Reply-To: <87wpy96pbd.fsf@elektro.pacujo.net> References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> <87wpy96pbd.fsf@elektro.pacujo.net> Message-ID: On Fri, Jul 10, 2015 at 6:36 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> How do you expect the end result to work? Will it be that your code >> imports one version of a module, but other code imports another? You >> would have to rename one of them or something. > > At work, we have created an analogous component system that has solved > this issue the way I think it should be solved. > > Component B ver 1.1 must declare (ABI) backward-compatibility with B ver > 1.0. That allows the component system to resolve such natural dependency > discrepancies in a safe manner. > > The application (or component) C, which was created at B ver 1.0 time, > can't depend on >= B-1.0 because C has no way of knowing if, say, B-2.0 > will be backward-compatible with B-1.0. The compatibility declaration > belongs to B. Or, B could simply declare that it follows the common versioning pattern of Major.Minor.Revision, where Revision changes don't add features or in any way break compatibility (or if they do, it's a bug), Minor changes add features without normally breaking backward compatibility in any serious way, and Major chances might break all sorts of things (but usually won't). Then, depending on B >= 1.3 < 2.0 is sufficient if you require a feature that came in with 1.3. If it turns out that 1.7 breaks your code, you either change your code to be compatible with 1.7 (and either drop support for 1.3 or figure out some way of supporting both), or declare B >= 1.3 < 1.7. It's really not difficult. This is what version numbers are for. In general, I would expect that B 1.1 is backward-compatible with B 1.0, unless otherwise stated. Why must it be declared in any way other than the version number? ChrisA From marko at pacujo.net Thu Jul 9 17:11:54 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 10 Jul 2015 00:11:54 +0300 Subject: module dependencies issues References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> <87wpy96pbd.fsf@elektro.pacujo.net> Message-ID: <87oajl6nol.fsf@elektro.pacujo.net> Chris Angelico : > In general, I would expect that B 1.1 is backward-compatible with B > 1.0, unless otherwise stated. Why must it be declared in any way other > than the version number? To make it explicit. The generic component system shouldn't impose (m)any assumptions on version numbering. Version numbers can contain digits, punctuation, letters. Comparisons should be done the way "ls -v" and "sort -V" do it. Whoever creates B-1.1 ought to make it backward-compatible, but he should also say so. The majority of developers are careless about backward-compatibility; having the component system make wishful assumptions will lead to catastrophic consequences. Marko From rosuav at gmail.com Thu Jul 9 17:20:16 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Jul 2015 07:20:16 +1000 Subject: module dependencies issues In-Reply-To: <87oajl6nol.fsf@elektro.pacujo.net> References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> <87wpy96pbd.fsf@elektro.pacujo.net> <87oajl6nol.fsf@elektro.pacujo.net> Message-ID: On Fri, Jul 10, 2015 at 7:11 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> In general, I would expect that B 1.1 is backward-compatible with B >> 1.0, unless otherwise stated. Why must it be declared in any way other >> than the version number? > > To make it explicit. The generic component system shouldn't impose > (m)any assumptions on version numbering. Version numbers can contain > digits, punctuation, letters. Comparisons should be done the way "ls > -v" and "sort -V" do it. > > Whoever creates B-1.1 ought to make it backward-compatible, but he > should also say so. The majority of developers are careless about > backward-compatibility; having the component system make wishful > assumptions will lead to catastrophic consequences. I strongly disagree. All your idea would do is create a massive compatibility matrix, which would itself become utterly unmaintainable. It's all very well to ask for a declaration that 1.1 is compatible with 1.0, but what happens when you add in 1.2 and 1.3, and then add some point releases on all of them? Python 2.7 is up to 2.7.10; does every one of them need to declare backward compatibility with every other, and with every point release of 2.6, and 2.5, and how far back do we go? And just how compatible does it have to be to get a tick? EVERY change can break someone's workflow - XKCD 1172 comes to mind - so does that mean that a single bugfix prevents the compatibility mark? No. Version numbers exist to provide a granularity to the compatibility concerns. ChrisA From marko at pacujo.net Thu Jul 9 17:33:48 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 10 Jul 2015 00:33:48 +0300 Subject: module dependencies issues References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> <87wpy96pbd.fsf@elektro.pacujo.net> <87oajl6nol.fsf@elektro.pacujo.net> Message-ID: <87k2u96mo3.fsf@elektro.pacujo.net> Chris Angelico : > On Fri, Jul 10, 2015 at 7:11 AM, Marko Rauhamaa wrote: >> Whoever creates B-1.1 ought to make it backward-compatible, but he >> should also say so. The majority of developers are careless about >> backward-compatibility; having the component system make wishful >> assumptions will lead to catastrophic consequences. > > I strongly disagree. All your idea would do is create a massive > compatibility matrix, which would itself become utterly > unmaintainable. Well, it's working and very much maintainable. > It's all very well to ask for a declaration that 1.1 is compatible > with 1.0, but what happens when you add in 1.2 and 1.3, and then add > some point releases on all of them? The compatibility statement accepts ranges and can be open-ended. > And just how compatible does it have to be to get a tick? It must be a safe binary replacement of the earlier version. Bug fixes and new features are ok, but none of the old functionality can be obsoleted. Marko From rosuav at gmail.com Thu Jul 9 17:45:10 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Jul 2015 07:45:10 +1000 Subject: module dependencies issues In-Reply-To: <87k2u96mo3.fsf@elektro.pacujo.net> References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> <87wpy96pbd.fsf@elektro.pacujo.net> <87oajl6nol.fsf@elektro.pacujo.net> <87k2u96mo3.fsf@elektro.pacujo.net> Message-ID: On Fri, Jul 10, 2015 at 7:33 AM, Marko Rauhamaa wrote: >> And just how compatible does it have to be to get a tick? > > It must be a safe binary replacement of the earlier version. Bug fixes > and new features are ok, but none of the old functionality can be > obsoleted. Your descriptions conflict. A safe binary replacement usually cannot even add new features, in case this breaks something. Consider what happens when Python creates a new keyword; it's a new feature, old functionality hasn't been broken, but if that word had been used anywhere as an identifier, it's now broken. Even something as simple as updating to the latest Unicode release can change what means what, and won't necessarily be backward-compatible (eg when a character's classes are changed, the places where that character is legal may also change). There is NO CHANGE which is perfectly backward-compatible. ChrisA From random832 at fastmail.us Thu Jul 9 19:04:25 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Thu, 09 Jul 2015 19:04:25 -0400 Subject: (side-)effects and ... In-Reply-To: References: Message-ID: <1436483065.507812.319906673.3D3B674E@webmail.messagingengine.com> On Thu, Jul 9, 2015, at 15:36, Tony the Tiger wrote: > On Sun, 05 Jul 2015 20:29:11 +0000, Stefan Ram wrote: > > > X-Copyright: (C) Copyright 2015 Stefan Ram. All rights reserved. > > Distribution through any means other than regular usenet channels is > > forbidden. It is forbidden to publish this article in the world wide > > web. It is forbidden to change URIs of this article into links. It is > > forbidden to remove this notice or to transfer the body without this > > notice. > > X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is > > only set, because this prevents some > > services to mirror the article via the web (HTTP). But Stefan Ram > > hereby allows to keep this article within a Usenet archive server with > > only NNTP access without any time limitation. > > X-No-Html: yes That's ridiculous. Why is he even including URIs if he doesn't want them to be links - a feature many newsreaders and terminal emulators have (and can't read these instructions) even regardless of web mirroring? Also, he should not post here, because all articles posted here are automatically put on a mailing list and that list's web-accessible archive. Do we have a cancelbot so he can be effectively blocked from posting (since the list is incapable of complying with his conditions)? @Stefan, why are you here? From skip.montanaro at gmail.com Thu Jul 9 19:27:36 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 9 Jul 2015 18:27:36 -0500 Subject: (side-)effects and ... In-Reply-To: <1436483065.507812.319906673.3D3B674E@webmail.messagingengine.com> References: <1436483065.507812.319906673.3D3B674E@webmail.messagingengine.com> Message-ID: > Also, he should not post here, because all articles posted here are > automatically put on a mailing list and that list's web-accessible > archive. I thought so at first add well. It looks like the Mailman system handles the X-No-Archive and/or Archive headers. I couldn't find his name in this month's archive. -------------- next part -------------- An HTML attachment was scrubbed... URL: From marko at pacujo.net Thu Jul 9 20:04:57 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 10 Jul 2015 03:04:57 +0300 Subject: module dependencies issues References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> <87wpy96pbd.fsf@elektro.pacujo.net> <87oajl6nol.fsf@elektro.pacujo.net> <87k2u96mo3.fsf@elektro.pacujo.net> Message-ID: <87k2u8x4gm.fsf@elektro.pacujo.net> Chris Angelico : > Your descriptions conflict. A safe binary replacement usually cannot > even add new features, in case this breaks something. Linus Torvalds is adamant about maintaining ABI compatibility across Linux versions. That hasn't prevented him from accepting numerous new system calls. New functions in C libraries do not cause runtime breakage. > Consider what happens when Python creates a new keyword; it's a new > feature, old functionality hasn't been broken, but if that word had > been used anywhere as an identifier, it's now broken. You are right about adding keywords; they break backward-compatibility (except in Perl, where keywords and names are in different namespaces, or Scheme, which doesn't have keywords). > There is NO CHANGE which is perfectly backward-compatible. That statement is untrue in theory, and even more untrue in practice. Marko From matt at plot.ly Thu Jul 9 20:10:03 2015 From: matt at plot.ly (Matt Sundquist) Date: Thu, 9 Jul 2015 17:10:03 -0700 (PDT) Subject: Python dashboard tutorials/frameworks for interactive, D3.js graphs in IPython Notebooks Message-ID: Hi all, I'm part of Plotly, and we've just finished a few releases I thought I'd pass along. These tools make it easy to craft interactive graphs and dashboards with D3.js using Python. We're especially drawn towards matplotlib, pandas, and IPython. We're still early in building, so any and all feedback and help is much appreciated. First, here is an overview of some of our dashboard capabilities: http://blog.plot.ly/post/123617968702/online-dashboards-eight-helpful-tips-you-should For more background, refer to our Python docs: https://plot.ly/python/, our Python framework for making dashboards: https://github.com/plotly/dash, our data science blog: http://moderndata.plot.ly/, or these 21 IPython Notebooks: https://plot.ly/python/ipython-notebooks/. Feedback and suggestions are welcome! M From c.candide at laposte.net Thu Jul 9 20:10:18 2015 From: c.candide at laposte.net (candide) Date: Thu, 9 Jul 2015 17:10:18 -0700 (PDT) Subject: Evaluation order Message-ID: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> The official doc explains that : Python evaluates expressions from left to right. cf. https://docs.python.org/3.3/reference/expressions.html#evaluation-order But consider the following snippet : >>> t=[2020, 42, 2015] >>> t*(1+int(bool(t.sort()))) [42, 2015, 2020] >>> Is there not some contradiction with left-right evalutation? From breamoreboy at yahoo.co.uk Thu Jul 9 20:24:28 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 10 Jul 2015 01:24:28 +0100 Subject: module dependencies issues In-Reply-To: <87k2u8x4gm.fsf@elektro.pacujo.net> References: <10ADE079-3F0F-4EA8-9312-06F7FCDB6130@free.fr> <85B68343-326C-4768-A236-3459299AD129@free.fr> <87wpy96pbd.fsf@elektro.pacujo.net> <87oajl6nol.fsf@elektro.pacujo.net> <87k2u96mo3.fsf@elektro.pacujo.net> <87k2u8x4gm.fsf@elektro.pacujo.net> Message-ID: On 10/07/2015 01:04, Marko Rauhamaa wrote: > Chris Angelico : > >> Your descriptions conflict. A safe binary replacement usually cannot >> even add new features, in case this breaks something. > > New functions in C libraries do not cause runtime breakage. > It's good to know that there's never been a crash in the entire history of the C programming language due to a bug in a new function causing runtime breakage. It just proves the point that I've made in the past, that programmers using statically typed languages are far smarter than those using dynamically typed languages. The former just compile their code by lunchtime and then head to the pub, while the latter have to stay in the office all afternoon testing. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From c.buhtz at posteo.jp Thu Jul 9 21:11:04 2015 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Fri, 10 Jul 2015 03:11:04 +0200 Subject: [setuptools] install data-file in users home-dir Message-ID: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> I am using setuptools to create a wheel file. There is a conf-file I want to install into the users config-diretory. e.g. /home/user/.config/appname/app.conf setup(..., data_files = [ ('~/.config/appname/', ['app.conf']) ] ) I see two problems here: 1. I don't know the users "name". So I have to use a placeholder here. Does '~' work here in that case? 2. To install the wheel-file with pip I need sudo-privilegs on Ubuntu 14.04.2. That means while the install script runs I can not ask for the users name because it is "root" in that case. From tjreedy at udel.edu Thu Jul 9 21:45:56 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 9 Jul 2015 21:45:56 -0400 Subject: Evaluation order In-Reply-To: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: On 7/9/2015 8:10 PM, candide wrote: > The official doc explains that : > Python evaluates expressions from left to right. > cf. https://docs.python.org/3.3/reference/expressions.html#evaluation-order > But consider the following snippet : > >>>> t=[2020, 42, 2015] >>>> t*(1+int(bool(t.sort()))) > [42, 2015, 2020] > Is there not some contradiction with left-right evalutation? No, as shown by the disassembled byte code >>> dis.dis("t*(1+int(bool(t.sort())))") 1 0 LOAD_NAME 0 (t) 3 LOAD_CONST 0 (1) 6 LOAD_NAME 1 (int) 9 LOAD_NAME 2 (bool) 12 LOAD_NAME 0 (t) 15 LOAD_ATTR 3 (sort) 18 CALL_FUNCTION 0 (0 positional, 0 keyword pair) 21 CALL_FUNCTION 1 (1 positional, 0 keyword pair) 24 CALL_FUNCTION 1 (1 positional, 0 keyword pair) 27 BINARY_ADD 28 BINARY_MULTIPLY 29 RETURN_VALUE t.sort() sorts in place and returns None -- Terry Jan Reedy From rosuav at gmail.com Thu Jul 9 22:02:41 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Jul 2015 12:02:41 +1000 Subject: Evaluation order In-Reply-To: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: On Fri, Jul 10, 2015 at 10:10 AM, candide wrote: > The official doc explains that : > > Python evaluates expressions from left to right. > > cf. https://docs.python.org/3.3/reference/expressions.html#evaluation-order > > > But consider the following snippet : > > >>>> t=[2020, 42, 2015] >>>> t*(1+int(bool(t.sort()))) > [42, 2015, 2020] >>>> > > > Is there not some contradiction with left-right evalutation? I'm not sure what contradiction you're referring to, here. The evaluation that you're pointing out says, as Terry showed via the disassembly, that Python's first action is to look up the name 't' and grab a reference to whatever object it points to. The execution of t.sort() has to happen before the multiplication, because of the parentheses. ChrisA From rosuav at gmail.com Thu Jul 9 22:05:57 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Jul 2015 12:05:57 +1000 Subject: (side-)effects and ... In-Reply-To: References: <1436483065.507812.319906673.3D3B674E@webmail.messagingengine.com> Message-ID: On Fri, Jul 10, 2015 at 9:27 AM, Skip Montanaro wrote: >> Also, he should not post here, because all articles posted here are >> automatically put on a mailing list and that list's web-accessible >> archive. > > I thought so at first add well. It looks like the Mailman system handles the > X-No-Archive and/or Archive headers. I couldn't find his name in this > month's archive. Even if it respects that, there's no way that Mailman can know to respect his ridiculous copyright restriction. Human-readable text in a copyright notice is not going to affect an automated system. If he tries to sue Mailman or the PSF or "the internet" for distributing his text in violation of his copyright, I hope that an intelligent judge would liken it to posting your phone number on a billboard and then complaining that people are ringing you. When you put something out there in public, it's public, and people can and will see it. ChrisA From torriem at gmail.com Fri Jul 10 00:26:19 2015 From: torriem at gmail.com (Michael Torrie) Date: Thu, 09 Jul 2015 22:26:19 -0600 Subject: (side-)effects and ... In-Reply-To: References: <1436483065.507812.319906673.3D3B674E@webmail.messagingengine.com> Message-ID: <559F496B.40301@gmail.com> On 07/09/2015 08:05 PM, Chris Angelico wrote: >> I thought so at first add well. It looks like the Mailman system handles the >> X-No-Archive and/or Archive headers. I couldn't find his name in this >> month's archive. > > Even if it respects that, there's no way that Mailman can know to > respect his ridiculous copyright restriction. Human-readable text in a > copyright notice is not going to affect an automated system. If he > tries to sue Mailman or the PSF or "the internet" for distributing his > text in violation of his copyright, I hope that an intelligent judge > would liken it to posting your phone number on a billboard and then > complaining that people are ringing you. When you put something out > there in public, it's public, and people can and will see it. I received his message via the e-mail gateway, so oh nos apparently copyright has already been violated! From torriem at gmail.com Fri Jul 10 00:56:05 2015 From: torriem at gmail.com (Michael Torrie) Date: Thu, 09 Jul 2015 22:56:05 -0600 Subject: Readline -- cannot bind to both Ctrl-tab and tab at the same time? In-Reply-To: <87si8x6p1p.fsf@elektro.pacujo.net> References: <55904328$0$1636$c3e8da3$5496439d@news.astraweb.com> <87si8x6p1p.fsf@elektro.pacujo.net> Message-ID: <559F5065.7060608@gmail.com> On 07/09/2015 02:42 PM, Marko Rauhamaa wrote: > Skip Montanaro : > >> It makes perfect sense to me that TAB and Ctrl-TAB would generate the >> same keycode, as TAB is itself a control character (Ctrl-I). As the >> Ctrl modifier bit is effectively already set, I don't think you can >> really set it a second time and be able to detect it. > > If you input a character stream, that's the case since the characters > are Unicode code points. AFAIK, Unicode doesn't have Ctrl-TAB as a > separate code point. Yes and readline works on character streams, not with X11. > > However, X11 key events come with modifiers. Thus, CAPS-A, LeftShift-A, > RightShift-A, CAPS-LeftShift-RightShift-A and the plain A are different > key events (provided the physical keyboard plays along). Not relevant to libreadline, unfortunately. From kwpolska at gmail.com Fri Jul 10 03:39:35 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Fri, 10 Jul 2015 09:39:35 +0200 Subject: [setuptools] install data-file in users home-dir In-Reply-To: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> References: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> Message-ID: On 10 July 2015 at 03:11, wrote: > I am using setuptools to create a wheel file. > > There is a conf-file I want to install into the users config-diretory. > e.g. /home/user/.config/appname/app.conf > > setup(..., > data_files = [ ('~/.config/appname/', ['app.conf']) ] > ) > > I see two problems here: > > 1. > I don't know the users "name". So I have to use a placeholder here. > Does '~' work here in that case? It doesn?t. You would have to use os.path.expanduser, but don?t do that. > 2. > To install the wheel-file with pip I need sudo-privilegs on Ubuntu > 14.04.2. That means while the install script runs I can not ask for the > users name because it is "root" in that case. > -- > https://mail.python.org/mailman/listinfo/python-list You should NEVER use sudo with pip. Instead, use virtualenvs as a regular user, or create your own .deb packages. And you should not create the files in your install script. Instead, install them to a different data dir (somewhere in 'share/appname', or alongside your package). When someone runs your app, only then you should copy this file to user?s config directory (use pkg_resources to help you get it) if it does not exist yet. -- Chris Warrick PGP: 5EAAEA16 From mal at europython.eu Fri Jul 10 06:40:08 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Fri, 10 Jul 2015 12:40:08 +0200 Subject: The EuroPython 2015 Keynotes Message-ID: <559FA108.8060309@europython.eu> With Mandy Waite we have announced all keynotes for EuroPython 2015: 5 keynotes, 6 speakers, 4 women and 2 men. Keynote Schedule ---------------- * Monday: Ola Sendecka & Ola Sitarska * Tuesday: Guido van Rossum * Wednesday: Holger Krekel * Thursday: Carrie Anne * Friday: Mandy Waite More details about the keynotes are available on the EuroPython 2015 Keynotes page: https://ep2015.europython.eu/en/events/keynotes/ Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From subhabrata.banerji at gmail.com Fri Jul 10 07:46:25 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Fri, 10 Jul 2015 04:46:25 -0700 (PDT) Subject: Combing Search Engine with REST Message-ID: Dear Group, I am trying to make a search engine. I used Whoosh to do it. I want to add documents to it. This is going fine. Now, I want to add documents in the index with REST framework. I could learn Flask well. My task is to use Flask to add documents (by using put/post) to index. I am slightly confused how may I do it. If any one of esteemed members of the group may suggest. Regards, Subhabrata Banerjee. From beliavsky at aol.com Fri Jul 10 08:01:29 2015 From: beliavsky at aol.com (beliavsky at aol.com) Date: Fri, 10 Jul 2015 05:01:29 -0700 (PDT) Subject: The EuroPython 2015 Keynotes In-Reply-To: References: Message-ID: <61f0400e-a882-448f-8116-e2df3ff4aaae@googlegroups.com> On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg wrote: > With Mandy Waite we have announced all keynotes for EuroPython 2015: > 5 keynotes, 6 speakers, 4 women and 2 men. Your mentioning these numbers makes me wonder if the organizing committee is using gender preferences in its selection of keynote speakers. I hope not. It is better to choose the speakers who will give the most interesting talks and let the demographic chips fall where they may. From c.candide at laposte.net Fri Jul 10 08:04:25 2015 From: c.candide at laposte.net (candide) Date: Fri, 10 Jul 2015 05:04:25 -0700 (PDT) Subject: Evaluation order In-Reply-To: References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a ?crit?: > I'm not sure what contradiction you're referring to, here. The > evaluation that you're pointing out says, as Terry showed via the > disassembly, that Python's first action is to look up the name 't' and > grab a reference to whatever object it points to. But in order to perform an operation, the interpreter has to evaluate the operands and "evaluating" is not "grabbing a reference to". > The execution of > t.sort() has to happen before the multiplication, because of the > parentheses. > Official docs explains what evaluation is : When the name is bound to an object, evaluation of the atom yields that object. So, since the Python interpreter is performing evaluation from left to right, the first operand of the expression : t*(1+int(bool(t.sort()))) evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the integer 1. So I was expecting the result to be a shallow copy of the first list [2020, 42, 2015] (the value of t before side effect produced by the sort method). On the contrary, the final result takes into in account the side effect and it is as if the first operand has been evaluated twice before execution of the multiplication operation. From lac at openend.se Fri Jul 10 08:06:23 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 10 Jul 2015 14:06:23 +0200 Subject: Combing Search Engine with REST In-Reply-To: Message from subhabrata.banerji@gmail.com of "Fri, 10 Jul 2015 04:46:25 -0700." References: Message-ID: <201507101206.t6AC6NPJ022331@fido.openend.se> In a message of Fri, 10 Jul 2015 04:46:25 -0700, subhabrata.banerji at gmail.com writes: >Dear Group, > >I am trying to make a search engine. I used Whoosh to do it. >I want to add documents to it. This is going fine. >Now, I want to add documents in the index with REST framework. >I could learn Flask well. >My task is to use Flask to add documents (by using put/post) to index. >I am slightly confused how may I do it. > >If any one of esteemed members of the group may suggest. > >Regards, >Subhabrata Banerjee. I suggest you look at https://pythonhosted.org/Flask-WhooshAlchemy/ and see if it does what you want. Laura From ned at nedbatchelder.com Fri Jul 10 08:19:32 2015 From: ned at nedbatchelder.com (Ned Batchelder) Date: Fri, 10 Jul 2015 05:19:32 -0700 (PDT) Subject: Evaluation order In-Reply-To: References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: <724768da-9b5e-4085-b999-ca2435a2e06f@googlegroups.com> On Friday, July 10, 2015 at 8:04:36 AM UTC-4, candide wrote: > Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a ?crit?: > > > > > I'm not sure what contradiction you're referring to, here. The > > evaluation that you're pointing out says, as Terry showed via the > > disassembly, that Python's first action is to look up the name 't' and > > grab a reference to whatever object it points to. > > > But in order to perform an operation, the interpreter has to evaluate the operands and "evaluating" is not "grabbing a reference to". > > > The execution of > > t.sort() has to happen before the multiplication, because of the > > parentheses. > > > > > > Official docs explains what evaluation is : > > When the name is bound to an object, evaluation of the atom yields that object. > > So, since the Python interpreter is performing evaluation from left to right, the first operand of the expression : > > t*(1+int(bool(t.sort()))) > > evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the integer 1. So I was expecting the result to be a shallow copy of the first list [2020, 42, 2015] (the value of t before side effect produced by the sort method). On the contrary, the final result takes into in account the side effect and it is as if the first operand has been evaluated twice before execution of the multiplication operation. The first operand is t. Evaluating t does not make a copy of t, it is simply a reference to t. If t is later modified (by the sort method), the modified data will be seen when t is used in the multiplication. Python never implicitly copies lists (or any other data structure). This explains more about the mechanics of names and values: http://bit.ly/pynames1 --Ned. From tchappui at gmail.com Fri Jul 10 08:24:51 2015 From: tchappui at gmail.com (Thierry Chappuis) Date: Fri, 10 Jul 2015 14:24:51 +0200 Subject: Evaluation order In-Reply-To: References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: Hi, No, the value of t is a reference to tje list. So first, (1) the value of the reference t is recovered, (2) the parenthesis is evaluated, (...) the whole expression is evaluated. To evaluate (2), the .sort() call is executed in place with the side effect of sorting the content of t. t.sort() returns None. When the whole expression is evaluated, the sorted list will be displayed, as expected. Kind regards 2015-07-10 14:04 GMT+02:00 candide : > Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a ?crit : > > > > > I'm not sure what contradiction you're referring to, here. The > > evaluation that you're pointing out says, as Terry showed via the > > disassembly, that Python's first action is to look up the name 't' and > > grab a reference to whatever object it points to. > > > But in order to perform an operation, the interpreter has to evaluate the > operands and "evaluating" is not "grabbing a reference to". > > > The execution of > > t.sort() has to happen before the multiplication, because of the > > parentheses. > > > > > > Official docs explains what evaluation is : > > When the name is bound to an object, evaluation of the atom yields that > object. > > So, since the Python interpreter is performing evaluation from left to > right, the first operand of the expression : > > t*(1+int(bool(t.sort()))) > > evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the > integer 1. So I was expecting the result to be a shallow copy of the first > list [2020, 42, 2015] (the value of t before side effect produced by the > sort method). On the contrary, the final result takes into in account the > side effect and it is as if the first operand has been evaluated twice > before execution of the multiplication operation. > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tchappui at gmail.com Fri Jul 10 08:25:32 2015 From: tchappui at gmail.com (Thierry Chappuis) Date: Fri, 10 Jul 2015 14:25:32 +0200 Subject: Evaluation order In-Reply-To: References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: Hi, No, the value of t is a reference to tje list. So first, (1) the value of the reference t is recovered, (2) the parenthesis is evaluated, (...) the whole expression is evaluated. To evaluate (2), the .sort() call is executed in place with the side effect of sorting the content of t. t.sort() returns None. When the whole expression is evaluated, the sorted list will be displayed, as expected. Kind regards 2015-07-10 14:04 GMT+02:00 candide : > Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a ?crit : > > > > > I'm not sure what contradiction you're referring to, here. The > > evaluation that you're pointing out says, as Terry showed via the > > disassembly, that Python's first action is to look up the name 't' and > > grab a reference to whatever object it points to. > > > But in order to perform an operation, the interpreter has to evaluate the > operands and "evaluating" is not "grabbing a reference to". > > > The execution of > > t.sort() has to happen before the multiplication, because of the > > parentheses. > > > > > > Official docs explains what evaluation is : > > When the name is bound to an object, evaluation of the atom yields that > object. > > So, since the Python interpreter is performing evaluation from left to > right, the first operand of the expression : > > t*(1+int(bool(t.sort()))) > > evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the > integer 1. So I was expecting the result to be a shallow copy of the first > list [2020, 42, 2015] (the value of t before side effect produced by the > sort method). On the contrary, the final result takes into in account the > side effect and it is as if the first operand has been evaluated twice > before execution of the multiplication operation. > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Fri Jul 10 08:27:35 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 10 Jul 2015 08:27:35 -0400 Subject: Evaluation order In-Reply-To: References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: On 7/10/2015 8:04 AM, candide wrote: > Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a ?crit : >> I'm not sure what contradiction you're referring to, here. The >> evaluation that you're pointing out says, as Terry showed via the >> disassembly, that Python's first action is to look up the name 't' and >> grab a reference to whatever object it points to. > > But in order to perform an operation, the interpreter has to evaluate > the operands and "evaluating" is not "grabbing a reference to". In the CPython, evaluating a name is implemented as getting the reference corresponding to the name. >> The execution of >> t.sort() has to happen before the multiplication, because of the >> parentheses. > Official docs explains what evaluation is : > > When the name is bound to an object, evaluation of the atom yields that object. Conceptually, that is exactly right. How that is implemented on a computer in CPython is to load the address on the top of the virtual machine stack. > So, since the Python interpreter is performing evaluation from left to right, > the first operand of the expression : > > t*(1+int(bool(t.sort()))) > > evaluates to [2020, 42, 2015]. 't' evaluates to the ***mutable*** list that 't' is bound to. > Next, the second operatand evaluates to the integer 1. And in the process of that evaluation, the list is sorted. -- Terry Jan Reedy From skip.montanaro at gmail.com Fri Jul 10 10:05:48 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Fri, 10 Jul 2015 09:05:48 -0500 Subject: (side-)effects and ... In-Reply-To: References: <1436483065.507812.319906673.3D3B674E@webmail.messagingengine.com> Message-ID: On Thu, Jul 9, 2015 at 9:05 PM, Chris Angelico wrote: > Even if it respects that, there's no way that Mailman can know to > respect his ridiculous copyright restriction. > Well, sure. But Mailman is probably not alone in this regard. In case it wasn't clear from Tony the Tiger's post (everything was wrapped in my copy), here's how those headers all look in-the-raw: X-Copyright: (C) Copyright 2015 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the world wide web. It is forbidden to change URIs of this article into links. It is forbidden to remove this notice or to transfer the body without this notice. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is only set, because this prevents some services to mirror the article via the web (HTTP). But Stefan Ram hereby allows to keep this article within a Usenet archive server with only NNTP access without any time limitation. X-No-Html: yes So he's got five headers, two of which you would clearly expect mail software to recognize (X-No-Archive and Archive), two which must be for human consumption only (X-Copyright and X-No-Archive-Readme). I'm not sure about X-No-Html. A quick Google search for that header returned nothing useful. Skip -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Fri Jul 10 10:18:39 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 00:18:39 +1000 Subject: (side-)effects and ... In-Reply-To: References: <1436483065.507812.319906673.3D3B674E@webmail.messagingengine.com> Message-ID: On Sat, Jul 11, 2015 at 12:05 AM, Skip Montanaro wrote: > I'm not sure about X-No-Html. A quick Google search for that header returned > nothing useful. Yeah. At best it seems redundant - "Hey look, there's no HTML in this message!" - but I suspect it's mainly bragging "I can add headers to my posts". ChrisA From mstorkamp at yahoo.com Fri Jul 10 10:27:21 2015 From: mstorkamp at yahoo.com (Mark Storkamp) Date: Fri, 10 Jul 2015 09:27:21 -0500 Subject: Trouble getting to windows My Documents directory Message-ID: I'm just learning Python, and I've run into trouble trying to change directory to the windows My Documents directory. There's likely a better way to do this, but this is what I've tried so far: --------------------------------------------- from tkinter import Tk from tkinter.filedialog import askopenfilename import os Tk().withdraw() sourcedir = os.environ['HOME']+"/Documents/" os.chdir(sourcedir) src = askopenfilename() if src == '' : sys.exit() fin = open(src, mode='r') ## do stuff fin.close() ----------------------------------------------- When this is run from IDLE, it works fine. But when I double click on the saved file to run it, it quits without ever showing the open file dialog box, and doesn't show any error message. The problem is with the os.environ['HOME'] call. If I comment it out (and fix up the surrounding code with an absolute path) then it runs. But then it won't work properly for other users. Interestingly enough, when I moved this to a Mac so I could post to Usenet, I discovered it works fine on the Mac. Only Windows seems to be the problem. Windows 7. Any thoughts or suggestions? From rosuav at gmail.com Fri Jul 10 10:27:32 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 00:27:32 +1000 Subject: Evaluation order In-Reply-To: References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: On Fri, Jul 10, 2015 at 10:04 PM, candide wrote: > But in order to perform an operation, the interpreter has to evaluate the operands and "evaluating" is not "grabbing a reference to". Actually, it is. Suppose that instead of 't', you had a function call: def get_t(announce, returnme=[]): print(announce) return returnme get_t("setup").extend((2020, 42, 2015)) get_t("first")*(1+int(bool(get_t("second").sort()))) I think it's obvious from running the above code that get_t("first") is evaluated before get_t("second") is. In the trivial case where the operand is a simple name, yes, evaluating that name is simply "grab a reference to the object this name references" (and in the case of CPython, shove it onto the stack; other Pythons may operate some other way). > Official docs explains what evaluation is : > > When the name is bound to an object, evaluation of the atom yields that object. > > So, since the Python interpreter is performing evaluation from left to right, the first operand of the expression : > > t*(1+int(bool(t.sort()))) > > evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the integer 1. So I was expecting the result to be a shallow copy of the first list [2020, 42, 2015] (the value of t before side effect produced by the sort method). On the contrary, the final result takes into in account the side effect and it is as if the first operand has been evaluated twice before execution of the multiplication operation. > The shallow copy isn't made until the multiplication is performed; it's only at that point that a function takes two parameters and does the work, something like this: class list: def __mul__(self, count): result = [] for i in range(count): result.extend(self) return result Obviously you can't call that function until you know both the list object and the count, so no copies are made until both those values can be provided. The first operand evaluates to *the list with the identity X*, the second operand evaluates to *the integer 1*, and then the multiplication is performed. Does that answer the question? ChrisA From tchappui at gmail.com Fri Jul 10 10:30:25 2015 From: tchappui at gmail.com (Thierry Chappuis) Date: Fri, 10 Jul 2015 16:30:25 +0200 Subject: Evaluation order In-Reply-To: References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Message-ID: <1436538627000-c6691d41-4e8fb13e-1d21e2ee@gmail.com> Anyway, if we enter this kind of discussion, it is a reliable indication that the code smells. There is a pythonic way to express the same task: >>> t.sort() >>> t kind regards Thierry On ven., juil. 10, 2015 at 2:28 PM, Terry Reedy < tjreedy at udel.edu [tjreedy at udel.edu] > wrote: On 7/10/2015 8:04 AM, candide wrote: > Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a ?crit : >> I'm not sure what contradiction you're referring to, here. The >> evaluation that you're pointing out says, as Terry showed via the >> disassembly, that Python's first action is to look up the name 't' and >> grab a reference to whatever object it points to. > > But in order to perform an operation, the interpreter has to evaluate > the operands and "evaluating" is not "grabbing a reference to". In the CPython, evaluating a name is implemented as getting the reference corresponding to the name. >> The execution of >> t.sort() has to happen before the multiplication, because of the >> parentheses. > Official docs explains what evaluation is : > > When the name is bound to an object, evaluation of the atom yields that object. Conceptually, that is exactly right. How that is implemented on a computer in CPython is to load the address on the top of the virtual machine stack. > So, since the Python interpreter is performing evaluation from left to right, > the first operand of the expression : > > t*(1+int(bool(t.sort()))) > > evaluates to [2020, 42, 2015]. 't' evaluates to the ***mutable*** list that 't' is bound to. > Next, the second operatand evaluates to the integer 1. And in the process of that evaluation, the list is sorted. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Fri Jul 10 10:46:07 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Fri, 10 Jul 2015 09:46:07 -0500 Subject: Trouble getting to windows My Documents directory In-Reply-To: References: Message-ID: <20150710094607.66e62712@bigbox.christie.dr> On 2015-07-10 09:27, Mark Storkamp via Python-list wrote: > sourcedir = os.environ['HOME']+"/Documents/" First, I'd do a couple things here to accommodate various systems to make it cross-platform: sourcedir = os.path.join( os.path.expanduser('~'), "Documents" ) > os.chdir(sourcedir) > src = askopenfilename() Then, rather than changing to that directory, use src = askopenfilename(initialdir=sourcedir) > When this is run from IDLE, it works fine. But when I double click > on the saved file to run it, it quits without ever showing the open > file dialog box, and doesn't show any error message. If the above doesn't solve the problem, you might try writing the sourcedir to a file so you can see what it thinks you're trying to open. > The problem is with the os.environ['HOME'] call. If I comment it > out (and fix up the surrounding code with an absolute path) then it > runs. But then it won't work properly for other users. I suspect that inspecting that sourcedir will show what's going on, and that the above tweaks will ameliorate the problem. -tkc From breamoreboy at yahoo.co.uk Fri Jul 10 10:47:11 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 10 Jul 2015 15:47:11 +0100 Subject: Trouble getting to windows My Documents directory In-Reply-To: References: Message-ID: On 10/07/2015 15:27, Mark Storkamp via Python-list wrote: > I'm just learning Python, and I've run into trouble trying to change > directory to the windows My Documents directory. There's likely a better > way to do this, but this is what I've tried so far: > > --------------------------------------------- > from tkinter import Tk > from tkinter.filedialog import askopenfilename > > import os > > Tk().withdraw() > > sourcedir = os.environ['HOME']+"/Documents/" > os.chdir(sourcedir) > src = askopenfilename() > if src == '' : > sys.exit() > fin = open(src, mode='r') > ## do stuff > fin.close() > ----------------------------------------------- > > When this is run from IDLE, it works fine. But when I double click on > the saved file to run it, it quits without ever showing the open file > dialog box, and doesn't show any error message. > > The problem is with the os.environ['HOME'] call. If I comment it out > (and fix up the surrounding code with an absolute path) then it runs. > But then it won't work properly for other users. > > Interestingly enough, when I moved this to a Mac so I could post to > Usenet, I discovered it works fine on the Mac. Only Windows seems to be > the problem. Windows 7. > > Any thoughts or suggestions? > Home isn't defined in Windows but somehow is in IDLE? From a command line enter "set home". Doing that on my Windows 8.1 box shows:- HOMEDRIVE=C: HOMEPATH=\Users\Mark -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Fri Jul 10 10:49:21 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 10 Jul 2015 15:49:21 +0100 Subject: Evaluation order In-Reply-To: <1436538627000-c6691d41-4e8fb13e-1d21e2ee@gmail.com> References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> <1436538627000-c6691d41-4e8fb13e-1d21e2ee@gmail.com> Message-ID: On 10/07/2015 15:30, Thierry Chappuis wrote: [snipped] Please don't top post here as it can get irritating, especially in long threads, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From kwpolska at gmail.com Fri Jul 10 10:49:49 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Fri, 10 Jul 2015 16:49:49 +0200 Subject: [setuptools] install data-file in users home-dir In-Reply-To: <3mScQ36NW9zFpW6@dovecot04.posteo.de> References: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> <3mScQ36NW9zFpW6@dovecot04.posteo.de> Message-ID: CC?ing the mailing list; please use Reply All in the future. On 10 July 2015 at 16:36, wrote: > Hi Chris, > > thank you for your answer. > > On 2015-07-10 09:39 Chris Warrick wrote: >> You should NEVER use sudo with pip. Instead, use virtualenvs as a >> regular user, or create your own .deb packages. > > I am not sure, but maybe this is an Ubuntu-specific "problem"? > When I don't use sudo I got errors like this > "PermissionError: [Errno 13] Permission denied: > '/usr/local/lib/python3.4/dist-packages/SQLAlchemy-1.0.6.dist-info" > > And it make sense for me. This is correct. Don?t install things system-wide with pip. > Don't tell me about deb-Packages! :D I am stuck with that currently. I > would be glad to have a correct working whl-file for my local needs. > After that - maybe! - I will start again with thinking about a deb. > > How can virtualenv help here? I need to install > python-software/packages to the system and not to a different > environment or sandbox. > I never used virtualenv but as I understand it it is for testing > purpose not for productive system. virtualenv should be used for both testing AND production environments. Your projects can have different versions of dependencies, and this is what virtualenv helps with: they are separate from each other. You can also modify the system packages without messing with your system packages. You can also use pip install --user to install to ~/.local >> And you should not create the files in your install script. Instead, >> install them to a different data dir (somewhere in 'share/appname' > > What do you mean with "data dir"? For a default config-file it could > be /etc/appname/default.conf. But I have no rights for that. https://pythonhosted.org/setuptools/setuptools.html#including-data-files Makes your package installable through wheel files and friendly for all environments. >> should copy this file to user?s config directory (use pkg_resources to >> help you get it) if it does not exist yet. > > I will look at this package. https://pythonhosted.org/setuptools/setuptools.html#accessing-data-files-at-runtime -- Chris Warrick PGP: 5EAAEA16 From lac at openend.se Fri Jul 10 11:11:31 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 10 Jul 2015 17:11:31 +0200 Subject: Trouble getting to windows My Documents directory In-Reply-To: Message from Mark Storkamp via Python-list of "Fri, 10 Jul 2015 09:27:21 -0500." References: Message-ID: <201507101511.t6AFBVOK026517@fido.openend.se> Maybe HOMEPATH is what windows calls it? http://libertyboy.free.fr/computing/reference/envariables/ (but maybe this is only for windows XP. I don't have a windows system, so I cannot test this.) Laura From python at mrabarnett.plus.com Fri Jul 10 11:12:17 2015 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 10 Jul 2015 16:12:17 +0100 Subject: Trouble getting to windows My Documents directory In-Reply-To: References: Message-ID: <559FE0D1.3070005@mrabarnett.plus.com> On 2015-07-10 15:27, Mark Storkamp via Python-list wrote: > I'm just learning Python, and I've run into trouble trying to change > directory to the windows My Documents directory. There's likely a better > way to do this, but this is what I've tried so far: > > --------------------------------------------- > from tkinter import Tk > from tkinter.filedialog import askopenfilename > > import os > > Tk().withdraw() > > sourcedir = os.environ['HOME']+"/Documents/" > os.chdir(sourcedir) > src = askopenfilename() > if src == '' : > sys.exit() > fin = open(src, mode='r') > ## do stuff > fin.close() > ----------------------------------------------- > > When this is run from IDLE, it works fine. But when I double click on > the saved file to run it, it quits without ever showing the open file > dialog box, and doesn't show any error message. > > The problem is with the os.environ['HOME'] call. If I comment it out > (and fix up the surrounding code with an absolute path) then it runs. > But then it won't work properly for other users. > > Interestingly enough, when I moved this to a Mac so I could post to > Usenet, I discovered it works fine on the Mac. Only Windows seems to be > the problem. Windows 7. > > Any thoughts or suggestions? > Try os.path.expanduser(r'~\Documents'). It's a bad idea to use os.chdir; it's better to use absolute paths: src = askopenfilename(initialdir=os.path.expanduser(r'~\Documents')) From mstorkamp at yahoo.com Fri Jul 10 11:25:08 2015 From: mstorkamp at yahoo.com (Mark Storkamp) Date: Fri, 10 Jul 2015 10:25:08 -0500 Subject: Trouble getting to windows My Documents directory References: Message-ID: In article , MRAB wrote: > On 2015-07-10 15:27, Mark Storkamp via Python-list wrote: > > I'm just learning Python, and I've run into trouble trying to change > > directory to the windows My Documents directory. There's likely a better > > way to do this, but this is what I've tried so far: > > > > --------------------------------------------- > > from tkinter import Tk > > from tkinter.filedialog import askopenfilename > > > > import os > > > > Tk().withdraw() > > > > sourcedir = os.environ['HOME']+"/Documents/" > > os.chdir(sourcedir) > > src = askopenfilename() > > if src == '' : > > sys.exit() > > fin = open(src, mode='r') > > ## do stuff > > fin.close() > > ----------------------------------------------- > > > > When this is run from IDLE, it works fine. But when I double click on > > the saved file to run it, it quits without ever showing the open file > > dialog box, and doesn't show any error message. > > > > The problem is with the os.environ['HOME'] call. If I comment it out > > (and fix up the surrounding code with an absolute path) then it runs. > > But then it won't work properly for other users. > > > > Interestingly enough, when I moved this to a Mac so I could post to > > Usenet, I discovered it works fine on the Mac. Only Windows seems to be > > the problem. Windows 7. > > > > Any thoughts or suggestions? > > > Try os.path.expanduser(r'~\Documents'). > > It's a bad idea to use os.chdir; it's better to use absolute paths: > > src = askopenfilename(initialdir=os.path.expanduser(r'~\Documents')) I thought there must be a way to pass the directory to askopenfilename, but I just hadn't figured out how yet. The other suggestions for using HOMEPATH also worked for both Mac and Windows. Thanks. From subhabangalore at gmail.com Fri Jul 10 11:44:54 2015 From: subhabangalore at gmail.com (subhabangalore at gmail.com) Date: Fri, 10 Jul 2015 08:44:54 -0700 (PDT) Subject: Combing Search Engine with REST In-Reply-To: References: Message-ID: <3dc4e882-e5fd-4773-a0eb-849639d73f41@googlegroups.com> On Friday, July 10, 2015 at 5:36:48 PM UTC+5:30, Laura Creighton wrote: > In a message of Fri, 10 Jul 2015 04:46:25 -0700, > writes: > >Dear Group, > > > >I am trying to make a search engine. I used Whoosh to do it. > >I want to add documents to it. This is going fine. > >Now, I want to add documents in the index with REST framework. > >I could learn Flask well. > >My task is to use Flask to add documents (by using put/post) to index. > >I am slightly confused how may I do it. > > > >If any one of esteemed members of the group may suggest. > > > >Regards, > >Subhabrata Banerjee. > > I suggest you look at > https://pythonhosted.org/Flask-WhooshAlchemy/ > and see if it does what you want. > > Laura Hi, Thanks. But documentation is very low. Both whoosh and Flask are well documented. Regards, Subhabrata. From pkpearson at nowhere.invalid Fri Jul 10 12:15:58 2015 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 10 Jul 2015 16:15:58 GMT Subject: Matplotlib X-axis timezone trouble References: Message-ID: On Thu, 09 Jul 2015 19:50:33 GMT, Tony the Tiger wrote: > On Tue, 30 Jun 2015 00:56:26 +0000, Peter Pearson wrote: > >> If I use timezone US/Central, I get the same (bad) plot. > > Perhaps this can help?: > http://stackoverflow.com/questions/1301493/setting-timezone-in-python Yes, thanks. As I summarized (in greater detail) elsewhere on this thread, Matplotlib was entirely innocent, and was correctly labeling erroneous datetime objects. My real problem was that datetime.datetime() malfunctions when its tzinfo parameter is a timezone with daylight saving time. The practical solution is to use pytz.localize(). -- To email me, substitute nowhere->runbox, invalid->com. From rustompmody at gmail.com Fri Jul 10 13:48:28 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Fri, 10 Jul 2015 10:48:28 -0700 (PDT) Subject: Trouble getting to windows My Documents directory In-Reply-To: References: Message-ID: <657d89e9-7505-4a2b-b8e7-b7ce7b785a96@googlegroups.com> On Friday, July 10, 2015 at 8:56:48 PM UTC+5:30, Mark Storkamp wrote: > MRAB wrote: > > > On 2015-07-10 15:27, Mark Storkamp via Python-list wrote: > > > I'm just learning Python, and I've run into trouble trying to change > > > directory to the windows My Documents directory. There's likely a better > > > way to do this, but this is what I've tried so far: > > > > > > --------------------------------------------- > > > from tkinter import Tk > > > from tkinter.filedialog import askopenfilename > > > > > > import os > > > > > > Tk().withdraw() > > > > > > sourcedir = os.environ['HOME']+"/Documents/" > > > os.chdir(sourcedir) > > > src = askopenfilename() > > > if src == '' : > > > sys.exit() > > > fin = open(src, mode='r') > > > ## do stuff > > > fin.close() > > > ----------------------------------------------- > > > > > > When this is run from IDLE, it works fine. But when I double click on > > > the saved file to run it, it quits without ever showing the open file > > > dialog box, and doesn't show any error message. > > > > > > The problem is with the os.environ['HOME'] call. If I comment it out > > > (and fix up the surrounding code with an absolute path) then it runs. > > > But then it won't work properly for other users. > > > > > > Interestingly enough, when I moved this to a Mac so I could post to > > > Usenet, I discovered it works fine on the Mac. Only Windows seems to be > > > the problem. Windows 7. > > > > > > Any thoughts or suggestions? > > > > > Try os.path.expanduser(r'~\Documents'). > > > > It's a bad idea to use os.chdir; it's better to use absolute paths: > > > > src = askopenfilename(initialdir=os.path.expanduser(r'~\Documents')) > > I thought there must be a way to pass the directory to askopenfilename, > but I just hadn't figured out how yet. > > The other suggestions for using HOMEPATH also worked for both Mac and > Windows. > > Thanks. According to http://serverfault.com/questions/29948/difference-between-profile-and-home-path it seems %userprofile% is more current than %homepath% [though windows arcana is not exactly my forte ;-) ] From rustompmody at gmail.com Fri Jul 10 13:56:54 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Fri, 10 Jul 2015 10:56:54 -0700 (PDT) Subject: Trouble getting to windows My Documents directory In-Reply-To: <657d89e9-7505-4a2b-b8e7-b7ce7b785a96@googlegroups.com> References: <657d89e9-7505-4a2b-b8e7-b7ce7b785a96@googlegroups.com> Message-ID: <8fe697f8-c8e5-4858-888b-063b6b510656@googlegroups.com> On Friday, July 10, 2015 at 11:18:57 PM UTC+5:30, Rustom Mody wrote: > On Friday, July 10, 2015 at 8:56:48 PM UTC+5:30, Mark Storkamp wrote: > > MRAB wrote: > > > > > On 2015-07-10 15:27, Mark Storkamp via Python-list wrote: > > > > I'm just learning Python, and I've run into trouble trying to change > > > > directory to the windows My Documents directory. There's likely a better > > > > way to do this, but this is what I've tried so far: > > > > > > > > --------------------------------------------- > > > > from tkinter import Tk > > > > from tkinter.filedialog import askopenfilename > > > > > > > > import os > > > > > > > > Tk().withdraw() > > > > > > > > sourcedir = os.environ['HOME']+"/Documents/" > > > > os.chdir(sourcedir) > > > > src = askopenfilename() > > > > if src == '' : > > > > sys.exit() > > > > fin = open(src, mode='r') > > > > ## do stuff > > > > fin.close() > > > > ----------------------------------------------- > > > > > > > > When this is run from IDLE, it works fine. But when I double click on > > > > the saved file to run it, it quits without ever showing the open file > > > > dialog box, and doesn't show any error message. > > > > > > > > The problem is with the os.environ['HOME'] call. If I comment it out > > > > (and fix up the surrounding code with an absolute path) then it runs. > > > > But then it won't work properly for other users. > > > > > > > > Interestingly enough, when I moved this to a Mac so I could post to > > > > Usenet, I discovered it works fine on the Mac. Only Windows seems to be > > > > the problem. Windows 7. > > > > > > > > Any thoughts or suggestions? > > > > > > > Try os.path.expanduser(r'~\Documents'). > > > > > > It's a bad idea to use os.chdir; it's better to use absolute paths: > > > > > > src = askopenfilename(initialdir=os.path.expanduser(r'~\Documents')) > > > > I thought there must be a way to pass the directory to askopenfilename, > > but I just hadn't figured out how yet. > > > > The other suggestions for using HOMEPATH also worked for both Mac and > > Windows. > > > > Thanks. > > According to http://serverfault.com/questions/29948/difference-between-profile-and-home-path > it seems %userprofile% is more current than %homepath% > [though windows arcana is not exactly my forte ;-) ] which may need to be combined with something like: home = 'HOME' if os.name=='posix' else 'USERPROFILE' (see https://docs.python.org/2/library/os.html for os.name) From c.buhtz at posteo.jp Fri Jul 10 14:33:56 2015 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Fri, 10 Jul 2015 20:33:56 +0200 Subject: [setuptools] install data-file in users home-dir In-Reply-To: References: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> Message-ID: <3mSjgp53rPzFpWF@dovecot04.posteo.de> Hi Chris, thank you for your answer. On 2015-07-10 09:39 Chris Warrick wrote: > You should NEVER use sudo with pip. Instead, use virtualenvs as a > regular user, or create your own .deb packages. I am not sure, but maybe this is an Ubuntu-specific "problem"? When I don't use sudo I got errors like this "PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.4/dist-packages/SQLAlchemy-1.0.6.dist-info" And it make sense for me. Don't tell me about deb-Packages! :D I am stuck with that currently. I would be glad to have a correct working whl-file for my local needs. After that - maybe! - I will start again with thinking about a deb. How can virtualenv help here? I need to install python-software/packages to the system and not to a different environment or sandbox. I never used virtualenv but as I understand it it is for testing purpose not for productive system. > And you should not create the files in your install script. Instead, > install them to a different data dir (somewhere in 'share/appname' What do you mean with "data dir"? For a default config-file it could be /etc/appname/default.conf. But I have no rights for that. > should copy this file to user?s config directory (use pkg_resources to > help you get it) if it does not exist yet. I will look at this package. From rosuav at gmail.com Fri Jul 10 14:57:56 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 04:57:56 +1000 Subject: The EuroPython 2015 Keynotes In-Reply-To: <61f0400e-a882-448f-8116-e2df3ff4aaae@googlegroups.com> References: <61f0400e-a882-448f-8116-e2df3ff4aaae@googlegroups.com> Message-ID: On Fri, Jul 10, 2015 at 10:01 PM, beliavsky--- via Python-list wrote: > On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg wrote: >> With Mandy Waite we have announced all keynotes for EuroPython 2015: >> 5 keynotes, 6 speakers, 4 women and 2 men. > > Your mentioning these numbers makes me wonder if the organizing committee is using gender preferences in its selection of keynote speakers. I hope not. It is better to choose the speakers who will give the most interesting talks and let the demographic chips fall where they may. > I think that's more a matter of having the statistically-curious brain. In my father's family, there are 5 sons and 2 daughters - does that indicate gender preference in my reporting, or just an acknowledgement of a fact? ChrisA From beliavsky at aol.com Fri Jul 10 17:14:56 2015 From: beliavsky at aol.com (beliavsky at aol.com) Date: Fri, 10 Jul 2015 14:14:56 -0700 (PDT) Subject: The EuroPython 2015 Keynotes In-Reply-To: References: <61f0400e-a882-448f-8116-e2df3ff4aaae@googlegroups.com> Message-ID: <873e46e8-b117-42a5-a863-b40ee2823ea6@googlegroups.com> On Friday, July 10, 2015 at 2:58:18 PM UTC-4, Chris Angelico wrote: > On Fri, Jul 10, 2015 at 10:01 PM, beliavsky--- via Python-list > wrote: > > On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg wrote: > >> With Mandy Waite we have announced all keynotes for EuroPython 2015: > >> 5 keynotes, 6 speakers, 4 women and 2 men. > > > > Your mentioning these numbers makes me wonder if the organizing committee is using gender preferences in its selection of keynote speakers. I hope not. It is better to choose the speakers who will give the most interesting talks and let the demographic chips fall where they may. > > > > I think that's more a matter of having the statistically-curious > brain. In my father's family, there are 5 sons and 2 daughters - does > that indicate gender preference in my reporting, or just an > acknowledgement of a fact? If 80% of Python programmers and potential speakers at a Python conference are male, the chance of 4 out 6 speakers being female is fairly low if gender is ignored. Some people think gender diversity in tech is so important that there should be gender preferences -- see for example this post by a Python blogger http://ilovesymposia.com/2015/04/03/calling-out-scipy-on-diversity/ . It is plausible that the organizers preferred female keynote speakers. Can the OP comment on this? From jon+usenet at unequivocal.co.uk Fri Jul 10 17:41:07 2015 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Fri, 10 Jul 2015 21:41:07 +0000 (UTC) Subject: The EuroPython 2015 Keynotes References: <61f0400e-a882-448f-8116-e2df3ff4aaae@googlegroups.com> <873e46e8-b117-42a5-a863-b40ee2823ea6@googlegroups.com> Message-ID: On 2015-07-10, beliavsky at aol.com wrote: > On Friday, July 10, 2015 at 2:58:18 PM UTC-4, Chris Angelico wrote: >> On Fri, Jul 10, 2015 at 10:01 PM, beliavsky--- via Python-list >> wrote: >> > On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg wrote: >> >> With Mandy Waite we have announced all keynotes for EuroPython 2015: >> >> 5 keynotes, 6 speakers, 4 women and 2 men. >> > >> > Your mentioning these numbers makes me wonder if the organizing >> > committee is using gender preferences in its selection of keynote >> > speakers. I hope not. It is better to choose the speakers who >> > will give the most interesting talks and let the demographic >> > chips fall where they may. >> >> I think that's more a matter of having the statistically-curious >> brain. In my father's family, there are 5 sons and 2 daughters - does >> that indicate gender preference in my reporting, or just an >> acknowledgement of a fact? > > If 80% of Python programmers and potential speakers at a Python > conference are male, the chance of 4 out 6 speakers being female is > fairly low if gender is ignored. Some people think gender diversity > in tech is so important that there should be gender preferences -- > see for example this post by a Python blogger > http://ilovesymposia.com/2015/04/03/calling-out-scipy-on-diversity/ > . It is plausible that the organizers preferred female keynote > speakers. I certainly hope they did, and applaud them if so. From nickgeovanis at gmail.com Fri Jul 10 19:06:39 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Fri, 10 Jul 2015 16:06:39 -0700 (PDT) Subject: pygtk2 and colors In-Reply-To: <654cbc5a-9142-4276-9b53-4e2d3a685c12@googlegroups.com> References: <3b7fcd33-8ba6-44f7-abf8-ad55458eb96a@googlegroups.com> <97288ef7-1d9e-4afc-b4e3-534582ccd059@googlegroups.com> <654cbc5a-9142-4276-9b53-4e2d3a685c12@googlegroups.com> Message-ID: I may be phrasing this question improperly, but...If I need a canvas or canvas-like object, does GTK3/pygobject provide one? Or only GTK2/PyGTK? The answer seems to be "only GTK2/PyGTK" but the discussion I find online doesn't seem to have a clear answer. From tjreedy at udel.edu Fri Jul 10 19:14:25 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 10 Jul 2015 19:14:25 -0400 Subject: The EuroPython 2015 Keynotes In-Reply-To: <873e46e8-b117-42a5-a863-b40ee2823ea6@googlegroups.com> References: <61f0400e-a882-448f-8116-e2df3ff4aaae@googlegroups.com> <873e46e8-b117-42a5-a863-b40ee2823ea6@googlegroups.com> Message-ID: On 7/10/2015 5:14 PM, beliavsky--- via Python-list wrote: > On Friday, July 10, 2015 at 2:58:18 PM UTC-4, Chris Angelico wrote: >> On Fri, Jul 10, 2015 at 10:01 PM, beliavsky--- via Python-list >> wrote: >>> On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg >>> wrote: >>>> With Mandy Waite we have announced all keynotes for EuroPython >>>> 2015: 5 keynotes, 6 speakers, 4 women and 2 men. >>> Your mentioning these numbers makes me wonder if the organizing >>> committee is using gender preferences in its selection of keynote >>> speakers. I am sure they did, just as most organizing committees have been doing for decades, though in the opposite direction. However, 2 of the 4 women are the founders of PyLadies, who I presume will talk about the successes and lessons of their work. Eliminating them, we have a balanced 2 and 2. About time. > If 80% of Python programmers and potential speakers at a Python > conference are male, the chance of 4 out 6 speakers being female is > fairly low if gender is ignored. Some people think gender diversity > in tech is so important that there should be gender preferences -- > see for example this post by a Python blogger > http://ilovesymposia.com/2015/04/03/calling-out-scipy-on-diversity/ . It is a real fact that some members of the tech community have tried to make people with female bodies feel unwelcome. (Hardly unique, the same is true of the academic community, for instance.) I strongly feel that all Python programmers who respect others should be respected and welcome. > It is plausible that the organizers preferred female keynote > speakers. Assume so and don't go if it bothers you. Let us hope that this is a non-issue within a decade. > Can the OP comment on this? Mark has better things to do, like continuing preparing for the conference. -- Terry Jan Reedy From c.buhtz at posteo.jp Fri Jul 10 20:01:56 2015 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Sat, 11 Jul 2015 02:01:56 +0200 Subject: [setuptools] install data-file in users home-dir In-Reply-To: References: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> Message-ID: <3mSryL0jHmzFpVq@dovecot04.posteo.de> On 2015-07-10 09:39 Chris Warrick wrote: > And you should not create the files in your install script. Instead, > install them to a different data dir (somewhere in 'share/appname', or > alongside your package). When someone runs your app, only then you > should copy this file to user?s config directory I have to check if there still is a user config file. When doing this with the app itself, the check would be done while each start - what is quite unnecessary. From random832 at fastmail.us Fri Jul 10 20:24:04 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Fri, 10 Jul 2015 20:24:04 -0400 Subject: Trouble getting to windows My Documents directory In-Reply-To: <20150710094607.66e62712@bigbox.christie.dr> References: <20150710094607.66e62712@bigbox.christie.dr> Message-ID: <1436574244.1600780.320804625.4F9C0CE1@webmail.messagingengine.com> The My Documents directory is not guaranteed to be named "Documents". On older versions of windows it was "My Documents", and on foreign versions of windows it is a name in their language. The correct way to get the path of this folder is, for example (couldn't test since I'm on a mac right now) import ctypes from ctypes import wintypes CSIDL_PERSONAL = 5 SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW pszPath = ctypes.create_unicode_buffer(wintypes.MAX_PATH) SHGetFolderPath.argtypes = [wintypes.HWND, ctypes.c_int, wintypes.HANDLE, wintypes.DWORD, LPWSTR] SHGetFolderPath.restype = wintypes.HRESULT hResult = SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, pszPath) if hResult == 0: print pszPath.value else raise OSError("Could not find My Documents directory") Linux systems generally provide their own way to get it (e.g. xdg-user-dirs), on OSX everything I can find indicates it really is always ~/Documents . From rosuav at gmail.com Fri Jul 10 20:40:35 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 10:40:35 +1000 Subject: [setuptools] install data-file in users home-dir In-Reply-To: <3mSryL0jHmzFpVq@dovecot04.posteo.de> References: <3mSGXb0tfQzFpW3@dovecot04.posteo.de> <3mSryL0jHmzFpVq@dovecot04.posteo.de> Message-ID: On Sat, Jul 11, 2015 at 10:01 AM, wrote: > On 2015-07-10 09:39 Chris Warrick wrote: >> And you should not create the files in your install script. Instead, >> install them to a different data dir (somewhere in 'share/appname', or >> alongside your package). When someone runs your app, only then you >> should copy this file to user?s config directory > > I have to check if there still is a user config file. > When doing this with the app itself, the check would be done while each > start - what is quite unnecessary. Wrong. It is completely necessary. What happens if (a) the user deletes the config file? (b) a different user runs the app? (c) a hard drive melt-down wipes out all home directories, and the sysadmin restores from last night's backup (which was before the app was installed)? You MUST check for the absence of the user config file. Most programs will be expected to function correctly after having their configs wiped out - it's a standard way of saying "go back to all defaults". ChrisA From kwpolska at gmail.com Sat Jul 11 03:28:26 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Sat, 11 Jul 2015 09:28:26 +0200 Subject: Trouble getting to windows My Documents directory In-Reply-To: <1436574244.1600780.320804625.4F9C0CE1@webmail.messagingengine.com> References: <20150710094607.66e62712@bigbox.christie.dr> <1436574244.1600780.320804625.4F9C0CE1@webmail.messagingengine.com> Message-ID: On 11 July 2015 at 02:24, wrote: > The My Documents directory is not guaranteed to be named "Documents". On > older versions of windows it was "My Documents", and on foreign versions > of windows it is a name in their language. That?s not necessarily ?older?. Windows XP/7/8: My Documents Windows Vista/8.1: Documents As for localized versions, Vista and up do the translation in Windows Explorer but use English names on disk. ?but even with all that, users (or their administrators) can move the My Documents folder away from the home directory (to a file server, for example). -- Chris Warrick PGP: 5EAAEA16 From zonzely1004 at gmail.com Sat Jul 11 04:23:51 2015 From: zonzely1004 at gmail.com (Zely Zon) Date: Sat, 11 Jul 2015 01:23:51 -0700 (PDT) Subject: How to use Tornado.gen.coroutine in TCP Server? Message-ID: <7478ee83-4a7a-4951-9f60-899a4e843d53@googlegroups.com> hi ,evreyone! i want to know how to user tornado.gen.coroutine in Tcp server? here is my question link in stackoverflow. http://stackoverflow.com/questions/31353861/how-to-use-tornado-gen-coroutine-in-tcp-server thank you ! From simon.ball46 at virginmedia.com Sat Jul 11 05:06:11 2015 From: simon.ball46 at virginmedia.com (Simon Ball) Date: Sat, 11 Jul 2015 10:06:11 +0100 Subject: Python 3.5.0b3(64 bit) - idle refused to work on windows 7 desktop pc. Message-ID: Good morning, Everything else appeared to work though. Kept getting the windows 'donut' telling me it was doing something, but then the program did not appear. Windows 7 Home Premium Service Pack 1 intel 64 bit pc. Kind regards Simon Ball Luton Bedfordshire UK -- Using Opera's mail client: http://www.opera.com/mail/ From framstag at rus.uni-stuttgart.de Sat Jul 11 05:28:43 2015 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Sat, 11 Jul 2015 09:28:43 +0000 (UTC) Subject: beginners choice: wx or tk? Message-ID: I want to start a project with python. The program must have a (simple) GUI and must run on Linux and Windows. The last one as standalone executable, created with pyinstaller. I have already an implementation in perl/tk : http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png http://fex.belwue.de/download/schwuppdiwupp.pl I am not really happy with tk, because it has some bugs, at least its perl integration. I have never used wx. What is the recommendation for a python beginner: wx or tk? -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ From rosuav at gmail.com Sat Jul 11 05:35:39 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 19:35:39 +1000 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: On Sat, Jul 11, 2015 at 7:28 PM, Ulli Horlacher wrote: > I want to start a project with python. > The program must have a (simple) GUI and must run on Linux and Windows. > The last one as standalone executable, created with pyinstaller. Not sure what your advantage is with pyinstaller, it adds a level of complication that doesn't usually justify itself IMO. > I have already an implementation in perl/tk : > http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png > http://fex.belwue.de/download/schwuppdiwupp.pl > > I am not really happy with tk, because it has some bugs, at least its perl > integration. I have never used wx. > > What is the recommendation for a python beginner: wx or tk? Using wxPython means you need another library, while tkinter comes with Python. There are some limitations to tk, and I personally don't like its style, but if you're wanting to package it up into an EXE, every third-party library you add will increase the size of that EXE, potentially quite significantly (wxPython will drag in everything that it depends on, which IIRC is quite a bit). There are other choices, too - pygtk/pygobject (GTK) and pyqt (Qt) come to mind - is there a particular reason you're limiting the question to just wx vs tk? Personally, I quite like GTK, but I don't have much experience with either of the Python bindings. Never used wxPython or PyQt. ChrisA From framstag at rus.uni-stuttgart.de Sat Jul 11 05:51:20 2015 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Sat, 11 Jul 2015 09:51:20 +0000 (UTC) Subject: beginners choice: wx or tk? References: Message-ID: Chris Angelico wrote: > On Sat, Jul 11, 2015 at 7:28 PM, Ulli Horlacher > wrote: > > I want to start a project with python. > > The program must have a (simple) GUI and must run on Linux and Windows. > > The last one as standalone executable, created with pyinstaller. > > Not sure what your advantage is with pyinstaller, it adds a level of > complication that doesn't usually justify itself IMO. I am not addicted to pyinstaller. It just works. Do you have a better alternative? > Using wxPython means you need another library, while tkinter comes > with Python. pyinstaller can make a standalone executable, there is no need for the users to install "another library". They just click on the program icon, that's it. > There are other choices, too - pygtk/pygobject (GTK) and pyqt (Qt) > come to mind Both create BIG executables, much bigger than with wx or tk. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ From breamoreboy at yahoo.co.uk Sat Jul 11 05:56:32 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Jul 2015 10:56:32 +0100 Subject: Python 3.5.0b3(64 bit) - idle refused to work on windows 7 desktop pc. In-Reply-To: References: Message-ID: On 11/07/2015 10:06, Simon Ball wrote: > Good morning, > > Everything else appeared to work though. > Kept getting the windows 'donut' telling > me it was doing something, but then > the program did not appear. > > Windows 7 Home Premium Service Pack 1 intel 64 bit pc. > > Kind regards > Simon Ball > > Luton > Bedfordshire > UK > Please state exactly what you did to try and run the program, e.g. click on a desktop shortcut or something on the start menu, or what you typed at the command line prompt. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Sat Jul 11 06:01:24 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Jul 2015 11:01:24 +0100 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: On 11/07/2015 10:28, Ulli Horlacher wrote: > I want to start a project with python. > The program must have a (simple) GUI and must run on Linux and Windows. > The last one as standalone executable, created with pyinstaller. > > I have already an implementation in perl/tk : > http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png > http://fex.belwue.de/download/schwuppdiwupp.pl > > I am not really happy with tk, because it has some bugs, at least its perl > integration. I have never used wx. > > What is the recommendation for a python beginner: wx or tk? > Right now if you only have the choice of wx or tk I'd stick with tk as it comes with Python 2 and 3, whereas wx is still in development for 3. However as Chris Angelico has already said there are other choices, see here https://wiki.python.org/moin/GuiProgramming for a comprehensive list. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From auriocus at gmx.de Sat Jul 11 06:19:24 2015 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sat, 11 Jul 2015 12:19:24 +0200 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: Am 11.07.15 um 11:28 schrieb Ulli Horlacher: > I want to start a project with python. > The program must have a (simple) GUI and must run on Linux and Windows. > The last one as standalone executable, created with pyinstaller. > > I have already an implementation in perl/tk : > http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png > http://fex.belwue.de/download/schwuppdiwupp.pl May I ask what is the reason to port this over to Python? Is it to learn Python, or do you want to use packages that are not available for Perl? Christian From rosuav at gmail.com Sat Jul 11 06:20:59 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 20:20:59 +1000 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: On Sat, Jul 11, 2015 at 7:51 PM, Ulli Horlacher wrote: > Chris Angelico wrote: > >> On Sat, Jul 11, 2015 at 7:28 PM, Ulli Horlacher >> wrote: >> > I want to start a project with python. >> > The program must have a (simple) GUI and must run on Linux and Windows. >> > The last one as standalone executable, created with pyinstaller. >> >> Not sure what your advantage is with pyinstaller, it adds a level of >> complication that doesn't usually justify itself IMO. > > I am not addicted to pyinstaller. It just works. > Do you have a better alternative? > > >> Using wxPython means you need another library, while tkinter comes >> with Python. > > pyinstaller can make a standalone executable, there is no need for the > users to install "another library". They just click on the program icon, > that's it. Yeah, I'd distribute the .py files and have done with it. Maybe do it up as a package and distribute it via pip, which allows you to fetch dependencies automatically. The supposed ease of "just click on the program icon" is all very well, but it means you have to have a whopping new download any time there's an update to your code (they have to redownload the entire binary even if you're using the same Python and the same libraries), and you have to distribute a whole bunch of different versions (32-bit vs 64-bit, possibly different builds for different Windowses, etc), and deal with the support issues from people who grabbed the wrong one. Once Python itself has been installed, users can still normally "just click on the program icon" even though it's a .py file - that's the whole point of file associations. And then their installed Python can be updated by the normal mechanisms, and your code will happily run on the new version. Suppose, for instance, that your program does something over HTTPS, and people are using it in a critical environment... and then someone discovers a flaw in OpenSSL, which has happened now and then. A bugfix release of CPython will fix that instantly for everyone who's using the standard python.org downloads; but if you've packaged up your own Python, it'll be frozen at whatever version you had when you built that - which might not even be the latest available at the time. How quickly will you get around to building new installers? Much better to distribute Python code without an interpreter, and let people get their own interpreters. ChrisA From c.candide at laposte.net Sat Jul 11 06:26:32 2015 From: c.candide at laposte.net (candide) Date: Sat, 11 Jul 2015 03:26:32 -0700 (PDT) Subject: 0 + not 0 Message-ID: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> >>> 0 + not 0 File "", line 1 0 + not 0 ^ SyntaxError: invalid syntax >>> What is syntactically wrong with 0 + not 0? From rosuav at gmail.com Sat Jul 11 06:38:52 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 20:38:52 +1000 Subject: 0 + not 0 In-Reply-To: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> Message-ID: On Sat, Jul 11, 2015 at 8:26 PM, candide wrote: >>>> 0 + not 0 > File "", line 1 > 0 + not 0 > ^ > SyntaxError: invalid syntax >>>> > > > What is syntactically wrong with 0 + not 0? I'm actually not sure why this can't be handled. Possibly it's a limitation of the parser. Certainly 0 + (not 0) works just fine. This suggests that the exponentiation operator may have been special-cased to cope with this: https://docs.python.org/3/reference/expressions.html#id21 So maybe there's just no corresponding special case for this - which, I have to say, is not exactly a common construct. ChrisA From irmen.NOSPAM at xs4all.nl Sat Jul 11 06:38:57 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Sat, 11 Jul 2015 12:38:57 +0200 Subject: 0 + not 0 In-Reply-To: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> Message-ID: <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> On 11-7-2015 12:26, candide wrote: >>>> 0 + not 0 > File "", line 1 > 0 + not 0 > ^ > SyntaxError: invalid syntax >>>> > > > What is syntactically wrong with 0 + not 0? > I would say that the boolean operator 'not' cannot occur in an arithmetic expression. Maybe you meant to use the bitwise not: >>> 0 + ~0 -1 Irmen From luuk at invalid.lan Sat Jul 11 07:12:54 2015 From: luuk at invalid.lan (Luuk) Date: Sat, 11 Jul 2015 13:12:54 +0200 Subject: 0 + not 0 In-Reply-To: <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> Message-ID: <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> On 11-7-2015 12:38, Irmen de Jong wrote: > On 11-7-2015 12:26, candide wrote: >>>>> 0 + not 0 >> File "", line 1 >> 0 + not 0 >> ^ >> SyntaxError: invalid syntax >>>>> >> >> >> What is syntactically wrong with 0 + not 0? >> > > I would say that the boolean operator 'not' cannot occur in an arithmetic expression. > Maybe you meant to use the bitwise not: > >>>> 0 + ~0 > -1 > > > Irmen > It can occur in an arithmetic expression, and 'not' has a higher precedence than '+' (https://docs.python.org/2/reference/expressions.html#operator-precedence) 0 + not 0 should evalutate to 0 + True 1 just like this does: 0 + (not 0) 1 True + True 2 But, it gets confusing...... >>> not 0 + 1 False >>> not 0 True >>> True + 1 2 >>> i would expect 'not 0 + 1' to return the same value as 'True + 1' From rosuav at gmail.com Sat Jul 11 07:20:13 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 21:20:13 +1000 Subject: 0 + not 0 In-Reply-To: <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> Message-ID: On Sat, Jul 11, 2015 at 9:12 PM, Luuk wrote: > It can occur in an arithmetic expression, and 'not' has a higher precedence > than '+' > (https://docs.python.org/2/reference/expressions.html#operator-precedence) > I think you're misreading the table; 'not' has *lower* precedence than '+'. > But, it gets confusing...... >>>> not 0 + 1 > False >>>> not 0 > True >>>> True + 1 > 2 >>>> > > i would expect 'not 0 + 1' to return the same value as 'True + 1' (not 0 + 1) == (not (0 + 1)) ChrisA From lac at openend.se Sat Jul 11 07:27:13 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 11 Jul 2015 13:27:13 +0200 Subject: beginners choice: wx or tk? In-Reply-To: Message from Ulli Horlacher of "Sat, 11 Jul 2015 09:28:43 -0000." References: Message-ID: <201507111127.t6BBRDMM020948@fido.openend.se> In a message of Sat, 11 Jul 2015 09:28:43 -0000, Ulli Horlacher writes: >I want to start a project with python. >The program must have a (simple) GUI and must run on Linux and Windows. >The last one as standalone executable, created with pyinstaller. > >I have already an implementation in perl/tk : >http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png >http://fex.belwue.de/download/schwuppdiwupp.pl > >I am not really happy with tk, because it has some bugs, at least its perl >integration. I have never used wx. > >What is the recommendation for a python beginner: wx or tk? > >-- >Ullrich Horlacher Server und Virtualisierung >Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de >Universitaet Stuttgart Tel: ++49-711-68565868 >Allmandring 30a Fax: ++49-711-682357 >70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ If you already have a tk version, then tkinter will be a whole lot more familiar with you. The question is, why do you want to reimplement this thing in Python? If the plan is to get rid of some perl and tk bugs, then it would be good to check if the bugs exist in tkinter + python as well. One of the strengths of wxPython was supposed to be that the signatures of things was very like what windows developers were already used to when writing windows code. Since I never had a windows machine to develop code on, I wasn't one of the people who was already used to things like this, so that was no benefit to me. I tried it for a bit and discovered I liked PyQT better, so I learned that instead. But I don't think that this means that one is better than the other, so much as 'try them for a bit and see what you like'. Tk works with Python 3. wxPython doesn't yet. So if your porting is being done 'because I want to learn Python' then it is probably Python 3 you want to learn, so that's a strong reason to use tkinter. Also, if you need your app to work with MacOS, be warned that you will need an older version of tk than the most recent one. This information is current: https://www.python.org/download/mac/tcltk/ Don't use 8.6 I'd also recommend kivy, which has the added advantage that if somebody wants to use your app from a cellphone or a tablet, it will just work. see: http://kivy.org/#home Laura From luuk at invalid.lan Sat Jul 11 07:30:29 2015 From: luuk at invalid.lan (Luuk) Date: Sat, 11 Jul 2015 13:30:29 +0200 Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> Message-ID: <55a0fe55$0$2875$e4fe514c@news.xs4all.nl> On 11-7-2015 13:20, Chris Angelico wrote: > On Sat, Jul 11, 2015 at 9:12 PM, Luuk wrote: >> It can occur in an arithmetic expression, and 'not' has a higher precedence >> than '+' >> (https://docs.python.org/2/reference/expressions.html#operator-precedence) >> > > I think you're misreading the table; 'not' has *lower* precedence than '+'. > >> But, it gets confusing...... >>>>> not 0 + 1 >> False >>>>> not 0 >> True >>>>> True + 1 >> 2 >>>>> >> >> i would expect 'not 0 + 1' to return the same value as 'True + 1' > > (not 0 + 1) == (not (0 + 1)) > > ChrisA > But operator precedence of 'not' is higher than of '+' ???? From c.candide at laposte.net Sat Jul 11 07:48:26 2015 From: c.candide at laposte.net (candide) Date: Sat, 11 Jul 2015 04:48:26 -0700 (PDT) Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> Message-ID: Le samedi 11 juillet 2015 13:21:03 UTC+2, Chris Angelico a ?crit?: > I think you're misreading the table; 'not' has *lower* precedence than '+'. > Right but Python docs helps a lot in misreading ;) Following the iconicity principle, it's pretty obvious that one has to display table priority beginning with items having the highest priority, cf. for instance table operator precedence for Java provided by oracle tutorial or for the C language as given by the K&R book. From c.candide at laposte.net Sat Jul 11 07:54:30 2015 From: c.candide at laposte.net (candide) Date: Sat, 11 Jul 2015 04:54:30 -0700 (PDT) Subject: 0 + not 0 In-Reply-To: <55a0fe55$0$2875$e4fe514c@news.xs4all.nl> References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> <55a0fe55$0$2875$e4fe514c@news.xs4all.nl> Message-ID: <57a9e100-5783-4d95-bb41-f1d19e757c16@googlegroups.com> Le samedi 11 juillet 2015 13:31:03 UTC+2, Luuk a ?crit?: > > But operator precedence of 'not' is higher than of '+' ???? Right but what does this prove? For instance, unary minus has higher precedence than exponentiation but the expression 2 ** -1 doesn't raise a syntax error. From auriocus at gmx.de Sat Jul 11 07:56:09 2015 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sat, 11 Jul 2015 13:56:09 +0200 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: Am 11.07.15 um 13:27 schrieb Laura Creighton: > Also, if you need your app to work with MacOS, be warned that you > will need an older version of tk than the most recent one. > This information is current: https://www.python.org/download/mac/tcltk/ > Don't use 8.6 I'm not sure how recent this really is. Kevin Walzer has done a lot of work to get recent Tcl/Tk (i.e. 8.6) running on OSX. The most recent ActiveTcl release is 8.6.4.1. I'm using exclusively Tk 8.6 on the Mac without problems. Christian From rosuav at gmail.com Sat Jul 11 08:05:03 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Jul 2015 22:05:03 +1000 Subject: 0 + not 0 In-Reply-To: <57a9e100-5783-4d95-bb41-f1d19e757c16@googlegroups.com> References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> <55a0fe55$0$2875$e4fe514c@news.xs4all.nl> <57a9e100-5783-4d95-bb41-f1d19e757c16@googlegroups.com> Message-ID: On Sat, Jul 11, 2015 at 9:54 PM, candide wrote: > Le samedi 11 juillet 2015 13:31:03 UTC+2, Luuk a ?crit : > >> >> But operator precedence of 'not' is higher than of '+' ???? > > > Right but what does this prove? For instance, unary minus has higher precedence than exponentiation but the expression > > 2 ** -1 > > doesn't raise a syntax error. You'll see down below a footnote referring to this as a special case. But I don't know the details of how it all works, so short of digging into the source code, I can't explain this any better. There are others on this list who can, I believe. ChrisA From c.candide at laposte.net Sat Jul 11 09:22:51 2015 From: c.candide at laposte.net (candide) Date: Sat, 11 Jul 2015 06:22:51 -0700 (PDT) Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> <55a0fe55$0$2875$e4fe514c@news.xs4all.nl> <57a9e100-5783-4d95-bb41-f1d19e757c16@googlegroups.com> Message-ID: <2db325c6-e9b2-4474-b2e9-e82dbf18647e@googlegroups.com> Le samedi 11 juillet 2015 14:05:58 UTC+2, Chris Angelico a ?crit?: > You'll see down below a footnote referring to this as a special case. I didn't spot the footnote and I don't regard it as dealing with a "special case": the footnote is paraphrasing the precedence hierarchy given by the table. I see it more as a glose (operator exponentiation is not so common in programming languages) or, better, a warning because precedence of unary minus is "between" two "multiplicative" operators (** and *). By the way, example provided by the doc in this footnote doesnt't properly illustrate the precedence of ** versus unary minus : whatever the precedence is, there is only one way to evaluate 2**-1. On the opposite, -1**2 (for instance) leads to two evaluations : (-1)**2 and -(1**2) and would provide an appropriate and better example. From storchaka at gmail.com Sat Jul 11 09:38:26 2015 From: storchaka at gmail.com (Serhiy Storchaka) Date: Sat, 11 Jul 2015 16:38:26 +0300 Subject: 0 + not 0 In-Reply-To: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> Message-ID: On 11.07.15 13:26, candide wrote: >>>> 0 + not 0 > File "", line 1 > 0 + not 0 > ^ > SyntaxError: invalid syntax >>>> > > > What is syntactically wrong with 0 + not 0? This looks as a bug to me. Please file a report on http://bugs.python.org. From lac at openend.se Sat Jul 11 10:48:17 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 11 Jul 2015 16:48:17 +0200 Subject: beginners choice: wx or tk? In-Reply-To: Message from Christian Gollwitzer of "Sat, 11 Jul 2015 13:56:09 +0200." References: Message-ID: <201507111448.t6BEmH6Z025227@fido.openend.se> In a message of Sat, 11 Jul 2015 13:56:09 +0200, Christian Gollwitzer writes: >Am 11.07.15 um 13:27 schrieb Laura Creighton: >> Also, if you need your app to work with MacOS, be warned that you >> will need an older version of tk than the most recent one. >> This information is current: https://www.python.org/download/mac/tcltk/ >> Don't use 8.6 > >I'm not sure how recent this really is. Kevin Walzer has done a lot of >work to get recent Tcl/Tk (i.e. 8.6) running on OSX. The most recent >ActiveTcl release is 8.6.4.1. I'm using exclusively Tk 8.6 on the Mac >without problems. > > Christian Unless I was misinformed 2 weeks or so ago when I asked, that is the problem. Tcl/Tk 8.6 works (and is shipped with) OSX, but tkinter and idle don't work with it. We will see what Ned Deily says when he gets around to reading this. Laura From c.candide at laposte.net Sat Jul 11 11:07:12 2015 From: c.candide at laposte.net (candide) Date: Sat, 11 Jul 2015 08:07:12 -0700 (PDT) Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> Message-ID: <9c11cfab-2b9e-4f80-9a80-2e21a823ce62@googlegroups.com> Le samedi 11 juillet 2015 15:38:51 UTC+2, Serhiy Storchaka a ?crit?: > This looks as a bug to me. Please file a report on http://bugs.python.org. OK, I'll report. From nad at acm.org Sat Jul 11 11:09:41 2015 From: nad at acm.org (Ned Deily) Date: Sat, 11 Jul 2015 08:09:41 -0700 Subject: beginners choice: wx or tk? References: <201507111448.t6BEmH6Z025227@fido.openend.se> Message-ID: In article <201507111448.t6BEmH6Z025227 at fido.openend.se>, Laura Creighton wrote: > In a message of Sat, 11 Jul 2015 13:56:09 +0200, Christian Gollwitzer writes: > >Am 11.07.15 um 13:27 schrieb Laura Creighton: > >> Also, if you need your app to work with MacOS, be warned that you > >> will need an older version of tk than the most recent one. > >> This information is current: https://www.python.org/download/mac/tcltk/ > >> Don't use 8.6 > >I'm not sure how recent this really is. Kevin Walzer has done a lot of > >work to get recent Tcl/Tk (i.e. 8.6) running on OSX. The most recent > >ActiveTcl release is 8.6.4.1. I'm using exclusively Tk 8.6 on the Mac > >without problems. > Unless I was misinformed 2 weeks or so ago when I asked, that is the > problem. Tcl/Tk 8.6 works (and is shipped with) OSX, but tkinter > and idle don't work with it. We will see what Ned Deily says > when he gets around to reading this. Apple still does not ship 8.6 with OS X, only 8.5 (as of OS X 10.6) and, for backwards compatibility, 8.4. That's why the python.org Python installers for OS X do not yet use 8.6. ActiveState does provide an OS X installer for Tcl/Tk 8.6 but it is not open source; assuming your use is compatible with their (liberal) license, you can build your own Python linking with it. Also, some third-party package managers for OS X supply a Python linked with their own Tcl/Tk 8.6, e.g. MacPorts. We haven't wanted to get into the business of building and shipping our own Tcl/Tk for python.org OS X installers but, because of Apple's recent poor support for Tcl/Tk, we more or less need to; it's on the list of future enhancements. -- Ned Deily, nad at acm.org From ernest.bonat at gmail.com Sat Jul 11 11:15:00 2015 From: ernest.bonat at gmail.com (Ernest Bonat, Ph.D.) Date: Sat, 11 Jul 2015 08:15:00 -0700 Subject: =?UTF-8?Q?Python_Error=3A_ImportError=3A_No_module_named_=27=27folder=5F?= =?UTF-8?Q?name=E2=80=99_at_Command_Prompt?= Message-ID: Hi All, I?m doing a CSV data analysis in Python using Eclipse IDE/PyDev. I have organized my project using the standard MVC architecture. In Eclipse IDE everything is working properly. When I run my main.py file it at Command Prompt I got an error: ImportError: No module named 'folder_name'. It?s like the location path of the ?'folder_name? was not found. Do I need to update my main.py file to run it at the Command Prompt? Thank you for all your help, Thanks Ernest Bonat, Ph.D. Senior Software Engineer | Senior Data Analyst Visual WWW, Inc. | President and CEO 115 NE 39th Avenue | Hillsboro, OR 97124 Cell: 503.730.4556 | Email: ernest.bonat at gmail.com *The content of this email is confidential. It is intended only for the use of the persons named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.* -------------- next part -------------- An HTML attachment was scrubbed... URL: From framstag at rus.uni-stuttgart.de Sat Jul 11 12:01:05 2015 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Sat, 11 Jul 2015 16:01:05 +0000 (UTC) Subject: beginners choice: wx or tk? References: Message-ID: Laura Creighton wrote: > The question is, why do you want to reimplement this thing in Python? The Windows support of perl/pp (a perl "compiler" similar to pyinstall) is really bad. It does not work any more with Windows 7, I still have to use Windows XP. > If the plan is to get rid of some perl and tk bugs, then it would be good > to check if the bugs exist in tkinter + python as well. It's on my checklist :-) > Tk works with Python 3. wxPython doesn't yet. > So if your porting is being done 'because I want to learn Python' then it > is probably Python 3 you want to learn, so that's a strong reason to use > tkinter. Indeed! Thanks for the warning! Then I will go with python+tk. > I'd also recommend kivy, which has the added advantage that if > somebody wants to use your app from a cellphone or a tablet, it > will just work. see: http://kivy.org/#home Is it compatible with pyinstall? My main target architecture is Windows, for which I need a standalone executable. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ From framstag at rus.uni-stuttgart.de Sat Jul 11 12:04:57 2015 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Sat, 11 Jul 2015 16:04:57 +0000 (UTC) Subject: beginners choice: wx or tk? References: Message-ID: Christian Gollwitzer wrote: > > I have already an implementation in perl/tk : > > http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png > > http://fex.belwue.de/download/schwuppdiwupp.pl > > May I ask what is the reason to port this over to Python? Is it to learn > Python, or do you want to use packages that are not available for Perl? Both is true. It is a nice project to start learning python and perl/pp does not work any more with Windows 7, when one needs SSL/TLS. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ From python at mrabarnett.plus.com Sat Jul 11 12:20:58 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 11 Jul 2015 17:20:58 +0100 Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> Message-ID: <55A1426A.9000504@mrabarnett.plus.com> On 2015-07-11 17:02, Stefan Ram wrote: > Serhiy Storchaka writes: >>On 11.07.15 13:26, candide wrote: >>>>>> 0 + not 0 >>> File "", line 1 >>> 0 + not 0 >>> ^ >>> SyntaxError: invalid syntax >>> What is syntactically wrong with 0 + not 0? >>This looks as a bug to me. Please file a report > > I look at Python 3.4.3: > > a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr > > So, ?not 0? must be an ?m_expr? when used as the right operand of ?+?. > > m_expr ::= u_expr | m_expr "*" u_expr | m_expr "//" u_expr | m_expr "/" u_expr | m_expr "%" u_expr > u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr > power ::= primary ["**" u_expr] > primary ::= atom | attributeref | subscription | slicing | call > atom ::= identifier | literal | enclosure > enclosure ::= parenth_form | list_display | dict_display | set_display | generator_expression | yield_atom > > How can there be a ?not?? > > ?not? is used in > > not_test ::= comparison | "not" not_test > and_test ::= not_test | and_test "and" not_test > or_test ::= and_test | or_test "or" and_test > conditional_expression ::= or_test ["if" or_test "else" expression] > expression_nocond ::= or_test | lambda_expr_nocond > expression ::= conditional_expression | lambda_expr > > , but an ?expression? is not an ?m_expr?. > If "not" had the high priority of unary "-", then: not a < b would be parsed as: (not a) < b If you extended the OP's example to: 0 + not 0 + 0 and permitted "not" in that position, it wouldn't be parsed as: 0 + (not 0) + 0 but as: 0 + (not (0 + 0)) From nickgeovanis at gmail.com Sat Jul 11 12:26:18 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Sat, 11 Jul 2015 09:26:18 -0700 (PDT) Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: <0b848288-9d4e-4d85-a3e5-a41b35d51e73@googlegroups.com> I've recently been facing the same question but with a new (probably simpler) app than your own. I've decided to re-implement what I have in tk, replacing GTK in the python code. I am no expert in either but I find tk to be more coherent at the API level and better documented. However Windows and Mac support is not necessarily an issue for me. From ian.g.kelly at gmail.com Sat Jul 11 12:33:56 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Jul 2015 10:33:56 -0600 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: On Sat, Jul 11, 2015 at 3:35 AM, Chris Angelico wrote: > On Sat, Jul 11, 2015 at 7:28 PM, Ulli Horlacher > wrote: >> I want to start a project with python. >> The program must have a (simple) GUI and must run on Linux and Windows. >> The last one as standalone executable, created with pyinstaller. > > Not sure what your advantage is with pyinstaller, it adds a level of > complication that doesn't usually justify itself IMO. > >> I have already an implementation in perl/tk : >> http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png >> http://fex.belwue.de/download/schwuppdiwupp.pl >> >> I am not really happy with tk, because it has some bugs, at least its perl >> integration. I have never used wx. >> >> What is the recommendation for a python beginner: wx or tk? > > Using wxPython means you need another library, while tkinter comes > with Python. There are some limitations to tk, and I personally don't > like its style, but if you're wanting to package it up into an EXE, > every third-party library you add will increase the size of that EXE, > potentially quite significantly (wxPython will drag in everything that > it depends on, which IIRC is quite a bit). I've worked with wxPython + pyInstaller in the past, and IIRC the total size of those dependencies (roughly Python + wxPython + matplotlib + numpy + cx_Oracle + sqlalchemy + pywin32) clocked in at around 20 MB. From ian.g.kelly at gmail.com Sat Jul 11 12:56:04 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Jul 2015 10:56:04 -0600 Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> Message-ID: On Sat, Jul 11, 2015 at 10:02 AM, Stefan Ram wrote: > I look at Python 3.4.3: > > a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr > > So, ?not 0? must be an ?m_expr? when used as the right operand of ?+?. > > m_expr ::= u_expr | m_expr "*" u_expr | m_expr "//" u_expr | m_expr "/" u_expr | m_expr "%" u_expr > u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr > power ::= primary ["**" u_expr] > primary ::= atom | attributeref | subscription | slicing | call > atom ::= identifier | literal | enclosure > enclosure ::= parenth_form | list_display | dict_display | set_display | generator_expression | yield_atom > > How can there be a ?not?? > > ?not? is used in > > not_test ::= comparison | "not" not_test > and_test ::= not_test | and_test "and" not_test > or_test ::= and_test | or_test "or" and_test > conditional_expression ::= or_test ["if" or_test "else" expression] > expression_nocond ::= or_test | lambda_expr_nocond > expression ::= conditional_expression | lambda_expr > > , but an ?expression? is not an ?m_expr?. I must concur. The grammar as written does not actually produce 1 + not 0. I think it's still worthwhile opening a bug, because the behavior is surprising and possibly not intentional. From john_ladasky at sbcglobal.net Sat Jul 11 13:25:26 2015 From: john_ladasky at sbcglobal.net (John Ladasky) Date: Sat, 11 Jul 2015 10:25:26 -0700 (PDT) Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: On Saturday, July 11, 2015 at 2:51:32 AM UTC-7, Ulli Horlacher wrote: > Chris Angelico wrote: > > There are other choices, too - pygtk/pygobject (GTK) and pyqt (Qt) > > come to mind > > Both create BIG executables, much bigger than with wx or tk. I worked with wxPython back when I was using Python 2. I got impatient waiting for Phoenix when I switched to Python 3, so I started using PyQt as my GUI. I'm happy with PyQt. I haven't created standalone executable files with it, though. Do they necessarily have to be large? I would think that well-written import statements would cut down on the file size. Just import the objects you need, rather than the whole namespace. PyQt is even organized in sub-modules, apparently to encourage you to refrain from importing everything. From lac at openend.se Sat Jul 11 13:37:17 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 11 Jul 2015 19:37:17 +0200 Subject: beginners choice: wx or tk? In-Reply-To: Message from Ulli Horlacher of "Sat, 11 Jul 2015 16:01:05 -0000." References: Message-ID: <201507111737.t6BHbHHB028899@fido.openend.se> In a message of Sat, 11 Jul 2015 16:01:05 -0000, Ulli Horlacher writes: >> I'd also recommend kivy, which has the added advantage that if >> somebody wants to use your app from a cellphone or a tablet, it >> will just work. see: http://kivy.org/#home > >Is it compatible with pyinstall? >My main target architecture is Windows, for which I need a standalone >executable. Kivy has its own way to make standalone windows executables, which uses pyinstallers. see: http://kivy.org/docs/guide/packaging.html Laura From rosuav at gmail.com Sat Jul 11 13:39:20 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Jul 2015 03:39:20 +1000 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: On Sun, Jul 12, 2015 at 3:25 AM, John Ladasky wrote: > On Saturday, July 11, 2015 at 2:51:32 AM UTC-7, Ulli Horlacher wrote: >> Chris Angelico wrote: >> > There are other choices, too - pygtk/pygobject (GTK) and pyqt (Qt) >> > come to mind >> >> Both create BIG executables, much bigger than with wx or tk. > > I worked with wxPython back when I was using Python 2. I got impatient waiting for Phoenix when I switched to Python 3, so I started using PyQt as my GUI. > > I'm happy with PyQt. I haven't created standalone executable files with it, though. Do they necessarily have to be large? I would think that well-written import statements would cut down on the file size. Just import the objects you need, rather than the whole namespace. PyQt is even organized in sub-modules, apparently to encourage you to refrain from importing everything. > If there are submodules that you aren't importing, then it's possible they don't need to be included. But if you just import a few names from a module, you still need the entire module to be included. ChrisA From lac at openend.se Sat Jul 11 13:55:20 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 11 Jul 2015 19:55:20 +0200 Subject: beginners choice: wx or tk? In-Reply-To: Message from Laura Creighton of "Sat, 11 Jul 2015 19:37:17 +0200." <201507111737.t6BHbHHB028899@fido.openend.se> References: <201507111737.t6BHbHHB028899@fido.openend.se> Message-ID: <201507111755.t6BHtKaZ029496@fido.openend.se> In a message of Sat, 11 Jul 2015 19:37:17 +0200, Laura Creighton writes: >Kivy has its own way to make standalone windows executables, which >uses pyinstallers. s/pyinstallers/PyInstaller/ sorry about that. Laura From breamoreboy at yahoo.co.uk Sat Jul 11 16:05:13 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Jul 2015 21:05:13 +0100 Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> Message-ID: On 11/07/2015 17:56, Ian Kelly wrote: > On Sat, Jul 11, 2015 at 10:02 AM, Stefan Ram wrote: >> I look at Python 3.4.3: >> >> a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr >> >> So, ?not 0? must be an ?m_expr? when used as the right operand of ?+?. >> >> m_expr ::= u_expr | m_expr "*" u_expr | m_expr "//" u_expr | m_expr "/" u_expr | m_expr "%" u_expr >> u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr >> power ::= primary ["**" u_expr] >> primary ::= atom | attributeref | subscription | slicing | call >> atom ::= identifier | literal | enclosure >> enclosure ::= parenth_form | list_display | dict_display | set_display | generator_expression | yield_atom >> >> How can there be a ?not?? >> >> ?not? is used in >> >> not_test ::= comparison | "not" not_test >> and_test ::= not_test | and_test "and" not_test >> or_test ::= and_test | or_test "or" and_test >> conditional_expression ::= or_test ["if" or_test "else" expression] >> expression_nocond ::= or_test | lambda_expr_nocond >> expression ::= conditional_expression | lambda_expr >> >> , but an ?expression? is not an ?m_expr?. > > I must concur. The grammar as written does not actually produce 1 + > not 0. I think it's still worthwhile opening a bug, because the > behavior is surprising and possibly not intentional. > http://bugs.python.org/issue24612 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From torriem at gmail.com Sat Jul 11 16:16:14 2015 From: torriem at gmail.com (Michael Torrie) Date: Sat, 11 Jul 2015 14:16:14 -0600 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: <55A1798E.9070000@gmail.com> On 07/11/2015 11:39 AM, Chris Angelico wrote: >> I'm happy with PyQt. I haven't created standalone executable files with it, though. Do they necessarily have to be large? I would think that well-written import statements would cut down on the file size. Just import the objects you need, rather than the whole namespace. PyQt is even organized in sub-modules, apparently to encourage you to refrain from importing everything. >> > > If there are submodules that you aren't importing, then it's possible > they don't need to be included. But if you just import a few names > from a module, you still need the entire module to be included. It's not the size of the PyQt wrapper files themselves that are big. It's the Qt dlls. Last I worked with Qt, they added nearly 10 MB to an app bundle's size. You will have to ship them with your app one way or another. There is some modularity there. But at the very least you need QtCore and QtGui, which are between 8 and 15 MB total, depending on debugging symbols, qt version, etc. Qt 5 seems to be more modular; there are a lot more individual shared libraries that are smaller. From random832 at fastmail.us Sat Jul 11 16:46:29 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Sat, 11 Jul 2015 16:46:29 -0400 Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> <55a0f241$0$2933$e4fe514c@news2.news.xs4all.nl> <55a0fa36$0$2935$e4fe514c@news.xs4all.nl> Message-ID: <1436647589.2611252.321265601.4733354D@webmail.messagingengine.com> On Sat, Jul 11, 2015, at 07:20, Chris Angelico wrote: > On Sat, Jul 11, 2015 at 9:12 PM, Luuk wrote: > > It can occur in an arithmetic expression, and 'not' has a higher precedence > > than '+' > > (https://docs.python.org/2/reference/expressions.html#operator-precedence) > > > > I think you're misreading the table; 'not' has *lower* precedence than > '+'. Precedence shouldn't actually matter when resolving a unary prefix operator on the right of a binary operator. I don't understand how this could possibly be interpreted in a different valid way rather than being spuriously rejected as a syntax error. From musicalhacksaw at yahoo.co.uk Sat Jul 11 18:17:41 2015 From: musicalhacksaw at yahoo.co.uk (Simon Evans) Date: Sat, 11 Jul 2015 15:17:41 -0700 (PDT) Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? Message-ID: Dear Programmers, Thank you for your advice regarding giving the console a current address in the code for it to access the html file. The console seems to accept the code to that extent, but when I input the two lines of code intended to access the location of a required word, the console rejects it re : AttributeError:'NoneType' object has no attribute 'li' However the document 'EcologicalPyramid.html' does contain the words 'li' and 'ul', in its text. I am not sure as to how the input is arranged to output 'plants' which is also in the documents text, but that is the word the code is meant to elicit. I enclose the pertinent code as input and output from the console, and the html code for the document 'EcologicalPyramid.html' Thank you in advance for your help. --------------------------------------------------------------------- >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as ecological_pyramid: soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html","lxml") ... producer_entries = soup.find("ul") File "", line 2 producer_entries = soup.find("ul") ^ SyntaxError: invalid syntax >>> producer_entries = soup.find("ul") >>> print (producer_entries.li.div.string) Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'li' ---------------------------------------------------------------------- prin
  • plants
    100000
  • algae
    100000
  • deer
    1000
  • deer
    1000
  • rabbit
    2000
  • fox
    100
  • bear
    100
  • lion
    80
  • tiger
    50
From ian.burnette at gmail.com Sat Jul 11 18:20:50 2015 From: ian.burnette at gmail.com (Ian Burnette) Date: Sat, 11 Jul 2015 18:20:50 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) Message-ID: Hi there, First, please forgive me if this is the wrong venue to be suggesting this idea-- I'm just following the PEP workflow page . I've recently been playing around with Clojure, and I really like the way they've overcome the JVM not supporting TRE. The way Clojure solves this problem is to have a built in "recur" function that signals to the Clojure compiler to convert the code to a loop in the JVM. In python we could do something similar by having a *recur(*args, **kwargs)* function that removes its parent from the stack and then runs the parent function again with the given arguments. It would look something like this: def factorial(n, acc=1): if n == 0: return acc else: return recur(n-1, acc=(acc*n)) #signals to the interpreter to trigger TRE # Doesn't overflow the stack! factorial(30000) I've also created a plugin that mocks this behavior using the try/except looping method that others have utilized to implement TCO into python. Of course, my plugin still requires a decorator and the overhead of transmitting information through an exception. Implementing recur with interpreter support should lead to much better performance. I've read Guido's reasoning against dynamic TCO , but I believe many of his concerns can be boiled down to "I don't want the interpreter doing things the user didn't expect, and I just don't think this is important enough to affect everyone's experience". This recur approach solves that by giving functional python users the ability to explicitly tell the interpreter what they want without changing how other users interact with the interpreter. Guido also notes that TRE removes removes stack trace data. While a more subtle garbage collection scheme would help alleviate this problem, there's really no avoiding this. My only defense is that this solution is at least explicit, so users should know that they're implementing code that might produce a completely unhelpful stack trace. Thank you for your time and consideration; I hope this was at least interesting! All the best, Ian Burnette *Ian Burnette* Python/Django Developer Cox Media Group P: 843.478.5026 -------------- next part -------------- An HTML attachment was scrubbed... URL: From framstag at rus.uni-stuttgart.de Sat Jul 11 18:42:12 2015 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Sat, 11 Jul 2015 22:42:12 +0000 (UTC) Subject: beginners choice: wx or tk? References: Message-ID: Chris Angelico wrote: > > pyinstaller can make a standalone executable, there is no need for the > > users to install "another library". They just click on the program icon, > > that's it. > > Yeah, I'd distribute the .py files and have done with it. This is not an option for me. My users only accept standalone executables. They cannot install any runtime environment or extra libraries. > distribute a whole bunch of different versions (32-bit vs 64-bit, Is a 64 bit Windows unable to run 32 bit programs? > Suppose, for instance, that your program does something over HTTPS, and > people are using it in a critical environment... and then someone > discovers a flaw in OpenSSL, which has happened now and then. The same problem has docker - the newest and hottest computer hype ;-) > Much better to distribute Python code without an interpreter, and let > people get their own interpreters. Again: this is a no-go for me, because my users cannot accept it. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ From no.email at nospam.invalid Sat Jul 11 18:50:05 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Sat, 11 Jul 2015 15:50:05 -0700 Subject: beginners choice: wx or tk? References: Message-ID: <87wpy62tsy.fsf@jester.gateway.sonic.net> Ulli Horlacher writes: > This is not an option for me. My users only accept standalone executables. > They cannot install any runtime environment or extra libraries. Long ago I was involved with a thing like this and used Inno Setup, which was great. It's a very slick installer whose user experience is similar to Install Shield if you're familiar with that. I have no idea what current best practice is, but I see that Inno Setup is still around. From framstag at rus.uni-stuttgart.de Sat Jul 11 19:04:51 2015 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Sat, 11 Jul 2015 23:04:51 +0000 (UTC) Subject: beginners choice: wx or tk? References: <87wpy62tsy.fsf@jester.gateway.sonic.net> Message-ID: Paul Rubin wrote: > Ulli Horlacher writes: > > This is not an option for me. My users only accept standalone executables. > > They cannot install any runtime environment or extra libraries. > > Long ago I was involved with a thing like this and used Inno Setup, > which was great. It's a very slick installer It is not a matter of knowledge, but one of user rights. It is also forbidden by organization rules. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ From breamoreboy at yahoo.co.uk Sat Jul 11 19:06:46 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 12 Jul 2015 00:06:46 +0100 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: References: Message-ID: On 11/07/2015 23:17, Simon Evans wrote: > Dear Programmers, > Thank you for your advice regarding giving the console a current address in the code for it to access the html file. > > The console seems to accept the code to that extent, but when I input the two lines of code intended to access the location of a required word, the console rejects it re : > > AttributeError:'NoneType' object has no attribute 'li' > > However the document 'EcologicalPyramid.html' does contain the words 'li' and 'ul', in its text. I am not sure as to how the input is arranged to output 'plants' which is also in the documents text, but that is the word the code is meant to elicit. > > I enclose the pertinent code as input and output from the console, and the html code for the document 'EcologicalPyramid.html' > > Thank you in advance for your help. > > --------------------------------------------------------------------- >>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as ecological_pyramid: > soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html","lxml") Beautiful Soup takes a string or a file handle so as it's good practise to use the "with open" construct this should do it:- soup = BeautifulSoup(ecological_pyramid,"lxml") but do you actually need the "lxml", with the simple parsing I've done in the past I've never used it? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From no.email at nospam.invalid Sat Jul 11 19:10:30 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Sat, 11 Jul 2015 16:10:30 -0700 Subject: beginners choice: wx or tk? References: <87wpy62tsy.fsf@jester.gateway.sonic.net> Message-ID: <87si8u2sux.fsf@jester.gateway.sonic.net> Ulli Horlacher writes: >> Long ago I was involved with a thing like this and used Inno Setup, >> which was great. It's a very slick installer > It is not a matter of knowledge, but one of user rights. > It is also forbidden by organization rules. I might not understand what you're looking for. I thought you wanted a single .exe to give your users. Inno Setup packages up such a thing for you, making it very convenient for them. I think I used it in conjunction with py2exe, another Windows packaging tool that might or might not still be in use. Do you mean it's not ok for the setup tool to install files? Hmm. It might still be possible with py2exe. On the UI issue, I've always used tkinter and been satisfied with it, though the gui's I've done haven't been terribly fancy. tkinter is pretty easy to use and relatively portable, and included with python distros, so that made it my default choice. From tjreedy at udel.edu Sat Jul 11 19:54:20 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 11 Jul 2015 19:54:20 -0400 Subject: Python 3.5.0b3(64 bit) - idle refused to work on windows 7 desktop pc. In-Reply-To: References: Message-ID: On 7/11/2015 5:56 AM, Mark Lawrence wrote: > On 11/07/2015 10:06, Simon Ball wrote: >> Good morning, >> >> Everything else appeared to work though. >> Kept getting the windows 'donut' telling >> me it was doing something, but then >> the program did not appear. >> >> Windows 7 Home Premium Service Pack 1 intel 64 bit pc. >> >> Kind regards >> Simon Ball >> >> Luton >> Bedfordshire >> UK >> > > Please state exactly what you did to try and run the program, e.g. click > on a desktop shortcut or something on the start menu, or what you typed > at the command line prompt. And whether python itself runs without Idle. -- Terry Jan Reedy From framstag at rus.uni-stuttgart.de Sat Jul 11 19:55:42 2015 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Sat, 11 Jul 2015 23:55:42 +0000 (UTC) Subject: beginners choice: wx or tk? References: <87wpy62tsy.fsf@jester.gateway.sonic.net> <87si8u2sux.fsf@jester.gateway.sonic.net> Message-ID: Paul Rubin wrote: > Ulli Horlacher writes: > >> Long ago I was involved with a thing like this and used Inno Setup, > >> which was great. It's a very slick installer > > It is not a matter of knowledge, but one of user rights. > > It is also forbidden by organization rules. > > Do you mean it's not ok for the setup tool to install files? Yes, as I wrote before: They cannot install any files. My program for them must be a single click-and-run executable. > Hmm. It might still be possible with py2exe. What does py2exe better than pyinstaller? pyinstaller works for me. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ From ian.g.kelly at gmail.com Sat Jul 11 19:59:19 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Jul 2015 17:59:19 -0600 Subject: beginners choice: wx or tk? In-Reply-To: <87si8u2sux.fsf@jester.gateway.sonic.net> References: <87wpy62tsy.fsf@jester.gateway.sonic.net> <87si8u2sux.fsf@jester.gateway.sonic.net> Message-ID: On Sat, Jul 11, 2015 at 5:10 PM, Paul Rubin wrote: > Ulli Horlacher writes: >>> Long ago I was involved with a thing like this and used Inno Setup, >>> which was great. It's a very slick installer >> It is not a matter of knowledge, but one of user rights. >> It is also forbidden by organization rules. > > I might not understand what you're looking for. I thought you wanted a > single .exe to give your users. Inno Setup packages up such a thing for > you, making it very convenient for them. I think I used it in > conjunction with py2exe, another Windows packaging tool that might or > might not still be in use. Do you mean it's not ok for the setup tool > to install files? Hmm. It might still be possible with py2exe. Perhaps you've been misled by the talk about pyInstaller, which despite the name does not create installers. It merely creates a portable exe that runs the Python program contained in it, similar to py2exe. From tjreedy at udel.edu Sat Jul 11 20:02:45 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 11 Jul 2015 20:02:45 -0400 Subject: =?UTF-8?Q?Re:_Python_Error:_ImportError:_No_module_named_''folder?= =?UTF-8?Q?=5fname=e2=80=99_at_Command_Prompt?= In-Reply-To: References: Message-ID: On 7/11/2015 11:15 AM, Ernest Bonat, Ph.D. wrote: > Hi All, > > > I?m doing a CSV data analysis in Python using Eclipse IDE/PyDev. I have > organized my project using the standard MVC architecture. In Eclipse IDE > everything is working properly. When I run my main.py file it at Command > Prompt I got an error: ImportError: No module named 'folder_name'. It?s > like the location path of the ?'folder_name? was not found. Do I need to > update my main.py file to run it at the Command Prompt? 'import module' searches directories on sys.path for a file or directory named 'module'. sys.path starts with '.', which represents the 'current' directory. If you start with the directory containing main.py as current directory and 'folder-name' is in the same directory, the import should work. Otherwise ??? EclipseIDE probably modifies the current dir and/or path to make things work. For any more help, post the OS and locations of main.py, folder_name, and python. -- Terry Jan Reedy From jugurtha.hadjar at gmail.com Sat Jul 11 20:54:07 2015 From: jugurtha.hadjar at gmail.com (Jugurtha Hadjar) Date: Sun, 12 Jul 2015 01:54:07 +0100 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: <55A1BAAF.4010901@gmail.com> Hello, On 07/11/2015 11:20 AM, Chris Angelico wrote: > Yeah, I'd distribute the .py files and have done with it. Maybe do > it up as a package and distribute it via pip, which allows you to > fetch dependencies automatically. I'm also writing something, and the target audience is Windows users in a Treasury department, not really a command line crowd. The supposed ease of "just click on the > program icon" is all very well, but it means you have to have a > whopping new download any time there's an update to your code (they > have to redownload the entire binary even if you're using the same > Python and the same libraries), and you have to distribute a whole > bunch of different versions (32-bit vs 64-bit, possibly different > builds for different Windowses, etc), and deal with the support > issues from people who grabbed the wrong one. Let the feature creep begin... : Why not put the updates as diffs/patches? In any given change, there's only a part of the .EXE that will change and I can't think of a good reason to download the whole thing again like Google Chrome. This either requires using some third party tool for the patch, or rolling one's own. Once Python itself has been > installed, users can still normally "just click on the program icon" > even though it's a .py file - that's the whole point of file > associations. And then their installed Python can be updated by the > normal mechanisms, and your code will happily run on the new > version. Suppose, for instance, that your program does something over > HTTPS, and people are using it in a critical environment... and then > someone discovers a flaw in OpenSSL, which has happened now and then. > A bugfix release of CPython will fix that instantly for everyone > who's using the standard python.org downloads; but if you've packaged > up your own Python, it'll be frozen at whatever version you had when > you built that - which might not even be the latest available at the > time. How quickly will you get around to building new installers? > > Much better to distribute Python code without an interpreter, and > let people get their own interpreters. > I just found this: https://us.pycon.org/2012/schedule/presentation/393/ It's a talk titled "Deep Freeze: building better stand-alone apps with Python". I'll watch it later. > ChrisA > -- ~Jugurtha Hadjar, From kw at codebykevin.com Sat Jul 11 21:29:13 2015 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 11 Jul 2015 21:29:13 -0400 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: On 7/11/15 10:48 AM, Laura Creighton wrote: > Unless I was misinformed 2 weeks or so ago when I asked, that is the > problem. Tcl/Tk 8.6 works (and is shipped with) OSX, but tkinter > and idle don't work with it. We will see what Ned Deily says > when he gets around to reading this. You were misinformed. Tkinter has worked fine with Tk 8.6 for a long time. The issues with Tk on the Mac, owing to Apple's force migration of GUI libraries to Cocoa, have finally been more or less resolved, and Tk 8.6.4 is now quite stable on OS X. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From ernest.bonat at gmail.com Sun Jul 12 00:01:47 2015 From: ernest.bonat at gmail.com (Ernest Bonat, Ph.D.) Date: Sat, 11 Jul 2015 21:01:47 -0700 Subject: =?UTF-8?Q?Fwd=3A_Python_Error=3A_ImportError=3A_No_module_named_=27=27fo?= =?UTF-8?Q?lder=5Fname=E2=80=99_at_Command_Prompt?= In-Reply-To: <55A1E620.7070507@udel.edu> References: <55A1E620.7070507@udel.edu> Message-ID: Thanks Ernest Bonat, Ph.D. Senior Software Engineer | Senior Data Analyst Visual WWW, Inc. | President and CEO 115 NE 39th Avenue | Hillsboro, OR 97124 Cell: 503.730.4556 | Email: ernest.bonat at gmail.com *The content of this email is confidential. It is intended only for the use of the persons named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.* ---------- Forwarded message ---------- From: Terry Reedy Date: Sat, Jul 11, 2015 at 8:59 PM Subject: Re: Python Error: ImportError: No module named ''folder_name? at Command Prompt To: "Ernest Bonat, Ph.D." Please send this followup to python-list. On 7/11/2015 11:26 PM, Ernest Bonat, Ph.D. wrote: > Hey Terry, > > Thanks for your help. I had follow the link: How to add a Python module > to syspath? > < > http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath > > > and I could not make it work. I did use sys.path.insert() and > sys.path.append() as: > > Examples: sys.path.append('/python_mvc_calculator/calculator/') or > sys.path.insert(0, "/python_mvc_calculator/calculator") > > I did try it to: > sys.path.append('/python_mvc_calculator/calculator/controller') or > sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too! > > The main.py file is in python_mvc_calculator/calculator folder and I > need to import a module calculatorcontroller.py in > "python_mvc_calculator/calculator/controller" > > I hope this explanation helps a bit! > > < > http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath > > > > Thanks > > Ernest Bonat, Ph.D. > Senior Software Engineer | Senior Data Analyst > Visual WWW, Inc. | President and CEO > 115 NE 39th Avenue | Hillsboro, OR 97124 > Cell: 503.730.4556 | Email: ernest.bonat at gmail.com > > > /The content of this email is confidential. It is intended only for the > use of the persons named above. If you are not the intended recipient, > you are hereby notified that any review, dissemination, distribution or > duplication of this communication is strictly prohibited. If you are not > the intended recipient, please contact the sender by reply email and > destroy all copies of the original message./ > > On Sat, Jul 11, 2015 at 5:02 PM, Terry Reedy > wrote: > > On 7/11/2015 11:15 AM, Ernest Bonat, Ph.D. wrote: > > Hi All, > > > I?m doing a CSV data analysis in Python using Eclipse IDE/PyDev. > I have > organized my project using the standard MVC architecture. In > Eclipse IDE > everything is working properly. When I run my main.py file it at > Command > Prompt I got an error: ImportError: No module named > 'folder_name'. It?s > like the location path of the ?'folder_name? was not found. Do I > need to > update my main.py file to run it at the Command Prompt? > > > 'import module' searches directories on sys.path for a file or > directory named 'module'. sys.path starts with '.', which > represents the 'current' directory. If you start with the directory > containing main.py as current directory and 'folder-name' is in the > same directory, the import should work. Otherwise ??? EclipseIDE > probably modifies the current dir and/or path to make things work. > > For any more help, post the OS and locations of main.py, > folder_name, and python. > > -- > Terry Jan Reedy > > > -- > https://mail.python.org/mailman/listinfo/python-list > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ernest.bonat at gmail.com Sun Jul 12 00:02:49 2015 From: ernest.bonat at gmail.com (Ernest Bonat, Ph.D.) Date: Sat, 11 Jul 2015 21:02:49 -0700 Subject: =?UTF-8?Q?Fwd=3A_Python_Error=3A_ImportError=3A_No_module_named_=27=27fo?= =?UTF-8?Q?lder=5Fname=E2=80=99_at_Command_Prompt?= In-Reply-To: <55A1E620.7070507@udel.edu> References: <55A1E620.7070507@udel.edu> Message-ID: Thanks for your help. I had follow the link: How to add a Python module to syspath? and I could not make it work. I did use sys.path.insert() and sys.path.append() as: Examples: sys.path.append('/python_mvc_calculator/calculator/') or sys.path.insert(0, "/python_mvc_calculator/calculator") I did try it to: sys.path.append('/python_mvc_calculator/calculator/controller') or sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too! The main.py file is in python_mvc_calculator/calculator folder and I need to import a module calculatorcontroller.py in "python_mvc_calculator/calculator/controller" I hope this explanation helps a bit! Thanks Ernest Bonat, Ph.D. Senior Software Engineer | Senior Data Analyst Visual WWW, Inc. | President and CEO 115 NE 39th Avenue | Hillsboro, OR 97124 Cell: 503.730.4556 | Email: ernest.bonat at gmail.com /The content of this email is confidential. It is intended only for the use of the persons named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message./ ---------- Forwarded message ---------- From: Terry Reedy Date: Sat, Jul 11, 2015 at 8:59 PM Subject: Re: Python Error: ImportError: No module named ''folder_name? at Command Prompt To: "Ernest Bonat, Ph.D." Please send this followup to python-list. On 7/11/2015 11:26 PM, Ernest Bonat, Ph.D. wrote: > Hey Terry, > > Thanks for your help. I had follow the link: How to add a Python module > to syspath? > < > http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath > > > and I could not make it work. I did use sys.path.insert() and > sys.path.append() as: > > Examples: sys.path.append('/python_mvc_calculator/calculator/') or > sys.path.insert(0, "/python_mvc_calculator/calculator") > > I did try it to: > sys.path.append('/python_mvc_calculator/calculator/controller') or > sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too! > > The main.py file is in python_mvc_calculator/calculator folder and I > need to import a module calculatorcontroller.py in > "python_mvc_calculator/calculator/controller" > > I hope this explanation helps a bit! > > < > http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath > > > > Thanks > > Ernest Bonat, Ph.D. > Senior Software Engineer | Senior Data Analyst > Visual WWW, Inc. | President and CEO > 115 NE 39th Avenue | Hillsboro, OR 97124 > Cell: 503.730.4556 | Email: ernest.bonat at gmail.com > > > /The content of this email is confidential. It is intended only for the > use of the persons named above. If you are not the intended recipient, > you are hereby notified that any review, dissemination, distribution or > duplication of this communication is strictly prohibited. If you are not > the intended recipient, please contact the sender by reply email and > destroy all copies of the original message./ > > On Sat, Jul 11, 2015 at 5:02 PM, Terry Reedy > wrote: > > On 7/11/2015 11:15 AM, Ernest Bonat, Ph.D. wrote: > > Hi All, > > > I?m doing a CSV data analysis in Python using Eclipse IDE/PyDev. > I have > organized my project using the standard MVC architecture. In > Eclipse IDE > everything is working properly. When I run my main.py file it at > Command > Prompt I got an error: ImportError: No module named > 'folder_name'. It?s > like the location path of the ?'folder_name? was not found. Do I > need to > update my main.py file to run it at the Command Prompt? > > > 'import module' searches directories on sys.path for a file or > directory named 'module'. sys.path starts with '.', which > represents the 'current' directory. If you start with the directory > containing main.py as current directory and 'folder-name' is in the > same directory, the import should work. Otherwise ??? EclipseIDE > probably modifies the current dir and/or path to make things work. > > For any more help, post the OS and locations of main.py, > folder_name, and python. > > -- > Terry Jan Reedy > > > -- > https://mail.python.org/mailman/listinfo/python-list > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From no.email at nospam.invalid Sun Jul 12 00:34:13 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Sat, 11 Jul 2015 21:34:13 -0700 Subject: beginners choice: wx or tk? References: <87wpy62tsy.fsf@jester.gateway.sonic.net> <87si8u2sux.fsf@jester.gateway.sonic.net> Message-ID: <87lhem2dve.fsf@jester.gateway.sonic.net> Ulli Horlacher writes: >> Do you mean it's not ok for the setup tool to install files? > Yes, as I wrote before: They cannot install any files. You wrote before that the users couldn't install files, but it wasn't clear before that the setup tool also can't install files. >> Hmm. It might still be possible with py2exe. > What does py2exe better than pyinstaller? > pyinstaller works for me. I don't know anything about pyinstaller. I used py2exe and it worked, so I mentioned that in case the info is useful. If pyinstaller also works, that's great, it sounds like your problem is solved. From nad at acm.org Sun Jul 12 01:01:25 2015 From: nad at acm.org (Ned Deily) Date: Sat, 11 Jul 2015 22:01:25 -0700 Subject: beginners choice: wx or tk? References: 436626130.3674..ython-list@pythhhhhhhh Message-ID: In article , Kevin Walzer wrote: > On 7/11/15 10:48 AM, Laura Creighton wrote: > > Unless I was misinformed 2 weeks or so ago when I asked, that is the > > problem. Tcl/Tk 8.6 works (and is shipped with) OSX, but tkinter > > and idle don't work with it. We will see what Ned Deily says > > when he gets around to reading this. > > You were misinformed. Tkinter has worked fine with Tk 8.6 for a long > time. The issues with Tk on the Mac, owing to Apple's force migration of > GUI libraries to Cocoa, have finally been more or less resolved, and Tk > 8.6.4 is now quite stable on OS X. I believe Laura is referring to the Pythons installed by python.org installers and it is true that their versions of tkinter and IDLE are not linked with 8.6 (but it is not correct that 8.6 is shipped with OS X). As I replied earlier, the issue is not that Tkinter doesn't work with Tk 8.6 on OS X: as you say, it does. The issues are that (1) Apple doesn't supply 8.6 with OS X; (2) the Pythons supplied by the python.org installers for OS X have traditionally depended on using Apple-supplied Tk's shipped with OS X (with an override to ActiveTcl if installed); (3) Apple has not updated the version of Tk 8.5 shipped with recent releases of OS X, thus still shipping an early version of Cocoa Tk with critical bugs that have been fixed upstream by you (Kevin) and others; (4) while liberally licensed, ActiveTcl is not free or open source software so it is problematic to require all tkinter users to have to install it when using python.org Pythons. The best solution at the moment would be for the python.org OS X installers to supply their own builds of Tcl/Tk (like the python.org Windows installers do). That hasn't happened yet (we tried one approach a while back but ran into problems with some key third-party Python packages expecting files to be in particular locations); I hope to try again in the near future. -- Ned Deily, nad at acm.org From vincent.vande.vyvre at telenet.be Sun Jul 12 01:50:57 2015 From: vincent.vande.vyvre at telenet.be (Vincent Vande Vyvre) Date: Sun, 12 Jul 2015 07:50:57 +0200 Subject: =?windows-1252?Q?Re=3A_Fwd=3A_Python_Error=3A_ImportErro?= =?windows-1252?Q?r=3A_No_module_named_=27=27folder=5Fname=92_a?= =?windows-1252?Q?t_Command_Prompt?= In-Reply-To: References: <55A1E620.7070507@udel.edu> Message-ID: <55A20041.7020204@telenet.be> Le 12/07/2015 06:02, Ernest Bonat, Ph.D. a ?crit : > Thanks for your help. I had follow the link: How to add a Python module > to syspath? > > > and I could not make it work. I did use sys.path.insert() and > sys.path.append() as: > > Examples: sys.path.append('/python_mvc_calculator/calculator/') or > sys.path.insert(0, "/python_mvc_calculator/calculator") > > I did try it to: > sys.path.append('/python_mvc_calculator/calculator/controller') or > sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too! > > The main.py file is in python_mvc_calculator/calculator folder and I > need to import a module calculatorcontroller.py in > "python_mvc_calculator/calculator/controller" > > I hope this explanation helps a bit! > > > > Thanks > If "/python_mvc_calculator/calculator/controller" is a folder and if you have a file __init__.py into this folder, you have to use: sys.path.insert(0, "/python_mvc_calculator/calculator/controller") from calculatorcontroller import foo # or import calculatorcontroller But the init file must be named __init__.py NOT init.py as sayed in askubuntu. Vincent From greg.ewing at canterbury.ac.nz Sun Jul 12 02:12:00 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 12 Jul 2015 18:12:00 +1200 Subject: 0 + not 0 In-Reply-To: References: <01ec6551-1f40-42b0-9406-036030591519@googlegroups.com> Message-ID: Ian Kelly wrote: > I must concur. The grammar as written does not actually produce 1 + > not 0. I think it's still worthwhile opening a bug, because the > behavior is surprising and possibly not intentional. It's almost certainly intentional. If you want not a + b > c to be interpreted as not (a + b > c) rather than (not a) + b > c then 'not' has to be higher up in the chain of grammar productions than the arithmetic operations. Maintaining that while allowing 'a + not b' would require contortions in the grammar that wouldn't be worth the very small benefit that would be obtained. -- Greg From framstag at rus.uni-stuttgart.de Sun Jul 12 03:55:52 2015 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Sun, 12 Jul 2015 07:55:52 +0000 (UTC) Subject: beginners choice: wx or tk? References: <194c69b3-d994-400a-9613-6078c4ad50f4@googlegroups.com> Message-ID: wxjmfauth at gmail.com wrote: > On Windows, there are no more usable, working GUI toolkits (wrappers). What is the problem with tkinter? A first "hello world" program worked. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ From auriocus at gmx.de Sun Jul 12 04:00:37 2015 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sun, 12 Jul 2015 10:00:37 +0200 Subject: beginners choice: wx or tk? In-Reply-To: References: <194c69b3-d994-400a-9613-6078c4ad50f4@googlegroups.com> Message-ID: Am 12.07.15 um 09:55 schrieb Ulli Horlacher: > wxjmfauth at gmail.com wrote: > >> On Windows, there are no more usable, working GUI toolkits (wrappers). > > What is the problem with tkinter? > A first "hello world" program worked. > Don't listen. jmf is a troll, who always complains about Unicode support, which is broken accoring to him in all ways. In the case of Tk, sadly he would have a point: Tk only supports the BMP, which means that you cannot input astral characters into an entry box (emoticons, some rare Chinese characters...) Still most scripts *do* work. QT handles this better. And jmf's complaints are otherwise invalid. Christian From rosuav at gmail.com Sun Jul 12 04:54:08 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Jul 2015 18:54:08 +1000 Subject: beginners choice: wx or tk? In-Reply-To: References: <194c69b3-d994-400a-9613-6078c4ad50f4@googlegroups.com> Message-ID: On Sun, Jul 12, 2015 at 6:00 PM, Christian Gollwitzer wrote: > Am 12.07.15 um 09:55 schrieb Ulli Horlacher: >> >> wxjmfauth at gmail.com wrote: >> >>> On Windows, there are no more usable, working GUI toolkits (wrappers). >> >> >> What is the problem with tkinter? >> A first "hello world" program worked. >> > Don't listen. > jmf is a troll, who always complains about Unicode support, which is broken > accoring to him in all ways. > > In the case of Tk, sadly he would have a point: Tk only supports the BMP, > which means that you cannot input astral characters into an entry box > (emoticons, some rare Chinese characters...) Still most scripts *do* work. > QT handles this better. And jmf's complaints are otherwise invalid. I don't know about the Python bindings, but I know for sure that GTK has excellent Unicode support. (My only concern is that one particular API uses UTF-8 byte positions rather than Unicode codepoint indices, which may or may not have been papered over in the Python bindings.) Qt is probably comparable. wxPython/wxWindows maybe, maybe not, given that it aims for Windows API similarity. But it's something worth checking, given that Tk doesn't do so well. And yet... a few simple tests will prove the point. Don't listen to jmf, just check if you care. ChrisA From musicalhacksaw at yahoo.co.uk Sun Jul 12 04:59:57 2015 From: musicalhacksaw at yahoo.co.uk (Simon Evans) Date: Sun, 12 Jul 2015 01:59:57 -0700 (PDT) Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: References: Message-ID: Dear Mark Lawrence, thank you for your advice. I take it that I use the input you suggest for the line : soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html",lxml") seeing as I have to give the file's full address I therefore have to modify your : soup = BeautifulSoup(ecological_pyramid,"lxml") to : soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid," "lxml") otherwise I get : >>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as ecological_pyramid: >>> soup = BeautifulSoup(ecological_pyramid,"lxml") Traceback (most recent call last): File "", line 1, in NameError: name 'ecological_pyramid' is not defined so anyway with the input therefore as: >>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as ecological_pyramid: >>> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid,","lxml") >>> producer_entries = soup.find("ul") >>> print(producer_entries.li.div.string) I still get the following output from the console: Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'li' >>> As is probably evident, what is the problem Python has with finding the required html code within the 'ecologicalpyramid' html file, or more specifically why does it respond that the html file has no such attribute as 'li' ? Incidentally I have installed all the xml, lxml, html, and html5 TreeBuilders/ Parsers. I am using lxml as that is the format specified in the text. I may as well quote the text on the page in question in 'Getting Started with Beautiful Soup': 'Since producers come as the first entry for the
    tag, we can use the find() method, which normally searches fo ronly the first occurrance of a particular tag in a BeautifulSoup object. We store this in producer_entries. The next line prints the name of the first producer. From the previous HTML diagram we can understand that the first producer is stored inside the first
    tag of the first
  • tag that immediately follows the first
      tag , as shown inthe following code:
      • plants
        100000
      So after running the preceding code, we will get plants, which is the first producer, as the output.' (page 30) From yonggangchen168 at gmail.com Sun Jul 12 05:40:36 2015 From: yonggangchen168 at gmail.com (Yonggang Chen) Date: Sun, 12 Jul 2015 02:40:36 -0700 (PDT) Subject: Python backreference replacing doesn't work as expected Message-ID: There are two named groups in my pattern: myFlag and id, I want to add one more myFlag immediately before group id. Here is my current code: ## code begin # i'm using Python 3.4.2 import re import os contents = b''' xdlg::xdlg(x_app* pApp, CWnd* pParent) : customized_dlg((UINT)0, pParent, pApp) , m_pReaderApp(pApp) , m_info(pApp) { } ''' pattern = rb'(?P[a-zA-Z0-9_]+)::(?P=myFlag).+:.+(?P\(UINT\)0 *,)' res = re.search(pattern, contents, re.DOTALL) if None != res: print(res.groups()) # the output is (b'xdlg', b'(UINT)0,') # 'replPattern' becomes b'(?P[a-zA-Z0-9_]+)::(?P=myFlag).+:.+((?P=myFlag)\\(UINT\\)0 *,)' replPattern = pattern.replace(b'?P', b'(?P=myFlag)', re.DOTALL) print(replPattern) contents = re.sub(pattern, replPattern, contents) print(contents) # code end The expected results should be: xdlg::xdlg(x_app* pApp, CWnd* pParent) : customized_dlg(xdlg(UINT)0, pParent, pApp) , m_pReaderApp(pApp) , m_info(pApp) { } but now the result this the same with the original: xdlg::xdlg(x_app* pApp, CWnd* pParent) : customized_dlg((UINT)0, pParent, pApp) , m_pReaderApp(pApp) , m_info(pApp) { } From __peter__ at web.de Sun Jul 12 05:51:58 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 12 Jul 2015 11:51:58 +0200 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? References: Message-ID: Simon Evans wrote: > Dear Mark Lawrence, thank you for your advice. > I take it that I use the input you suggest for the line : > > soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html",lxml") > > seeing as I have to give the file's full address I therefore have to > modify your : > > soup = BeautifulSoup(ecological_pyramid,"lxml") > > to : > > soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid," "lxml") > > otherwise I get : > > >>>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as >>>> ecological_pyramid: soup = BeautifulSoup(ecological_pyramid,"lxml") > Traceback (most recent call last): > File "", line 1, in > NameError: name 'ecological_pyramid' is not defined > > > so anyway with the input therefore as: > >>>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as >>>> ecological_pyramid: soup = BeautifulSoup("C:\Beautiful >>>> Soup\ecological_pyramid,","lxml") producer_entries = soup.find("ul") >>>> print(producer_entries.li.div.string) No. If you pass the filename beautiful soup will mistake it as the HTML. You can verify that in the interactive interpreter: >>> soup = BeautifulSoup("C:\Beautiful Soup\ecologicalpyramid.html","lxml") >>> soup

      C:\Beautiful Soup\ecologicalpyramid.html

      You have to pass an open file to BeautifulSoup, not a filename: >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as f: ... soup = BeautifulSoup(f, "lxml") ... However, if you look at the data returned by soup.find("ul") you'll see >>> producer_entries = soup.find("ul") >>> producer_entries
      • plants
        100000
      • algae
        100000
      The first
    • ...
    • node does not contain a div >>> producer_entries.li
    • and thus >>> producer_entries.li.div is None True and the following error is expected with the given data. Returning None is beautiful soup's way of indicating that the
    • node has no
      child at all. If you want to process the first li that does have a
      child a straight-forward way is to iterate over the children: >>> for li in producer_entries.find_all("li"): ... if li.div is not None: ... print(li.div.string) ... break # remove if you want all, not just the first ... plants Taking a second look at the data you probably want the li nodes with class="producerlist": >>> for li in soup.find_all("li", attrs={"class": "producerlist"}): ... print(li.div.string) ... plants algae From lac at openend.se Sun Jul 12 06:00:32 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 12 Jul 2015 12:00:32 +0200 Subject: beginners choice: wx or tk? In-Reply-To: Message from Paul Rubin of "Sat, 11 Jul 2015 15:50:05 -0700." <87wpy62tsy.fsf@jester.gateway.sonic.net> References: <87wpy62tsy.fsf@jester.gateway.sonic.net> Message-ID: <201507121000.t6CA0Wlj017944@fido.openend.se> In a message of Sat, 11 Jul 2015 15:50:05 -0700, Paul Rubin writes: >Ulli Horlacher writes: >> This is not an option for me. My users only accept standalone executables. >> They cannot install any runtime environment or extra libraries. > >Long ago I was involved with a thing like this and used Inno Setup, >which was great. It's a very slick installer whose user experience is >similar to Install Shield if you're familiar with that. I have no idea >what current best practice is, but I see that Inno Setup is still >around. Docker is what I hear people are using now. https://www.docker.com/ But I have never tried this myself. Laura From mal at europython.eu Sun Jul 12 07:18:17 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Sun, 12 Jul 2015 13:18:17 +0200 Subject: EuroPython 2015: Recruiting Offers Message-ID: <55A24CF9.9020206@europython.eu> Many of our sponsors are looking for new employees, so EuroPython 2015 is not only an exciting conference, but may very well also be your chance to find the perfect job you?ve always been looking for. Sponsor job board ----------------- We will post sponsor recruiting offers on the job board of our website: *** https://ep2015.europython.eu/en/sponsor/job-board/ *** Sponsor recruiting messages --------------------------- If you want to receive the sponsor messages directly to your inbox, please log in to the website and enable the recruiting message option in your privacy settings: https://ep2015.europython.eu/accounts/profile/#account-spam-control Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From musicalhacksaw at yahoo.co.uk Sun Jul 12 07:48:38 2015 From: musicalhacksaw at yahoo.co.uk (Simon Evans) Date: Sun, 12 Jul 2015 04:48:38 -0700 (PDT) Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: References: Message-ID: Dear Peter Otten, thank you for your reply that I have not gone very far into the detail of which, as it seems Python console cannot recognise the name 'f' as given it, re output below : Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> from bs4 import BeautifulSoup >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: >>> soup = BeautifulSoup(f, "lxml") Traceback (most recent call last): File "", line 1, in NameError: name 'f' is not defined >>> From __peter__ at web.de Sun Jul 12 08:26:28 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 12 Jul 2015 14:26:28 +0200 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? References: Message-ID: Simon Evans wrote: > Dear Peter Otten, thank you for your reply that I have not gone very far > into the detail of which, as it seems Python console cannot recognise the > name 'f' as given it, re output below : > > > Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] > on win 32 > Type "help", "copyright", "credits" or "license" for more information. > >>>> from bs4 import BeautifulSoup >>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: >>>> soup = BeautifulSoup(f, "lxml") > Traceback (most recent call last): > File "", line 1, in > NameError: name 'f' is not defined >>>> Is that copy-and-paste? When I try to reproduce that I get $ python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from bs4 import BeautifulSoup >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f, "lxml") File "", line 2 soup = BeautifulSoup(f, "lxml") ^ IndentationError: expected an indented block and when I indent the soup = ... line properly I don't get an error: $ python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from bs4 import BeautifulSoup >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f, "lxml") ... >>> From musicalhacksaw at yahoo.co.uk Sun Jul 12 08:36:31 2015 From: musicalhacksaw at yahoo.co.uk (Simon Evans) Date: Sun, 12 Jul 2015 05:36:31 -0700 (PDT) Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: References: Message-ID: <98fa51f3-ea5b-40eb-b9d9-aa54594d1299@googlegroups.com> Dear Peter Otten, Incidentally, you have discovered a fault in that there is an erroneous difference in my code of 'ecologicalpyramid.html' and that given in the text, in the first few lines re: ----------------------------------------------------------------------------
      • plants
        100000
      • algae
        100000
      ----------------------------------------------------------------------------
      • plants
        100000
      • algae
        100000
      ---------------------------------------------------------------------------- I have removed the line
    • to the right html code of the lower version. Now there is a string ("plants") between the <"li class producerlist"> and
    • Sorry about that. However as you said, the input code as quoted in the text, still won't return 'plants' re: ---------------------------------------------------------------------------- Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> from bs4 import BeautifulSoup >>> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid,","lxml") >>> producer_entries = soup.find("ul") >>> print(producer_entries.li.div.string) Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'li' >>> ---------------------------------------------------------------------------- From musicalhacksaw at yahoo.co.uk Sun Jul 12 08:48:17 2015 From: musicalhacksaw at yahoo.co.uk (Simon Evans) Date: Sun, 12 Jul 2015 05:48:17 -0700 (PDT) Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: References: Message-ID: <8ae715b3-91b1-4db2-9e69-cfc8c078939e@googlegroups.com> Dear Peter Otten, Yes, I have been copying and pasting, as it saves typing. I do get 'indented block' error responses as a small price to pay for the time and energy thus saved. Also Console seems to reject for 'indented block' reasons better known to itself, copy and pasted lines that it accepts and are exactly the same on the following line of input. Maybe it is an inbuilt feature of Python's to discourage copy and pasting. From __peter__ at web.de Sun Jul 12 09:12:15 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 12 Jul 2015 15:12:15 +0200 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? References: <8ae715b3-91b1-4db2-9e69-cfc8c078939e@googlegroups.com> Message-ID: Simon Evans wrote: > Dear Peter Otten, > Yes, I have been copying and pasting, as it saves typing. I do get > 'indented block' error responses as a small price to pay for the time and > energy thus saved. Also Console seems to reject for 'indented block' > reasons better known to itself, copy and pasted lines that it accepts and > are exactly the same on the following line of input. Maybe it is an > inbuilt feature of Python's to discourage copy and pasting. You should not ignore the error. It means that the respective code was not executed. From musicalhacksaw at yahoo.co.uk Sun Jul 12 13:33:17 2015 From: musicalhacksaw at yahoo.co.uk (Simon Evans) Date: Sun, 12 Jul 2015 10:33:17 -0700 (PDT) Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: References: Message-ID: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> Dear Peter Otten, I typed in (and did not copy and paste) the code as you suggested just now (6.28 pm, Sunday 12th July 2015), this is the result I got: ---------------------------------------------------------------------------- Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> from bs4 import BeautifulSoup >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f,"lxml") File "", line 2 soup = BeautifulSoup(f,"lxml") ^ IndentationError: expected an indented block >>> soup = BeautifulSoup(f,"lxml") Traceback (most recent call last): File "", line 1, in NameError: name 'f' is not defined >>> ---------------------------------------------------------------------------- The first time I typed in the second line, I got the "Indentation error" the second time I typed in exactly the same code, I got the: "NameError:name 'f' is not defined" From laurent.pointal at free.fr Sun Jul 12 13:54:01 2015 From: laurent.pointal at free.fr (Laurent Pointal) Date: Sun, 12 Jul 2015 19:54:01 +0200 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? References: Message-ID: <55a2a9b9$0$2970$426a74cc@news.free.fr> Simon Evans wrote: > --------------------------------------------------------------------- >>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as You seem to run Python under Windows. You have to take care of escape mechanism beyond \ char in string literals (see Python docs). By chance, \B and \e are not recognized as escape sequences, so they are left as is. But \a \b \f \n \r \t \v \x will be processed differently Double \ in your string: "C:\\Beautiful Soup\\ecologicalpyramid.html" Or use a raw string by prepending a r to disable escape sequences: r"C:\Beautiful Soup\ecologicalpyramid.html" A+ Laurent. From rosuav at gmail.com Sun Jul 12 13:58:36 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Jul 2015 03:58:36 +1000 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: <55a2a9b9$0$2970$426a74cc@news.free.fr> References: <55a2a9b9$0$2970$426a74cc@news.free.fr> Message-ID: On Mon, Jul 13, 2015 at 3:54 AM, Laurent Pointal wrote: > Double \ in your string: > "C:\\Beautiful Soup\\ecologicalpyramid.html" > > Or use a raw string by prepending a r to disable escape sequences: > r"C:\Beautiful Soup\ecologicalpyramid.html" Or use forward slashes: "C:/Beautiful Soup/ecologicalpyramid.html" ChrisA From python at mrabarnett.plus.com Sun Jul 12 14:05:22 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 12 Jul 2015 19:05:22 +0100 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> Message-ID: <55A2AC62.7090804@mrabarnett.plus.com> On 2015-07-12 18:33, Simon Evans wrote: > > Dear Peter Otten, > I typed in (and did not copy and paste) the code as you suggested just now (6.28 pm, Sunday 12th July 2015), this is the result I got: > ---------------------------------------------------------------------------- > Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win > 32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from bs4 import BeautifulSoup >>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: > ... soup = BeautifulSoup(f,"lxml") > File "", line 2 > soup = BeautifulSoup(f,"lxml") > ^ > IndentationError: expected an indented block >>>> soup = BeautifulSoup(f,"lxml") > Traceback (most recent call last): > File "", line 1, in > NameError: name 'f' is not defined >>>> > ---------------------------------------------------------------------------- > The first time I typed in the second line, I got the > "Indentation error" > the second time I typed in exactly the same code, I got the: > "NameError:name 'f' is not defined" > Python parses the lines, and, if there are no syntax errors, it then executes them. That block of code (the 2 lines) contained a syntax (indentation) error in the second line, so _none_ of the block was executed, and, therefore, 'f' isn't defined. From breamoreboy at yahoo.co.uk Sun Jul 12 14:23:05 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 12 Jul 2015 19:23:05 +0100 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> Message-ID: On 12/07/2015 18:33, Simon Evans wrote: > > Dear Peter Otten, > I typed in (and did not copy and paste) the code as you suggested just now (6.28 pm, Sunday 12th July 2015), this is the result I got: > ---------------------------------------------------------------------------- > Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win > 32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from bs4 import BeautifulSoup >>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: > ... soup = BeautifulSoup(f,"lxml") > File "", line 2 > soup = BeautifulSoup(f,"lxml") > ^ > IndentationError: expected an indented block >>>> soup = BeautifulSoup(f,"lxml") > Traceback (most recent call last): > File "", line 1, in > NameError: name 'f' is not defined >>>> > ---------------------------------------------------------------------------- > The first time I typed in the second line, I got the > "Indentation error" > the second time I typed in exactly the same code, I got the: > "NameError:name 'f' is not defined" > You can tell that to the marines :) >>> with open("ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f) ... producer_entries = soup.find("ul") ... producer_entries ...
      • plants
        100000
      • algae
        100000
      >>> Can I suggest that you slow down. It strikes me that you're trying to run a marathon a day for a year before you can even walk. For example is the file path in your call to open() correct? Frankly I very much doubt it, although it is possible. Perhaps you'd be more comfortable on the tutor mailing list? If so see https://mail.python.org/mailman/listinfo/tutor or gmane.comp.python.tutor. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From albert.visser at gmail.com Sun Jul 12 14:34:18 2015 From: albert.visser at gmail.com (Albert Visser) Date: Sun, 12 Jul 2015 20:34:18 +0200 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> Message-ID: On Sun, 12 Jul 2015 19:33:17 +0200, Simon Evans wrote: > > Dear Peter Otten, > I typed in (and did not copy and paste) the code as you suggested just > now (6.28 pm, Sunday 12th July 2015), this is the result I got: > ---------------------------------------------------------------------------- > Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit > (Intel)] on win > 32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from bs4 import BeautifulSoup >>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: > ... soup = BeautifulSoup(f,"lxml") > File "", line 2 > soup = BeautifulSoup(f,"lxml") > ^ > IndentationError: expected an indented block >>>> soup = BeautifulSoup(f,"lxml") > Traceback (most recent call last): > File "", line 1, in > NameError: name 'f' is not defined >>>> > ---------------------------------------------------------------------------- > The first time I typed in the second line, I got the > "Indentation error" > the second time I typed in exactly the same code, I got the: > "NameError:name 'f' is not defined" "Expected an indented block" means that the indicated line should have started with at least one whitespace character more than the preceding line. >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f,"lxml") should have been something like >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f,"lxml") -- Vriendelijke groeten / Kind regards, Albert Visser Using Opera's mail client: http://www.opera.com/mail/ From python at mrabarnett.plus.com Sun Jul 12 15:25:57 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 12 Jul 2015 20:25:57 +0100 Subject: Python backreference replacing doesn't work as expected In-Reply-To: References: Message-ID: <55A2BF45.6070708@mrabarnett.plus.com> On 2015-07-12 10:40, Yonggang Chen wrote: > There are two named groups in my pattern: myFlag and id, I want to add one more myFlag immediately before group id. > > Here is my current code: > ## code begin > # i'm using Python 3.4.2 > import re > import os > contents = b''' > xdlg::xdlg(x_app* pApp, CWnd* pParent) > : customized_dlg((UINT)0, pParent, pApp) > , m_pReaderApp(pApp) > , m_info(pApp) > { > > } > ''' > > pattern = rb'(?P[a-zA-Z0-9_]+)::(?P=myFlag).+:.+(?P\(UINT\)0 *,)' > res = re.search(pattern, contents, re.DOTALL) > if None != res: > print(res.groups()) # the output is (b'xdlg', b'(UINT)0,') > > # 'replPattern' becomes b'(?P[a-zA-Z0-9_]+)::(?P=myFlag).+:.+((?P=myFlag)\\(UINT\\)0 *,)' In a replacement template, the (?P...) parts are just literals. > replPattern = pattern.replace(b'?P', b'(?P=myFlag)', re.DOTALL) This .replace method is a string method. It has nothing to do with regex. > print(replPattern) > contents = re.sub(pattern, replPattern, contents) You're not passing in the DOTALL flag; this function doesn't have an argument for the flags, anyway. You could compile the regex and then use its .sub method, or use inline flags instead. > print(contents) > # code end > > The expected results should be: > > xdlg::xdlg(x_app* pApp, CWnd* pParent) > : customized_dlg(xdlg(UINT)0, pParent, pApp) > , m_pReaderApp(pApp) > , m_info(pApp) > { > > } > > but now the result this the same with the original: > > xdlg::xdlg(x_app* pApp, CWnd* pParent) > : customized_dlg((UINT)0, pParent, pApp) > , m_pReaderApp(pApp) > , m_info(pApp) > { > > } > From lac at openend.se Sun Jul 12 15:47:46 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 12 Jul 2015 21:47:46 +0200 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: Message from Simon Evans of "Sun, 12 Jul 2015 10:33:17 -0700." <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> Message-ID: <201507121947.t6CJlk64031222@fido.openend.se> Simon Evans -- what editor are you using to write your Python code with? Laura Creighton From orgnut at yahoo.com Sun Jul 12 16:06:16 2015 From: orgnut at yahoo.com (Larry Hudson) Date: Sun, 12 Jul 2015 13:06:16 -0700 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: <8ae715b3-91b1-4db2-9e69-cfc8c078939e@googlegroups.com> References: <8ae715b3-91b1-4db2-9e69-cfc8c078939e@googlegroups.com> Message-ID: On 07/12/2015 05:48 AM, Simon Evans wrote: > Dear Peter Otten, > Yes, I have been copying and pasting, as it saves typing. I do get 'indented block' error responses as a small price > to pay for the time and energy thus saved. > You CANNOT ignore indenting. Indenting is NOT optional, it is REQUIRED by Python syntax. Changing indenting TOTALLY changes the meaning. > Also Console seems to reject for 'indented block' reasons better known to itself, copy and > pasted lines that it accepts and are exactly the same on the following line of input. > As above, that is Python syntax. > Maybe it is an inbuilt feature of Python's to discourage copy and pasting. > Absolutely not. As noted above, this is the way Python is defined to work. -=- Larry -=- From breamoreboy at yahoo.co.uk Sun Jul 12 16:09:22 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 12 Jul 2015 21:09:22 +0100 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: <201507121947.t6CJlk64031222@fido.openend.se> References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> <201507121947.t6CJlk64031222@fido.openend.se> Message-ID: On 12/07/2015 20:47, Laura Creighton wrote: > Simon Evans -- what editor are you using to write your Python code with? > > Laura Creighton > Editor? His earlier posts clearly show he's using the 2.7.6 32 bit interactive interpreter on Windows. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From lac at openend.se Sun Jul 12 16:29:21 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 12 Jul 2015 22:29:21 +0200 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: Message from Mark Lawrence of "Sun, 12 Jul 2015 21:09:22 +0100." References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> <201507121947.t6CJlk64031222@fido.openend.se> Message-ID: <201507122029.t6CKTLgu032108@fido.openend.se> In a message of Sun, 12 Jul 2015 21:09:22 +0100, Mark Lawrence writes: >On 12/07/2015 20:47, Laura Creighton wrote: >> Simon Evans -- what editor are you using to write your Python code with? >> >> Laura Creighton >> > >Editor? His earlier posts clearly show he's using the 2.7.6 32 bit >interactive interpreter on Windows. He's sending us that stuff, but he may be writing it someplace else first. And that someplace else may be spitting out combined spaces and tabs. If he is pasting that into the interpreter, that will cause tons of problems like he is seeing. Laura From breamoreboy at yahoo.co.uk Sun Jul 12 16:48:18 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 12 Jul 2015 21:48:18 +0100 Subject: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? In-Reply-To: <201507122029.t6CKTLgu032108@fido.openend.se> References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> <201507121947.t6CJlk64031222@fido.openend.se> <201507122029.t6CKTLgu032108@fido.openend.se> Message-ID: On 12/07/2015 21:29, Laura Creighton wrote: > In a message of Sun, 12 Jul 2015 21:09:22 +0100, Mark Lawrence writes: >> On 12/07/2015 20:47, Laura Creighton wrote: >>> Simon Evans -- what editor are you using to write your Python code with? >>> >>> Laura Creighton >>> >> >> Editor? His earlier posts clearly show he's using the 2.7.6 32 bit >> interactive interpreter on Windows. > > He's sending us that stuff, but he may be writing it someplace else > first. And that someplace else may be spitting out combined > spaces and tabs. If he is pasting that into the interpreter, > that will cause tons of problems like he is seeing. > > Laura > At 18:33 BST Simon stated "I typed in (and did not copy and paste) the code...". I started my reply with "You can tell that to the marines :)". -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From donne.martin at gmail.com Mon Jul 13 07:20:38 2015 From: donne.martin at gmail.com (donne.martin at gmail.com) Date: Mon, 13 Jul 2015 04:20:38 -0700 (PDT) Subject: Interactive, test-driven coding challenges (algorithms and data structures) Message-ID: Repo: https://github.com/donnemartin/interactive-coding-challenges Shortlink: https://bit.ly/git-code Hi Everyone, I created a number of interactive, test-driven coding challenges. I will continue to add to the repo on a regular basis. I'm hoping you find it useful as a fun, hands-on way to learn or to sharpen your skills on algorithms and data structures, while helping yourself prep for coding interviews and coding challenges. Let me know if you have any questions or comments. Contributions are welcome! -Donne From jpiitula at ling.helsinki.fi Mon Jul 13 07:22:19 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Mon, 13 Jul 2015 14:22:19 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: Message-ID: Ian Burnette writes: > I've recently been playing around with Clojure, and I really like the > way they've overcome the JVM not supporting TRE. The way Clojure > solves this problem is to have a built in "recur" function that > signals to the Clojure compiler to convert the code to a loop in the > JVM. In python we could do something similar by having a recur(*args, > **kwargs) function that removes its parent from the stack and then > runs the parent function again with the given arguments. It would look > something like this: where I introduce some indentation: > def factorial(n, acc=1): > if n == 0: > return acc > else: > return recur(n-1, acc=(acc*n)) > #signals to the interpreter to trigger TRE That's oddly restricted to self-calls. To get the real thing, "recur" should replace "return" - I'm tempted to spell it "recurn" - so the definition would look like this: def factorial(n, acc=1): if n == 0: return acc else: recur factorial(n-1, acc=(acc*n)) Probably it would still be syntactically restricted to calls - just guessing what it would and would not be like to have this in Python: def factorial(n, acc=1): recur ( acc if n == 0 else factorial(n-1, acc=(acc*n)) ) #error? Something similar could be done inside lambda forms, again probably restricted to calls in value position: factorial = ( lambda n, acc=1 : #horror? ( acc if n == 0 else rec factorial(n-1, acc=(acc*n)) )) But I don't think it's a way that's missing, I think it's a will. I know you know this, and I agree with your point (in a paragraph that I'm not quoting) that an explicit syntax for "eliminable" tail calls would be, well, explicit :) so a user of such syntax should at least know why they are not getting in their stack traces material that they have specifically requested to not have in their stacks. From rosuav at gmail.com Mon Jul 13 07:28:15 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Jul 2015 21:28:15 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: Message-ID: On Sun, Jul 12, 2015 at 8:20 AM, Ian Burnette wrote: > > I've recently been playing around with Clojure, and I really like the way they've overcome the JVM not supporting TRE. The way Clojure solves this problem is to have a built in "recur" function that signals to the Clojure compiler to convert the code to a loop in the JVM. In python we could do something similar by having a recur(*args, **kwargs) function that removes its parent from the stack and then runs the parent function again with the given arguments. It would look something like this: > > def factorial(n, acc=1): > if n == 0: > return acc > else: > return recur(n-1, acc=(acc*n)) #signals to the interpreter to trigger TRE > # Doesn't overflow the stack! > > factorial(30000) > > > I've also created a plugin that mocks this behavior using the try/except looping method that others have utilized to implement TCO into python. Of course, my plugin still requires a decorator and the overhead of transmitting information through an exception. Implementing recur with interpreter support should lead to much better performance. > When a function is purely tail-recursive like this, it's trivial to convert it at the source code level: def factorial(n): acc = 1 while n > 0: acc *= n n -= 1 return acc The cases that _can't_ be converted this trivially are the ones that usually can't be converted automatically either - the best case I can think of is tree traversal, where one of the calls could be tail-call optimized: def traverse(node, func): if node.left: traverse(node.left, func) func(node) if node.right: return recur(node.right, func) (By the way, what happens if you call recur() without returning its result?) It still needs stack space for all the left calls, so it's not really benefiting that much from TCO. Where does the advantage show up? Why is it worth writing your code recursively, only to have it be implemented iteratively? Warping your code around a recursive solution to make it into a perfect tail call usually means making it look a lot less impressive; for instance, the 'acc' parameter in your above code has no meaning outside of transforming the recursion into tail recursion. https://xkcd.com/1270/ ChrisA From rosuav at gmail.com Mon Jul 13 07:47:07 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Jul 2015 21:47:07 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: Message-ID: On Mon, Jul 13, 2015 at 9:22 PM, Jussi Piitulainen wrote: > That's oddly restricted to self-calls. To get the real thing, "recur" > should replace "return" - I'm tempted to spell it "recurn" - so the > definition would look like this: > > def factorial(n, acc=1): > if n == 0: > return acc > else: > recur factorial(n-1, acc=(acc*n)) > > Probably it would still be syntactically restricted to calls Huh. Now it looks like the 'exec' operation (the C function and shell operation, not the Python keyword/function) - it's saying "replace the current stack frame with _this_", which looks reasonable. It doesn't have to be recursion. The thing is, you would have to use this ONLY when you don't care about the current stack frame; so you could do a logging decorator thus: def log_calls(func): @functools.wraps(func) def wrapped(*a, **kw): logging.debug("Calling %s(%r, %r)", func.__name__, a, kw) recur func, a, kw return wrapped When an exception occurs inside the wrapped function, the wrapper won't be visible - but that's not a problem, because it doesn't affect anything. Like every other tool, it would be something that could easily be abused, but this actually does justify the removal. It would almost certainly need to be language syntax. I've done it up as a keyword that takes "function, args, kwargs" rather than a prefix on a function call, which emphasizes that the part after it is NOT an expression. In a sense, it makes a counterpart to lambda - where lambda takes an expression and turns it into a function, recur takes a function and treats it as if its body were part of the current function. Kinda. Does that make sense to anyone else? ChrisA From antoon.pardon at rece.vub.ac.be Mon Jul 13 08:00:19 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Mon, 13 Jul 2015 14:00:19 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: Message-ID: <55A3A853.4040006@rece.vub.ac.be> On 07/13/2015 01:28 PM, Chris Angelico wrote: > On Sun, Jul 12, 2015 at 8:20 AM, Ian Burnette wrote: >> [ About tail recursion ] >> > When a function is purely tail-recursive like this, it's trivial to > convert it at the source code level: > > def factorial(n): > acc = 1 > while n > 0: > acc *= n > n -= 1 > return acc > > The cases that _can't_ be converted this trivially are the ones that > usually can't be converted automatically either - the best case I can > think of is tree traversal, where one of the calls could be tail-call > optimized: This is not true. Tail recursion elimination can always converted automatically. Otherwise other languages couldn't have implemted it. > Why is it worth writing your code recursively, only to have it be > implemented iteratively? Because sometimes, it is easier to think about the problem recursively. > Warping your code around a recursive solution > to make it into a perfect tail call usually means making it look a lot > less impressive; for instance, And sometimes your problem is very easily solved by a number of functions that tail call each other but in python you will need to warp your code around an iterative solution, in order to avoid the stack limit. It seems warping your code is only seen as a problem when going in the functional direction. Going into the iterative direction may take all the warping that is needed, without comment. From rosuav at gmail.com Mon Jul 13 08:34:42 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Jul 2015 22:34:42 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A3A853.4040006@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> Message-ID: On Mon, Jul 13, 2015 at 10:00 PM, Antoon Pardon wrote: > On 07/13/2015 01:28 PM, Chris Angelico wrote: >> On Sun, Jul 12, 2015 at 8:20 AM, Ian Burnette wrote: >>> [ About tail recursion ] >>> >> When a function is purely tail-recursive like this, it's trivial to >> convert it at the source code level: >> >> def factorial(n): >> acc = 1 >> while n > 0: >> acc *= n >> n -= 1 >> return acc >> >> The cases that _can't_ be converted this trivially are the ones that >> usually can't be converted automatically either - the best case I can >> think of is tree traversal, where one of the calls could be tail-call >> optimized: > > This is not true. Tail recursion elimination can always converted > automatically. Otherwise other languages couldn't have implemted it. Yes, when it's in the pure form of an actual tail call. Most recursion isn't, so you have to warp your code until it is (like adding the 'acc' parameter, which is NOT logically a parameter to the factorial function). >> Why is it worth writing your code recursively, only to have it be >> implemented iteratively? > > Because sometimes, it is easier to think about the problem recursively. Can you give me an example that (a) makes a lot more sense recursively than iteratively, and (b) involves just one tail call? >> Warping your code around a recursive solution >> to make it into a perfect tail call usually means making it look a lot >> less impressive; for instance, > > And sometimes your problem is very easily solved by a number of functions > that tail call each other but in python you will need to warp your code > around an iterative solution, in order to avoid the stack limit. Example, please? In all my Python programming, I've never hit the stack limit outside of deliberate playing around (or accidental infinite recursion, which means it's doing its job). > It seems warping your code is only seen as a problem when going in the > functional direction. Going into the iterative direction may take all > the warping that is needed, without comment. That's because I've never seen code that warps more for iteration than it does for programming in general. Again, example please? ChrisA From ian.g.kelly at gmail.com Mon Jul 13 09:46:03 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 13 Jul 2015 07:46:03 -0600 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> Message-ID: On Mon, Jul 13, 2015 at 6:34 AM, Chris Angelico wrote: > On Mon, Jul 13, 2015 at 10:00 PM, Antoon Pardon > wrote: >> On 07/13/2015 01:28 PM, Chris Angelico wrote: >>> Why is it worth writing your code recursively, only to have it be >>> implemented iteratively? >> >> Because sometimes, it is easier to think about the problem recursively. > > Can you give me an example that (a) makes a lot more sense recursively > than iteratively, and (b) involves just one tail call? Why does (b) matter? If the function has more than one tail call, it doesn't matter which one you hit -- either way it's a tail call and the stack frame is no longer needed. From antoon.pardon at rece.vub.ac.be Mon Jul 13 09:55:50 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Mon, 13 Jul 2015 15:55:50 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> Message-ID: <55A3C366.6060602@rece.vub.ac.be> On 07/13/2015 02:34 PM, Chris Angelico wrote: > >>> Warping your code around a recursive solution >>> to make it into a perfect tail call usually means making it look a lot >>> less impressive; for instance, >> And sometimes your problem is very easily solved by a number of functions >> that tail call each other but in python you will need to warp your code >> around an iterative solution, in order to avoid the stack limit. > Example, please? In all my Python programming, I've never hit the > stack limit outside of deliberate playing around (or accidental > infinite recursion, which means it's doing its job). I have had to process text coming from a network connection. The data was mosly unstructered text with some lines that could be used as markers to proceed through some kind of state machine that indicated how the following lines needed to be processed. That was easiest written by having a function for each "state" that would process the next lines until a marker line was encountered and then call the function corresponding with the next state. However since a connection could stay active for days, sooner or later a stack limit would occur if done the natural recursive way. >> It seems warping your code is only seen as a problem when going in the >> functional direction. Going into the iterative direction may take all >> the warping that is needed, without comment. > That's because I've never seen code that warps more for iteration than > it does for programming in general. Again, example please? And since when is your experience the measure stick for what other people encounter as problems? From rosuav at gmail.com Mon Jul 13 09:56:51 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Jul 2015 23:56:51 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> Message-ID: On Mon, Jul 13, 2015 at 11:46 PM, Ian Kelly wrote: > On Mon, Jul 13, 2015 at 6:34 AM, Chris Angelico wrote: >> On Mon, Jul 13, 2015 at 10:00 PM, Antoon Pardon >> wrote: >>> On 07/13/2015 01:28 PM, Chris Angelico wrote: >>>> Why is it worth writing your code recursively, only to have it be >>>> implemented iteratively? >>> >>> Because sometimes, it is easier to think about the problem recursively. >> >> Can you give me an example that (a) makes a lot more sense recursively >> than iteratively, and (b) involves just one tail call? > > Why does (b) matter? If the function has more than one tail call, it > doesn't matter which one you hit -- either way it's a tail call and > the stack frame is no longer needed. Oops. I meant "involves just one point of recursion". When you traverse a tree, only one can be a tail call, because after the other, you still have more processing to do. Most problems that I've found to work recursively and not iteratively have involved multiple branches - consider a simplistic solution to the Eight Queens problem that places a queen, then calls itself to place another queen: def eightqueens(positions=()): for i in range(8): if i not in positions: # TODO: check for the diagonals result = eightqueens(positions + (i,)) if result: return result return None While it can do the classic "call self, return result", it has to conditionally _not_ do that and keep on going. While this algorithm can be implemented iteratively, it's a reasonable show-case for recursion; but not for tail recursion, because one call to eightqueens() might result in more than one chained call, so I don't think there's any way for TCO to kick in here. What I'm asking for is an example of something that can have the tail calls optimized away, and yet still looks cleaner - preferably, *significantly* cleaner - in its recursive form than in its corresponding iterative form. Considering that an iterative function can maintain state that isn't in the parameters, I'm dubious that such a thing exists outside of the deranged minds of functional programmers. (Very much deranged. If you consider that a recursive factorial just uses addition and subtraction, while an iterative one can start with "for i in range(n):", you will agree that my terminology is strictly correct. So there.) ChrisA From rosuav at gmail.com Mon Jul 13 10:05:41 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 00:05:41 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A3C366.6060602@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> Message-ID: On Mon, Jul 13, 2015 at 11:55 PM, Antoon Pardon wrote: > On 07/13/2015 02:34 PM, Chris Angelico wrote: >> >>>> Warping your code around a recursive solution >>>> to make it into a perfect tail call usually means making it look a lot >>>> less impressive; for instance, >>> And sometimes your problem is very easily solved by a number of functions >>> that tail call each other but in python you will need to warp your code >>> around an iterative solution, in order to avoid the stack limit. >> Example, please? In all my Python programming, I've never hit the >> stack limit outside of deliberate playing around (or accidental >> infinite recursion, which means it's doing its job). > > I have had to process text coming from a network connection. The data > was mosly unstructered text with some lines that could be used as markers > to proceed through some kind of state machine that indicated how the > following lines needed to be processed. That was easiest written by having > a function for each "state" that would process the next lines until > a marker line was encountered and then call the function corresponding > with the next state. However since a connection could stay active for > days, sooner or later a stack limit would occur if done the natural > recursive way. I'm not sure why the transition to another state has to be recursive. With most network protocols, you'll end up returning to some kind of "base state" - maybe there's a header line that says that you're entering some new mode, which strongly suggests a subroutine call, but then at the end of that mode, you would return to the normal position of looking for another header. Alternatively, if the only way you know you're at the end of one mode is by discovering the beginning of the next, it's common to be able to have a single primary loop that dispatches lines appropriately - when it gets the next header, it sends the entire previous block to its appropriate function, and then carries on looking for lines of text. Maybe this is something where previous experience makes you more comfortable with a particular style, which will mean that functional idioms will never feel more comfortable to me than iterative ones do, and vice versa for you. If that's the case, then I'll stick with Python and Pike, and you can happily use Lisp and Haskell, and neither of us need be a problem to the other. But honestly, I'm not seeing anything that requires infinite recursion in your description. And I've worked with a lot of networking protocols in my time. >>> It seems warping your code is only seen as a problem when going in the >>> functional direction. Going into the iterative direction may take all >>> the warping that is needed, without comment. >> That's because I've never seen code that warps more for iteration than >> it does for programming in general. Again, example please? > > And since when is your experience the measure stick for what other people > encounter as problems? That's why I said "example please?". My experience has not a single time come across this. If you want to make an assertion that iterative code requires equivalent warping to tail-recursive code, I want to see an example of it. Is that difficult? ChrisA From antoon.pardon at rece.vub.ac.be Mon Jul 13 10:42:42 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Mon, 13 Jul 2015 16:42:42 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> Message-ID: <55A3CE62.6060304@rece.vub.ac.be> On 07/13/2015 04:05 PM, Chris Angelico wrote: > On Mon, Jul 13, 2015 at 11:55 PM, Antoon Pardon > wrote: >> On 07/13/2015 02:34 PM, Chris Angelico wrote: >>>>> Warping your code around a recursive solution >>>>> to make it into a perfect tail call usually means making it look a lot >>>>> less impressive; for instance, >>>> And sometimes your problem is very easily solved by a number of functions >>>> that tail call each other but in python you will need to warp your code >>>> around an iterative solution, in order to avoid the stack limit. >>> Example, please? In all my Python programming, I've never hit the >>> stack limit outside of deliberate playing around (or accidental >>> infinite recursion, which means it's doing its job). >> I have had to process text coming from a network connection. The data >> was mosly unstructered text with some lines that could be used as markers >> to proceed through some kind of state machine that indicated how the >> following lines needed to be processed. That was easiest written by having >> a function for each "state" that would process the next lines until >> a marker line was encountered and then call the function corresponding >> with the next state. However since a connection could stay active for >> days, sooner or later a stack limit would occur if done the natural >> recursive way. > I'm not sure why the transition to another state has to be recursive. Off course it doesn't has to be recursive. It was just easier/more natural to do in a recursive way and needed warping to do in an interactive way. > Maybe this is something where previous experience makes you more > comfortable with a particular style, which will mean that functional > idioms will never feel more comfortable to me than iterative ones do, > and vice versa for you. Don't give me that. I have generally no problem solving things in an iterative way. This problem however was most naturally solved with a functional approach and I had to warp it in order to fit an iterative approach. > If that's the case, then I'll stick with > Python and Pike, and you can happily use Lisp and Haskell, and neither > of us need be a problem to the other. But honestly, I'm not seeing > anything that requires infinite recursion in your description. And > I've worked with a lot of networking protocols in my time. Your moving the goal posts. I only stated that sometimes the problem is easily solved by a number of fuctions that tail call each other. That you can warp this into an interative process and so don't require infinite recursion doesn't contradict that. >>>> It seems warping your code is only seen as a problem when going in the >>>> functional direction. Going into the iterative direction may take all >>>> the warping that is needed, without comment. >>> That's because I've never seen code that warps more for iteration than >>> it does for programming in general. Again, example please? >> And since when is your experience the measure stick for what other people >> encounter as problems? > That's why I said "example please?". My experience has not a single > time come across this. If you want to make an assertion that iterative > code requires equivalent warping to tail-recursive code, I want to see > an example of it. Is that difficult? Oh come on. It was rather obvious that your request for an example was not meant to learn something new but was meant for you to have a target to demolish and thus that you would try to mold that target into something you were familiar with. Which is exactly what you did above. From invalid at invalid.invalid Mon Jul 13 10:42:43 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 13 Jul 2015 14:42:43 +0000 (UTC) Subject: beginners choice: wx or tk? References: Message-ID: On 2015-07-11, Chris Angelico wrote: > On Sat, Jul 11, 2015 at 7:28 PM, Ulli Horlacher > wrote: >> I want to start a project with python. >> The program must have a (simple) GUI and must run on Linux and Windows. >> The last one as standalone executable, created with pyinstaller. > > Not sure what your advantage is with pyinstaller, it adds a level of > complication that doesn't usually justify itself IMO. > >> I have already an implementation in perl/tk : >> http://fex.rus.uni-stuttgart.de/fop/ZAcXSugp/schwuppdiwupp.png >> http://fex.belwue.de/download/schwuppdiwupp.pl >> >> I am not really happy with tk, because it has some bugs, at least its >> perl integration. I have never used wx. IMO, tk is quite a bit easier to use than wx for simple apps. >> What is the recommendation for a python beginner: wx or tk? > > Using wxPython means you need another library, while tkinter comes > with Python. Tkinter _usually_ comes with Python. You may run into Linux/Unix installs that have Python without tk. > There are some limitations to tk, and I personally don't like its > style, but if you're wanting to package it up into an EXE, every > third-party library you add will increase the size of that EXE, > potentially quite significantly (wxPython will drag in everything > that it depends on, which IIRC is quite a bit). Interesting. My experience was opposite. When I used to use py2exe, wx bundles tended to be smaller installs that tkinter apps (at least for small, simple apps). It doesn't matter whether the library is "third party" or not when bundling up a windows app. All that matters is the size of the library. When I compared sizes of farily simple apps, tkinter apps were quite a bit larger than wx apps. Don't forget that tkinter pulls in a complete TCL implementation. > There are other choices, too - pygtk/pygobject (GTK) and pyqt (Qt) > come to mind - is there a particular reason you're limiting the > question to just wx vs tk? The last time I checked pygtk on Windows wasn't ready for the real world, but that was a year or two back. That said, I think pygtk feels like a much cleaner and more pythonesque API than wx. > Personally, I quite like GTK, but I don't have much experience with > either of the Python bindings. Never used wxPython or PyQt. If it didn't have to run on Windows, I'd pick pygtk over wx. I've never tried qt. -- Grant Edwards grant.b.edwards Yow! Pardon me, but do you at know what it means to be gmail.com TRULY ONE with your BOOTH! From baruchel at no.spam.gmx.dot.com Mon Jul 13 11:44:25 2015 From: baruchel at no.spam.gmx.dot.com (Th. Baruchel) Date: 13 Jul 2015 15:44:25 GMT Subject: A new module for performing tail-call elimination Message-ID: <55a3dcd9$0$3024$426a34cc@news.free.fr> Hi, after having spent much time thinking about tail-call elimination in Python (see for instance http://baruchel.github.io/blog/ ), I finally decided to write a module for that. You may find it at: https://github.com/baruchel/tco Tail-call elimination is done for tail-recursion as well as for continuation-passing style (cps) in a consistent syntax for both usages. Any tail-recursive function having the suitable format for being embeddable in the Y combinator can be used here with no change at all (with the main difference that tail-calls will be eliminated), but other continuations can also be added The module is available under two forms: traditional python code and cython compilable code (pre-compiled binaries are also released for the cython version). Of course the Cython version is quicker and should be preferred for serious work. I must admit I haven't browsed much in order to know if similar projects already exist; I was happy to do it for myself, but I want to share it now in case other people are interested by it also. Best regards, -- Thomas Baruchel From roel at roelschroeven.net Mon Jul 13 12:56:33 2015 From: roel at roelschroeven.net (Roel Schroeven) Date: Mon, 13 Jul 2015 18:56:33 +0200 Subject: str.index() and str.find() versus only list.index() Message-ID: Hi, Quick question: why does str have both index() and find(), while list only has index()? Is there a reason for that, or is it just an historical accident? Best regards, Roel -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven From ethan at stoneleaf.us Mon Jul 13 13:38:12 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 13 Jul 2015 10:38:12 -0700 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A3CE62.6060304@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <55A3CE62.6060304@rece.vub.ac.be> Message-ID: <55A3F784.3020103@stoneleaf.us> Antoon, I think Chris is arguing in good faith; certainly asking for examples should be a reasonable request. Even if he is not, we would have better discussions and other participants would learn more if you act like he is. I would love to see good functional examples as it is definitely a weak spot for me. -- ~Ethan~ From marko at pacujo.net Mon Jul 13 15:07:31 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 13 Jul 2015 22:07:31 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <55A3CE62.6060304@rece.vub.ac.be> Message-ID: <87r3obev0s.fsf@elektro.pacujo.net> Ethan Furman : > I would love to see good functional examples as it is definitely a > weak spot for me. Oh, if you want to go functional, you should look at idiomatic Scheme code: ======================================================================== (define (common-prefix-length bytes-a bytes-b) (let loop ((list-a (string->list bytes-a)) (list-b (string->list bytes-b)) (common-length 0)) (cond ((null? list-a) common-length) ((null? list-b) common-length) ((= (car list-a) (car list-b)) (loop (cdr list-a) (cdr list-b) (+ common-length 8))) (else (+ common-length (vector-ref bit-match (- 8 (integer-length (logxor (car list-a) (car list-b)))))))))) ======================================================================== Or, translated into (non-idiomatic) Python code: ======================================================================== def common_prefix_length(bytes_a, bytes_b): def loop(list_a, list_b, common_length): if not list_a: return common_length if not list_b: return common_length if list_a[0] == list_b[0]: return loop(list_a[1:], list_b[1:], common_length + 8) return common_length + \ bit_match[8 - integer_length(list_a[0] ^ list_b[0])] return loop(bytes_a, bytes_b, 0) ======================================================================== Marko From kingklong2013 at hotmail.com Mon Jul 13 17:20:15 2015 From: kingklong2013 at hotmail.com (Thomas Via) Date: Mon, 13 Jul 2015 21:20:15 +0000 Subject: =?utf-8?Q?Can't_install/uninstall_Python?= Message-ID: Hello. I have a problem installing/uninstalling python. I?m trying to reinstall Python 2.7.9/2.7.10, but during the installation, it didn?t let me, which gave me this: "There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor." (The message wanted me to contact you for this.) Is there any way to fix this problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From colindnz at hotmail.com Mon Jul 13 18:15:42 2015 From: colindnz at hotmail.com (Colin Dick) Date: Mon, 13 Jul 2015 22:15:42 +0000 Subject: python 3.5.0b3 (32-bit) exe setup Message-ID: Hi guys when I run the downloaded version of this pgm "python-3.5.0b3.exe" there are no visible selection box's except "cancel" on the first screen shown see the attached screen dump its running on a win xp sp3 as a vmware vm Hey, thanks for all your hard work otherwise Colin Dick +64 21 166 0828 ( not currently in service ) +64 21 059 1318 ColinDNZ on facebook, linkedin, skype, twitter & hotmail or google it -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Toy 1-2015-07-14-09-57-50.PNG Type: image/png Size: 239409 bytes Desc: not available URL: From tjreedy at udel.edu Mon Jul 13 18:46:37 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 Jul 2015 18:46:37 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: Message-ID: On 7/13/2015 7:22 AM, Jussi Piitulainen wrote: > Ian Burnette writes: A post I did not receive, but want to comment on. >> I've recently been playing around with Clojure, and I really like the >> way they've overcome the JVM not supporting TRE. The way Clojure >> solves this problem is to have a built in "recur" function that >> signals to the Clojure compiler to convert the code to a loop in the >> JVM.In python we could do something similar Currently, the only means of affecting compilation of Python code are future imports and global and nonlocal declarations. (Coding cookie comments affect decoding of python code encoded as bytes, which happens before interpretation of the code.) Functions are called while running, after normal compilation. Python-coded functions are created during runtime by executing def statements (although code object are created during compilation). A tre(code) function could be written today that converts a tail-recursive body to a while body. It would be used as an alternate 'decorator' that works on the function text rather than the function object. Example: tre('''\ def dsum(n, a=0): return dsum(n-1, a+n) if n > 0 else a ''' In pseudocode (minus error checks and raises) that would work for the simple (and normal) case of exactly one tail_recursive call: def tre(tail_rec_code): split tail_rec_code into initial_part (header, docstring, and initial comments and code before the alternation) and recursive_alternation if recursive_alternation is if-else expression, convert to if-else statement if tail-recursion is in else branch, invert if condition and switch branch bodies replace 'if' with 'while' replace tail call with multiple assignment to parameters (from signature) modified_code = inital_part + modified_body return exec(modified_code, globals()) In the replacement steps if n > 1: return fac(n-1, acc*n) would become while n > 1: n, acc = n-1, acc*n If the operations were done with strings, tre would work today and indefinitely with any interpreter with standard string operations, exec and globals (though in practice I would use re also). If operations were done with ASTs, compile and the ast module (which is subject to change) would be required. >> by having a recur(*args, >> **kwargs) function that removes its parent from the stack and then >> runs the parent function again with the given arguments. Ian here somewhat confusingly half switches from loop conversion, which saves both space and time, to general tail call elimination, which saves space possibly at the cost of more time and less useful or even useless tracebacks. Which is to say, he switches from a tre-only implementation to a general tco implementation but uses syntax limited to tre. As Jussi notes, a general method should not be so limited. If one only wants tre, for which traceback compression is often a plus rather than a minus, then for automatic conversion, I think the time and space efficient loop-conversion should be used. If the recursion iterates through a collection, which is nearly always the case, then a human might convert to a for loop instead of a while loop. The idiomatic example below contains the input check usually left out of toy recursion examples. (Doing the check just once would require nesting the recursion within an outer function.) def fact(n): if n < 0 or not isinstance(n, int): raise ValueError('non-negative integer required') val = 1 for i in range(2, n+1): val *= i return val For loops separate iterating through a collection, which in this case is a range of integers, which has a known builtin solution, from processing the items produced by the iteration. Recursion and the equivalent while loops mix item processing with explicit next-item calculation, which is generally collection-class specific. To write a generic function like sum(iterable, start) with recursion, one must explicitly do everything that for loop do, which is to call iter, next, and handle StopIteration. Stack frames, and hence tre and tco, are implementation issues, not language issues. Moreover, these are machine implementation issues, as an intelligent human executing Python code should do 'the right thing' anyway. Guido himself has noted that it would be trivial for CPython to optimize all tail calls. But he also noted the cost of sometimes useless trackbacks and distraction from using iterables with for loops. Optimizing specific tail calls is tricker. For one thing, calls to a recursion-replacement function, such as recur, add a stack frame that must also be popped. A CPython bytecode manimpuation solution was given years ago as a recipe on the ActiveState Python Cookbook site. MacroPy at pypi.python.org "provides a mechanism for user-defined functions (macros) to perform transformations on the abstract syntax tree(AST) of Python code at module import time". Among many included examples, it has a tco decorator. -- Terry Jan Reedy From yongzhi.chen at gmail.com Mon Jul 13 19:13:05 2015 From: yongzhi.chen at gmail.com (yongzhi.chen at gmail.com) Date: Mon, 13 Jul 2015 16:13:05 -0700 (PDT) Subject: A webpy Templetor question Message-ID: Hi all, I want to display/update several metrics in a normal page (not in a webpy form). These metrics got updated every minute and were stored in a log file. I prepared a function to open that log file then analyze the last several lines to collect them. I want these metrics got updated in every page load/refresh. The first method I considered is to utilize Templetor (http://webpy.org/docs/0.3/templetor). I used $code block in the template but figured out soon that this solution won't work for the security reason. In my function I use open which is prohibited by webpy. Then I thought of `Import functions into templates` (https://github.com/webpy/webpy.github.com/blob/master/cookbook/template_import.md). In my case, there is no argument for that function. I followed the instruction but got the following error. checknow() takes no arguments (1 given) #in my application.py: def checknow(): ... return TN_str render = web.template.render('templates/',globals={'stat':checknow}) #in the template: $def with(checknow) ... ...

      Test: $stat(checknow)

      By the way, how to refer multiple values of the function checknow()? The function checknow() should return multiple values in the real case. Could you please help me out? Thanks a lot. Best Regards, -Yongzhi From rosuav at gmail.com Mon Jul 13 20:59:08 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 10:59:08 +1000 Subject: A webpy Templetor question In-Reply-To: References: Message-ID: On Tue, Jul 14, 2015 at 9:13 AM, wrote: > #in my application.py: > def checknow(): > ... > return TN_str > > render = web.template.render('templates/',globals={'stat':checknow}) > > #in the template: > $def with(checknow) > ... ... >

      Test: $stat(checknow)

      You've effectively taken a reference to the checknow function and given it the name 'stat'. So when you call $stat(), I would expect it to call checknow() with exactly those arguments. I don't know what "$def with(checknow)" means, but if you figure out what checknow is inside there, then you'll know whether you want any argument at all. I suspect just "$stat()" may well do what you want. ChrisA From torriem at gmail.com Mon Jul 13 22:16:10 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 13 Jul 2015 20:16:10 -0600 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: <55A470EA.5090708@gmail.com> On 07/13/2015 08:42 AM, Grant Edwards wrote: > If it didn't have to run on Windows, I'd pick pygtk over wx. I've > never tried qt. PyQt is very nice to work with. In some respects it's not as Pythonic as PyGTK. It feels a lot like transliterated C++ code, which it is. But it's a powerful toolkit and looks great on all supported platforms. If the licensing terms of PyQt are not to your liking, PySide is fairly close to PyQt (a few quirks that can be worked around), though I'm not sure how much love it's receiving lately. Like wx, or Gtk, you would have to ship some extra dlls with your project for Windows and OS X. From ian.g.kelly at gmail.com Mon Jul 13 23:12:18 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 13 Jul 2015 21:12:18 -0600 Subject: str.index() and str.find() versus only list.index() In-Reply-To: References: Message-ID: On Mon, Jul 13, 2015 at 10:56 AM, Roel Schroeven wrote: > Hi, > > Quick question: why does str have both index() and find(), while list only > has index()? Is there a reason for that, or is it just an historical > accident? Historical accident, I think. If it were to be redone, I doubt that str.find would exist. The problem with it is that it returns -1 to indicate that the argument was not found, but -1 is a valid index into the string. This is a potential source of hard-to-find bugs. There was a long thread from 2005 on python-dev proposing to remove str.find in Python 3, but evidently it didn't make the cut: https://mail.python.org/pipermail/python-dev/2005-August/055704.html From steve at pearwood.info Mon Jul 13 23:20:55 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Tue, 14 Jul 2015 13:20:55 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> Message-ID: <55a48017$0$1673$c3e8da3$5496439d@news.astraweb.com> On Tue, 14 Jul 2015 12:05 am, Chris Angelico wrote: > If you want to make an assertion that iterative > code requires equivalent warping to tail-recursive code, I want to see > an example of it. Is that difficult? Of course it is. If it wasn't difficult, people would post examples instead of getting all defensive about being asked for examples. -- Steven From steve at pearwood.info Mon Jul 13 23:23:44 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Tue, 14 Jul 2015 13:23:44 +1000 Subject: str.index() and str.find() versus only list.index() References: Message-ID: <55a480c0$0$1673$c3e8da3$5496439d@news.astraweb.com> On Tue, 14 Jul 2015 01:12 pm, Ian Kelly wrote: > On Mon, Jul 13, 2015 at 10:56 AM, Roel Schroeven > wrote: >> Hi, >> >> Quick question: why does str have both index() and find(), while list >> only has index()? Is there a reason for that, or is it just an historical >> accident? > > Historical accident, I think. If it were to be redone, I doubt that > str.find would exist. The problem with it is that it returns -1 to > indicate that the argument was not found, but -1 is a valid index into > the string. This is a potential source of hard-to-find bugs. Correct. But rather than removing it, it would be better to take a leaf out of re.match's book and return None as the sentinel. That would eliminate the "using -1 as a valid index" bug. -- Steven From tjreedy at udel.edu Mon Jul 13 23:36:44 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 Jul 2015 23:36:44 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87r3obev0s.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <55A3CE62.6060304@rece.vub.ac.be> <87r3obev0s.fsf@elektro.pacujo.net> Message-ID: On 7/13/2015 3:07 PM, Marko Rauhamaa wrote: > Or, translated into (non-idiomatic) Python code: > > ======================================================================== > def common_prefix_length(bytes_a, bytes_b): > def loop(list_a, list_b, common_length): > if not list_a: > return common_length > if not list_b: > return common_length > if list_a[0] == list_b[0]: > return loop(list_a[1:], list_b[1:], common_length + 8) > return common_length + \ > bit_match[8 - integer_length(list_a[0] ^ list_b[0])] > return loop(bytes_a, bytes_b, 0) > ======================================================================== This is an interesting challenge for conversion. The straightforward while loop conversion is (untested, obviously, without the auxiliary functions): def common_prefix_length(bytes_a, bytes_b): length = 0 while bytes_a and bytes_b and bytes_a[0] == bytes_b[0]: length += 8 bytes_a, bytes_b = bytes_a[1:], bytes_b[1:] if not bytes_a or not bytes_b: return length else: return common_length + bit_match[ 8 - integer_length(bytes_a[0] ^ bytes_b[0])] Using a for loop and zip to do the parallel iteration for us and avoid the list slicing, which is O(n) versus the O(1) lisp (cdr bytes), I believe the following is equivalent. def common_prefix_length(bytes_a, bytes_b): length = 0 for a, b in zip(bytes_a, bytes_b): if a == b: length += 8 else: return length + bit_match[8 - integer_length(a ^ b)] else: # short bytes is prefix of longer bytes return length I think this is much clearer than either recursion or while loop. It is also more general, as the only requirement on bytes_a and bytes_b is that they be iterables of bytes with a finite common_prefix, and not necessarily sequences with slicing or even indexing. -- Terry Jan Reedy From ian.g.kelly at gmail.com Tue Jul 14 00:07:27 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 13 Jul 2015 22:07:27 -0600 Subject: str.index() and str.find() versus only list.index() In-Reply-To: <55a480c0$0$1673$c3e8da3$5496439d@news.astraweb.com> References: <55a480c0$0$1673$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jul 13, 2015 at 9:23 PM, Steven D'Aprano wrote: > On Tue, 14 Jul 2015 01:12 pm, Ian Kelly wrote: > >> On Mon, Jul 13, 2015 at 10:56 AM, Roel Schroeven >> wrote: >>> Hi, >>> >>> Quick question: why does str have both index() and find(), while list >>> only has index()? Is there a reason for that, or is it just an historical >>> accident? >> >> Historical accident, I think. If it were to be redone, I doubt that >> str.find would exist. The problem with it is that it returns -1 to >> indicate that the argument was not found, but -1 is a valid index into >> the string. This is a potential source of hard-to-find bugs. > > Correct. But rather than removing it, it would be better to take a leaf out > of re.match's book and return None as the sentinel. That would eliminate > the "using -1 as a valid index" bug. I disagree on both counts. >>> s = 'abc' >>> s[None:None] 'abc' Better IMO to just have the one non-redundant method that raises an exception rather than returning anything that could possibly be interpreted as a string index. From ben+python at benfinney.id.au Tue Jul 14 00:45:25 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 14 Jul 2015 14:45:25 +1000 Subject: Foo.__new__ is what species of method? Message-ID: <85615nwdne.fsf@benfinney.id.au> Howdy all, The Python reference says of a class ?__new__? method:: object.__new__(cls[, ...]) Called to create a new instance of class cls. __new__() is a static method (special-cased so you need not declare it as such) that takes the class of which an instance was requested as its first argument. But a ?static method? is described, elsewhere in the documentation , as ?A static method does not receive an implicit first argument?. What the ?__new__? documentation describes would match a ?class method? ?A class method receives the class as implicit first argument?. I suspect this a bug in the reference documentation for ?__new__?, and it should instead say ?__new__ is a class method ??. Am I wrong? -- \ ?Cooles & Heates: If you want just condition of warm in your | `\ room, please control yourself.? ?air conditioner instructions, | _o__) Japan | Ben Finney From steve+comp.lang.python at pearwood.info Tue Jul 14 00:54:07 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Tue, 14 Jul 2015 14:54:07 +1000 Subject: Foo.__new__ is what species of method? References: Message-ID: <55a495ee$0$1580$c3e8da3$5496439d@news.astraweb.com> On Tuesday 14 July 2015 14:45, Ben Finney wrote: > Howdy all, > > The Python reference says of a class ?__new__? method:: > > object.__new__(cls[, ...]) > > Called to create a new instance of class cls. __new__() is a static > method (special-cased so you need not declare it as such) that takes > the class of which an instance was requested as its first argument. This is correct. __new__ is a static method and you need to explicitly provide the cls argument: py> class Spam(object): ... def __new__(cls): ... print cls ... py> Spam.__new__() # implicit first arg? Traceback (most recent call last): File "", line 1, in TypeError: __new__() takes exactly 1 argument (0 given) py> Spam.__new__(Spam) Furthermore: py> type(Spam.__dict__['__new__']) > I suspect this a bug in the reference documentation for ?__new__?, and > it should instead say ?__new__ is a class method ??. Am I wrong? I've made that mistake in the past too :-) -- Steve From steve+comp.lang.python at pearwood.info Tue Jul 14 00:58:31 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Tue, 14 Jul 2015 14:58:31 +1000 Subject: str.index() and str.find() versus only list.index() References: <55a480c0$0$1673$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55a496f6$0$1580$c3e8da3$5496439d@news.astraweb.com> On Tuesday 14 July 2015 14:07, Ian Kelly wrote: > On Mon, Jul 13, 2015 at 9:23 PM, Steven D'Aprano > wrote: >> On Tue, 14 Jul 2015 01:12 pm, Ian Kelly wrote: >> >>> On Mon, Jul 13, 2015 at 10:56 AM, Roel Schroeven >>> wrote: >>>> Hi, >>>> >>>> Quick question: why does str have both index() and find(), while list >>>> only has index()? Is there a reason for that, or is it just an >>>> historical accident? >>> >>> Historical accident, I think. If it were to be redone, I doubt that >>> str.find would exist. The problem with it is that it returns -1 to >>> indicate that the argument was not found, but -1 is a valid index into >>> the string. This is a potential source of hard-to-find bugs. >> >> Correct. But rather than removing it, it would be better to take a leaf >> out of re.match's book and return None as the sentinel. That would >> eliminate the "using -1 as a valid index" bug. > > I disagree on both counts. > >>>> s = 'abc' >>>> s[None:None] > 'abc' Well wadda ya know, I just learned something new. I was thinking more along these lines: py> 'abc'[None] Traceback (most recent call last): File "", line 1, in TypeError: string indices must be integers, not NoneType > Better IMO to just have the one non-redundant method that raises an > exception rather than returning anything that could possibly be > interpreted as a string index. Well, maybe, but if you got rid of str.find, the first thing people would do is recreate it: def find(*args): try: return str.index(*args) except ValueError: return -1 Having a version of str.index that returns a sentinel is just too damn handy. -- Steve From rosuav at gmail.com Tue Jul 14 01:13:41 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 15:13:41 +1000 Subject: str.index() and str.find() versus only list.index() In-Reply-To: <55a496f6$0$1580$c3e8da3$5496439d@news.astraweb.com> References: <55a480c0$0$1673$c3e8da3$5496439d@news.astraweb.com> <55a496f6$0$1580$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Jul 14, 2015 at 2:58 PM, Steven D'Aprano wrote: > On Tuesday 14 July 2015 14:07, Ian Kelly wrote: > >> On Mon, Jul 13, 2015 at 9:23 PM, Steven D'Aprano >> wrote: >>> Correct. But rather than removing it, it would be better to take a leaf >>> out of re.match's book and return None as the sentinel. That would >>> eliminate the "using -1 as a valid index" bug. >> >> I disagree on both counts. >> >>>>> s = 'abc' >>>>> s[None:None] >> 'abc' > > > Well wadda ya know, I just learned something new. I was thinking more along > these lines: > > py> 'abc'[None] > Traceback (most recent call last): > File "", line 1, in > TypeError: string indices must be integers, not NoneType Which proves that None is not a valid index, but it is a valid slice boundary. Given that the return value will often be used for slicing as well as indexing, it'd be good to have something that's not valid for either. How about -1.0? It's equal to -1 in case someone uses (str.find(...) == -1), it's less than zero in case they do (str.find(...) < 0), and it's invalid in both slices and string subscripts. There's no way that can break anything, right? ... oh wait. XKCD 1172. And anyone who's adding 1 to the position and using that as a slice boundary, which will smoothly and without error work with the beginning of the string if something isn't found (eg s[s.find("-"):] will be everything after the first hyphen, or the whole string if there isn't one). >> Better IMO to just have the one non-redundant method that raises an >> exception rather than returning anything that could possibly be >> interpreted as a string index. > > > Well, maybe, but if you got rid of str.find, the first thing people would do > is recreate it: > > def find(*args): > try: > return str.index(*args) > except ValueError: > return -1 > > > Having a version of str.index that returns a sentinel is just too damn > handy. Same as dictionaries have [] and .get(), although find doesn't allow you to change the sentinel. ChrisA From no.email at nospam.invalid Tue Jul 14 01:15:33 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Mon, 13 Jul 2015 22:15:33 -0700 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> Message-ID: <87fv4r1fre.fsf@jester.gateway.sonic.net> Chris Angelico writes: > I'm not sure why the transition to another state has to be recursive. It's not recursive: it's more like a goto with arguments, and a tail call expresses it nicely. > Maybe this is something where previous experience makes you more > comfortable with a particular style, which will mean that functional > idioms will never feel more comfortable to me than iterative ones do, > and vice versa for you. If that's the case, then I'll stick with > Python and Pike, and you can happily use Lisp and Haskell, and neither > of us need be a problem to the other. Do you also use explicit loops instead of list comprehensions? They are another nice functional idiom adapted into Python. > That's why I said "example please?". My experience has not a single > time come across this. If you want to make an assertion that iterative > code requires equivalent warping to tail-recursive code, I want to see > an example of it. Is that difficult? It's difficult given how subjective the concept of warping is. What's straightforward to someone else sounds likely to look warped to you and vice versa. But how does this look: def quicksort(array, start, end): midp = partition(array, start, end) if midp <= (start+end)//2: quicksort(array, start, midp) quicksort(array, midp+1, end) else: quicksort(array, midp+1, end) quicksort(array, start, midp) I assume you know how quicksort and its partition step work. The idea is you partition the array around the pivot element (midp is the index of that element), then recursively sort the two partitions, doing the smaller partition as a recursive call and the larger one as a tail call, so that you use O(log n) stack depth instead of potentially O(n). So the idea is that the second quicksort call in each branch of the if is a tail call. Yes you could code that as a loop but from my perspective the way I wrote it above looks more natural. Of course it's also possible that I've totally derped this and the example is no good for some reason I've missed so far ;-). From ben+python at benfinney.id.au Tue Jul 14 01:17:35 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 14 Jul 2015 15:17:35 +1000 Subject: Foo.__new__ is what species of method? References: <55a495ee$0$1580$c3e8da3$5496439d@news.astraweb.com> Message-ID: <851tgbwc5s.fsf@benfinney.id.au> Steven D'Aprano writes: > py> class Spam(object): > ... def __new__(cls): > ... print cls > ... > py> Spam.__new__() # implicit first arg? > Traceback (most recent call last): > File "", line 1, in > TypeError: __new__() takes exactly 1 argument (0 given) Thanks, I'm glad I checked before filing a bug report. Hopefully I'll remember that clear test, when I need to remember which species it is :-) -- \ ?Instead of having ?answers? on a math test, they should just | `\ call them ?impressions?, and if you got a different | _o__) ?impression?, so what, can't we all be brothers?? ?Jack Handey | Ben Finney From rosuav at gmail.com Tue Jul 14 01:25:41 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 15:25:41 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87fv4r1fre.fsf@jester.gateway.sonic.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> Message-ID: On Tue, Jul 14, 2015 at 3:15 PM, Paul Rubin wrote: > It's difficult given how subjective the concept of warping is. What's > straightforward to someone else sounds likely to look warped to you and > vice versa. But how does this look: > > def quicksort(array, start, end): > midp = partition(array, start, end) > if midp <= (start+end)//2: > quicksort(array, start, midp) > quicksort(array, midp+1, end) > else: > quicksort(array, midp+1, end) > quicksort(array, start, midp) > > I assume you know how quicksort and its partition step work. The idea > is you partition the array around the pivot element (midp is the index > of that element), then recursively sort the two partitions, doing the > smaller partition as a recursive call and the larger one as a tail call, > so that you use O(log n) stack depth instead of potentially O(n). > > So the idea is that the second quicksort call in each branch of the if > is a tail call. Yes you could code that as a loop but from my > perspective the way I wrote it above looks more natural. > > Of course it's also possible that I've totally derped this and the > example is no good for some reason I've missed so far ;-). That's a prime example of recursion... but not of recursion that can be tail-call optimized into iteration. It's an example of forking recursion, where one call can result in multiple calls (same with tree traversal); it calls itself to sort the first part and the last part, and while you might be able to turn the second call into a goto, you still need stack space to maintain the first call. The claim that TCO means you don't need stack space for all those levels of recursion doesn't work if you still need stack space for all those levels of recursion *before* you get to the tail call. (Also, side point: Python can't actually optimize the above function, because it actually means "call quicksort, then discard its return value and return None". A true tail call has to return the result of the recursive call, and Python lacks a way to say "this function will always return None". But that's trivial.) ChrisA From rosuav at gmail.com Tue Jul 14 01:31:59 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 15:31:59 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87fv4r1fre.fsf@jester.gateway.sonic.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> Message-ID: On Tue, Jul 14, 2015 at 3:15 PM, Paul Rubin wrote: > Chris Angelico writes: >> I'm not sure why the transition to another state has to be recursive. > > It's not recursive: it's more like a goto with arguments, and a tail > call expresses it nicely. Hmm, maybe, but I'm not sure that the transition to another state is a goto with arguments. What triggers the transition? Is it a linear protocol? Is it a nested protocol that completes some operation and returns to a base state? How are these transitions recognized, and why is that needing a "goto with arguments" to express it? >> Maybe this is something where previous experience makes you more >> comfortable with a particular style, which will mean that functional >> idioms will never feel more comfortable to me than iterative ones do, >> and vice versa for you. If that's the case, then I'll stick with >> Python and Pike, and you can happily use Lisp and Haskell, and neither >> of us need be a problem to the other. > > Do you also use explicit loops instead of list comprehensions? They are > another nice functional idiom adapted into Python. I use list comprehensions, but that's not the same thing as using functional programming. What that means is that there's nothing that we can't learn from. I'm glad functional languages exist, where people try to make everything have no side effects and be deterministic; it's a good discipline, and worth being aware of even when your language doesn't enforce it. But just because functional languages like to say "take this array and multiply every element by 4" and I like using that same feature, that doesn't mean that I want to do everything in a functional style. Here's an alternative way of expressing that thought. Do you write code such that each line does one simple thing? That's a nice assembly language practice that's been adapted into Python. Assembly languages tend to enforce a "one line, one operation" rule. Python programmers often adhere to that (you don't generally see a bunch of stuff separated by semicolons, and even "for line in lines: print(line)" is frowned upon - add a newline!), but that doesn't mean we want all the other trappings of assembly languages. ChrisA From no.email at nospam.invalid Tue Jul 14 01:41:07 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Mon, 13 Jul 2015 22:41:07 -0700 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> Message-ID: <87bnff1eks.fsf@jester.gateway.sonic.net> Chris Angelico writes: > That's a prime example of recursion... but not of recursion that can > be tail-call optimized into iteration. It's an example of forking > recursion, where one call can result in multiple calls (same with tree > traversal); it calls itself to sort the first part and the last part, > and while you might be able to turn the second call into a goto, you > still need stack space to maintain the first call. The claim that TCO > means you don't need stack space for all those levels of recursion > doesn't work if you still need stack space for all those levels of > recursion *before* you get to the tail call. You partition the array into two parts, one of which has at most N/2 elements. You push that smaller one onto the stack and recurse, so at the next recursive level you push at most an N/4 part, then N/8 and so on. In that way the total recursion depth is O(log N). If N=1e6 you enter 20 levels of recursion which is no big deal. If you also push the larger part on the stack, it can have size as high as N-1, so you can end up pushing N-1, N-2, N-3, etc. If N=1e6 you overflow the stack when you've barely gotten started. So it's important in that example that both of the recursive calls involving the larger partition are both tail calls. It's fine that the first call pushes stuff on the stack. It's vital that the second call be turned into a goto. From marko at pacujo.net Tue Jul 14 01:41:37 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 08:41:37 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> Message-ID: <87bnffnvn2.fsf@elektro.pacujo.net> Chris Angelico : >> def quicksort(array, start, end): >> midp = partition(array, start, end) >> if midp <= (start+end)//2: >> quicksort(array, start, midp) >> quicksort(array, midp+1, end) >> else: >> quicksort(array, midp+1, end) >> quicksort(array, start, midp) > [...] > That's a prime example of recursion... but not of recursion that can > be tail-call optimized into iteration. Of course it can. The 2nd and 4th calls to quicksort can be trivially tail-call-optimized. Tail-call optimization has nothing to do with converting algorithms into iterations. It's a prosaic trick of dropping an unneeded stack frame before making a function call. > The claim that TCO means you don't need stack space for all those > levels of recursion doesn't work if you still need stack space for all > those levels of recursion *before* you get to the tail call. Nobody is making that claim. What you are questioning is what tail-call optimization would buy you in practice. Not much. The few times you run into a stack overflow, you can refactor your code pretty easily. However, when you have to do that, it feels a bit silly. Marko From ian.g.kelly at gmail.com Tue Jul 14 01:46:23 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 13 Jul 2015 23:46:23 -0600 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> Message-ID: On Mon, Jul 13, 2015 at 11:25 PM, Chris Angelico wrote: > (Also, side point: Python can't actually optimize the above function, > because it actually means "call quicksort, then discard its return > value and return None". A true tail call has to return the result of > the recursive call, and Python lacks a way to say "this function will > always return None". But that's trivial.) Another point in favor of an explicit tail-call keyword. Then one couldn't make that mistake. From marko at pacujo.net Tue Jul 14 01:57:27 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 08:57:27 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> Message-ID: <877fq3nuwo.fsf@elektro.pacujo.net> Ian Kelly : > On Mon, Jul 13, 2015 at 11:25 PM, Chris Angelico wrote: >> (Also, side point: Python can't actually optimize the above function, >> because it actually means "call quicksort, then discard its return >> value and return None". A true tail call has to return the result of >> the recursive call, and Python lacks a way to say "this function will >> always return None". But that's trivial.) > > Another point in favor of an explicit tail-call keyword. Then one > couldn't make that mistake. How about "return"? Marko From stefan_ml at behnel.de Tue Jul 14 02:26:46 2015 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 14 Jul 2015 08:26:46 +0200 Subject: Foo.__new__ is what species of method? In-Reply-To: <55a495ee$0$1580$c3e8da3$5496439d@news.astraweb.com> References: <55a495ee$0$1580$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano schrieb am 14.07.2015 um 06:54: > On Tuesday 14 July 2015 14:45, Ben Finney wrote: >> The Python reference says of a class ?__new__? method:: >> >> object.__new__(cls[, ...]) >> >> Called to create a new instance of class cls. __new__() is a static >> method (special-cased so you need not declare it as such) that takes >> the class of which an instance was requested as its first argument. > > This is correct. __new__ is a static method and you need to explicitly > provide the cls argument: And it needs to be that way in order to allow superclass calls in a subclass's __new__ method: class Super(object): def __new__(cls): return object.__new__(cls) class Sub(Super): def __new__(cls): return Super.__new__(cls) If it was a classmethod, it would receive the class you call it on as first argument (i.e. "Super" and "object" above), not the class you want to instantiate (i.e. "Sub" or "Super"). Stefan From greg.ewing at canterbury.ac.nz Tue Jul 14 02:29:12 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 14 Jul 2015 18:29:12 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <877fq3nuwo.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> Message-ID: Marko Rauhamaa wrote: > Ian Kelly : > >>Another point in favor of an explicit tail-call keyword. Then one >>couldn't make that mistake. > > How about "return"? How about "goto"? :-) That's not entirely an unserious suggestion -- if you really believe that a "goto with arguments" is a good feature for a language to have, you shouldn't be afraid to spell it as such. def quicksort(array, start, end): midp = partition(array, start, end) if midp <= (start+end)//2: quicksort(array, start, midp) goto quicksort(array, midp+1, end) else: quicksort(array, midp+1, end) goto quicksort(array, start, midp) -- Greg From marko at pacujo.net Tue Jul 14 03:05:46 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 10:05:46 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> Message-ID: <87380rnrqt.fsf@elektro.pacujo.net> Gregory Ewing : > Marko Rauhamaa wrote: >> How about "return"? > > How about "goto"? :-) > > That's not entirely an unserious suggestion -- if you > really believe that a "goto with arguments" is a good > feature for a language to have, you shouldn't be > afraid to spell it as such. > > def quicksort(array, start, end): > midp = partition(array, start, end) > if midp <= (start+end)//2: > quicksort(array, start, midp) > goto quicksort(array, midp+1, end) > else: > quicksort(array, midp+1, end) > goto quicksort(array, start, midp) This works already now: def quicksort(array, start, end): midp = partition(array, start, end) if midp <= (start+end)//2: quicksort(array, start, midp) return quicksort(array, midp+1, end) else: quicksort(array, midp+1, end) return quicksort(array, start, midp) It might even be tail-call optimized by Python. Only you can't count on it because the language spec doesn't guarantee it. Marko From antoon.pardon at rece.vub.ac.be Tue Jul 14 03:26:57 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Tue, 14 Jul 2015 09:26:57 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55a48017$0$1673$c3e8da3$5496439d@news.astraweb.com> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <55a48017$0$1673$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55A4B9C1.4000009@rece.vub.ac.be> On 07/14/2015 05:20 AM, Steven D'Aprano wrote: > On Tue, 14 Jul 2015 12:05 am, Chris Angelico wrote: > >> If you want to make an assertion that iterative >> code requires equivalent warping to tail-recursive code, I want to see >> an example of it. Is that difficult? > Of course it is. If it wasn't difficult, people would post examples instead > of getting all defensive about being asked for examples. Shrug! I have seen this game played before. It has been played since before python had an if-expression. It always goes as follows. Some one mentions a feature python doesn't has and that could be useful. The python status-quo people will argue that it is unnecessary. Any example that will be given to illustrate the advantage will be nit picked appart for any possible flaw, while mostly ignoring the flaws in the status quo. Before python had an if-expression, examples were asked too and they convinced noone. It wasn't until a core developer was bitten by an elusive bug, caused by using the then advised "and or" combination, that python got an if-expression and that an if-expression was considered useful by the python community in general. I expect any example given, to be used as a contest by those reading, for finding the least warped alternative and then using that to dismiss the example. So I really don't feel compelled to search through my code in the hope of finding an example that would persuade someone. -- Antoon Pardon From breamoreboy at yahoo.co.uk Tue Jul 14 03:39:15 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 14 Jul 2015 08:39:15 +0100 Subject: beginners choice: wx or tk? In-Reply-To: <55A470EA.5090708@gmail.com> References: <55A470EA.5090708@gmail.com> Message-ID: On 14/07/2015 03:16, Michael Torrie wrote: > On 07/13/2015 08:42 AM, Grant Edwards wrote: >> If it didn't have to run on Windows, I'd pick pygtk over wx. I've >> never tried qt. > > PyQt is very nice to work with. In some respects it's not as Pythonic > as PyGTK. It feels a lot like transliterated C++ code, which it is. > But it's a powerful toolkit and looks great on all supported platforms. > If the licensing terms of PyQt are not to your liking, PySide is fairly > close to PyQt (a few quirks that can be worked around), though I'm not > sure how much love it's receiving lately. Like wx, or Gtk, you would > have to ship some extra dlls with your project for Windows and OS X. > > Looks good for PySide http://lists.qt-project.org/pipermail/pyside/2015-July/002313.html :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Tue Jul 14 03:47:28 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 14 Jul 2015 08:47:28 +0100 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> Message-ID: On 14/07/2015 07:29, Gregory Ewing wrote: > Marko Rauhamaa wrote: >> Ian Kelly : >> >>> Another point in favor of an explicit tail-call keyword. Then one >>> couldn't make that mistake. >> >> How about "return"? > > How about "goto"? :-) > Why not "goto"? It's use is scattered throughout the cpython code, and to my knowledge there's no paper that says *NEVER* use it. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From ian.g.kelly at gmail.com Tue Jul 14 04:13:37 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 14 Jul 2015 02:13:37 -0600 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <877fq3nuwo.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> Message-ID: On Mon, Jul 13, 2015 at 11:57 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Mon, Jul 13, 2015 at 11:25 PM, Chris Angelico wrote: >>> (Also, side point: Python can't actually optimize the above function, >>> because it actually means "call quicksort, then discard its return >>> value and return None". A true tail call has to return the result of >>> the recursive call, and Python lacks a way to say "this function will >>> always return None". But that's trivial.) >> >> Another point in favor of an explicit tail-call keyword. Then one >> couldn't make that mistake. > > How about "return"? I think you miss my point entirely. "return" doesn't mean tail-call optimize; it just means to return the result. This is what led to the confusion responsible for the bug that Chris pointed out in the first place. With a keyword that explicitly means "perform tail-call optimization *and* return", the association of the keyword with the optimization is much clearer, and the programmer is much less likely to mistakenly omit it. From toddrjen at gmail.com Tue Jul 14 04:20:41 2015 From: toddrjen at gmail.com (Todd) Date: Tue, 14 Jul 2015 10:20:41 +0200 Subject: str.index() and str.find() versus only list.index() In-Reply-To: References: <55a480c0$0$1673$c3e8da3$5496439d@news.astraweb.com> <55a496f6$0$1580$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Jul 14, 2015 at 7:13 AM, Chris Angelico wrote: > On Tue, Jul 14, 2015 at 2:58 PM, Steven D'Aprano > wrote: > > On Tuesday 14 July 2015 14:07, Ian Kelly wrote: > > > >> On Mon, Jul 13, 2015 at 9:23 PM, Steven D'Aprano > >> wrote: > >>> Correct. But rather than removing it, it would be better to take a leaf > >>> out of re.match's book and return None as the sentinel. That would > >>> eliminate the "using -1 as a valid index" bug. > >> > >> Better IMO to just have the one non-redundant method that raises an > >> exception rather than returning anything that could possibly be > >> interpreted as a string index. > > > > > > Well, maybe, but if you got rid of str.find, the first thing people > would do > > is recreate it: > > > > def find(*args): > > try: > > return str.index(*args) > > except ValueError: > > return -1 > > > > > > Having a version of str.index that returns a sentinel is just too damn > > handy. > > Same as dictionaries have [] and .get(), although find doesn't allow > you to change the sentinel. > > Maybe that is the solution? Add a keyword-only argument to find to change the sentinel? -------------- next part -------------- An HTML attachment was scrubbed... URL: From marko at pacujo.net Tue Jul 14 04:33:56 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 11:33:56 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> Message-ID: <87pp3vm93f.fsf@elektro.pacujo.net> Ian Kelly : > On Mon, Jul 13, 2015 at 11:57 PM, Marko Rauhamaa wrote: >> How about "return"? > > I think you miss my point entirely. "return" doesn't mean tail-call > optimize; Why not? > it just means to return the result. Same difference. > This is what led to the confusion responsible for the bug that Chris > pointed out in the first place. With a keyword that explicitly means > "perform tail-call optimization *and* return", That could well be the explicit definition of the "return" statement in Python without changing the behavior of any working Python program today. > the association of the keyword with the optimization is much clearer, > and the programmer is much less likely to mistakenly omit it. The programmer shouldn't be controlling tail call optimizations. Marko From ian.g.kelly at gmail.com Tue Jul 14 04:34:11 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 14 Jul 2015 02:34:11 -0600 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A4B9C1.4000009@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <55a48017$0$1673$c3e8da3$5496439d@news.astraweb.com> <55A4B9C1.4000009@rece.vub.ac.be> Message-ID: On Tue, Jul 14, 2015 at 1:26 AM, Antoon Pardon wrote: > On 07/14/2015 05:20 AM, Steven D'Aprano wrote: >> On Tue, 14 Jul 2015 12:05 am, Chris Angelico wrote: >> >>> If you want to make an assertion that iterative >>> code requires equivalent warping to tail-recursive code, I want to see >>> an example of it. Is that difficult? >> Of course it is. If it wasn't difficult, people would post examples instead >> of getting all defensive about being asked for examples. > > Shrug! I have seen this game played before. It has been played since before > python had an if-expression. It always goes as follows. Some one mentions > a feature python doesn't has and that could be useful. The python status-quo > people will argue that it is unnecessary. Any example that will be given > to illustrate the advantage will be nit picked appart for any possible flaw, > while mostly ignoring the flaws in the status quo. > > Before python had an if-expression, examples were asked too and they > convinced > noone. It wasn't until a core developer was bitten by an elusive bug, caused > by using the then advised "and or" combination, that python got an > if-expression > and that an if-expression was considered useful by the python community > in general. > > I expect any example given, to be used as a contest by those reading, > for finding > the least warped alternative and then using that to dismiss the example. > > So I really don't feel compelled to search through my code in the hope > of finding > an example that would persuade someone. And yet, Python somehow manages to gain new features with each release. The reason why most proposals get rejected is because most proposals are bad. If every idea that came along just got accepted, we'd have a disastrous hodge-podge of a language. In the case of TCO, Guido rejected the feature six years ago and hasn't shown any sign of changing his mind. He considered the arguments for it, and he decided that for Python, the benefits don't outweigh the drawbacks. Maybe his mind could still be changed, but it's going to take somebody to make a very convincing case for the feature, and if you're not even willing to put forth some examples then you don't have a case at all. From antoon.pardon at rece.vub.ac.be Tue Jul 14 06:43:05 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Tue, 14 Jul 2015 12:43:05 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <55a48017$0$1673$c3e8da3$5496439d@news.astraweb.com> <55A4B9C1.4000009@rece.vub.ac.be> Message-ID: <55A4E7B9.3080801@rece.vub.ac.be> On 07/14/2015 10:34 AM, Ian Kelly wrote: > On Tue, Jul 14, 2015 at 1:26 AM, Antoon Pardon > wrote: >> I expect any example given, to be used as a contest by those reading, >> for finding >> the least warped alternative and then using that to dismiss the example. >> >> So I really don't feel compelled to search through my code in the hope >> of finding >> an example that would persuade someone. > And yet, Python somehow manages to gain new features with each release. Sure, but what happens in this list, has an insignificant role in driving that process. > The reason why most proposals get rejected is because most proposals > are bad. If every idea that came along just got accepted, we'd have a > disastrous hodge-podge of a language. But I'm not proposing TCO to be accepted. I was just pointing out a reason for preferring it in particular circumstances and only because some people here suggested there could be no such reasons. > In the case of TCO, Guido rejected the feature six years ago and > hasn't shown any sign of changing his mind. He considered the > arguments for it, and he decided that for Python, the benefits don't > outweigh the drawbacks. Maybe his mind could still be changed, but > it's going to take somebody to make a very convincing case for the > feature, and if you're not even willing to put forth some examples > then you don't have a case at all. Indeed I am not trying to make a case. I was just protesting the sugestion that there are no circumstances in which having TCO could be an advantage. That me suggesting such circumstances do exist gets turned into me trying to make a case for including TCO into the language is one important reason why I am not inclined to search for examples. Because all I would try to do is illustrate how TCO would be an advantage in that case en how it would probably be received is as if I would try and present that example as a compelling case for introducing TCO into python. For what it is worth, in general I find both the warping necessary for turning iterative code into tail-recursive code and vice versa not that big a deal. I just find that the solutions for my problems are sometimes more easily expressed one way and sometimes the other way and I would prefer I didn't need to warp. From rosuav at gmail.com Tue Jul 14 07:33:55 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 21:33:55 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87bnffnvn2.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnffnvn2.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 14, 2015 at 3:41 PM, Marko Rauhamaa wrote: > Tail-call optimization has nothing to do with converting algorithms into > iterations. It's a prosaic trick of dropping an unneeded stack frame > before making a function call. > >> The claim that TCO means you don't need stack space for all those >> levels of recursion doesn't work if you still need stack space for all >> those levels of recursion *before* you get to the tail call. > > Nobody is making that claim. Actually, that claim was made - that Python's stack would overflow if you didn't optimize tail calls away. I don't feel like digging up through the history to find out who first made the claim, but it was made in this thread. ChrisA From rosuav at gmail.com Tue Jul 14 07:43:57 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 21:43:57 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87bnff1eks.fsf@jester.gateway.sonic.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: On Tue, Jul 14, 2015 at 3:41 PM, Paul Rubin wrote: > Chris Angelico writes: >> That's a prime example of recursion... but not of recursion that can >> be tail-call optimized into iteration. It's an example of forking >> recursion, where one call can result in multiple calls (same with tree >> traversal); it calls itself to sort the first part and the last part, >> and while you might be able to turn the second call into a goto, you >> still need stack space to maintain the first call. The claim that TCO >> means you don't need stack space for all those levels of recursion >> doesn't work if you still need stack space for all those levels of >> recursion *before* you get to the tail call. > > You partition the array into two parts, one of which has at most N/2 > elements. You push that smaller one onto the stack and recurse, so at > the next recursive level you push at most an N/4 part, then N/8 and so > on. In that way the total recursion depth is O(log N). If N=1e6 you > enter 20 levels of recursion which is no big deal. > > If you also push the larger part on the stack, it can have size as high > as N-1, so you can end up pushing N-1, N-2, N-3, etc. If N=1e6 you > overflow the stack when you've barely gotten started. Ah, good point. So this is a way of forcing the recursion to be capped at log N, preventing the worst-case time from also carrying worst-case stack usage. Fair enough. Okay! Great! We have one example where TCO can be helpful, because it means your two calls look identical. Well, nearly identical... since one of them has to be "return quicksort(...)" but the other has to be just "quicksort(...)". So in order to make sure it's a true optimizable tail call, they end up having to look different. Plus there's the whole traceback problem. I'm still interested in the explicit "replace current stack frame with this call" operation. Calling it "goto" seems wrong, as most languages with goto restrict it to _within_ a function, whereas this would be _across_ functions: int fail_and_bail_demo(int arg, char *whatever) { int ret = 1; /* failure */ if (arg < 0) goto failure; int stuff_done = do_stuff(whatever); if (stuff_done < arg) goto failure; if (do_more_stuff(arg, whatever)) goto failure; ret = 0; /* If we get here, success! */ failure: clean_up(); return ret; } Contrast this proposal: def func(): pass def setup_and_call(): setup() transfer func, (), {} The transfer of control has to be to the beginning of some other function. So I'd rather it _not_ be called goto, but rather something more evoking the notion of "hand control over to that function over there, pretending that I've already returned". It's very much like the Unix exec* family of functions, but Python already uses the name 'exec' in a very different way. Done explicitly like this, it avoids the problem of bad tracebacks, because by definition you would use it only when you want the current stack frame to be dropped. I wonder how hard it would be to hack this into CPython... Anyone feel like tackling it? ChrisA From rosuav at gmail.com Tue Jul 14 07:53:48 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 21:53:48 +1000 Subject: Can't install/uninstall Python In-Reply-To: References: Message-ID: On Tue, Jul 14, 2015 at 7:20 AM, Thomas Via wrote: > I?m trying to reinstall Python 2.7.9/2.7.10, but during the installation, it > didn?t let me, which gave me this: > > "There is a problem with this Windows Installer package. A program required > for this install to complete could not be run. Contact your support > personnel or package vendor." Hi! What version of Windows are you running? And what architecture (32-bit or 64-bit)? Exactly what file did you download, and from where? The more information you can provide, the easier it will be to figure out what's going on. ChrisA From rosuav at gmail.com Tue Jul 14 07:56:54 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 21:56:54 +1000 Subject: python 3.5.0b3 (32-bit) exe setup In-Reply-To: References: Message-ID: On Tue, Jul 14, 2015 at 8:15 AM, Colin Dick wrote: > when I run the downloaded version of this pgm "python-3.5.0b3.exe" > > there are no visible selection box's except "cancel" on the > first screen shown > > see the attached screen dump > > its running on a win xp sp3 as a vmware vm > As of Python 3.5, Windows XP is no longer a supported platform. Since there has also been a change of compiler for 3.5, it wouldn't surprise me if there are odd problems where something just doesn't work. Can you reproduce the problem on Win 7 or newer? If it's just an XP problem, I suspect the devs won't be very much interested in fixing it (although if _you_ fix it, they may be willing to incorporate the change, assuming it doesn't break anything else). ChrisA From marko at pacujo.net Tue Jul 14 08:08:42 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 15:08:42 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnffnvn2.fsf@elektro.pacujo.net> Message-ID: <87h9p7lz5h.fsf@elektro.pacujo.net> Chris Angelico : > On Tue, Jul 14, 2015 at 3:41 PM, Marko Rauhamaa wrote: >> Tail-call optimization has nothing to do with converting algorithms into >> iterations. It's a prosaic trick of dropping an unneeded stack frame >> before making a function call. >> >>> The claim that TCO means you don't need stack space for all those >>> levels of recursion doesn't work if you still need stack space for all >>> those levels of recursion *before* you get to the tail call. >> >> Nobody is making that claim. > > Actually, that claim was made - that Python's stack would overflow if > you didn't optimize tail calls away. I don't feel like digging up > through the history to find out who first made the claim, but it was > made in this thread. Nobody is making the claim that optimizing tail calls *always* saves you from stack overflows. Optimizing tail calls *sometimes* saves you from stack overflows. Marko From marko at pacujo.net Tue Jul 14 08:28:02 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 15:28:02 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: <87d1zunctp.fsf@elektro.pacujo.net> Chris Angelico : > Done explicitly like this, it avoids the problem of bad tracebacks, > because by definition you would use it only when you want the current > stack frame to be dropped. I wonder how hard it would be to hack this > into CPython... Anyone feel like tackling it? I would rather optimize by default and disable optimizations with --debug or equivalent. Marko From rosuav at gmail.com Tue Jul 14 08:55:48 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 22:55:48 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87d1zunctp.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 14, 2015 at 10:28 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> Done explicitly like this, it avoids the problem of bad tracebacks, >> because by definition you would use it only when you want the current >> stack frame to be dropped. I wonder how hard it would be to hack this >> into CPython... Anyone feel like tackling it? > > I would rather optimize by default and disable optimizations with > --debug or equivalent. That assumes that it's simply an optimization. This is a distinct semantic change. Would you, for instance, want all of your arithmetic to be rounded to integer because integers are faster - and then disable this "optimization" with a flag that permits floating-point arithmetic? Certainly not. ChrisA From ian.g.kelly at gmail.com Tue Jul 14 09:15:19 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 14 Jul 2015 07:15:19 -0600 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87pp3vm93f.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 14, 2015 at 2:33 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Mon, Jul 13, 2015 at 11:57 PM, Marko Rauhamaa wrote: >>> How about "return"? >> >> I think you miss my point entirely. "return" doesn't mean tail-call >> optimize; > > Why not? > >> it just means to return the result. > > Same difference. > >> This is what led to the confusion responsible for the bug that Chris >> pointed out in the first place. With a keyword that explicitly means >> "perform tail-call optimization *and* return", > > That could well be the explicit definition of the "return" statement in > Python without changing the behavior of any working Python program > today. To the compiler. It won't be viewed that way be the programmer, however. So they'll forget that the "return" is necessary to the optimization and just write quicksort() instead of return quicksort(). >> the association of the keyword with the optimization is much clearer, >> and the programmer is much less likely to mistakenly omit it. > > The programmer shouldn't be controlling tail call optimizations. The programmer controls it regardless. return foo() # TCO result = foo() # No TCO return result # No TCO From marko at pacujo.net Tue Jul 14 09:38:08 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 16:38:08 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> Message-ID: <87k2u2eu67.fsf@elektro.pacujo.net> Chris Angelico : > On Tue, Jul 14, 2015 at 10:28 PM, Marko Rauhamaa wrote: >> I would rather optimize by default and disable optimizations with >> --debug or equivalent. > > That assumes that it's simply an optimization. This is a distinct > semantic change. No, tail call optimization doesn't change the behavior of the program, for the worse anyway. Marko From rosuav at gmail.com Tue Jul 14 09:43:22 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Jul 2015 23:43:22 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87k2u2eu67.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Tue, Jul 14, 2015 at 10:28 PM, Marko Rauhamaa wrote: >>> I would rather optimize by default and disable optimizations with >>> --debug or equivalent. >> >> That assumes that it's simply an optimization. This is a distinct >> semantic change. > > No, tail call optimization doesn't change the behavior of the program, > for the worse anyway. It does, because you lose traceback records. That's pretty significant when you come to try to debug something. ChrisA From antoon.pardon at rece.vub.ac.be Tue Jul 14 10:02:10 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Tue, 14 Jul 2015 16:02:10 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> Message-ID: <55A51662.4090007@rece.vub.ac.be> On 07/14/2015 03:43 PM, Chris Angelico wrote: > On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> On Tue, Jul 14, 2015 at 10:28 PM, Marko Rauhamaa wrote: >>>> I would rather optimize by default and disable optimizations with >>>> --debug or equivalent. >>> That assumes that it's simply an optimization. This is a distinct >>> semantic change. >> No, tail call optimization doesn't change the behavior of the program, >> for the worse anyway. > It does, because you lose traceback records. That's pretty significant > when you come to try to debug something. I doubt it would be really significant. Not compared to writing it iteratively. When you write it iteratively, you don't get to keep a traceback record per time you go throught the loop. So the traceback records you loose in tale call elimination would be the traceback records you wouldn't have anyway in the iterative version. So how would this be significant? From invalid at invalid.invalid Tue Jul 14 10:03:43 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 14 Jul 2015 14:03:43 +0000 (UTC) Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <55a48017$0$1673$c3e8da3$5496439d@news.astraweb.com> <55A4B9C1.4000009@rece.vub.ac.be> Message-ID: On 2015-07-14, Ian Kelly wrote: > And yet, Python somehow manages to gain new features with each release. > > The reason why most proposals get rejected is because most proposals > are bad. If every idea that came along just got accepted, we'd have a > disastrous hodge-podge of a language. And PHP already has that niche nailed down. -- Grant Edwards grant.b.edwards Yow! World War III? at No thanks! gmail.com From invalid at invalid.invalid Tue Jul 14 10:06:10 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 14 Jul 2015 14:06:10 +0000 (UTC) Subject: beginners choice: wx or tk? References: Message-ID: On 2015-07-14, Michael Torrie wrote: > On 07/13/2015 08:42 AM, Grant Edwards wrote: >> If it didn't have to run on Windows, I'd pick pygtk over wx. I've >> never tried qt. > > PyQt is very nice to work with. In some respects it's not as Pythonic > as PyGTK. It feels a lot like transliterated C++ code, which it is. > But it's a powerful toolkit and looks great on all supported platforms. > If the licensing terms of PyQt are not to your liking, PySide is fairly > close to PyQt (a few quirks that can be worked around), though I'm not > sure how much love it's receiving lately. Like wx, or Gtk, you would > have to ship some extra dlls with your project for Windows and OS X. Why would you have to ship "extra" libraries for Windows? Extra compared to what? When I compared bundled apps for Windows using wx and Tk, you had to ship more libraries using Tk than you did with wx. Maybe that's changed... -- Grant Edwards grant.b.edwards Yow! On the road, ZIPPY at is a pinhead without a gmail.com purpose, but never without a POINT. From rosuav at gmail.com Tue Jul 14 10:07:18 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 00:07:18 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A51662.4090007@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> Message-ID: On Wed, Jul 15, 2015 at 12:02 AM, Antoon Pardon wrote: > On 07/14/2015 03:43 PM, Chris Angelico wrote: >> On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa wrote: >>> Chris Angelico : >>> >>>> On Tue, Jul 14, 2015 at 10:28 PM, Marko Rauhamaa wrote: >>>>> I would rather optimize by default and disable optimizations with >>>>> --debug or equivalent. >>>> That assumes that it's simply an optimization. This is a distinct >>>> semantic change. >>> No, tail call optimization doesn't change the behavior of the program, >>> for the worse anyway. >> It does, because you lose traceback records. That's pretty significant >> when you come to try to debug something. > > I doubt it would be really significant. Not compared to writing it iteratively. > When you write it iteratively, you don't get to keep a traceback record per time > you go throught the loop. So the traceback records you loose in tale call elimination > would be the traceback records you wouldn't have anyway in the iterative version. > > So how would this be significant? You're proposing making _every_ instance of "return func(...)" into this kind of thing. That's not always recursion, and it's certainly not always clear what called what to get you there. ChrisA From torriem at gmail.com Tue Jul 14 11:21:57 2015 From: torriem at gmail.com (Michael Torrie) Date: Tue, 14 Jul 2015 09:21:57 -0600 Subject: beginners choice: wx or tk? In-Reply-To: References: Message-ID: <55A52915.8020909@gmail.com> On 07/14/2015 08:06 AM, Grant Edwards wrote: > On 2015-07-14, Michael Torrie wrote: >> On 07/13/2015 08:42 AM, Grant Edwards wrote: >>> If it didn't have to run on Windows, I'd pick pygtk over wx. I've >>> never tried qt. >> >> PyQt is very nice to work with. In some respects it's not as Pythonic >> as PyGTK. It feels a lot like transliterated C++ code, which it is. >> But it's a powerful toolkit and looks great on all supported platforms. >> If the licensing terms of PyQt are not to your liking, PySide is fairly >> close to PyQt (a few quirks that can be worked around), though I'm not >> sure how much love it's receiving lately. Like wx, or Gtk, you would >> have to ship some extra dlls with your project for Windows and OS X. > > Why would you have to ship "extra" libraries for Windows? Extra > compared to what? When I compared bundled apps for Windows using wx > and Tk, you had to ship more libraries using Tk than you did with wx. > Maybe that's changed... You make a good point. Although Tk is considered part of the standard Python library (though optional), Tk not only requires some dlls, it also embeds the tcl language interpreter as well. So by some measures, Tk in Python is pretty heavy, though I have no idea what the size it would add to an application bundle actually is. I've always thought it was a bit crazy how when you use Tk, you're actually using the Tcl language as well, even though you're driving it all from Python. I believe there were attempts to separate Tk from Tcl, and allow Perl/Tk to replace all the Tcl code with Perl code. Qt weighs in at between 5 and 15 MB of dlls, depending on how much of it you are using, and 32 or 64-bit. Gtk weighs in at about 10-15 MB also, and that's over a lot more little files and directories for things like image loaders. From breamoreboy at yahoo.co.uk Tue Jul 14 11:43:46 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 14 Jul 2015 16:43:46 +0100 Subject: beginners choice: wx or tk? In-Reply-To: <55A52915.8020909@gmail.com> References: <55A52915.8020909@gmail.com> Message-ID: On 14/07/2015 16:21, Michael Torrie wrote: > On 07/14/2015 08:06 AM, Grant Edwards wrote: >> On 2015-07-14, Michael Torrie wrote: >>> On 07/13/2015 08:42 AM, Grant Edwards wrote: >>>> If it didn't have to run on Windows, I'd pick pygtk over wx. I've >>>> never tried qt. >>> >>> PyQt is very nice to work with. In some respects it's not as Pythonic >>> as PyGTK. It feels a lot like transliterated C++ code, which it is. >>> But it's a powerful toolkit and looks great on all supported platforms. >>> If the licensing terms of PyQt are not to your liking, PySide is fairly >>> close to PyQt (a few quirks that can be worked around), though I'm not >>> sure how much love it's receiving lately. Like wx, or Gtk, you would >>> have to ship some extra dlls with your project for Windows and OS X. >> >> Why would you have to ship "extra" libraries for Windows? Extra >> compared to what? When I compared bundled apps for Windows using wx >> and Tk, you had to ship more libraries using Tk than you did with wx. >> Maybe that's changed... > > You make a good point. Although Tk is considered part of the standard > Python library (though optional), Tk not only requires some dlls, it > also embeds the tcl language interpreter as well. So by some measures, > Tk in Python is pretty heavy, though I have no idea what the size it > would add to an application bundle actually is. I've always thought it > was a bit crazy how when you use Tk, you're actually using the Tcl > language as well, even though you're driving it all from Python. I > believe there were attempts to separate Tk from Tcl, and allow Perl/Tk > to replace all the Tcl code with Perl code. > Surely if Tk is optional then IDLE is also optional, as IDLE depends on Tk? But I thought that IDLE was always supplied with Python, so am I missing something, or am I simply plain wrong, or what? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From bugshideout at gmail.com Tue Jul 14 12:28:57 2015 From: bugshideout at gmail.com (Marcos) Date: Tue, 14 Jul 2015 18:28:57 +0200 Subject: Improve usage of Python 3 Message-ID: <55A538C9.5050509@gmail.com> Hi! Just like many, I want the projects in which I work on to move to Python 3. And incredibly, there are a few users on the same project who refuse to use python 3 simply because of the print statement. That has probably already been discussed, but since I actually couldn't find anything relevant about, I decided to ask here anyway. What are the changes of something like from __past__ import print_statement or to make both print and print() work on Python 3 ? Sorry for the dumb question, but although it's not a very pure solution, it might be one that would be very well accepted. Some reference: http://stackoverflow.com/questions/20250130/from-past-import-print-statement https://news.ycombinator.com/item?id=6990481 https://news.ycombinator.com/item?id=6987309 https://news.ycombinator.com/item?id=6985792 http://code.activestate.com/lists/python-dev/101111/ http://code.activestate.com/lists/python-dev/101115/ Thanks Marcos From steve at pearwood.info Tue Jul 14 12:53:29 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 15 Jul 2015 02:53:29 +1000 Subject: beginners choice: wx or tk? References: <55A52915.8020909@gmail.com> Message-ID: <55a53e89$0$1642$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Jul 2015 01:43 am, Mark Lawrence wrote: > Surely if Tk is optional then IDLE is also optional, as IDLE depends on > Tk? But I thought that IDLE was always supplied with Python, so am I > missing something, or am I simply plain wrong, or what? If you try to run IDLE on a system that doesn't have Tk/Tcl installed, you get an exception and IDLE won't run. -- Steven From marko at pacujo.net Tue Jul 14 13:27:25 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 20:27:25 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> Message-ID: <87d1zuejk2.fsf@elektro.pacujo.net> Ian Kelly : > On Tue, Jul 14, 2015 at 2:33 AM, Marko Rauhamaa wrote: >> The programmer shouldn't be controlling tail call optimizations. > > The programmer controls it regardless. > > return foo() # TCO > > result = foo() # No TCO > return result # No TCO Not necessarily. Compile this function with gcc ("gcc -S -O2 atoi.c"): ======================================================================== int atoi(const char *str, int n) { if (str && *str) n = atoi(str + 1, n * 10 + *str - '0'); return n; } ======================================================================== (Example modified from .) You'll see that the generated code is tail-call-optimized. Marko From invalid at invalid.invalid Tue Jul 14 13:28:06 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 14 Jul 2015 17:28:06 +0000 (UTC) Subject: beginners choice: wx or tk? References: <55A52915.8020909@gmail.com> Message-ID: On 2015-07-14, Mark Lawrence wrote: > On 14/07/2015 16:21, Michael Torrie wrote: >>> Why would you have to ship "extra" libraries for Windows? Extra >>> compared to what? When I compared bundled apps for Windows using wx >>> and Tk, you had to ship more libraries using Tk than you did with wx. >>> Maybe that's changed... >> >> You make a good point. Although Tk is considered part of the standard >> Python library (though optional), Tk not only requires some dlls, it >> also embeds the tcl language interpreter as well. So by some measures, >> Tk in Python is pretty heavy, though I have no idea what the size it >> would add to an application bundle actually is. I've always thought it >> was a bit crazy how when you use Tk, you're actually using the Tcl >> language as well, even though you're driving it all from Python. I >> believe there were attempts to separate Tk from Tcl, and allow Perl/Tk >> to replace all the Tcl code with Perl code. > > Surely if Tk is optional It is. > then IDLE is also optional, It is. > as IDLE depends on Tk? But I thought that IDLE was always supplied > with Python, That depends on who supplied the Python. Most/all of the ready-made Windows builds include Tk, but there's no reason you can't build it without Tk not install IDLE. But, you can't assume that all Windows machines have _any_ Python build installed. > so am I missing something, or am I simply plain wrong, or what? My point is that on Windows, _Python_ is optional. If you want to ship a stand-alone .exe file, then you've got to ship both Python andT Tcl/Tk or ship both Python and wx. In my experience (which was a couple years ago), Windows wx libs were smaller than Windows Tcl+Tk libs. wx on Windows uses native widgets. Tcl/Tk doesn't: it includes not only the Tcl language implementation, it also includes low-level pixel-twiddling implementations of all the widgets. Comparing the size of Tcl+Tk and wx/Gtk doesn't really make sense either since we're talking about MS Windows targets. Gtk isn't involved. wxWindows on MS Windows runs on top of native widgets, not on top of Gtk. -- Grant Edwards grant.b.edwards Yow! VICARIOUSLY experience at some reason to LIVE!! gmail.com From marko at pacujo.net Tue Jul 14 13:29:23 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 20:29:23 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> Message-ID: <874ml6ejgs.fsf@elektro.pacujo.net> Chris Angelico : > On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa wrote: >> No, tail call optimization doesn't change the behavior of the >> program, for the worse anyway. > > It does, because you lose traceback records. That's pretty significant > when you come to try to debug something. Doesn't count. Optimization can do weird things to code and make debugging challenging. That's why you usually tell the compiler not to optimize the debug builds. Marko From marko at pacujo.net Tue Jul 14 13:31:23 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 20:31:23 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> Message-ID: <87zj2yd4t0.fsf@elektro.pacujo.net> Chris Angelico : > You're proposing making _every_ instance of "return func(...)" into > this kind of thing. Yes. > That's not always recursion, Correct. > and it's certainly not always clear what called what to get you there. Correct. Marko From steve at pearwood.info Tue Jul 14 13:34:16 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 15 Jul 2015 03:34:16 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> Message-ID: <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> On Tue, 14 Jul 2015 06:33 pm, Marko Rauhamaa wrote: > Ian Kelly : > >> On Mon, Jul 13, 2015 at 11:57 PM, Marko Rauhamaa >> wrote: >>> How about "return"? >> >> I think you miss my point entirely. "return" doesn't mean tail-call >> optimize; > > Why not? Because then you lose most of your debugging information when an exception occurs and a stack trace is printed. >> it just means to return the result. > > Same difference. If "return" was the same as "return and TCO", we wouldn't be having this discussion, because Python would have had TCO for over 20 years. So the two must clearly be different. And I think that's the solution. If we had two key words, let's say "return" and "treturn" ("tail-return"), where treturn performed TCO when possible, then the programmer could TCO some functions and not others, according to whether they feared bugs in the function more or less than hitting the recursion limit. That's better than a global setting or switch, and better than a TCO decorator, since it would even allow you to TCO some paths through a function but not others. I'm undecided about what should happen if you use treturn in a non-tail call situation. Should it simply fall back to regular return? Or should it raise an exception? (Preferably at compile time, if not possible, at runtime.) The downside is that this would put responsibility on the programmer to decide whether to TCO or not. Well, potential downside. Using a TCO decorator or switch to enable it also puts responsibility on the programmer, but that's usually considered a good thing. >> This is what led to the confusion responsible for the bug that Chris >> pointed out in the first place. With a keyword that explicitly means >> "perform tail-call optimization *and* return", > > That could well be the explicit definition of the "return" statement in > Python without changing the behavior of any working Python program > today. Really? If it doesn't change the behaviour, why bother making the change? It would change the behaviour of code. Code which currently breaks for sufficiently large data may no longer break. That's a plus. Code which currently generates tracebacks -- which may actually be *intended* behaviour and not a bug, e.g. in test suites -- will change their behaviour and be significantly less useful. That's a minus. >> the association of the keyword with the optimization is much clearer, >> and the programmer is much less likely to mistakenly omit it. > > The programmer shouldn't be controlling tail call optimizations. Why not? The programmer should control ALL optimizations that have a semantic effect. I think constant folding is okay[1], everything else is dubious and should be under the control of the programmer, not the compiler writer. I find it rather unnerving to think that I've written code to do something in a certain way, and somebody else (the compiler writer) decides to silently change that to something which may or may not have the same effect. The *intent* is that it should have the same effect, but in practice that's often not the case. Compiler optimizations often break floating point algorithms (e.g. inappropriately deciding that x + y - x must equal y) or introduce security bugs. Here's an example where an overzealous but standards-conforming optimization introduced a security bug: http://code.google.com/p/nativeclient/issues/detail?id=245 According to the compiler writer, the code before and after the optimization had precisely the same meaning. According to the developers. who should know because they wrote it, the optimized code was missing a rather large function: sanitising untrusted data. C, in my opinion, is the poster child for how a programming language should NOT be designed, and I don't want Python to go down the same path. John Regehr writes: "... there are compilers (like GCC) where integer overflow behaved a certain way for many years and then at some point the optimizer got just a little bit smarter and integer overflows suddenly and silently stopped working as expected. This is perfectly OK as far as the standard goes. While it may be unfriendly to developers, it would be considered a win by the compiler team because it will increase benchmark scores." http://blog.regehr.org/archives/213 So, no, I don't want the compiler making optimizations I can't control. [1] Only because Python gives us no standard way to control the floating point rounding mode. -- Steven From rosuav at gmail.com Tue Jul 14 13:43:08 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 03:43:08 +1000 Subject: beginners choice: wx or tk? In-Reply-To: References: <55A52915.8020909@gmail.com> Message-ID: On Wed, Jul 15, 2015 at 3:28 AM, Grant Edwards wrote: > Comparing the size of Tcl+Tk and wx/Gtk doesn't really make sense > either since we're talking about MS Windows targets. Gtk isn't > involved. wxWindows on MS Windows runs on top of native widgets, not > on top of Gtk. Well, let's look at three straight-forward options: 1) Python program uses tkinter 2) Python program uses wxPython 3) Python program uses PyGTK 4) (optionally) Python program uses PyGObject Then you package your script up with all of its dependencies - Python interpreter, GUI toolkit, and everything that they depend on - and see how big it is. That's the comparison that matters; everything else is implementation detail. I had been under the impression that tkinter + Tcl + Tk + etc etc etc was smaller than wxPython + wxWidgets + etc etc etc, but it's entirely possible I'm flat wrong on that. It doesn't matter how Python is normally shipped, it matters how big it's going to be when you make that single-executable package. But I still think it's better to *not* do that, because you bind your deps to your code release cycle. If you make this kind of package, most people won't know how to unwrap it and get the Python scripts out of it, so the only thing they can do is upgrade to the latest release that you've made. So when Python 2.7.11 comes out, maybe with some crucial security patch that an end user needs, s/he has to wait for you to make a new package that incorporates the latest Python. If you ship just the .py files, you're responsible for your own code and nothing else. ChrisA From marko at pacujo.net Tue Jul 14 13:43:45 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 20:43:45 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87vbdmd48e.fsf@elektro.pacujo.net> Steven D'Aprano : > C, in my opinion, is the poster child for how a programming language > should NOT be designed, and I don't want Python to go down the same > path. John Regehr writes: > > "... there are compilers (like GCC) where integer overflow behaved a > certain way for many years and then at some point the optimizer got > just a little bit smarter and integer overflows suddenly and silently > stopped working as expected. This is perfectly OK as far as the > standard goes. While it may be unfriendly to developers, it would be > considered a win by the compiler team because it will increase > benchmark scores." The problem there is in the C standard, not the compiler that complies with the standard. I don't like the way integer overflows are explicitly undefined in modern C. Similarly, I don't like the way tail call behavior is undefined in Python. Neither blemish gives me much trouble in practice. Marko From steve at pearwood.info Tue Jul 14 13:48:32 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 15 Jul 2015 03:48:32 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <874ml6ejgs.fsf@elektro.pacujo.net> Message-ID: <55a54b6f$0$1660$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Jul 2015 03:29 am, Marko Rauhamaa wrote: > Chris Angelico : > >> On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa >> wrote: >>> No, tail call optimization doesn't change the behavior of the >>> program, for the worse anyway. >> >> It does, because you lose traceback records. That's pretty significant >> when you come to try to debug something. > > Doesn't count. Says you. > Optimization can do weird things to code and make > debugging challenging. That's why you usually tell the compiler not to > optimize the debug builds. Here's a real scenario for you to chew on: testing. Test suites should be considered an application where the developer is the end user, and the point of the application is to verify that the code passes tests, and if they don't, present the user (i.e. the developer) with sufficient information to debug the problem (i.e. full stack traces). So how do you test your optimized code? If you turn optimizations on globally, you're testing something which may or may not have the same behaviour as the code you wrote. Compiler bugs exist, so it is more important than ever to ensure that the post-optimization code passes the test suite. But if it fails, you no longer get the stack traces you need to debug the problem. But if you turn optimizations off globally, you're not testing the optimized code any longer. -- Steven From rosuav at gmail.com Tue Jul 14 13:52:58 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 03:52:58 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87vbdmd48e.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> <87vbdmd48e.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 15, 2015 at 3:43 AM, Marko Rauhamaa wrote: > I don't like the way integer overflows are explicitly undefined in > modern C. > > Similarly, I don't like the way tail call behavior is undefined in > Python. Where in the Python spec is it stated that tail call behaviour is undefined? The behaviour of the 'return' statement is well defined: it evaluates its expression (or None), *then* removes the top of the call stack and passes control back to the caller: https://docs.python.org/3/reference/simple_stmts.html#the-return-statement This implies that during the evaluation of its expression, the current function's call stack entry is still present. Tail call behaviour is therefore well defined: it is identical to any other expression evaluation, and then the final result is passed back to the caller. ChrisA From no.email at nospam.invalid Tue Jul 14 13:54:20 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Tue, 14 Jul 2015 10:54:20 -0700 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87380q1v77.fsf@jester.gateway.sonic.net> Steven D'Aprano writes: > Here's an example where an overzealous but standards-conforming optimization > introduced a security bug: > http://code.google.com/p/nativeclient/issues/detail?id=245 In that particular example, the refactored code simply looks wrong. From steve at pearwood.info Tue Jul 14 14:06:42 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 15 Jul 2015 04:06:42 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> <87vbdmd48e.fsf@elektro.pacujo.net> Message-ID: <55a54fb2$0$1646$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Jul 2015 03:43 am, Marko Rauhamaa wrote: > The problem there is in the C standard, not the compiler that complies > with the standard. > > I don't like the way integer overflows are explicitly undefined in > modern C. > > Similarly, I don't like the way tail call behavior is undefined in > Python. Tail call behaviour is not undefined in Python. There is a strong convention (followed by all implementations I know of) to follow the reference implementation's (CPython) behaviour, which is not to optimize tail calls. But even if an implementation chooses to not follow that, it's not *undefined behaviour*. It's just implementation-dependent behaviour. No Python compiler is permitted to format your hard drive because you perform a tail call. > Neither blemish gives me much trouble in practice. Given how even the best, cleverest, and most security conscious C programmers get repeatedly bitten by C undefined behaviour, I'm confident that if you've written any non-trivial C code, it almost certainly has bugs because of undefined behaviour, you've just never noticed them yet. Perhaps the specific version of the compiler you use doesn't optimize that case, or you've never tried it with data that exposes the introduced bugs. "Making the landmine a much much worse place to be is the fact that there is no good way to determine whether a large scale application is free of undefined behavior, and thus not susceptible to breaking in the future. There are many useful tools that can help find some of the bugs, but nothing that gives full confidence that your code won't break in the future." http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html So, if you make it a habit to religiously compile your C applications with all warnings turned on, and you actually read *and fix* them all, AND you scan the applications with Valgrind, the Clang static analyser, and whatever other tools you can find, then you *might* have good reason to be reasonably confident that your code is *mostly* free of C undefined behaviour bugs. -- Steven From invalid at invalid.invalid Tue Jul 14 14:28:45 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 14 Jul 2015 18:28:45 +0000 (UTC) Subject: beginners choice: wx or tk? References: <55A52915.8020909@gmail.com> Message-ID: On 2015-07-14, Chris Angelico wrote: > On Wed, Jul 15, 2015 at 3:28 AM, Grant Edwards wrote: >> Comparing the size of Tcl+Tk and wx/Gtk doesn't really make sense >> either since we're talking about MS Windows targets. Gtk isn't >> involved. wxWindows on MS Windows runs on top of native widgets, not >> on top of Gtk. > > Well, let's look at three straight-forward options: > > 1) Python program uses tkinter > 2) Python program uses wxPython > 3) Python program uses PyGTK > 4) (optionally) Python program uses PyGObject > > Then you package your script up with all of its dependencies - Python > interpreter, GUI toolkit, and everything that they depend on - and see > how big it is. That's the comparison that matters; everything else is > implementation detail. > > I had been under the impression that tkinter + Tcl + Tk + etc etc etc > was smaller than wxPython + wxWidgets + etc etc etc, but it's entirely > possible I'm flat wrong on that. The last time I did exactly that comparison, the tk option was larger. That was 2-3 years ago, and it's quite possible the py2exe configuration I was using for the tk option could have been optimized more to get rid of libraries that py2exe thought were needed but were in fact not needed. Once the download gets below about 25MB, nobody seems to care about the size. > It doesn't matter how Python is normally shipped, it matters how big > it's going to be when you make that single-executable package. Right. And in practice, I find that doesn't actually matter either. Python+ is small compared to a lot of the things people are used to downloading. > But I still think it's better to *not* do that, because you bind your > deps to your code release cycle. If you make this kind of package, > most people won't know how to unwrap it and get the Python scripts out > of it, so the only thing they can do is upgrade to the latest release > that you've made. So when Python 2.7.11 comes out, maybe with some > crucial security patch that an end user needs, s/he has to wait for > you to make a new package that incorporates the latest Python. If you > ship just the .py files, you're responsible for your own code and > nothing else. Maybe your Windows audience is different than mine. Mine absolutely will not tolerate anything other than a single myapp-setup.exe or myapp.msi file. They will not can not install Python, update Python, or update the Python scripts independently of the exe/msi single-blob. If you depend on an external Python installation or make a bundled one visible to the user, you're just digging yourself a hole. They'll screw up the external Python installation somehow or they'll uninstall a bundled but exposed Python installation and then call in complaining the app doesn't work. -- Grant Edwards grant.b.edwards Yow! Jesuit priests are at DATING CAREER DIPLOMATS!! gmail.com From marko at pacujo.net Tue Jul 14 14:37:02 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 21:37:02 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> <87vbdmd48e.fsf@elektro.pacujo.net> <55a54fb2$0$1646$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87r3oad1rl.fsf@elektro.pacujo.net> Steven D'Aprano : > Tail call behaviour is not undefined in Python. There is a strong > convention (followed by all implementations I know of) to follow the > reference implementation's (CPython) behaviour, which is not to > optimize tail calls. But even if an implementation chooses to not > follow that, it's not *undefined behaviour*. It's just > implementation-dependent behaviour. But in Scheme, tail call elimination is mandatory and thus can be relied on. Unless that promise is made, you can't write code that depends on it. Marko From rosuav at gmail.com Tue Jul 14 14:55:43 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 04:55:43 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87r3oad1rl.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> <87vbdmd48e.fsf@elektro.pacujo.net> <55a54fb2$0$1646$c3e8da3$5496439d@news.astraweb.com> <87r3oad1rl.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 15, 2015 at 4:37 AM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Tail call behaviour is not undefined in Python. There is a strong >> convention (followed by all implementations I know of) to follow the >> reference implementation's (CPython) behaviour, which is not to >> optimize tail calls. But even if an implementation chooses to not >> follow that, it's not *undefined behaviour*. It's just >> implementation-dependent behaviour. > > But in Scheme, tail call elimination is mandatory and thus can be relied > on. Unless that promise is made, you can't write code that depends on I think I'm beginning to understand. Tail call elimination is necessary to cope with a system of programming that has deliberately excluded certain other options (eg mutables, in pure functional languages), but is not as important in a more fully-featured language. Constant folding would be the same way; it's not absolutely critical, and if Python doesn't support it for some particular expression then it's not going to kill you, but in SPL [1] it would be a vital efficiency improvement. Scheme needs TCE because of the way you have to write code for Scheme to be even capable of executing it; Python doesn't, because you can write your code to not need TCE. [1] https://en.wikipedia.org/wiki/Shakespeare_(programming_language)#Constants_and_Assignment_of_Values ChrisA From tjreedy at udel.edu Tue Jul 14 15:09:52 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 14 Jul 2015 15:09:52 -0400 Subject: python 3.5.0b3 (32-bit) exe setup In-Reply-To: References: Message-ID: On 7/14/2015 7:56 AM, Chris Angelico wrote: > On Tue, Jul 14, 2015 at 8:15 AM, Colin Dick wrote: >> when I run the downloaded version of this pgm "python-3.5.0b3.exe" >> >> there are no visible selection box's except "cancel" on the >> first screen shown >> >> see the attached screen dump >> >> its running on a win xp sp3 as a vmware vm >> > > As of Python 3.5, Windows XP is no longer a supported platform. It is unsupported by Microsoft, and hence by CPython. > Since there has also been a change of compiler for 3.5, to the new 2015 Microsoft compiler, which I am very sure does not support XP, as per above. People running XP should install the latest 3.4. > it wouldn't surprise > me if there are odd problems where something just doesn't work. Can > you reproduce the problem on Win 7 or newer? If it's just an XP > problem, I suspect the devs won't be very much interested in fixing it > (although if _you_ fix it, they may be willing to incorporate the > change, assuming it doesn't break anything else). I think not. -- Terry Jan Reedy From marko at pacujo.net Tue Jul 14 15:12:01 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 14 Jul 2015 22:12:01 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> <87vbdmd48e.fsf@elektro.pacujo.net> <55a54fb2$0$1646$c3e8da3$5496439d@news.astraweb.com> <87r3oad1rl.fsf@elektro.pacujo.net> Message-ID: <87mvyyd05a.fsf@elektro.pacujo.net> Chris Angelico : > Tail call elimination is necessary to cope with a system of > programming that has deliberately excluded certain other options (eg > mutables, in pure functional languages), Tail call elimination is necessary for the functional programming style. While Scheme strongly promotes it, functional programming style crops up in virtually all programming languages nowadays. > but is not as important in a more fully-featured language. It is not all that important in Python for idiomatic reasons, not for some "full-featuredness". > Scheme needs TCE because of the way you have to write code for Scheme > to be even capable of executing it; Python doesn't, because you can > write your code to not need TCE. You can write Sheme perfectly procedurally, but why would you do that when you have Python to satisfy your procedural urges? Marko From rosuav at gmail.com Tue Jul 14 15:17:08 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 05:17:08 +1000 Subject: python 3.5.0b3 (32-bit) exe setup In-Reply-To: References: Message-ID: On Wed, Jul 15, 2015 at 5:09 AM, Terry Reedy wrote: >> it wouldn't surprise >> me if there are odd problems where something just doesn't work. Can >> you reproduce the problem on Win 7 or newer? If it's just an XP >> problem, I suspect the devs won't be very much interested in fixing it >> (although if _you_ fix it, they may be willing to incorporate the >> change, assuming it doesn't break anything else). > > > I think not. Yeah, I wasn't particularly sanguine [1] on that last point. ChrisA [1] Sanguine. Hopeful. Point of interest, it also means bloody, which is a word a lot of British people use in describing Win XP. From tjreedy at udel.edu Tue Jul 14 15:27:34 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 14 Jul 2015 15:27:34 -0400 Subject: beginners choice: wx or tk? In-Reply-To: References: <55A52915.8020909@gmail.com> Message-ID: On 7/14/2015 11:43 AM, Mark Lawrence wrote: > On 14/07/2015 16:21, Michael Torrie wrote: >> You make a good point. Although Tk is considered part of the standard >> Python library (though optional), Python-coded tkinter depends on C-coded _tkinter and both are in the stdlib, which means the code is in the CPython hg repository. tcl/tk is an external dependency of _tkinter and is not is the stdlib. There are a few other stdlib modules with such external dependencies. The Windows installers include the external dependencies. AFAIK, Linux distributions do not, but expect the dependencies to be already present or separately downloaded. I believe the situation is mixed on Mac. Ned Deily is working on include the latest tcl/tk with the Mac installer, but this is apparently not trivial. > Surely if Tk is optional then IDLE is also optional, as IDLE depends on > Tk? Idle is in the stdlib and depends on tkinter (and maybe _tkinter), so it indirectly depends on tk. Turtle and turtledemo and some tools/scripts also depend on tkinter. > But I thought that IDLE was always supplied with Python, It is unless a distributor removes it, perhaps to bundle with tcl/tk, _tkinter, tkinter, turtle, and turtledemo. Importing tkinter imports _tkinter, which fails if it cannot find tcl/tk. -- Terry Jan Reedy From breamoreboy at yahoo.co.uk Tue Jul 14 19:40:14 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Jul 2015 00:40:14 +0100 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: Message-ID: On 13/07/2015 23:46, Terry Reedy wrote: > > Optimizing specific tail calls is tricker. For one thing, calls to a > recursion-replacement function, such as recur, add a stack frame that > must also be popped. A CPython bytecode manimpuation solution was given > years ago as a recipe on the ActiveState Python Cookbook site. MacroPy > at pypi.python.org "provides a mechanism for user-defined functions > (macros) to perform transformations on the abstract syntax tree(AST) of > Python code at module import time". Among many included examples, it > has a tco decorator. > A direct link https://github.com/lihaoyi/macropy#tail-call-optimization for anybody who is interested. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Tue Jul 14 20:14:33 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Jul 2015 01:14:33 +0100 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: Message-ID: On 15/07/2015 00:40, Mark Lawrence wrote: > On 13/07/2015 23:46, Terry Reedy wrote: >> >> Optimizing specific tail calls is tricker. For one thing, calls to a >> recursion-replacement function, such as recur, add a stack frame that >> must also be popped. A CPython bytecode manimpuation solution was given >> years ago as a recipe on the ActiveState Python Cookbook site. MacroPy >> at pypi.python.org "provides a mechanism for user-defined functions >> (macros) to perform transformations on the abstract syntax tree(AST) of >> Python code at module import time". Among many included examples, it >> has a tco decorator. >> > > A direct link https://github.com/lihaoyi/macropy#tail-call-optimization > for anybody who is interested. > And I've just stumbled across this https://github.com/baruchel/tco which was only put up two days ago. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From tjreedy at udel.edu Tue Jul 14 20:23:27 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 14 Jul 2015 20:23:27 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87fv4r1fre.fsf@jester.gateway.sonic.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> Message-ID: On 7/14/2015 1:15 AM, Paul Rubin wrote: > def quicksort(array, start, end): > midp = partition(array, start, end) > if midp <= (start+end)//2: > quicksort(array, start, midp) > quicksort(array, midp+1, end) > else: > quicksort(array, midp+1, end) > quicksort(array, start, midp) > > I assume you know how quicksort and its partition step work. The idea > is you partition the array around the pivot element (midp is the index > of that element), then recursively sort the two partitions, doing the > smaller partition as a recursive call and the larger one as a tail call, > so that you use O(log n) stack depth instead of potentially O(n). Thank you for the example. It I have ever seen how to minimize the max stack needed for first calls, I have forgotten. First some comment: 1. There is no terminal condition, so the above will loop forever. The body should start with 'if not terminal(start, end):' where terminal is the actual expression. I did not write it because it depends on whether 'end' is the highest index or one past it. 2. There are no tail calls (call followed by return), so a tail-call optimizer will not optimize this. A recur() function might be able to. 3. Mutation is anathema to functional programming, so a functional programmer would never write and version of this, at least not without holding his nose. The tail-like calls in each branch can be avoided with assignment and gobacks. In Python, we go-back with while loops. (IE, 'while' = 'label' + 'if' + 'goto'.) With minimal change to the above, we get (untested) def quicksort(array, start, end): while not terminal(start, end): midp = partition(array, start, end) if midp <= (start+end) // 2: quicksort(array, start, midp) start = midp+1 else: quicksort(array, midp+1, end) end = midp I can understand that someone might prefer to break the symmetry of the paired calls by wrapping the second with recur() (assuming that such a function is sensibly feasible on *all* implementations). In the other hand, I prefer the reduced-noise explicit assignment that highlights the one parameter that gets rebound. -- Terry Jan Reedy From trentonwesley10 at gmail.com Tue Jul 14 20:31:31 2015 From: trentonwesley10 at gmail.com (trentonwesley10 at gmail.com) Date: Tue, 14 Jul 2015 17:31:31 -0700 (PDT) Subject: Why pay DICE When TheGongzuo.com is !! FREE !! Message-ID: Greetings! You been Invited as a Beta User for TheGongzuo.com ( Absolutely Extended Trial). We bring to you TheGongzuo.com, Top notch highly talented IT (Information Technology / Software Industry) skilled Professional Candidates, where you can find more than a resume. ________________________________________ For a NO COST TRIAL all you have to do is: * Register & Post only 1 Active Job. * Start interacting with more 100,000 IT professionals and Innovators/Ideators. ________________________________________ Before you get started , there are few things you should know, 1. We are getting better :- We will be updating our site with new material daily basis and we welcome your feedback on newly added material. Please send us your feedback by using Feedback option on the site or send us an email @ support at thegongzuo.com. 2. We like Criticism :- As a fresh site, We are sure you can find lots to Criticize - remember , though we would prefer constructive criticism, so we can make site better. Please send us your valuable criticism by email @ support at thegongzuo.com. ________________________________________ Please make us a part of your distribution list, We will start sending resumes to you. If you do not wish to be a part of our mailing list just reply to us with unsubscribe from this list or else it will consider it as your consent to be part of our distribution list. ________________________________________ Thanks for trying TheGongzuo.com and please let us know , What you think ! Thanks, TheGongzuo.com Team ! Disclaimer: This message is sent in compliance with the new email bill section 301. Under Bill S.1618 TITLE III passed by the 105th US Congress, this message cannot be considered SPAM as long as we include the way to be removed, Paragraph (a)(c) of S.1618, further transmissions to you by the sender of this email will be stopped if you by send a response of "REMOVE" in the subject line of the email, we will remove you immediately from subscription. From tjreedy at udel.edu Tue Jul 14 20:41:06 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 14 Jul 2015 20:41:06 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A51662.4090007@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> Message-ID: On 7/14/2015 10:02 AM, Antoon Pardon wrote: > On 07/14/2015 03:43 PM, Chris Angelico wrote: >> On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa wrote: >>> No, tail call optimization doesn't change the behavior of the program, >>> for the worse anyway. >> It does, because you lose traceback records. That's pretty significant >> when you come to try to debug something. > > I doubt it would be really significant. Not compared to writing it iteratively. > When you write it iteratively, you don't get to keep a traceback record per time > you go throught the loop. So the traceback records you loose in tale call elimination > would be the traceback records you wouldn't have anyway in the iterative version. To repeat: loosing tracebacks is probably fine when the function has a single *recursive* tail call. This are precise the cases when it is simple and perhaps preferable to use a loop. But *recursive* tail calls are only a small fraction of all tail calls. So most of the time, the loss *would* be significant. Consider In moda: def f(a): return modb.g(a-3) In modb: def g(b): return modc.h(b*(b-1)) In modc: def h(c): return 1.0/c from moda import f ... (500 lines later) f(3) and your traceback has been reduced to In modc: line 1 return 1.0/c ZeroDivisionError: ... ??? -- Terry Jan Reedy From tjreedy at udel.edu Tue Jul 14 21:01:21 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 14 Jul 2015 21:01:21 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> <87vbdmd48e.fsf@elektro.pacujo.net> Message-ID: On 7/14/2015 1:52 PM, Chris Angelico wrote: > On Wed, Jul 15, 2015 at 3:43 AM, Marko Rauhamaa wrote: >> I don't like the way integer overflows are explicitly undefined in >> modern C. >> >> Similarly, I don't like the way tail call behavior is undefined in >> Python. > > Where in the Python spec is it stated that tail call behaviour is > undefined? The behaviour of the 'return' statement is well defined: it > evaluates its expression (or None), *then* removes the top of the call > stack and passes control back to the caller: > > https://docs.python.org/3/reference/simple_stmts.html#the-return-statement I do not see anything there explicitly about call stacks. > This implies that during the evaluation of its expression, the current > function's call stack entry is still present. Tail call behaviour is > therefore well defined: it is identical to any other expression > evaluation, and then the final result is passed back to the caller. In the blog post http://neopythonic.blogspot.co.uk/2009/04/tail-recursion-elimination.html that everyone discussing this issue should read, Guido said that if a tail call is not within a try statement, tco would be fine except for the implementation issue of helpful tracebacks, which he cares greatly about. However, as both he and the linked doc say, a tail call within a try: statement is not a tail call, in that more python code within the function may yet be executed. It is not hard to construct an example in which tco would mess up a traceback message that is displayed. -- Terry Jan Reedy From tjreedy at udel.edu Tue Jul 14 21:36:13 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 14 Jul 2015 21:36:13 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> <87vbdmd48e.fsf@elektro.pacujo.net> <55a54fb2$0$1646$c3e8da3$5496439d@news.astraweb.com> <87r3oad1rl.fsf@elektro.pacujo.net> Message-ID: > I think I'm beginning to understand. Tail call elimination is > necessary to cope with a system of programming that has deliberately > excluded certain other options (eg mutables, in pure functional > languages), Tail recursion is the functional way to write a while loop. To put is another way, a while loop is within stackframe recursion. Ditto for for loops, which are specialized while loops. Recursion, first (or car), rest (or cdr), and linked lists (non-mutational stacks with the top at the front) work together as a tightly coordinated system. (rest ll) is equivalent to ll[1:] except that rest does not mutate anything. When Python's ll.pop(0) (or ll.pop() removes and returns (first ll), it does mutate ll. Since ll becomes what was previously (rest ll), there is no need for a separate list.rest method. Python's next(it) is also does the job of both first + rest. As with pop(0), it removes the first item of it, mutates it so it represents the rest of the items in the collection it represents, and then returns the initial item. Again, there is no need for a separate rest(it) funciton. The fundamental computational idea in both systems, beneath the differing syntax and religious wars, is that we can process a collection by processing one item at a time. -- Terry Jan Reedy From hayesstw at telkomsa.net Tue Jul 14 22:47:51 2015 From: hayesstw at telkomsa.net (Steve Hayes) Date: Wed, 15 Jul 2015 04:47:51 +0200 Subject: Why pay DICE When TheGongzuo.com is !! FREE !! References: Message-ID: On Tue, 14 Jul 2015 17:31:31 -0700 (PDT), trentonwesley10 at gmail.com wrote: >Greetings! >You been Invited as a Beta User for TheGongzuo.com ( Absolutely Extended Trial). >We bring to you TheGongzuo.com, Top notch highly talented IT (Information Technology / Software Industry) skilled Professional Candidates, So what does it actually DO? I'm assuming that it's some kind of enhancement for Python, but why would anyone actually use it? -- Steve Hayes from Tshwane, South Africa Web: http://www.khanya.org.za/stevesig.htm Blog: http://khanya.wordpress.com E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk From rosuav at gmail.com Tue Jul 14 23:05:50 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 13:05:50 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <55a54818$0$1652$c3e8da3$5496439d@news.astraweb.com> <87vbdmd48e.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 15, 2015 at 11:01 AM, Terry Reedy wrote: > On 7/14/2015 1:52 PM, Chris Angelico wrote: >> >> On Wed, Jul 15, 2015 at 3:43 AM, Marko Rauhamaa wrote: >>> >>> I don't like the way integer overflows are explicitly undefined in >>> modern C. >>> >>> Similarly, I don't like the way tail call behavior is undefined in >>> Python. >> >> >> Where in the Python spec is it stated that tail call behaviour is >> undefined? The behaviour of the 'return' statement is well defined: it >> evaluates its expression (or None), *then* removes the top of the call >> stack and passes control back to the caller: >> >> https://docs.python.org/3/reference/simple_stmts.html#the-return-statement > > > I do not see anything there explicitly about call stacks. There isn't anything explicitly about call stacks, but it clearly states that the expression is evaluated, and *then* processing of the return statement occurs. Unlike C, Python doesn't have "undefined behaviour"; there are some things which are "implementation-defined", but that's a different concept. But the spec is reasonably clear by implication, in my opinion; if tail calls are allowed to remove stack entries, that definition will need to be edited. (That's not to say it can't be, of course. But it would be a change.) ChrisA From ian.g.kelly at gmail.com Tue Jul 14 23:14:37 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 14 Jul 2015 21:14:37 -0600 Subject: Why pay DICE When TheGongzuo.com is !! FREE !! In-Reply-To: References: Message-ID: On Tue, Jul 14, 2015 at 8:47 PM, Steve Hayes wrote: > On Tue, 14 Jul 2015 17:31:31 -0700 (PDT), trentonwesley10 at gmail.com > wrote: > >>Greetings! >>You been Invited as a Beta User for TheGongzuo.com ( Absolutely Extended Trial). >>We bring to you TheGongzuo.com, Top notch highly talented IT (Information Technology / Software Industry) skilled Professional Candidates, > > So what does it actually DO? > > I'm assuming that it's some kind of enhancement for Python, but why > would anyone actually use it? Dice is a tech recruiting website, so I assume that the advertised site is the same, which makes the OP's post spam. From greg.ewing at canterbury.ac.nz Wed Jul 15 01:52:21 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 15 Jul 2015 17:52:21 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87380rnrqt.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87380rnrqt.fsf@elektro.pacujo.net> Message-ID: Marko Rauhamaa wrote: > It might even be tail-call optimized by Python. Only you can't count on > it because the language spec doesn't guarantee it. The language spec might permit it, but the BDFL has explicitly expressed a dislike for the idea of implicit tail call removal, so it's unlikely to ever happen in CPython. -- Greg From uday3prakash at gmail.com Wed Jul 15 01:59:07 2015 From: uday3prakash at gmail.com (udhay prakash pethakamsetty) Date: Tue, 14 Jul 2015 22:59:07 -0700 (PDT) Subject: Can't install/uninstall Python In-Reply-To: References: Message-ID: On Tuesday, 14 July 2015 17:24:22 UTC+5:30, Chris Angelico wrote: > On Tue, Jul 14, 2015 at 7:20 AM, Thomas Via wrote: > > I'm trying to reinstall Python 2.7.9/2.7.10, but during the installation, it > > didn't let me, which gave me this: > > > > "There is a problem with this Windows Installer package. A program required > > for this install to complete could not be run. Contact your support > > personnel or package vendor." > > Hi! > > What version of Windows are you running? And what architecture (32-bit > or 64-bit)? Exactly what file did you download, and from where? The > more information you can provide, the easier it will be to figure out > what's going on. > > ChrisA Hi! You can uninstall the python directly through the control panel, normally. But, if the python was installed as part of any software package that you have installed in your system, then it requires that specific software to be uninstalled a prior its un-installation. Uday Prakash From chris at simplistix.co.uk Wed Jul 15 02:27:48 2015 From: chris at simplistix.co.uk (Chris Withers) Date: Wed, 15 Jul 2015 07:27:48 +0100 Subject: xlrd 0.9.4 released! Message-ID: <55A5FD64.90302@simplistix.co.uk> Hi All, I'm pleased to announce the release of xlrd 0.9.4: http://pypi.python.org/pypi/xlrd/0.9.4 This release includes the following changes: - Automated tests are now run on Python 3.4 - Use ElementTree.iter() if available, not deprecated getiterator() when parsing xlsx files. - Fix #106 : Exception Value: unorderable types: Name() < Name() - Create row generator expression with Sheet.get_rows() - Fix for forward slash file separator and lowercase names within xlsx internals. Thanks to the following for their contributions to this release: - Corey Farwell - Jonathan Kamens - Deepak N - Brandon R. Stoner - John McNamara If you find any problems, please ask about them on the python-excel at googlegroups.com list, or submit an issue on GitHub: https://github.com/python-excel/xlrd/issues Full details of all things Python and Excel related can be found here: http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From marko at pacujo.net Wed Jul 15 02:44:42 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 15 Jul 2015 09:44:42 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87380rnrqt.fsf@elektro.pacujo.net> Message-ID: <87615lncmd.fsf@elektro.pacujo.net> Gregory Ewing : > Marko Rauhamaa wrote: >> It might even be tail-call optimized by Python. Only you can't count >> on it because the language spec doesn't guarantee it. > > The language spec might permit it, but the BDFL has explicitly > expressed a dislike for the idea of implicit tail call removal, so > it's unlikely to ever happen in CPython. Permitting wouldn't be enough. The other problem for tail call elimination is the requirement that functions return None by default. Smooth tail call elimination would require that Python leave the default return value unspecified. Marko From rosuav at gmail.com Wed Jul 15 03:40:14 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 17:40:14 +1000 Subject: Improve usage of Python 3 In-Reply-To: <55A538C9.5050509@gmail.com> References: <55A538C9.5050509@gmail.com> Message-ID: On Wed, Jul 15, 2015 at 2:28 AM, Marcos wrote: > And incredibly, there are a few users on the same project who refuse to use > python 3 simply because of the print statement. Solution: Explain to them the massive benefits of the print function. It may be simpler to omit the parentheses in the case where you just want to print out a single string, but for pretty much everything else, the function is at least as good. # I can never remember the syntax for this, and # have to look it up every time. Can you put the # file reference at the end? Or only at the start? print >>sys.stderr, "Hello, world!" # Keyword-only argument, exactly the way every # other Python function operates print("Hello, world!", file=sys.stderr) # Separated by spaces print "Hello", "world", "!" # Separated by spaces print("Hello", "world", "!") # Separated by something other than space # Again, keyword-only args, nice and easy print("Hello", "world", "!", sep="*") # No newline at the end: magic print "Hello, world!", # Hard to explain the exact semantics of the # soft space and what happens if you mix # print and sys.stdout.write(), not to mention # sys.stderr.write() when they're both attached # to the same console # No newline at the end: no magic print("Hello, world!", end="") # Need to define a shim function to pass elsewhere def Print(x): print x walk(tree, Print) def print_with_star(x): print x, "*" walk(tree, print_with_star) # Can just use print directly, or use lambda walk(tree, print) walk(tree, lambda x: print(x, end="*\n")) The function is well worth it. Teach people the new way, don't try to warp the language around maintaining an old way of doing things. There's really no reason for console output to have magic syntax. ChrisA From rapzak at gmail.com Wed Jul 15 04:08:28 2015 From: rapzak at gmail.com (Kasper Jepsen) Date: Wed, 15 Jul 2015 01:08:28 -0700 (PDT) Subject: data visualization - graph Message-ID: <419f0b10-a32f-4f13-8a75-d8bf0df9e673@googlegroups.com> Hi, I am looking for a solution to graph charts from real time measurements on the web like: http://pvoutput.org/intraday.jsp?id=16919&sid=14707&gs=1&dxa=1&dt=20150715 I have some solar systems i like to save data into an sql database - and then i like to have some web service where i can select which data to see and compare and zoom in/ out etc. I like to do it in Python - but maybe some else also? Also i like as much as possible in some library / packages.. Any one who has experience? best regards /Kasper From antoon.pardon at rece.vub.ac.be Wed Jul 15 04:28:26 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Wed, 15 Jul 2015 10:28:26 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55a54b6f$0$1660$c3e8da3$5496439d@news.astraweb.com> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <874ml6ejgs.fsf@elektro.pacujo.net> <55a54b6f$0$1660$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55A619AA.8080607@rece.vub.ac.be> On 07/14/2015 07:48 PM, Steven D'Aprano wrote: > On Wed, 15 Jul 2015 03:29 am, Marko Rauhamaa wrote: > >> Chris Angelico : >> >>> On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa >>> wrote: >>>> No, tail call optimization doesn't change the behavior of the >>>> program, for the worse anyway. >>> It does, because you lose traceback records. That's pretty significant >>> when you come to try to debug something. >> Doesn't count. > Says you. > >> Optimization can do weird things to code and make >> debugging challenging. That's why you usually tell the compiler not to >> optimize the debug builds. > Here's a real scenario for you to chew on: testing. Test suites should be > considered an application where the developer is the end user, and the > point of the application is to verify that the code passes tests, and if > they don't, present the user (i.e. the developer) with sufficient > information to debug the problem (i.e. full stack traces). The stack traces in Test suites are generally pretty useless. If the code doesn't pass a test, the stack trace you get, is the one provoked by an assert like statement in the test code. At that moment the call to the code to be tested is already done. So the stack trace won't provide any information about the code just tested. > So how do you test your optimized code? > > If you turn optimizations on globally, you're testing something which may or > may not have the same behaviour as the code you wrote. Compiler bugs exist, > so it is more important than ever to ensure that the post-optimization code > passes the test suite. But if it fails, you no longer get the stack traces > you need to debug the problem. You don't need those stack traces to debug the problem. The only thing useful they generally contain is the line that failed. Traceback records of the moment some subcalculation in some subcall went wrong are not available. So TCO will not be a real burden here. -- Antoon Pardon From breamoreboy at yahoo.co.uk Wed Jul 15 04:33:10 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Jul 2015 09:33:10 +0100 Subject: data visualization - graph In-Reply-To: <419f0b10-a32f-4f13-8a75-d8bf0df9e673@googlegroups.com> References: <419f0b10-a32f-4f13-8a75-d8bf0df9e673@googlegroups.com> Message-ID: On 15/07/2015 09:08, Kasper Jepsen wrote: > Hi, > > I am looking for a solution to graph charts from real time measurements on the web like: > http://pvoutput.org/intraday.jsp?id=16919&sid=14707&gs=1&dxa=1&dt=20150715 > > I have some solar systems i like to save data into an sql database - and then i like to have some web service where i can select which data to see and compare and zoom in/ out etc. > > I like to do it in Python - but maybe some else also? > > Also i like as much as possible in some library / packages.. > > Any one who has experience? > > best regards > /Kasper > Please check the following out. http://ipython.org/notebook.html http://matplotlib.org/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From antoon.pardon at rece.vub.ac.be Wed Jul 15 05:10:03 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Wed, 15 Jul 2015 11:10:03 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> Message-ID: <55A6236B.1020001@rece.vub.ac.be> On 07/15/2015 02:41 AM, Terry Reedy wrote: > On 7/14/2015 10:02 AM, Antoon Pardon wrote: >> On 07/14/2015 03:43 PM, Chris Angelico wrote: >>> On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa >>> wrote: > >>>> No, tail call optimization doesn't change the behavior of the program, >>>> for the worse anyway. >>> It does, because you lose traceback records. That's pretty significant >>> when you come to try to debug something. >> >> I doubt it would be really significant. Not compared to writing it >> iteratively. >> When you write it iteratively, you don't get to keep a traceback >> record per time >> you go throught the loop. So the traceback records you loose in tale >> call elimination >> would be the traceback records you wouldn't have anyway in the >> iterative version. > > To repeat: loosing tracebacks is probably fine when the function has a > single *recursive* tail call. This are precise the cases when it is > simple and perhaps preferable to use a loop. But *recursive* tail > calls are only a small fraction of all tail calls. So most of the > time, the loss *would* be significant. Consider But it doesn't need to be all or nothing. How about the following possibility. When the runtime detects a serie of tail calls, it will keep the bottom three and the top three backtrace records of the serie. And when it needs to print a stacktrace it writes an indication that some tracebacks are missing. I think that would be a workable compromise between workable tail call recursion and usefull stacktraces. Now of course there are some other problems like what if the tail call is into a C-function. I don't think you want to drop a stack frame in those circumstances. So I guess implementing this and getting all corner cases right, will not be trivial and I understand if the core developers don't consider this a high priority. But one likes to dream sometimes. -- Antoon Pardon From greg.ewing at canterbury.ac.nz Wed Jul 15 05:13:00 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 15 Jul 2015 21:13:00 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: Chris Angelico wrote: > I'm still interested in the explicit "replace current stack frame with > this call" operation. Calling it "goto" seems wrong, as most languages > with goto restrict it to _within_ a function, This just suggests to me is that most language designers are not very imaginative. :-) A tail call *is* a goto. That's how you implement one in assembly language -- you write a jump instruction instead of a call instruction. The jump doesn't have to be to the same function. Also see: https://litrev.wordpress.com/2009/07/16/lambda-the-ultimate-goto/ -- Greg From antoon.pardon at rece.vub.ac.be Wed Jul 15 05:29:48 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Wed, 15 Jul 2015 11:29:48 +0200 Subject: A new module for performing tail-call elimination In-Reply-To: <55a3dcd9$0$3024$426a34cc@news.free.fr> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> Message-ID: <55A6280C.3090602@rece.vub.ac.be> On 07/13/2015 05:44 PM, Th. Baruchel wrote: > Hi, after having spent much time thinking about tail-call elimination > in Python (see for instance http://baruchel.github.io/blog/ ), I finally > decided to write a module for that. You may find it at: > > https://github.com/baruchel/tco > > Tail-call elimination is done for tail-recursion as well as for > continuation-passing style (cps) in a consistent syntax for both usages. > > Any tail-recursive function having the suitable format for being > embeddable in the Y combinator can be used here with no change at all > (with the main difference that tail-calls will be eliminated), but other > continuations can also be added Can you explain how you would do mutual recursive functions? Suppose I start with the following: def even(n): True if n == 0 else odd(n - 1) def odd(n): False if n == 0 else even(n - 1) How do I rewrite those with your module? -- Antoon Pardon From tjreedy at udel.edu Wed Jul 15 05:33:31 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 Jul 2015 05:33:31 -0400 Subject: Improve usage of Python 3 In-Reply-To: <55A538C9.5050509@gmail.com> References: <55A538C9.5050509@gmail.com> Message-ID: On 7/14/2015 12:28 PM, Marcos wrote: > Hi! > > Just like many, I want the projects in which I work on to move to Python 3. > > And incredibly, there are a few users on the same project who refuse to > use python 3 simply because of the print statement. > > That has probably already been discussed, but since I actually couldn't > find anything relevant about, I decided to ask here anyway. > > What are the changes of something like > > from __past__ import print_statement 0 > or to make both > > print This already works, like any other name >>> print To add to what Chris said, this means that print can be rebound just like any other name. For example: >>> import builtins >>> builtins.print >>> def print(*args, **kwargs): kwargs['sep'] = '|' builtins.print(*args, **kwargs) >>> print(1,2,3) 1|2|3 > and > > print() > > work on Python 3 ? -- Terry Jan Reedy From marko at pacujo.net Wed Jul 15 05:55:18 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 15 Jul 2015 12:55:18 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: <87zj2xlp89.fsf@elektro.pacujo.net> Gregory Ewing : > A tail call *is* a goto. That's how you implement one in assembly > language -- you write a jump instruction instead of a call > instruction. The jump doesn't have to be to the same function. In functional programming languages you might not even have a call stack. Instead, you specify the program execution through transformations. When you evaluate a program, you repeatedly convert the program text into new programs until no more transformations apply and the execution halts with the result of the computation. Marko From mal at europython.eu Wed Jul 15 06:06:45 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Wed, 15 Jul 2015 12:06:45 +0200 Subject: EuroPython 2015: Guggenheim and Fine Arts Museum Message-ID: <55A630B5.3000102@europython.eu> EuroPython is not the only attraction in Bilbao to attend in July. The city also hosts the famous *Guggenheim Museum*, featuring modern art in an amazing building designed by Frank O. Gehry. See below for a special deal we have available for the Guggenheim. You can also find the *Fine Arts Museum* in Bilbao, with exhibitions of Tucker and 50s fashion in France, in addition to other masterpieces. It is very close to the conference venue. We have compiled more information about these two museums on these pages: * Guggenheim Museum https://ep2015.europython.eu/en/venue/guggenheim-museum/ * Fine Arts Museum https://ep2015.europython.eu/en/venue/guggenheim-museum/ *Special Deal for EuroPython Attendees* --------------------------------------- If you want to avoid long queues at the Guggenheim Museum, you can benefit from getting a ticket at the conference desk. We have acquired a block of 100 tickets and will give them away for free, if you donate at least EUR 10 to the EuroPython conference financial aid budget for next year. That?s less than the regular ticket price and you get the additional warm fuzzy feeling of helping others as bonus :-) Donations can be made in cash at the conference desk. Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From ned at nedbatchelder.com Wed Jul 15 06:45:55 2015 From: ned at nedbatchelder.com (Ned Batchelder) Date: Wed, 15 Jul 2015 03:45:55 -0700 (PDT) Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87615lncmd.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87380rnrqt.fsf@elektro.pacujo.net> <87615lncmd.fsf@elektro.pacujo.net> Message-ID: <2ab46173-5bfb-44df-b7e5-c92fcd0c9461@googlegroups.com> On Wednesday, July 15, 2015 at 2:44:55 AM UTC-4, Marko Rauhamaa wrote: > Gregory Ewing : > > > Marko Rauhamaa wrote: > > >> It might even be tail-call optimized by Python. Only you can't count > >> on it because the language spec doesn't guarantee it. > > > > The language spec might permit it, but the BDFL has explicitly > > expressed a dislike for the idea of implicit tail call removal, so > > it's unlikely to ever happen in CPython. > > Permitting wouldn't be enough. > > The other problem for tail call elimination is the requirement that > functions return None by default. Smooth tail call elimination would > require that Python leave the default return value unspecified. I don't understand this, can you explain more? Are you saying that the Python specification shouldn't specify what x becomes?: def who_knows(): pass x = who_knows() --Ned. From marko at pacujo.net Wed Jul 15 06:55:57 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 15 Jul 2015 13:55:57 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87380rnrqt.fsf@elektro.pacujo.net> <87615lncmd.fsf@elektro.pacujo.net> <2ab46173-5bfb-44df-b7e5-c92fcd0c9461@googlegroups.com> Message-ID: <87r3o9lmf6.fsf@elektro.pacujo.net> Ned Batchelder : > On Wednesday, July 15, 2015 at 2:44:55 AM UTC-4, Marko Rauhamaa wrote: >> The other problem for tail call elimination is the requirement that >> functions return None by default. Smooth tail call elimination would >> require that Python leave the default return value unspecified. > > I don't understand this, can you explain more? Are you saying that the > Python specification shouldn't specify what x becomes?: > > def who_knows(): > pass > > x = who_knows() Yes, that's what I'm saying. The implementation would be free to assign any value whatsoever to x. Marko From kliateni at gmail.com Wed Jul 15 07:00:01 2015 From: kliateni at gmail.com (Karim) Date: Wed, 15 Jul 2015 13:00:01 +0200 Subject: xlrd 0.9.4 released! In-Reply-To: <55A5FD64.90302@simplistix.co.uk> References: <55A5FD64.90302@simplistix.co.uk> Message-ID: <55A63D31.70101@gmail.com> On 15/07/2015 08:27, Chris Withers wrote: > Hi All, > > I'm pleased to announce the release of xlrd 0.9.4: > > http://pypi.python.org/pypi/xlrd/0.9.4 > > This release includes the following changes: > > - Automated tests are now run on Python 3.4 > > - Use ElementTree.iter() if available, not deprecated getiterator() > when parsing xlsx files. > > - Fix #106 : Exception Value: unorderable types: Name() < Name() > > - Create row generator expression with Sheet.get_rows() > > - Fix for forward slash file separator and lowercase names within xlsx > internals. > > Thanks to the following for their contributions to this release: > > - Corey Farwell > - Jonathan Kamens > - Deepak N > - Brandon R. Stoner > - John McNamara > > If you find any problems, please ask about them on the > python-excel at googlegroups.com list, or submit an issue on GitHub: > > https://github.com/python-excel/xlrd/issues > > Full details of all things Python and Excel related can be found here: > > http://www.python-excel.org/ > > cheers, > > Chris > Thank You! From antoon.pardon at rece.vub.ac.be Wed Jul 15 07:04:32 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Wed, 15 Jul 2015 13:04:32 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87r3o9lmf6.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87380rnrqt.fsf@elektro.pacujo.net> <87615lncmd.fsf@elektro.pacujo.net> <2ab46173-5bfb-44df-b7e5-c92fcd0c9461@googlegroups.com> <87r3o9lmf6.fsf@elektro.pacujo.net> Message-ID: <55A63E40.8040403@rece.vub.ac.be> On 07/15/2015 12:55 PM, Marko Rauhamaa wrote: > Ned Batchelder : > >> On Wednesday, July 15, 2015 at 2:44:55 AM UTC-4, Marko Rauhamaa wrote: >>> The other problem for tail call elimination is the requirement that >>> functions return None by default. Smooth tail call elimination would >>> require that Python leave the default return value unspecified. >> I don't understand this, can you explain more? Are you saying that the >> Python specification shouldn't specify what x becomes?: >> >> def who_knows(): >> pass >> >> x = who_knows() > Yes, that's what I'm saying. The implementation would be free to assign > any value whatsoever to x. And can you explain why this would be needed foor smooth tail call elimination? -- Antoon Pardon. From ned at nedbatchelder.com Wed Jul 15 07:12:59 2015 From: ned at nedbatchelder.com (Ned Batchelder) Date: Wed, 15 Jul 2015 04:12:59 -0700 (PDT) Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87r3o9lmf6.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87380rnrqt.fsf@elektro.pacujo.net> <87615lncmd.fsf@elektro.pacujo.net> <2ab46173-5bfb-44df-b7e5-c92fcd0c9461@googlegroups.com> <87r3o9lmf6.fsf@elektro.pacujo.net> Message-ID: On Wednesday, July 15, 2015 at 6:56:10 AM UTC-4, Marko Rauhamaa wrote: > Ned Batchelder : > > > On Wednesday, July 15, 2015 at 2:44:55 AM UTC-4, Marko Rauhamaa wrote: > >> The other problem for tail call elimination is the requirement that > >> functions return None by default. Smooth tail call elimination would > >> require that Python leave the default return value unspecified. > > > > I don't understand this, can you explain more? Are you saying that the > > Python specification shouldn't specify what x becomes?: > > > > def who_knows(): > > pass > > > > x = who_knows() > > Yes, that's what I'm saying. The implementation would be free to assign > any value whatsoever to x. I don't understand why that is helpful for TCE? Can you explain? How does specifying None make "smooth TCE" difficult? --Ned. From breamoreboy at yahoo.co.uk Wed Jul 15 07:22:30 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Jul 2015 12:22:30 +0100 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: On 15/07/2015 10:13, Gregory Ewing wrote: > Chris Angelico wrote: >> I'm still interested in the explicit "replace current stack frame with >> this call" operation. Calling it "goto" seems wrong, as most languages >> with goto restrict it to _within_ a function, > > This just suggests to me is that most language designers > are not very imaginative. :-) > > A tail call *is* a goto. That's how you implement one in > assembly language -- you write a jump instruction instead > of a call instruction. The jump doesn't have to be to > the same function. > IIRC the realms of the C setjmp and longjmp. I'm just wondering out aloud if anybody has ever tried playing with cPython using these, or whether the code and/or Python itself is just too complex to allow this to even be tried, let alone succeed. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From marko at pacujo.net Wed Jul 15 07:24:40 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 15 Jul 2015 14:24:40 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87380rnrqt.fsf@elektro.pacujo.net> <87615lncmd.fsf@elektro.pacujo.net> <2ab46173-5bfb-44df-b7e5-c92fcd0c9461@googlegroups.com> <87r3o9lmf6.fsf@elektro.pacujo.net> Message-ID: <87mvyxll3b.fsf@elektro.pacujo.net> Ned Batchelder : > On Wednesday, July 15, 2015 at 6:56:10 AM UTC-4, Marko Rauhamaa wrote: >> Ned Batchelder : >> > I don't understand this, can you explain more? Are you saying that the >> > Python specification shouldn't specify what x becomes?: >> > >> > def who_knows(): >> > pass >> > >> > x = who_knows() >> >> Yes, that's what I'm saying. The implementation would be free to assign >> any value whatsoever to x. > > I don't understand why that is helpful for TCE? Can you explain? How does > specifying None make "smooth TCE" difficult? As Chris already pointed out, tail procedure calls can't be eliminated otherwise. An example: def some_func(): do_stuff() more_stuff() Now, for Python to replace the call to "more_stuff()" with a simple jump, there can't be an implicit "return None" following it. Instead, "some_func()" must be allowed to return whatever "more_stuff()" returns. You could require the programmer to write: def some_func(): do_stuff() return more_stuff() but that's not good style. In fact, it is not good style to write code that omits "return None" when None needs to be returned. IOW, the unspecifiedness of procedure return values is already the unwritten assumption in good Python code. Marko From suscricions at gmail.com Wed Jul 15 07:44:22 2015 From: suscricions at gmail.com (Jason P.) Date: Wed, 15 Jul 2015 04:44:22 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case Message-ID: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> Hi all! I'm working in a little Python exercise with testing since the beginning. So far I'm with my first end to end test (not even finished yet) trying to: 1) Launch a development web server linked to a demo app that just returns 'Hello World!' 2) Make a GET request successfully I can't understand very well what's happening. It seems that the main thread gets blocked listening to the web server. My intent was to spawn another process for the server independent of the test. Obviously I'm doing something wrong. I've made several guesses commenting pieces of code (tearDown method for example) but I didn't manage to solve the problem(s). I'm running the test through PyCharm. Python version = 3.4.3 Here it's the code: test_forecast_end_to_end.py =========================== import unittest from tests.end_to_end.forecastserver import ForecastServer import src.forecast.webservice as webservice import requests class TestForecastEndToEnd(unittest.TestCase): def setUp(self): # Start the forecast server self.server = ForecastServer() self.server.start(webservice.app) def tearDown(self): # Stop the forecast server self.server.stop() def test_webservice_receives_a_request(self): response = requests.get('http://localhost:8000') print(response.text) if __name__ == '__main__': unittest.main() forecastserver.py ================= from wsgiref.simple_server import make_server import multiprocessing class ForecastServer: def __init__(self): self._httpd_process = None def start(self, webservice): if not self._httpd_process: httpd = make_server('localhost', 8000, webservice) self._httpd_process = multiprocessing.Process( target=httpd.serve_forever) self._httpd_process.start() def stop(self): if self._httpd_process: self._httpd_process.join() self._httpd_process.terminate() del self._httpd_process webservice.py ============= def app(environ, start_response): status = '200 OK' headers = [('Content-type', 'text/plain')] start_response(status, headers) return ['Hello World!'] From python at mrabarnett.plus.com Wed Jul 15 08:00:48 2015 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 15 Jul 2015 13:00:48 +0100 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: <55A64B70.1000204@mrabarnett.plus.com> On 2015-07-15 12:22, Mark Lawrence wrote: > On 15/07/2015 10:13, Gregory Ewing wrote: >> Chris Angelico wrote: >>> I'm still interested in the explicit "replace current stack frame with >>> this call" operation. Calling it "goto" seems wrong, as most languages >>> with goto restrict it to _within_ a function, >> >> This just suggests to me is that most language designers >> are not very imaginative. :-) >> >> A tail call *is* a goto. That's how you implement one in >> assembly language -- you write a jump instruction instead >> of a call instruction. The jump doesn't have to be to >> the same function. >> > > IIRC the realms of the C setjmp and longjmp. I'm just wondering out > aloud if anybody has ever tried playing with cPython using these, or > whether the code and/or Python itself is just too complex to allow this > to even be tried, let alone succeed. > The problem with longjmp is that it could inadvertently bypass some clean-up code or deallocation, or, in the case of CPython, a DECREF. From rosuav at gmail.com Wed Jul 15 08:11:46 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 22:11:46 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> Message-ID: On Wed, Jul 15, 2015 at 9:44 PM, Jason P. wrote: > I can't understand very well what's happening. It seems that the main thread gets blocked listening to the web server. My intent was to spawn another process for the server independent of the test. Obviously I'm doing something wrong. I've made several guesses commenting pieces of code (tearDown method for example) but I didn't manage to solve the problem(s). > When you find yourself making guesses to try to figure out what's going on, here are two general tips: 1) Cut out as many pieces as you can. Test one small thing at a time. 2) If In Doubt, Print It Out! Stick print() calls into the code at key places, displaying the values of parameters or the results of intermediate calculations - or just saying "Hi, I'm still here and I'm running!". For #1, I would recommend first just trying to get the web service going. Can you connect (using an external program) on port 8000 and receive a text/plain HTTP response saying "Hello World!"? Never mind about the test for the moment. And for #2, judicious placement of console output will help you figure out things you're not sure about. For instance, you're suspecting that the main thread is getting blocked handling the web server. Easy way to check: def setUp(self): # Start the forecast server self.server = ForecastServer() self.server.start(webservice.app) Just before you construct the server, print something out. After you've constructed it but before you call start(), print something out. And after starting it, print something out. Then run the program. If you see the first line and no other, then it's blocking during the construction. Other deductions I'm sure you can figure out. One small point: Probe even things that you think are trivial. In the above example, I cannot see any reason why constructing ForecastServer() could possibly block, because its init does nothing but set a flag. But you can get surprised by things sometimes - maybe the problem is actually that you're not running the code you think you are, but there's some other ForecastServer kicking in, and it's synchronous rather than subprocess-based. End-to-end testing is all very well, but when something goes wrong, the key is to break the program down into smaller parts. Otherwise, all you have is "it doesn't work", which is one of the most useless error reports ever. If someone comes to python-list saying "it doesn't work", we'll be asking him/her to give a lot more details; if your aunt asks you for help printing out a document because "it doesn't work", you'll probably have to go over and watch her attempt it; and it's the same with your test cases - you make them tell you more details. Hope that helps! The techniques I'm offering are completely problem-independent, and even language-independent. IIDPIO debugging works in anything that gives you a console, which is pretty much everything - maybe it won't be print() but logging.debug(), but the same technique works. ChrisA From rosuav at gmail.com Wed Jul 15 08:13:47 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 22:13:47 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A64B70.1000204@mrabarnett.plus.com> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <55A64B70.1000204@mrabarnett.plus.com> Message-ID: On Wed, Jul 15, 2015 at 10:00 PM, MRAB wrote: > On 2015-07-15 12:22, Mark Lawrence wrote: >> >> On 15/07/2015 10:13, Gregory Ewing wrote: >>> >>> Chris Angelico wrote: >>>> >>>> I'm still interested in the explicit "replace current stack frame with >>>> this call" operation. Calling it "goto" seems wrong, as most languages >>>> with goto restrict it to _within_ a function, >>> >>> >>> This just suggests to me is that most language designers >>> are not very imaginative. :-) >>> >>> A tail call *is* a goto. That's how you implement one in >>> assembly language -- you write a jump instruction instead >>> of a call instruction. The jump doesn't have to be to >>> the same function. >>> >> >> IIRC the realms of the C setjmp and longjmp. I'm just wondering out >> aloud if anybody has ever tried playing with cPython using these, or >> whether the code and/or Python itself is just too complex to allow this >> to even be tried, let alone succeed. >> > The problem with longjmp is that it could inadvertently bypass some > clean-up code or deallocation, or, in the case of CPython, a DECREF. Which really says that TCO is impossible if you have any sort of clean-up or deallocation to be done after the call begins. The only way to truly turn your tail call into a GOTO is to do all your cleanup first. "try: return x() finally: more_code" is not a tail call, nor is it if you have "except:" in place of "finally:". ChrisA From rosuav at gmail.com Wed Jul 15 08:22:16 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Jul 2015 22:22:16 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: On Wed, Jul 15, 2015 at 7:13 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> I'm still interested in the explicit "replace current stack frame with >> this call" operation. Calling it "goto" seems wrong, as most languages >> with goto restrict it to _within_ a function, > > > This just suggests to me is that most language designers > are not very imaginative. :-) > > A tail call *is* a goto. That's how you implement one in > assembly language -- you write a jump instruction instead > of a call instruction. The jump doesn't have to be to > the same function. > Sure it is; but then, a while loop is a goto, but we don't call them goto loops. Ultimately, assembly language lets you treat everything the same way - in some CPUs, a jump is an assignment to the instruction pointer register, and is thus the same kind of operation as any other. In real-mode Intel 80x86 Assembly, there are unconditional and conditional jumps, where conditional jumps are limited to the shortest possible form of jump (relative jumps within +/- 128 bytes), but other than that, there's no distinctions between "if" statements, "while" loops, etc, etc. (Yes, there's also near-call, far-call, and interrupt, which push the instruction pointer, the IP plus the code segment, and the IP, CS, and the flags register, respectively - but then still just do a straight jump to the other location.) But in high level languages, we differentiate all of them, because the human who reads the code should differentiate between them. You don't use Python's "while" statement as a sort of "if", nor vice versa. At least, not usually... while x < 1: print("x is less than one!") break else: print("x is one or greater!") ChrisA From ian.g.kelly at gmail.com Wed Jul 15 10:28:31 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Jul 2015 08:28:31 -0600 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87d1zuejk2.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <87d1zuejk2.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 14, 2015 at 11:27 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Tue, Jul 14, 2015 at 2:33 AM, Marko Rauhamaa wrote: >>> The programmer shouldn't be controlling tail call optimizations. >> >> The programmer controls it regardless. >> >> return foo() # TCO >> >> result = foo() # No TCO >> return result # No TCO > > Not necessarily. Compile this function with gcc ("gcc -S -O2 atoi.c"): > > ======================================================================== > int atoi(const char *str, int n) > { > if (str && *str) > n = atoi(str + 1, n * 10 + *str - '0'); > return n; > } > ======================================================================== > (Example modified from ich-if-any-c-compilers-do-tail-recursion-optimization#220660>.) > > You'll see that the generated code is tail-call-optimized. This can't be done generally, though. What if, instead of a local variable, the assignment were to a dict item? Even if the dict itself is a local variable, the assignment can't be optimized away. From marko at pacujo.net Wed Jul 15 10:55:26 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 15 Jul 2015 17:55:26 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87pp3vm93f.fsf@elektro.pacujo.net> <87d1zuejk2.fsf@elektro.pacujo.net> Message-ID: <87vbdlbhcx.fsf@elektro.pacujo.net> Ian Kelly : > On Tue, Jul 14, 2015 at 11:27 AM, Marko Rauhamaa wrote: >> You'll see that the generated code is tail-call-optimized. > > This can't be done generally, though. What if, instead of a local > variable, the assignment were to a dict item? Even if the dict itself > is a local variable, the assignment can't be optimized away. Of course, you can only do correct optimizations. My point is that tail call optimizations should not be micromanaged by the programmer. Marko From skip.montanaro at gmail.com Wed Jul 15 11:35:30 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Wed, 15 Jul 2015 10:35:30 -0500 Subject: A couple virtual env questions Message-ID: I built and installed Python from Mercurial tip (head, whatever), so I have a Python 3.6.0a0 available. I created a virtualenv using that. Q1: Suppose I install something like matplotlib into that virtualenv which itself contains extension modules. Those will depend on the include files and shared libraries from Python itself. If I update my Python install, how do I detect that matplotlib needs to be rebuilt? I didn't see any obvious pip command to help with this. Q2: My normal environment is a work-specific Python 2.7 install. For that, I have PYTHONPATH set most/all of the time. I tried unsetting it when I created the virtual environment, but after activating it, PYTHONPATH is still set. Is there an automatic way to keep my global environment (PYTHONPATH, PYTHONSTARTUP, etc) from polluting my virtual env? Thx, Skip -------------- next part -------------- An HTML attachment was scrubbed... URL: From mal at europython.eu Wed Jul 15 13:11:37 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Wed, 15 Jul 2015 19:11:37 +0200 Subject: EuroPython 2015: Guidebook (Mobile Schedule) available Message-ID: <55A69449.7010705@europython.eu> We are pleased to announce the official guidebook for the EuroPython 2015 conference: *** https://ep2015.europython.eu/en/events/mobile-schedule/ *** We will regularly issue updates to the guidebook when there are changes in schedule. Available for all platforms --------------------------- This is available in several flavors: * for mobile phones as native apps for iOS and Android https://guidebook.com/g/europython2015/ * for browsers as web app https://guidebook.com/guide/31002/ The native apps have the advantage of allowing to use the guidebook in offline mode. Once you have the Guidebook app installed, search for ?EuroPython 2015? and download the guide. Nice Features ------------- * Maps of the venue * Full schedule * Create your personal schedule (My Schedule) * Watch Twitter updates and tweet right in the guidebook * Contact other attendees who have sign in to the guidebook * Useful information (Contacts, CoC, FAQ, City Infos, etc.) * Offline use (for the native apps) More information, links and QR codes are available on our mobile schedule page: https://ep2015.europython.eu/en/events/mobile-schedule/ Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From gary719_list1 at verizon.net Wed Jul 15 13:13:15 2015 From: gary719_list1 at verizon.net (Gary Roach) Date: Wed, 15 Jul 2015 10:13:15 -0700 Subject: password authentication failed Message-ID: <55A694AB.2020408@verizon.net> Every time I try to do a python manage.py migrate I get: django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" System Debian linux jessie python 2.79 Django 1.8 Postgresql 9.4.3 database Using virtualenv and virtualenvwrapper Postgres has root privileges in the Debian passwd file. Project settings.py file database setup # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'archivedb', 'USER': 'postgres', 'PASSWORD': 'xxxxxx', # A valid debian pw 'HOST': '127.0.0.1', 'PORT': '5432' } } I'm not certain how this should be corrected. Postgres ( using \d commands) does not seem to have any privileges set. Am I supposed to go outside the virtual environment to set up a postgres account in postgres or is Django supposed to do this with the migrate command. I feel like I am at a critical point where I can really screw things up and need some expert advise. This is my first time working with python / Django and am really shaky. I do have another learning project (rango) using SQLite that works fine. Gary R From rosuav at gmail.com Wed Jul 15 14:25:02 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Jul 2015 04:25:02 +1000 Subject: password authentication failed In-Reply-To: <55A694AB.2020408@verizon.net> References: <55A694AB.2020408@verizon.net> Message-ID: On Thu, Jul 16, 2015 at 3:13 AM, Gary Roach wrote: > Every time I try to do a python manage.py migrate I get: > django.db.utils.OperationalError: FATAL: password > authentication failed for user "postgres" > FATAL: password authentication failed for user "postgres" > > > DATABASES = { > 'default': { > 'USER': 'postgres', > 'PASSWORD': 'xxxxxx', # A valid debian pw > } > } PostgreSQL users are not the same as Unix users, and their passwords aren't necessarily the same. I would recommend *not* using the postgres user, which is the database superuser; instead, create a new user explicitly. On most Debian PostgreSQL installations, you should be able to invoke 'psql' while running as user 'postgres', either by su'ing to postgres or with sudo, for instance: $ sudo sudo -u postgres psql That should get you into a database CLI as superuser. Your prompt should look like this: postgres=# You should then be able to create a regular user, and grant appropriate permissions: postgres=# create user archives password 'traded-links-linguistics-informal'; CREATE ROLE postgres=# grant all on database archivedb to archives; GRANT (Make sure you have the semicolons at the ends, otherwise you'll think it's done nothing. It's actually waiting for you to type more lines for the same command, but the prompt difference is so subtle that it's easy to think it's silently ignoring you.) Then you should be able to use user name 'archives' and password 'traded-links-linguistics-informal' (of course, you don't want to use that; that's just what my password generating parrot came up with) instead of 'postgres' and whatever the Unix password was. Incidentally, I usually don't have any password on my postgres Unix user, nor on the corresponding database users. Safer to use sudo, eg to root and then down to postgres, as shown above. ChrisA From davros at bellaliant.net Wed Jul 15 15:05:41 2015 From: davros at bellaliant.net (John McKenzie) Date: Wed, 15 Jul 2015 19:05:41 GMT Subject: Keypress Input References: Message-ID: <9aypx.126956$r46.110087@fx28.iad> Hello, all. Thanks to everyone who responded to my post. I decided to make sure I had something that worked with what I have now and used Curses to finish it. However, it turns out that the extra work and problems with using GPIO pins and wiring up controllers that way is a small amount of headaches and work compared to what I thought it would be and the software part is actually easier than doing it this way. So in the end I will hooking the Raspberry Pi up directly to the buttons and use the Raspberry Pi's GPIO library to do it all. For posterity and in case other beginners want to look at it, here is what I have with curses that works now. Tried to add a function to cause it to only work for a certain amount of time and that did not work. Will worry about that when I do the new programme based off of directly connected buttons and have those working. Thanks everyone. Here is the keyboard controls the colours script. (Raspberry Pi B+, Blinkstick Pro and LED Adapter, analouge RGB LED light strip.) import curses import atexit import time from datetime import datetime from blinkstick import blinkstick starttime = time.time() screen = curses.initscr() curses.noecho() curses.curs_set(0) screen.keypad(1) screen.nodelay(1) led = blinkstick.find_first() timered = 0 timeyellow = 0 timeblue = 0 timestamp = str(datetime.now()) colour = 0 screen.addstr("Eflag 1") while True: event = screen.getch() if event == ord("q"): flog = open('flag1log.text', 'a') flog.write(timestamp + '\n' + 'Red Team: ' + str(timered) + '\n' + 'Yellow Team: ' + str(timeyellow) + '\n' + 'Blue Team: ' + str(timeblue) + '\n') flog.close() curses.endwin() break elif event == ord("r"): colour = 1 screen.addstr("Red Activated") elif event == ord("y"): colour = 2 screen.addstr("Yellow Activated") elif event == ord("b"): colour = 3 screen.addstr("Blue Activated") if colour == 1: led.pulse(red=255, green=0, blue=0, repeats=1, duration=3000, steps=50) timered += 1 print timered if colour == 2: led.pulse(red=255, green=255, blue=0, repeats=1, duration=3000, steps=50) timeyellow += 1 if colour == 3: led.pulse(red=0, green=0, blue=255, repeats=1, duration=2000, steps=50) timeblue += 1 if time.time() == (time.time() + 30): flog = open('flag1log.text', 'a') flog.write(timestamp + '\n' + 'Red Team: ' + str(timered) + '\n' + 'Yellow Team: ' + str(timeyellow) + '\n' + 'Blue Team: ' + str(timeblue) + '\n') flog.close() curses.endwin() break From torriem at gmail.com Wed Jul 15 15:17:07 2015 From: torriem at gmail.com (Michael Torrie) Date: Wed, 15 Jul 2015 13:17:07 -0600 Subject: Keypress Input In-Reply-To: <9aypx.126956$r46.110087@fx28.iad> References: <9aypx.126956$r46.110087@fx28.iad> Message-ID: <55A6B1B3.2010907@gmail.com> On 07/15/2015 01:05 PM, John McKenzie wrote: > Hello, all. > > Thanks to everyone who responded to my post. > > I decided to make sure I had something that worked with what I have now > and used Curses to finish it. However, it turns out that the extra work > and problems with using GPIO pins and wiring up controllers that way is a > small amount of headaches and work compared to what I thought it would be > and the software part is actually easier than doing it this way. So in > the end I will hooking the Raspberry Pi up directly to the buttons and > use the Raspberry Pi's GPIO library to do it all. > > For posterity and in case other beginners want to look at it, here is > what I have with curses that works now. Tried to add a function to cause > it to only work for a certain amount of time and that did not work. Will > worry about that when I do the new programme based off of directly > connected buttons and have those working. > > Thanks everyone. Thanks for the update! Also I am very glad to hear that using GPIO doesn't look very difficult. Good luck on things! From tjreedy at udel.edu Wed Jul 15 17:19:49 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 Jul 2015 17:19:49 -0400 Subject: A new module for performing tail-call elimination In-Reply-To: <55A6280C.3090602@rece.vub.ac.be> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> Message-ID: On 7/15/2015 5:29 AM, Antoon Pardon wrote: > On 07/13/2015 05:44 PM, Th. Baruchel wrote: >> Hi, after having spent much time thinking about tail-call elimination >> in Python (see for instance http://baruchel.github.io/blog/ ), I finally >> decided to write a module for that. You may find it at: >> >> https://github.com/baruchel/tco >> >> Tail-call elimination is done for tail-recursion as well as for >> continuation-passing style (cps) in a consistent syntax for both usages. >> >> Any tail-recursive function having the suitable format for being >> embeddable in the Y combinator can be used here with no change at all >> (with the main difference that tail-calls will be eliminated), but other >> continuations can also be added > > Can you explain how you would do mutual recursive functions? > Suppose I start with the following: > > def even(n): > True if n == 0 else odd(n - 1) > > def odd(n): > False if n == 0 else even(n - 1) > > How do I rewrite those with your module? I will not answer for Baruchel's tco module. However, combining the two bodies and following the general rule of replacing tail recursive calls with assignments inside a while loop gives us def even(n): return not odd(n) def odd(n): while True: if not n: return False else: n -= 1 if not n: return True else: n -= 1 # which passes this test print(even(0) is True, odd(0) is False, even(1) is False, odd(1) is True, even(2) is True, odd(2) is False, even(5) is False, odd(5) is True, even(6) is True, odd(6) is False) I believe that this pattern should work with any set of mutually recursive functions that always call each other in cyclic order. A more elaborate version does not have this limitation. -- Terry Jan Reedy From davidmichaelkarr at gmail.com Wed Jul 15 17:54:37 2015 From: davidmichaelkarr at gmail.com (David Karr) Date: Wed, 15 Jul 2015 14:54:37 -0700 (PDT) Subject: Where is "pyvenv.py" in new Python3.4 environment on CentOS7? Message-ID: I'm just learning more about Python (although I've been a Java dev for many years, and C/C++ before that). A book I'm reading (Learning Python Network Programming) refers to running "pyvenv". I can find this in my Win7 environment, but I was planning on using my CentOS7 VM for most of this. I have both "python" (Python 2) and "python3.4" installed. I noticed a "python-virtualenv.noarch" package, but it said it was already installed. Can someone elaborate on where I should be able to find or install this? (I tried asking this on the #python IRC channel, but I guess I couldn't yell loud enough.) From breamoreboy at yahoo.co.uk Wed Jul 15 18:22:30 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Jul 2015 23:22:30 +0100 Subject: Where is "pyvenv.py" in new Python3.4 environment on CentOS7? In-Reply-To: References: Message-ID: On 15/07/2015 22:54, David Karr wrote: > I'm just learning more about Python (although I've been a Java dev for many years, and C/C++ before that). Welcome to the world of sanity after years of insanity :) > > A book I'm reading (Learning Python Network Programming) refers to running "pyvenv". I can find this in my Win7 environment, but I was planning on using my CentOS7 VM for most of this. I have both "python" (Python 2) and "python3.4" installed. I noticed a "python-virtualenv.noarch" package, but it said it was already installed. > > Can someone elaborate on where I should be able to find or install this? On my Windows 8.1 box its under C:\Python34\Tools\Scripts > > (I tried asking this on the #python IRC channel, but I guess I couldn't yell loud enough.) > Yelling doesn't get you very far in the Python world, been there, seen it, done it, failed miserably, started again. Funnily enough the second time around was far more succesful. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From dk068x at att.com Wed Jul 15 18:32:10 2015 From: dk068x at att.com (KARR, DAVID) Date: Wed, 15 Jul 2015 22:32:10 +0000 Subject: Where is "pyvenv.py" in new Python3.4 environment on CentOS7? In-Reply-To: References: Message-ID: > -----Original Message----- > From: Python-list [mailto:python-list- > bounces+dk068x=att.com at python.org] On Behalf Of Mark Lawrence > Sent: Wednesday, July 15, 2015 3:23 PM > To: python-list at python.org > Subject: Re: Where is "pyvenv.py" in new Python3.4 environment on > CentOS7? > > On 15/07/2015 22:54, David Karr wrote: > > I'm just learning more about Python (although I've been a Java > dev for many years, and C/C++ before that). > > Welcome to the world of sanity after years of insanity :) Uh, right. We'll see about that. I have no complaints or issues with the Java ecosystem, it's just not used that much in networking, which I'm edging into. > > A book I'm reading (Learning Python Network Programming) refers > to running "pyvenv". I can find this in my Win7 environment, but I > was planning on using my CentOS7 VM for most of this. I have both > "python" (Python 2) and "python3.4" installed. I noticed a > "python-virtualenv.noarch" package, but it said it was already > installed. > > > > Can someone elaborate on where I should be able to find or > install this? > > On my Windows 8.1 box its under C:\Python34\Tools\Scripts Same as my Win7 box, but that's not what I need. I want to work on this on my CentOS7 box. > > (I tried asking this on the #python IRC channel, but I guess I > couldn't yell loud enough.) > > > > Yelling doesn't get you very far in the Python world, been there, > seen > it, done it, failed miserably, started again. Funnily enough the > second > time around was far more succesful. Yeah, I wasn't serious. I wasn't really yelling, just asking polite questions. It just made it seem like I needed to (yell) because I appeared to be invisible. I'm sure I'll have better luck when I can ask more interesting questions. From greg.ewing at canterbury.ac.nz Wed Jul 15 18:34:39 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 16 Jul 2015 10:34:39 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: Mark Lawrence wrote: > IIRC the realms of the C setjmp and longjmp. Not really the same thing. A longjmp chops the stack back, whereas a tail call avoids putting something on the stack to begin with. -- Greg From greg.ewing at canterbury.ac.nz Wed Jul 15 18:34:43 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 16 Jul 2015 10:34:43 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <55A64B70.1000204@mrabarnett.plus.com> Message-ID: Chris Angelico wrote: > Which really says that TCO is impossible if you have any sort of > clean-up or deallocation to be done after the call begins. The only > way to truly turn your tail call into a GOTO is to do all your cleanup > first. Indeed. In compilers that implement TCO, there's quite a lot more to it than just "replace CALL with JMP". It requires rethinking your whole strategy on when to put various things on the stack and take them off again, so that by the time you get to the point of the tail call, there is nothing on the stack other than the arguments to the tail call and the ultimate return address. -- Greg From greg.ewing at canterbury.ac.nz Wed Jul 15 18:43:22 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 16 Jul 2015 10:43:22 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> Message-ID: Antoon Pardon wrote: > But it doesn't need to be all or nothing. How about the following possibility. > When the runtime detects a serie of tail calls, it will keep the bottom three > and the top three backtrace records of the serie. Whatever value you choose for N, keeping only the first/last N traceback frames will lead to someone tearing their hair out. I recently had an experience with some Java code running in an environment which believed that nobody would want to see more than about 30 traceback levels, and chopped the rest off. Of course, the information I desperately wanted was buried deeper than that... So, -1 on any arbitrarily chosen traceback cutoff. -- Greg From breamoreboy at yahoo.co.uk Wed Jul 15 19:34:51 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 16 Jul 2015 00:34:51 +0100 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> Message-ID: On 15/07/2015 23:34, Gregory Ewing wrote: > Mark Lawrence wrote: >> IIRC the realms of the C setjmp and longjmp. > > Not really the same thing. A longjmp chops the stack > back, whereas a tail call avoids putting something on > the stack to begin with. > Thanks for that :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From rantingrickjohnson at gmail.com Wed Jul 15 21:03:23 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 15 Jul 2015 18:03:23 -0700 (PDT) Subject: Keypress Input In-Reply-To: References: Message-ID: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> On Friday, June 19, 2015 at 12:20:14 AM UTC-5, Christian Gollwitzer wrote: > The nonsense starts here: > > [...snip code...] > > it seems you don't understand event based programming. Duh. No need to abuse the lad. > It waits for the user input and does the dispatching, i.e. > when a key is pressed, then according to your bindings, > the functions red1, yellow1, blue1 are called, which set a > variable but do not do nything else. > > Now your job is to also do the functionality there, i.e. > you have to reformulate your task (waiting for red, then > blue...) as a state machine. Alternatively you can > circumvent to redo the logic in a state machine by using a > coroutine. State machines? Co-routines? Dispatching? Bindings? Are you purposefully attempting to scare the OP away from GUI programming forever, or merely practicing for your next tenure exam? Heck you're scaring me away and i have years of GUI programming experience under my belt! > You should read a text about GUI programming, or more > specifically event based programming, to understand your > mistake. Christian, peppering a student with a barrage of technical verbiage and then smacking them in the face with that tried and true knee-jerk-reactionary condescension of RTFM, is hardly the reaction that the OP deserves when he *DID* attempt to formulate working code from the sample that Laura provided. And even *IF* his attempt was an abysmal failure, we should strive to provide more information than simply: "go study the history of GUI design and get back to us in a year or two". Of course, we don't want to write the code for him, but his attempt does warrant a few extra clues. ============================================================ @ John ============================================================ You may have solved your input capturing problem, and i don't think a GUI is the preferred solution for a graphically deficient device anyhow, but you may well need a GUI in the future, and this would be a fine example from which to learn. So you want to know about Event Driven Programming do ya? Well then, skip the boring lectures and the hours of eyeball parsing techno-babble-prose and listen up! You see, we, as humans, emulate a version of Event Driven Programming (or EDP) in our everyday lives as something i shall henceforth refer to as Event Driven Reactions (or EDR). And these EDRs are codified as culturally acceptable reactions to external stimuli during the course of interpersonal relations. For instance: If we meet someone for the first time and they extend their hand, then we should extend ours and engage in the "hand shake" or the "fist bump" (depending upon cultural norms). And if you're in one of those really freaky cultures you may have to kiss someone... YUCK! Or if someone insults us with a sexual advance, and we're of the female persuasion, and they're of the male persuasion: then we might react (as "Manolo" found out in that famous scene from "Scarface") by slapping them *SMACK* The point is: The action of us reacting to external stimuli (based on predefined rules) is the exact nature of Event Driven GUIs. When we write GUI code under this paradigm, we need to follow a few design rules. (1) DEFINE/CREATE THE REQUIRED GUI COMPONENTS Here we define the window(s) and the required widgets that shall provide an interface between our users and our code. (2) DEFINE RULES FOR REACTIONS TO EXTERNAL STIMULI Here we bind events (keyboard, mouse, joystick, etc) to callbacks (aka: functions in Python) that our "master control program" (aka: Tkinter in this instance) will execute when the defined event is recieved. Now you may be asking yourself: "But i did that already! Why does my code fail to produce required results?" Hmm, it seems (as Christian pointed out) you made the fatal flaw of starting the event loop before your logic could execute. However. Even if your logic was allowed to execute, it would fail to produce the desired results. ============================================================ THE ROAD TO ENLIGHTENMENT: ============================================================ I have re-packaged Laura's basic example into a class format that utilizes a paradigm known as Object Oriented Programming (or OOP). Of course, you're not required to write code utilizing this format, but i feel it may be easier for a GUI novice to understand the entire structure of this program when the relevant bits are in near proximity to one another, rather than spread around a module like a spilled carton of toothpicks on the floor -- because, not all of us are blessed with the narrowly focused genius of the "idiot savant"! Now, conceptualize the entire class as representing the window whilst it's "alive", and the methods defined in the class as "personal reactions" to events that the window encounters during it's lifetime. You should think of the window as a unique object in two dimensional space, just as you and i are unique objects in three dimensional space. Furthermore, looking over the code you should recognize two distinct "syntactical groupings" (1) The "App object" (2) The instantiation of the that App object (psst: look below __name__ == '__main__') The object and the instantation of the object are now clearly defined by utilizing a "naturally linear" syntactical progression. Moreover, the functional behavior of the object is defined from *INSIDE* the object and *NOT* in the next room or next solar system. Most humans find this format to be a more natural way of writing code as it mirrors the conceptual observation of real life systems, objects, and the encapsulation of their innate behaviors. Enjoy. ## BEGIN "AWESOME CODE" ## import Tkinter as tk from tkMessageBox import showinfo, showerror MSG1 = """\ To begin retinal stimulation, press r or g or b on your keyboard Hold key down for extended stimulation! """ class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.bind("", self.evtKeyDown) self.bind("", self.evtKeyUp) self.protocol("WM_DELETE_WINDOW", self.evtDeleteWindow) w = tk.Label(self, text=MSG1) w.pack() self.config(bg='white') self.geometry('500x500') self.focus_set() def evtDeleteWindow(self): showinfo("The window is Dying", "Goodbye cruel world!", parent=self) self.destroy() def evtKeyDown(self, event): key = event.keysym.lower() alert = False if key == 'r': self.config(bg='red') elif key == 'g': self.config(bg='green') elif key == 'b': self.config(bg='blue') else: msg = 'I *TOLD* you to press r or g or b, not {0!r}!'.format(key) showerror('', msg, parent=self) def evtKeyUp(self, event): self.config(bg='white') if __name__ == '__main__': app = App() app.title('Retina Stimultor') app.mainloop() print "This code only executes *AFTER* the mainloop call returns!" ## END "AWESOME CODE" ## PS: Don't be too upset at Christian. He's probably just grumpy due to the excessive trolling and emotional warfare that plagues this fine group. I'm sure he did not mean to offend. Of course it could be that he's having withdraw systems due to my extended absence. Who knows? Perhaps if i found this group to more intellectually stimulating i might be inclined to participate on a regular basis. From ben+python at benfinney.id.au Wed Jul 15 21:51:07 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 16 Jul 2015 11:51:07 +1000 Subject: Mapping, with sequence as key, wildcard and subsequence matching Message-ID: <85k2u0vpis.fsf@benfinney.id.au> Howdy all, What well-defined data type exists with the following properties: * Mapping, key ? value. * Each key is a sequence (e.g. `tuple`) of items such as text strings. * Items in a key may be the sentinel `ANY` value, which will match any value at that position. * A key may specify that it will match *only* sequences of the same length. * A key may specify that it will match sequences with arbitrarily many additional unspecified items. If it matters: I'm using Python 2 to implement this. The ?match any item? type is simple enough; I'm aware of the `unittest.mock.ANY` sentinel, and that meets my needs. What I'm hoping to find is a general, existing, solution to the problem of a mapping that uses keys which, in their value, encapsulate the fact that the key does, or does not, match sequences of arbitrary length longer than itself. Example of what I'd like:: from unittest import mock responses = SubsequenceMatchingType([ ('foo', 'bar', 'baz'): "Simple three-argument command.", ('wibble', mock.ANY, 'wubble'): "Second argument ANY.", ('lorem', 'ipsum'): "Arbitrary trailing arguments.", ]) responses[('foo', 'bar')] # raises KeyError responses[('foo', 'bar', 'baz')] # ? "Simple three-argument command." responses[('foo', 'bar', 'baz', 'bork')] # raises KeyError responses[('wibble', 'wobble')] # raises KeyError responses[('wibble', 'wobble', 'wubble')] # ? "Second argument ANY." responses[('wibble', 'wobble', 'baz')] # raises KeyError responses[('wibble', 'wobble', 'wubble', 'baz')] # raises KeyError responses[('lorem',)] # raises KeyError responses[('lorem', 'ipsum')] # ? "Arbitrary trailing arguments." responses[('lorem', 'ipsum', 'dolor', 'sit', 'amet')] # ? "Arbitrary trailing arguments." So some kind of distinguishing feature needs to be added to those keys which should match arbitrary trailing items: not ?('foo', 'bar', 'baz')? but ?('lorem', 'ipsum')?. The trouble I'm having is that the keys in the mapping, and the candidate sequences, are simple tuples. Adding a sentinel item at the end would make it a different sequence, and indistinguishable from specifying an additional item at that position. Is this a problem already solved (and implemented, and debugged!) in a general form that I can use? -- \ ?I am too firm in my consciousness of the marvelous to be ever | `\ fascinated by the mere supernatural ?? ?Joseph Conrad, _The | _o__) Shadow-Line_ | Ben Finney From orgnut at yahoo.com Wed Jul 15 23:01:46 2015 From: orgnut at yahoo.com (Larry Hudson) Date: Wed, 15 Jul 2015 20:01:46 -0700 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> Message-ID: <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> On 07/15/2015 05:11 AM, Chris Angelico wrote: > On Wed, Jul 15, 2015 at 9:44 PM, Jason P. wrote: >> I can't understand very well what's happening. It seems that the main thread gets blocked listening to the web server. My intent was to spawn another process for the server independent of the test. Obviously I'm doing something wrong. I've made several guesses commenting pieces of code (tearDown method for example) but I didn't manage to solve the problem(s). >> > > When you find yourself making guesses to try to figure out what's > going on, here are two general tips: > > 1) Cut out as many pieces as you can. Test one small thing at a time. > 2) If In Doubt, Print It Out! Stick print() calls into the code at key > places, displaying the values of parameters or the results of > intermediate calculations - or just saying "Hi, I'm still here and I'm > running!". > In addition to using print(), in some places I like using input() instead, as in: input('x={}, y={} --> '.format(x, y)) Then the program stops at that point so you can study it. To continue just press , or Ctrl-C to abort. -=- Larry -=- From orgnut at yahoo.com Wed Jul 15 23:01:46 2015 From: orgnut at yahoo.com (Larry Hudson) Date: Wed, 15 Jul 2015 20:01:46 -0700 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> Message-ID: <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> On 07/15/2015 05:11 AM, Chris Angelico wrote: > On Wed, Jul 15, 2015 at 9:44 PM, Jason P. wrote: >> I can't understand very well what's happening. It seems that the main thread gets blocked listening to the web server. My intent was to spawn another process for the server independent of the test. Obviously I'm doing something wrong. I've made several guesses commenting pieces of code (tearDown method for example) but I didn't manage to solve the problem(s). >> > > When you find yourself making guesses to try to figure out what's > going on, here are two general tips: > > 1) Cut out as many pieces as you can. Test one small thing at a time. > 2) If In Doubt, Print It Out! Stick print() calls into the code at key > places, displaying the values of parameters or the results of > intermediate calculations - or just saying "Hi, I'm still here and I'm > running!". > In addition to using print(), in some places I like using input() instead, as in: input('x={}, y={} --> '.format(x, y)) Then the program stops at that point so you can study it. To continue just press , or Ctrl-C to abort. -=- Larry -=- From rosuav at gmail.com Wed Jul 15 23:11:28 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Jul 2015 13:11:28 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> Message-ID: On Thu, Jul 16, 2015 at 1:01 PM, Larry Hudson via Python-list wrote: > On 07/15/2015 05:11 AM, Chris Angelico wrote: >> >> On Wed, Jul 15, 2015 at 9:44 PM, Jason P. wrote: >>> >>> I can't understand very well what's happening. It seems that the main >>> thread gets blocked listening to the web server. My intent was to spawn >>> another process for the server independent of the test. Obviously I'm doing >>> something wrong. I've made several guesses commenting pieces of code >>> (tearDown method for example) but I didn't manage to solve the problem(s). >>> >> >> When you find yourself making guesses to try to figure out what's >> going on, here are two general tips: >> >> 1) Cut out as many pieces as you can. Test one small thing at a time. >> 2) If In Doubt, Print It Out! Stick print() calls into the code at key >> places, displaying the values of parameters or the results of >> intermediate calculations - or just saying "Hi, I'm still here and I'm >> running!". >> > In addition to using print(), in some places I like using input() instead, > as in: > input('x={}, y={} --> '.format(x, y)) > Then the program stops at that point so you can study it. > To continue just press , or Ctrl-C to abort. That's a neat trick, as long as you actually do have a console. IIDPIO is extremely general (works across languages, across frameworks (eg a web server), etc), but these kinds of extensions are pretty handy when they make sense. ChrisA From rantingrickjohnson at gmail.com Wed Jul 15 23:33:19 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 15 Jul 2015 20:33:19 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> Message-ID: <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> On Wednesday, July 15, 2015 at 10:11:43 PM UTC-5, Chris Angelico wrote: > That's a neat trick, as long as you actually do have a console. Well if you don't have a console, another option is to use the dialogs of the "batteries included GUI" named Tkinter. from tkMessageBox import showinfo # Syntax == Python < 3.0 From rosuav at gmail.com Wed Jul 15 23:44:56 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Jul 2015 13:44:56 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> Message-ID: On Thu, Jul 16, 2015 at 1:33 PM, Rick Johnson wrote: > On Wednesday, July 15, 2015 at 10:11:43 PM UTC-5, Chris Angelico wrote: >> That's a neat trick, as long as you actually do have a console. > > Well if you don't have a console, another option is to use the > dialogs of the "batteries included GUI" named Tkinter. > > from tkMessageBox import showinfo # Syntax == Python < 3.0 A GUI is another form of console. Not all programs are run in a situation where this makes sense. Also, please don't post Py2-only code when the OP clearly stated that 3.4.3 was being used... ChrisA From steve at pearwood.info Thu Jul 16 00:01:15 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Thu, 16 Jul 2015 14:01:15 +1000 Subject: Mapping, with sequence as key, wildcard and subsequence matching References: Message-ID: <55a72c8b$0$1671$c3e8da3$5496439d@news.astraweb.com> On Thu, 16 Jul 2015 11:51 am, Ben Finney wrote: > Howdy all, > > What well-defined data type exists with the following properties: > > * Mapping, key ? value. > > * Each key is a sequence (e.g. `tuple`) of items such as text strings. > > * Items in a key may be the sentinel `ANY` value, which will match any > value at that position. > > * A key may specify that it will match *only* sequences of the same > length. > > * A key may specify that it will match sequences with arbitrarily many > additional unspecified items. Sounds like a regular expression. Remember that computer science theoretical regular expressions don't just match strings, they can apply to any sequence of primitive values. In your case, you only need two special tokens, match-one and match-one-or-more (which may be like r'.' and r'.*'). If you can guarantee that the key items have no spaces in them, you may even be able to use a string re. Assemble the key from the tuple like so: - replace ONE by "." - replace ONE-OR-MORE by ".*" - return " ".join(keyitems) Otherwise, you can create your own sequence type and simple regex engine (you only need two meta-items, ONE and ONE-OR-MORE) to perform equality tests. If you can use a string, make it a subclass with an __eq__ method that returns re.match(key, self). Either way, you can then use your custom class as the keys in a mapping type. You can't use a dict for the mapping, not unless you're smarter than me, due to the requirement to hash the keys. You can use a simple list of tuples [(key, value), ...] if O(N) searches are fast enough. (Surely they'll be fast enough for a proof of concept?) That at least is guaranteed to work: when doing a lookup, you simply look at every key until you find (at least one) that matches. If there are no matches by the time you hit the end of the list, you know that there cannot be any matches! A more complex, but potentially faster for large N, method would be to keep the list sorted and use a binary search (bisect module). Or use a binary tree. The hard part is that for this to work, you need a well-defined less-than operation as well as equality, and I'm not sure how to implement that for ONE and ONE-OR-MORE. I'm sure it can be done though. At a guess... make ONE less than every string, and every string less than ONE-OR-MORE, and then just use regular tuple order comparisons. -- Steven From torriem at gmail.com Thu Jul 16 00:30:13 2015 From: torriem at gmail.com (Michael Torrie) Date: Wed, 15 Jul 2015 22:30:13 -0600 Subject: Keypress Input In-Reply-To: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> References: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> Message-ID: <55A73355.40008@gmail.com> On 07/15/2015 07:03 PM, Rick Johnson wrote: > I think you've missed the whole point of the OP's project. He doesn't want to make a GUI. He simply wants to have his program do something like blink an LED when someone presses a big red button. He just wanted a quick way to test things out since his big red button can emulate a USB keyboard. So all he needed was a simple console app that can fetch keystrokes. In the end, though GPIO is very simple both electrically and in terms of Python, so that is the ultimate route he will go. If you read his last post you'll find he says this. From tjreedy at udel.edu Thu Jul 16 01:27:36 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 16 Jul 2015 01:27:36 -0400 Subject: Mapping, with sequence as key, wildcard and subsequence matching In-Reply-To: <85k2u0vpis.fsf@benfinney.id.au> References: <85k2u0vpis.fsf@benfinney.id.au> Message-ID: On 7/15/2015 9:51 PM, Ben Finney wrote: > Howdy all, > > What well-defined data type exists with the following properties: > > * Mapping, key ? value. > > * Each key is a sequence (e.g. `tuple`) of items such as text strings. > > * Items in a key may be the sentinel `ANY` value, which will match any > value at that position. > > * A key may specify that it will match *only* sequences of the same > length. > > * A key may specify that it will match sequences with arbitrarily many > additional unspecified items. Every key should signal which of the last two alterntives holds. One can be a default. The signal can be 'in-band', in the tuple key itself, or 'out-of-band', not in the tuple key. An in-band signal must be a special value, like 'ANY', that is not otherwise used in keys. ... might be a good choice. For out-of-band, you could try a tuple subclass with a __new__ method that sets an attribute. Or wrap a tuple, say with a list, to signal the non-default alternative. Something like tail = False if type(key) is list: tail = True key = key.pop() -- Terry Jan Reedy From ben+python at benfinney.id.au Thu Jul 16 01:53:21 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 16 Jul 2015 15:53:21 +1000 Subject: Mapping, with sequence as key, wildcard and subsequence matching References: <55a72c8b$0$1671$c3e8da3$5496439d@news.astraweb.com> Message-ID: <85fv4oveb2.fsf@benfinney.id.au> Steven D'Aprano writes: > Sounds like a regular expression. Remember that computer science > theoretical regular expressions don't just match strings, they can > apply to any sequence of primitive values. Good insight, thank you. > In your case, you only need two special tokens, match-one and > match-one-or-more (which may be like r'.' and r'.*'). It actually needs ?one? and ?zero-or-more?. Which does match your analogous regex ?.? and ?.*? patterns. > Otherwise, you can create your own sequence type and simple regex > engine (you only need two meta-items, [ONE and ZERO-OR-MORE]) to > perform equality tests. It may have to come to that. That's not such a problem, but: > You can't use a dict for the mapping, not unless you're smarter than > me, due to the requirement to hash the keys. Dang. It's the mapping that I really need to solve, I think. A mapping that has a custom ?does this candidate match any existing key? and ?return the value for this key? to defer to the matching behaviour described above. Are those the ?__contains__?, ?__getitem__? methods? What actually is the API of a mapping type, that would need to be customised for this application? -- \ ?If we listen only to those who are like us, we will squander | `\ the great opportunity before us: To live together peacefully in | _o__) a world of unresolved differences.? ?David Weinberger | Ben Finney From ben+python at benfinney.id.au Thu Jul 16 01:55:15 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 16 Jul 2015 15:55:15 +1000 Subject: Mapping, with sequence as key, wildcard and subsequence matching References: <85k2u0vpis.fsf@benfinney.id.au> Message-ID: <85bnfcve7w.fsf@benfinney.id.au> Terry Reedy writes: > On 7/15/2015 9:51 PM, Ben Finney wrote: > > What well-defined data type exists with the following properties: > > > > * Mapping, key ? value. > > > > * Each key is a sequence (e.g. `tuple`) of items such as text strings. > > > > * Items in a key may be the sentinel `ANY` value, which will match any > > value at that position. > > > > * A key may specify that it will match *only* sequences of the same > > length. > > > > * A key may specify that it will match sequences with arbitrarily many > > additional unspecified items. > > Every key should signal which of the last two alterntives holds. One > can be a default. The signal can be 'in-band', in the tuple key > itself, or 'out-of-band', not in the tuple key. Thanks. The part which puzzle me though: How do we teach the mapping type about that matching behaviour? -- \ ?Without cultural sanction, most or all of our religious | `\ beliefs and rituals would fall into the domain of mental | _o__) disturbance.? ?John F. Schumaker | Ben Finney From tjreedy at udel.edu Thu Jul 16 02:08:53 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 16 Jul 2015 02:08:53 -0400 Subject: Keypress Input In-Reply-To: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> References: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> Message-ID: On 7/15/2015 9:03 PM, Rick Johnson wrote: > You may have solved your input capturing problem, and i > don't think a GUI is the preferred solution for a > graphically deficient device anyhow, but you may well need a > GUI in the future, and this would be a fine example from which > to learn. This really is a nice example. Your rationale for defining an app class is the best I remember seeing. To run in 3.x, change the first two lines to import tkinter as tk from tkinter.messagebox import showinfo, showerror > import Tkinter as tk > from tkMessageBox import showinfo, showerror > > MSG1 = """\ > To begin retinal stimulation, press r or g or b on your keyboard > Hold key down for extended stimulation! > """ > > class App(tk.Tk): > def __init__(self): > tk.Tk.__init__(self) > self.bind("", self.evtKeyDown) > self.bind("", self.evtKeyUp) > self.protocol("WM_DELETE_WINDOW", self.evtDeleteWindow) > w = tk.Label(self, text=MSG1) > w.pack() > self.config(bg='white') > self.geometry('500x500') > self.focus_set() > > def evtDeleteWindow(self): > showinfo("The window is Dying", "Goodbye cruel world!", parent=self) > self.destroy() > > def evtKeyDown(self, event): > key = event.keysym.lower() > alert = False > if key == 'r': > self.config(bg='red') > elif key == 'g': > self.config(bg='green') > elif key == 'b': > self.config(bg='blue') > else: Can condense block above to this easily extended code: (Replacing if if/elif/elif/... chains, when possible, is part of mastering Python.) try: self['bg'] = {'r':'red', 'g':'green', 'b':'blue'}[key] except KeyError: > msg = 'I *TOLD* you to press r or g or b, not {0!r}!'.format(key) > showerror('', msg, parent=self) > > def evtKeyUp(self, event): > self.config(bg='white') > > if __name__ == '__main__': > app = App() > app.title('Retina Stimultor') > app.mainloop() > print "This code only executes *AFTER* the mainloop call returns!" Adding parens to print, when there is a single object being printed, has no effect in 2.x and makes the statement work in 3.x. The following works the same in both. print("Mainloop has returned") -- Terry Jan Reedy From rosuav at gmail.com Thu Jul 16 02:21:22 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Jul 2015 16:21:22 +1000 Subject: Mapping, with sequence as key, wildcard and subsequence matching In-Reply-To: <85bnfcve7w.fsf@benfinney.id.au> References: <85k2u0vpis.fsf@benfinney.id.au> <85bnfcve7w.fsf@benfinney.id.au> Message-ID: On Thu, Jul 16, 2015 at 3:55 PM, Ben Finney wrote: > Thanks. The part which puzzle me though: How do we teach the mapping > type about that matching behaviour? I'm not sure you really need a mapping type per se. The benefit of something like Python's dict is that it gives really fast lookups via the hash table... but with the "match any" concept, there's actually a potential for ambiguities, which means you need a sequential (strictest first) check. In any case, it's virtually impossible to hash a tuple of strings such that it can match multiple targets, based only on what the targets do. Steven's suggestion to turn this into an honest linear search is probably what I'd do; ultimately, a dict that can't hash its keys properly is going to devolve to that anyway. You could craft a mapping-like type that uses subscripts in this way. I'm not sure whether it'd help, but there's no particular reason for __getitem__ to not do a full linear search: class Lookup: def __getitem__(self, item): for matcher, value in self.stuff: keys = iter(item) for key in matcher: if key is ZERO_OR_MORE: return value # Matched! try: val = next(keys) except StopIteration: break # Too short, doesn't match if key != val and key is not ANY_ONE: break # Mismatch else: return value # Matched! raise KeyError(item) Then in your code, it would look like any other mapping type, but it'd still be the exact same linear search that Steven talked about. ChrisA From ethan at stoneleaf.us Thu Jul 16 02:31:08 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 15 Jul 2015 23:31:08 -0700 Subject: Mapping, with sequence as key, wildcard and subsequence matching In-Reply-To: <85fv4oveb2.fsf@benfinney.id.au> References: <55a72c8b$0$1671$c3e8da3$5496439d@news.astraweb.com> <85fv4oveb2.fsf@benfinney.id.au> Message-ID: <55A74FAC.4090807@stoneleaf.us> On 07/15/2015 10:53 PM, Ben Finney wrote: > Steven D'Aprano writes: >> You can't use a dict for the mapping, not unless you're smarter than >> me, due to the requirement to hash the keys. > > Dang. It's the mapping that I really need to solve, I think. A mapping > that has a custom ?does this candidate match any existing key? and > ?return the value for this key? to defer to the matching behaviour > described above. > > Are those the ?__contains__?, ?__getitem__? methods? What actually is > the API of a mapping type, that would need to be customised for this > application? The problem is that potential key matches are found by hashes, and the hash of ('value1', ANY, 'next_value') and ('value1, 'value2', 'next_value') and ('value1', 'value3', 'next_value') will not and cannot be the same. If you fiddle with your object such that all instances hash to the same value then you lose the O(1) lookup for the dict -- you basically have a list. -- ~Ethan~ From ben+python at benfinney.id.au Thu Jul 16 02:31:50 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 16 Jul 2015 16:31:50 +1000 Subject: Mapping, with sequence as key, wildcard and subsequence matching References: <85k2u0vpis.fsf@benfinney.id.au> <85bnfcve7w.fsf@benfinney.id.au> Message-ID: <85380ovcix.fsf@benfinney.id.au> Chris Angelico writes: > I'm not sure you really need a mapping type per se. My reasons include (but I can probably think of more) testing membership via the ?key in mapping? syntax. > with the "match any" concept, there's actually a potential for > ambiguities, which means you need a sequential (strictest first) > check. In any case, it's virtually impossible to hash a tuple of > strings such that it can match multiple targets, based only on what > the targets do. I'm fine with not having the keys hashed, so long as I can use the mapping API (membership test, item retrieval by key, rejecting keys that already match one of the items, etc.). In other words, I'm not limiting myself to Python's ?dict? type, which is why I've only been talking about a type which can be classified as a mapping type. > Steven's suggestion to turn this into an honest linear search is > probably what I'd do; ultimately, a dict that can't hash its keys > properly is going to devolve to that anyway. Fine by me. What is the mapping API that needs to be implemented though? I can guess, but for code I intend to release, API design should not be a matter of guessing. I'd rather have an already-worked example of a custom mapping type that fully implements the API used by Python's mapping type, without having to discover it all by trial and error. Once this is out in the wild, I don't want to discover I made a bad API design decision. -- \ ?When a well-packaged web of lies has been sold to the masses | `\ over generations, the truth will seem utterly preposterous and | _o__) its speaker a raving lunatic.? ?Dresden James | Ben Finney From ben+python at benfinney.id.au Thu Jul 16 02:37:50 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 16 Jul 2015 16:37:50 +1000 Subject: Mapping, with sequence as key, wildcard and subsequence matching References: <55a72c8b$0$1671$c3e8da3$5496439d@news.astraweb.com> <85fv4oveb2.fsf@benfinney.id.au> <55A74FAC.4090807@stoneleaf.us> Message-ID: <85y4igtxoh.fsf@benfinney.id.au> Ethan Furman writes: > On 07/15/2015 10:53 PM, Ben Finney wrote: > > Are those the ?__contains__?, ?__getitem__? methods? What actually > > is the API of a mapping type, that would need to be customised for > > this application? > > The problem is that potential key matches are found by hashes For the Python ?dict? type, yes. I already know that I don't want that type, I want a custom mapping type which matches keys according to the algorithm I specify. So, I'm not asking ?how do I make ?dict? do this??. I am instead asking ?how do I implement a custom type which can duck-type for ?dict? but have a different key-lookup implementation??. -- \ ?As the most participatory form of mass speech yet developed, | `\ the Internet deserves the highest protection from governmental | _o__) intrusion.? ?U.S. District Court Judge Dalzell | Ben Finney From zachary.ware+pylist at gmail.com Thu Jul 16 02:43:54 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Thu, 16 Jul 2015 01:43:54 -0500 Subject: Mapping, with sequence as key, wildcard and subsequence matching In-Reply-To: <85380ovcix.fsf@benfinney.id.au> References: <85k2u0vpis.fsf@benfinney.id.au> <85bnfcve7w.fsf@benfinney.id.au> <85380ovcix.fsf@benfinney.id.au> Message-ID: On Thu, Jul 16, 2015 at 1:31 AM, Ben Finney wrote: > Fine by me. What is the mapping API that needs to be implemented though? Have a look at collections.MutableMapping. -- Zach From marko at pacujo.net Thu Jul 16 02:53:44 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 16 Jul 2015 09:53:44 +0300 Subject: Mapping, with sequence as key, wildcard and subsequence matching References: Message-ID: <871tg8bnk7.fsf@elektro.pacujo.net> Ben Finney : > What well-defined data type exists with the following properties: > > * Mapping, key ? value. > > * Each key is a sequence (e.g. `tuple`) of items such as text strings. > > * Items in a key may be the sentinel `ANY` value, which will match any > value at that position. > > * A key may specify that it will match *only* sequences of the same > length. > > * A key may specify that it will match sequences with arbitrarily many > additional unspecified items. What you are describing is a tree; the sequences specify paths: ======================================================================== class Node: ANY = object() UNDEFINED = object() def __init__(self): self.value = Node.UNDEFINED self.children = {} def setvalue(self, keyseq, value, offset=0): try: next = keyseq[offset] except IndexError: self.value = value return if next is Node.ANY: raise KeyError() try: child = self.children[next] except KeyError: self.children[next] = child = Node() child.setvalue(keyseq, value, offset + 1) def lookup(self, keyseq, offset=0): try: next = keyseq[offset] except IndexError: for value in self.yieldall(): yield value return if next is Node.ANY: for child in self.children.itervalues(): for value in child.lookup(keyseq, offset + 1): yield value return try: child = self.children[next] except KeyError: return for value in child.lookup(keyseq, offset + 1): yield value def yieldall(self): if self.value is not Node.UNDEFINED: yield self.value for child in self.children.itervalues(): for value in child.yieldall(): yield value ===================================================================== Usage: ===================================================================== tree = Node() tree.setvalue((1, 2), 3) print list(tree.lookup((1, 2))) print list(tree.lookup((Node.ANY, 2))) ===================================================================== CAVEAT: Code barely tested. Marko From breamoreboy at yahoo.co.uk Thu Jul 16 03:09:05 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 16 Jul 2015 08:09:05 +0100 Subject: Mapping, with sequence as key, wildcard and subsequence matching In-Reply-To: <85y4igtxoh.fsf@benfinney.id.au> References: <55a72c8b$0$1671$c3e8da3$5496439d@news.astraweb.com> <85fv4oveb2.fsf@benfinney.id.au> <55A74FAC.4090807@stoneleaf.us> <85y4igtxoh.fsf@benfinney.id.au> Message-ID: On 16/07/2015 07:37, Ben Finney wrote: > Ethan Furman writes: > >> On 07/15/2015 10:53 PM, Ben Finney wrote: >>> Are those the ?__contains__?, ?__getitem__? methods? What actually >>> is the API of a mapping type, that would need to be customised for >>> this application? >> >> The problem is that potential key matches are found by hashes > > For the Python ?dict? type, yes. I already know that I don't want that > type, I want a custom mapping type which matches keys according to the > algorithm I specify. > > So, I'm not asking ?how do I make ?dict? do this??. I am instead asking > ?how do I implement a custom type which can duck-type for ?dict? but > have a different key-lookup implementation??. > https://docs.python.org/3/reference/datamodel.html?emulating-container-types The collections module provides a MutableMapping abstract base class to help create those methods from a base set of __getitem__(), __setitem__(), __delitem__(), and keys() Hence https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping Hunting for examples got me to http://code.activestate.com/recipes/578096-a-mutablemapping-that-can-use-unhashable-objects-a/ so fingers crossed, I'm just hoping that we're going in the right direction. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From tjreedy at udel.edu Thu Jul 16 03:10:30 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 16 Jul 2015 03:10:30 -0400 Subject: Keypress Input In-Reply-To: <55A73355.40008@gmail.com> References: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> <55A73355.40008@gmail.com> Message-ID: On 7/16/2015 12:30 AM, Michael Torrie wrote: > On 07/15/2015 07:03 PM, Rick Johnson wrote: >> > > I think you've missed the whole point of the OP's project. He doesn't > want to make a GUI. He simply wants to have his program do something > like blink an LED when someone presses a big red button. He just wanted > a quick way to test things out since his big red button can emulate a > USB keyboard. So all he needed was a simple console app that can fetch > keystrokes. In the end, though GPIO is very simple both electrically > and in terms of Python, so that is the ultimate route he will go. If > you read his last post you'll find he says this. Rick pretty much acknowledged what you said in this paragraph. "You may have solved your input capturing problem, and i don't think a GUI is the preferred solution for a graphically deficient device anyhow, but you may well need a GUI in the future, and this would be a fine example from which to learn." It is a fine example. -- Terry Jan Reedy From ben+python at benfinney.id.au Thu Jul 16 03:11:38 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 16 Jul 2015 17:11:38 +1000 Subject: Mapping, with sequence as key, wildcard and subsequence matching References: <85k2u0vpis.fsf@benfinney.id.au> <85bnfcve7w.fsf@benfinney.id.au> <85380ovcix.fsf@benfinney.id.au> Message-ID: <85pp3stw45.fsf@benfinney.id.au> Zachary Ware writes: > On Thu, Jul 16, 2015 at 1:31 AM, Ben Finney wrote: > > Fine by me. What is the mapping API that needs to be implemented though? > > Have a look at collections.MutableMapping. Thank you, that's great! I hadn't realised the ?collections? module had such comprehensive coverage of Python built-in type APIs. Now to focus back on the ?existing debugged implementation? part :-) -- \ ?Nothing is so common as to imitate one's enemies, and to use | `\ their weapons.? ?Voltaire, _Dictionnaire Philosophique_ | _o__) | Ben Finney From breamoreboy at yahoo.co.uk Thu Jul 16 03:24:08 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 16 Jul 2015 08:24:08 +0100 Subject: Mapping, with sequence as key, wildcard and subsequence matching In-Reply-To: References: <55a72c8b$0$1671$c3e8da3$5496439d@news.astraweb.com> <85fv4oveb2.fsf@benfinney.id.au> <55A74FAC.4090807@stoneleaf.us> <85y4igtxoh.fsf@benfinney.id.au> Message-ID: On 16/07/2015 08:09, Mark Lawrence wrote: > On 16/07/2015 07:37, Ben Finney wrote: >> Ethan Furman writes: >> >>> On 07/15/2015 10:53 PM, Ben Finney wrote: >>>> Are those the ?__contains__?, ?__getitem__? methods? What actually >>>> is the API of a mapping type, that would need to be customised for >>>> this application? >>> >>> The problem is that potential key matches are found by hashes >> >> For the Python ?dict? type, yes. I already know that I don't want that >> type, I want a custom mapping type which matches keys according to the >> algorithm I specify. >> >> So, I'm not asking ?how do I make ?dict? do this??. I am instead asking >> ?how do I implement a custom type which can duck-type for ?dict? but >> have a different key-lookup implementation??. >> > > https://docs.python.org/3/reference/datamodel.html?emulating-container-types > > > > The collections module provides a MutableMapping abstract base class to > help create those methods from a base set of __getitem__(), > __setitem__(), __delitem__(), and keys() > > > Hence > https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping > > > Hunting for examples got me to > http://code.activestate.com/recipes/578096-a-mutablemapping-that-can-use-unhashable-objects-a/ > so fingers crossed, I'm just hoping that we're going in the right > direction. > Drat, should have scrolled down one more page on the activestate recipe, Stephen D'Aprano comment. This is very ingenious, but I wouldn't want to touch it with a ten foot pole for production code Eric Snow replied. Oh yeah. I wouldn't use it in production either. :) I expect you could iron out the wrinkles, but there are better solutions. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Thu Jul 16 03:27:46 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 16 Jul 2015 08:27:46 +0100 Subject: Mapping, with sequence as key, wildcard and subsequence matching In-Reply-To: <85pp3stw45.fsf@benfinney.id.au> References: <85k2u0vpis.fsf@benfinney.id.au> <85bnfcve7w.fsf@benfinney.id.au> <85380ovcix.fsf@benfinney.id.au> <85pp3stw45.fsf@benfinney.id.au> Message-ID: On 16/07/2015 08:11, Ben Finney wrote: > Zachary Ware writes: > >> On Thu, Jul 16, 2015 at 1:31 AM, Ben Finney wrote: >>> Fine by me. What is the mapping API that needs to be implemented though? >> >> Have a look at collections.MutableMapping. > > Thank you, that's great! I hadn't realised the ?collections? module had > such comprehensive coverage of Python built-in type APIs. > You might get some inspiration from http://nullege.com/codes/search/collections.MutableMapping -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From antoon.pardon at rece.vub.ac.be Thu Jul 16 03:31:44 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Thu, 16 Jul 2015 09:31:44 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> Message-ID: <55A75DE0.1070101@rece.vub.ac.be> On 07/16/2015 12:43 AM, Gregory Ewing wrote: > Antoon Pardon wrote: >> But it doesn't need to be all or nothing. How about the following possibility. >> When the runtime detects a serie of tail calls, it will keep the bottom three >> and the top three backtrace records of the serie. > Whatever value you choose for N, keeping only the > first/last N traceback frames will lead to someone > tearing their hair out. I would say, that someone should get over himself. Traceback are not the only or even the most useful tool for debugging code. The current stack trace doesn't even contain the value's of the variables on the stack. So in case of Terry Reedy's example that stack trace would IMO have been next to useless. > I recently had an experience with some Java code > running in an environment which believed that nobody > would want to see more than about 30 traceback levels, > and chopped the rest off. Of course, the information > I desperately wanted was buried deeper than that... So? My experience is, that if you need to dig that deep in a stack trace, to find the information you need, you get it easier and faster by turning debug level logging on and going through the logs. YMMV. I also have to wonder, In my suggestion you would only start to loose traceback records after six consecutive tail calls. That IMO strongly suggest a loop. Most people suggest such a loop should be written iteratively. So my example would allow to keep 6 trace back records through such a loop while the iterative version would only keep one trace back record. But no one seems to be tearing their hair out for not having trace back records of the previous run through a loop. Yet you protest when trace back records disappear when such a loop is written recursively. > So, -1 on any arbitrarily chosen traceback cutoff. Noted. It just doesn't carry much weight with me. -- Antoon Pardon From antoon.pardon at rece.vub.ac.be Thu Jul 16 03:45:26 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Thu, 16 Jul 2015 09:45:26 +0200 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> Message-ID: <55A76116.7070708@rece.vub.ac.be> On 07/15/2015 11:19 PM, Terry Reedy wrote: > On 7/15/2015 5:29 AM, Antoon Pardon wrote: >> >> Can you explain how you would do mutual recursive functions? >> Suppose I start with the following: >> >> def even(n): >> True if n == 0 else odd(n - 1) >> >> def odd(n): >> False if n == 0 else even(n - 1) >> >> How do I rewrite those with your module? > > I will not answer for Baruchel's tco module. However, combining the > two bodies and following the general rule of replacing tail recursive > calls with assignments inside a while loop gives us > > def even(n): > return not odd(n) > > def odd(n): > while True: > if not n: > return False > else: > n -= 1 > if not n: > return True > else: > n -= 1 > [ ... ] > > I believe that this pattern should work with any set of mutually > recursive functions that always call each other in cyclic order. A > more elaborate version does not have this limitation. > Nice of you to illustrate the warping involved. ;-) -- Antoon Pardon. From steve+comp.lang.python at pearwood.info Thu Jul 16 04:07:03 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 16 Jul 2015 18:07:03 +1000 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> Message-ID: <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> On Wednesday 15 July 2015 19:29, Antoon Pardon wrote: > Suppose I start with the following: > > def even(n): > True if n == 0 else odd(n - 1) > > def odd(n): > False if n == 0 else even(n - 1) Well, both of those always return None, so can be optimized to: even = odd = lambda x: None :-) Fixing the obvious mistake (failing to return anything) leads to the next mistake. When all you have is a hammer, everything looks like a nail. def even(n): return n%2 == 0 def odd(n): return n%2 != 0 are faster, easier to understand, and don't turn into an infinite loop if you pass a negative integer. The point is, people keep insisting that there are a vast number of algorithms which are best expressed using recursion and which require TCO to be practical, and yet when asked for examples they either can't give any examples at all, or they give examples that are not well-suited to recursion. Or, at best, examples which are equally good when written either using recursion or iteration. I do believe that such examples surely must exist. But I'm yet to see one. -- Steve From songofacandy at gmail.com Thu Jul 16 04:13:12 2015 From: songofacandy at gmail.com (INADA Naoki) Date: Thu, 16 Jul 2015 17:13:12 +0900 Subject: Where is "pyvenv.py" in new Python3.4 environment on CentOS7? In-Reply-To: References: Message-ID: How about `python3 -m venv` ? On Thu, Jul 16, 2015 at 6:54 AM, David Karr wrote: > I'm just learning more about Python (although I've been a Java dev for > many years, and C/C++ before that). > > A book I'm reading (Learning Python Network Programming) refers to running > "pyvenv". I can find this in my Win7 environment, but I was planning on > using my CentOS7 VM for most of this. I have both "python" (Python 2) and > "python3.4" installed. I noticed a "python-virtualenv.noarch" package, but > it said it was already installed. > > Can someone elaborate on where I should be able to find or install this? > > (I tried asking this on the #python IRC channel, but I guess I couldn't > yell loud enough.) > -- > https://mail.python.org/mailman/listinfo/python-list > -- INADA Naoki -------------- next part -------------- An HTML attachment was scrubbed... URL: From robin at reportlab.com Thu Jul 16 05:13:29 2015 From: robin at reportlab.com (Robin Becker) Date: Thu, 16 Jul 2015 10:13:29 +0100 Subject: A new module for performing tail-call elimination In-Reply-To: <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> Message-ID: <55A775B9.3050307@chamonix.reportlab.co.uk> On 16/07/2015 09:07, Steven D'Aprano wrote: ......... > Fixing the obvious mistake (failing to return anything) leads to the next > mistake. When all you have is a hammer, everything looks like a nail. > > def even(n): > return n%2 == 0 > > def odd(n): > return n%2 != 0 > ...... what about >>> def odd(n): ... return bool(n%2) ... >>> def even(n): ... return not odd(n) ... not much more complex, but the logic for A(n) and not A(n) is only done once. Not really much to do with TCO though. -- Robin Becker From lac at openend.se Thu Jul 16 05:27:35 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 16 Jul 2015 11:27:35 +0200 Subject: Mapping, with sequence as key, wildcard and subsequence matching In-Reply-To: Message from Ben Finney of "Thu, 16 Jul 2015 16:31:50 +1000." <85380ovcix.fsf@benfinney.id.au> References: <85k2u0vpis.fsf@benfinney.id.au> <85bnfcve7w.fsf@benfinney.id.au> <85380ovcix.fsf@benfinney.id.au> Message-ID: <201507160927.t6G9RZsg018968@fido.openend.se> I'm ill, so I am not trusting my own reasoning further than I can jump (not too far today) but I don't think you have a problem that is well-suited to a mapping. But it seems like a perfect fit for a tree, to me. Laura From robin at reportlab.com Thu Jul 16 05:28:07 2015 From: robin at reportlab.com (Robin Becker) Date: Thu, 16 Jul 2015 10:28:07 +0100 Subject: A new module for performing tail-call elimination In-Reply-To: <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> Message-ID: <55A77927.7090406@chamonix.reportlab.co.uk> .......... > > The point is, people keep insisting that there are a vast number of > algorithms which are best expressed using recursion and which require TCO to > be practical, and yet when asked for examples they either can't give any > examples at all, or they give examples that are not well-suited to > recursion. Or, at best, examples which are equally good when written either > using recursion or iteration. > > I do believe that such examples surely must exist. But I'm yet to see one. .... I believe the classic answer is Ackermann's function http://demonstrations.wolfram.com/RecursionInTheAckermannFunction/ which is said to be not "primitive recursive" ie cannot be unwound into loops; not sure whether that implies it has to be recursively defined or can perhaps be broken down some other way. For more eye-glazing http://math.stackexchange.com/questions/75296/what-is-the-difference-between-total-recursive-and-primitive-recursive-functions -- Robin Becker From marko at pacujo.net Thu Jul 16 05:56:50 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 16 Jul 2015 12:56:50 +0300 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> Message-ID: <87a8uwl925.fsf@elektro.pacujo.net> Robin Becker : > which is said to be not "primitive recursive" ie cannot be unwound > into loops; not sure whether that implies it has to be recursively > defined or can perhaps be broken down some other way. For more > eye-glazing You only need a single while loop plus primitive recursion to implement total recursion. Marko From antoon.pardon at rece.vub.ac.be Thu Jul 16 06:41:06 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Thu, 16 Jul 2015 12:41:06 +0200 Subject: A new module for performing tail-call elimination In-Reply-To: <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> Message-ID: <55A78A42.4090506@rece.vub.ac.be> On 07/16/2015 10:07 AM, Steven D'Aprano wrote: > On Wednesday 15 July 2015 19:29, Antoon Pardon wrote: > >> Suppose I start with the following: >> >> def even(n): >> True if n == 0 else odd(n - 1) >> >> def odd(n): >> False if n == 0 else even(n - 1) > Well, both of those always return None, so can be optimized to: > > even = odd = lambda x: None > > :-) > > Fixing the obvious mistake (failing to return anything) leads to the next > mistake. When all you have is a hammer, everything looks like a nail. > > def even(n): > return n%2 == 0 > > def odd(n): > return n%2 != 0 > > > are faster, easier to understand, and don't turn into an infinite loop if > you pass a negative integer. Nice of you to illustrate how being pedantic about something, can make a response useless with regard to the intended original question. Sure your implementation for solving this particular problem is better if the purpose is to actually solve this problem. But it is useless as an illustration for the question I'm asking, which was about how to use a particular module. > The point is, people keep insisting that there are a vast number of > algorithms which are best expressed using recursion and which require TCO to > be practical, and yet when asked for examples they either can't give any > examples at all, or they give examples that are not well-suited to > recursion. Or, at best, examples which are equally good when written either > using recursion or iteration. So what did you expect? That I should give a real world example here with lots of details that would only detract from the information I'm looking for, just so that your curiosity would be satisfied? I'm not here to satisfy your or anyone else's curiosity. Certainly not when that curiosity often enough is just a pretext for donning the role of judge or arbiter and where any simplification that was done to make the example better understandable is siezed upon as a reason to dismiss it, because one looks at it litterally, like you do above, and is unable or unwilling to understand the spirit of the example. -- Antoon Pardon From DLipman~NOSPAM~ at Verizon.Net Thu Jul 16 06:54:38 2015 From: DLipman~NOSPAM~ at Verizon.Net (David H. Lipman) Date: Thu, 16 Jul 2015 06:54:38 -0400 Subject: Why pay DICE When TheGongzuo.com is !! FREE !! In-Reply-To: References: Message-ID: >> "Steve Hayes" wrote in message >> news:gaibqatads4eamjchr9k4f5tau30un2pdu at 4ax.com... >> >> On Tue, 14 Jul 2015 17:31:31 -0700 (PDT), trentonwesley10 at gmail.com >> wrote: >> >>> Greetings! >>> You been Invited as a Beta User for TheGongzuo.com ( Absolutely Extended >>> Trial). >>> We bring to you TheGongzuo.com, Top notch highly talented IT >>> (Information Technology / Software Industry) skilled Professional >>> Candidates, >> >> So what does it actually DO? >> >> I'm assuming that it's some kind of enhancement for Python, but why >> would anyone actually use it? Who cares. They are a spammer. Who cares what they do, the fact they spam means they are unethical and you should NOT use their services. They ask "Why pay DICE When TheGongzuo.com is !! FREE !!", the answer is DICE is ethical and they don't spam. They have added the following to the message... "This message is sent in compliance with the new email bill section 301. Under Bill S.1618 TITLE III passed by the 105th US Congress, this message cannot be considered SPAM as long as we include the way to be removed, Paragraph (a)(c) of S.1618, further transmissions to you by the sender of this email will be stopped if you by send a response of "REMOVE" in the subject line of the email, we will remove you immediately from subscription." This is Usenet which is tied an email list. Such appended text is inappropriate as they posted to Google Groups which is a Web Front-End ( HTTP/HTTPS ) to Usenet ( NNTP ). However lets assume it was sent via email. They use a BS disclaimer "Under Bill S.1618 TITLE III passed by the 105th US Congress,". That's false. It was NOT passed. Even if it had been passed, it would have been superseded by the US Can Spam Act and Amendments. That is the law, not Bill S.1618 TITLE III which never became law. If you see the appended text "Under Bill S.1618 TITLE III passed by the 105th US Congress,", now you also know they are complete morons. Furthermore, the IP address is 49.206.15.227. which is ACTFIBERNET-Secundrabad, Beam Telecom Pvt Ltd of India. -- Dave Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk http://www.pctipp.ch/downloads/dl/35905.asp From rosuav at gmail.com Thu Jul 16 07:11:16 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Jul 2015 21:11:16 +1000 Subject: A new module for performing tail-call elimination In-Reply-To: <55A78A42.4090506@rece.vub.ac.be> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> Message-ID: On Thu, Jul 16, 2015 at 8:41 PM, Antoon Pardon wrote: >> Fixing the obvious mistake (failing to return anything) leads to the next >> mistake. When all you have is a hammer, everything looks like a nail. >> >> def even(n): >> return n%2 == 0 >> >> def odd(n): >> return n%2 != 0 >> >> >> are faster, easier to understand, and don't turn into an infinite loop if >> you pass a negative integer. > > Nice of you to illustrate how being pedantic about something, can > make a response useless with regard to the intended original question. > > Sure your implementation for solving this particular problem is better > if the purpose is to actually solve this problem. But it is useless as > an illustration for the question I'm asking, which was about how to > use a particular module. Once again, tail call optimization is used as a way to make something more efficient that shouldn't need to be done at all. "Bubble sort takes too long when I give it 1000 elements. How can I make it faster?" Before looking at code improvements or language improvements, it's crucial to do algorithmic improvements. The recursive even() and odd() functions are O(n), the modulo ones are O(1). Bubble sort is simply a terrible way to sort long lists. Time spent optimizing bubble sort is time utterly and totally wasted, because you'll get more benefit by switching to quicksort, insertion sort, or a hybrid like Timsort. Time spent eliminating tail call stack frames is equally useless if a small algorithmic change can eliminate the recursion altogether. That's why we need examples that *can't* be trivially reimplemented some other way. Unless, of course, *all* TCO examples, even real-world ones, could be trivially reimplemented some other way, a theory which is gaining currency... ChrisA From alain at universite-de-strasbourg.fr.invalid Thu Jul 16 07:23:47 2015 From: alain at universite-de-strasbourg.fr.invalid (Alain Ketterlin) Date: Thu, 16 Jul 2015 13:23:47 +0200 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> Message-ID: <87egk8qrb0.fsf@universite-de-strasbourg.fr.invalid> Antoon Pardon writes: > On 07/13/2015 05:44 PM, Th. Baruchel wrote: >> Hi, after having spent much time thinking about tail-call elimination >> in Python (see for instance http://baruchel.github.io/blog/ ), I finally >> decided to write a module for that. You may find it at: >> >> https://github.com/baruchel/tco >> >> Tail-call elimination is done for tail-recursion as well as for >> continuation-passing style (cps) in a consistent syntax for both usages. >> >> Any tail-recursive function having the suitable format for being >> embeddable in the Y combinator can be used here with no change at all >> (with the main difference that tail-calls will be eliminated), but other >> continuations can also be added > > Can you explain how you would do mutual recursive functions? > > Suppose I start with the following: > > def even(n): > True if n == 0 else odd(n - 1) > > def odd(n): > False if n == 0 else even(n - 1) > > > How do I rewrite those with your module? I'm not sure the module mentioned above has provision for that, but in any case the Y combinator has a corresponding fixed-point combinator called Y*. There is quite a bit of theory behind this, anybody interested can google, e.g., "Y combinator mutual recursion", whose first result is: http://stackoverflow.com/questions/4899113/fixed-point-combinator-for-mutually-recursive-functions -- Alain. From jeremy at jeremysanders.net Thu Jul 16 07:29:11 2015 From: jeremy at jeremysanders.net (Jeremy Sanders) Date: Thu, 16 Jul 2015 13:29:11 +0200 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A77927.7090406@chamonix.reportlab.co.uk> Message-ID: Robin Becker wrote: > I believe the classic answer is Ackermann's function > > http://demonstrations.wolfram.com/RecursionInTheAckermannFunction/ > > which is said to be not "primitive recursive" ie cannot be unwound into > loops; not sure whether that implies it has to be recursively defined or > can perhaps be broken down some other way. For more eye-glazing But am I right in thinking that TCO doesn't work for Ackermann's function, at least not as it's written down in the above page? J. From rosuav at gmail.com Thu Jul 16 07:45:28 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Jul 2015 21:45:28 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A75DE0.1070101@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> Message-ID: On Thu, Jul 16, 2015 at 5:31 PM, Antoon Pardon wrote: > On 07/16/2015 12:43 AM, Gregory Ewing wrote: > >> Antoon Pardon wrote: >>> But it doesn't need to be all or nothing. How about the following possibility. >>> When the runtime detects a serie of tail calls, it will keep the bottom three >>> and the top three backtrace records of the serie. >> Whatever value you choose for N, keeping only the >> first/last N traceback frames will lead to someone >> tearing their hair out. > > I would say, that someone should get over himself. > Traceback are not the only or even the most useful > tool for debugging code. The current stack trace > doesn't even contain the value's of the variables > on the stack. So in case of Terry Reedy's example > that stack trace would IMO have been next to useless. Actually, they do contain all of that (at least, they do in Py3 - not sure about Py2 as I haven't checked). You can poke around with the locals at every point on the stack: def f(x): if x < 10: g(x+10) return 5 def g(x): if x % 3: h(x + 2) return 7 def h(x): return 1/x try: x = -12 print(f(x)) except ZeroDivisionError as e: tb = e.__traceback__ while tb: fr = tb.tb_frame print("In function %s (%s:%d), x = %r" % ( fr.f_code.co_name, fr.f_code.co_filename, fr.f_lineno, fr.f_locals["x"], )) tb = tb.tb_next It's all there. And it's immensely helpful. ChrisA From antoon.pardon at rece.vub.ac.be Thu Jul 16 09:35:05 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Thu, 16 Jul 2015 15:35:05 +0200 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> Message-ID: <55A7B309.8080903@rece.vub.ac.be> On 07/16/2015 01:11 PM, Chris Angelico wrote: > On Thu, Jul 16, 2015 at 8:41 PM, Antoon Pardon > wrote: >>> Fixing the obvious mistake (failing to return anything) leads to the next >>> mistake. When all you have is a hammer, everything looks like a nail. >>> >>> def even(n): >>> return n%2 == 0 >>> >>> def odd(n): >>> return n%2 != 0 >>> >>> >>> are faster, easier to understand, and don't turn into an infinite loop if >>> you pass a negative integer. >> Nice of you to illustrate how being pedantic about something, can >> make a response useless with regard to the intended original question. >> >> Sure your implementation for solving this particular problem is better >> if the purpose is to actually solve this problem. But it is useless as >> an illustration for the question I'm asking, which was about how to >> use a particular module. > Once again, tail call optimization is used as a way to make something > more efficient that shouldn't need to be done at all. Once again, the intend of the example is ignored. The question was not about how tail call optimization could be done on this specific example. The question was about how it could be done generally and this example was just used as a vehicle to get the question more easily explained. > "Bubble sort takes too long when I give it 1000 elements. How can I > make it faster?" But that is not a similar question. A similar question would have been if someone would have trouble with making comparing items somehow parametric is his function. So he writes a bubblesort to illustrate that he somehow wants to specify on call time how items get compared. And what happens is that lots of people start critisizing the bubble sort and ignore the actual question, even though the question was not about bubble sort. Bubble sort was just used as a vehicle to easily explain the question. > Before looking at code improvements or language improvements, it's > crucial to do algorithmic improvements. But we were not looking at code improvements here. We were looking at how to use a particular module. > The recursive even() and odd() > functions are O(n), the modulo ones are O(1). Bubble sort is simply a > terrible way to sort long lists. Which are all beside the point. The intent of the even and odd functions was not to actually use them in production, but as a vehicle to ask someone on how to use his module. For anyone in this context to seize upon the particular implementation of those functions, is just making it clear he completly missed the specific intend and used these examples to get on his high horse. > Time spent optimizing bubble sort is > time utterly and totally wasted, because you'll get more benefit by > switching to quicksort, insertion sort, or a hybrid like Timsort. Time > spent eliminating tail call stack frames is equally useless if a small > algorithmic change can eliminate the recursion altogether. That depends on the purpose. When the purpose is to learn something, it may be usefull to spend time on code unfit for production, because such code is often more comprehensible than code for which tco would be actually useful. So here you are critisizing code meant to learn something, because it isn't useful. > That's why we need examples that *can't* be trivially reimplemented > some other way. These functions were not intented to provide such an example. I also think that was rather clear. So critisizing them because they are not is just disingenuous. > Unless, of course, *all* TCO examples, even real-world ones, could be > trivially reimplemented some other way, a theory which is gaining > currency... Of course they could be rather trivially reimplemented. They would also become rather ugly and less easy to comprehend. Here is one way to do the odd, even example. def even(n): return odd_even('even', n) def odd(n): return odd_even('odd', n) def odd_even(fn, n): while fn is not None: if fn == 'even': fn, n = (None, True) if n == 0 else ('odd', n - 1) elif fn == 'odd': fn, n = (None, False) if n == 0 else ('even', n - 1) else: raise ValueError("Unknown state: %s" % fn) return n Any collection of functions that tail calls each other can rather trivially be turned into a state machine like the above. You can just paste in the code of the individual functions and replace the return call combo's with an assignment indicating which 'function' is to be 'called' next and its arguments. -- Antoon Pardon From rosuav at gmail.com Thu Jul 16 09:47:59 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Jul 2015 23:47:59 +1000 Subject: A new module for performing tail-call elimination In-Reply-To: <55A7B309.8080903@rece.vub.ac.be> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> <55A7B309.8080903@rece.vub.ac.be> Message-ID: On Thu, Jul 16, 2015 at 11:35 PM, Antoon Pardon wrote: > Of course they could be rather trivially reimplemented. They would > also become rather ugly and less easy to comprehend. > > Here is one way to do the odd, even example. > > def even(n): > return odd_even('even', n) > > def odd(n): > return odd_even('odd', n) > > def odd_even(fn, n): > while fn is not None: > if fn == 'even': > fn, n = (None, True) if n == 0 else ('odd', n - 1) > elif fn == 'odd': > fn, n = (None, False) if n == 0 else ('even', n - 1) > else: > raise ValueError("Unknown state: %s" % fn) > return n > > Any collection of functions that tail calls each other can rather > trivially be turned into a state machine like the above. You can > just paste in the code of the individual functions and replace > the return call combo's with an assignment indicating which 'function' > is to be 'called' next and its arguments. That's not an algorithmic change, though. That's just a mechanical change, and a poorly-written one. My point was that I have yet to see anything that demands TCO and can't be algorithmically improved. The best so far has been a quicksort that uses TCO to guarantee a maximum on stack usage. ChrisA From antoon.pardon at rece.vub.ac.be Thu Jul 16 09:56:27 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Thu, 16 Jul 2015 15:56:27 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> Message-ID: <55A7B80B.6090905@rece.vub.ac.be> On 07/16/2015 01:45 PM, Chris Angelico wrote: > On Thu, Jul 16, 2015 at 5:31 PM, Antoon Pardon > wrote: >> >> I would say, that someone should get over himself. >> Traceback are not the only or even the most useful >> tool for debugging code. The current stack trace >> doesn't even contain the value's of the variables >> on the stack. So in case of Terry Reedy's example >> that stack trace would IMO have been next to useless. > Actually, they do contain all of that (at least, they do in Py3 - not > sure about Py2 as I haven't checked). You can poke around with the > locals at every point on the stack: Fine, I should have been more clear. The stack trace as it is generally produced on stderr after an uncought exception, doesn't contain the values of the variables on the stack. -- Antoon Pardon From rosuav at gmail.com Thu Jul 16 10:00:05 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 00:00:05 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A7B80B.6090905@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> Message-ID: On Thu, Jul 16, 2015 at 11:56 PM, Antoon Pardon wrote: > On 07/16/2015 01:45 PM, Chris Angelico wrote: >> On Thu, Jul 16, 2015 at 5:31 PM, Antoon Pardon >> wrote: >>> >>> I would say, that someone should get over himself. >>> Traceback are not the only or even the most useful >>> tool for debugging code. The current stack trace >>> doesn't even contain the value's of the variables >>> on the stack. So in case of Terry Reedy's example >>> that stack trace would IMO have been next to useless. >> Actually, they do contain all of that (at least, they do in Py3 - not >> sure about Py2 as I haven't checked). You can poke around with the >> locals at every point on the stack: > > Fine, I should have been more clear. > > The stack trace as it is generally produced on stderr after an uncought > exception, doesn't contain the values of the variables on the stack. Sure. So you catch it at top level and grab whatever info you need. In some frameworks, this is already done for you - an uncaught exception from application code drops you into a debugger that lets you explore and even execute code at any level in the stack. This would be destroyed by automated tail call optimization. ChrisA From antoon.pardon at rece.vub.ac.be Thu Jul 16 10:21:10 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Thu, 16 Jul 2015 16:21:10 +0200 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> <55A7B309.8080903@rece.vub.ac.be> Message-ID: <55A7BDD6.2030003@rece.vub.ac.be> On 07/16/2015 03:47 PM, Chris Angelico wrote: > On Thu, Jul 16, 2015 at 11:35 PM, Antoon Pardon > wrote: >> Any collection of functions that tail calls each other can rather >> trivially be turned into a state machine like the above. You can >> just paste in the code of the individual functions and replace >> the return call combo's with an assignment indicating which 'function' >> is to be 'called' next and its arguments. > That's not an algorithmic change, though. That's just a mechanical > change, and a poorly-written one. What did you expect when you talked about all tco examples (including real world ones) and the reimplementation being trivial? > My point was that I have yet to see > anything that demands TCO and can't be algorithmically improved. And how is this point relevant? Why should I care about what you have not seen? Will it give me new insights about my original question in this thread? -- Antoon Pardon From rosuav at gmail.com Thu Jul 16 10:27:03 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 00:27:03 +1000 Subject: A new module for performing tail-call elimination In-Reply-To: <55A7BDD6.2030003@rece.vub.ac.be> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> <55A7B309.8080903@rece.vub.ac.be> <55A7BDD6.2030003@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 12:21 AM, Antoon Pardon wrote: >> My point was that I have yet to see >> anything that demands TCO and can't be algorithmically improved. > > And how is this point relevant? Why should I care about what you have > not seen? Will it give me new insights about my original question in > this thread? I guess you shouldn't care, because to you, functional programming is an end in itself, XKCD 1270 style. You could alternatively show an example, if there are any, but if you'd rather just live the functional life, who am I to stop you? Go ahead. Write LISP code that runs in the Python interpreter, and then bemoan the stack limit. Meanwhile, I'll write Python code. ChrisA From antoon.pardon at rece.vub.ac.be Thu Jul 16 10:32:52 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Thu, 16 Jul 2015 16:32:52 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> Message-ID: <55A7C094.7060604@rece.vub.ac.be> On 07/16/2015 04:00 PM, Chris Angelico wrote: > On Thu, Jul 16, 2015 at 11:56 PM, Antoon Pardon > wrote: >> Fine, I should have been more clear. >> >> The stack trace as it is generally produced on stderr after an uncought >> exception, doesn't contain the values of the variables on the stack. > Sure. So you catch it at top level and grab whatever info you need. In > some frameworks, this is already done for you - an uncaught exception > from application code drops you into a debugger that lets you explore > and even execute code at any level in the stack. What is unclear about "as it is generally produced on stderr"? That you can do a whole lot of stuff, doesn't mean that this whole lot of stuff is part of what generally happens. When people on this list ask a person to include the stacktrace with the description of the problem, they don't mean something that includes the values of the variables. From antoon.pardon at rece.vub.ac.be Thu Jul 16 11:14:15 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Thu, 16 Jul 2015 17:14:15 +0200 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> <55A7B309.8080903@rece.vub.ac.be> <55A7BDD6.2030003@rece.vub.ac.be> Message-ID: <55A7CA47.4060202@rece.vub.ac.be> On 07/16/2015 04:27 PM, Chris Angelico wrote: > On Fri, Jul 17, 2015 at 12:21 AM, Antoon Pardon > wrote: >>> My point was that I have yet to see >>> anything that demands TCO and can't be algorithmically improved. >> And how is this point relevant? Why should I care about what you have >> not seen? Will it give me new insights about my original question in >> this thread? > I guess you shouldn't care, because to you, functional programming is > an end in itself, XKCD 1270 style. You are wrong and how is this relevant? I use the functional style when I think it is more useful way in implementing things. And that is in a minority of the cases. You not having seen anything that demands TCO and can't be algorithmically improved, doesn't change anything about that. You agreeing with me or not, doesn't change anything about that either. Please explain how it would make a difference for me, whether or not you were given such an example? > You could alternatively show an example, if there are any? As far as I can see, such an example is not relevant in this topic. It doesn't help in any way clarify on how the module written by the topic starter is to be used. You and steven just blundered into this topic, as if others need to use examples that satisfy your curiosity instead of examples helpful to get their own question accross. Behaving as if this topic is about convincing either of you and getting indignant when I don't accept that change in subject. And you are still behaving here as if I should indulge you, as if I somehow owe you such an example. -- Antoon Pardon From ian.g.kelly at gmail.com Thu Jul 16 12:17:09 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 16 Jul 2015 10:17:09 -0600 Subject: A new module for performing tail-call elimination In-Reply-To: <55A77927.7090406@chamonix.reportlab.co.uk> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A77927.7090406@chamonix.reportlab.co.uk> Message-ID: On Thu, Jul 16, 2015 at 3:28 AM, Robin Becker wrote: > .......... >> >> >> The point is, people keep insisting that there are a vast number of >> algorithms which are best expressed using recursion and which require TCO >> to >> be practical, and yet when asked for examples they either can't give any >> examples at all, or they give examples that are not well-suited to >> recursion. Or, at best, examples which are equally good when written >> either >> using recursion or iteration. >> >> I do believe that such examples surely must exist. But I'm yet to see one. > > .... > I believe the classic answer is Ackermann's function > > http://demonstrations.wolfram.com/RecursionInTheAckermannFunction/ > > which is said to be not "primitive recursive" ie cannot be unwound into > loops; not sure whether that implies it has to be recursively defined or can > perhaps be broken down some other way. My recollection -- and it's been awhile since I've studied computability theory so I may be distorting things here -- is that primitive recursive functions can be computed using for loops, i.e. loops where the number of iterations is bounded in advance, whereas non-primitive recursive functions require while loops. From rosuav at gmail.com Thu Jul 16 12:43:29 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 02:43:29 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A7C094.7060604@rece.vub.ac.be> References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 12:32 AM, Antoon Pardon wrote: > On 07/16/2015 04:00 PM, Chris Angelico wrote: >> On Thu, Jul 16, 2015 at 11:56 PM, Antoon Pardon >> wrote: >>> Fine, I should have been more clear. >>> >>> The stack trace as it is generally produced on stderr after an uncought >>> exception, doesn't contain the values of the variables on the stack. >> Sure. So you catch it at top level and grab whatever info you need. In >> some frameworks, this is already done for you - an uncaught exception >> from application code drops you into a debugger that lets you explore >> and even execute code at any level in the stack. > > What is unclear about "as it is generally produced on stderr"? That you > can do a whole lot of stuff, doesn't mean that this whole lot of stuff is > part of what generally happens. When people on this list ask a person > to include the stacktrace with the description of the problem, they > don't mean something that includes the values of the variables. True. That said, though, it's not a justification for dropping stack frames; even in the form that's printed to stderr, there is immense value in them. It may be possible to explicitly drop frames that a programmer believes won't be useful, but a general and automated dropping of tail-call information will do more harm than good. The fact that some frameworks can show _even more_ helpful information out of a traceback only makes this stronger. ChrisA From liik.joonas at gmail.com Thu Jul 16 12:50:22 2015 From: liik.joonas at gmail.com (Joonas Liik) Date: Thu, 16 Jul 2015 19:50:22 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: Wouldn't it be possible to have like a dynamically sized stack so that you can grow it endlessly with some acceptable overhead.. That would pretty much take care of the stack-overflow argument without many painful side effects on the semantics at least.. From rosuav at gmail.com Thu Jul 16 13:03:48 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 03:03:48 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 2:50 AM, Joonas Liik wrote: > Wouldn't it be possible to have like a dynamically > sized stack so that you can grow it endlessly > with some acceptable overhead.. > > That would pretty much take care of the stack-overflow > argument without many painful side effects on > the semantics at least.. The trouble with that is that it can quickly run you out memory when you accidentally trigger infinite recursion. A classic example is a simple wrapper function... def print(msg): print(ctime()+" "+msg) With the recursion limit at its default of 1000, this can't do more than 1000 iterations before the system detects that it's stuck. With an infinite stack, this could destroy your system memory and then finally terminate with MemoryError... if you're lucky. If you're not, the whole system could get wedged before this gets killed. (Imagine, for instance, a computer with a large hard disk devoted to virtual memory. Long before that's exhausted, the system will be practically unusable, because every little operation will require going back to the disk.) ChrisA From ethan at stoneleaf.us Thu Jul 16 13:04:26 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 16 Jul 2015 10:04:26 -0700 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: <55A7E41A.3050309@stoneleaf.us> On 07/16/2015 09:43 AM, Chris Angelico wrote: > True. That said, though, it's not a justification for dropping stack > frames; even in the form that's printed to stderr, there is immense > value in them. It may be possible to explicitly drop frames that a > programmer believes won't be useful, but a general and automated > dropping of tail-call information will do more harm than good. The > fact that some frameworks can show _even more_ helpful information out > of a traceback only makes this stronger. If we had a general mechanism then we would also need to have a setting somewhere so we could adjust which frames to keep when debugging. I must say I don't see much value in a stack trace that says a called b called c called a called b called c called a called ... -- particularly when the line quoted has only the variable names, not their values, so you can't see what's changing. Of this whole thread, though, I like the 'recurse' keyword proposal best -- I have no issues with the programmer specifying when to ditch the stack frame, but maybe that's my assembly roots showing. ;) -- ~Ethan~ From rantingrickjohnson at gmail.com Thu Jul 16 13:22:49 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 16 Jul 2015 10:22:49 -0700 (PDT) Subject: Keypress Input In-Reply-To: References: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> Message-ID: <92d31684-8003-4b9e-9f2a-925a421d05c6@googlegroups.com> On Wednesday, July 15, 2015 at 11:30:40 PM UTC-5, Michael Torrie wrote: > On 07/15/2015 07:03 PM, Rick Johnson wrote: > > > > I think you've missed the whole point of the OP's project. Obviously my reply was not only "too much to quote", but apparently, and sadly, "too much to read"! I don't know about anyone else here, but i would be cautious about replying to any post before i took the time to read the entire content. I mean, i'd wouldn't want to embarrass myself. But, I suppose this more evidence of the damage social media is doing to our collective attention spans. There are some studies that report an average attention span of only 8 seconds -- which is less than the attention span of a goldfish. AN EFFING GOLDFISH! CLOWN-FISH: Hello Dori! DORI: Who's Dori? I had read an article the other day about how "smart phones are making people dumb". However, by focusing on the phone, which is nothing more than a tool, the author ignored the real cause of this ubiquitous intelligence drain that is rotting our culture from the inside out. It's not the *PHONES* that making people dumb, it's the *CONTENT* people *CHOOSE* that is turning us into a society of drooling, superficial, and mindless gossip zombies. TWITTER BEING THE MOST DESTRUCTIVE AND EVIL OF THEM ALL! With Twitter, we have a communication medium that encourages teeny tiny thoughtless reactions to whatever "emotional drivel" happens to be churning around in the daily cesspools of what, for whatever "sociological reason", we still refer to as "News". Is the size of some morally corrupt celeb's butt really "news"? Or the love interest of various talent-less glitterati anything we should concern ourselves with? Heck, just a few days ago, another "lip singer" made front page world news simply by licking a donut! BY LICKING AN EFFING DONUT! Are our lives that pathetic? In the past there were at least a few educational programs on the tele, now even so called "educational channels" have devolved into train-wrecks of thought UNprovoking emotion, with episode after episode of "totally scripted reality TV" far more concerned with shock value than entertainment -- much less "education". I once believed that Facebook was the "bottom of the barrel" for social media -- BOY WAS I WRONG! It's seems there is no level that we, as a society will stoop, in the effort to destroy our capacity of intellectual evolution. So fire up those twitter engines and speed headlong into that wall of ignorant bliss! And don't bother trotting out the old cliche of "grab a fiddle" folks, because the unwashed masses are not refined enough to appreciate the "higher intellectual emotions" and the thoughtful introspection that such an instrument can produce, instead, grab a shiny rattle and shake it in front of their pasty little ignorant faces. For they can only understand simple concepts and the selfish emotions. >:-O = = = ___^ __ ^_____ ___'Modern-Society'___ From liik.joonas at gmail.com Thu Jul 16 13:34:20 2015 From: liik.joonas at gmail.com (Joonas Liik) Date: Thu, 16 Jul 2015 20:34:20 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: On 16 July 2015 at 20:03, Chris Angelico wrote: > > The trouble with that is that it can quickly run you out memory when > you accidentally trigger infinite recursion. A classic example is a > simple wrapper function... > > def print(msg): > print(ctime()+" "+msg) > > With the recursion limit at its default of 1000, this can't do more > than 1000 iterations before the system detects that it's stuck. With > an infinite stack, this could destroy your system memory and then > finally terminate with MemoryError... if you're lucky. If you're not, > the whole system could get wedged before this gets killed. (Imagine, > for instance, a computer with a large hard disk devoted to virtual > memory. Long before that's exhausted, the system will be practically > unusable, because every little operation will require going back to > the disk.) > That all sounds reasonable. However that can be looked another way. Soppose you have some code that traverses some tree, a strange imbalanced tree (say from some xml) It is, semantically at least, a reasonable aproach to process such a structure with some recursive function. Lets say we have a function that counts all
    • elements in a document for example. and recursively traverses the element tree. Because most xml is relatively flat (let's assume its rare to find more than 100 levels of nesting say) this function would perform perfectly well for most cases. however if some guy sent you an xml document with 1000 levels of nesting your program would crash. Now suddenly you have perfectly good functioning code that randomly crashes. because of some arbitrary limit. it most distinctly reminds me of a certain programming language that kills your thread after 30000 operations because you are obviously-in-an-infinite-loop. it leaves a very bad taste in my mouth. That 30k limit (much less lines of source code ofc) is the reason you need nasty hacks to do stuff like implement BigInteger. That 1k stack limit is the limit you cant use perfectly good code just because your input data has some weird quirk. This puts python on par with jass2 and this deeply saddens me. Now i admit that it is possible to have infinite recursion but it is also possiblew to have infinite loops. and we don't kill your code after 1000 iterations of a while loop so why should we treat recursion any differently? Having a user defined maximum stack limit might be a good idea, eg if my stack takes up 100MB its prolly broke, but it should be my duty as a programmer to specify such a limit, not have it inflicted upon me (worse, in a manner that cannot be changed!). From yoursurrogategod at gmail.com Thu Jul 16 13:39:47 2015 From: yoursurrogategod at gmail.com (yoursurrogategod at gmail.com) Date: Thu, 16 Jul 2015 13:39:47 -0400 Subject: How does a dictionary work exactly? Message-ID: Hello, I was trying to see how some have implemented a hashtable. I took a gather at dictobject.h/.c. It seems that underneath it all it's a linked list and that is used in order to store the actual information (I'm looking at PyDictEntry.) Am I correct in my assumption or is there more to this? I'm still looking into how new entries are handled. Thanks From rosuav at gmail.com Thu Jul 16 13:49:05 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 03:49:05 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 3:34 AM, Joonas Liik wrote: > That all sounds reasonable. However that can be looked another way. > Soppose you have some code that traverses some tree, a strange > imbalanced tree (say from some xml) > > It is, semantically at least, a reasonable aproach to process such a > structure with some recursive function. > Lets say we have a function that counts all
    • elements in a > document for example. and recursively traverses the element tree. > Because most xml is relatively flat (let's assume its rare to find > more than 100 levels of nesting say) this function would perform > perfectly well for most cases. > however if some guy sent you an xml document with 1000 levels of > nesting your program would crash. This sounds like a denial-of-service attack. If you can state that no reasonable document will ever have more than 100 levels of nesting, then you can equally state that cutting the parser off with a tidy exception if it exceeds 100 levels is safe. > Now i admit that it is possible to have infinite recursion but it is > also possiblew to have infinite loops. and we don't kill your code > after 1000 iterations of a while loop so why should we treat recursion > any differently? Partly because infinite recursion requires infinite storage too. If it truly is tail calls, then you can turn it into a while loop and not have the limit; otherwise, you run the risk of blowing out your RAM. > Having a user defined maximum stack limit might be a good idea, eg if > my stack takes up 100MB its prolly broke, but it should be my duty as > a programmer to specify such a limit, not have it inflicted upon me > (worse, in a manner that cannot be changed!). Actually, it is up to you. There's a default, but you can change it. >>> def recurse(n): return n and recurse(n-1) ... >>> recurse(998) 0 >>> recurse(999) (throws RuntimeError) >>> sys.getrecursionlimit() 1000 >>> sys.setrecursionlimit(5) >>> recurse(5) Traceback (most recent call last): File "", line 1, in File "", line 1, in recurse File "", line 1, in recurse File "", line 1, in recurse File "", line 1, in recurse RuntimeError: maximum recursion depth exceeded >>> sys.setrecursionlimit(5000) >>> recurse(5000) (throws RuntimeError with a gigantic traceback) >>> sys.setrecursionlimit(50000) >>> recurse(50000) Segmentation fault Though as you can see, CPython does have other issues. If you crank the recursion limit up far enough, you *will* blow out your C stack. Other Pythons may behave differently, and different builds of CPython may crash at different points. But within reason, you can expand this limit, and you can certainly shrink it (eg to reduce the effect of a tree-parser DOS attack). ChrisA From ethan at stoneleaf.us Thu Jul 16 13:54:35 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 16 Jul 2015 10:54:35 -0700 Subject: A new module for performing tail-call elimination In-Reply-To: <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> Message-ID: <55A7EFDB.6050208@stoneleaf.us> On 07/16/2015 01:07 AM, Steven D'Aprano wrote: > The point is, people keep insisting that there are a vast number of > algorithms which are best expressed using recursion and which require TCO to > be practical, and yet when asked for examples they either can't give any > examples at all, or they give examples that are not well-suited to > recursion. Or, at best, examples which are equally good when written either > using recursion or iteration. You mean toy examples? Toy examples serve useful purposes: - easy to understand - easy to write - esay to test as proof-of-concept (after all, if a routine can't handle a toy example, how is it going to handle real life?) With responses like these I can understand Antoon's position that folks are not arguing in good faith. -- ~Ethan~ From skip.montanaro at gmail.com Thu Jul 16 13:56:34 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 16 Jul 2015 12:56:34 -0500 Subject: How does a dictionary work exactly? In-Reply-To: References: Message-ID: > I was trying to see how some have implemented a hashtable. I took a gather at dictobject.h/.c. It seems that underneath it all it's a linked list and that is used in order to store the actual information (I'm looking at PyDictEntry.) > > Am I correct in my assumption or is there more to this? I'm still looking into how new entries are handled. The Python dictionary implementation has been pretty well optimized over the years, so it might not be the most easy-to-read code. You might actually try and latch onto a copy of dictobject.[ch] from a very old version of Python (1.5-ish). That will have much less in the way of speed tricks obfuscating the code. Very generally (I'm writing with a lot of water under the bridge since I last thought about this), a dictionary contains an array whose length is typically a power of two (2**n). When considering a key for insertion or lookup, a hash value is computed, and the last n bits of the resulting value are used as an index into that array. Each element of the array consists of a linked list of all the key/value pairs whose keys hash to that value. Once you've identified an element in the hash array, the linked list is traversed looking for the key. There are three operations: get, set, delete. Each operation has one of two actions to perform depending whether the key is found or not: * get - if found, return the corresponding value, if not, raise KeyError * set - if found, replace the old value with the new, if not, add a new key/value pair to the list * del if found, delete the key/value pair, if not, raise KeyError The challenge is to come up with a reasonable size hash array and a suitable hash function which balances the desire to not chew up all of memory with the desire to have very short lists. In Python's case, I believe that dictionaries with strings as keys (and the hash function used for strings) have been optimized for how Python's runtime works. Skip From ethan at stoneleaf.us Thu Jul 16 14:02:15 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 16 Jul 2015 11:02:15 -0700 Subject: A new module for performing tail-call elimination In-Reply-To: <55A7B309.8080903@rece.vub.ac.be> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> <55A7B309.8080903@rece.vub.ac.be> Message-ID: <55A7F1A7.9000203@stoneleaf.us> On 07/16/2015 06:35 AM, Antoon Pardon wrote: > On 07/16/2015 01:11 PM, Chris Angelico wrote: >> Unless, of course, *all* TCO examples, even real-world ones, could be >> trivially reimplemented some other way, a theory which is gaining >> currency... > > Of course they could be rather trivially reimplemented. They would > also become rather ugly and less easy to comprehend. > > Here is one way to do the odd, even example. > > def even(n): > return odd_even('even', n) > > def odd(n): > return odd_even('odd', n) > > def odd_even(fn, n): > while fn is not None: > if fn == 'even': > fn, n = (None, True) if n == 0 else ('odd', n - 1) > elif fn == 'odd': > fn, n = (None, False) if n == 0 else ('even', n - 1) > else: > raise ValueError("Unknown state: %s" % fn) > return n Wow -- definitely uglier and less easy to understand than the original (even if the original had had the error-checking). -- ~Ethan~ From liik.joonas at gmail.com Thu Jul 16 14:23:45 2015 From: liik.joonas at gmail.com (Joonas Liik) Date: Thu, 16 Jul 2015 21:23:45 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: On 16 July 2015 at 20:49, Chris Angelico wrote: > > This sounds like a denial-of-service attack. If you can state that no > reasonable document will ever have more than 100 levels of nesting, > then you can equally state that cutting the parser off with a tidy > exception if it exceeds 100 levels is safe. > This particular example does have that kind of smell.. my bad for being careless with examples. what if its not a ddos tho, maybe its just strange data? how about you run some genetic algorithm to optimise something, and you store a log of your progress as a tree structure. then you have a script to traverse that tree for some reason, maybe to analyse the history and optimise the parameters of the search in the future. when the problem is complex it might well require thousands of steps to get to the desired outcome.. but over time the log grows longer and longer. at first as the script is written it's probably tested on some rather small logs, but they grow over time so eventually your program will implode on completely reasonable input. notice that the tree grows at a constant rate with generations rather than ~log(n) so it will not reach a natural limit other than finding a satisfying solution. whether that limit be 1k or 8k there is no single limit that is reasonable for all use cases and the range you can vary it is rather restricted.. (notice: this example has the issue with the genetic algorithm being potentially expensive to run so it might not reach the 1k limit, but that does not mean there are not other problems that share this property. what I want to convey here is that not all tree traversal has a natural depth limit and there are cases where it will be hit even with completely natural inputs) > > Partly because infinite recursion requires infinite storage too. If it > truly is tail calls, then you can turn it into a while loop and not > have the limit; otherwise, you run the risk of blowing out your RAM. A valid argument. tho 100MB stack space vs infinite stack space is still very much distinct. For a long running program it might not even be a big issue if some of the stack (the very bottom) is swapped to disk as the top will be nice and warm in the cache. and yes such a program is not exactly common but just because it uses a lot of memory does not mean it has "frozen". it is the job of the programmer to say how much heap his program can use and it is also his job to say how much stack space is acceptable. also: def much_memory_1(str): return munch_memory_1(str+"munch much memory!") much_memory_1(str) --vs-- def much_memory_2(str): tmp = str[:] while True: tmp +="munch much memory!" return tmp # will never reach this much_memory_2(str) >> Having a user defined maximum stack limit might be a good idea, eg if >> my stack takes up 100MB its prolly broke, but it should be my duty as >> a programmer to specify such a limit, not have it inflicted upon me >> (worse, in a manner that cannot be changed!). > > Actually, it is up to you. There's a default, but you can change it. > >>>> def recurse(n): return n and recurse(n-1) > ... >>>> recurse(998) > 0 >>>> recurse(999) > (throws RuntimeError) >>>> sys.getrecursionlimit() > 1000 >>>> sys.setrecursionlimit(5) >>>> recurse(5) > Traceback (most recent call last): > File "", line 1, in > File "", line 1, in recurse > File "", line 1, in recurse > File "", line 1, in recurse > File "", line 1, in recurse > RuntimeError: maximum recursion depth exceeded >>>> sys.setrecursionlimit(5000) >>>> recurse(5000) > (throws RuntimeError with a gigantic traceback) >>>> sys.setrecursionlimit(50000) >>>> recurse(50000) > Segmentation fault ..as i recall reading from a certain stackoverflow post the limit was about 8000 and possibly varying.. From rosuav at gmail.com Thu Jul 16 14:29:42 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 04:29:42 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 4:23 AM, Joonas Liik wrote: > On 16 July 2015 at 20:49, Chris Angelico wrote: >> >> This sounds like a denial-of-service attack. If you can state that no >> reasonable document will ever have more than 100 levels of nesting, >> then you can equally state that cutting the parser off with a tidy >> exception if it exceeds 100 levels is safe. >> > This particular example does have that kind of smell.. my bad for > being careless with examples. > > what if its not a ddos tho, maybe its just strange data? > That's why you're allowed to change the default limit either direction. If you're guarding against a DOS, you can crank it down; if you're working with something where 1000 stack entries isn't unreasonable, you can crank it up. I honestly don't know what you'd want to do if 5000+ stack entries isn't enough, but if you're working with something *that* deeply nested, you probably know a lot more about what you're doing than I ever will. Maybe you could recompile CPython with a bigger stack? Give Jython or PyPy a try? No idea. But I'm sure it'd be possible somehow. ChrisA From rantingrickjohnson at gmail.com Thu Jul 16 14:30:04 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 16 Jul 2015 11:30:04 -0700 (PDT) Subject: Keypress Input In-Reply-To: References: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> Message-ID: <6d0248bd-415d-4801-bfde-acab06317da7@googlegroups.com> On Thursday, July 16, 2015 at 1:09:32 AM UTC-5, Terry Reedy wrote: > This really is a nice example. Your rationale for defining an app class > is the best I remember seeing. Well thank you Terry. Your many years of selfless altruistic offerings to this fine group are both inspiring and educational. And i can happily admit that you are no doubt much more of an asset to this group than i. > > def evtKeyDown(self, event): > > key = event.keysym.lower() > > alert = False Oops. I just noticed that i forgot to remove the "alert = False" line. It was an artifact from one of my earlier versions. It's obviously superfluous to we pyhtonistas, but it could become a source of confusion to the shadow lurkers. > > if key == 'r': > > self.config(bg='red') > > elif key == 'g': > > self.config(bg='green') > > elif key == 'b': > > self.config(bg='blue') > > else: > > Can condense block above to this easily extended code: (Replacing if > if/elif/elif/... chains, when possible, is part of mastering Python.) > > try: > self['bg'] = {'r':'red', 'g':'green', 'b':'blue'}[key] > except KeyError: Yes you make a good point. And i'm glad you injected this alternative, as it offers yet another fine "teaching moment" for the OP and this group. [Warning: Caveat ahead!] However, i must take exception with your claim that replacing "classical conditional chains" with Python's unofficial "pseudo case/switch" is key to: "mastering Python". I feel there are instances when a "classical condition chain" are more appropriate, and then other times, when the "pseudo switch/case" is superior. For me, I believe the "key to mastering Python" is not to choose one method over the other (as some sort of religious rule carved into stone), rather, to know when one method is more appropriate than the other. That's my person opinion anyway. > Adding parens to print, when there is a single object > being printed, has no effect in 2.x and makes the > statement work in 3.x. The following works the same in > both. > > print("Mainloop has returned") Yes, another fine teaching moment! But just to be clear of my intentions: I only write code in full 2.x compliance, or full 3.x compliance. And i do this because i don't want to inject any "implicit version confusion" into my source code. In fact, the only time i will mix the incompatible syntaxes is when i can wrap them explicitly in an exception handler. But since there is no exception to catch in this case, even that option would be unavailable to me. But again. The act of you pointing out this easily overlooked difference between print 2.x and print(3.x) is yet another opportunity at exploiting fundamental teaching moments as they pop up. Hey, who would ever have "thunk" that teaching could be as exciting and egotistically fulfilling as a game of wack-a-mole! O:-) From skip.montanaro at gmail.com Thu Jul 16 14:58:22 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 16 Jul 2015 13:58:22 -0500 Subject: How does a dictionary work exactly? In-Reply-To: <948FE9D4-63CF-4730-B5F0-675F780A2481@gmail.com> References: <948FE9D4-63CF-4730-B5F0-675F780A2481@gmail.com> Message-ID: On Thu, Jul 16, 2015 at 1:36 PM, yoursurrogategod at gmail.com wrote: > If I understand correctly, lookup would not be a constant, yes? On the contrary, that's what you desire, nearly constant time execution. To the greatest extent possible, you want the linked lists to be of length zero or one. Part of the magic is in figuring out good places to expand the size of the hash array. You don't want it to grow too big, but you still want most linked lists to be very short. The resize operation isn't done too often because it itself is expensive. I believe Python dicts start out with an overly large initial hash array (again, dredging up old memories of threads on python-dev) as an optimization to avoid lots of early resize operations. Skip From steve at pearwood.info Thu Jul 16 14:58:38 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 17 Jul 2015 04:58:38 +1000 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> Message-ID: <55a7fedd$0$1674$c3e8da3$5496439d@news.astraweb.com> On Thu, 16 Jul 2015 08:41 pm, Antoon Pardon wrote: > On 07/16/2015 10:07 AM, Steven D'Aprano wrote: >> On Wednesday 15 July 2015 19:29, Antoon Pardon wrote: >> >>> Suppose I start with the following: >>> >>> def even(n): >>> True if n == 0 else odd(n - 1) >>> >>> def odd(n): >>> False if n == 0 else even(n - 1) >> Well, both of those always return None, so can be optimized to: >> >> even = odd = lambda x: None >> >> :-) >> >> Fixing the obvious mistake (failing to return anything) leads to the next >> mistake. When all you have is a hammer, everything looks like a nail. >> >> def even(n): >> return n%2 == 0 >> >> def odd(n): >> return n%2 != 0 >> >> >> are faster, easier to understand, and don't turn into an infinite loop if >> you pass a negative integer. > > Nice of you to illustrate how being pedantic about something, can > make a response useless with regard to the intended original question. Just because your intention in giving that code was X, doesn't mean that others cannot use that code to also do Y. Your example of a mutually recursive pair of functions is perfectly fine as a toy example to demonstrate a point. But the fact that people can only come up with toy examples to demonstrate the uses of unbounded recursion is telling. That's *my* point. It's orthogonal to your point. > Sure your implementation for solving this particular problem is better > if the purpose is to actually solve this problem. But it is useless as > an illustration for the question I'm asking, which was about how to > use a particular module. True. But my comment doesn't stop the OP from answering your question. A single post can lead to multiple replies you know :-) >> The point is, people keep insisting that there are a vast number of >> algorithms which are best expressed using recursion and which require TCO >> to be practical, and yet when asked for examples they either can't give >> any examples at all, or they give examples that are not well-suited to >> recursion. Or, at best, examples which are equally good when written >> either using recursion or iteration. > > So what did you expect? That I should give a real world example here with > lots of details that would only detract from the information I'm looking > for, just so that your curiosity would be satisfied? A non-toy example would be nice. There are non-toy examples of recursion which are still simple enough to express in a few lines, like the usual recursive algorithm for inorder traversal of a binary tree: def inorder(node): if node is not None: inorder(node.left) visit(node.data) inorder(node.right) If you can't come up with a non-toy example of mutual recursion, then something which is *obviously* useless is better than something useful-looking but actually a poor example of recursion. To go back to the "if all you have is a hammer, everything looks like a nail" analogy: if I want to demonstrate a hammer, I can pick an actual useful task ("watch me build a chicken coop with a hammer, nails and timber"); or I can pick something obviously pointless to demonstrate the technique ("watch me nail this piece of wood to this other piece of wood"); but what I shouldn't do is demonstrate something *bad* ("watch me remove the battery from my iPhone by wacking it repeatedly with a hammer"). def spam(s): return s if len(s) > 50 else eggs(s + "spam") def eggs(s): return s if len(s) > 50 else spam("eggs" + s) > I'm not here to satisfy your or anyone else's curiosity. Fair enough. What are you here for? When you complain that Python doesn't have TCO, is your intent to persuade people that it should, with the ultimate aim to changing Python so that it gains TCO? If not, then what? -- Steven From steve at pearwood.info Thu Jul 16 14:58:54 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 17 Jul 2015 04:58:54 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: <55a7feed$0$1674$c3e8da3$5496439d@news.astraweb.com> On Fri, 17 Jul 2015 03:34 am, Joonas Liik wrote: > Now i admit that it is possible to have infinite recursion but it is > also possiblew to have infinite loops. and we don't kill your code > after 1000 iterations of a while loop so why should we treat recursion > any differently? Because a while loop which repeats to many times is annoying but harmless, but a function that recurses too many times will blow up the stack and cause a seg fault, possibly executing arbitrary memory as code. You want malware and viruses to take over your system? That's how you get malware and viruses to take over your system. > Having a user defined maximum stack limit might be a good idea, eg if > my stack takes up 100MB its prolly broke, but it should be my duty as > a programmer to specify such a limit, not have it inflicted upon me > (worse, in a manner that cannot be changed!). You mean sys.getrecursionlimit() and sys.setrecursionlimit()? -- Steven From davidmichaelkarr at gmail.com Thu Jul 16 15:13:12 2015 From: davidmichaelkarr at gmail.com (David Karr) Date: Thu, 16 Jul 2015 12:13:12 -0700 (PDT) Subject: Where is "pyvenv.py" in new Python3.4 environment on CentOS7? In-Reply-To: References: Message-ID: <54d216ec-5424-418f-b72e-bff870cd4f9b@googlegroups.com> On Thursday, July 16, 2015 at 1:14:22 AM UTC-7, INADA Naoki wrote: > How about `python3 -m venv` ? I guess that works, thanks. > On Thu, Jul 16, 2015 at 6:54 AM, David Karr wrote: > I'm just learning more about Python (although I've been a Java dev for many years, and C/C++ before that). > > > > A book I'm reading (Learning Python Network Programming) refers to running "pyvenv".? I can find this in my Win7 environment, but I was planning on using my CentOS7 VM for most of this.? I have both "python" (Python 2) and "python3.4" installed.? I noticed a "python-virtualenv.noarch" package, but it said it was already installed. > > > > Can someone elaborate on where I should be able to find or install this? > > > > (I tried asking this on the #python IRC channel, but I guess I couldn't yell loud enough.) > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > > > -- > > INADA Naoki? From liik.joonas at gmail.com Thu Jul 16 15:14:15 2015 From: liik.joonas at gmail.com (Joonas Liik) Date: Thu, 16 Jul 2015 22:14:15 +0300 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55a7feed$0$1674$c3e8da3$5496439d@news.astraweb.com> References: <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55a7feed$0$1674$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 16 July 2015 at 21:58, Steven D'Aprano wrote: > On Fri, 17 Jul 2015 03:34 am, Joonas Liik wrote: > >> Now i admit that it is possible to have infinite recursion but it is >> also possiblew to have infinite loops. and we don't kill your code >> after 1000 iterations of a while loop so why should we treat recursion >> any differently? > > Because a while loop which repeats to many times is annoying but harmless, > but a function that recurses too many times will blow up the stack and > cause a seg fault, possibly executing arbitrary memory as code. You want > malware and viruses to take over your system? That's how you get malware > and viruses to take over your system. That's just a buggy implementation, there are ways to extend the stack that nears its capacity, safely. > >> Having a user defined maximum stack limit might be a good idea, eg if >> my stack takes up 100MB its prolly broke, but it should be my duty as >> a programmer to specify such a limit, not have it inflicted upon me >> (worse, in a manner that cannot be changed!). > > You mean sys.getrecursionlimit() and sys.setrecursionlimit()? > ... and that buggy implementation means that when you sys.setrecursionlimit() you will overflow the stack and crash because the recursion limit is an aritificial safeguard and the underlying c buffer is not adjusted accordingly or at least so it would seem. https://docs.python.org/2/library/sys.html#sys.setrecursionlimit so as per the docs the programmer has no real control over how much stack his program can have. all you can say is "let me ignore the safeguard a little longer, i hope i wont crash the program" that is not the same as "can i please have a stack depth of 20000.. You are giving the programmer a choice between "run out of stack and crash" and "mutilate interpreter internals and crash or zero out the hard drive" this is not a real choice.. From aronbarsam at gmail.com Thu Jul 16 15:20:00 2015 From: aronbarsam at gmail.com (Aron Barsam) Date: Thu, 16 Jul 2015 20:20:00 +0100 Subject: how do you play python because i have gone on the website but i haven't managed to code? Message-ID: -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Thu Jul 16 15:34:12 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 16 Jul 2015 15:34:12 -0400 Subject: A new module for performing tail-call elimination In-Reply-To: <55A76116.7070708@rece.vub.ac.be> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> Message-ID: On 7/16/2015 3:45 AM, Antoon Pardon wrote: > On 07/15/2015 11:19 PM, Terry Reedy wrote: >> On 7/15/2015 5:29 AM, Antoon Pardon wrote: >>> >>> Can you explain how you would do mutual recursive functions? >>> Suppose I start with the following: >>> >>> def even(n): >>> True if n == 0 else odd(n - 1) >>> >>> def odd(n): >>> False if n == 0 else even(n - 1) >>> >>> How do I rewrite those with your module? >> >> I will not answer for Baruchel's tco module. However, combining the >> two bodies and following the general rule of replacing tail recursive >> calls with assignments inside a while loop gives us >> >> def even(n): >> return not odd(n) >> >> def odd(n): >> while True: >> if not n: >> return False >> else: >> n -= 1 >> if not n: >> return True >> else: >> n -= 1 >> [ ... ] >> >> I believe that this pattern should work with any set of mutually >> recursive functions that always call each other in cyclic order. A >> more elaborate version does not have this limitation. >> > > Nice of you to illustrate the warping involved. ;-) Glad you appreciate it. To me, the warping is no more than, and perhaps less than, and certainly less obnoxious than, the warping required when using Baruchel's tco module. (Opinions can vary, of course.) The result will definitely run faster than with B's tco. -- Terry Jan Reedy From marko at pacujo.net Thu Jul 16 15:45:09 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 16 Jul 2015 22:45:09 +0300 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> Message-ID: <87lhefanui.fsf@elektro.pacujo.net> Nobody seemed to notice that I just posted a fairly typical tail call function: ======================================================================== def setvalue(self, keyseq, value, offset=0): try: next = keyseq[offset] except IndexError: self.value = value return if next is Node.ANY: raise KeyError() try: child = self.children[next] except KeyError: self.children[next] = child = Node() child.setvalue(keyseq, value, offset + 1) ======================================================================== In the context, the tail call is at least as clear as the corresponding while/for loop. In the case of this function, tail call elimination is hardly needed because the key sequence is probably not all that long (and if it were, the accompanying lookup function would overflow the stack anyway). At any rate, it demonstrates how the idiom has its place in Python. Marko From tjreedy at udel.edu Thu Jul 16 15:45:45 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 16 Jul 2015 15:45:45 -0400 Subject: A new module for performing tail-call elimination In-Reply-To: <55A7F1A7.9000203@stoneleaf.us> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> <55A7B309.8080903@rece.vub.ac.be> <55A7F1A7.9000203@stoneleaf.us> Message-ID: On 7/16/2015 2:02 PM, Ethan Furman wrote: > On 07/16/2015 06:35 AM, Antoon Pardon wrote: >> Here is one way to do the odd, even example. >> >> def even(n): >> return odd_even('even', n) >> >> def odd(n): >> return odd_even('odd', n) >> >> def odd_even(fn, n): >> while fn is not None: >> if fn == 'even': >> fn, n = (None, True) if n == 0 else ('odd', n - 1) >> elif fn == 'odd': >> fn, n = (None, False) if n == 0 else ('even', n - 1) >> else: >> raise ValueError("Unknown state: %s" % fn) >> return n > > Wow -- definitely uglier and less easy to understand than the original > (even if the original had had the error-checking). What you call ugly is an example of the core of the proof that alternation and indefinite while looping are enough for turing completeness, and that no recursive syntax is needed. Another way to put it is that while loops perform recursion in the operational sense, as opposed to the syntactical sense. -- Terry Jan Reedy From ethan at stoneleaf.us Thu Jul 16 15:52:33 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 16 Jul 2015 12:52:33 -0700 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55a7feed$0$1674$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55A80B81.2070906@stoneleaf.us> On 07/16/2015 12:14 PM, Joonas Liik wrote: > You are giving the programmer a choice between "run out of stack and > crash" and "mutilate interpreter internals and crash or zero out the > hard drive" this is not a real choice.. +1 -- ~Ethan~ From ethan at stoneleaf.us Thu Jul 16 15:58:44 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 16 Jul 2015 12:58:44 -0700 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> <55A7B309.8080903@rece.vub.ac.be> <55A7F1A7.9000203@stoneleaf.us> Message-ID: <55A80CF4.30608@stoneleaf.us> On 07/16/2015 12:45 PM, Terry Reedy wrote: > On 7/16/2015 2:02 PM, Ethan Furman wrote: >> On 07/16/2015 06:35 AM, Antoon Pardon wrote: > >>> Here is one way to do the odd, even example. >>> >>> def even(n): >>> return odd_even('even', n) >>> >>> def odd(n): >>> return odd_even('odd', n) >>> >>> def odd_even(fn, n): >>> while fn is not None: >>> if fn == 'even': >>> fn, n = (None, True) if n == 0 else ('odd', n - 1) >>> elif fn == 'odd': >>> fn, n = (None, False) if n == 0 else ('even', n - 1) >>> else: >>> raise ValueError("Unknown state: %s" % fn) >>> return n >> >> Wow -- definitely uglier and less easy to understand than the original >> (even if the original had had the error-checking). > > What you call ugly is an example of the core of the proof that alternation and indefinite > while looping are enough for turing completeness, and that no recursive syntax is needed. > Another way to put it is that while loops perform recursion in the operational sense, as > opposed to the syntactical sense. And we add new constructs and new language features to make certain ways of thinking/programming easier -- async and await come to mind. ;) After all, we don't really even need while loops as we could get by with if and goto. -- ~Ethan~ From rantingrickjohnson at gmail.com Thu Jul 16 16:03:14 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 16 Jul 2015 13:03:14 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> Message-ID: On Wednesday, July 15, 2015 at 10:45:12 PM UTC-5, Chris Angelico wrote: > A GUI is another form of console. And a blindingly obvious association is another form of patronizing! What's next, are you going to tell us that a Volvo is a street-legal Scandinavian version of an armored personal carrier? Or perhaps you'll *WOW* us with your knowledge that a penis is merely another form of editable sausage? OBVIOUSLY YOUR "SAUSAGE" WAS CANNED IN VIENNA! > Not all programs are run in a situation where this makes > sense. Really? I thought every situation was exactly the same. How foolish am i? Oh please enlighten us with more of your wisdom! > Also, please don't post Py2-only code when the OP clearly > stated that 3.4.3 was being used... Chris i hate to burst you're little naive "vajayjay bubble", but a vast majority of the Python community is currently using, and will for many years continue using, Python<3.0. Just because they don't participate here => in your private self-aggrandizing blog <= does not mean they don't exist! See, unlike you, we didn't start writing Python code a few years ago. No, we skipped the "pike detour" through the intellectual ghetto, and we've been writing Python code for many years. And we have millions of lines of code in our repos! And we're not about to risk "exception hell" just so we can get a few "meager" new features and a "kewel" new print function. Besides, most of the new features have long ago been patched by creative programmers or are available via the: from __future__ import KEWEL_NEW_FEATURE I have a statement about what you can do with your print function, but executing that statement might result in this fine group throwing an IntegrityError. Therefor, i'll leave the "interpretation" of my statement as an academic exercise for all the Usenet eyeball-parsers. sys.exit(0) From rosuav at gmail.com Thu Jul 16 16:11:25 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 06:11:25 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> Message-ID: On Fri, Jul 17, 2015 at 6:03 AM, Rick Johnson wrote: > but a vast majority of the Python community is currently > using, and will for many years continue using, Python<3.0. Where's the latest survey results? I think the numbers don't agree with you any more. ChrisA From DLipman~NoSpam~ at Verizon.Net Thu Jul 16 16:13:38 2015 From: DLipman~NoSpam~ at Verizon.Net (David H. Lipman) Date: Thu, 16 Jul 2015 16:13:38 -0400 Subject: Why pay DICE When TheGongzuo.com is !! FREE !! In-Reply-To: References: Message-ID: <0aydnbjeKpjkjTXInZ2dnUU7-TmdnZ2d@giganews.com> ADDENDUM: TheGongzuo.com was bitch-slapped and there should no longer be any spam from them. -- Dave Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk http://www.pctipp.ch/downloads/dl/35905.asp From tjreedy at udel.edu Thu Jul 16 16:19:37 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 16 Jul 2015 16:19:37 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> Message-ID: On 7/16/2015 7:45 AM, Chris Angelico wrote: > On Thu, Jul 16, 2015 at 5:31 PM, Antoon Pardon > wrote: >> Traceback are not the only or even the most useful >> tool for debugging code. The current stack trace >> doesn't even contain the value's of the variables >> on the stack. So in case of Terry Reedy's example >> that stack trace would IMO have been next to useless. > > Actually, they do contain all of that (at least, they do in Py3 - not > sure about Py2 as I haven't checked). You can poke around with the > locals at every point on the stack: > > def f(x): > if x < 10: g(x+10) > return 5 > > def g(x): > if x % 3: h(x + 2) > return 7 > > def h(x): > return 1/x > > try: > x = -12 > print(f(x)) > except ZeroDivisionError as e: > tb = e.__traceback__ > while tb: > fr = tb.tb_frame > print("In function %s (%s:%d), x = %r" % ( > fr.f_code.co_name, > fr.f_code.co_filename, > fr.f_lineno, > fr.f_locals["x"], > )) > tb = tb.tb_next > > > It's all there. And it's immensely helpful. One of the features of Idle is Debug => Stack Viewer, which, when invoked immediately after an exception, displays a tree widget with a node for each stack frame in the traceback. Running your code without the extra try: except: stuff, so a traceback is displayed, I easily see that x is -12, -2, and 0 in f, g, and h. I suspect that this feature is not well known and is underused. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Thu Jul 16 16:30:36 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 16 Jul 2015 13:30:36 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> Message-ID: On Thursday, July 16, 2015 at 3:11:56 PM UTC-5, Chris Angelico wrote: > Where's the latest survey results? I think the numbers don't agree > with you any more. What? You think the handful of regulars on this list in any way shape or form somehow represents the multitude of *REAL* python programmers who work day in and day out in the trenches? ON THE FRONT LINES! Heck you're more naive than the BDFL: who gets a woody simply from gawking at that atrociously inaccurate TIOBI index! Oooh. Oooh. Python is moving up the list! Yeah, it's not just Python that's moving up. Besides, everybody knows his bots are out there manipulating the numbers! From emile at fenx.com Thu Jul 16 17:27:01 2015 From: emile at fenx.com (Emile van Sebille) Date: Thu, 16 Jul 2015 14:27:01 -0700 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> Message-ID: On Thursday, July 16, 2015 at 3:11:56 PM UTC-5, Chris Angelico wrote: > Where's the latest survey results? I think the numbers don't agree > with you any more. Not that there's a source for that info, but a quick survey of yahoo results certainly continues to show more v2 activity. --anytime-- python v3 -- 1430000 python v2 -- 1890000 --Past month-- python v3 -- 386000 python v2 -- 554000 Emile From torriem at gmail.com Thu Jul 16 17:27:58 2015 From: torriem at gmail.com (Michael Torrie) Date: Thu, 16 Jul 2015 15:27:58 -0600 Subject: Keypress Input In-Reply-To: <92d31684-8003-4b9e-9f2a-925a421d05c6@googlegroups.com> References: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> <92d31684-8003-4b9e-9f2a-925a421d05c6@googlegroups.com> Message-ID: <55A821DE.40105@gmail.com> On 07/16/2015 11:22 AM, Rick Johnson wrote: > On Wednesday, July 15, 2015 at 11:30:40 PM UTC-5, Michael Torrie wrote: >> On 07/15/2015 07:03 PM, Rick Johnson wrote: >>> >> >> I think you've missed the whole point of the OP's project. > > Obviously my reply was not only "too much to quote", but > apparently, and sadly, "too much to read"! I don't know about > anyone else here, but i would be cautious about replying to > any post before i took the time to read the entire content. I > mean, i'd wouldn't want to embarrass myself. I read a good deal of what you wrote, which is more than most do with such long, rambling posts. Good to know there were some good nuggets in there. This is as much as I read of your current post though. As soon as you started going off about gold fish, I'm out. It's true that attention spans are shorter these days. But it's also true there are ways of being concise. From torriem at gmail.com Thu Jul 16 17:29:48 2015 From: torriem at gmail.com (Michael Torrie) Date: Thu, 16 Jul 2015 15:29:48 -0600 Subject: Keypress Input In-Reply-To: References: <3fec5a1e-44e6-4e3c-ab01-2703f2911c50@googlegroups.com> <55A73355.40008@gmail.com> Message-ID: <55A8224C.7050703@gmail.com> On 07/16/2015 01:10 AM, Terry Reedy wrote: > On 7/16/2015 12:30 AM, Michael Torrie wrote: >> On 07/15/2015 07:03 PM, Rick Johnson wrote: >>> >> >> I think you've missed the whole point of the OP's project. He doesn't >> want to make a GUI. He simply wants to have his program do something >> like blink an LED when someone presses a big red button. He just wanted >> a quick way to test things out since his big red button can emulate a >> USB keyboard. So all he needed was a simple console app that can fetch >> keystrokes. In the end, though GPIO is very simple both electrically >> and in terms of Python, so that is the ultimate route he will go. If >> you read his last post you'll find he says this. > > Rick pretty much acknowledged what you said in this paragraph. > > "You may have solved your input capturing problem, and i > don't think a GUI is the preferred solution for a > graphically deficient device anyhow, but you may well need a > GUI in the future, and this would be a fine example from which > to learn." > > It is a fine example. Good to know. With some posters it's hard to glean the good bits from the ramblings. From greg.ewing at canterbury.ac.nz Thu Jul 16 18:41:40 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Fri, 17 Jul 2015 10:41:40 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> Message-ID: Antoon Pardon wrote: > On 07/16/2015 12:43 AM, Gregory Ewing wrote: > >>Whatever value you choose for N, keeping only the >>first/last N traceback frames will lead to someone >>tearing their hair out. > > I would say, that someone should get over himself. > Traceback are not the only or even the most useful > tool for debugging code. They're the one thing I miss the most whenever I have to debug something in an environment that doesn't provide them, though, > My experience is, that if you need to dig that deep > in a stack trace, to find the information you need, you > get it easier and faster by turning debug level logging > on and going through the logs. YMMV. That only helps if the code logs the information you need or can be easily modified to do so. In my case, it didn't and couldn't. > I also have to wonder, In my suggestion you would only start > to loose traceback records after six consecutive tail calls. > That IMO strongly suggest a loop. Not necessarily. Chains of calls very often go more than 6 levels deep. It's less likely that they would all happen to be tail calls, but it could happen without there being any looping or recursion involved. And the source of the problem you're trying to debug could be in *any* of the intermediate calls, not necessarily the first or last 3. -- Greg From magixx2006 at gmail.com Thu Jul 16 18:58:37 2015 From: magixx2006 at gmail.com (Alex) Date: Thu, 16 Jul 2015 18:58:37 -0400 Subject: ANN: eGenix PyRun - One file Python Runtime 2.1.0 In-Reply-To: References: <555346E3.4030400@egenix.com> <55535FE6.2090007@egenix.com> Message-ID: Do you have Python 2.7 64bit versions available for Solaris (10/11) x86/SPARC, AIX, and HP-UX IA/RISC? I've had the displeasure of having to install 64bit Python on Solaris and AIX and it's an experience I would not recommend even though OpenCSW and Perzl have done much of the legwork already. I'd also just be happy with any pointers to building PyRun or regular Python on such systems if such currently there exist no such builds. On Wed, May 13, 2015 at 10:34 AM, Cristiano Cortezia < cristiano.cortezia at gmail.com> wrote: > In one of the next releases we'll probably add a tool to bundle >> complete applications together with pyrun, perhaps even by >> recompiling it to include the application byte code files >> right in the binary like we do for the stdlib. > > > Well, that would be simply awesome. Looking forward to it. > > PS: you guys should definitely advertise this work on the embedded > software community. > > > 2015-05-13 11:29 GMT-03:00 M.-A. Lemburg : > >> On 13.05.2015 16:09, Cristiano Cortezia wrote: >> > Well I gave it a try, and it seems my assumptions were *somehow* true. >> > Here is what I got when running one of my apps in single shot mode >> (load, >> > run, terminate): >> > >> > *default python distribution* >> > total time 9.022s >> > ENOENT's count 7377 >> > >> > *pyrun* >> > total time 8.455s >> > ENOENT's count 3064 >> > >> > So, it indeed failed much less to open files, but I guess this didn't >> make >> > that much difference after all (500ms). >> >> PyRun has the advantage of being able to read the byte code >> directly from the binary (using memory mapping). However, >> it still needs to run the same startup machinery as Python >> itself. >> >> Note that startup time for Python was a lot worse before >> Python used the same approach as PyRun to compile in the >> parsed sysconfig data. >> >> > Perhaps it is because this app has some external dependencies (22 to be >> > precise) not bundled on pyrun that had to be scanned by the interpreter >> > anyway. If by any means we could bundle them all the same way, than it >> > could bring a much higher performance gain. But I guess it is not really >> > safe-feasible. >> >> It's certainly possible to use the pyrun build system to create >> bundles with more packages and tools included. >> >> The one we're shipping has most of the stdlib included, >> but leaves all the application code to reside on the >> sys.path or in a ZIP archive. >> >> In one of the next releases we'll probably add a tool to bundle >> complete applications together with pyrun, perhaps even by >> recompiling it to include the application byte code files >> right in the binary like we do for the stdlib. >> >> -- >> Marc-Andre Lemburg >> eGenix.com >> >> Professional Python Services directly from the Source (#1, May 13 2015) >> >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >> >>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/ >> >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ >> ________________________________________________________________________ >> 2015-05-13: Released mxODBC Connect 2.1.3 ... http://egenix.com/go75 >> 2015-05-11 : Released eGenix PyRun >> 2.1.0 ... http://egenix.com/go74 >> 2015-05-25 : PyWaw Summit 2015, >> Warsaw, Poland ... 12 days to go >> >> eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 >> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg >> Registered at Amtsgericht Duesseldorf: HRB 46611 >> http://www.egenix.com/company/contact/ >> > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Jul 16 19:24:01 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 09:24:01 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> Message-ID: On Fri, Jul 17, 2015 at 7:27 AM, Emile van Sebille wrote: > On Thursday, July 16, 2015 at 3:11:56 PM UTC-5, Chris Angelico wrote: > >> Where's the latest survey results? I think the numbers don't agree >> with you any more. > > > Not that there's a source for that info, but a quick survey of yahoo results > certainly continues to show more v2 activity. > > --anytime-- > python v3 -- 1430000 > python v2 -- 1890000 > > --Past month-- > python v3 -- 386000 > python v2 -- 554000 Yes, and this is skewed somewhat by the Linux distros that ship Python 2 as the system Python, which leads to automatic use of Py2 in various places. Even if you don't correct for that, these figures show *at most* 30-50% more Py2 usage than Py3, which hardly justifies Rick's statement that the "vast majority" of Python is 2.x. Different metrics differ in the exact figures, but none show a 99:1 ratio or even 90:10 for any recent stats. The most skewed I can find puts Py2 at about 90%, of which a significant slab is 2.6, and 3.4 didn't exist yet: https://alexgaynor.net/2014/jan/03/pypi-download-statistics/ (There are some 3.4 downloads in the stats, but they come from beta users; when that blog post was written, 3.4 final was still several months away.) And the post makes several caveats about repeated downloads from eg continuous integration systems, which naturally will tend to be skewed heavily toward the old stable version. No, the "vast majority" of Python is no longer on a single version. ChrisA From gary719_list1 at verizon.net Thu Jul 16 19:34:43 2015 From: gary719_list1 at verizon.net (Gary Roach) Date: Thu, 16 Jul 2015 16:34:43 -0700 Subject: password authentication failed In-Reply-To: References: <55A694AB.2020408@verizon.net> Message-ID: <55A83F93.4030403@verizon.net> On 07/15/2015 11:25 AM, Chris Angelico wrote: > On Thu, Jul 16, 2015 at 3:13 AM, Gary Roach wrote: >> Every time I try to do a python manage.py migrate I get: >> django.db.utils.OperationalError: FATAL: password >> authentication failed for user "postgres" >> FATAL: password authentication failed for user "postgres" >> >> >> DATABASES = { >> 'default': { >> 'USER': 'postgres', >> 'PASSWORD': 'xxxxxx', # A valid debian pw >> } >> } > PostgreSQL users are not the same as Unix users, and their passwords > aren't necessarily the same. I would recommend *not* using the > postgres user, which is the database superuser; instead, create a new > user explicitly. On most Debian PostgreSQL installations, you should > be able to invoke 'psql' while running as user 'postgres', either by > su'ing to postgres or with sudo, for instance: > > $ sudo sudo -u postgres psql > > That should get you into a database CLI as superuser. Your prompt > should look like this: > > postgres=# > > You should then be able to create a regular user, and grant > appropriate permissions: > > postgres=# create user archives password 'traded-links-linguistics-informal'; > CREATE ROLE > postgres=# grant all on database archivedb to archives; > GRANT > > (Make sure you have the semicolons at the ends, otherwise you'll think > it's done nothing. It's actually waiting for you to type more lines > for the same command, but the prompt difference is so subtle that it's > easy to think it's silently ignoring you.) > > Then you should be able to use user name 'archives' and password > 'traded-links-linguistics-informal' (of course, you don't want to use > that; that's just what my password generating parrot came up with) > instead of 'postgres' and whatever the Unix password was. > > Incidentally, I usually don't have any password on my postgres Unix > user, nor on the corresponding database users. Safer to use sudo, eg > to root and then down to postgres, as shown above. > > ChrisA I really appreciate the help Chris. I created a user archive with password 'xxxxxx' and changed the settings.py file accordingly. When I tried python manage.py migrate I got the following error with it's traceback: (archivedb)root at supercrunch:~/archivedb# python manage.py migrate Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute output = self.handle(*args, **options) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 93, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 19, in __init__ self.loader = MigrationLoader(self.connection) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in __init__ self.build_graph() File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 180, in build_graph self.applied_migrations = recorder.applied_migrations() File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 60, in applied_migrations return set(tuple(x) for x in self.migration_qs.values_list("app", "name")) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/query.py", line 162, in __iter__ self._fetch_all() File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/query.py", line 965, in _fetch_all self._result_cache = list(self.iterator()) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/query.py", line 1220, in iterator for row in compiler.results_iter(): File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 783, in results_iter results = self.execute_sql(MULTI) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 829, in execute_sql cursor.execute(sql, params) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: permission denied for relation django_migrations (archivedb)root at supercrunch:~/archivedb# I'm not at all sure what this means. Any help will be sincerely appreciated. Gary R. From greg.ewing at canterbury.ac.nz Thu Jul 16 19:41:39 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Fri, 17 Jul 2015 11:41:39 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55a7feed$0$1674$c3e8da3$5496439d@news.astraweb.com> Message-ID: Joonas Liik wrote: > https://docs.python.org/2/library/sys.html#sys.setrecursionlimit > so as per the docs the programmer has no real control over how much > stack his program can have. all you can say is "let me ignore the > safeguard a little longer, i hope i wont crash the program" that is > not the same as "can i please have a stack depth of 20000.. I don't think there's much that can be done about that. If CPython doesn't impose an artificial limit, then it's at the mercy of the C compiler and runtime system as to the handling of stack overflows. The only way for CPython to take total control of the stack situation would be to get the C stack out of the picture altogether, using techniques such as the original Stackless Python employed. But the BDFL has ruled out CPython ever going that way, because it would massively warp the C API. -- Greg From rosuav at gmail.com Thu Jul 16 19:46:45 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 09:46:45 +1000 Subject: Proposed keyword to transfer control to another function Message-ID: Out of the lengthy thread on tail call optimization has come one broad theory that might be of interest, so I'm spinning it off into its own thread. The concept is like the Unix exec[vlpe] family of functions: replace the current stack frame with a new one. This can be used for explicit tail recursion without repeated stack frames, or for a pre-check that then disappears out of the stack. Like any other feature, it can be misused to make debugging difficult, but among consenting adults, hopefully it can be used sensibly. Examples: # derived from Paul Rubin's example def quicksort(array, start, end): midp = partition(array, start, end) if midp <= (start+end)//2: quicksort(array, start, midp) transfer quicksort(array, midp+1, end) else: quicksort(array, midp+1, end) transfer quicksort(array, start, midp) def count_usage(func): @functools.wraps(func) def wrapper(*args, **kwargs): wrapper.usage += 1 transfer func(*args, **kwargs) wrapper.usage = 0 return wrapper Semantics: * Evaluate the function and all its arguments, exactly as per a current function call. * Leaving them on the stack, remove the current call frame and dispose of all its objects. * Finally, construct a new stack frame for the target function and transfer control to it. In effect, "transfer f()" is equivalent to "return f()", except that the current function finishes before the target is entered. Note that this is incompatible with 'try' and 'with' blocks, and is disallowed inside them. It may be safe to use 'transfer' from a 'finally' block, and possibly from an 'except' block that isn't followed by a 'finally', but otherwise, there's code to be executed after the target returns, ergo it can't be done with a direct transfer. Open for bikeshedding: What should the keyword be? We can't use "exec", which would match Unix and shell usage, because it's already used in a rather different sense in Python. Current candidates: "transfer", "goto", "recurse", and anything else you suggest. Possible alternate syntax: transfer func[, (arg1, arg2, arg3)[, {'kw1': val1, 'kw2': val2}]] This makes it very clear that this is NOT accepting an arbitrary expression, but MUST be used with a single function and its arguments. Downside: It doesn't look like a function call any more. Upside: It's easy to parse. Also, if the argument sequence is mandatory instead of optional, this doesn't conflict with the simpler syntax (which wouldn't be allowed to have a comma after it), so one can be added now and another added later, if necessary. Is there anything that I've missed out in speccing this up? I've a suspicion that this might turn out to be as complicated as 'yield from' in all its handling of edge cases. ChrisA From rosuav at gmail.com Thu Jul 16 19:53:37 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 09:53:37 +1000 Subject: password authentication failed In-Reply-To: <55A83F93.4030403@verizon.net> References: <55A694AB.2020408@verizon.net> <55A83F93.4030403@verizon.net> Message-ID: On Fri, Jul 17, 2015 at 9:34 AM, Gary Roach wrote: > On 07/15/2015 11:25 AM, Chris Angelico wrote: > >> You should then be able to create a regular user, and grant >> appropriate permissions: >> >> postgres=# create user archives password >> 'traded-links-linguistics-informal'; >> CREATE ROLE >> postgres=# grant all on database archivedb to archives; >> GRANT > > I really appreciate the help Chris. I created a user archive with password > 'xxxxxx' and changed the settings.py file accordingly. When I tried python > manage.py migrate I got the following error with it's traceback: > > (archivedb)root at supercrunch:~/archivedb# python manage.py migrate > [chomp] > django.db.utils.ProgrammingError: permission denied for relation > django_migrations This suggests that your new user doesn't have permissions set yet. Did you do the grant command as listed above? If so, you may have to also do this: $ sudo sudo -u postgres psql archivedb postgres=# grant all on all tables in schema X to archives; Replace X with the name of the database schema you use - possibly "public" or some other user name. You can list multiple schema names, separated by commas, if you need to. To list all schemas in the database: select distinct table_schema from information_schema.tables; Hope that helps! ChrisA From rantingrickjohnson at gmail.com Thu Jul 16 20:30:33 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 16 Jul 2015 17:30:33 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> Message-ID: <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> On Thursday, July 16, 2015 at 6:24:21 PM UTC-5, Chris Angelico wrote: Any attempt to translate downloads into *REAL* usage statistics is doomed to be unreliable. Chris, you're smarter than this! (1) for instance: Python2.x coders have been around long enough that they don't need to download as much from PyPi anymore. Whereas, Python3.x coders are more recent, therfor they will be downloading the majority of packages these days. (2) Also. Old and stable code bases do not change as much as new unstable code bases tend to do. Therfor, less Python2.x downloads (3) The numbers are falsified even more by 3.0 packages that are downloaded, but never actually used. Maybe the package was not what the downloaded expected it to be. I have downloaded many packages from PyPi and never used the majority of them. > > Even if you don't correct for that, these figures show *at > most* 30-50% more Py2 usage than Py3, which hardly > justifies Rick's statement that the "vast majority" of > Python is 2.x. > I think I've dispelled the validity of your assertion and the weakness inherent in your mental heuristic. As my logical reasoning demonstrates, your percentages of 30%-50% are, at best, on the *LOW* end of the real percentages of Python2.x usage. And i'm not talking about downloads. I'm talking about *REAL* code out in the wild. I talking about real applications out in the wild, or living on hard drives doing *REAL* work. That's the *REAL* litmus test of Python! Not some false download statistics that can easily be tainted by a large number of 2.x coders downloading and "playing" with 3.0 source and packages, but never releasing or even creating anything substantial. Where is the substantial amount of Python3000 applications, code, and libraries? Sure you can point to PyPi, as it does contain 3.0 compatible code, but that code is sitting around doing nothing? But more importantly than *WHERE* -> *WHAT* are they doing? Are they making peoples lives better? Are they solving problems? Or are they just toys written to satisfy some childish need to play, before getting bored and moving on to real life projects? The fact is, the *REAL* code that is doing *REAL* work that is solving *REAL* problems, is doing it in Python2.x That's a fact Chris. And your smoke and mirror parlor tricks are not going to change that one bit. From craig.sirna at gmail.com Thu Jul 16 22:15:38 2015 From: craig.sirna at gmail.com (craig.sirna at gmail.com) Date: Thu, 16 Jul 2015 19:15:38 -0700 (PDT) Subject: Need assistance Message-ID: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> I need help writing a homework program. I'll write it, but I can't figure out how to incorporate what I have read in the book to work in code. The assignment wants us to take a users first, middle and last name in a single input ( name=('enter your full name: )). Then we must display the full name rearranged in Last, First Middle order. I tried to use the search function in Python to locate any spaces in the input. It spot back the index 5 (I used Craig Daniel Sirna) That is correct for the first space, but I can't figure out how to get it to continue to the next space. The indexing process is also a bit confusingto me. I get that I can use len(fullName) to set the length of the index, and how the index is counted, but after that I'm lost. I have emailed my professor a few times, but haven't gotten a response.(online course) Any help would be greatly appreciated. From torriem at gmail.com Thu Jul 16 22:40:35 2015 From: torriem at gmail.com (Michael Torrie) Date: Thu, 16 Jul 2015 20:40:35 -0600 Subject: Need assistance In-Reply-To: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: <55A86B23.9040702@gmail.com> On 07/16/2015 08:15 PM, craig.sirna at gmail.com wrote: > I need help writing a homework program. > > I'll write it, but I can't figure out how to incorporate what I have > read in the book to work in code. Can you post the code that you are currently working with? > The assignment wants us to take a users first, middle and last name > in a single input ( name=('enter your full name: )). > > Then we must display the full name rearranged in Last, First Middle > order. > > I tried to use the search function in Python to locate any spaces in > the input. It spot back the index 5 (I used Craig Daniel Sirna) Which search function are you talking about? Is it a string method or something else? One of the first string methods I learned about when I first started with Python was the .split() method. For example, in the interactive shell try this: >>> a="one,two,three" >>> a.split(',') Does this help at all? > That is correct for the first space, but I can't figure out how to > get it to continue to the next space. > The indexing process is also a bit confusingto me. Which part of indexing is confusing? The syntax for slicing? I admit I sometimes find it a bit complicated to know when and where to use -1 as the index. > I get that I can use len(fullName) to set the length of the index, > and how the index is counted, but after that I'm lost. > > I have emailed my professor a few times, but haven't gotten a > response.(online course) > > Any help would be greatly appreciated. Again, show us the code you have so far and maybe we can help you figure it out. From joseph.lee22590 at gmail.com Thu Jul 16 22:44:32 2015 From: joseph.lee22590 at gmail.com (Joseph Lee) Date: Thu, 16 Jul 2015 19:44:32 -0700 Subject: Need assistance In-Reply-To: <55A86B23.9040702@gmail.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55A86B23.9040702@gmail.com> Message-ID: <004201d0c03a$83159410$8940bc30$@gmail.com> Hi Michael, I have talked to this guy offlist (basically you gave him the answer (smiles)). Cheers, Joseph -----Original Message----- From: Python-list [mailto:python-list-bounces+joseph.lee22590=gmail.com at python.org] On Behalf Of Michael Torrie Sent: Thursday, July 16, 2015 7:41 PM To: python-list at python.org Subject: Re: Need assistance On 07/16/2015 08:15 PM, craig.sirna at gmail.com wrote: > I need help writing a homework program. > > I'll write it, but I can't figure out how to incorporate what I have > read in the book to work in code. Can you post the code that you are currently working with? > The assignment wants us to take a users first, middle and last name in > a single input ( name=('enter your full name: )). > > Then we must display the full name rearranged in Last, First Middle > order. > > I tried to use the search function in Python to locate any spaces in > the input. It spot back the index 5 (I used Craig Daniel Sirna) Which search function are you talking about? Is it a string method or something else? One of the first string methods I learned about when I first started with Python was the .split() method. For example, in the interactive shell try this: >>> a="one,two,three" >>> a.split(',') Does this help at all? > That is correct for the first space, but I can't figure out how to get > it to continue to the next space. > The indexing process is also a bit confusingto me. Which part of indexing is confusing? The syntax for slicing? I admit I sometimes find it a bit complicated to know when and where to use -1 as the index. > I get that I can use len(fullName) to set the length of the index, and > how the index is counted, but after that I'm lost. > > I have emailed my professor a few times, but haven't gotten a > response.(online course) > > Any help would be greatly appreciated. Again, show us the code you have so far and maybe we can help you figure it out. -- https://mail.python.org/mailman/listinfo/python-list From steve at pearwood.info Thu Jul 16 22:44:43 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 17 Jul 2015 12:44:43 +1000 Subject: Noob in Python. Problem with fairly simple test case References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> Message-ID: <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> It amuses me that this discussion started because the OP stated explicitly that he uses Python 3, and Rick gave an answer for Python 2. Rather than accept his mistake, Rick's defence is that practically nobody uses Python 3. (Presumably he means "apart from the guy who actually asked the question".) More comments below: On Fri, 17 Jul 2015 10:30 am, Ranting Rick wrote: > On Thursday, July 16, 2015 at 6:24:21 PM UTC-5, Chris Angelico wrote: > > Any attempt to translate downloads into *REAL* usage > statistics is doomed to be unreliable. Chris, you're smarter > than this! > > (1) for instance: Python2.x coders have been around long > enough that they don't need to download as much from PyPi > anymore. Whereas, Python3.x coders are more recent, therfor > they will be downloading the majority of packages these > days. Translation: "It's only old dinosaurs that use Python 2! Newcomers to the language are moving straight to Python 3!". > (2) Also. Old and stable code bases do not change as much as > new unstable code bases tend to do. Therfor, less Python2.x > downloads Translation: "Python 2 code is abandoned and no longer being actively maintained. If you want code that's actually being worked on, Python 3 is the place to go." > (3) The numbers are falsified even more by 3.0 packages that > are downloaded, but never actually used. Maybe the package > was not what the downloaded expected it to be. I have > downloaded many packages from PyPi and never used the > majority of them. Translation: "I don't use many libraries outside of what's in the standard library." I don't necessarily agree with *any* of these things, except for the initial comment that it's difficult to tell exactly how many people are using any specific version of Python. That at least is true. But: - I think it is ridiculous to suggest that just because somebody has been using Python for many years, they no longer need to download packages from PyPI. - While it's true that old stable code doesn't change, most heavily used code is under active development for security updates, bug fixes, and new features. This is *particularly* true now that Python 3 is in the picture. The great majority of non-abandoned packages on PyPI have been, or are in the process of being, updated to support Python 3. - It's a dishonest argument to suggest that people download Python 3 packages but never use them, without acknowledging that the same applies to Python 2 packages. By default, pip installs Python 2 packages, so if anything the rate of "downloaded but not used" errors will be slightly higher for Python 2 than Python 3. (It's easy for somebody to accidentally download an unwanted Python 2 version of a package, but hard to download an unwanted Python 3 version.) >> Even if you don't correct for that, these figures show *at >> most* 30-50% more Py2 usage than Py3, which hardly >> justifies Rick's statement that the "vast majority" of >> Python is 2.x. >> > > I think I've dispelled the validity of your assertion and > the weakness inherent in your mental heuristic. As my > logical reasoning demonstrates, your percentages of 30%-50% > are, at best, on the *LOW* end of the real percentages of > Python2.x usage. I believe Rick has misunderstood Chris' comment. Chris is not saying that 30-50% of Python users are using Python 2. He's saying that there are 30-50% *more* Python 2 users than Python 3, that is, for each Python 3 user there are 1.3 to 1.5 Python 2 users, i.e. about 40% Python 3 versus 60% Python 2. I think that undercounts two sorts of users: - those who are behind corporate or government firewalls; - and those using only packages available via their Linux distro's package management (yum, apt-get, etc) neither of whom will be represented well by PyPI downloads, and both of those will be mostly using Python 2. In other words, I think Chris is overcounting Python 3 users. My sense is that: - A lot of newcomers to Python are starting with Python 3; quite a few schools and colleges which teach Python now start with Python 3. From the evidence I've seen on the tutor mailing list, I'd estimate that newcomers are probably 40% Python 3. - Established Python users of the sort who spend a lot of time talking about Python on the Internet (e.g. here, on Reddit, Stackoverflow, blogging) tend to be relatively early adopters of Python 3. Reddit, for example, is extremely (and sometimes obnoxiously so) pro-Python 3. My estimate is that there's probably about 60% Python 3 usage. - Government and corporate users tend to be the opposite of early adaptors, more like late or never adaptors. The majority of them won't upgrade to 3 until the last possible minute. Some will never upgrade -- there are still people using Python 2.3 and even 1.5 who have no intention of upgrading to 2.7, let alone 3.x. My guess -- and this really is a plucked-from-thin-air guess -- is that probably 5% or less are using Python 3. I think that this group of users are the only ones where Rick's "vast majority" is plausible. - Scientists are heavy users of Python, and the majority of them will still be using Python 2. Although both numpy and scipy support Python 3, and so does IPython, scientists tend to be almost as conservative as government and corporate users. (They often *are* government and corporate users.) My guestimate is that there's probably about 15% Python 3 take-up. My take from all this is that overall, Python 3 take-up is probably around 10% of all Python users, but it's the most influential 10%: newbies learning Python 3 at school, the people chatting about Python on the Internet, writing blog posts and answering questions on Stackoverflow. Furthermore, there's probably another 30% who *want* to use Python 3 but cannot due to company policy. In my day job, I fall into that category: the company I work for use Python as their main language for our flagship application, and by policy we're stuck with using the default Python on Debian jessie, which is 2.6. The numbers of people actively hostile to Python 3 is probably less than 10%. The take-up rate of Python 3 is about where we would expect after less than seven years: - the majority of popular third-party libraries and frameworks now support Python 3; - one or two Linux distros have Python 3 as their system Python; - most of the big distros (Red Hat, Fedora, Centos, Debian, Ubuntu) are well into their preparation to do the same; - educators are well into the move to Python 3; - and popular awareness of Python 3 is high and mostly positive. -- Steven From torriem at gmail.com Thu Jul 16 23:00:46 2015 From: torriem at gmail.com (Michael Torrie) Date: Thu, 16 Jul 2015 21:00:46 -0600 Subject: Need assistance In-Reply-To: <004201d0c03a$83159410$8940bc30$@gmail.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55A86B23.9040702@gmail.com> <004201d0c03a$83159410$8940bc30$@gmail.com> Message-ID: <55A86FDE.6090109@gmail.com> On 07/16/2015 08:44 PM, Joseph Lee wrote: > Hi Michael, > I have talked to this guy offlist (basically you gave him the answer > (smiles)). > Cheers, > Joseph Sounds good. I had hoped to merely point him in the right way, and that he would put things together. I hope this is indeed the case. From craig.sirna at gmail.com Thu Jul 16 23:00:55 2015 From: craig.sirna at gmail.com (craig.sirna at gmail.com) Date: Thu, 16 Jul 2015 20:00:55 -0700 (PDT) Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: <3f8d701e-1d52-403d-9fc2-baa74e2159e4@googlegroups.com> I am in bed, on my phone, gotta be up in 4 hours for work. I will get back with you guys tomorrow after I take care of my Math class stuff. I need to step away from this for a day lol. Worst part...this is the C assignment and it's driving me crazy. I do recall the list fuction. But isn't it imperative that I have the index of the spaces in the string name? I use the Fullname.isspace function. From rosuav at gmail.com Thu Jul 16 23:01:42 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 13:01:42 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Jul 17, 2015 at 12:44 PM, Steven D'Aprano wrote: > My take from all this is that overall, Python 3 take-up is probably around > 10% of all Python users... Really? That low? Wow. I guess 90% could count as Rick's declared "vast majority", although that term does imply more like 99%. > Furthermore, there's probably another 30% who *want* to use Python 3 but > cannot due to company policy. In my day job, I fall into that category: the > company I work for use Python as their main language for our flagship > application, and by policy we're stuck with using the default Python on > Debian jessie, which is 2.6. Jessie's default should be 2.7, at least. Wheezy shipped 2.7, too; it's only Squeeze (now out of support) that didn't ship any 2.7.x Python. Are you sure you can't at least upgrade to 2.7? But yes, that's still not 3.x. ChrisA From ryexander at gmail.com Thu Jul 16 23:06:15 2015 From: ryexander at gmail.com (ryexander at gmail.com) Date: Thu, 16 Jul 2015 20:06:15 -0700 (PDT) Subject: Pyitect - Plugin architectural system for Python 3.0+ (feedback?) In-Reply-To: References: Message-ID: On Monday, June 22, 2015 at 1:18:08 PM UTC-6, Ian wrote: > On Mon, Jun 22, 2015 at 2:32 AM, Ben Powers wrote: > > on Tue, Jun 16, 2015 at 17:49 Ian Kelly wrote > > > >>On Mon, Jun 8, 2015 at 10:42 PM, Ben Powers wrote: > >>> #file.py > >>> from PyitectConsumes import foo > >>> > >>> class Bar(object): > >>> def __init__(): > >>> foo("it's a good day to be a plugin")> > > > >>I don't understand this example. Is "PyitectConsumes" the name of a > >>component or part of Pyitect? Or is "foo" the name of the component?> > > > > > > `PyitectComsumes` is a special module injected into sys.modules when the > > plugin module is imported and removed after the import is complete. it's > > name-space contains all the components declared as required in the plugin's > > .json > > So this import can only be performed when the module is loaded, not > later when a component's functionality is being invoked? > > >>> Plugins are loaded on demand when a component is loaded via > >>> > >>> System.load("")> > > > >>What's the difference between this and the "PyitectConsumes" import?> > > > > > > The PyitectConsumes import is for use inside plugins where dependencies are > > declared prior to import. > > > > System.load is for use in the application to load components. Plugins are > > not intended to know about the System they are being used in. > > > > > >>> Loaded pluginss do NOT store their module object in sys.modules> > > > >>What about imports of plugin-local modules that are performed inside > >>the plugins? Do those also get cleaned up from sys.modules?> > > > > > > Actually no... thats an oversight on my part. really I should temporally > > clone sys.modules inject the PyitectConsumes special module and then set it > > back to the original sys.modules dict after the import has been performed, > > that would secure the process more and prevent cluttering of sys.modules. > > It seems to me that this could create new problems. For example, > suppose a plugin being loaded imports urllib, and then later the > application tries to import urllib. It's not in sys.modules, so the > import framework loads it again, and now there are two copies of > urllib floating around in the interpreter. I think you actually need > to diff sys.modules and then remove anything that's added but only if > its path falls within the path of the plugin directory. > > The more that I think about this, I don't think that overloading the > import machinery like this is the right way for plugins to gain access > to components. If instead you just pass the module a context object > with a get_component method, then you won't have to muck around with > sys.modules as much, and the context object can remain available to > the plugin for later use. well I've done some reworking of the system trying to take the points you've brought up into account. your probably right this would be best done without mucking with the import machinery. passing a module a context object as you say would be a much preferred method. unless were using direct code execution on a module object's namespace like so filepath = os.path.join(self.path, self.file) module_name = os.path.splitext(self.file)[0] # exec mode requieres the file to be raw python package = False if module_name == '__init__': module_name = os.path.basename(self.path) package = True try: plugin = types.ModuleType(module_name) if package: plugin.__package__ = module_name plugin.__path__ = [self.path] sys.modules[module_name] = plugin else: plugin.__package__ = None sys.path.insert(0, self.path) with open(filepath) as f: code = compile(f.read(), filepath, 'exec') exec(code, plugin.__dict__) sys.path.remove(self.path) if package: del sys.modules[module_name] there is no way to make this context object available during the module load as importlib offer no functionality to provide a context during import. and if the context object WAS provided this way by injecting it into the module object's __dict__ before the plugin code was executed it would exist as a magic object with no formal definition you just have to trust that it exists. Also short of some convoluted declaration of globals in the plugin modules namespace, there is no way to pass in the plugin system so that the plugin can acquire components on demand short of the author of the plugin system author doing it themself by explicitly passing in an instance of the system. Ultimately I think it best to inject a special Module into sys.modules during the import and require the plugin author to pull anything they might need during load from that. if they need to save it for later there is always import PyitectConsumes as foobar then use foobar.componentName there after I think it far more pythonic to fail for lack of dependency during import of the plugin than during execution If the plugin author needs to do things on demand then the system author will need to make available a way to access the plugin system instance. I HAVE implemented the on_enable via providing a path to a callable in the imported module, that was a much better way than specifying a separate file. as to your point about plugin import like urllib getting duplicated if I implimented the sys.modules clone to keep it form getting cluttered... I not entirely sure this would be a bad thing. It would certinly lead to higher memory usage, depending on the dubed module's implementation it might cause undefined behavior... but I can think of a few way around that namely pre importing such modules before the plugin so that they would be in sys.modules before it gets cloned. I guess it comes down to the decision of "do I let sys.moudles get cluttered? or do I force plugin authors to declare external imports to avoided duplicate imports?" honestly I can't decide there. From joseph.lee22590 at gmail.com Thu Jul 16 23:12:13 2015 From: joseph.lee22590 at gmail.com (Joseph Lee) Date: Thu, 16 Jul 2015 20:12:13 -0700 Subject: Need assistance In-Reply-To: <3f8d701e-1d52-403d-9fc2-baa74e2159e4@googlegroups.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <3f8d701e-1d52-403d-9fc2-baa74e2159e4@googlegroups.com> Message-ID: <004701d0c03e$610b9a00$2322ce00$@gmail.com> Hi Craig: -----Original Message----- From: Python-list [mailto:python-list-bounces+joseph.lee22590=gmail.com at python.org] On Behalf Of craig.sirna at gmail.com Sent: Thursday, July 16, 2015 8:01 PM To: python-list at python.org Subject: Re: Need assistance >I am in bed, on my phone, gotta be up in 4 hours for work. I will get back with you guys tomorrow after I take care of my Math class stuff. I need to step away from this for a day lol. JL: Please rest well (you don't want to have a headache all night). >Worst part...this is the C assignment and it's driving me crazy. >I do recall the list fuction. But isn't it imperative that I have the index of the spaces in the string name? >I use the Fullname.isspace function. JL: No. Michael's hint lets you turn a string into a list. Good luck. Cheers, Joseph -- https://mail.python.org/mailman/listinfo/python-list From iecrahul at gmail.com Thu Jul 16 23:48:46 2015 From: iecrahul at gmail.com (rahul tiwari) Date: Fri, 17 Jul 2015 09:18:46 +0530 Subject: Fwd: PROBLEM IN INSTALLATION In-Reply-To: References: Message-ID: I want to import PIL package but every time this is showing error " no PIL module find" . plz suggest me how i can fix this problem. -- -- Rahul Tiwari Research Engineer Robospecies Technology Pvt. Ltd. -------------- next part -------------- An HTML attachment was scrubbed... URL: From orgnut at yahoo.com Thu Jul 16 23:49:46 2015 From: orgnut at yahoo.com (Larry Hudson) Date: Thu, 16 Jul 2015 20:49:46 -0700 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> Message-ID: On 07/15/2015 08:11 PM, Chris Angelico wrote: > On Thu, Jul 16, 2015 at 1:01 PM, Larry Hudson via Python-list > wrote: >> On 07/15/2015 05:11 AM, Chris Angelico wrote: >>> [snip] >>> >> In addition to using print(), in some places I like using input() instead, >> as in: >> input('x={}, y={} --> '.format(x, y)) >> Then the program stops at that point so you can study it. >> To continue just press , or Ctrl-C to abort. > > That's a neat trick, as long as you actually do have a console. IIDPIO > is extremely general (works across languages, across frameworks (eg a > web server), etc), but these kinds of extensions are pretty handy when > they make sense. > > ChrisA > Actually, that was an (unstated) point -- it's handy where it _can_ be used and makes sense, but it is certainly not a universal technique. Also I didn't specifically point out the '-->' that I use at the end of the string as an input prompt. Obviously, optional as well. -=- Larry -=- From rantingrickjohnson at gmail.com Fri Jul 17 00:15:22 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 16 Jul 2015 21:15:22 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> Message-ID: <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> On Thursday, July 16, 2015 at 9:44:56 PM UTC-5, Steven D'Aprano wrote: > [...] My take from all this is that overall, Python 3 > take-up is probably > around 10% of all Python users, All that rambling just to agree with me? My educated guess is a minimum of 75% still using Python2.x. But i'll take your 90% because it makes my argument stronger! O:-D > but it's the most influential 10%: newbies learning Python > 3 at school, the people chatting about Python on the > Internet, writing blog posts and answering questions on > Stackoverflow. Furthermore, there's probably another 30% > who *want* to use Python 3 but cannot due to company > policy. In my day job, I fall into that category: the > company I work for use Python as their main language for > our flagship application, and by policy we're stuck with > using the default Python on Debian jessie, which is 2.6. > The numbers of people actively hostile to Python 3 is > probably less than 10%. Well i'm not "actively hostile" to py3 by any means, i just can't risk the upgrade at this time. Perhaps in another five years or so i might change my mind. But then, in another five years, something more interesting might come along and sweep me off my feet. Who knows, I'm a sucker for romance. > The take-up rate of Python 3 is about where we would > expect after less than seven years: Well, that's one way of coping with it. I know a lot of folks worked hard to get Python3 up and running, but they need to realize that these sort of transitions take time. Heck, there is always the possibility that Python3 never gets any real traction. Until it's usage reaches 50%, it's only spinning tires in the mud, digging a deeper hole. Not to mention the elephant in the room: We have been moving towards mobile and cloud ubiquity, and this trend is not going to stop. If Python wants to survive it had better start adapting, and adapting fast. If not, it shall become just another forgotten language relegated to obscurity within the dark corners of academia. From rustompmody at gmail.com Fri Jul 17 00:28:55 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Thu, 16 Jul 2015 21:28:55 -0700 (PDT) Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <87mvyxll3b.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <877fq3nuwo.fsf@elektro.pacujo.net> <87380rnrqt.fsf@elektro.pacujo.net> <87615lncmd.fsf@elektro.pacujo.net> <2ab46173-5bfb-44df-b7e5-c92fcd0c9461@googlegroups.com> <87r3o9lmf6.fsf@elektro.pacujo.net> <87mvyxll3b.fsf@elektro.pacujo.net> Message-ID: <74159589-8704-4083-bce7-a348f07e4729@googlegroups.com> On Wednesday, July 15, 2015 at 4:54:51 PM UTC+5:30, Marko Rauhamaa wrote: > Ned Batchelder: > > > On Wednesday, July 15, 2015 at 6:56:10 AM UTC-4, Marko Rauhamaa wrote: > >> Ned Batchelder : > >> > I don't understand this, can you explain more? Are you saying that the > >> > Python specification shouldn't specify what x becomes?: > >> > > >> > def who_knows(): > >> > pass > >> > > >> > x = who_knows() > >> > >> Yes, that's what I'm saying. The implementation would be free to assign > >> any value whatsoever to x. > > > > I don't understand why that is helpful for TCE? Can you explain? How does > > specifying None make "smooth TCE" difficult? > > As Chris already pointed out, tail procedure calls can't be eliminated > otherwise. An example: > > def some_func(): > do_stuff() > more_stuff() > > Now, for Python to replace the call to "more_stuff()" with a simple > jump, there can't be an implicit "return None" following it. Instead, > "some_func()" must be allowed to return whatever "more_stuff()" returns. > > You could require the programmer to write: > > def some_func(): > do_stuff() > return more_stuff() > > but that's not good style. In fact, it is not good style to write code > that omits "return None" when None needs to be returned. IOW, the > unspecifiedness of procedure return values is already the unwritten > assumption in good Python code. An interesting insight. For sometime now I am seeing that C's void-return's are a mess-up of Pascal procedures. And python's None-returns are a mess-up of C's void-return: http://blog.languager.org/2015/06/functional-programming-moving-target.html This was mostly from pedagogic data of observing student confusions Now you are giving a new take on why None-return could be a language-design anti-pattern. So thanks for that. From ethan at stoneleaf.us Fri Jul 17 00:44:30 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 16 Jul 2015 21:44:30 -0700 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: <55A8882E.1080404@stoneleaf.us> On 07/16/2015 04:46 PM, Chris Angelico wrote: > Examples: > > # derived from Paul Rubin's example > def quicksort(array, start, end): > midp = partition(array, start, end) > if midp <= (start+end)//2: > quicksort(array, start, midp) > transfer quicksort(array, midp+1, end) > else: > quicksort(array, midp+1, end) > transfer quicksort(array, start, midp) > > def count_usage(func): > @functools.wraps(func) > def wrapper(*args, **kwargs): > wrapper.usage += 1 > transfer func(*args, **kwargs) > wrapper.usage = 0 > return wrapper > > Semantics: > * Evaluate the function and all its arguments, exactly as per a > current function call. > * Leaving them on the stack, remove the current call frame and dispose > of all its objects. > * Finally, construct a new stack frame for the target function and > transfer control to it. > > In effect, "transfer f()" is equivalent to "return f()", except that > the current function finishes before the target is entered. Sounds cool! Code it up and let us know how it goes. :) -- ~Ethan~ From rosuav at gmail.com Fri Jul 17 01:16:54 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 15:16:54 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> Message-ID: On Fri, Jul 17, 2015 at 2:15 PM, Rick Johnson wrote: > On Thursday, July 16, 2015 at 9:44:56 PM UTC-5, Steven D'Aprano wrote: >> [...] My take from all this is that overall, Python 3 >> take-up is probably > around 10% of all Python users, > > All that rambling just to agree with me? My educated guess > is a minimum of 75% still using Python2.x. But i'll take > your 90% because it makes my argument stronger! O:-D You said "vast majority". That's not 75:25, which is just a 3:1 ratio. > Well, that's one way of coping with it. I know a lot of > folks worked hard to get Python3 up and running, but they > need to realize that these sort of transitions take time. > Heck, there is always the possibility that Python3 never > gets any real traction. Until it's usage reaches 50%, it's > only spinning tires in the mud, digging a deeper hole. Given how easily the two coexist, I would say that demanding 50% before giving Py3 any respect at all is a bit presumptuous. Py3 has already gained very real traction; it just hasn't achieved a majority of usage. > Not to mention the elephant in the room: We have been moving > towards mobile and cloud ubiquity, and this trend is not > going to stop. If Python wants to survive it had better > start adapting, and adapting fast. If not, it shall become > just another forgotten language relegated to obscurity > within the dark corners of academia. Mobile is just how people access things. Usually there has to be a server on the back end. "Cloud" also implies some sort of server. What languages are people using on servers? Python is right up there among them. The basic notion of client-server infrastructure has been around for three parts of forever, and it isn't going anywhere. Thank you for your FUD. Allow me to offer my preferred alternative. https://www.youtube.com/watch?v=6e1hZGDaqIw ChrisA From lac at openend.se Fri Jul 17 02:24:04 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 17 Jul 2015 08:24:04 +0200 Subject: Fwd: PROBLEM IN importing PIL In-Reply-To: Message from rahul tiwari of "Fri, 17 Jul 2015 09:18:46 +0530." References: Message-ID: <201507170624.t6H6O4E4014783@fido.openend.se> In a message of Fri, 17 Jul 2015 09:18:46 +0530, rahul tiwari writes: >I want to import PIL package but every time this is showing error " no PIL > module find" . > >plz suggest me how i can fix this problem. Get Pillow. Instructions on how to install it here: https://pillow.readthedocs.org/installation.html#basic-installation Laura From lac at openend.se Fri Jul 17 02:26:42 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 17 Jul 2015 08:26:42 +0200 Subject: ANN: eGenix PyRun - One file Python Runtime 2.1.0 In-Reply-To: Message from Alex of "Thu, 16 Jul 2015 18:58:37 -0400." References: <555346E3.4030400@egenix.com> <55535FE6.2090007@egenix.com> Message-ID: <201507170626.t6H6QgEu014891@fido.openend.se> I think Activestate makes a Python 2.y for Solaris. http://www.activestate.com/activepython I've never used it. Laura In a message of Thu, 16 Jul 2015 18:58:37 -0400, Alex writes: >Do you have Python 2.7 64bit versions available for Solaris (10/11) >x86/SPARC, AIX, and HP-UX IA/RISC? I've had the displeasure of having to >install 64bit Python on Solaris and AIX and it's an experience I would not >recommend even though OpenCSW and Perzl have done much of the legwork >already. I'd also just be happy with any pointers to building PyRun or >regular Python on such systems if such currently there exist no such builds. > >On Wed, May 13, 2015 at 10:34 AM, Cristiano Cortezia < >cristiano.cortezia at gmail.com> wrote: > >> In one of the next releases we'll probably add a tool to bundle >>> complete applications together with pyrun, perhaps even by >>> recompiling it to include the application byte code files >>> right in the binary like we do for the stdlib. >> >> >> Well, that would be simply awesome. Looking forward to it. >> >> PS: you guys should definitely advertise this work on the embedded >> software community. >> >> >> 2015-05-13 11:29 GMT-03:00 M.-A. Lemburg : >> >>> On 13.05.2015 16:09, Cristiano Cortezia wrote: >>> > Well I gave it a try, and it seems my assumptions were *somehow* true. >>> > Here is what I got when running one of my apps in single shot mode >>> (load, >>> > run, terminate): >>> > >>> > *default python distribution* >>> > total time 9.022s >>> > ENOENT's count 7377 >>> > >>> > *pyrun* >>> > total time 8.455s >>> > ENOENT's count 3064 >>> > >>> > So, it indeed failed much less to open files, but I guess this didn't >>> make >>> > that much difference after all (500ms). >>> >>> PyRun has the advantage of being able to read the byte code >>> directly from the binary (using memory mapping). However, >>> it still needs to run the same startup machinery as Python >>> itself. >>> >>> Note that startup time for Python was a lot worse before >>> Python used the same approach as PyRun to compile in the >>> parsed sysconfig data. >>> >>> > Perhaps it is because this app has some external dependencies (22 to be >>> > precise) not bundled on pyrun that had to be scanned by the interpreter >>> > anyway. If by any means we could bundle them all the same way, than it >>> > could bring a much higher performance gain. But I guess it is not really >>> > safe-feasible. >>> >>> It's certainly possible to use the pyrun build system to create >>> bundles with more packages and tools included. >>> >>> The one we're shipping has most of the stdlib included, >>> but leaves all the application code to reside on the >>> sys.path or in a ZIP archive. >>> >>> In one of the next releases we'll probably add a tool to bundle >>> complete applications together with pyrun, perhaps even by >>> recompiling it to include the application byte code files >>> right in the binary like we do for the stdlib. >>> >>> -- >>> Marc-Andre Lemburg >>> eGenix.com >>> >>> Professional Python Services directly from the Source (#1, May 13 2015) >>> >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> >>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/ >>> >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ >>> ________________________________________________________________________ >>> 2015-05-13: Released mxODBC Connect 2.1.3 ... http://egenix.com/go75 >>> 2015-05-11 : Released eGenix PyRun >>> 2.1.0 ... http://egenix.com/go74 >>> 2015-05-25 : PyWaw Summit 2015, >>> Warsaw, Poland ... 12 days to go >>> >>> eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 >>> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg >>> Registered at Amtsgericht Duesseldorf: HRB 46611 >>> http://www.egenix.com/company/contact/ >>> >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> >> > >-- >https://mail.python.org/mailman/listinfo/python-list > From steve at pearwood.info Fri Jul 17 02:38:38 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 17 Jul 2015 16:38:38 +1000 Subject: Noob in Python. Problem with fairly simple test case References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> Message-ID: <55a8a2ee$0$1666$c3e8da3$5496439d@news.astraweb.com> On Fri, 17 Jul 2015 02:15 pm, Rick Johnson wrote: > On Thursday, July 16, 2015 at 9:44:56 PM UTC-5, Steven D'Aprano wrote: >> [...] My take from all this is that overall, Python 3 >> take-up is probably > around 10% of all Python users, > > All that rambling just to agree with me? My educated guess > is a minimum of 75% still using Python2.x. But i'll take > your 90% because it makes my argument stronger! O:-D 75% or 90% is not a "vast majority". Vast majority implies more than 99%. But regardless of the precise meaning of "vast", if you want to dismiss one in four people (25%) or one in ten (10%) as inconsequential, then you've got some serious issues. [...] > Well i'm not "actively hostile" to py3 by any means, i just > can't risk the upgrade at this time. You can't "risk" the upgrade? What precisely are you afraid of? >> The take-up rate of Python 3 is about where we would >> expect after less than seven years: > > Well, that's one way of coping with it. I know a lot of > folks worked hard to get Python3 up and running, but they > need to realize that these sort of transitions take time. Rick, you're being patronising. Before even a single line of code was written for Python 3, Guido and the core developers knew that there would be a long migration path from 2 to 3. Hence the parallel versions, and the long transition plan: * Python 2.6 and Python 3.0 came out more or less together, and 2.6 was explicitly designed as a transitional version with a number of Python 3 features available via __future___ imports; * Python 2.7 has an extended maintenance period; instead of the usual 2-3 years, 2.7 will be maintained for 10 years (until 2020); * there will also be at least three more years of commercial third-party maintenance available from companies like Red Hat. The core developers don't need to be told that "these sort of transitions take time". They predicted almost from the beginning that it would take 10 years for the transition. They didn't commit to a long period of parallel versions because they *like* having twice as much work to do. > Heck, there is always the possibility that Python3 never > gets any real traction. Until it's usage reaches 50%, it's > only spinning tires in the mud, digging a deeper hole. That's nonsense. Spinning tires implies no forward motion. Python 3 usage is *certainly* moving forward: we've gone from the situation in 2008 of nobody using it, to the current situation where there's lots of activity around it: students learning on Python 3, books about it, the avant-garde and early adopters have already moved to Python 3, and the majority of libraries also support Python 3. The chances of that forward motion coming to a stop are very slim. The work being done on async and concurrency for Python 3.5 is getting lots of people excited, and Red Hat and Debian have committed to migrating to Python 3. Where they go, Centos, Fedora, Mint and (probably) Ubuntu are sure to follow, and quite quickly too. My guess is, the rate of Python 3 adoption is going to hit the tipping point in 2 or 3 years, after which time it will be *very* rapid. > Not to mention the elephant in the room: We have been moving > towards mobile and cloud ubiquity, and this trend is not > going to stop. If Python wants to survive it had better > start adapting, and adapting fast. If not, it shall become > just another forgotten language relegated to obscurity > within the dark corners of academia. Yeah, right. Like academic computer scientists use Python. Whatever way you look at it, Python is one of the top 10 programming languages. It's at no risk of becoming forgotten any time soon. http://import-that.dreamwidth.org/1388.html -- Steven From steve at pearwood.info Fri Jul 17 02:47:39 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 17 Jul 2015 16:47:39 +1000 Subject: Noob in Python. Problem with fairly simple test case References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55a8a50a$0$1638$c3e8da3$5496439d@news.astraweb.com> On Fri, 17 Jul 2015 01:01 pm, Chris Angelico wrote: > On Fri, Jul 17, 2015 at 12:44 PM, Steven D'Aprano > wrote: >> My take from all this is that overall, Python 3 take-up is probably >> around 10% of all Python users... > > Really? That low? Wow. Well, that's based on a guess that for every Python programmer you see talking on the Internet, on Stackoverflow, Usenet, etc. there are probably ten or so who are invisible to us. They work a nominally 9 to 5 government or corporate job programming in Python, are forbidden to install packages which aren't approved by IT, and don't even have access to Stackoverflow let alone have time to chew the fat here. Those folks, I expect, are almost all using Python 2.6 or 2.7, with a small minority on even older versions. Some small percentage of them will still be using Python 2 in 20 years time, just as there are a small minority of people still using Python 1.5 today. > Jessie's default should be 2.7, at least. Wheezy shipped 2.7, too; > it's only Squeeze (now out of support) that didn't ship any 2.7.x > Python. Are you sure you can't at least upgrade to 2.7? I'm not sure, I'm not actively involved in that specific project. All I know is that the guys are always complaining about Jessie, and that they're using 2.6. -- Steven From antoon.pardon at rece.vub.ac.be Fri Jul 17 03:17:39 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 17 Jul 2015 09:17:39 +0200 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: <55A8AC13.8070803@rece.vub.ac.be> On 07/17/2015 01:46 AM, Chris Angelico wrote: > Open for bikeshedding: What should the keyword be? We can't use > "exec", which would match Unix and shell usage, because it's already > used in a rather different sense in Python. Current candidates: > "transfer", "goto", "recurse", and anything else you suggest. I propose the combination "return from". I think it is similar enough with "yield from" to justify this and it also won't need an extra keyword, so no programs will be broken because they used "transfer", "goto" or whatever other new keyword as an identifier. Should there be someone who is willing to spend time on this, I wish him all luck and strength he can find. I think it would be best if it was done by someone who is interrested in using this in his own programs. Because it is all very fine talking about the pro and cons here and I certainly would use it, the question is, how wide spread would the use become and is it worth the time and effort to introduce it. If future use turns out to be disappointing such a coder can at least think of it as something that was useful for himself. -- Antoon. From antoon.pardon at rece.vub.ac.be Fri Jul 17 04:06:01 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 17 Jul 2015 10:06:01 +0200 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> Message-ID: <55A8B769.5050204@rece.vub.ac.be> On 07/16/2015 09:34 PM, Terry Reedy wrote: > On 7/16/2015 3:45 AM, Antoon Pardon wrote: >> On 07/15/2015 11:19 PM, Terry Reedy wrote: >>> >>> I believe that this pattern should work with any set of mutually >>> recursive functions that always call each other in cyclic order. A >>> more elaborate version does not have this limitation. >>> >> >> Nice of you to illustrate the warping involved. ;-) > > Glad you appreciate it. To me, the warping is no more than, and > perhaps less than, and certainly less obnoxious than,the warping > required when using Baruchel's tco module. (Opinions can vary, > of course.) The result will definitely run faster than with B's tco. I don't care about the speed that much. Clarity of code is more important. And I agree how Baruchel's tco module needs to be used, doesn't seem very helpful in that respect. I wouldn't call it obnoxious, cause I can appreciate the mathematical elegance behind it, but my impression is that understanding what is going on, requires a back ground knowledge that is generally not expected. So using this would probably be good for job security but wouldn't be fair to my colleagues. -- Antoon Pardon From robin at reportlab.com Fri Jul 17 04:57:54 2015 From: robin at reportlab.com (Robin Becker) Date: Fri, 17 Jul 2015 09:57:54 +0100 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A77927.7090406@chamonix.reportlab.co.uk> Message-ID: <55A8C392.9000300@chamonix.reportlab.co.uk> On 16/07/2015 17:17, Ian Kelly wrote: > On Thu, Jul 16, 2015 at 3:28 AM, Robin Becker wrote: ............. >> >> .... >> I believe the classic answer is Ackermann's function >> >> http://demonstrations.wolfram.com/RecursionInTheAckermannFunction/ >> >> which is said to be not "primitive recursive" ie cannot be unwound into >> loops; not sure whether that implies it has to be recursively defined or can >> perhaps be broken down some other way. > that should have said "simple loops" > My recollection -- and it's been awhile since I've studied > computability theory so I may be distorting things here -- is that > primitive recursive functions can be computed using for loops, i.e. > loops where the number of iterations is bounded in advance, whereas > non-primitive recursive functions require while loops. > I'm guessing, but is the implication that for loops can be specified finitely in advance, but while loops need some processing in the calculation to determine termination? I'm an engineer :( -- Robin Becker From antoon.pardon at rece.vub.ac.be Fri Jul 17 05:00:59 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 17 Jul 2015 11:00:59 +0200 Subject: A new module for performing tail-call elimination In-Reply-To: <55a7fedd$0$1674$c3e8da3$5496439d@news.astraweb.com> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55a7fedd$0$1674$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55A8C44B.2020505@rece.vub.ac.be> On 07/16/2015 08:58 PM, Steven D'Aprano wrote: >> Nice of you to illustrate how being pedantic about something, can >> make a response useless with regard to the intended original question. > Just because your intention in giving that code was X, doesn't mean that > others cannot use that code to also do Y. > > Your example of a mutually recursive pair of functions is perfectly fine as > a toy example to demonstrate a point. But the fact that people can only > come up with toy examples to demonstrate the uses of unbounded recursion is > telling. That's *my* point. It's orthogonal to your point. We know your point. You have repeated it often enough. There is no need to keep bringing it up and certainly not where your point is irrelevant. People are allowed to not care about your point. People may think it is not worth the trouble trying to convince people who are skeptical and may choose to discuss possible directions with people who are likewise intressed. So why do you find it necessary to appear here and repeat your point, that is already known, but is not cared about much and irrelevant here. >> I'm not here to satisfy your or anyone else's curiosity. > Fair enough. > > What are you here for? When you complain that Python doesn't have TCO, is > your intent to persuade people that it should, with the ultimate aim to > changing Python so that it gains TCO? If not, then what? I don't complain that Python doesn't have TCO. I am intressed in the subject and I'm willing to discuss the pro and cons, how it could be simulated, and how good some arguments for or against it are. But I don't think any outcome here will have much weight in getting it implemented and although I would prefer having it, I can perfectly live without. So don't translate my interest in the subject into a complaint about python not having it. I'm also not interrested in convincing people who show a dislike for it. If the toy examples here, don't ignite a spark of imagination about how in some circumstance this could be useful for you, then I am not interessed in showing you. From jeanmichel at sequans.com Fri Jul 17 05:30:45 2015 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 17 Jul 2015 11:30:45 +0200 (CEST) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <55a8a2ee$0$1666$c3e8da3$5496439d@news.astraweb.com> Message-ID: <1042712953.236302.1437125445506.JavaMail.root@sequans.com> ----- Original Message ----- > From: "Steven D'Aprano" > 75% or 90% is not a "vast majority". Vast majority implies more than > 99%. You could not be more wrong. More than 99% is a stupendous majority, while within 95 to 99% is a tremendous majority. From the official "Majority rating" 2015 edition, a vast majority would be between 87 and 87.6%. Of course this is only valid in the northern hemisphere (my apologies for stating the obvious). JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From tjreedy at udel.edu Fri Jul 17 05:47:50 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 17 Jul 2015 05:47:50 -0400 Subject: Proposed keyword to transfer control to another function In-Reply-To: <55A8AC13.8070803@rece.vub.ac.be> References: <55A8AC13.8070803@rece.vub.ac.be> Message-ID: On 7/17/2015 3:17 AM, Antoon Pardon wrote: > On 07/17/2015 01:46 AM, Chris Angelico wrote: >> Open for bikeshedding: What should the keyword be? We can't use >> "exec", which would match Unix and shell usage, because it's already >> used in a rather different sense in Python. Current candidates: >> "transfer", "goto", "recurse", and anything else you suggest. > > I propose the combination "return from". Much better. I believe 'yield from' actually cuts out the middle frame containing yield from. -- Terry Jan Reedy From rosuav at gmail.com Fri Jul 17 06:43:56 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 20:43:56 +1000 Subject: Proposed keyword to transfer control to another function In-Reply-To: <55A8AC13.8070803@rece.vub.ac.be> References: <55A8AC13.8070803@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 5:17 PM, Antoon Pardon wrote: > On 07/17/2015 01:46 AM, Chris Angelico wrote: >> Open for bikeshedding: What should the keyword be? We can't use >> "exec", which would match Unix and shell usage, because it's already >> used in a rather different sense in Python. Current candidates: >> "transfer", "goto", "recurse", and anything else you suggest. > > I propose the combination "return from". I think it is similar enough > with "yield from" to justify this and it also won't need an extra > keyword, so no programs will be broken because they used "transfer", > "goto" or whatever other new keyword as an identifier. > Oooh I like this. The parallel makes sense, and as you say, no new keyword. Yes, "return from" is my new preferred command! ChrisA From antoon.pardon at rece.vub.ac.be Fri Jul 17 06:48:21 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 17 Jul 2015 12:48:21 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: <55A8DD75.5000403@rece.vub.ac.be> On 07/16/2015 06:43 PM, Chris Angelico wrote: > On Fri, Jul 17, 2015 at 12:32 AM, Antoon Pardon > wrote: > >> What is unclear about "as it is generally produced on stderr"? That you >> can do a whole lot of stuff, doesn't mean that this whole lot of stuff is >> part of what generally happens. When people on this list ask a person >> to include the stacktrace with the description of the problem, they >> don't mean something that includes the values of the variables. > True. That said, though, it's not a justification for dropping stack > frames; even in the form that's printed to stderr, there is immense > value in them. It may be possible to explicitly drop frames that a > programmer believes won't be useful, but a general and automated > dropping of tail-call information will do more harm than good. The > fact that some frameworks can show _even more_ helpful information out > of a traceback only makes this stronger. Just wondering, are traceback records of generators available? They are if an exception is raised in the generator itself, but what if an exception is raised in the loop that is driven by a generator. They don't appear in the standard stack trace. It seems a bit strange that with the immense value that is given to stack frames, that these wouldn't be available somehow. -- Antoon Pardon From rosuav at gmail.com Fri Jul 17 06:57:13 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 20:57:13 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <55a8a50a$0$1638$c3e8da3$5496439d@news.astraweb.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <55a8a50a$0$1638$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Jul 17, 2015 at 4:47 PM, Steven D'Aprano wrote: >> Jessie's default should be 2.7, at least. Wheezy shipped 2.7, too; >> it's only Squeeze (now out of support) that didn't ship any 2.7.x >> Python. Are you sure you can't at least upgrade to 2.7? > > I'm not sure, I'm not actively involved in that specific project. All I know > is that the guys are always complaining about Jessie, and that they're > using 2.6. Huh. Then maybe it's the other way: Jessie no longer ships or supports 2.6, so if 2.7 breaks the code, then so will Jessie. But I'm looking over the 2.7 What's New page, and it honestly doesn't jump out at me screaming "Your code will break!". Strange. Anyway, the specifics don't matter. What matters is that there *are* people who are using the system-provided Python, and that (so far) that's Py2 for the majority of Linux distros. But that's definitely changing; Ubuntu and Debian are both aiming toward a state of "ship Python 3 by default, but if you want 2.7, you'll have to download it", which implies that all system scripts will be ported to 3.x. Once that happens, I expect that all Debian-derived distros will follow pretty quickly (it's easy to transition if someone else has already done the vast majority of the work, by which I clearly mean about 87.4%), and non-Debian distros can probably take advantage of the prior work too, to some extent. That'll shift the balance on Linux from "mostly Py2" to "mostly Py3", and that'll have knock-on effects on Windows and Mac OS too, as third-party script developers will find it advisable [1] to write their code to match the predominantly available version. > My guess is, the rate of Python 3 adoption is going to hit the tipping point > in 2 or 3 years, after which time it will be *very* rapid. Yep, I'd agree with that estimate. Debian Stretch (9) may or may not switch; I'd be very surprised if Debian Buster (10) didn't have Py3 by default. ChrisA [1] The question is, what did the archbishop find? From rosuav at gmail.com Fri Jul 17 07:05:19 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 21:05:19 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A8DD75.5000403@rece.vub.ac.be> References: <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55A8DD75.5000403@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 8:48 PM, Antoon Pardon wrote: > Just wondering, are traceback records of generators available? They are > if an exception is raised in the generator itself, but what if an exception > is raised in the loop that is driven by a generator. They don't appear in > the standard stack trace. Not sure what you mean here. Something like this? def gen(): yield stuff yield more stuff for stuff in gen(): bomb with exception The error didn't happen in the generator, so I wouldn't expect to see it in the traceback. There's still room for the cause of an error to not be in the traceback; imagine, for instance, a function that populates a concrete list, and then you iterate over the list. If that function sticks a None into the list and the subsequent processing is expecting all strings, that's going to bomb, but then you have to figure out where the None came from. If the traceback could include that, it'd be great, but some things aren't possible. Doesn't mean we're happy to sacrifice other functionality. ChrisA From info at egenix.com Fri Jul 17 07:06:22 2015 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Fri, 17 Jul 2015 13:06:22 +0200 Subject: eGenix at the EuroPython Conference 2015 Message-ID: <55A8E1AE.1040402@egenix.com> ________________________________________________________________________ eGenix.com at the EuroPython Conference 2015 July 20-26 2015 Bilbao, Spain Meet up with eGenix at this year's EuroPython Conference in Bilbao. We have free project, consulting and coaching capacities. ________________________________________________________________________ The EuroPython Conference (https://ep2015.europython.eu/) is the one of the premier conferences for Python users and developers in Europe. It is the second largest gathering of Python enthusiast around the world. This year it is being held from July 20-26 in Bilbao, Spain. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/EuroPython-Conference-2015.html ________________________________________________________________________ Meet up with eGenix at EuroPython eGenix was one of the founding members of the EuroPython conference team and played a major role in organizing the first EuroPython conference in the year 2002. Since then we have attended every EuroPython conference to meet up face-to-face with the many people we know from the Python community and the many people that we don't yet know from the community -- if you are interested in meeting with us, please drop us a note so that we can arrange a meeting at info at egenix.com. ________________________________________________________________________ eGenix Talks at EuroPython At this year's EuroPython, Marc-Andr? Lemburg, CEO of eGenix, will be giving a talk providing some guidance for programmers new to Python: Python idioms to help you write good code ----------------------------------------- *Avoid gotchas, write faster, more readable and maintainable code* Python focuses a lot on writing readable code and also tries to make solutions obvious, but this doesn?t necessarily mean that you cannot write unreadable code or design your code in ways which makes it hard to extend or maintain. This talk will show some useful idioms to apply when writing Python code, how to structure your modules and also goes into details on which techniques to use and which to think about twice, based on 20 years of experience writing Python. Tuesday 21 July at 15:15 CEST, Google Room https://ep2015.europython.eu/conference/talks/python-idioms-to-help-you-write-good-code ________________________________________________________________________ Free project, consulting and coaching capacities eGenix currently has free custom Python project, consulting and coaching capacities. If you are interested in having eGenix implement your great ideas in Python, or want to have your teams benefit from our long Python coding experience, please contact us at info at egenix.com. If you happen to attend EuroPython, you can also talk to our CEO Marc-Andr? Lemburg directly. Please email him to arrange a meeting: mal at egenix.com. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 17 2015) >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2015-07-20: EuroPython 2015, Bilbao, Spain ... 3 days to go 2015-07-29: Python Meeting Duesseldorf ... 12 days to go ::::: Try our mxODBC.Connect Python Database Interface for free ! :::::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From antoon.pardon at rece.vub.ac.be Fri Jul 17 07:43:57 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 17 Jul 2015 13:43:57 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55A8DD75.5000403@rece.vub.ac.be> Message-ID: <55A8EA7D.2040005@rece.vub.ac.be> On 07/17/2015 01:05 PM, Chris Angelico wrote: > On Fri, Jul 17, 2015 at 8:48 PM, Antoon Pardon > wrote: >> Just wondering, are traceback records of generators available? They are >> if an exception is raised in the generator itself, but what if an exception >> is raised in the loop that is driven by a generator. They don't appear in >> the standard stack trace. > Not sure what you mean here. Something like this? > > def gen(): > yield stuff > yield more stuff > > for stuff in gen(): > bomb with exception > > The error didn't happen in the generator, so I wouldn't expect to see > it in the traceback. Yes something like that. And I wouldn't expect it either but if it is not present, is it because nobody thought about it or because it is a bad idea or an idea difficult to implement? > There's still room for the cause of an error to > not be in the traceback; imagine, for instance, a function that > populates a concrete list, and then you iterate over the list. If that > function sticks a None into the list and the subsequent processing is > expecting all strings, that's going to bomb, but then you have to > figure out where the None came from. If the traceback could include > that, it'd be great, but some things aren't possible. Sure, but in this case, the generator is still active. The Runtime would be able to jump to and somehow activates it's stack record for the next value. So why would we expect it to be impossible to include this trace back record in a stack trace? > Doesn't mean > we're happy to sacrifice other functionality. Indeed, this is an independend problem. Whatever the answer here doesn't need to affect how one feels about losing trace back record because of TCO. From rosuav at gmail.com Fri Jul 17 07:49:57 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 21:49:57 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A8EA7D.2040005@rece.vub.ac.be> References: <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55A8DD75.5000403@rece.vub.ac.be> <55A8EA7D.2040005@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 9:43 PM, Antoon Pardon wrote: > On 07/17/2015 01:05 PM, Chris Angelico wrote: >> On Fri, Jul 17, 2015 at 8:48 PM, Antoon Pardon >> wrote: >>> Just wondering, are traceback records of generators available? They are >>> if an exception is raised in the generator itself, but what if an exception >>> is raised in the loop that is driven by a generator. They don't appear in >>> the standard stack trace. >> Not sure what you mean here. Something like this? >> >> def gen(): >> yield stuff >> yield more stuff >> >> for stuff in gen(): >> bomb with exception >> >> The error didn't happen in the generator, so I wouldn't expect to see >> it in the traceback. > > Yes something like that. And I wouldn't expect it either but if it > is not present, is it because nobody thought about it or because it > is a bad idea or an idea difficult to implement? > >> There's still room for the cause of an error to >> not be in the traceback; imagine, for instance, a function that >> populates a concrete list, and then you iterate over the list. If that >> function sticks a None into the list and the subsequent processing is >> expecting all strings, that's going to bomb, but then you have to >> figure out where the None came from. If the traceback could include >> that, it'd be great, but some things aren't possible. > > Sure, but in this case, the generator is still active. The Runtime > would be able to jump to and somehow activates it's stack record > for the next value. So why would we expect it to be impossible to > include this trace back record in a stack trace? Python could also give you stack traces for any other threads that are concurrently running, on the off-chance that one of them affected it. But the only influence the generator has on the loop is to yield a value or signal termination; if an exception is thrown in the loop itself, the local name 'stuff' should have all the information about that cause. Python isn't a mind-reader, no matter how much it may look like one, and it can't know that this function's return value should be shown as part of a completely different function's stack trace. ChrisA From magixx2006 at gmail.com Fri Jul 17 08:40:57 2015 From: magixx2006 at gmail.com (Alex) Date: Fri, 17 Jul 2015 08:40:57 -0400 Subject: ANN: eGenix PyRun - One file Python Runtime 2.1.0 In-Reply-To: <201507170626.t6H6QgEu014891@fido.openend.se> References: <555346E3.4030400@egenix.com> <55535FE6.2090007@egenix.com> <201507170626.t6H6QgEu014891@fido.openend.se> Message-ID: They don't offer any free versions for those systems and their licenses are quite expensive. On Fri, Jul 17, 2015 at 2:26 AM, Laura Creighton wrote: > I think Activestate makes a Python 2.y for Solaris. > http://www.activestate.com/activepython > > I've never used it. > > Laura > > In a message of Thu, 16 Jul 2015 18:58:37 -0400, Alex writes: > >Do you have Python 2.7 64bit versions available for Solaris (10/11) > >x86/SPARC, AIX, and HP-UX IA/RISC? I've had the displeasure of having to > >install 64bit Python on Solaris and AIX and it's an experience I would not > >recommend even though OpenCSW and Perzl have done much of the legwork > >already. I'd also just be happy with any pointers to building PyRun or > >regular Python on such systems if such currently there exist no such > builds. > > > >On Wed, May 13, 2015 at 10:34 AM, Cristiano Cortezia < > >cristiano.cortezia at gmail.com> wrote: > > > >> In one of the next releases we'll probably add a tool to bundle > >>> complete applications together with pyrun, perhaps even by > >>> recompiling it to include the application byte code files > >>> right in the binary like we do for the stdlib. > >> > >> > >> Well, that would be simply awesome. Looking forward to it. > >> > >> PS: you guys should definitely advertise this work on the embedded > >> software community. > >> > >> > >> 2015-05-13 11:29 GMT-03:00 M.-A. Lemburg : > >> > >>> On 13.05.2015 16:09, Cristiano Cortezia wrote: > >>> > Well I gave it a try, and it seems my assumptions were *somehow* > true. > >>> > Here is what I got when running one of my apps in single shot mode > >>> (load, > >>> > run, terminate): > >>> > > >>> > *default python distribution* > >>> > total time 9.022s > >>> > ENOENT's count 7377 > >>> > > >>> > *pyrun* > >>> > total time 8.455s > >>> > ENOENT's count 3064 > >>> > > >>> > So, it indeed failed much less to open files, but I guess this didn't > >>> make > >>> > that much difference after all (500ms). > >>> > >>> PyRun has the advantage of being able to read the byte code > >>> directly from the binary (using memory mapping). However, > >>> it still needs to run the same startup machinery as Python > >>> itself. > >>> > >>> Note that startup time for Python was a lot worse before > >>> Python used the same approach as PyRun to compile in the > >>> parsed sysconfig data. > >>> > >>> > Perhaps it is because this app has some external dependencies (22 to > be > >>> > precise) not bundled on pyrun that had to be scanned by the > interpreter > >>> > anyway. If by any means we could bundle them all the same way, than > it > >>> > could bring a much higher performance gain. But I guess it is not > really > >>> > safe-feasible. > >>> > >>> It's certainly possible to use the pyrun build system to create > >>> bundles with more packages and tools included. > >>> > >>> The one we're shipping has most of the stdlib included, > >>> but leaves all the application code to reside on the > >>> sys.path or in a ZIP archive. > >>> > >>> In one of the next releases we'll probably add a tool to bundle > >>> complete applications together with pyrun, perhaps even by > >>> recompiling it to include the application byte code files > >>> right in the binary like we do for the stdlib. > >>> > >>> -- > >>> Marc-Andre Lemburg > >>> eGenix.com > >>> > >>> Professional Python Services directly from the Source (#1, May 13 > 2015) > >>> >>> Python Projects, Coaching and Consulting ... > http://www.egenix.com/ > >>> >>> mxODBC Plone/Zope Database Adapter ... > http://zope.egenix.com/ > >>> >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > >>> > ________________________________________________________________________ > >>> 2015-05-13: Released mxODBC Connect 2.1.3 ... > http://egenix.com/go75 > >>> 2015-05-11 : Released eGenix PyRun > >>> 2.1.0 ... http://egenix.com/go74 > >>> 2015-05-25 : PyWaw Summit 2015, > >>> Warsaw, Poland ... 12 days to go > >>> > >>> eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 > >>> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg > >>> Registered at Amtsgericht Duesseldorf: HRB 46611 > >>> http://www.egenix.com/company/contact/ > >>> > >> > >> > >> -- > >> https://mail.python.org/mailman/listinfo/python-list > >> > >> > > > >-- > >https://mail.python.org/mailman/listinfo/python-list > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoon.pardon at rece.vub.ac.be Fri Jul 17 08:54:14 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 17 Jul 2015 14:54:14 +0200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55A8DD75.5000403@rece.vub.ac.be> <55A8EA7D.2040005@rece.vub.ac.be> Message-ID: <55A8FAF6.5090104@rece.vub.ac.be> On 07/17/2015 01:49 PM, Chris Angelico wrote: > On Fri, Jul 17, 2015 at 9:43 PM, Antoon Pardon > wrote: > > >> Sure, but in this case, the generator is still active. The Runtime >> would be able to jump to and somehow activates it's stack record >> for the next value. So why would we expect it to be impossible to >> include this trace back record in a stack trace? > Python could also give you stack traces for any other threads that are > concurrently running, on the off-chance that one of them affected it. > But the only influence the generator has on the loop is to yield a > value or signal termination; if an exception is thrown in the loop > itself, the local name 'stuff' should have all the information about > that cause. But the local name 'stuff' may only have the information for the immediate cause. The underlying cause may be available in the generator. Suppose you have a generator that should only generate positive numbers that you use to divide some other number by. Your loop crashes because of a DivideByZeroError Sure the local name shows the dividor to be zero, but you have no information on why your generator produced a zero, but there may be a clue in the trace back record of the generator. > Python isn't a mind-reader, no matter how much it may look > like one, and it can't know that this function's return value should > be shown as part of a completely different function's stack trace. It is not a matter of mindreading. And it is not a completely different functions stack trace. It is the trace back record of a generator that is used by the process/thread that crashed. And AFAIK an active generator belongs to one specific thread. You can't have it yield a value to a different thread and you can't send it a value from an other thread. So I really see no reason to exclude the trace back records of active generators from a stack trace of a crashed thread. -- Antoon Pardon From rosuav at gmail.com Fri Jul 17 09:12:20 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Jul 2015 23:12:20 +1000 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A8FAF6.5090104@rece.vub.ac.be> References: <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55A8DD75.5000403@rece.vub.ac.be> <55A8EA7D.2040005@rece.vub.ac.be> <55A8FAF6.5090104@rece.vub.ac.be> Message-ID: On Fri, Jul 17, 2015 at 10:54 PM, Antoon Pardon wrote: > On 07/17/2015 01:49 PM, Chris Angelico wrote: >> On Fri, Jul 17, 2015 at 9:43 PM, Antoon Pardon >> wrote: >> >> >>> Sure, but in this case, the generator is still active. The Runtime >>> would be able to jump to and somehow activates it's stack record >>> for the next value. So why would we expect it to be impossible to >>> include this trace back record in a stack trace? >> Python could also give you stack traces for any other threads that are >> concurrently running, on the off-chance that one of them affected it. >> But the only influence the generator has on the loop is to yield a >> value or signal termination; if an exception is thrown in the loop >> itself, the local name 'stuff' should have all the information about >> that cause. > > But the local name 'stuff' may only have the information for the immediate > cause. The underlying cause may be available in the generator. Suppose > you have a generator that should only generate positive numbers that you > use to divide some other number by. Your loop crashes because of a DivideByZeroError > Sure the local name shows the dividor to be zero, but you have no > information on why your generator produced a zero, but there may be a > clue in the trace back record of the generator. Indeed, but there's nothing special about generators here. The same sequence could have been a concrete list, or it could have been some other kind of iterator (any object with __iter__ and __next__), which won't have a stack frame. Special cases aren't special enough to warp exception handling around. >> Python isn't a mind-reader, no matter how much it may look >> like one, and it can't know that this function's return value should >> be shown as part of a completely different function's stack trace. > > It is not a matter of mindreading. And it is not a completely different > functions stack trace. It is the trace back record of a generator that > is used by the process/thread that crashed. And AFAIK an active generator > belongs to one specific thread. You can't have it yield a value to a different > thread and you can't send it a value from an other thread. So I really > see no reason to exclude the trace back records of active generators > from a stack trace of a crashed thread. No, generators are fine across threads: rosuav at sikorsky:~$ python3 threadgen.py Starting! First yielded value Continuing! Second yielded value Terminating. Traceback (most recent call last): File "threadgen.py", line 20, in print(next(gen)) StopIteration rosuav at sikorsky:~$ cat threadgen.py import threading import time def thread(): time.sleep(0.5) print(next(gen)) threading.Thread(target=thread).start() def generator():rosuav at sikorsky:~$ print("Starting!") yield "First yielded value" print("Continuing!") yield "Second yielded value" print("Terminating.") gen = generator() print(next(gen)) time.sleep(1) print(next(gen)) rosuav at sikorsky:~$ In fact, a generator doesn't have a stack unless it's currently executing, so all you could get is whatever's actually inside it (that is, if there's a deep tree of 'yield from's, you could dig up that part of the stack). I'm not sure this would really help you very much. ChrisA From ned at nedbatchelder.com Fri Jul 17 10:32:36 2015 From: ned at nedbatchelder.com (Ned Batchelder) Date: Fri, 17 Jul 2015 07:32:36 -0700 (PDT) Subject: How does a dictionary work exactly? In-Reply-To: References: <948FE9D4-63CF-4730-B5F0-675F780A2481@gmail.com> Message-ID: <3a01125b-4f7d-4c37-bae1-ee8e6e7eb70b@googlegroups.com> On Thursday, July 16, 2015 at 2:59:02 PM UTC-4, Skip Montanaro wrote: > On Thu, Jul 16, 2015 at 1:36 PM, yoursurrogategod at gmail.com > wrote: > > If I understand correctly, lookup would not be a constant, yes? > > On the contrary, that's what you desire, nearly constant time > execution. To the greatest extent possible, you want the linked lists > to be of length zero or one. Part of the magic is in figuring out good > places to expand the size of the hash array. You don't want it to grow > too big, but you still want most linked lists to be very short. The > resize operation isn't done too often because it itself is expensive. > I believe Python dicts start out with an overly large initial hash > array (again, dredging up old memories of threads on python-dev) as an > optimization to avoid lots of early resize operations. > > Skip Maybe people are reading a different implementation than I am. Python's dict object doesn't use linked lists to deal with hash collisions, it probes other slots instead. Brandon Rhodes did a great talk about how dicts work: http://pyvideo.org/video/276/the-mighty-dictionary-55 BTW: The Python 3 implementation is more complicated than in Python 2, I think to deal with sharing keys among dictionaries that have the same set of keys. --Ned. From mal at egenix.com Fri Jul 17 10:45:14 2015 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 17 Jul 2015 16:45:14 +0200 Subject: ANN: eGenix PyRun - One file Python Runtime 2.1.0 In-Reply-To: References: <555346E3.4030400@egenix.com> <55535FE6.2090007@egenix.com> Message-ID: <55A914FA.5060505@egenix.com> Hi Alex, On 17.07.2015 00:58, Alex wrote: > Do you have Python 2.7 64bit versions available for Solaris (10/11) > x86/SPARC, AIX, and HP-UX IA/RISC? I've had the displeasure of having to > install 64bit Python on Solaris and AIX and it's an experience I would not > recommend even though OpenCSW and Perzl have done much of the legwork > already. I'd also just be happy with any pointers to building PyRun or > regular Python on such systems if such currently there exist no such builds. We don't currently have direct access to these types of systems, so cannot provide regular builds for these platforms. For AIX and Solaris x86 we do provide custom paid support to get our software ported, if you're interested in this. Thanks, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 17 2015) >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2015-07-20: EuroPython 2015, Bilbao, Spain ... 3 days to go 2015-07-29: Python Meeting Duesseldorf ... 12 days to go ::::: Try our mxODBC.Connect Python Database Interface for free ! :::::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ > On Wed, May 13, 2015 at 10:34 AM, Cristiano Cortezia < > cristiano.cortezia at gmail.com> wrote: > >> In one of the next releases we'll probably add a tool to bundle >>> complete applications together with pyrun, perhaps even by >>> recompiling it to include the application byte code files >>> right in the binary like we do for the stdlib. >> >> >> Well, that would be simply awesome. Looking forward to it. >> >> PS: you guys should definitely advertise this work on the embedded >> software community. >> >> >> 2015-05-13 11:29 GMT-03:00 M.-A. Lemburg : >> >>> On 13.05.2015 16:09, Cristiano Cortezia wrote: >>>> Well I gave it a try, and it seems my assumptions were *somehow* true. >>>> Here is what I got when running one of my apps in single shot mode >>> (load, >>>> run, terminate): >>>> >>>> *default python distribution* >>>> total time 9.022s >>>> ENOENT's count 7377 >>>> >>>> *pyrun* >>>> total time 8.455s >>>> ENOENT's count 3064 >>>> >>>> So, it indeed failed much less to open files, but I guess this didn't >>> make >>>> that much difference after all (500ms). >>> >>> PyRun has the advantage of being able to read the byte code >>> directly from the binary (using memory mapping). However, >>> it still needs to run the same startup machinery as Python >>> itself. >>> >>> Note that startup time for Python was a lot worse before >>> Python used the same approach as PyRun to compile in the >>> parsed sysconfig data. >>> >>>> Perhaps it is because this app has some external dependencies (22 to be >>>> precise) not bundled on pyrun that had to be scanned by the interpreter >>>> anyway. If by any means we could bundle them all the same way, than it >>>> could bring a much higher performance gain. But I guess it is not really >>>> safe-feasible. >>> >>> It's certainly possible to use the pyrun build system to create >>> bundles with more packages and tools included. >>> >>> The one we're shipping has most of the stdlib included, >>> but leaves all the application code to reside on the >>> sys.path or in a ZIP archive. >>> >>> In one of the next releases we'll probably add a tool to bundle >>> complete applications together with pyrun, perhaps even by >>> recompiling it to include the application byte code files >>> right in the binary like we do for the stdlib. >>> >>> -- >>> Marc-Andre Lemburg >>> eGenix.com >>> >>> Professional Python Services directly from the Source (#1, May 13 2015) >>>>>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>>>>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/ >>>>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ >>> ________________________________________________________________________ >>> 2015-05-13: Released mxODBC Connect 2.1.3 ... http://egenix.com/go75 >>> 2015-05-11 : Released eGenix PyRun >>> 2.1.0 ... http://egenix.com/go74 >>> 2015-05-25 : PyWaw Summit 2015, >>> Warsaw, Poland ... 12 days to go >>> >>> eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 >>> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg >>> Registered at Amtsgericht Duesseldorf: HRB 46611 >>> http://www.egenix.com/company/contact/ >>> >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> >> > From skip.montanaro at gmail.com Fri Jul 17 11:58:10 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Fri, 17 Jul 2015 10:58:10 -0500 Subject: How does a dictionary work exactly? In-Reply-To: <3a01125b-4f7d-4c37-bae1-ee8e6e7eb70b@googlegroups.com> References: <948FE9D4-63CF-4730-B5F0-675F780A2481@gmail.com> <3a01125b-4f7d-4c37-bae1-ee8e6e7eb70b@googlegroups.com> Message-ID: On Fri, Jul 17, 2015 at 9:32 AM, Ned Batchelder wrote: > Maybe people are reading a different implementation than I am. Python's > dict object doesn't use linked lists to deal with hash collisions, it probes > other slots instead. No, I was working a) from memory, and b) not looking at the implementation, which I last did a long, long time ago... Skip From rgaddi at technologyhighland.invalid Fri Jul 17 12:40:27 2015 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Fri, 17 Jul 2015 16:40:27 +0000 (UTC) Subject: Need assistance References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: On Thu, 16 Jul 2015 19:15:38 -0700, craig.sirna wrote: > I need help writing a homework program. > > I'll write it, but I can't figure out how to incorporate what I have > read in the book to work in code. > > The assignment wants us to take a users first, middle and last name in a > single input ( name=('enter your full name: )). > > Then we must display the full name rearranged in Last, First Middle > order. > > I tried to use the search function in Python to locate any spaces in the > input. It spot back the index 5 (I used Craig Daniel Sirna) > > That is correct for the first space, but I can't figure out how to get > it to continue to the next space. > > The indexing process is also a bit confusingto me. > > I get that I can use len(fullName) to set the length of the index, and > how the index is counted, but after that I'm lost. > > I have emailed my professor a few times, but haven't gotten a > response.(online course) > > Any help would be greatly appreciated. 1) Use the interactive console. Set x = 'Craig Daniel Sirna' and play with indexing and slicing it until you really internalize what they mean. x[3], x[-3], x[0:10], x[0:-1]. It's not actually relevant to the problem at hand, but right now is the time in your education to get indexing down cold; skimp on it now and you'll pay for it forever. Should take you about 5 minutes. 2) https://docs.python.org/3/library/stdtypes.html#string-methods You can do what you're trying to do, but you're swinging a hammer with a powered nailgun at your feet. Search is an inefficient way to try to split a string into parts based on a delimiter. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From ikorot01 at gmail.com Fri Jul 17 12:54:00 2015 From: ikorot01 at gmail.com (Igor Korot) Date: Fri, 17 Jul 2015 12:54:00 -0400 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: Hi, Rob, On Fri, Jul 17, 2015 at 12:40 PM, Rob Gaddi wrote: > On Thu, 16 Jul 2015 19:15:38 -0700, craig.sirna wrote: > >> I need help writing a homework program. >> >> I'll write it, but I can't figure out how to incorporate what I have >> read in the book to work in code. >> >> The assignment wants us to take a users first, middle and last name in a >> single input ( name=('enter your full name: )). >> >> Then we must display the full name rearranged in Last, First Middle >> order. >> >> I tried to use the search function in Python to locate any spaces in the >> input. It spot back the index 5 (I used Craig Daniel Sirna) >> >> That is correct for the first space, but I can't figure out how to get >> it to continue to the next space. >> >> The indexing process is also a bit confusingto me. >> >> I get that I can use len(fullName) to set the length of the index, and >> how the index is counted, but after that I'm lost. >> >> I have emailed my professor a few times, but haven't gotten a >> response.(online course) >> >> Any help would be greatly appreciated. > > 1) Use the interactive console. Set x = 'Craig Daniel Sirna' and play > with indexing and slicing it until you really internalize what they > mean. x[3], x[-3], x[0:10], x[0:-1]. It's not actually relevant to the > problem at hand, but right now is the time in your education to get > indexing down cold; skimp on it now and you'll pay for it forever. > Should take you about 5 minutes. > > 2) https://docs.python.org/3/library/stdtypes.html#string-methods > You can do what you're trying to do, but you're swinging a hammer with a > powered nailgun at your feet. Search is an inefficient way to try to > split a string into parts based on a delimiter. Most likely it's not him. They will learn it later during the course. ;-) > > -- > Rob Gaddi, Highland Technology -- www.highlandtechnology.com > Email address domain is currently out of order. See above to fix. > -- > https://mail.python.org/mailman/listinfo/python-list From sohcahtoa82 at gmail.com Fri Jul 17 13:12:34 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Fri, 17 Jul 2015 10:12:34 -0700 (PDT) Subject: how do you play python because i have gone on the website but i haven't managed to code? In-Reply-To: References: Message-ID: On Thursday, July 16, 2015 at 12:31:04 PM UTC-7, Aron Barsam wrote: > how do you play python because i have gone on the website but i haven't managed to code? http://i.imgur.com/x2KwTbw.jpg From sohcahtoa82 at gmail.com Fri Jul 17 13:15:40 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Fri, 17 Jul 2015 10:15:40 -0700 (PDT) Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: <1c11a4ba-505b-4e0a-9d64-d55236af330c@googlegroups.com> On Friday, July 17, 2015 at 12:17:55 AM UTC-7, Antoon Pardon wrote: > On 07/17/2015 01:46 AM, Chris Angelico wrote: > > Open for bikeshedding: What should the keyword be? We can't use > > "exec", which would match Unix and shell usage, because it's already > > used in a rather different sense in Python. Current candidates: > > "transfer", "goto", "recurse", and anything else you suggest. > > I propose the combination "return from". I think it is similar enough > with "yield from" to justify this and it also won't need an extra > keyword, so no programs will be broken because they used "transfer", > "goto" or whatever other new keyword as an identifier. > > Should there be someone who is willing to spend time on this, I wish > him all luck and strength he can find. I think it would be best if > it was done by someone who is interrested in using this in his own > programs. Because it is all very fine talking about the pro and > cons here and I certainly would use it, the question is, how wide > spread would the use become and is it worth the time and effort to > introduce it. If future use turns out to be disappointing such a > coder can at least think of it as something that was useful for > himself. > > -- > Antoon. "return from" or "yield from" looks too much like a COMEFROM instruction/statement. https://en.wikipedia.org/wiki/COMEFROM From ethan at stoneleaf.us Fri Jul 17 13:32:55 2015 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 17 Jul 2015 10:32:55 -0700 Subject: Proposed keyword to transfer control to another function In-Reply-To: <55A8AC13.8070803@rece.vub.ac.be> References: <55A8AC13.8070803@rece.vub.ac.be> Message-ID: <55A93C47.70302@stoneleaf.us> On 07/17/2015 12:17 AM, Antoon Pardon wrote: > On 07/17/2015 01:46 AM, Chris Angelico wrote: >> Open for bikeshedding: What should the keyword be? We can't use >> "exec", which would match Unix and shell usage, because it's already >> used in a rather different sense in Python. Current candidates: >> "transfer", "goto", "recurse", and anything else you suggest. > > I propose the combination "return from". +1 -- ~Ethan~ From rantingrickjohnson at gmail.com Fri Jul 17 13:57:23 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 17 Jul 2015 10:57:23 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <55a8a2ee$0$1666$c3e8da3$5496439d@news.astraweb.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <55a8a2ee$0$1666$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5de5b26b-8a4a-4ca0-9713-a9e85ef46a62@googlegroups.com> On Friday, July 17, 2015 at 1:38:52 AM UTC-5, Steven D'Aprano wrote: > 75% or 90% is not a "vast majority". Vast majority implies more than 99%. > > But regardless of the precise meaning of "vast", if you want to dismiss one > in four people (25%) or one in ten (10%) as inconsequential, then you've > got some serious issues. My estimate was *CONSERVATIVE* Steven. Read my words: "EDUCATED GUESS". Unlike you, I'm not going to falsify the numbers just to win an argument. I feel very strongly about the 75%, even though i know the percentage is much higher. > You can't "risk" the upgrade? What precisely are you afraid of? Simple. I don't want to waste even a second of time debugging old code that has been bug free for years. I would rather spend that time writing new code. Productivity is important to "some" of us Steven! And don't drag out that old cliche about how running 2to3 is the path to lands of "milk and honey". I call BS! With the nonrestrictive typing of Python a bug can be hidden from even the best testing methodology. Why would i risk exception hell just to please you? I don't make my decisions based on your, or the BDFL's, opinions of what is best for me. Heck, i don't make my decisions based on what "might" be good for the Python community. MY CODE! My RULES! GOT IT? > That's nonsense. Spinning tires implies no forward motion. > Python 3 usage is *certainly* moving forward: we've gone > from the situation in 2008 of nobody using it, to the > current situation where there's lots of activity around > it: How much of that is purely hype? Remember the explosion of Python usage *BEFORE* Python3? However, there has been a steady decline of Python usage since. > students learning on Python 3, You act as if *EVERY* student that ever uses Python will continue using Python forever, and *ONLY* Python! When in fact, Python is mostly a stepping stone for CS-101 students on their path to real languages like C, Java, DHTML, and the APIs of the various mobile platforms. *THIS* is where code is written to solve real life problems. *THIS* is where code directly interacts with the *VAST MAJORITY* (yeah i said it!) of humans on this planet to get stuff done! But where's Python? Oh, i know, it's stuck on my desktop. @_@ PYTHON IS A ONE TRICK PONY! > My guess is, the rate of Python 3 adoption is going to hit > the tipping point in 2 or 3 years, after which time it > will be *very* rapid. THE INTERNET WILL REMEMBER YOUR PREDICTION! A lot can happen in 2-3 years that may render Python obsolete (and your blabbing about 2020, really?). My prediction is that Python will never recover from this backward compatibility issue. And sadly, Python2 had been gaining stong momentum before Python3 arrived. The code break was the first blow, and the evolving technologies will be the final blow. Desktops computers are becoming obsolete, and mobile platforms are the future. This train has long since departed the station. From steveburrus28 at gmail.com Fri Jul 17 14:22:35 2015 From: steveburrus28 at gmail.com (Steve Burrus) Date: Fri, 17 Jul 2015 11:22:35 -0700 (PDT) Subject: Need Help w. Getting the Eclipse Python Add-On. Message-ID: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> I Need immediate Help w. Getting the Eclipse Python Add-On. I looked all around the Eclipse website to try to get this but didn't see the add-on for this. Can someone please help me to find it? Thanx. From malaclypse2 at gmail.com Fri Jul 17 14:32:52 2015 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 17 Jul 2015 14:32:52 -0400 Subject: Need Help w. Getting the Eclipse Python Add-On. In-Reply-To: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> References: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> Message-ID: On Fri, Jul 17, 2015 at 2:22 PM, Steve Burrus wrote: > I Need immediate Help w. Getting the Eclipse Python Add-On. I looked all around the Eclipse website to try to get this but didn't see the add-on for this. Can someone please help me to find it? Thanx. I think you're looking for PyDev: http://www.pydev.org/ -- Jerry From emile at fenx.com Fri Jul 17 14:36:09 2015 From: emile at fenx.com (Emile van Sebille) Date: Fri, 17 Jul 2015 11:36:09 -0700 Subject: Need Help w. Getting the Eclipse Python Add-On. In-Reply-To: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> References: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> Message-ID: On 7/17/2015 11:22 AM, Steve Burrus wrote: > I Need immediate Help w. Getting the Eclipse Python Add-On. I looked all around the Eclipse website to try to get this but didn't see the add-on for this. Can someone please help me to find it? Thanx. Googling 'python ecplise' certainly yields a lot of apparently valid links -- you might have better luck starting with a tutorial -- see perhaps http://www.vogella.com/tutorials/Python/article.html gets you further down the road. Emile From nickgeovanis at gmail.com Fri Jul 17 14:53:05 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Fri, 17 Jul 2015 11:53:05 -0700 (PDT) Subject: tkinter resize question Message-ID: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> Resizing a tkinter window which contains a frame which contains a button widget, will not change the current size of the window, frame or button as recorded in their height and width attributes (at least not if they are resizable). What is the correct way to detect their current size? From breamoreboy at yahoo.co.uk Fri Jul 17 15:00:43 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 17 Jul 2015 20:00:43 +0100 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: On 17/07/2015 17:40, Rob Gaddi wrote: > On Thu, 16 Jul 2015 19:15:38 -0700, craig.sirna wrote: > >> I need help writing a homework program. >> >> I'll write it, but I can't figure out how to incorporate what I have >> read in the book to work in code. >> >> The assignment wants us to take a users first, middle and last name in a >> single input ( name=('enter your full name: )). >> >> Then we must display the full name rearranged in Last, First Middle >> order. >> >> I tried to use the search function in Python to locate any spaces in the >> input. It spot back the index 5 (I used Craig Daniel Sirna) >> >> That is correct for the first space, but I can't figure out how to get >> it to continue to the next space. >> >> The indexing process is also a bit confusingto me. >> >> I get that I can use len(fullName) to set the length of the index, and >> how the index is counted, but after that I'm lost. >> >> I have emailed my professor a few times, but haven't gotten a >> response.(online course) >> >> Any help would be greatly appreciated. > > 1) Use the interactive console. Set x = 'Craig Daniel Sirna' and play > with indexing and slicing it until you really internalize what they > mean. x[3], x[-3], x[0:10], x[0:-1]. It's not actually relevant to the > problem at hand, but right now is the time in your education to get > indexing down cold; skimp on it now and you'll pay for it forever. > Should take you about 5 minutes. I'll throw in something to emphasize a major difference between indexing and slicing. >>> x = 'Craig Daniel Sirna' >>> x[100] Traceback (most recent call last): File "", line 1, in IndexError: string index out of range >>> x[100:] '' >>> x[:100] 'Craig Daniel Sirna' > > 2) https://docs.python.org/3/library/stdtypes.html#string-methods > You can do what you're trying to do, but you're swinging a hammer with a > powered nailgun at your feet. Search is an inefficient way to try to > split a string into parts based on a delimiter. > Inefficient I don't know about, and mostly don't care about either, but certainly not the cleanest way to code, at least IMHO. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From nickgeovanis at gmail.com Fri Jul 17 15:17:55 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Fri, 17 Jul 2015 12:17:55 -0700 (PDT) Subject: tkinter resize question In-Reply-To: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> References: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> Message-ID: On Friday, July 17, 2015 at 1:53:19 PM UTC-5, nickge... at gmail.com wrote: > Resizing a tkinter window which contains a frame which contains a button widget, will not change the current size of the window, frame or button as recorded in their height and width attributes (at least not if they are resizable). What is the correct way to detect their current size? Ok, partially answering my own question: The geometry of the window will change (win.geometry()), but the changes do not appear to "propagate" to the retrieved width/height of the child widgets, frames, etc. Or am I incorrect with this? From tjreedy at udel.edu Fri Jul 17 15:47:19 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 17 Jul 2015 15:47:19 -0400 Subject: A new module for performing tail-call elimination In-Reply-To: <87lhefanui.fsf@elektro.pacujo.net> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> Message-ID: On 7/16/2015 3:45 PM, Marko Rauhamaa wrote: > > Nobody seemed to notice that I just posted a fairly typical tail call > function: Because non-recursive tail calls are completely normal. Example: return len(self.children) Even tail operations like return a + b are tail calls if rewritten as return a.__add__(b) (usually but not always equivalent) or rewritten as return operator.add(a, b) (always equivalent) or compiled by an implementation as an equivalent internal function call. It happens to be that CPython implements calls to symbol operator functions by putting the bodies of such functions into a C switch inside a while loop. It this compiles operator symbols into bytecodes that cause a jump to the corresponding code. -- Terry Jan Reedy From rowen at uw.edu Fri Jul 17 15:52:33 2015 From: rowen at uw.edu (Russell Owen) Date: Fri, 17 Jul 2015 12:52:33 -0700 Subject: tkinter resize question In-Reply-To: References: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> Message-ID: On 7/17/15 12:17 PM, nickgeovanis at gmail.com wrote: > On Friday, July 17, 2015 at 1:53:19 PM UTC-5, nickge... at gmail.com wrote: >> Resizing a tkinter window which contains a frame which contains a button widget, will not change the current size of the window, frame or button as recorded in their height and width attributes (at least not if they are resizable). What is the correct way to detect their current size? > > Ok, partially answering my own question: > The geometry of the window will change (win.geometry()), but the changes do not appear to "propagate" to the retrieved width/height of the child widgets, frames, etc. Or am I incorrect with this? I'm not seeing it. If I try the following script I see that resizing the widget does update frame.winfo_width() and winfo_height. (I also see that the requested width and height are ignored; you can omit those). -- Russell #!/usr/bin/env python import Tkinter root = Tkinter.Tk() frame = Tkinter.Frame(root, width=100, height=50) frame.pack(expand=True, fill="both") def doReport(*args): print "frame actual width=%s, height=%s" % (frame.winfo_width(), frame.winfo_height()) print "frame requested width=%s, height=%s" % (frame.winfo_reqwidth(), frame.winfo_reqheight()) button = Tkinter.Button(frame, text="Report", command=doReport) button.pack() root.mainloop() From rantingrickjohnson at gmail.com Fri Jul 17 16:06:22 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 17 Jul 2015 13:06:22 -0700 (PDT) Subject: tkinter resize question In-Reply-To: References: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> Message-ID: On Friday, July 17, 2015 at 2:52:56 PM UTC-5, Russell Owen wrote: > I'm not seeing it. If I try the following script I see > that resizing the widget does update frame.winfo_width() > and winfo_height. (I also see that the requested width and > height are ignored; you can omit those). I wonder if the OP is trying to query the sizes from inside an event handler? Hmm. But since he failed to explain the problem coherently, and also failed to provide a code sample, i'm not willing to exert any effort beyond that. From tjreedy at udel.edu Fri Jul 17 16:27:49 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 17 Jul 2015 16:27:49 -0400 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: <55A8EA7D.2040005@rece.vub.ac.be> References: <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55A8DD75.5000403@rece.vub.ac.be> <55A8EA7D.2040005@rece.vub.ac.be> Message-ID: On 7/17/2015 7:43 AM, Antoon Pardon wrote: > On 07/17/2015 01:05 PM, Chris Angelico wrote: >> def gen(): >> yield stuff >> yield more stuff >> >> for stuff in gen(): >> bomb with exception >> >> The error didn't happen in the generator, so I wouldn't expect to see >> it in the traceback. > > Yes something like that. And I wouldn't expect it either but if it > is not present, is it because nobody thought about it or because it > is a bad idea or an idea difficult to implement? > >> There's still room for the cause of an error to >> not be in the traceback; imagine, for instance, a function that >> populates a concrete list, and then you iterate over the list. If that >> function sticks a None into the list and the subsequent processing is >> expecting all strings, that's going to bomb, but then you have to >> figure out where the None came from. If the traceback could include >> that, it'd be great, but some things aren't possible. > > Sure, but in this case, the generator is still active. No more than any other object sitting around inactive. Calling a generator function like gen above returns a generator with the generator function, in a suspended inactive state, attached as an attribute. When the generator.__next__ function is called, it activates its instance of the generator function, which suspends itself again after yielding something. At the point of the exception above, the generator next function has returned. There could be multiple generators with suspended generator functions sitting around. For instance: def f(): for tup in zip(gf0, gf1, gf2, gf3, gf4, gf5): a = tup[6] # whoops, IndexError -- Terry Jan Reedy From lac at openend.se Fri Jul 17 16:38:36 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 17 Jul 2015 22:38:36 +0200 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: Message from Rick Johnson of "Fri, 17 Jul 2015 10:57:23 -0700." <5de5b26b-8a4a-4ca0-9713-a9e85ef46a62@googlegroups.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <55a8a2ee$0$1666$c3e8da3$5496439d@news.astraweb.com><5de5b26b-8a4a-4ca0-9713-a9e85ef46a62@googlegroups.com> Message-ID: <201507172038.t6HKcal8001273@fido.openend.se> I think kivy is doing a very nice job of python-on-the-mobile. Have you looked? Please do not rant at me, just tell me what you think. Laura From marko at pacujo.net Fri Jul 17 16:55:21 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 17 Jul 2015 23:55:21 +0300 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> Message-ID: <877fpya4hy.fsf@elektro.pacujo.net> Terry Reedy : > On 7/16/2015 3:45 PM, Marko Rauhamaa wrote: >> Nobody seemed to notice that I just posted a fairly typical tail call >> function: > > Because non-recursive tail calls are completely normal. I don't know how recursion makes a difference but that one did happen to be recursive. It could easily have been replaced with a while loop but there were good aesthetic reasons to leave it recursive. Marko From wegge at wegge.dk Fri Jul 17 17:30:19 2015 From: wegge at wegge.dk (Anders Wegge Keller) Date: Fri, 17 Jul 2015 23:30:19 +0200 Subject: Parsing and displaying C structs in a semi-intelligent way. Message-ID: <20150717233019.73921f82@wegge.dk> In my day job, we have a large code base of mostly identical projects, each with their own customizations. The customizations can be a real pain sometimes. Especially when debugging binary data. The interesting part of the binary dumps are most often the stuff that are tweaked from project to project. The prime suspect is a structure like this: typedef struct { byte next ; /* Index to next wedge */ byte flags ; /* ricd-control flags */ word alt [MAX_alt] ; /* Alternative wedges */ ... } ConvResult ; typedef struct { byte state ; /* UCART_ (see cart.h) */ word headcart ; /* Cart number for header cart */ ConvResult conv ; ... } cartUTable_t ; The actual structure with substructures are much larger. This structure contains all the information used when sorting stuff[1]. For historical reasons, the data is dumped to a binary file at the end of the items life-cycle. We do have a debugging tool, that reads an in-house file format specifying the members of the structure, and how to display them. However, updating this description is error-prone, and just about as funny as waiting for the Norwegian Blue to fly out over the fiords. So most often it's either not done, or is unusable. To clean up this mess, I've devised a cunning plan, involving a C-parser, that can write a structure definition as XML. Reading this is simple enough, and going from that to a format string for struct.unpack() is mostly trivial. Except for the arrays of some C-type, that happens to be something else than an array of char. Due to the normal use case[2] of dumping this binary data, I need to get the parsed data munged into a form, that can be put into a namedtuple as single member, even when I have an array of (typical) six conv.alt values. I'm getting stuck with the limitations of struct and namedtuple. While inheriting either of them to get the job done, seem to be feasible, I still feel that I somehow should be able to do something "list comprehension"-ish, to avoid going there. I just can't see the light. (Thank you for reading all the way to here!) 1. Luggage, parcels, shop replenishments ... In short: mostly rectangular things that has a barcode attached. 2. Random ordering, not displaying all members, and only a part of the arrays. -- //Wegge From lukeharrison59 at gmail.com Fri Jul 17 17:37:49 2015 From: lukeharrison59 at gmail.com (Luke Harrison) Date: Fri, 17 Jul 2015 22:37:49 +0100 Subject: Python Requirements Message-ID: <6D1DCEF3-0263-4FD1-97F5-A3AF6C600018@gmail.com> > Dear Python-List > > As part of my A2 Computing coursework, I need to program a solution using > Python 3.4. I also need to document the minimum requirements to run Python > 3.4 on a Windows machine, including minimum RAM, minimum processing power, > minimum hard disk space and monitor resolution. > > I have searched the Python forums and website, but I was unable to find > these requirements. > > Could you please send me a copy of these requirements for use in my > coursework? > > Thank you for your response in advance, > > Luke Harrison > A2 Computing Student -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Fri Jul 17 17:40:23 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 18 Jul 2015 07:40:23 +1000 Subject: Python Requirements In-Reply-To: <6D1DCEF3-0263-4FD1-97F5-A3AF6C600018@gmail.com> References: <6D1DCEF3-0263-4FD1-97F5-A3AF6C600018@gmail.com> Message-ID: On Sat, Jul 18, 2015 at 7:37 AM, Luke Harrison wrote: > As part of my A2 Computing coursework, I need to program a solution using > > Python 3.4. I also need to document the minimum requirements to run Python > > 3.4 on a Windows machine, including minimum RAM, minimum processing power, > > minimum hard disk space and monitor resolution. Simple answer: If it's capable of running a modern Windows, it's capable of running Python. There's no screen resolution requirements, and the RAM, CPU, and HD requirements depend more on what you do with Python than on the language itself. The easiest way to find out is to try it - grab the installer, plop it onto a system, see how much less disk space you have. Then start running code and see how efficient it is. There's a world of difference between the RAM/CPU requirements of "Hello, world" and a program that does video processing, and that's true regardless of the language. ChrisA From breamoreboy at yahoo.co.uk Fri Jul 17 18:03:32 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 17 Jul 2015 23:03:32 +0100 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <201507172038.t6HKcal8001273@fido.openend.se> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <55a8a2ee$0$1666$c3e8da3$5496439d@news.astraweb.com><5de5b26b-8a4a-4ca0-9713-a9e85ef46a62@googlegroups.com> <201507172038.t6HKcal8001273@fido.openend.se> Message-ID: On 17/07/2015 21:38, Laura Creighton wrote: > I think kivy is doing a very nice job of python-on-the-mobile. > Have you looked? Please do not rant at me, just tell me what you > think. > > Laura > At least rr occasionally comes out with something useful, usually WRT tkinter. He's in the bottom division when compared to the RUE, who is still managing to get onto gg with his complete nonsense. I'll admit I enjoy tripping over there just to report him. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From nickgeovanis at gmail.com Fri Jul 17 18:42:34 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Fri, 17 Jul 2015 15:42:34 -0700 (PDT) Subject: tkinter resize question In-Reply-To: References: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> Message-ID: <78761f0b-39ff-4b08-99d5-fb52e791b85b@googlegroups.com> On Friday, July 17, 2015 at 2:52:56 PM UTC-5, Russell Owen wrote: > On 7/17/15 12:17 PM, nickgeovanis at gmail.com wrote: > > On Friday, July 17, 2015 at 1:53:19 PM UTC-5, nickge... at gmail.com wrote: > >> Resizing a tkinter window which contains a frame which contains a button widget, will not change the current size of the window, frame or button as recorded in their height and width attributes (at least not if they are resizable). What is the correct way to detect their current size? > > > > Ok, partially answering my own question: > > The geometry of the window will change (win.geometry()), but the changes do not appear to "propagate" to the retrieved width/height of the child widgets, frames, etc. Or am I incorrect with this? > > I'm not seeing it. If I try the following script I see that resizing the > widget does update frame.winfo_width() and winfo_height. (I also see > that the requested width and height are ignored; you can omit those). > > -- Russell > > > #!/usr/bin/env python > import Tkinter > root = Tkinter.Tk() > > frame = Tkinter.Frame(root, width=100, height=50) > frame.pack(expand=True, fill="both") > def doReport(*args): > print "frame actual width=%s, height=%s" % (frame.winfo_width(), > frame.winfo_height()) > print "frame requested width=%s, height=%s" % > (frame.winfo_reqwidth(), frame.winfo_reqheight()) > button = Tkinter.Button(frame, text="Report", command=doReport) > button.pack() > > root.mainloop() So my mistake was, rather than calling frame.winfo_height() or winfo_width() as you've done, instead checking frame["width"] and frame["height"]. Which retain their original values regardless of actual size AFAICS. If you do the same on the button, I think you'll find the same (non?)issue. I don't think I've seen the "winfo_optioname()" construct in the python-side doc. For example Sec 25.1.6.1 "Setting Options" in the tkinter chapter of the standard python Library Reference doesn't mention it or anything syntactically similar. I'm sure the usual disclaimer "see the tcl/tk docs" applies, but this seems more than a detail to me. Thanks for your help...Nick From tjreedy at udel.edu Fri Jul 17 18:45:23 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 17 Jul 2015 18:45:23 -0400 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> Message-ID: On 7/17/2015 12:15 AM, Rick Johnson wrote: > On Thursday, July 16, 2015 at 9:44:56 PM UTC-5, Steven D'Aprano wrote: >> [...] My take from all this is that overall, Python 3 >> take-up is probably > around 10% of all Python users, > > All that rambling just to agree with me? My educated guess > is a minimum of 75% still using Python2.x. I would call that a strong majority. > But i'll take your 90% because it makes my argument stronger! O:-D Unlike Chris, I would see that as a 'vast majority'. But these relative numbers are, as near as I can tell, restricted to the english-speaking world, perhaps extended to the latin-1 based world. Anyone who wants unicode identifiers must use Python 3 (or a translated Python like ChinesePython). Anyone seriously working with Unicode will find 3.3+ more pleasant, if not required (especially on Windows). On Amazon, the first hit for 'Japanese Python' is Dive into Python 3 (Japanese edition). As near as I can tell, there is no Japanese edition for the original Dive into Python (2). As I remember, half the Python books I saw in Japan *3 years ago* were for Python 3. Overall, I suspect that Python 3 penetration is greater in Asia. Rick, I only care about porting of public libraries. Leave your private code in Python 2. Continue writing new code in Python 2 if you wish. I only object to those who pressure others to not port to or writes in Python 3. If you want to help 2.7 become better, we need people test and backport patches to 2.7. Since 2.x bugs me as much as 3.x seems to bug you, I am considering not backporting until someone volunteers to help. Now my question for you or anyone else: If the vast majority of Python programmers are focused on 2.7, why are volunteers to help fix 2.7 bugs so scarce? Does they all consider it perfect (or sufficient) as is? Should the core developers who do not personally use 2.7 stop backporting, because no one cares if they do? -- Terry Jan Reedy From tjreedy at udel.edu Fri Jul 17 18:49:55 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 17 Jul 2015 18:49:55 -0400 Subject: tkinter resize question In-Reply-To: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> References: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> Message-ID: On 7/17/2015 2:53 PM, nickgeovanis at gmail.com wrote: > Resizing a tkinter window which contains a frame which contains a > button widget, will not change the current size of the window, frame > or button as recorded in their height and width attributes (at least > not if they are resizable). Post the code and experiments performed that leads you to believe the above. > What is the correct way to detect their current size? It is hard to fix code not posted. -- Terry Jan Reedy From emile at fenx.com Fri Jul 17 19:15:12 2015 From: emile at fenx.com (Emile van Sebille) Date: Fri, 17 Jul 2015 16:15:12 -0700 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> Message-ID: On 7/17/2015 3:45 PM, Terry Reedy wrote: > Now my question for you or anyone else: If the vast majority of Python > programmers are focused on 2.7, I consider myself in this group. > why are volunteers to help fix 2.7 bugs so scarce? perhaps the bugs that are show stoppers are providing the impetus to move forward to 3.x rather than fix? This may be an argument to stop back-porting fixes. (security bugs being the exception) > Does they all consider it perfect (or sufficient) as is? I have a number of one-off projects in place and running without issues on python versions all the way back to probably 1.52 (it's turtles all the way down) In all cases, the python version is perfect (or sufficient) as it sits. I do continue to support the applications and find myself writing mostly in some common core level of 2.x. > Should the core developers who do not personally use 2.7 stop > backporting, because no one cares if they do? That'd work for me. I'm not looking to upgrade the python versions of functioning productive code. Of course, neither are my customers looking to pay for me to f*ck^h^h^h^hupgrade up their non-buggy systems. Emile From cs at zip.com.au Fri Jul 17 19:31:17 2015 From: cs at zip.com.au (Cameron Simpson) Date: Sat, 18 Jul 2015 09:31:17 +1000 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: <20150717233117.GA42890@cskk.homeip.net> On 17Jul2015 20:43, Chris Angelico wrote: >On Fri, Jul 17, 2015 at 5:17 PM, Antoon Pardon > wrote: >> On 07/17/2015 01:46 AM, Chris Angelico wrote: >>> Open for bikeshedding: What should the keyword be? We can't use >>> "exec", which would match Unix and shell usage, because it's already >>> used in a rather different sense in Python. Current candidates: >>> "transfer", "goto", "recurse", and anything else you suggest. >> >> I propose the combination "return from". I think it is similar enough >> with "yield from" to justify this and it also won't need an extra >> keyword, so no programs will be broken because they used "transfer", >> "goto" or whatever other new keyword as an identifier. >> > >Oooh I like this. The parallel makes sense, and as you say, no new >keyword. Yes, "return from" is my new preferred command! +1 Cheers, Cameron Simpson A pessimist is an optimist in full possession of the facts. From denismfmcmahon at gmail.com Fri Jul 17 20:40:43 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Sat, 18 Jul 2015 00:40:43 +0000 (UTC) Subject: Need assistance References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: On Thu, 16 Jul 2015 19:15:38 -0700, craig.sirna wrote: > The assignment wants us to take a users first, middle and last name in a > single input ( name=('enter your full name: )). > > Then we must display the full name rearranged in Last, First Middle > order. To generate a list of words from a string, split the string up on the spaces between words. See the split method of strings. Having a list of words, get a copy of the list in reverse order. See the reversed function (and maybe the list function). Note - reversed returns an iterable, list will convert the iterable to a list. To join the elements of a list into a string, see the join method of strings. -- Denis McMahon, denismfmcmahon at gmail.com From tjreedy at udel.edu Fri Jul 17 20:40:53 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 17 Jul 2015 20:40:53 -0400 Subject: A new module for performing tail-call elimination In-Reply-To: <877fpya4hy.fsf@elektro.pacujo.net> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> <877fpya4hy.fsf@elektro.pacujo.net> Message-ID: On 7/17/2015 4:55 PM, Marko Rauhamaa wrote: > Terry Reedy : > >> On 7/16/2015 3:45 PM, Marko Rauhamaa wrote: >>> Nobody seemed to notice that I just posted a fairly typical tail call >>> function: >> >> Because non-recursive tail calls are completely normal. > > I don't know how recursion makes a difference There are two extremely important differences: 1. Direct recursion calls the function that contains the call. This is what allows replacement of tail recursion with a loop within the same function. 2. Almost all problems with stack overflow are due to recursion, whether at the tail or within the body of a code block. Such problems are nearly always with linear recursion (one recursive call per call until the base case). Problems with branching recursion (multiple recursive calls per call) are rare except for very deep trees and graphs. > but that one did happen to be recursive. Not directly, as needed for loop conversion. class X: # omitted from original but needed below def setvalue(self, keyseq, value, offset=0): ... child.setvalue(keyseq, value, offset + 1) child.setvalue is a new callable bound method object, call it 'bm', that is different from the setvalue function. This tail call is not a tail recursive call. The standard conversion of adding a while loop and replacing the tail call with the assignment in the call, in this case 'offset = offset+1' will not work. > It could easily have been replaced with a while loop Given the equality stated below, then yes. child.setvalue(*args) == bm(*args) calls (in 3.x) bm.__func__(bm.__self__, *args) If type(child) == type(self) == X, then bm.func == X.setvalue and the indirect call is the same as X.setvalue(child, keyseq, value, offset + 1) making the bound method call indirectly recursive. If we replace the bound method call in setvalue with the call to setvalue itself, then we have a tail recursive call and can do the standard replacement to get: class X def setvalue(self, keyseq, value, offset=0): while True: ... # child.setvalue(keyseq, value, offset + 1) offset += 1 self = child If children are not always instances of type(self), as when a tree has separate Node and Leaf classes, then recursive calls to Node instances must be separated from non-recursive Leaf calls before replacing the recursive calls. Having a good reason to rebind the first parameter within methods, as above, is a good reason to not hide it (as some have proposed). > but there were good aesthetic reasons to leave it recursive. Once one learns that looping and recursive calls are two ways of doing the same thing -- repeatedly executing a block of code with altered inputs, then the aesthetic reasons are purely aesthetic. I personally would probably initially write and test setvalue with recursion. If I were releasing it for others to use in production code (where aesthetics no longer break ties between equivalent correct implementations), I would do the conversion to avoid possible stack overflows. For cases like this, where only some parameters are rebound, I might leave the original tail call in a comment as documentation, as I did above. -- Terry Jan Reedy From rosuav at gmail.com Fri Jul 17 20:47:30 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 18 Jul 2015 10:47:30 +1000 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> <877fpya4hy.fsf@elektro.pacujo.net> Message-ID: On Sat, Jul 18, 2015 at 10:40 AM, Terry Reedy wrote: > If children are not always instances of type(self), as when a tree has > separate Node and Leaf classes, then recursive calls to Node instances must > be separated from non-recursive Leaf calls before replacing the recursive > calls. More serious concern: If it's possible for one of the children to be an arbitrary subclass of that type, it could have overridden the setvalue method. To maintain the expectations, you absolutely have to do the full lookup and pass the message down the chain. ChrisA From tjreedy at udel.edu Fri Jul 17 21:20:13 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 17 Jul 2015 21:20:13 -0400 Subject: tkinter resize question In-Reply-To: <78761f0b-39ff-4b08-99d5-fb52e791b85b@googlegroups.com> References: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> <78761f0b-39ff-4b08-99d5-fb52e791b85b@googlegroups.com> Message-ID: On 7/17/2015 6:42 PM, nickgeovanis at gmail.com wrote: > I don't think I've seen the "winfo_optioname()" construct in the > python-side doc. For example Sec 25.1.6.1 "Setting Options" in the > tkinter chapter of the standard python Library Reference doesn't > mention it or anything syntactically similar. The docs are incomplete. > I'm sure the usual > disclaimer "see the tcl/tk docs" applies, but this seems more than a > detail to me. Thanks for your help...Nick Better yet, bookmark this tkinter reference (which I believe is mentioned at the top of the doc). It is only missing stuff new in 8.6. http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html The winfo functions are included in 26 Universal widget methods. http://effbot.org/tkinterbook/ has some worked out examples. There is also a lot on Stackoverflow, which has a tkinter tag. -- Terry Jan Reedy From nickgeovanis at gmail.com Fri Jul 17 21:31:28 2015 From: nickgeovanis at gmail.com (nickgeovanis at gmail.com) Date: Fri, 17 Jul 2015 18:31:28 -0700 (PDT) Subject: tkinter resize question In-Reply-To: References: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> Message-ID: <114744ef-1de6-48c7-9024-727051e545a7@googlegroups.com> On Friday, July 17, 2015 at 5:55:19 PM UTC-5, Terry Reedy wrote: > On 7/17/2015 2:53 PM, nickgeovanis at gmail.com wrote: > > Resizing a tkinter window which contains a frame which contains a > > button widget, will not change the current size of the window, frame > > or button as recorded in their height and width attributes (at least > > not if they are resizable). > > Post the code and experiments performed that leads you to believe the above. It's really boring but here you are: [ngeo at localhost src]$ python3 Python 3.4.2 (default, Dec 20 2014, 13:53:33) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>> win=tkinter.Tk() >>> frame=tkinter.Frame(win, bg="blue", width=200, height=200) >>> butt1=tkinter.Button(fg="green", bg="black") >>> frame.grid() >>> butt1.grid() >>> butt1["width"] 0 >>> butt1["height"] 0 >>> win["width"] 0 >>> win["height"] 0 Needless to say the button has appeared and has non-zero size. > > What is the correct way to detect their current size? > > It is hard to fix code not posted. Just a question from first principles: Find a widget's current size. But the code example posted showed a working way to do the same thing. Unfortunately requiring a function call, and not in the doc online AFAICS but....doc is doc. > Terry Jan Reedy From no.email at nospam.invalid Fri Jul 17 23:06:57 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 17 Jul 2015 20:06:57 -0700 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55a76628$0$2846$c3e8da3$76491128@news.astraweb.com> <55A78A42.4090506@rece.vub.ac.be> <55A7B309.8080903@rece.vub.ac.be> Message-ID: <87pp3qyxim.fsf@jester.gateway.sonic.net> Chris Angelico writes: > My point was that I have yet to see anything that demands TCO and > can't be algorithmically improved. I don't think anyone claimed you can't simulate TCO with updateable variables and a while loop. TCO just sometimes lets you write some things in a cleaner (in proponnets' view) style. > The best so far has been a quicksort that uses TCO to guarantee a > maximum on stack usage. I actually thought the state machine example was more convincing. Doing that without TCO would have required some kind of explicit control loop and a messy dispatch mechanism instead of direct chaining from one state to the next. From no.email at nospam.invalid Fri Jul 17 23:16:29 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 17 Jul 2015 20:16:29 -0700 Subject: Proposed keyword to transfer control to another function References: Message-ID: <87lheeyx2q.fsf@jester.gateway.sonic.net> Chris Angelico writes: > # derived from Paul Rubin's example > def quicksort(array, start, end): > midp = partition(array, start, end) Heh, forgot to include the base case, as someone pointed out. Oh well, it's pseudocode, or something. > transfer quicksort(array, midp+1, end) Overall I like the idea but though it doesn't seem terribly important in the scheme of things. I think the syntax has converged to "return from" which seems good to me. > Note that this is incompatible with 'try' and 'with' blocks, and is Maybe something can be done about that. > Is there anything that I've missed out in speccing this up? I've a > suspicion that this might turn out to be as complicated as 'yield > from' in all its handling of edge cases. Seems worthy of more thought. From storchaka at gmail.com Fri Jul 17 23:48:13 2015 From: storchaka at gmail.com (Serhiy Storchaka) Date: Sat, 18 Jul 2015 06:48:13 +0300 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: On 17.07.15 02:46, Chris Angelico wrote: > Out of the lengthy thread on tail call optimization has come one broad > theory that might be of interest, so I'm spinning it off into its own > thread. > > The concept is like the Unix exec[vlpe] family of functions: replace > the current stack frame with a new one. This can be used for explicit > tail recursion without repeated stack frames, or for a pre-check that > then disappears out of the stack. Like any other feature, it can be > misused to make debugging difficult, but among consenting adults, > hopefully it can be used sensibly. I think there is no chance that this proposition will be accepted by Guido, because it makes debugging harder. From tjreedy at udel.edu Sat Jul 18 01:49:22 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 18 Jul 2015 01:49:22 -0400 Subject: tkinter resize question In-Reply-To: <114744ef-1de6-48c7-9024-727051e545a7@googlegroups.com> References: <21c1f9fb-1af0-4c57-aeba-2c7d78b1e707@googlegroups.com> <114744ef-1de6-48c7-9024-727051e545a7@googlegroups.com> Message-ID: On 7/17/2015 9:31 PM, nickgeovanis at gmail.com wrote: > On Friday, July 17, 2015 at 5:55:19 PM UTC-5, Terry Reedy wrote: >> On 7/17/2015 2:53 PM, nickgeovanis at gmail.com wrote: >>> Resizing a tkinter window which contains a frame which contains a >>> button widget, will not change the current size of the window, frame >>> or button as recorded in their height and width attributes (at least >>> not if they are resizable). >> >> Post the code and experiments performed that leads you to believe the above. > > It's really boring but here you are: > > [ngeo at localhost src]$ python3 > Python 3.4.2 (default, Dec 20 2014, 13:53:33) > [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import tkinter >>>> win=tkinter.Tk() >>>> frame=tkinter.Frame(win, bg="blue", width=200, height=200) >>>> butt1=tkinter.Button(fg="green", bg="black") >>>> frame.grid() >>>> butt1.grid() >>>> butt1["width"] > 0 >>>> butt1["height"] > 0 >>>> win["width"] > 0 >>>> win["height"] > 0 I believe these configuration settings should be interpreted a 'initial size' (if not default) or 'desired size' or possibly min or max size, depending on the grid or pack settings. -- Terry Jan Reedy From mal at europython.eu Sat Jul 18 06:19:33 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Sat, 18 Jul 2015 12:19:33 +0200 Subject: EuroPython 2015: More attendee tips Message-ID: <55AA2835.4050601@europython.eu> Some more last-minute news and tips for attendees. Be sure to check our attendee tips page for more information. Bilbao tram service on strike ----------------------------- Just like in Berlin last year, there will be some inconvenience due to strikes in Bilbao. The Bilbao tram service has been on strike since July 15th and it may well last until the end of Summer. The tram services will stop from 11:55 - 14.00 and 17:55 - 20.00 CEST each day and only maintain minimum service at other times. See ?Paralizado el servicio de tranv?a en Bilbao por huelga de sus trabajadores? for more details (in Spanish): http://www.elmundo.es/pais-vasco/2015/07/15/55a66b6aca47414f298b457e.html We had originally wanted to provide free public transport for attendees, but given the strikes during conference rush hours, we decided to drop this. Note that buses and the metro will still operate as usual. Great weather ------------- You will not only benefit from excellent talks, but also receive lots of Vitamin D in Bilbao. The weather forecast for the week is excellent: *lots of sunshine* and between 28?-30? Celsius: http://www.bbc.com/weather/3128026 So while the tram is on strike, you can walk and get an ice cream instead of a tram ticket. Speaker preparations -------------------- If you are a speaker, please read the nice guide written by Harry Percival: Tips for speakers https://ep2015.europython.eu/en/speakers/tips/ In particular, please check your talk time. The session chairs will have to make sure that all speakers only use the assigned talk time, so that the tracks don?t run out of sync. There are also some important technical things to prepare your talk at the conference: * *test your notebook* with the projector in the room where you will be holding your talk * make sure you have the right VGA adapters with you * make sure the projector resolution is supported by your notebook It?s best to do all of the above a few hours or a day before your talk. In case of problems, you can then try to find alternative solutions, e.g. borrow someone?s notebook for the talk. Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From nulla.epistola at web.de Sat Jul 18 06:35:10 2015 From: nulla.epistola at web.de (Sibylle Koczian) Date: Sat, 18 Jul 2015 12:35:10 +0200 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: <55AA2BDE.6050605@web.de> Am 18.07.2015 um 02:40 schrieb Denis McMahon: > On Thu, 16 Jul 2015 19:15:38 -0700, craig.sirna wrote: > >> The assignment wants us to take a users first, middle and last name in a >> single input ( name=('enter your full name: )). >> >> Then we must display the full name rearranged in Last, First Middle >> order. > > To generate a list of words from a string, split the string up on the > spaces between words. See the split method of strings. > > Having a list of words, get a copy of the list in reverse order. See the > reversed function (and maybe the list function). > That won't really help, because the desired order is, with the example the OP used: Sirna Daniel Craig. So here indexing is necessary, but indexing of the list elements, not of the characters in the string. (Necessary is too strong, because this could be done with rpartition. But I doubt that's the right answer for a beginner course.) From nulla.epistola at web.de Sat Jul 18 06:35:10 2015 From: nulla.epistola at web.de (Sibylle Koczian) Date: Sat, 18 Jul 2015 12:35:10 +0200 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: <55AA2BDE.6050605@web.de> Am 18.07.2015 um 02:40 schrieb Denis McMahon: > On Thu, 16 Jul 2015 19:15:38 -0700, craig.sirna wrote: > >> The assignment wants us to take a users first, middle and last name in a >> single input ( name=('enter your full name: )). >> >> Then we must display the full name rearranged in Last, First Middle >> order. > > To generate a list of words from a string, split the string up on the > spaces between words. See the split method of strings. > > Having a list of words, get a copy of the list in reverse order. See the > reversed function (and maybe the list function). > That won't really help, because the desired order is, with the example the OP used: Sirna Daniel Craig. So here indexing is necessary, but indexing of the list elements, not of the characters in the string. (Necessary is too strong, because this could be done with rpartition. But I doubt that's the right answer for a beginner course.) From lac at openend.se Sat Jul 18 08:16:11 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 18 Jul 2015 14:16:11 +0200 Subject: Need assistance In-Reply-To: Message from Sibylle Koczian of "Sat, 18 Jul 2015 12:35:10 +0200." <55AA2BDE.6050605@web.de> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> Message-ID: <201507181216.t6ICGBrY022256@fido.openend.se> You don't have to index them. You can unpack them into a tuple of first, middle, last Laura (who is trying not to do somebody's homework for them, since I'm not the person who needs to learn this). From joseph.lee22590 at gmail.com Sat Jul 18 12:05:49 2015 From: joseph.lee22590 at gmail.com (Joseph Lee) Date: Sat, 18 Jul 2015 09:05:49 -0700 Subject: Need assistance In-Reply-To: <201507181216.t6ICGBrY022256@fido.openend.se> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> <201507181216.t6ICGBrY022256@fido.openend.se> Message-ID: <002f01d0c173$9dd70a60$d9851f20$@gmail.com> Hi Laura, There are edge cases where this may fail (and let's see if Craig catches this on his own). Cheers, Joseph -----Original Message----- From: Python-list [mailto:python-list-bounces+joseph.lee22590=gmail.com at python.org] On Behalf Of Laura Creighton Sent: Saturday, July 18, 2015 5:16 AM To: Sibylle Koczian Cc: python-list at python.org; lac at openend.se Subject: Re: Need assistance You don't have to index them. You can unpack them into a tuple of first, middle, last Laura (who is trying not to do somebody's homework for them, since I'm not the person who needs to learn this). -- https://mail.python.org/mailman/listinfo/python-list From breamoreboy at yahoo.co.uk Sat Jul 18 13:34:04 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 18 Jul 2015 18:34:04 +0100 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> of "Sat 18 Jul 2015 12:35:10 +0200." <55AA2BDE.6050605@web.de> <201507181216.t6ICGBrY022256@fido.openend.se> Message-ID: On 18/07/2015 17:18, Dennis Lee Bieber wrote: > On Sat, 18 Jul 2015 14:16:11 +0200, Laura Creighton > declaimed the following: > >> You don't have to index them. You can unpack them into a tuple >> of first, middle, last >> >> Laura (who is trying not to do somebody's homework for them, since >> I'm not the person who needs to learn this). > > That only works if the input IS three names (My Birth Certificate reads > "Dennis Lee James Bieber"; and I often used to include my confirmation name > into the thing; I've grown out of that phase but do still sometimes use > dljjb as initials). This https://www.python.org/dev/peps/pep-3132/ might be handy in this case. > > Simple .split() and a {HP calculator} roll operation should get the > desired order. > What is an {HP calculator} roll operation? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From wrw at mac.com Sat Jul 18 14:28:05 2015 From: wrw at mac.com (William Ray Wing) Date: Sat, 18 Jul 2015 14:28:05 -0400 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> <"of> <18> <2015> <12:35:10> <+0200."@mac.com> <55AA2BDE.6050605@web.de> <201507181216.t6ICGBrY022256@fido.openend.se> Message-ID: > On Jul 18, 2015, at 1:34 PM, Mark Lawrence wrote: > > [byte] > What is an {HP calculator} roll operation? > The original Hewlett Packard ?Scientific? calculators (HP-35, 45, 65, etc) that used Polish notation (operand, operand, operation; with no ?=? sign) had a stack. That stack itself could be manipulated (e.g., interchange X and Y). One of the stack manipulation commands was ?Roll? which moved the top entry into X and pushed remaining elements up one. Later versions had both Roll-up and Roll-down, Roll-down moved the X entry to the top of the stack and dropped the other elements. Bill (Who still uses an HP-45 emulator on his iPhone) > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > -- > https://mail.python.org/mailman/listinfo/python-list From none at mailinator.com Sat Jul 18 14:51:00 2015 From: none at mailinator.com (mm0fmf) Date: Sat, 18 Jul 2015 19:51:00 +0100 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> of "Sat 18 Jul 2015 12:35:10 +0200." <55AA2BDE.6050605@web.de> <201507181216.t6ICGBrY022256@fido.openend.se> Message-ID: On 18/07/2015 18:34, Mark Lawrence wrote: > > What is an {HP calculator} roll operation? HP calculators were proper in that they used RPN entry. i.e. 2 enter 2 + would show 4 instead of 2 + 2 = Gawd it's so long but ISTR there were 3 stack registers and the display. So you could press 1 enter 2 enter 3 enter 4 and Z = 1, Y = 2, X = 3 and display = 4. Roll would rotate the entries through the display register. ROLL and Z = 2, Y = 3, X = 4 and display = 1 and so on. There was an INV ROLL to go the other way. The 3 level stack was equivalent to nesting parentheses three times. I only had a TI-59 as it was half the price of an HP67. The TI had more memories and program steps and was faster. But it didn't say HP on the front! From joel.goldstick at gmail.com Sat Jul 18 15:10:50 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Sat, 18 Jul 2015 15:10:50 -0400 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> <201507181216.t6ICGBrY022256@fido.openend.se> Message-ID: On Sat, Jul 18, 2015 at 2:51 PM, mm0fmf via Python-list wrote: > On 18/07/2015 18:34, Mark Lawrence wrote: >> >> >> What is an {HP calculator} roll operation? > > > HP calculators were proper in that they used RPN entry. > > i.e. 2 enter 2 + would show 4 instead of 2 + 2 = > > Gawd it's so long but ISTR there were 3 stack registers and the display. So > you could press > > 1 enter > 2 enter > 3 enter > 4 > > and Z = 1, Y = 2, X = 3 and display = 4. Roll would rotate the entries > through the display register. > > ROLL and Z = 2, Y = 3, X = 4 and display = 1 > > and so on. There was an INV ROLL to go the other way. > > The 3 level stack was equivalent to nesting parentheses three times. I only > had a TI-59 as it was half the price of an HP67. The TI had more memories > and program steps and was faster. But it didn't say HP on the front! > I have an hp35. But to be 'really' cool you have to have an hp35 that just says hp. Those were the very first ones -- Joel Goldstick http://joelgoldstick.com From none at mailinator.com Sat Jul 18 15:35:46 2015 From: none at mailinator.com (mm0fmf) Date: Sat, 18 Jul 2015 20:35:46 +0100 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> <201507181216.t6ICGBrY022256@fido.openend.se> Message-ID: On 18/07/2015 20:10, Joel Goldstick wrote: > On Sat, Jul 18, 2015 at 2:51 PM, mm0fmf via Python-list > wrote: >> On 18/07/2015 18:34, Mark Lawrence wrote: >>> >>> >>> What is an {HP calculator} roll operation? >> >> >> HP calculators were proper in that they used RPN entry. >> >> i.e. 2 enter 2 + would show 4 instead of 2 + 2 = >> >> Gawd it's so long but ISTR there were 3 stack registers and the display. So >> you could press >> >> 1 enter >> 2 enter >> 3 enter >> 4 >> >> and Z = 1, Y = 2, X = 3 and display = 4. Roll would rotate the entries >> through the display register. >> >> ROLL and Z = 2, Y = 3, X = 4 and display = 1 >> >> and so on. There was an INV ROLL to go the other way. >> >> The 3 level stack was equivalent to nesting parentheses three times. I only >> had a TI-59 as it was half the price of an HP67. The TI had more memories >> and program steps and was faster. But it didn't say HP on the front! >> > I have an hp35. But to be 'really' cool you have to have an hp35 that > just says hp. Those were the very first ones > I want a real HP16C and have been tempted to buy one from eBay. From rantingrickjohnson at gmail.com Sat Jul 18 17:12:16 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Jul 2015 14:12:16 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <55a8a2ee$0$1666$c3e8da3$5496439d@news.astraweb.com><5de5b26b-8a4a-4ca0-9713-a9e85ef46a62@googlegroups.com> Message-ID: <7e73baa6-cdaa-484e-98e3-1f7156b26d24@googlegroups.com> On Friday, July 17, 2015 at 3:39:02 PM UTC-5, Laura Creighton wrote: > I think kivy is doing a very nice job of python-on-the-mobile. > Have you looked? Please do not rant at me, just tell me what you > think. Hello Laura, I'm not sure if you're replying to me (as there is no quoted context) but since you mentioned "rant" i "suppose" that you could be referring be me? I mean, i don't know what gave you the impression that i would rant at anyone? But don't worry dear, i've always self-censored my rants when females are listening -- oops, gonna get some flac for that comment! O:-) First off. I don't remember seeing you here before. So allow me to say that having a female presence in this group is quite refreshing. I hope you continue to participate! Also, I have a lot to say on this subject, and most of what i say below is intended as a "general response", so please don't take any of my words as a personal attack. Thanks. ============================================================ Regarding Kivy ============================================================ I was not aware of this project until you mentioned it. However, i'm skeptical because: (1) it will suffer from latency issues, especially on the mobile platforms, and (2) but even if not, i feel projects like this are only encouraging the stagnation of our evolution towards multi-device compatibility. ============================================================ The road to enlightenment is paved with introspection ============================================================ For the last few decades we have been consumed with the task of bringing multi-platform-ism to every language or API or software or whatever. And this was a noble pursuit indeed! HOWEVER, We are now moving into a new age. Not of cross-platform-ism (where we want to write code *ONCE* and have it run on Linux, Windows, and Mac) but were we want to write code *ONCE* and have it run on a desktop, or a notebook, or a phone, or a watch, or a refrigerator, or even a HUD in our spaceship! I believe it's high time that we move away from religious ideologies codified in "selfish syntaxes" and "selfish interfaces". Because, we seek out these segregating policies just so we can say "hey, we're different", when in reality, we're all the same underneath. For example: printing to stdout is printing to stdout -> no matter what syntax you choose to use. Likewise, iterating over a collection of items, or creating an object that implements the OOP paradigm, or writing a stream into a storage medium -> the fundamentals of these concepts do not change simply by plastering them with selfish identities. Neither is the concept of a GUI window any different if that window was created in Windows, Linux, or Mac. I could provide example after example (ad nauseum) of how we're creating these selfish syntaxes and selfish interface, but i think you get the point. This "need to fulfill" the underlying selfish desires that we, as humans harbor, is preventing us (as programmers, software engineers, hardware producers, and most importantly -> end users) from reaching computing Nirvana. No programmer should ever need to re-write the same code numerous times so that it can run on multiple devices. We, are injecting needless superfluity into this system. And for no more reason than our need to fulfill selfish desires! Why are we *NOT* working together to create a single, linear, and scaleable system of producing software, A system that compiles all the best ideas, and throws the remainder into the refuse bin of history. The only system i've seen that has made *ANY* attempt (as feeble as it may be) is DHTML. But even with it's modern look and feel, it lacks the necessary hooks into the diverse platforms to get any "real work" done. However, utilizing the Trojan horse of "browser ubiquity", and expanding on it, may be much less work than rebuilding the entire system from the ground up (something to ponder...) Most of what we're doing, in the programming language design field, is fighting over who's version of "superficial CSS" is going to be the official version. Our partisan efforts are merely adolescent accessorizing. But we lack the introspective ability to notice the vanity and futility of our efforts. If you want to know why i rant so much, it's because i'm both saddened and angry that we waste our time on these petty battles. When, in fact, we could achieve greatness by working towards a common goal. ============================================================ Utopia's eventually fail Rick! ============================================================ I'm aware of that! I'm aware that "conflict" is the invisible force that breathes life into the cogs of evolution. But your superficial understanding of my proposal is not a failure of my proposal. ON THE CONTRARY! For example. We can *ALL* remember how every cell phone manufacture had their own selfish implementation of a charging port. Heck, every time you bought a new phone, you would be forced to buy a corresponding charger. Did not matter that your old changer was still working fine, or if the power output was exactly the same. NOPE! If the port did not match the plug, then you were screwed -- which means you were screwed 99% of the time! Heck, i have dozens of old chargers in my closet. Each one either has a different plug, or a different power output. And landfills are seething with them. Thankfully, at some point, most manufacturers switched to micro USB (possibly from governmental regulation???) and the charging routine of many cell phone users have been joyful since. *NOW*, i can borrow a friends charger if my battery level becomes low. *NOW*, i can buy a charger from *ANY* manufacture. This is freedom. And this is how we remove superfluously injected selfishness from our systems! Which is the very point i'm trying to make about our multi- device problem. We have willfully injected superfluity into our system of software creation, and as a result, we are wasting precious time fitting square blocks into round holes when we would could spend that time solving newer, more complex problems. Changing the world <-> instead of chewing the cud! I'm not sure if an authority will need to step in and regulate this blatant and infantile selfishness, or if we, as active members, and thus, guilty by association, will take the necessary steps to move ourselves towards the linear path to software engineering Nirvana. A system that is designed from the ground up to produce the best software, in the least amount of time. A system that not only rewards creativity, productivity, and pragmatic necessity, but a system that is designed to foster it; to cradle it; to nurture it. That is my dream. And the status quo is our collective nightmare! From greg.ewing at canterbury.ac.nz Sat Jul 18 18:39:29 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 19 Jul 2015 10:39:29 +1200 Subject: A new module for performing tail-call elimination In-Reply-To: <87lhefanui.fsf@elektro.pacujo.net> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> Message-ID: Marko Rauhamaa wrote: > At any rate, it demonstrates how the idiom has its place in Python. Perhaps it does, but I think I'd still prefer it to be explicit. The call in Marko's example is not actually a tail call as written. To make it a tail call, a return would need to be added: > return child.setvalue(keyseq, value, offset + 1) To someone reading the code, it's not obvious why the return is there. It looks redundant, and is likely to get removed by someone who thinks it's a mistake. Using a dedicated keyword would make it clear that tail call behaviour is being relied upon, and avoid looking like a spurious return. -- Greg From greg.ewing at canterbury.ac.nz Sat Jul 18 18:39:33 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 19 Jul 2015 10:39:33 +1200 Subject: A new module for performing tail-call elimination In-Reply-To: <877fpya4hy.fsf@elektro.pacujo.net> References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> <877fpya4hy.fsf@elektro.pacujo.net> Message-ID: Marko Rauhamaa wrote: > I don't know how recursion makes a difference It makes a difference because people don't expect frames to disappear from tracebacks when they're not consciously doing recursion. -- Greg From greg.ewing at canterbury.ac.nz Sat Jul 18 18:39:36 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 19 Jul 2015 10:39:36 +1200 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> <877fpya4hy.fsf@elektro.pacujo.net> Message-ID: Terry Reedy wrote: > Problems with branching recursion (multiple recursive calls per > call) are rare except for very deep trees and graphs. And if your recursion is branching, tail calls won't help you, except in certain special cases (such as the quicksort example) where you can predict in advance which branches are safe to recurse down. -- Greg From greg.ewing at canterbury.ac.nz Sat Jul 18 18:57:27 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 19 Jul 2015 10:57:27 +1200 Subject: Possibly Pythonic Tail Call Optimization (TCO/TRE) In-Reply-To: References: <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Message-ID: Antoon Pardon wrote: > It seems a bit strange that with the immense value that is given to > stack frames, that these wouldn't be available somehow. There was discussion recently about the idea of providing access to the frame of a suspended generator, so that debuggers can inspect the stack of an asyncio task that's not currently running. The same mechanism ought to allow the state of an arbitrary generator to be examined. You'd need to explicitly ask for it, though -- it wouldn't appear in stack traces automatically. -- Greg From rantingrickjohnson at gmail.com Sat Jul 18 19:18:57 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Jul 2015 16:18:57 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> Message-ID: <4760b41d-54c8-436f-a40b-40ecd9622c5b@googlegroups.com> On Friday, July 17, 2015 at 5:46:01 PM UTC-5, Terry Reedy wrote: > But these relative numbers are, as near as I can tell, > restricted to the english-speaking world, perhaps extended > to the latin-1 based world. Anyone who wants unicode > identifiers must use Python 3 (or a translated Python like > ChinesePython). Anyone seriously working with Unicode > will find 3.3+ more pleasant, if not required (especially > on Windows). I'll have to admit you make a good point here. Although the argument is diminished by observing that Ruby is far more popular in Asia than Python. Python seems to be mainly a Scandinavian, European, and American toy. For the most part anyway. There are always exceptions to any rule. I mean, think about it: who besides Xah Lee has an Asian name here? And it's been years since we've heard from him! O:-D > On Amazon, the first hit for 'Japanese Python' is Dive > into Python 3 (Japanese edition). As near as I can tell, > there is no Japanese edition for the original Dive into > Python (2). As I remember, half the Python books I saw in > Japan *3 years ago* were for Python 3. > > Overall, I suspect that Python 3 penetration is greater in > Asia. I would agree with that assessment, simply because of the Unicode factor. But i don't believe it's a "large audience". And don't get me wrong, i'm not wishing for the numbers to go one way or another. I just simply want to find the truth. > Rick, I only care about porting of public libraries. > Leave your private code in Python 2. Continue writing new > code in Python 2 if you wish. I only object to those who > pressure others to not port to or writes in Python 3. I don't want to pressure anyone in either direction. We, as the greater python community, did not vote to break backwards compatibility, it was dropped on us like an Acme anvil. But what we _can_ choose, is the version that suits our needs best. I have chosen to remain with 2.x. I encourage others to decide for themselves. I don't think pushing 3.x is any less evil than pushing 2.x -- unless the programmer is a python neophyte. In that case, go with 3.x. > If you want to help 2.7 become better, we need people test > and backport patches to 2.7. Since 2.x bugs me as much as > 3.x seems to bug you, I am considering not backporting > until someone volunteers to help. What do you need help with? Can you be more specific? Of course, a few people on this list are under the impression that i cannot write Python code unless Tkinter is imported first. I guess they think Tkinter is some sort of "magic module" that endows it's importer with mad skills (such as those i posses). Or, it could be that they're unwilling to give me any credit. Who knows? I never did participate in office politics anyway. I'm always too busy getting things done! > Now my question for you or anyone else: If the vast > majority of Python programmers are focused on 2.7, why are > volunteers to help fix 2.7 bugs so scarce? Does they all > consider it perfect (or sufficient) as is? Should the core > developers who do not personally use 2.7 stop backporting, > because no one cares if they do? My guess is that most have become disenfranchised. Perhaps some have moved to other languages. Perhaps some are surviving on old code annuities and don't need to work anymore. The number of programmers in this world is very small, and Python programmers represent a very small subset of _that_ small subset. Which means, small numerical losses can result in extreme damage to the "intellectual fortitude" of a community like ours. The days when the Python community could spare a few minds is over, -- as we have entered an era of Pythonic depression. Perhaps one day we'll look back on these tough times and tell fabulously exaggerated stories of how rugged individualism, and a pinch of community spirit, freed the world from the dark clutches of evil. HISTORY IS DEFINED BY THE WINNERS Let me know where i can be of assistance. It's always a great pleasure to make utter fools of my rivals. >:-) From greg.ewing at canterbury.ac.nz Sat Jul 18 19:32:35 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 19 Jul 2015 11:32:35 +1200 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: Chris Angelico wrote: > Possible alternate syntax: > > transfer func[, (arg1, arg2, arg3)[, {'kw1': val1, 'kw2': val2}]] > > This makes it very clear that this is NOT accepting an arbitrary > expression, but MUST be used with a single function and its arguments. > Downside: It doesn't look like a function call any more. Upside: It's > easy to parse. Personally I'd be fine with your initial syntax, but something else might be needed to get it past Guido. He didn't like my 'cocall f()' construct in PEP 3152, which is syntactically isomorphic to 'transfer f()'. > Is there anything that I've missed out in speccing this up? I've a > suspicion that this might turn out to be as complicated as 'yield > from' in all its handling of edge cases. Presumably it would only work on functions implemented in Python? It's no use discarding the Python stack frame unless the C recursion in the ceval loop can be avoided as well. > Current candidates: > "transfer", "goto", "recurse", and anything else you suggest. Another possibility is "chain", which I've seen in some contexts for an sh exec-like operation. -- Greg From tjreedy at udel.edu Sat Jul 18 19:36:33 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 18 Jul 2015 19:36:33 -0400 Subject: Should non-security 2.7 bugs be fixed? Message-ID: I asked the following as an off-topic aside in a reply on another thread. I got one response which presented a point I had not considered. I would like more viewpoints from 2.7 users. Background: each x.y.0 release normally gets up to 2 years of bugfixes, until x.(y+1).0 is released. For 2.7, released summer 2010, the bugfix period was initially extended to 5 years, ending about now. At the spring pycon last year, the period was extended to 10 years, with an emphasis on security and build fixed. My general question is what other fixes should be made? Some specific forms of this question are the following. If the vast majority of Python programmers are focused on 2.7, why are volunteers to help fix 2.7 bugs so scarce? Does they all consider it perfect (or sufficient) as is? Should the core developers who do not personally use 2.7 stop backporting, because no one cares if they do? -- Terry Jan Reedy From jeanpierreda at gmail.com Sat Jul 18 19:50:52 2015 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sat, 18 Jul 2015 16:50:52 -0700 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: Considering CPython is officially accepting performance improvements to 2.7, surely bug fixes are also allowed? I have contributed both performance improvements and bug fixes to 2.7. In my experience, the problem is not the lack of contributors, it's the lack of code reviewers. I think this is something everyone should care about. The really great thing about working on a project like Python is that not only do you help the programmers who use Python, but also the users who use the software that those programmers create. Python 2.7 is important in the software ecosystem of the world. Fixing bugs and making performance improvements can sometimes significantly help the >1B people who use the software written in Python 2.7. -- Devin On Sat, Jul 18, 2015 at 4:36 PM, Terry Reedy wrote: > I asked the following as an off-topic aside in a reply on another thread. I > got one response which presented a point I had not considered. I would like > more viewpoints from 2.7 users. > > Background: each x.y.0 release normally gets up to 2 years of bugfixes, > until x.(y+1).0 is released. For 2.7, released summer 2010, the bugfix > period was initially extended to 5 years, ending about now. At the spring > pycon last year, the period was extended to 10 years, with an emphasis on > security and build fixed. My general question is what other fixes should be > made? Some specific forms of this question are the following. > > If the vast majority of Python programmers are focused on 2.7, why are > volunteers to help fix 2.7 bugs so scarce? > > Does they all consider it perfect (or sufficient) as is? > > Should the core developers who do not personally use 2.7 stop backporting, > because no one cares if they do? > > -- > Terry Jan Reedy > > -- > https://mail.python.org/mailman/listinfo/python-list From gherron at digipen.edu Sat Jul 18 20:03:02 2015 From: gherron at digipen.edu (Gary Herron) Date: Sat, 18 Jul 2015 17:03:02 -0700 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: <55AAE936.4010306@digipen.edu> On 07/18/2015 04:36 PM, Terry Reedy wrote: > I would like more viewpoints from 2.7 users. I read that (incorrectly of course) and just had to ask: How do you intend to extract a viewpoint from that last 7/10 of a user? With apologies, Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 From breamoreboy at yahoo.co.uk Sat Jul 18 20:09:49 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 01:09:49 +0100 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> Message-ID: On 18/07/2015 23:39, Gregory Ewing wrote: > Marko Rauhamaa wrote: >> At any rate, it demonstrates how the idiom has its place in Python. > > Perhaps it does, but I think I'd still prefer it to be > explicit. > > The call in Marko's example is not actually a tail call > as written. To make it a tail call, a return would need > to be added: > > > return child.setvalue(keyseq, value, offset + 1) > > To someone reading the code, it's not obvious why the > return is there. It looks redundant, and is likely to > get removed by someone who thinks it's a mistake. A time to use perhaps the most abused part of any programming language, a comment? > > Using a dedicated keyword would make it clear that tail > call behaviour is being relied upon, and avoid looking > like a spurious return. > +1 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From python at mrabarnett.plus.com Sat Jul 18 20:14:46 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Jul 2015 01:14:46 +0100 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> <"of> <18> <2015> <12:35:10> <+0200."@mac.com> <55AA2BDE.6050605@web.de> <201507181216.t6ICGBrY022256@fido.openend.se> Message-ID: <55AAEBF6.5040403@mrabarnett.plus.com> On 2015-07-18 19:28, William Ray Wing wrote: > >> On Jul 18, 2015, at 1:34 PM, Mark Lawrence wrote: >> >> > > [byte] > >> What is an {HP calculator} roll operation? >> > > The original Hewlett Packard ?Scientific? calculators (HP-35, 45, 65, etc) that used Polish notation (operand, operand, operation; with no ?=? sign) had a stack. FYI, Polish Notation is a prefix notation; the operation comes first. What you're talking about is Reverse Polish Notation, where the operation comes last. > That stack itself could be manipulated (e.g., interchange X and Y). One of the stack manipulation commands was ?Roll? which moved the top entry into X and pushed remaining elements up one. Later versions had both Roll-up and Roll-down, Roll-down moved the X entry to the top of the stack and dropped the other elements. > > Bill (Who still uses an HP-45 emulator on his iPhone) > From python at mrabarnett.plus.com Sat Jul 18 20:19:51 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Jul 2015 01:19:51 +0100 Subject: A new module for performing tail-call elimination In-Reply-To: References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> Message-ID: <55AAED27.2080200@mrabarnett.plus.com> On 2015-07-18 23:39, Gregory Ewing wrote: > Marko Rauhamaa wrote: >> At any rate, it demonstrates how the idiom has its place in Python. > > Perhaps it does, but I think I'd still prefer it to be > explicit. > > The call in Marko's example is not actually a tail call > as written. To make it a tail call, a return would need > to be added: > > > return child.setvalue(keyseq, value, offset + 1) > > To someone reading the code, it's not obvious why the > return is there. It looks redundant, and is likely to > get removed by someone who thinks it's a mistake. > > Using a dedicated keyword would make it clear that tail > call behaviour is being relied upon, and avoid looking > like a spurious return. > Of the current reserved words, the choice is between 'continue' and 'pass'. How clear is: continue child.setvalue(keyseq, value, offset + 1) ? I think the problem is that it reads like it's something to do with co-routines. From rosuav at gmail.com Sat Jul 18 20:21:30 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 19 Jul 2015 10:21:30 +1000 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: On Sun, Jul 19, 2015 at 9:32 AM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> Possible alternate syntax: >> >> transfer func[, (arg1, arg2, arg3)[, {'kw1': val1, 'kw2': val2}]] >> >> This makes it very clear that this is NOT accepting an arbitrary >> expression, but MUST be used with a single function and its arguments. >> Downside: It doesn't look like a function call any more. Upside: It's >> easy to parse. > > > Personally I'd be fine with your initial syntax, but > something else might be needed to get it past Guido. > He didn't like my 'cocall f()' construct in PEP 3152, > which is syntactically isomorphic to 'transfer f()'. Maybe it should get written up and rejected, then, to be something to point to any time anyone advocates TCO. >> Is there anything that I've missed out in speccing this up? I've a >> suspicion that this might turn out to be as complicated as 'yield >> from' in all its handling of edge cases. > > > Presumably it would only work on functions implemented > in Python? It's no use discarding the Python stack frame > unless the C recursion in the ceval loop can be avoided > as well. Hmm. Conceptually, I'd like it to work like this: def f(x): return from g(x+1) x = f(3) # absolutely identical to x = g(4) Is it possible to strip away the current Python stack frame and replace it with a C stack frame? That would be the most logical, if it's viable. It'd also mean that other Python implementations are all looking at things on the same footing. Obviously 'return from' (or whatever keyword is used) would be valid only from a Python function, but ideally it could chain to a function written in any form. >> Current candidates: >> "transfer", "goto", "recurse", and anything else you suggest. > > > Another possibility is "chain", which I've seen in some > contexts for an sh exec-like operation. Hah, that brings me back! "Chaining was attempted from a REXX batch file". I never understood why typing the name of a batch file would do a one-way chain/exec rather than a more logical call. Unix has that much better. Downside: The name "chain" is highly likely to exist in people's code. I'm liking "return from", as it's currently illegal, uses existing keywords, and parallels with "yield from". But as a term for describing what happens, "chain" works well. ChrisA From breamoreboy at yahoo.co.uk Sat Jul 18 20:27:23 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 01:27:23 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On 19/07/2015 00:36, Terry Reedy wrote: > I asked the following as an off-topic aside in a reply on another > thread. I got one response which presented a point I had not considered. > I would like more viewpoints from 2.7 users. > > Background: each x.y.0 release normally gets up to 2 years of bugfixes, > until x.(y+1).0 is released. For 2.7, released summer 2010, the bugfix > period was initially extended to 5 years, ending about now. At the > spring pycon last year, the period was extended to 10 years, with an > emphasis on security and build fixed. My general question is what other > fixes should be made? Some specific forms of this question are the > following. > > If the vast majority of Python programmers are focused on 2.7, why are > volunteers to help fix 2.7 bugs so scarce? > > Does they all consider it perfect (or sufficient) as is? > > Should the core developers who do not personally use 2.7 stop > backporting, because no one cares if they do? > Programmers don't much like doing maintainance work when they're paid to do it, so why would they volunteer to do it? Then even if you do the work to fix *ANY* bug there is no guarantee that it gets committed. The last "Summary of Python tracker Issues" over on python-dev giving 4947 open issues of which 2260 have patches speaks for itself. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From rosuav at gmail.com Sat Jul 18 20:27:48 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 19 Jul 2015 10:27:48 +1000 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On Sun, Jul 19, 2015 at 9:36 AM, Terry Reedy wrote: > If the vast majority of Python programmers are focused on 2.7, why are > volunteers to help fix 2.7 bugs so scarce? > > Does they all consider it perfect (or sufficient) as is? > > Should the core developers who do not personally use 2.7 stop backporting, > because no one cares if they do? I use Linux on all my computers, but I wouldn't be volunteering to help fix kernel bugs, because I'm not competent to. I also compile C code now and then, but don't offer to fix GCC bugs. There may well be huge numbers of people who write Python code who don't feel they can contribute in that way (whether or not that's strictly true - after all, half of Python is written in Python anyway). ChrisA From denismfmcmahon at gmail.com Sat Jul 18 20:59:18 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Sun, 19 Jul 2015 00:59:18 +0000 (UTC) Subject: Need assistance References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: On Sat, 18 Jul 2015 12:35:10 +0200, Sibylle Koczian wrote: > Am 18.07.2015 um 02:40 schrieb Denis McMahon: >> Having a list of words, get a copy of the list in reverse order. See >> the reversed function (and maybe the list function). > That won't really help, because the desired order is, with the example > the OP used: Sirna Daniel Craig. So here indexing is necessary, but > indexing of the list elements, not of the characters in the string. Oh, then it's even easier, yes, it's mainly a case of list indexing. 1) Split the original string into a list of words (string.split() method) 2) create a sublist (s1) of the last element 3) create another sublist (s2) of the first to penultimate elements 4) combine the two sublists 5) use the string.join() method to combine the sublist elements into a single string I think most pythonistas would probably combine steps 2 through 4 in a single line of code, possibly even steps 2 through 5. -- Denis McMahon, denismfmcmahon at gmail.com From tjreedy at udel.edu Sat Jul 18 21:34:21 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 18 Jul 2015 21:34:21 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On 7/18/2015 8:27 PM, Mark Lawrence wrote: > On 19/07/2015 00:36, Terry Reedy wrote: >> I asked the following as an off-topic aside in a reply on another >> thread. I got one response which presented a point I had not considered. >> I would like more viewpoints from 2.7 users. >> >> Background: each x.y.0 release normally gets up to 2 years of bugfixes, >> until x.(y+1).0 is released. For 2.7, released summer 2010, the bugfix >> period was initially extended to 5 years, ending about now. At the >> spring pycon last year, the period was extended to 10 years, with an >> emphasis on security and build fixed. My general question is what other >> fixes should be made? Some specific forms of this question are the >> following. >> >> If the vast majority of Python programmers are focused on 2.7, why are >> volunteers to help fix 2.7 bugs so scarce? >> >> Does they all consider it perfect (or sufficient) as is? >> >> Should the core developers who do not personally use 2.7 stop >> backporting, because no one cares if they do? >> > > Programmers don't much like doing maintainance work when they're paid to > do it, so why would they volunteer to do it? Right. So I am asking: if a 3.x user volunteers a 3.x patch and a 3.x core developer reviews and edits the patch until it is ready to commit, why should either of them volunteer to do a 2.7 backport that they will not use? I am suggesting that if there are 10x as many 2.7only programmers as 3.xonly programmers, and none of the 2.7 programmers is willing to do the backport *of an already accepted patch*, then maybe it should not be done at all. > Then even if you do the > work to fix *ANY* bug there is no guarantee that it gets committed. I am discussing the situation where there *is* a near guarantee (if the backport works and does not break anything and has not been so heavily revised as to require a separate review). -- Terry Jan Reedy From rantingrickjohnson at gmail.com Sat Jul 18 22:04:45 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Jul 2015 19:04:45 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: <81d8a5ec-3ee3-46a5-aa64-96c05642089c@googlegroups.com> On Saturday, July 18, 2015 at 6:37:41 PM UTC-5, Terry Reedy wrote: > If the vast majority of Python programmers are focused on > 2.7, why are volunteers to help fix 2.7 bugs so scarce? Because newer code is always more buggy than older code (when both get significant attention that is). There were quite a few growing pains after Py3 was released. All of this required massive attention. This explains the "hype" for Py3. > Does they all consider it perfect (or sufficient) as is? No, but it works, and it works without bug-fixing old repos. > Should the core developers who do not personally use 2.7 stop > backporting, because no one cares if they do? I think that would be an awful mistake. The last thing you want is rumors spreading that Python is buggy. Even if only Python2 becomes buggy, it's bugginess with affect Python3's reputation. TEAMLEADER: Should we use Python for project X? MEMBER1: I don't know, i heard Python was buggy??? MEMBER2: *AND* the community is fractured! Member3: Which begs the question: Which version is going be around in few years? MEMBER4: And what if his "holiness" decides to break compatibility again? MEMBER5: Perhaps this time he'll make print a method of some new stdout object! TEAMLEADER: Yup. Let's make this easy and go with Ruby. A bad reputation can ruin a language. I would warn against allowing any version of Python to become buggy. Security or otherwise. The future of Python is literally hanging by a thread. From tjreedy at udel.edu Sat Jul 18 22:13:28 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 18 Jul 2015 22:13:28 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: > Considering CPython is officially accepting performance improvements I was not exactly aware of that. > to 2.7, surely bug fixes are also allowed? Of course, allowed. But should they be made, and if so, by who? > I have contributed both performance improvements and bug fixes to 2.7. > In my experience, the problem is not the lack of contributors, it's > the lack of code reviewers. I understand the general problem quite well. But feeling that one would have to do a 2.7 backport after writing, editing, or reviewing a 3.x patch can discourage doing a review in the first place. I am at that point now with respect to Idle patches. > I think this is something everyone should care about. The really great > thing about working on a project like Python is that not only do you > help the programmers who use Python, but also the users who use the > software that those programmers create. Python 2.7 is important in the > software ecosystem of the world. Fixing bugs and making performance > improvements can sometimes significantly help the >1B people who use > the software written in Python 2.7. > > -- Devin > > On Sat, Jul 18, 2015 at 4:36 PM, Terry Reedy wrote: >> I asked the following as an off-topic aside in a reply on another thread. I >> got one response which presented a point I had not considered. I would like >> more viewpoints from 2.7 users. >> >> Background: each x.y.0 release normally gets up to 2 years of bugfixes, >> until x.(y+1).0 is released. For 2.7, released summer 2010, the bugfix >> period was initially extended to 5 years, ending about now. At the spring >> pycon last year, the period was extended to 10 years, with an emphasis on >> security and build fixed. My general question is what other fixes should be >> made? Some specific forms of this question are the following. >> >> If the vast majority of Python programmers are focused on 2.7, why are >> volunteers to help fix 2.7 bugs so scarce? >> >> Does they all consider it perfect (or sufficient) as is? >> >> Should the core developers who do not personally use 2.7 stop backporting, >> because no one cares if they do? >> >> -- >> Terry Jan Reedy >> >> -- >> https://mail.python.org/mailman/listinfo/python-list -- Terry Jan Reedy From jeanpierreda at gmail.com Sat Jul 18 22:33:21 2015 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sat, 18 Jul 2015 19:33:21 -0700 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On Sat, Jul 18, 2015 at 6:34 PM, Terry Reedy wrote: > On 7/18/2015 8:27 PM, Mark Lawrence wrote: >> On 19/07/2015 00:36, Terry Reedy wrote: >> Programmers don't much like doing maintainance work when they're paid to >> do it, so why would they volunteer to do it? > > Right. So I am asking: if a 3.x user volunteers a 3.x patch and a 3.x core > developer reviews and edits the patch until it is ready to commit, why > should either of them volunteer to do a 2.7 backport that they will not use? Because it helps even more people. The reason people make upstream contributions is so that the world benefits. If you only wanted to help yourself, you'd just patch CPython locally, and not bother contributing anything upstream. > I am suggesting that if there are 10x as many 2.7only programmers as 3.xonly > programmers, and none of the 2.7 programmers is willing to do the backport > *of an already accepted patch*, then maybe it should not be done at all. That just isn't true. I have backported 3.x patches. Other people have backported entire modules. It gets really boring submitting 2.7-specific patches, though, when they aren't accepted, and the committers have such a hostile attitude towards it. I was told by core devs that, instead of fixing bugs in Python 2, I should just rewrite my app in Python 3. It has even been implied that bugs in Python 2 are *good*, because that might help with Python 3 adoption. >> Then even if you do the >> work to fix *ANY* bug there is no guarantee that it gets committed. > > I am discussing the situation where there *is* a near guarantee (if the > backport works and does not break anything and has not been so heavily > revised as to require a separate review). That is not how I have experienced contribution to CPython. No, the patches are *not* guaranteed, and in my experience they are not likely to be accepted. If the issue was closed as fixed before I contributed the backported patch, does anyone even see it? -- Devin From torriem at gmail.com Sat Jul 18 22:46:18 2015 From: torriem at gmail.com (Michael Torrie) Date: Sat, 18 Jul 2015 20:46:18 -0600 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <55AA2BDE.6050605@web.de> of "Sat 18 Jul 2015 12:35:10 +0200." <55AA2BDE.6050605@web.de> <201507181216.t6ICGBrY022256@fido.openend.se> Message-ID: <55AB0F7A.10802@gmail.com> On 07/18/2015 03:44 PM, Dennis Lee Bieber wrote: > The new units (HP28, 48, 49, 50, etc.) no longer use the 4-register > stack; the stack is whatever is available in memory. As a result, the Roll > instructions now need an argument for how many stack entries are in play. > > The HP50g has a bit of a sluggish response compared to the 48sx [which > is not equivalent to a 48g]. Might be since the 48sx is still a SATURN > hardware processor. The 50g is an underclocked (for battery life) ARM, > running a SATURN emulator, with the emulator running the RPL/RPN user > interface (there are packages that let one program in SYSRPL [which > bypasses all the user level data checks, so if one knows the data on the > stack is good, one can speed up subsequent operations], SATURN assembly, > AND ARM assembly). > > For $20 or so one can get the HP Prime as an Android app. My list of must-have android apps on my phone and tablet include Droid48, which is an android port of X48. Runs the original firmware and everything. Works very well for me. Of course I also use my real HP 48 on regular basis. The poor thing is 20 years old now but still the most useful calculator I've ever owned. I get lost on calculators without a stack and RPN. Had a debate with m boss over RPN though. He claimed it was just HP's engineers being lazy. For me RPN on a stack is faster for me than a normal calculator because it's closer to how my brain does math--you have to manually do order of operations on paper. Just the other day I learned how to implement custom units on my hp 48 and have them automatically convert to other units. Very cool. From zachary.ware+pylist at gmail.com Sat Jul 18 22:48:36 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Sat, 18 Jul 2015 21:48:36 -0500 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On Sat, Jul 18, 2015 at 9:13 PM, Terry Reedy wrote: > I understand the general problem quite well. But feeling that one would > have to do a 2.7 backport after writing, editing, or reviewing a 3.x patch > can discourage doing a review in the first place. I am at that point now > with respect to Idle patches. I wonder if it would be worth the significant one-time effort to port IDLE to 2/3, so that future bugfixes/improvements don't require any extra effort than testing them with all versions. -- Zach From rantingrickjohnson at gmail.com Sat Jul 18 22:49:42 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Jul 2015 19:49:42 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: <26e80e77-6648-41c8-b0ad-c35f343d6d37@googlegroups.com> On Saturday, July 18, 2015 at 9:34:20 PM UTC-5, Devin Jeanpierre wrote: > It has even been implied that bugs in Python 2 are *good*, > because that might help with Python 3 adoption. So now we're implementing coercion, Microsoft style? What's next, paid subscriptions to superficial, and backwards incompatible, upgrades every two years? Perhaps after that, we can roll our own security vulnerabilities and inject them into the deprecated source downloads! You'll pay 2x users! You'll pay! And your little repos too! From rustompmody at gmail.com Sat Jul 18 23:06:48 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 18 Jul 2015 20:06:48 -0700 (PDT) Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: <4c0b6646-f5c9-4dee-8686-00beafb46205@googlegroups.com> On Saturday, July 18, 2015 at 9:18:32 AM UTC+5:30, Serhiy Storchaka wrote: > On 17.07.15 02:46, Chris Angelico wrote: > > Out of the lengthy thread on tail call optimization has come one broad > > theory that might be of interest, so I'm spinning it off into its own > > thread. > > > > The concept is like the Unix exec[vlpe] family of functions: replace > > the current stack frame with a new one. This can be used for explicit > > tail recursion without repeated stack frames, or for a pre-check that > > then disappears out of the stack. Like any other feature, it can be > > misused to make debugging difficult, but among consenting adults, > > hopefully it can be used sensibly. > > I think there is no chance that this proposition will be accepted by > Guido, because it makes debugging harder. I personally thought Chris was being tongue-in-cheek with this suggestion. Taking it more seriously, here are some thoughts. Given: 1. A new keyword is a more deep change than a new optimzation flag 2. The tail-call site is (arguably!) more crucial than the tail-call So why not have a tco decorator such that @tco def foo(...): body will have tail-calls in body optimized? My guess is that someone who knows enough of python's code generator may even be able to do it in pure python; ie with no change to the language in foo.__code__.co_code, replace code of the form "... call; ret..." with "...goto..." From no.email at nospam.invalid Sat Jul 18 23:45:53 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Sat, 18 Jul 2015 20:45:53 -0700 Subject: Should non-security 2.7 bugs be fixed? References: Message-ID: <87egk4zu6m.fsf@jester.gateway.sonic.net> Terry Reedy writes: > I am suggesting that if there are 10x as many 2.7only programmers as > 3.xonly programmers, and none of the 2.7 programmers is willing to do > the backport *of an already accepted patch*, then maybe it should not > be done at all. The patch acceptance/approval process is frankly daunting. From rustompmody at gmail.com Sat Jul 18 23:52:39 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 18 Jul 2015 20:52:39 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> On Sunday, July 19, 2015 at 8:04:20 AM UTC+5:30, Devin Jeanpierre wrote: > On Sat, Jul 18, 2015 at 6:34 PM, Terry Reedy wrote: > > On 7/18/2015 8:27 PM, Mark Lawrence wrote: > >> On 19/07/2015 00:36, Terry Reedy wrote: > >> Programmers don't much like doing maintainance work when they're paid to > >> do it, so why would they volunteer to do it? > > > > Right. So I am asking: if a 3.x user volunteers a 3.x patch and a 3.x core > > developer reviews and edits the patch until it is ready to commit, why > > should either of them volunteer to do a 2.7 backport that they will not use? > > Because it helps even more people. The reason people make upstream > contributions is so that the world benefits. If you only wanted to > help yourself, you'd just patch CPython locally, and not bother > contributing anything upstream. > > > I am suggesting that if there are 10x as many 2.7only programmers as 3.xonly > > programmers, and none of the 2.7 programmers is willing to do the backport > > *of an already accepted patch*, then maybe it should not be done at all. > > That just isn't true. I have backported 3.x patches. Other people have > backported entire modules. > > It gets really boring submitting 2.7-specific patches, though, when > they aren't accepted, and the committers have such a hostile attitude > towards it. I was told by core devs that, instead of fixing bugs in > Python 2, I should just rewrite my app in Python 3. It has even been > implied that bugs in Python 2 are *good*, because that might help with > Python 3 adoption. > > >> Then even if you do the > >> work to fix *ANY* bug there is no guarantee that it gets committed. > > > > I am discussing the situation where there *is* a near guarantee (if the > > backport works and does not break anything and has not been so heavily > > revised as to require a separate review). > > That is not how I have experienced contribution to CPython. No, the > patches are *not* guaranteed, and in my experience they are not likely > to be accepted. > > If the issue was closed as fixed before I contributed the backported > patch, does anyone even see it? Not to mention actively hostile attitude to discussions that could at the moment be tangential to current CPython. See (and whole thread) https://mail.python.org/pipermail/python-ideas/2015-May/033708.html JFTR: My kids (um... students) have just managed to add devanagari numerals to python. ie we can now do >>> ? + ? 3 [The devanagari equivalent of "12334567890" is "??????????" And also for those who may not be familiar, devanagari is the script for sanskrit, hindi and a slew of (north) Indian languages ] Regarding this as a fork of python is technically (legalistically) correct but pragmatically ridiculous [unless my students spell as 'Linus Torvalds' or somethin...]. Note that while I dont regard that specific answer as representative of the python-community at large, it is also true that a little help -- even brusque RTFM answers? -- would have seen us farther than "If this is what you are up to, get out of here" tl;dr: Not so much a complaint but a indicator that people who could potentially contribute are being prevented from entering ------ ? For me, RTFM is always welcome if accompanied by which FM From rustompmody at gmail.com Sun Jul 19 00:04:06 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 18 Jul 2015 21:04:06 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87egk4zu6m.fsf@jester.gateway.sonic.net> References: <87egk4zu6m.fsf@jester.gateway.sonic.net> Message-ID: <3de0c3f8-7dc1-49b3-a7a0-bef388f3a8ed@googlegroups.com> On Sunday, July 19, 2015 at 9:16:08 AM UTC+5:30, Paul Rubin wrote: > Terry Reedy writes: > > I am suggesting that if there are 10x as many 2.7only programmers as > > 3.xonly programmers, and none of the 2.7 programmers is willing to do > > the backport *of an already accepted patch*, then maybe it should not > > be done at all. > > The patch acceptance/approval process is frankly daunting. And it should be. Ive used python for some 15 years now and more than any particular language aspect or feature, the aspect that keeps it in my core tool box is its reliability: Mostly it does what I expect, and allowing a teacher to open the interpreter in a class and hack real-time on coding depends on a certain stability that I personally find very valuable. So I would like to make a distinction between *approvals* being daunting and *discussions* (for patches) being tolerated though (mostly) not being accepted. Of course I accept that this can be unrealistic: Having to email: "Sorry -- Unacceptable" can itself get out of hand if/when the number of well-meaning ignoramus suggestions crosses a threshold From rantingrickjohnson at gmail.com Sun Jul 19 00:18:11 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Jul 2015 21:18:11 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> Message-ID: <0686a5a3-5bca-4045-a7f9-ff86e6439272@googlegroups.com> On Saturday, July 18, 2015 at 10:52:51 PM UTC-5, Rustom Mody wrote: > tl;dr: Not so much a complaint but a indicator that people > who could potentially contribute are being prevented from > entering EXACTLY! If this community fails, it won't be due to old members walking out of the back door, no, it will be because the front door was slammed shut and nails were driven into the frame, preventing new members from entering! We are not in a freaking zombie movie people! We're in a freaking community! And communities require doors to be unlocked during business hours. Communities require welcome mats. But mostly of all, communities require hospitality. From steve at pearwood.info Sun Jul 19 00:45:11 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 19 Jul 2015 14:45:11 +1000 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> Message-ID: <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> On Sun, 19 Jul 2015 01:52 pm, Rustom Mody wrote: > Not to mention actively hostile attitude to discussions that could at the > moment be tangential to current CPython. See (and whole thread) > https://mail.python.org/pipermail/python-ideas/2015-May/033708.html I stand by my comments there. I have no disagreement with your aim to build a specialised language for teaching functional programming. I don't believe that should be Python. > JFTR: My kids (um... students) have just managed to add devanagari > numerals to python. > ie we can now do > >>>> ? + ? > 3 That is actually quite awesome, and I would support a new feature that set the numeric characters to a particular script, e.g. Latin, Arabic, Devanagari, whatever, and printed them in that same script. It seems unfortunate that ? + ? prints as 3 rather than ?. Python already, and has for many years, supported non-ASCII digits in string conversions. This is in Python 2.4: py> int(u'??') 12 py> float(u'.??') 0.12 so the feature goes back a long time. I think that Python should allow int and float literals using any sequences of digits from the same language, e.g. 12 or ?? but not ?2. One might have an interpreter hook which displayed ints and floats using non-ASCII digits, or one might even build that function into the intepreter, e.g. have a global setting which tells ints and floats what digits to use, e.g.: sys.setdigits('Devanagari') I would support this, or something like this, as a language feature. If we can write Python using Hindi identifiers, why not Hindi numerals? > Regarding this as a fork of python is technically (legalistically) correct > but pragmatically ridiculous [unless my students spell as 'Linus Torvalds' > or somethin...]. There's a grey area between a fork and a local patch. Ever fork begins as a local patch. It only becomes a fork if you go public with it, give it a new name, etc. Forks can be highly respected, e.g. Stackless is a fork of CPython. -- Steven From steve at pearwood.info Sun Jul 19 00:45:40 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 19 Jul 2015 14:45:40 +1000 Subject: Should non-security 2.7 bugs be fixed? References: Message-ID: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> On Sun, 19 Jul 2015 12:33 pm, Devin Jeanpierre wrote: [...] > Because it helps even more people. The reason people make upstream > contributions is so that the world benefits. If you only wanted to > help yourself, you'd just patch CPython locally, and not bother > contributing anything upstream. And have your patch disappear when you upgrade Python? No thanks. [...] > It gets really boring submitting 2.7-specific patches, though, when > they aren't accepted, and the committers have such a hostile attitude > towards it. I was told by core devs that, instead of fixing bugs in > Python 2, I should just rewrite my app in Python 3. Really? Can you point us to this discussion? If you are right, and that was an official pronouncement, then it seems that non-security bug fixes to 2.7 are forbidden. I suspect though that it's not quite that black and white. Perhaps there was some doubt about whether or not the patch in question was fixing a bug or adding a feature (a behavioural change). Or the core dev in question was speaking for themselves, not for all. > It has even been > implied that bugs in Python 2 are *good*, because that might help with > Python 3 adoption. Really? Can you point us to this discussion? As they say on Wikipedia, Citation Needed. I would like to see the context before taking that at face value. -- Steven From rosuav at gmail.com Sun Jul 19 01:06:49 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 19 Jul 2015 15:06:49 +1000 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jul 19, 2015 at 2:45 PM, Steven D'Aprano wrote: > I think that Python should allow int and float literals using any sequences > of digits from the same language, e.g. 12 or ?? but not ?2. I would agree with this. Actually, given that int("??") works just fine, I was surprised that it didn't already work in syntax. > One might have > an interpreter hook which displayed ints and floats using non-ASCII digits, > or one might even build that function into the intepreter, e.g. have a > global setting which tells ints and floats what digits to use, e.g.: > > sys.setdigits('Devanagari') Easiest way to play with this would be a sys.displayhook, I think; I suspect it would be problematic to change int.__str__ or int.__repr__. But for interactive work, yep, definitely, it should be easy enough to make int and float display appropriately. ChrisA From steve at pearwood.info Sun Jul 19 01:39:08 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 19 Jul 2015 15:39:08 +1000 Subject: Integers with leading zeroes Message-ID: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> In Python 2, integer literals with leading zeroes are treated as octal, so 09 is a syntax error and 010 is 8. This is confusing to those not raised on C-style octal literals, so in Python 3 leading zeroes are prohibited in int literals. Octal is instead written using the prefix 0o, similar to hex 0x and binary 0b. Consequently Python 3 makes both 09 and 010 a syntax error. However there is one exception: zero itself is allowed any number of leading zeroes, so 00000 is a legal way to write zero as a base-10 int literal. Does anyone use that (mis)feature? -- Steven From ian.g.kelly at gmail.com Sun Jul 19 01:46:08 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 18 Jul 2015 23:46:08 -0600 Subject: Integers with leading zeroes In-Reply-To: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Jul 18, 2015 at 11:39 PM, Steven D'Aprano wrote: > In Python 2, integer literals with leading zeroes are treated as octal, so > 09 is a syntax error and 010 is 8. > > This is confusing to those not raised on C-style octal literals, so in > Python 3 leading zeroes are prohibited in int literals. Octal is instead > written using the prefix 0o, similar to hex 0x and binary 0b. > > Consequently Python 3 makes both 09 and 010 a syntax error. > > However there is one exception: zero itself is allowed any number of leading > zeroes, so 00000 is a legal way to write zero as a base-10 int literal. It's obviously a base-8 literal, not a base-10 literal. :-P > Does anyone use that (mis)feature? I don't, but why should it matter? From dieter at handshake.de Sun Jul 19 01:53:50 2015 From: dieter at handshake.de (dieter) Date: Sun, 19 Jul 2015 07:53:50 +0200 Subject: Should non-security 2.7 bugs be fixed? References: Message-ID: <87r3o4wv4h.fsf@handshake.de> Mark Lawrence writes: > ... >> If the vast majority of Python programmers are focused on 2.7, why are >> volunteers to help fix 2.7 bugs so scarce? I have not done much work related to Python bug fixing. But, I had bad experience with other open source projects: many of my patches (and bug reports) have been ignored over decades. This caused me to change my attitude: I now report bugs (sometimes with patches) and publish a potential solution in a separate package (--> "dm.zopepatches.*", "dm.zodbpatches.*"). This way, affected people can use a solution even if the core developpers don't care. >From my point of view: if you want help with fixing bugs, you must ensure that there is a high probability that those contributions really find their way into the main development lines. As I understand from other messages in this thread, this is also a problem with Python bug fixing. >> Does they all consider it perfect (or sufficient) as is? I have not much blame for Python 2.7. I see a few minor points * "pdb" is quite weak - but I could fix some (but by far not all) aspects in "dm.pdb". * "https" has been weakly handled in earlier versions, but someone has done the Python 3 backport work in an external package before the backport finally arrived in Python 2.7. >> Should the core developers who do not personally use 2.7 stop >> backporting, because no one cares if they do? I am grateful that the above mentioned "https" backport was finally integrated into Python 2.7 -- even though I find it acceptable to use an external package to get it. Thus, there are people who care. Of course, I will not tell core developers that they must do backporting. If they don't more external packages will come into existence which contain (unofficial) backports. From lanuradha at gmail.com Sun Jul 19 02:25:30 2015 From: lanuradha at gmail.com (Anuradha Laxminarayan) Date: Sat, 18 Jul 2015 23:25:30 -0700 (PDT) Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sunday, July 19, 2015 at 10:15:37 AM UTC+5:30, Steven D'Aprano wrote: > On Sun, 19 Jul 2015 01:52 pm, Rustom Mody wrote: > > > Not to mention actively hostile attitude to discussions that could at the > > moment be tangential to current CPython. See (and whole thread) > > https://mail.python.org/pipermail/python-ideas/2015-May/033708.html > > I stand by my comments there. I have no disagreement with your aim to build > a specialised language for teaching functional programming. I don't believe > that should be Python. > > > > JFTR: My kids (um... students) have just managed to add devanagari > > numerals to python. > > ie we can now do > > > >>>> ? + ? > > 3 > > That is actually quite awesome, and I would support a new feature that set > the numeric characters to a particular script, e.g. Latin, Arabic, > Devanagari, whatever, and printed them in that same script. It seems > unfortunate that ? + ? prints as 3 rather than ?. Thanks. [I am part of this team] > > Python already, and has for many years, supported non-ASCII digits in string > conversions. This is in Python 2.4: > > py> int(u'??') > 12 > py> float(u'.??') > 0.12 > Very useful to know! > > so the feature goes back a long time. > > I think that Python should allow int and float literals using any sequences > of digits from the same language, e.g. 12 or ?? but not ?2. One might have > an interpreter hook which displayed ints and floats using non-ASCII digits, > or one might even build that function into the intepreter, e.g. have a > global setting which tells ints and floats what digits to use, e.g.: > > sys.setdigits('Devanagari') > Currently our code works with UTF-8 byte sequences not unicode codepoints because thats how tokenizer.c is structured: messy and not generalizable (easily) to things beyond devanagari. How far this can be improved (without too deep surgery) is not quite clear yet. In other words, this generality is nice to talk about but easier said than done at the moment. From marko at pacujo.net Sun Jul 19 02:29:45 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 19 Jul 2015 09:29:45 +0300 Subject: A new module for performing tail-call elimination References: <55a3dcd9$0$3024$426a34cc@news.free.fr> <55A6280C.3090602@rece.vub.ac.be> <55A76116.7070708@rece.vub.ac.be> <87lhefanui.fsf@elektro.pacujo.net> Message-ID: <87y4ic7j8m.fsf@elektro.pacujo.net> Gregory Ewing : > Marko Rauhamaa wrote: >> At any rate, it demonstrates how the idiom has its place in Python. > > Perhaps it does, but I think I'd still prefer it to be explicit. Don't get me wrong. The method doesn't depend on tail call elimination. It couldn't because its sibling method has the same recursion depth without the possibility of tail call elimination. I was just showing an example of an iteration expressed idiomatically through a tail call. > The call in Marko's example is not actually a tail call as written. To > make it a tail call, a return would need to be added: > >> return child.setvalue(keyseq, value, offset + 1) Adding the return statement there would be bad because it would suggest to the maintainer of the code that the method has a meaningful return value, which it doesn't. > To someone reading the code, it's not obvious why the return is there. > It looks redundant, and is likely to get removed by someone who thinks > it's a mistake. Exactly. That's why I said also that it is unfortunate for Python to promise to return None implicitly. That stipulation of the language specification is against the de-facto semantics of procedures (your sentence above) and effectively prevents automatic tail call optimizations. > Using a dedicated keyword would make it clear that tail call behaviour > is being relied upon, and avoid looking like a spurious return. A dedicated keyword would indeed work as advertised. However, I'm not too keen on the idea. My position is: Python probably should have made tail call elimination a matter of course, but since it doesn't, oh well. Marko From tjreedy at udel.edu Sun Jul 19 02:44:08 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 02:44:08 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> Message-ID: On 7/18/2015 11:52 PM, Rustom Mody wrote: > Not to mention actively hostile attitude to discussions that could at the > moment be tangential to current CPython. See (and whole thread) > https://mail.python.org/pipermail/python-ideas/2015-May/033708.html Rustom, I think this is grossly unfair. Python-ideas was started by Guido as a forum for ideas about *future* versions of Python. Your post was about teaching Python,which is something different, as are lost of other Python-related topics. It would have fit either this list or edu-sig better. Your post https://mail.python.org/pipermail/python-ideas/2015-May/033661.html started a thread with nearly 40 responses, which is far more than average. Thou doth protest too much. This https://mail.python.org/pipermail/python-ideas/2015-May/thread.html#33672 is the list for May; there might be a few more in June. To the extent that you were (vaguely) proposing a change to core python itself, by splitting it up into 'teachpacks' (whatever those are) and 'concentric rings', the idea was quickly rejected. It is too specialized, being aimed as one use, and impractically complicated for a mostly volunteer development group. It is the sort of thing one might do with a $5 million grant. Beyond that, the thread veered ogf onto topics that even you labelled off-topic. Yes, we are hostile to prolonged off-topic discussions. They detract from the purpose of the list. -- Terry Jan Reedy From marko at pacujo.net Sun Jul 19 03:16:09 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 19 Jul 2015 10:16:09 +0300 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87twt07h3a.fsf@elektro.pacujo.net> Chris Angelico : > On Sun, Jul 19, 2015 at 2:45 PM, Steven D'Aprano wrote: >> sys.setdigits('Devanagari') > > Easiest way to play with this would be a sys.displayhook, I think; I think the numeral selection is analogous to the number base: >>> 0o10 8 >>> "{:o}".format(0o10) '10' what we need is: >>> "{:d/base({base})}".format(0o10, base=7) '11' >>> "{:d/numeral('{num}')".format(0o10, num="European") '8' >>> "{:d/numeral('{num}')".format(0o10, num="Roman") 'VIII' >>> "{:d/numeral('{num}')".format(0o10, num="RomanLowerCase") 'viii' >>> "{:d/numeral('{num}')".format(0o10, num="EasternArabic") '?' >>> "{:d/numeral('{num}')".format(0o10, num="Devanagari") '?' IOW, don't make it global. Marko From rustompmody at gmail.com Sun Jul 19 03:32:59 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 19 Jul 2015 00:32:59 -0700 (PDT) Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <87twt07h3a.fsf@elektro.pacujo.net> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <87twt07h3a.fsf@elektro.pacujo.net> Message-ID: <1fc552fc-5504-434a-8fdd-2bdd88afc4d7@googlegroups.com> On Sunday, July 19, 2015 at 12:46:26 PM UTC+5:30, Marko Rauhamaa wrote: > Chris Angelico: > > > On Sun, Jul 19, 2015 at 2:45 PM, Steven D'Aprano wrote: > >> sys.setdigits('Devanagari') > > > > Easiest way to play with this would be a sys.displayhook, I think; > > I think the numeral selection is analogous to the number base: Nice analogy > > >>> 0o10 > 8 > >>> "{:o}".format(0o10) > '10' > > what we need is: > > >>> "{:d/base({base})}".format(0o10, base=7) > '11' > >>> "{:d/numeral('{num}')".format(0o10, num="European") > '8' > >>> "{:d/numeral('{num}')".format(0o10, num="Roman") > 'VIII' > >>> "{:d/numeral('{num}')".format(0o10, num="RomanLowerCase") > 'viii' > >>> "{:d/numeral('{num}')".format(0o10, num="EasternArabic") > '?' > >>> "{:d/numeral('{num}')".format(0o10, num="Devanagari") > '?' > > IOW, don't make it global. But it is willy-nilly global. Python: >>> 4+5 9 >>> Unix bc: $ bc bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 4+5 9 obase=8 4+5 11 IOW bc has two (global) variables ibase and obase for input and output base. If you dont provide these as settable you hardwire them at 10 (8/16 in some assembly languages)? Hopefully you will agree that python is more full-featured than bc and should subsume bc functionality? [Implementability is a second question and ease of implementability a third] I believe numeral-language is similar --- ? When Ive played around with writing assemblers for toy machines, the hardwired 10-base has often been a nuisance. Of course one can in principle rebuild an REPL. Repurposing the existing one is usually a far more palatable option (for me). From marko at pacujo.net Sun Jul 19 03:44:15 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 19 Jul 2015 10:44:15 +0300 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <87twt07h3a.fsf@elektro.pacujo.net> <1fc552fc-5504-434a-8fdd-2bdd88afc4d7@googlegroups.com> Message-ID: <87pp3o7fsg.fsf@elektro.pacujo.net> Rustom Mody : > On Sunday, July 19, 2015 at 12:46:26 PM UTC+5:30, Marko Rauhamaa wrote: >> IOW, don't make it global. > > But it is willy-nilly global. > Python: >>>> 4+5 > 9 The interactive mode is not all that interesting, but ok, make that configurable as well. Marko From skybuck2000 at hotmail.com Sun Jul 19 04:19:18 2015 From: skybuck2000 at hotmail.com (Skybuck Flying) Date: Sun, 19 Jul 2015 10:19:18 +0200 Subject: Integers with leading zeroes In-Reply-To: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> Message-ID: <17c85$55ab5d66$5419aafe$47498@news.ziggo.nl> Don't be noob ? ;) Always remove leading zeroes ? One case that comes to mind is ASCII art like code... where programmer may want to align numbers for clearity: 0014324 0234545 0000345 0534543 ^ That could be a problem but possibly solveable with spaces instead: 14324 234545 345 534543 ^ Looks less good though in non-fixed-sized font. Bye, Skybuck. From tjreedy at udel.edu Sun Jul 19 04:26:27 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 04:26:27 -0400 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 7/19/2015 12:45 AM, Steven D'Aprano wrote: > On Sun, 19 Jul 2015 01:52 pm, Rustom Mody wrote: >> JFTR: My kids (um... students) have just managed to add devanagari >> numerals to python. >> ie we can now do >> >>>>> ? + ? >> 3 > > That is actually quite awesome, and I would support a new feature that set > the numeric characters to a particular script, e.g. Latin, Arabic, > Devanagari, whatever, and printed them in that same script. It seems > unfortunate that ? + ? prints as 3 rather than ?. > > Python already, and has for many years, supported non-ASCII digits in string > conversions. This is in Python 2.4: > > py> int(u'??') > 12 > py> float(u'.??') > 0.12 > > > so the feature goes back a long time. > > I think that Python should allow int and float literals using any sequences > of digits from the same language, e.g. 12 or ?? but not ?2. This could be done easily by adding 10 modified productions from https://docs.python.org/3/reference/lexical_analysis.html#integer-literals for each language. The problem of doing the above in the grammar, including the no mixing rule, is that is *would* take a separate set of productions for each language supported. > One might have > an interpreter hook which displayed ints and floats using non-ASCII digits, > or one might even build that function into the intepreter, e.g. have a > global setting which tells ints and floats what digits to use, e.g.: > > sys.setdigits('Devanagari') > > I would support this, or something like this, as a language feature. If we > can write Python using Hindi identifiers, why not Hindi numerals? As I remember, when non-ascii-digit inputs to int were last discussed (python-ideas?, pydev?), the possibility of expanding literals was mentioned. As I remember, to idea was rejected or deferred on the basis that nearly all numbers used in production programs are read from files as numbers or converted by int or float. The few numeric literals in programs could just as well be converted first, or the int expression could be used. These true observations do not cover the shell, as in the examples above. At some time, Guido has expresses the opinion that interactive console python should remain plain and basic and the fancier interaction features are the domain of replacement shells. That brings me, anyway, to Idle. It currently imitates console python in sending keystrokes as is to compile() and output streams as are to the tk display. There are a couple of tracker issues claiming that this means that Idle does not imitate console python because a tk display does not treat backspace and return the same way simulated terminal consoles usually do. While the bug claims have been rejected, I have been thinking that the Idle extension interface could and maybe should be extended so that extensions could filter and either transform or act on the input/output streams. With a general mechanism in place, it would be trivial to use str.maketrans and str.translate in the input/output streams. This would not disable ascii digit input, including mixtures in a single literal, but output has to all be in one digit set. Selecting a language is a somewhat solved problem because last summer we added a extension configuration dialog that dynamically generates a dialog tab for each extension present. -- Terry Jan Reedy From tjreedy at udel.edu Sun Jul 19 04:29:28 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 04:29:28 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <55AAE936.4010306@digipen.edu> References: <55AAE936.4010306@digipen.edu> Message-ID: On 7/18/2015 8:03 PM, Gary Herron wrote: > On 07/18/2015 04:36 PM, Terry Reedy wrote: >> I would like more viewpoints from 2.7 users. > > I read that (incorrectly of course) and just had to ask: > How do you intend to extract a viewpoint from that last 7/10 of a user? > > With apologies, Some humor is definitely welcome. -- Terry Jan Reedy From lac at openend.se Sun Jul 19 05:09:30 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 19 Jul 2015 11:09:30 +0200 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: Message from Rick Johnson of "Sat, 18 Jul 2015 16:18:57 -0700." <4760b41d-54c8-436f-a40b-40ecd9622c5b@googlegroups.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <4760b41d-54c8-436f-a40b-40ecd9622c5b@googlegroups.com> Message-ID: <201507190909.t6J99UU6017190@fido.openend.se> In a message of Sat, 18 Jul 2015 16:18:57 -0700, Rick Johnson writes: >I'll have to admit you make a good point here. Although the >argument is diminished by observing that Ruby is far more >popular in Asia than Python. Python seems to be mainly a >Scandinavian, European, and American toy. For the most part >anyway. There are always exceptions to any rule. I mean, >think about it: who besides Xah Lee has an Asian name here? >And it's been years since we've heard from him! O:-D This is because this is an english-speaking mailing list, not because people who don't speak English aren't using Python. Being here isn't much of an indicator. And, despite Norway not being part of the EU, Scandinavia is still in Europe. Laura From tjreedy at udel.edu Sun Jul 19 05:11:25 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 05:11:25 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> Message-ID: On 7/18/2015 11:52 PM, Rustom Mody wrote: among other things, a complaint about rejection of his desire for a mechanism for subsetting Python for teaching purposes. Response 2: Core python is the most conservatively maintained part of Python. Trying to change it radically, as distributed by PSF, is practically asking for rejection. For subsetting, I suggest a different tack: filtering input before sending it to python and raise if it contains forbidden code. After Response 1, I posted on the Devanagari thread a similar suggestion. I also posted an idea for implementing the idea by extending the internal reach of Idle extensions. I limited the idea to the interactive shell because I could not immediately think of a use for filtering code before compiling. Then I thought of this issue. Among other things, code could be tokenized or parsed to an ast for filtering. -- Terry Jan Reedy From lac at openend.se Sun Jul 19 05:27:31 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 19 Jul 2015 11:27:31 +0200 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: Message from Terry Reedy of "Sat, 18 Jul 2015 19:36:33 -0400." References: Message-ID: <201507190927.t6J9RVqM017606@fido.openend.se> In a message of Sat, 18 Jul 2015 19:36:33 -0400, Terry Reedy writes: >If the vast majority of Python programmers are focused on 2.7, why are >volunteers to help fix 2.7 bugs so scarce? Because volunteers to fix any bugs are scarce? Because most people really only think of bug fixing when they have one, and when they get that one fixed they drop back into thinking that everything is perfect? >Does they all consider it perfect (or sufficient) as is? > >Should the core developers who do not personally use 2.7 stop >backporting, because no one cares if they do? > >-- >Terry Jan Reedy In the tiny corner of industrial automation where I do a lot of work, nobody is using 3.0. It is not clear that this is ever going to change. It would have to be driven by 'lack of people who know 2.x syntax' or something like that. Not 'third party library compatibility' because we really don't use them all that much. In this corner of the world, the favourite language for developing in is C (because we work close to hardware) and one of the things we like about it, a whole lot, is that the language never changes out from under you. So there is great hope among industrial users of Python that we can get a hold of a 'never going to change any more' version of Python, and then code in that 'forever' knowing that a code change isn't going to come along and break all our stuff. Bug fixes aren't supposed to do this, of course, in the same way that backporting of features do, but every so often something that was introduced to fix bug X ends up breaking something else Y. If the consequences of a bug can be 10s of thousands of Euros lost, you can see the appeal of 'this isn't going to happen any more'. While nobody likes to get bit by bugs, there is some sort of fuzzy belief out there that the bugs fixes that have gone into 2.7 are more about things that we would never run into, and thus we get the risk of change without the benefit of the bugfix. This belief isn't one that people substantiate -- it is 'just a feeling'. So from this corner of the world, which admittedly is a very small corner, yes, the news is 'Life is good. Please leave us alone.' This is in large part, I think, due to the belief that 'if things aren't breaking, things are perfect' which is completely untrue, but that's the way people are thinking. Laura From Cecil at decebal.nl Sun Jul 19 06:35:16 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sun, 19 Jul 2015 12:35:16 +0200 Subject: Is this a good way to work with init and exception Message-ID: <87380kzb8b.fsf@Equus.decebal.nl> I am using libturpial to post things on Twitter. But sometimes I get a ServiceOverCapacity exception. So I wrote the following code. ====================================================================== class InitAlreadyDoneError(Exception): pass ##### Functions def init(max_tries = 5, wait_time = 60): global _core if _core != None: raise InitAlreadyDoneError tries = 0 while True: try: _core = Core() break except ServiceOverCapacity: tries += 1 sys.stderr.write('Tried to init _core it {0} times\n'.format(tries)) sys.stderr.flush() if tries >= max_tries: raise time.sleep(wait_time) ====================================================================== Is this the correct way to work user defined exceptions, or should I also define a default message? I use this in the following way: import twitterDecebal twitterDecebal.init() Because you can not give parameters with an import as far as I can see. Is this a good way to do this, or is there a better way? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From laritaba at gmail.com Sun Jul 19 08:11:45 2015 From: laritaba at gmail.com (Lara BK) Date: Sun, 19 Jul 2015 05:11:45 -0700 (PDT) Subject: batch spatial join - python Message-ID: <044a0f78-91fe-4730-945a-8b6456e32d9d@googlegroups.com> Hello, I would like to do a spatial join in a batch process in python. # I have this layers: neighbourhood = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\neighbourhood.shp" buildings = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\buildings.shp" openspace = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\openspace.shp" buses = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\buses.shp" education = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\education.shp" health = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\health.shp" sport_point_shp = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\sport_point.shp" #I created this variables with the layers: input_features = [sport_point_shp, health, buses, education] #the layers that will be used to count the buildings inside the neighbourhood layer new_layers = ["join_sport", "join_health", "join_buses", "join_education"] # the layer that will be created after join arcpy.BatchSpatialJoin_analysis(neighbourhood, input_features, new_layers, "JOIN_ONE_TO_ONE", "KEEP_ALL", "", "INTERSECT") #### but when i run the script is says: Runtime error Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'BatchSpatialJoin_analysis' How can i solve this problem? Thank you! From phil at riverbankcomputing.com Sun Jul 19 08:18:30 2015 From: phil at riverbankcomputing.com (Phil Thompson) Date: Sun, 19 Jul 2015 13:18:30 +0100 Subject: PyQt v5.5 Released Message-ID: PyQt5 v5.5 has been released and is available from http://www.riverbankcomputing.com/software/pyqt/download5. PyQt5 is a comprehensive set of bindings for v5 of The Qt Company's Qt cross-platform application framework. It supports Python v3, v2.7 and v2.6. The highlights of this release include support for Qt v5.5.0 including the new QtLocation and QtNfc modules. PyQt5 supports cross-compiling to iOS and Android. Windows installers are provided which contain everything needed for PyQt5 development (including Qt, Qt Designer, QScintilla, and MySQL, PostgreSQL, SQLite and ODBC drivers) except Python itself. Installers are provided for the 32 and 64 bit versions of Python v3.4. PyQt5 is implemented as a set of 35 extension modules comprising more than a 1,000 classes including support for: - non-GUI infrastructure including event loops, threads, i18n, user and application settings, mapped files and shared memory - GUI infrastructure including window system integration, event handling, 2D graphics, basic imaging, fonts, OpenGL - a comprehensive set of desktop widgets - WebKit and Chromium based browsers - WebSockets - location and positioning services (including OpenStreetMap) using satellite, Wi-Fi or text file sources - a client-side library for accessing Qt Cloud Services - full integration with Quick2 and QML allowing new Quick items to be implemented in Python and created in QML - event driven network programming - multimedia including cameras, audio and radios - Bluetooth - NFC enabled devices - sensors including accelerometers, altimeters, compasses, gyroscopes, magnetometers, and light, pressure, proximity, rotation and temperature sensors - serial ports - SQL - printing - DBus - XPath, XQuery, XSLT and XML Schema validation - a help system for creating and viewing searchable documentation - unit testing of GUI applications. From python.list at tim.thechases.com Sun Jul 19 08:56:01 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 19 Jul 2015 07:56:01 -0500 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20150719075601.779a4edb@bigbox.christie.dr> On 2015-07-19 14:45, Steven D'Aprano wrote: >> ie we can now do >>>>> ? + ? >> 3 > > That is actually quite awesome, and I would support a new feature > that set the numeric characters to a particular script, e.g. Latin, > Arabic, Devanagari, whatever, and printed them in that same script. > It seems unfortunate that ? + ? prints as 3 rather than ?. > > Python already, and has for many years, supported non-ASCII digits > in string conversions. This is in Python 2.4: > > py> int(u'??') > 12 > py> float(u'.??') > 0.12 > > so the feature goes back a long time. Agreed that it's pretty awesome. It seems to have some holes though: Python 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> print('\N{VULGAR FRACTION ONE EIGHTH}') ? >>> print(float('\N{VULGAR FRACTION ONE EIGHTH}')) Traceback (most recent call last): File "", line 1, in ValueError: could not convert string to float: '?' >>> print('\N{ROMAN NUMERAL NINE}') ? >>> int('\N{ROMAN NUMERAL NINE}') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '?' >>> print('\N{ROMAN NUMERAL TEN THOUSAND}') ? >>> int('\N{ROMAN NUMERAL TEN THOUSAND}') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '?' -tkc From rosuav at gmail.com Sun Jul 19 08:59:26 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 19 Jul 2015 22:59:26 +1000 Subject: Is this a good way to work with init and exception In-Reply-To: <87380kzb8b.fsf@Equus.decebal.nl> References: <87380kzb8b.fsf@Equus.decebal.nl> Message-ID: Reordering/interleaving your post to respond to different parts together. On Sun, Jul 19, 2015 at 8:35 PM, Cecil Westerhof wrote: > I am using libturpial to post things on Twitter. But sometimes I get a > ServiceOverCapacity exception. So I wrote the following code. > > ====================================================================== > class InitAlreadyDoneError(Exception): > pass > Is this the correct way to work user defined exceptions, or should I > also define a default message? I'd start by looking through the exception hierarchy for something appropriate to subclass. In this case, you're basically saying "run init() exactly once, and if you run it a second time, I'll throw back an error", which probably doesn't have any logical match, so directly subclassing Exception would be correct. But you might decide that subclassing ValueError or RuntimeError is more appropriate. > ##### Functions > def init(max_tries = 5, wait_time = 60): > global _core > > if _core != None: > raise InitAlreadyDoneError This is where I'd add a message, if you want one. But it looks to me as if there's never going to be any other place that raises this, so the message would be redundant. InitAlreadyDoneError implies "you called init() after someone else called init()". (Side point: It might be a neat courtesy to let people call init again, or maybe a try_init() that won't error out if already initialized.) > tries = 0 > while True: > try: > _core = Core() > break > except ServiceOverCapacity: > tries += 1 > sys.stderr.write('Tried to init _core it {0} times\n'.format(tries)) > sys.stderr.flush() > if tries >= max_tries: > raise > time.sleep(wait_time) > ====================================================================== > > > I use this in the following way: > import twitterDecebal > twitterDecebal.init() > > Because you can not give parameters with an import as far as I can > see. Is this a good way to do this, or is there a better way? Parameterized imports aren't possible, correct. What I'd look at here is a more explicit instantiation. Something like: import twitterDecebal twitter = twitterDecebal.twitterDecebal(5, 60) Especially since it's something that does a ton of network operations and all sorts of sleeps and timeouts, I would strongly recommend NOT doing this on import, even if you could. If you don't absolutely _need_ it to be global, it'd be cleanest to make it a class that you construct. ChrisA From breamoreboy at yahoo.co.uk Sun Jul 19 09:42:32 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 14:42:32 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On 19/07/2015 03:13, Terry Reedy wrote: > On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >> to 2.7, surely bug fixes are also allowed? > > Of course, allowed. But should they be made, and if so, by who? The people who want the fixes. > >> I have contributed both performance improvements and bug fixes to 2.7. >> In my experience, the problem is not the lack of contributors, it's >> the lack of code reviewers. > > I understand the general problem quite well. But feeling that one would > have to do a 2.7 backport after writing, editing, or reviewing a 3.x > patch can discourage doing a review in the first place. I am at that > point now with respect to Idle patches. Do the work with the 3.x patch and finish. Let somebody who needs the patch for 2.7 do the work. If nobody steps up to the mark that's not Terry Reedy's problem, you've done way more than your fair share over the years. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Sun Jul 19 09:52:06 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 14:52:06 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87egk4zu6m.fsf@jester.gateway.sonic.net> References: <87egk4zu6m.fsf@jester.gateway.sonic.net> Message-ID: On 19/07/2015 04:45, Paul Rubin wrote: > Terry Reedy writes: >> I am suggesting that if there are 10x as many 2.7only programmers as >> 3.xonly programmers, and none of the 2.7 programmers is willing to do >> the backport *of an already accepted patch*, then maybe it should not >> be done at all. > > The patch acceptance/approval process is frankly daunting. > Correct, which is why "PEP 0462 -- Core development workflow automation for CPython" https://www.python.org/dev/peps/pep-0462/, "PEP 0474 -- Creating forge.python.org" https://www.python.org/dev/peps/pep-0474/ and a separate core-workflow mailing list exist. Admittedly things had stalled but I understand that they're being picked up again. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From steve at pearwood.info Sun Jul 19 09:55:27 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 19 Jul 2015 23:55:27 +1000 Subject: batch spatial join - python References: <044a0f78-91fe-4730-945a-8b6456e32d9d@googlegroups.com> Message-ID: <55abac4f$0$1642$c3e8da3$5496439d@news.astraweb.com> On Sun, 19 Jul 2015 10:11 pm, Lara BK wrote: > I would like to do a spatial join in a batch process in python. You seem to be using arcpy. Unfortunately, that's not a standard part of Python, so I don't know it very well. But looking at the error you get: > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'module' object has no attribute > 'BatchSpatialJoin_analysis' it looks like the line starting with this: arcpy.BatchSpatialJoin_analysis(neighbourhood, blah-blah-blah...) is misspelled. Are you sure that it's called *Batch* SpacialJoin_analysis? Looking at this page: http://help.arcgis.com/en/arcgisdesktop/10.0/help/0008/00080000000q000000.htm I think you might need to change it to: arcpy.SpatialJoin_analysis(neighbourhood, blah-blah-blah...) Does that help? -- Steven From steve at pearwood.info Sun Jul 19 09:59:29 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 19 Jul 2015 23:59:29 +1000 Subject: Should non-security 2.7 bugs be fixed? References: Message-ID: <55abad41$0$1642$c3e8da3$5496439d@news.astraweb.com> On Sun, 19 Jul 2015 07:27 pm, Laura Creighton wrote: > In the tiny corner of industrial automation where I do a lot of work, > nobody is using 3.0. I should hope not, because 3.0 was rubbish and is unsupported :-) I expect you mean 3.x in general. > It is not clear that this is ever going to change. > It would have to be driven by 'lack of people who know 2.x syntax' > or something like that. Not 'third party library compatibility' because > we really don't use them all that much. > > In this corner of the world, the favourite language for developing in > is C (because we work close to hardware) and one of the things we like > about it, a whole lot, is that the language never changes out from > under you. Bug for bug compatible back to the 1970s, right? :-) I sympathise, really I do. Particularly in the application space (Firefox, I'm looking at you) I'm really fed up with every security update breaking functionality, removing features, and adding anti-features. > So there is great hope among industrial users of Python > that we can get a hold of a 'never going to change any more' version > of Python, and then code in that 'forever' knowing that a code change > isn't going to come along and break all our stuff. Presumably they like the 2.7 features too much to go back to an even older version. Because 2.5 or even 1.5 are pretty stable now. I'm not kidding about 1.5, a year or two ago there was (so I'm told) a fellow at PyCon in the US who was still using 1.5. "If it ain't broke, don't fix it" -- he wasn't concerned about security updates, or new features, he just needed to keep his legacy applications running. I get it, I really do, and so do the core developers. (Well, most of them, and certainly Guido.) It cannot be said often enough and loudly enough that if you find yourself in the lucky position where you don't need to care about security updates, bug fixes or new functionality, there is absolutely nothing wrong with using an old, unmaintained, stable version forever. -- Steven From breamoreboy at yahoo.co.uk Sun Jul 19 10:00:52 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 15:00:52 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> Message-ID: On 19/07/2015 04:52, Rustom Mody wrote: > > Not to mention actively hostile attitude to discussions that could at the > moment be tangential to current CPython. See (and whole thread) > https://mail.python.org/pipermail/python-ideas/2015-May/033708.html > This https://mail.python.org/pipermail/python-ideas/2015-May/033686.html is "actively hostile"? Sour grapes springs to my mind. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Sun Jul 19 10:08:33 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 15:08:33 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87r3o4wv4h.fsf@handshake.de> References: <87r3o4wv4h.fsf@handshake.de> Message-ID: On 19/07/2015 06:53, dieter wrote: > Mark Lawrence writes: >> ... >>> If the vast majority of Python programmers are focused on 2.7, why are >>> volunteers to help fix 2.7 bugs so scarce? > > I have not done much work related to Python bug fixing. But, I had > bad experience with other open source projects: many of my patches > (and bug reports) have been ignored over decades. This caused me > to change my attitude: I now report bugs (sometimes with patches) > and publish a potential solution in a separate package > (--> "dm.zopepatches.*", "dm.zodbpatches.*"). This way, affected > people can use a solution even if the core developpers don't care. > > From my point of view: if you want help with fixing bugs, > you must ensure that there is a high probability that those contributions > really find their way into the main development lines. > As I understand from other messages in this thread, this is also > a problem with Python bug fixing. > The entire workflow is the problem. This is now being addressed, see my earlier reply to Paul Rubin. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From lac at openend.se Sun Jul 19 10:15:12 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 19 Jul 2015 16:15:12 +0200 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: Message from "Steven D'Aprano" of "Sun, 19 Jul 2015 23:59:29 +1000." <55abad41$0$1642$c3e8da3$5496439d@news.astraweb.com> References: <55abad41$0$1642$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507191415.t6JEFCOj024848@fido.openend.se> In a message of Sun, 19 Jul 2015 23:59:29 +1000, "Steven D'Aprano" writes: >On Sun, 19 Jul 2015 07:27 pm, Laura Creighton wrote: > >> In the tiny corner of industrial automation where I do a lot of work, >> nobody is using 3.0. > >I should hope not, because 3.0 was rubbish and is unsupported :-) > >I expect you mean 3.x in general. indeed. Or should I be saying Python 3000. >Bug for bug compatible back to the 1970s, right? :-) Exactly. >> So there is great hope among industrial users of Python >> that we can get a hold of a 'never going to change any more' version >> of Python, and then code in that 'forever' knowing that a code change >> isn't going to come along and break all our stuff. > >Presumably they like the 2.7 features too much to go back to an even older >version. Because 2.5 or even 1.5 are pretty stable now. > >I'm not kidding about 1.5, a year or two ago there was (so I'm told) a >fellow at PyCon in the US who was still using 1.5. "If it ain't broke, >don't fix it" -- he wasn't concerned about security updates, or new >features, he just needed to keep his legacy applications running. I have 1.5 code out there. Unless something breaks there is no way that I will get permission to ever change it. >I get it, I really do, and so do the core developers. (Well, most of them, >and certainly Guido.) It cannot be said often enough and loudly enough that >if you find yourself in the lucky position where you don't need to care >about security updates, bug fixes or new functionality, there is absolutely >nothing wrong with using an old, unmaintained, stable version forever. Well, Terry asked. In my corner of the world -- well, iterators are cool. Though a ton of my code broke when we got a 'yield' keyword, as I had used that as a function name all over the place ... But aside from that, pretty much nothing post 1.5.2 really made a difference for us. Some bugs in struct got fixed, and that was nice, but, well on the whole we'd like stone cold dead. >-- >Steven Laura From lac at openend.se Sun Jul 19 10:18:09 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 19 Jul 2015 16:18:09 +0200 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: Message from "Steven D'Aprano" of "Sun, 19 Jul 2015 23:59:29 +1000." <55abad41$0$1642$c3e8da3$5496439d@news.astraweb.com> References: <55abad41$0$1642$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507191418.t6JEI93B024929@fido.openend.se> In a message of Sun, 19 Jul 2015 23:59:29 +1000, "Steven D'Aprano" writes: >Bug for bug compatible back to the 1970s, right? :-) No, till the last posix in 1989 or so. Definitely not to the 1970s as we want v7 c structs and x++ not the v6 ++x version. :) Laura From rustompmody at gmail.com Sun Jul 19 10:30:43 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 19 Jul 2015 07:30:43 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> Message-ID: On Sunday, July 19, 2015 at 2:42:41 PM UTC+5:30, Terry Reedy wrote: > On 7/18/2015 11:52 PM, Rustom Mody wrote: > among other things, a complaint about rejection of his desire for a > mechanism for subsetting Python for teaching purposes. Sorry Terry if the compliant sounded louder than the answer. You asked: > If the vast majority of Python programmers are focused on 2.7, why are > volunteers to help fix 2.7 bugs so scarce? As someone who's been associated in one way or other with teaching for near 3 decades, I'd say that of the two factors which destroy an education institute -- bar to entry too high, bar to entry too low -- the second is by far the more dangerous. I believe open source is no different. If every patch is to be accepted (or even given a polite answer) there will be no remaining working code. And this will become more true the more the project is successful. Super successful projects like the linux kernel are that way because the top guys are ruthlessly meritocratic: If your submission is poor you are told "Your code is shit" If you persist, the "Your code" shortens to "You" As I said it to Paul: I am thankful that python is meritocratic As for that specific exchange I would rather not flog that horse further [in public at least -- we can continue off list] From ian.g.kelly at gmail.com Sun Jul 19 11:29:11 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 19 Jul 2015 09:29:11 -0600 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <201507190927.t6J9RVqM017606@fido.openend.se> References: <201507190927.t6J9RVqM017606@fido.openend.se> Message-ID: On Sun, Jul 19, 2015 at 3:27 AM, Laura Creighton wrote: > In this corner of the world, the favourite language for developing in > is C (because we work close to hardware) and one of the things we like > about it, a whole lot, is that the language never changes out from > under you. So there is great hope among industrial users of Python > that we can get a hold of a 'never going to change any more' version > of Python, and then code in that 'forever' knowing that a code change > isn't going to come along and break all our stuff. I think this is an unrealistic and unattainable goal. Even if you stop patching your Python 2.7 version altogether, what about the environment that it runs in? Are you going to stop patching the OS forever? Are you going to fix the current machine architecture exactly as it is, forever? I don't know if industrial code uses a network much or at all, but if it does, are you never going to upgrade your network infrastructure? At some point in the future, maybe far in the future, but eventually, assumptions made in the Python 2.7 code will no longer hold true, and at that point Python 2.7 will break. From Cecil at decebal.nl Sun Jul 19 12:10:44 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sun, 19 Jul 2015 18:10:44 +0200 Subject: Should non-security 2.7 bugs be fixed? References: Message-ID: <87y4icxh4r.fsf@Equus.decebal.nl> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: > On 19/07/2015 03:13, Terry Reedy wrote: >> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>> to 2.7, surely bug fixes are also allowed? >> >> Of course, allowed. But should they be made, and if so, by who? > > The people who want the fixes. Babies want clean diapers. So babies have to change diapers themselves? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From rosuav at gmail.com Sun Jul 19 12:13:58 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 02:13:58 +1000 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: On Mon, Jul 20, 2015 at 2:05 AM, Dennis Lee Bieber wrote: > I've only seen one other application using HHMLL -- and that was the > Amiga file system. Okay, I'll bite. What does HHMLL stand for? Google didn't answer my question instantly with the first result, like it usually does. I even got desperate [1] but no luck. ChrisA [1] https://xkcd.com/1334/ From python at mrabarnett.plus.com Sun Jul 19 12:24:47 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Jul 2015 17:24:47 +0100 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: <55ABCF4F.4090802@mrabarnett.plus.com> On 2015-07-19 17:13, Chris Angelico wrote: > On Mon, Jul 20, 2015 at 2:05 AM, Dennis Lee Bieber > wrote: >> I've only seen one other application using HHMLL -- and that was the >> Amiga file system. > > Okay, I'll bite. What does HHMLL stand for? Google didn't answer my > question instantly with the first result, like it usually does. I even > got desperate [1] but no luck. > HHMLL stands for "hashed-head multiple-linked list", a phrase from a little earlier in the post. From rosuav at gmail.com Sun Jul 19 12:32:14 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 02:32:14 +1000 Subject: Proposed keyword to transfer control to another function In-Reply-To: <55ABCF4F.4090802@mrabarnett.plus.com> References: <55ABCF4F.4090802@mrabarnett.plus.com> Message-ID: On Mon, Jul 20, 2015 at 2:24 AM, MRAB wrote: > On 2015-07-19 17:13, Chris Angelico wrote: >> >> On Mon, Jul 20, 2015 at 2:05 AM, Dennis Lee Bieber >> wrote: >>> >>> I've only seen one other application using HHMLL -- and that was >>> the >>> Amiga file system. >> >> >> Okay, I'll bite. What does HHMLL stand for? Google didn't answer my >> question instantly with the first result, like it usually does. I even >> got desperate [1] but no luck. >> > HHMLL stands for "hashed-head multiple-linked list", a phrase from a little > earlier in the post. D'oh. I skimmed the post, looking for expressions matching that, and somehow missed it. Of course, it's right there when I go back and check again. I'm pretty sure the universe is out to gaslight me some days, particularly the days when my proposals end up indecisive. Which one of them is, today. This does not bode well. ChrisA From python at mrabarnett.plus.com Sun Jul 19 12:35:03 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Jul 2015 17:35:03 +0100 Subject: Need assistance In-Reply-To: References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: <55ABD1B7.8010002@mrabarnett.plus.com> On 2015-07-19 01:59, Denis McMahon wrote: > On Sat, 18 Jul 2015 12:35:10 +0200, Sibylle Koczian wrote: > >> Am 18.07.2015 um 02:40 schrieb Denis McMahon: > >>> Having a list of words, get a copy of the list in reverse order. See >>> the reversed function (and maybe the list function). > >> That won't really help, because the desired order is, with the example >> the OP used: Sirna Daniel Craig. So here indexing is necessary, but >> indexing of the list elements, not of the characters in the string. > > Oh, then it's even easier, yes, it's mainly a case of list indexing. > > 1) Split the original string into a list of words (string.split() method) > 2) create a sublist (s1) of the last element > 3) create another sublist (s2) of the first to penultimate elements > 4) combine the two sublists > 5) use the string.join() method to combine the sublist elements into a > single string > > I think most pythonistas would probably combine steps 2 through 4 in a > single line of code, possibly even steps 2 through 5. > If you use rsplit, you can do it in one line. From breamoreboy at yahoo.co.uk Sun Jul 19 12:38:37 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 17:38:37 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87y4icxh4r.fsf@Equus.decebal.nl> References: <87y4icxh4r.fsf@Equus.decebal.nl> Message-ID: On 19/07/2015 17:10, Cecil Westerhof wrote: > On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: > >> On 19/07/2015 03:13, Terry Reedy wrote: >>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>> to 2.7, surely bug fixes are also allowed? >>> >>> Of course, allowed. But should they be made, and if so, by who? >> >> The people who want the fixes. > > Babies want clean diapers. So babies have to change diapers > themselves? > That has to be the worst analogy I've ever read. We are discussing backporting working patches, *NOT* having to go through the whole shooting match from scratch. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Sun Jul 19 12:41:55 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 17:41:55 +0100 Subject: Proposed keyword to transfer control to another function In-Reply-To: <55ABCF4F.4090802@mrabarnett.plus.com> References: <55ABCF4F.4090802@mrabarnett.plus.com> Message-ID: On 19/07/2015 17:24, MRAB wrote: > On 2015-07-19 17:13, Chris Angelico wrote: >> On Mon, Jul 20, 2015 at 2:05 AM, Dennis Lee Bieber >> wrote: >>> I've only seen one other application using HHMLL -- and that >>> was the >>> Amiga file system. >> >> Okay, I'll bite. What does HHMLL stand for? Google didn't answer my >> question instantly with the first result, like it usually does. I even >> got desperate [1] but no luck. >> > HHMLL stands for "hashed-head multiple-linked list", a phrase from a little > earlier in the post. > I want one in the stdlib on the grounds that I like the name :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From Cecil at decebal.nl Sun Jul 19 12:46:02 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sun, 19 Jul 2015 18:46:02 +0200 Subject: Is this a good way to work with init and exception References: <87380kzb8b.fsf@Equus.decebal.nl> Message-ID: <87r3o4xfhx.fsf@Equus.decebal.nl> On Sunday 19 Jul 2015 14:59 CEST, Chris Angelico wrote: > Reordering/interleaving your post to respond to different parts > together. > > On Sun, Jul 19, 2015 at 8:35 PM, Cecil Westerhof wrote: >> I am using libturpial to post things on Twitter. But sometimes I >> get a ServiceOverCapacity exception. So I wrote the following code. >> >> ====================================================================== >> class InitAlreadyDoneError(Exception): pass > >> Is this the correct way to work user defined exceptions, or should >> I also define a default message? > > I'd start by looking through the exception hierarchy for something > appropriate to subclass. In this case, you're basically saying "run > init() exactly once, and if you run it a second time, I'll throw > back an error", which probably doesn't have any logical match, so > directly subclassing Exception would be correct. But you might > decide that subclassing ValueError or RuntimeError is more > appropriate. Subclassing ValueError or RuntimeError looks wrong to me. >> ##### Functions >> def init(max_tries = 5, wait_time = 60): >> global _core >> >> if _core != None: >> raise InitAlreadyDoneError > > This is where I'd add a message, if you want one. But it looks to me > as if there's never going to be any other place that raises this, so > the message would be redundant. InitAlreadyDoneError implies "you > called init() after someone else called init()". I thought so, but just wanted to be sure. ;-) > (Side point: It might be a neat courtesy to let people call init > again, or maybe a try_init() that won't error out if already > initialized.) I changed it to: ======================================================================== def init(max_tries = 5, wait_time = 60, reinit_allowed = False): global _core if (_core != None) and not reinit_allowed: raise InitAlreadyDoneError ======================================================================== >> I use this in the following way: >> import twitterDecebal >> twitterDecebal.init() >> >> Because you can not give parameters with an import as far as I can >> see. Is this a good way to do this, or is there a better way? > > Parameterized imports aren't possible, correct. What I'd look at > here is a more explicit instantiation. Something like: > > import twitterDecebal > twitter = twitterDecebal.twitterDecebal(5, 60) I worked with default values, because I thought that would be a good idea. I should remove the default values? > Especially since it's something that does a ton of network > operations and all sorts of sleeps and timeouts, I would strongly > recommend NOT doing this on import, even if you could. If you don't > absolutely _need_ it to be global, it'd be cleanest to make it a > class that you construct. In principal I only mend that before you use the twitter functions you need to do the init. (And because of the ton of functions I wanted a reinit to be an error.) In my case it is exactly below the import. Because I use it in a script and except one situation _core is always used. So I thought it to be more clear. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From rosuav at gmail.com Sun Jul 19 12:50:21 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 02:50:21 +1000 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: <55ABCF4F.4090802@mrabarnett.plus.com> Message-ID: On Mon, Jul 20, 2015 at 2:41 AM, Mark Lawrence wrote: > On 19/07/2015 17:24, MRAB wrote: >> >> On 2015-07-19 17:13, Chris Angelico wrote: >>> >>> On Mon, Jul 20, 2015 at 2:05 AM, Dennis Lee Bieber >>> wrote: >>>> >>>> I've only seen one other application using HHMLL -- and that >>>> was the >>>> Amiga file system. >>> >>> >>> Okay, I'll bite. What does HHMLL stand for? Google didn't answer my >>> question instantly with the first result, like it usually does. I even >>> got desperate [1] but no luck. >>> >> HHMLL stands for "hashed-head multiple-linked list", a phrase from a >> little >> earlier in the post. >> > > I want one in the stdlib on the grounds that I like the name :) I like the name Rachel, too, but I don't want her in the stdlib :) ChrisA From rantingrickjohnson at gmail.com Sun Jul 19 12:56:50 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 09:56:50 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On Sunday, July 19, 2015 at 12:54:34 AM UTC-5, dieter wrote: > From my point of view: if you want help with fixing bugs, > you must ensure that there is a high probability that > those contributions really find their way into the main > development lines. As I understand from other messages in > this thread, this is also a problem with Python bug > fixing. (Not sure who said this, so my apologies if the attribution is incorrect) Bug fixing is not something most programmers find enjoyable, at least not for long durations. I prefer to spend my time solving real world problems, and designing intuitive APIs, this is what brings me joy. Heck, there have been many times that i purposefully re- invented the wheel simply because solving the problem is much easier (and more enjoyable) than trying to understand another programmer's atrocious spaghetti code. Therefor, we should not be surprised that the bug list is so understaffed and lacks vigor. What is becoming apparent to me though, is that most of the complaints i had voiced (years ago) about the exclusive attitudes, horrible interface, and the burdensome workflow of submitting patches is contributing to the lack of interest in this process -> and it seems i am not alone! I can remember twice getting excited about helping out, to only quickly become frustrated with the politics and interface. Why should i have to fight just to volunteer? What's the point? The whole system is self defeating. Time for some introspection folks. From Cecil at decebal.nl Sun Jul 19 13:14:13 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sun, 19 Jul 2015 19:14:13 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> Message-ID: <87mvysxe6y.fsf@Equus.decebal.nl> On Sunday 19 Jul 2015 18:38 CEST, Mark Lawrence wrote: > On 19/07/2015 17:10, Cecil Westerhof wrote: >> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >> >>> On 19/07/2015 03:13, Terry Reedy wrote: >>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>> to 2.7, surely bug fixes are also allowed? >>>> >>>> Of course, allowed. But should they be made, and if so, by who? >>> >>> The people who want the fixes. >> >> Babies want clean diapers. So babies have to change diapers >> themselves? >> > > That has to be the worst analogy I've ever read. We are discussing > backporting working patches, *NOT* having to go through the whole > shooting match from scratch. You think so? I think that a lot of people who are using 2.7 would like to have the fixes. They know how to use Python, but they would not now how to implement a patch. That is why I made this comment. Comments are (almost) always an exaggeration. When someone tells me: ?I have been 1.000 times to the store to get my money back?, most of the time I would not take this literally, but understand it means very often. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From rantingrickjohnson at gmail.com Sun Jul 19 13:25:35 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 10:25:35 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <4760b41d-54c8-436f-a40b-40ecd9622c5b@googlegroups.com> Message-ID: On Sunday, July 19, 2015 at 4:18:31 AM UTC-5, Laura Creighton wrote: > And, despite Norway not being part of the EU, Scandinavia > is still in Europe. This is a bit off topic: But i don't consider Scandinavia to be a part of the EU. Not anymore than i would consider America to be a part of the EU. Sure, we're all colloquially known as "the west", but large ideological and social design structures exist between the members. And besides, there is a great possibility that the EU could implode on itself. Take for instance the disaster of Greece, with many other large players teetering on the edge. The only ubiquitous binding agent between all the member countries is the existential need to conglomerate military power against foes in the east. Beyond that, the union is superficial at best. If the bailout fails, or another worldwide financial crisis hits, the outcome could be disastrous for the EU. When those pension checks stop coming in the mail, people get violent! From python at mrabarnett.plus.com Sun Jul 19 13:45:04 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Jul 2015 18:45:04 +0100 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <4760b41d-54c8-436f-a40b-40ecd9622c5b@googlegroups.com> Message-ID: <55ABE220.1000209@mrabarnett.plus.com> On 2015-07-19 18:25, Rick Johnson wrote: > On Sunday, July 19, 2015 at 4:18:31 AM UTC-5, Laura Creighton wrote: >> And, despite Norway not being part of the EU, Scandinavia >> is still in Europe. > > This is a bit off topic: But i don't consider Scandinavia to > be a part of the EU. Not anymore than i would consider > America to be a part of the EU. Sure, we're all colloquially > known as "the west", but large ideological and social design > structures exist between the members. And besides, there is > a great possibility that the EU could implode on itself. > [snip] Denmark and Sweden are _both_ members of the EU. From lac at openend.se Sun Jul 19 13:50:33 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 19 Jul 2015 19:50:33 +0200 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: Message from Rick Johnson of "Sun, 19 Jul 2015 10:25:35 -0700." References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <4760b41d-54c8-436f-a40b-40ecd9622c5b@googlegroups.com> Message-ID: <201507191750.t6JHoXvj029777@fido.openend.se> In a message of Sun, 19 Jul 2015 10:25:35 -0700, Rick Johnson writes: >On Sunday, July 19, 2015 at 4:18:31 AM UTC-5, Laura Creighton wrote: >> And, despite Norway not being part of the EU, Scandinavia >> is still in Europe. > >This is a bit off topic: But i don't consider Scandinavia to >be a part of the EU. Not anymore than i would consider >America to be a part of the EU. Well, that makes one of you. The significant number of people who want to pull Sweden out of the EU still have a lot of work ahead of them before ignoring laws that come from Brussels is in my future. But in or out of the EU, Sweden will still be in Europe. Laura From breamoreboy at yahoo.co.uk Sun Jul 19 13:54:28 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 18:54:28 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87mvysxe6y.fsf@Equus.decebal.nl> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> Message-ID: On 19/07/2015 18:14, Cecil Westerhof wrote: > On Sunday 19 Jul 2015 18:38 CEST, Mark Lawrence wrote: > >> On 19/07/2015 17:10, Cecil Westerhof wrote: >>> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >>> >>>> On 19/07/2015 03:13, Terry Reedy wrote: >>>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>>> to 2.7, surely bug fixes are also allowed? >>>>> >>>>> Of course, allowed. But should they be made, and if so, by who? >>>> >>>> The people who want the fixes. >>> >>> Babies want clean diapers. So babies have to change diapers >>> themselves? >>> >> >> That has to be the worst analogy I've ever read. We are discussing >> backporting working patches, *NOT* having to go through the whole >> shooting match from scratch. > > You think so? I think that a lot of people who are using 2.7 would > like to have the fixes. They know how to use Python, but they would > not now how to implement a patch. That is why I made this comment. > I don't think so, I know. If they want the patches that badly and can't do it themselves they'll have to grin and bear it, or do a bit of begging, or pay somebody to do it for them. Unless the PSF or another body does the paying, something which I vaguely recall hearing about. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From denismfmcmahon at gmail.com Sun Jul 19 14:06:25 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Sun, 19 Jul 2015 18:06:25 +0000 (UTC) Subject: flipping string order References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: On Sun, 19 Jul 2015 17:35:03 +0100, MRAB wrote: > rsplit -> one line. def lastWordFirst(s): return " ".join(reversed(s.rsplit(" ", 1))) -- Denis McMahon, denismfmcmahon at gmail.com From rosuav at gmail.com Sun Jul 19 14:07:58 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 04:07:58 +1000 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <20150719075601.779a4edb@bigbox.christie.dr> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <20150719075601.779a4edb@bigbox.christie.dr> Message-ID: On Sun, Jul 19, 2015 at 10:56 PM, Tim Chase wrote: > Agreed that it's pretty awesome. It seems to have some holes though: > > Python 3.4.2 (default, Oct 8 2014, 10:45:20) > [GCC 4.9.1] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> print('\N{VULGAR FRACTION ONE EIGHTH}') > ? >>>> print(float('\N{VULGAR FRACTION ONE EIGHTH}')) > Traceback (most recent call last): > File "", line 1, in > ValueError: could not convert string to float: '?' >>>> print('\N{ROMAN NUMERAL NINE}') > ? >>>> int('\N{ROMAN NUMERAL NINE}') > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '?' >>>> print('\N{ROMAN NUMERAL TEN THOUSAND}') > ? >>>> int('\N{ROMAN NUMERAL TEN THOUSAND}') > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '?' The int() and float() functions accept, if I'm not mistaken, anything with Unicode category "Nd" (Number, decimal digit). In your examples, the fraction (U+215B) is No, and the Roman numerals (U+2168, U+2182) are Nl, so they're not supported. Adding support for these forms might be accepted as a feature request, but it's not a bug. (I may be wrong about the definition being based on category. It may be based on the "Numeric type" of each character. But again, the characters that are accepted would be those which have a Digit type, not merely Numeric, and again, it'd be a feature request to expand that.) ChrisA From rosuav at gmail.com Sun Jul 19 14:11:51 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 04:11:51 +1000 Subject: Is this a good way to work with init and exception In-Reply-To: <87r3o4xfhx.fsf@Equus.decebal.nl> References: <87380kzb8b.fsf@Equus.decebal.nl> <87r3o4xfhx.fsf@Equus.decebal.nl> Message-ID: On Mon, Jul 20, 2015 at 2:46 AM, Cecil Westerhof wrote: > On Sunday 19 Jul 2015 14:59 CEST, Chris Angelico wrote: > >> Reordering/interleaving your post to respond to different parts >> together. >> >> On Sun, Jul 19, 2015 at 8:35 PM, Cecil Westerhof wrote: >>> I am using libturpial to post things on Twitter. But sometimes I >>> get a ServiceOverCapacity exception. So I wrote the following code. >>> >>> ====================================================================== >>> class InitAlreadyDoneError(Exception): pass >> >>> Is this the correct way to work user defined exceptions, or should >>> I also define a default message? >> >> I'd start by looking through the exception hierarchy for something >> appropriate to subclass. In this case, you're basically saying "run >> init() exactly once, and if you run it a second time, I'll throw >> back an error", which probably doesn't have any logical match, so >> directly subclassing Exception would be correct. But you might >> decide that subclassing ValueError or RuntimeError is more >> appropriate. > > Subclassing ValueError or RuntimeError looks wrong to me. Sure. Like I said, directly subclassing Exception seemed the most logical route. Just threw that out there as a possibility. >> (Side point: It might be a neat courtesy to let people call init >> again, or maybe a try_init() that won't error out if already >> initialized.) > > I changed it to: > ======================================================================== > def init(max_tries = 5, wait_time = 60, reinit_allowed = False): > global _core > > if (_core != None) and not reinit_allowed: > raise InitAlreadyDoneError > ======================================================================== That works, too! >>> I use this in the following way: >>> import twitterDecebal >>> twitterDecebal.init() >>> >>> Because you can not give parameters with an import as far as I can >>> see. Is this a good way to do this, or is there a better way? >> >> Parameterized imports aren't possible, correct. What I'd look at >> here is a more explicit instantiation. Something like: >> >> import twitterDecebal >> twitter = twitterDecebal.twitterDecebal(5, 60) > > I worked with default values, because I thought that would be a good > idea. I should remove the default values? No no, the default values are good. I just gave an example that didn't use them, as that's where you actually need the call. If you're always going to use the defaults, well, there's not a lot of point having the function. But if you often use the defaults (or one of them), and occasionally override it, then what you have is good design. >> Especially since it's something that does a ton of network >> operations and all sorts of sleeps and timeouts, I would strongly >> recommend NOT doing this on import, even if you could. If you don't >> absolutely _need_ it to be global, it'd be cleanest to make it a >> class that you construct. > > In principal I only mend that before you use the twitter functions you > need to do the init. (And because of the ton of functions I wanted a > reinit to be an error.) In my case it is exactly below the import. > Because I use it in a script and except one situation _core is always > used. So I thought it to be more clear. I think it's fine, then. As long as it makes absolutely no sense to have two separately-initialized twitter connections, and as long as it's okay for two separate modules to both import this and to then share state, then what you have is fine. ChrisA From lac at openend.se Sun Jul 19 14:14:30 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 19 Jul 2015 20:14:30 +0200 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: Message from Ian Kelly of "Sun, 19 Jul 2015 09:29:11 -0600." References: <201507190927.t6J9RVqM017606@fido.openend.se> Message-ID: <201507191814.t6JIEUwu030318@fido.openend.se> In a message of Sun, 19 Jul 2015 09:29:11 -0600, Ian Kelly writes: >I think this is an unrealistic and unattainable goal. Even if you stop >patching your Python 2.7 version altogether, what about the >environment that it runs in? Are you going to stop patching the OS >forever? Are you going to fix the current machine architecture exactly >as it is, forever? I don't know if industrial code uses a network much >or at all, but if it does, are you never going to upgrade your network >infrastructure? There is clearly some wishful thinking going around here, but in terms of having the same machine architecture forever ... well, my friend the hardware guy can make you a board that you can plug your old perfectly working, reliable 1970s tech machines into -- because they really want to be plugged into a pdp-11 running RSX-11. Then we fake things using Python to simulate enough RSX-11 to keep on running. We figure the machines will still be running long after we are dead. Laura From rosuav at gmail.com Sun Jul 19 14:17:52 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 04:17:52 +1000 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <201507191814.t6JIEUwu030318@fido.openend.se> References: <201507190927.t6J9RVqM017606@fido.openend.se> <201507191814.t6JIEUwu030318@fido.openend.se> Message-ID: On Mon, Jul 20, 2015 at 4:14 AM, Laura Creighton wrote: > In a message of Sun, 19 Jul 2015 09:29:11 -0600, Ian Kelly writes: >>I think this is an unrealistic and unattainable goal. Even if you stop >>patching your Python 2.7 version altogether, what about the >>environment that it runs in? Are you going to stop patching the OS >>forever? Are you going to fix the current machine architecture exactly >>as it is, forever? I don't know if industrial code uses a network much >>or at all, but if it does, are you never going to upgrade your network >>infrastructure? > > There is clearly some wishful thinking going around here, but > in terms of having the same machine architecture forever ... well, my > friend the hardware guy can make you a board that you can plug your > old perfectly working, reliable 1970s tech machines into -- because they > really want to be plugged into a pdp-11 running RSX-11. Then we fake > things using Python to simulate enough RSX-11 to keep on running. > > We figure the machines will still be running long after we are dead. And for software, you can often run emulators. How many people have ancient Amiga games running on modern PCs via some sort of emulation layer? ChrisA From rantingrickjohnson at gmail.com Sun Jul 19 14:28:03 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 11:28:03 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> Message-ID: On Sunday, July 19, 2015 at 12:55:06 PM UTC-5, Mark Lawrence wrote: > I don't think so, I know. If they want the patches that > badly and can't do it themselves they'll have to grin and > bear it, or do a bit of begging, or pay somebody to do it > for them. It's all about the effing money then? So the barriers are not a bug, but a feature? Mr. Gates would be *SO* proud! From breamoreboy at gmail.com Sun Jul 19 14:44:10 2015 From: breamoreboy at gmail.com (breamoreboy at gmail.com) Date: Sun, 19 Jul 2015 11:44:10 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> Message-ID: <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> On Sunday, July 19, 2015 at 7:28:15 PM UTC+1, Rick Johnson wrote: > On Sunday, July 19, 2015 at 12:55:06 PM UTC-5, Mark Lawrence wrote: > > I don't think so, I know. If they want the patches that > > badly and can't do it themselves they'll have to grin and > > bear it, or do a bit of begging, or pay somebody to do it > > for them. > > It's all about the effing money then? So the barriers are not a > bug, but a feature? Mr. Gates would be *SO* proud! No, it's simply that nobody can force volunteers to back port something when they're just not interested in doing the work, for whatever reason. Hence my statement above, of which you have focussed on the last eight words. From ian.g.kelly at gmail.com Sun Jul 19 15:01:11 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 19 Jul 2015 13:01:11 -0600 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87y4icxh4r.fsf@Equus.decebal.nl> References: <87y4icxh4r.fsf@Equus.decebal.nl> Message-ID: On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof wrote: > On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: > >> On 19/07/2015 03:13, Terry Reedy wrote: >>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>> to 2.7, surely bug fixes are also allowed? >>> >>> Of course, allowed. But should they be made, and if so, by who? >> >> The people who want the fixes. > > Babies want clean diapers. So babies have to change diapers > themselves? Poor analogy. Babies need others to change their diapers for them because they're not capable of doing it for themselves. From aronbarsam at gmail.com Sun Jul 19 15:01:30 2015 From: aronbarsam at gmail.com (Aron Barsam) Date: Sun, 19 Jul 2015 20:01:30 +0100 Subject: how to play Message-ID: i have trouble trying to play python please can you respond soon -------------- next part -------------- An HTML attachment was scrubbed... URL: From Cecil at decebal.nl Sun Jul 19 15:10:24 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sun, 19 Jul 2015 21:10:24 +0200 Subject: Is this a good way to work with init and exception References: <87380kzb8b.fsf@Equus.decebal.nl> <87r3o4xfhx.fsf@Equus.decebal.nl> Message-ID: <87io9gx8tb.fsf@Equus.decebal.nl> On Sunday 19 Jul 2015 20:11 CEST, Chris Angelico wrote: >>> Parameterized imports aren't possible, correct. What I'd look at >>> here is a more explicit instantiation. Something like: >>> >>> import twitterDecebal >>> twitter = twitterDecebal.twitterDecebal(5, 60) >> >> I worked with default values, because I thought that would be a >> good idea. I should remove the default values? > > No no, the default values are good. I just gave an example that > didn't use them, as that's where you actually need the call. If > you're always going to use the defaults, well, there's not a lot of > point having the function. But if you often use the defaults (or one > of them), and occasionally override it, then what you have is good > design. In my case I think the defaults are good. (But I do not know how I will use the function in the future. ;-) ) But I want to share it on GitHub and it would be possible that for someone else my defaults are not correct and then it is nice when they can be overridden. > I think it's fine, then. As long as it makes absolutely no sense to > have two separately-initialized twitter connections, and as long as > it's okay for two separate modules to both import this and to then > share state, then what you have is fine. I do not see myself doing this, but I like to know ?everything?. When I have a program with two different modules that both import this, they would get in each-others way? How? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From ian.g.kelly at gmail.com Sun Jul 19 15:11:29 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 19 Jul 2015 13:11:29 -0600 Subject: how to play In-Reply-To: References: Message-ID: On Sun, Jul 19, 2015 at 1:01 PM, Aron Barsam wrote: > i have trouble trying to play python please can you respond soon "Play" is an odd choice of verb. Are you under the impression that Python is a game? Anyway, here's how to use Python: 1. Download Python from python.org. 2. Install Python on your local system. 3. Start Python from your OS command line. 4. ? 5. Profit! If you can tell us in more detail which step it is that you're stuck on and what problem you're running into, then maybe we can help. From rantingrickjohnson at gmail.com Sun Jul 19 15:13:32 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 12:13:32 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> Message-ID: <088e076d-90fc-46c4-a440-c1f04fdc747c@googlegroups.com> On Sunday, July 19, 2015 at 1:44:25 PM UTC-5, bream... at gmail.com wrote: > No, it's simply that nobody can force volunteers to back > port something when they're just not interested in doing > the work, for whatever reason. Hence my statement above, > of which you have focused on the last eight words. Well i argue that the free labor *WOULD* exists *IF* the patching mechanism were more inclusive and intuitive. PS: My apologies to Mark Lawrence for mis-attributing the quote to him. I seem to be having a bad quote day. From python at mrabarnett.plus.com Sun Jul 19 15:24:20 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Jul 2015 20:24:20 +0100 Subject: how to play In-Reply-To: References: Message-ID: <55ABF964.1070600@mrabarnett.plus.com> On 2015-07-19 20:01, Aron Barsam wrote: > i have trouble trying to play python please can you respond soon > You'll need to provide some details. Saying "i have trouble" isn't helpful. Help us to help you. Which operating system are you using? Windows, MacOS, Linux? Which version? Which version of Python? What are you doing? If there's an error message, what does it say? From rantingrickjohnson at gmail.com Sun Jul 19 15:28:55 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 12:28:55 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <87y4icxh4r.fsf@Equus.decebal.nl> Message-ID: <3aa144a1-79f9-4008-bb24-f10761562f4d@googlegroups.com> On Sunday, July 19, 2015 at 2:02:12 PM UTC-5, Ian wrote: > Poor analogy. Babies need others to change their diapers > for them because they're not capable of doing it for > themselves. Duh! That was the point of his analogy, Ian. *ALL* Python programmers need the patches. Whether or not they possess the skill to create them is irrelevant. But the baby is not the only victim if the diapers are not changed. Imagine the foul odors that "rumors of bugginess" will emit into the household, and if unchecked long enough, out into the neighborhood. A some point a social worker will be dispatched, and the baby will be taken away to a home that provides the necessary sanitary conditions. But not before the parents will be thrown in prison, ridiculed, and forgotten. The end result is a broken family Ian. Is any of this sinking in? From tjreedy at udel.edu Sun Jul 19 15:38:23 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 15:38:23 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On 7/18/2015 10:33 PM, Devin Jeanpierre wrote: > On Sat, Jul 18, 2015 at 6:34 PM, Terry Reedy wrote: >> On 7/18/2015 8:27 PM, Mark Lawrence wrote: >>> On 19/07/2015 00:36, Terry Reedy wrote: >>> Programmers don't much like doing maintainance work when they're paid to >>> do it, so why would they volunteer to do it? >> >> Right. So I am asking: if a 3.x user volunteers a 3.x patch and a 3.x core >> developer reviews and edits the patch until it is ready to commit, why >> should either of them volunteer to do a 2.7 backport that they will not use? > > Because it helps even more people. Writing another 3.x patch would also help other people and might be more 'fun'. That is the situation I am in with respect to Idle. > It gets really boring submitting 2.7-specific patches, though, when > they aren't accepted, and the committers have such a hostile attitude > towards it. I was told by core devs that, instead of fixing bugs in > Python 2, I should just rewrite my app in Python 3. It has even been > implied that bugs in Python 2 are *good*, because that might help with > Python 3 adoption. Like Steven, I would be interested in specifics, though I do not disbelieve you. I do not believe those two attitudes are exactly official policy, and I may request more discussion of them on pydev. >>> Then even if you do the >>> work to fix *ANY* bug there is no guarantee that it gets committed. >> >> I am discussing the situation where there *is* a near guarantee (if the >> backport works and does not break anything and has not been so heavily >> revised as to require a separate review). > > That is not how I have experienced contribution to CPython. I know. Some core developers are trying to revamp the issue-patch handling process to remove some of the busywork, use our time more efficiency, and make it work more smoothly for everyone. But let me try again. I am discussing a situation where a core developer has either requested or already agreed to apply a 2.7 backport. I have seen such in the past, but maybe this is now rare. I specifically would like to be able to request backports for Idle patches and get responses. When requested, I really would apply responses that worked. Really. But I now realized that most people would rather write a patch, on their own schedule, for an issue that bugs them, and perhaps use it locally, even if rejected for the repository, than write a guaranteed patch 'right now for a issue of no interest to them (and which might require python knowledge they do not have). > If the issue was closed as fixed before I contributed the backported > patch, does anyone even see it? Yes. All changes on as issue, including uploads, are emailed to all on the nosy list regardless of open/closed/... status. However, I would inquire first. "If I backport the committed bugfix to 2.7, would you apply it?" -- Terry Jan Reedy From python.list at tim.thechases.com Sun Jul 19 15:55:20 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 19 Jul 2015 14:55:20 -0500 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <20150719075601.779a4edb@bigbox.christie.dr> Message-ID: <20150719145520.5888c9e1@bigbox.christie.dr> On 2015-07-20 04:07, Chris Angelico wrote: > The int() and float() functions accept, if I'm not mistaken, > anything with Unicode category "Nd" (Number, decimal digit). In > your examples, the fraction (U+215B) is No, and the Roman numerals > (U+2168, U+2182) are Nl, so they're not supported. Adding support > for these forms might be accepted as a feature request, but it's > not a bug. Ah, that makes sense. Some simple testing (thanks, unicodedata module) supports your conjecture. It's not a particularly big deal so not really worth the brain-cycles to add support for them. Just upon hearing "Python's int() does smart things with Unicode characters", those were some of my first characters to try. The failure struck me as odd until you explained the simple difference. -tkc From rantingrickjohnson at gmail.com Sun Jul 19 15:58:27 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 12:58:27 -0700 (PDT) Subject: Integers with leading zeroes In-Reply-To: <17c85$55ab5d66$5419aafe$47498@news.ziggo.nl> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <17c85$55ab5d66$5419aafe$47498@news.ziggo.nl> Message-ID: <81809fc5-5db3-486c-8a8b-89afbe95c04e@googlegroups.com> On Sunday, July 19, 2015 at 3:19:01 AM UTC-5, Skybuck Flying wrote: > 14324 > 234545 > 345 > 534543 > > ^ Looks less good though in non-fixed-sized font. The obvious solution is to use a fixed width font. If you're inserting syntactical noise simply to maintain readability in variable width fonts, then you may want to reconsider the practicality of such a font. Readability counts. And errors (even mental errors) should never pass silently. From Cecil at decebal.nl Sun Jul 19 16:05:09 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sun, 19 Jul 2015 22:05:09 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> Message-ID: <87egk3ykui.fsf@Equus.decebal.nl> On Sunday 19 Jul 2015 21:01 CEST, Ian Kelly wrote: > On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof wrote: >> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >> >>> On 19/07/2015 03:13, Terry Reedy wrote: >>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>> to 2.7, surely bug fixes are also allowed? >>>> >>>> Of course, allowed. But should they be made, and if so, by who? >>> >>> The people who want the fixes. >> >> Babies want clean diapers. So babies have to change diapers >> themselves? > > Poor analogy. Babies need others to change their diapers for them > because they're not capable of doing it for themselves. That is why I think it is good analogy. I think that most of the users of 2.7 who would be delighted with fixes would have no idea how to get those fixes into 2.7. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From breamoreboy at gmail.com Sun Jul 19 16:21:44 2015 From: breamoreboy at gmail.com (breamoreboy at gmail.com) Date: Sun, 19 Jul 2015 13:21:44 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <088e076d-90fc-46c4-a440-c1f04fdc747c@googlegroups.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> <088e076d-90fc-46c4-a440-c1f04fdc747c@googlegroups.com> Message-ID: On Sunday, July 19, 2015 at 8:13:50 PM UTC+1, Rick Johnson wrote: > On Sunday, July 19, 2015 at 1:44:25 PM UTC-5, bream... at gmail.com wrote: > > No, it's simply that nobody can force volunteers to back > > port something when they're just not interested in doing > > the work, for whatever reason. Hence my statement above, > > of which you have focused on the last eight words. > > Well i argue that the free labor *WOULD* exists *IF* the > patching mechanism were more inclusive and intuitive. > "More inclusive"? Any man and his dog can get an account on the issue tracker? Perhaps it isn't "intuitive", but then reading the development guide tends to help. All in all though I have to admit that overall it's a really onerous task. Once you've produced the patch you have to go to all the trouble of logging on to the issue tracker, finding the appropriate issue and uploading the patch. You may even be inclined to make a comment. In this case this entire process could take as much as two whole minutes. From breamoreboy at yahoo.co.uk Sun Jul 19 16:28:31 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 21:28:31 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87egk3ykui.fsf@Equus.decebal.nl> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> Message-ID: On 19/07/2015 21:05, Cecil Westerhof wrote: > On Sunday 19 Jul 2015 21:01 CEST, Ian Kelly wrote: > >> On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof wrote: >>> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >>> >>>> On 19/07/2015 03:13, Terry Reedy wrote: >>>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>>> to 2.7, surely bug fixes are also allowed? >>>>> >>>>> Of course, allowed. But should they be made, and if so, by who? >>>> >>>> The people who want the fixes. >>> >>> Babies want clean diapers. So babies have to change diapers >>> themselves? >> >> Poor analogy. Babies need others to change their diapers for them >> because they're not capable of doing it for themselves. > > That is why I think it is good analogy. I think that most of the users > of 2.7 who would be delighted with fixes would have no idea how to get > those fixes into 2.7. > They could try reading the development guide to start with, or is that also too much to ask? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at gmail.com Sun Jul 19 16:36:09 2015 From: breamoreboy at gmail.com (breamoreboy at gmail.com) Date: Sun, 19 Jul 2015 13:36:09 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <3aa144a1-79f9-4008-bb24-f10761562f4d@googlegroups.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <3aa144a1-79f9-4008-bb24-f10761562f4d@googlegroups.com> Message-ID: <09a9e835-a826-4fc5-b101-246e4341c046@googlegroups.com> On Sunday, July 19, 2015 at 8:29:06 PM UTC+1, Rick Johnson wrote: > On Sunday, July 19, 2015 at 2:02:12 PM UTC-5, Ian wrote: > > Poor analogy. Babies need others to change their diapers > > for them because they're not capable of doing it for > > themselves. > > Duh! That was the point of his analogy, Ian. *ALL* Python > programmers need the patches. Whether or not they possess > the skill to create them is irrelevant. > Wrong, not all programmers need the patches as a lot of people couldn't care two hoots about 2.7. I'm one of them. If a programmer can't create a patch then they're in the wrong job. > But the baby is not the only victim if the diapers are not > changed. Imagine the foul odors that "rumors of bugginess" > will emit into the household, and if unchecked long enough, > out into the neighborhood. > > A some point a social worker will be dispatched, and the > baby will be taken away to a home that provides the > necessary sanitary conditions. But not before the parents > will be thrown in prison, ridiculed, and forgotten. The end > result is a broken family Ian. > > Is any of this sinking in? No because as always it's complete dross. From rosuav at gmail.com Sun Jul 19 17:08:19 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 07:08:19 +1000 Subject: Is this a good way to work with init and exception In-Reply-To: <87io9gx8tb.fsf@Equus.decebal.nl> References: <87380kzb8b.fsf@Equus.decebal.nl> <87r3o4xfhx.fsf@Equus.decebal.nl> <87io9gx8tb.fsf@Equus.decebal.nl> Message-ID: On Mon, Jul 20, 2015 at 5:10 AM, Cecil Westerhof wrote: >> I think it's fine, then. As long as it makes absolutely no sense to >> have two separately-initialized twitter connections, and as long as >> it's okay for two separate modules to both import this and to then >> share state, then what you have is fine. > > I do not see myself doing this, but I like to know ?everything?. When > I have a program with two different modules that both import this, > they would get in each-others way? How? If two modules import the same module, they get two references to that same module, not two separate module instances. Since your parameters appear only to affect the initialization itself, this is not likely to be a problem (it's not like you'll need to authenticate with two different sets of credentials, for instance), but it will mean that the second one will import an already-initialized module. That's why I suggested the try_init function which would quietly return an immediate success if the module had already been initialized. But if this isn't going to be an issue, then your code's fine. ChrisA From rosuav at gmail.com Sun Jul 19 17:16:55 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 07:16:55 +1000 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <20150719145520.5888c9e1@bigbox.christie.dr> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <20150719075601.779a4edb@bigbox.christie.dr> <20150719145520.5888c9e1@bigbox.christie.dr> Message-ID: On Mon, Jul 20, 2015 at 5:55 AM, Tim Chase wrote: > On 2015-07-20 04:07, Chris Angelico wrote: >> The int() and float() functions accept, if I'm not mistaken, >> anything with Unicode category "Nd" (Number, decimal digit). In >> your examples, the fraction (U+215B) is No, and the Roman numerals >> (U+2168, U+2182) are Nl, so they're not supported. Adding support >> for these forms might be accepted as a feature request, but it's >> not a bug. > > Ah, that makes sense. Some simple testing (thanks, unicodedata > module) supports your conjecture. > > It's not a particularly big deal so not really worth the brain-cycles > to add support for them. Just upon hearing "Python's int() does > smart things with Unicode characters", those were some of my first > characters to try. The failure struck me as odd until you explained > the simple difference. The other part of the problem is: What should float("2?3") be? Should it be equal to 21.0/83.0? Should the first part be parsed as a classic mixed number (2 + 1/8), and then what should the 3 mean? While it's easy to see what an individual character should represent (just check unicodedata.numeric(ch) - for ? it's 0.125), the true meaning of a string of such characters is less than clear. Similarly, Roman numerals aren't meant to be used after the decimal point, so "?.?" does not normally mean nine and a half... not to mention the confusing situation that "??" would naively parse as 15 but "?" is definitely 4. Since these kinds of complexities exist, it's safest to reserve this level of parsing for a special-purpose function. If someone can come up with a really strong argument for the float() and int() constructors interpreting these, I'd expect to see it deployed as a third-party module first, before being pointed out as "see, you can use float() for all these, but if you want to use those, you should use Float() instead". (Incidentally, I fully expect to see, some day, pytz.localize() semantics brought into the standard library datetime.datetime class, for precisely this reason.) Unicode is awesome, but it's not a panacea :) ChrisA From rantingrickjohnson at gmail.com Sun Jul 19 17:27:36 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 14:27:36 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <09a9e835-a826-4fc5-b101-246e4341c046@googlegroups.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <3aa144a1-79f9-4008-bb24-f10761562f4d@googlegroups.com> <09a9e835-a826-4fc5-b101-246e4341c046@googlegroups.com> Message-ID: <0718ce1d-5560-49d8-832b-5d71404e31fc@googlegroups.com> On Sunday, July 19, 2015 at 3:36:21 PM UTC-5, bream... at gmail.com wrote: > Wrong, not all programmers need the patches as a lot of > people couldn't care two hoots about 2.7. Well you should. Because apparently, you're incapable of recognizing that Py2 and Py3 are existentially joined at the hip! The world of language survival is more complex than your selfish desires. If you're unable to draw parallels between py2 and py3, it's only because your focused is far too narrow. Negative perception of py2 translates to negative perception of py3. Python is the sum of all it's parts. Not merely the small part (or rattle) that you happen to find amusing. And since py3 is the smallest part of Python, and py2 is the largest, you would be wise to consider the consequences of a failed, or even perceived failure, of Py2. If you change the diapers in Py3 nursery but refuse to change them in Py2 nursery, you might alleviate the your diaper rash, but other babies poop will always smell worse than your own! From tjreedy at udel.edu Sun Jul 19 17:27:59 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 17:27:59 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <201507190927.t6J9RVqM017606@fido.openend.se> References: <201507190927.t6J9RVqM017606@fido.openend.se> Message-ID: On 7/19/2015 5:27 AM, Laura Creighton wrote: > In a message of Sat, 18 Jul 2015 19:36:33 -0400, Terry Reedy writes: >> If the vast majority of Python programmers are focused on 2.7, why are >> volunteers to help fix 2.7 bugs so scarce? > > Because volunteers to fix any bugs are scarce? Because most people really > only think of bug fixing when they have one, and when they get that > one fixed they drop back into thinking that everything is perfect? > >> Does they all consider it perfect (or sufficient) as is? >> >> Should the core developers who do not personally use 2.7 stop >> backporting, because no one cares if they do? >> >> -- >> Terry Jan Reedy > > In the tiny corner of industrial automation where I do a lot of work, > nobody is using 3.0. It is not clear that this is ever going to change. > It would have to be driven by 'lack of people who know 2.x syntax' > or something like that. Not 'third party library compatibility' because > we really don't use them all that much. > > In this corner of the world, the favourite language for developing in > is C (because we work close to hardware) and one of the things we like > about it, a whole lot, is that the language never changes out from > under you. So there is great hope among industrial users of Python > that we can get a hold of a 'never going to change any more' version > of Python, and then code in that 'forever' knowing that a code change > isn't going to come along and break all our stuff. Any version of Python too old even for security patches would qualify. Of course, in a chaotic environment, static code may mean unstatic behavior. Changing internet attacks and changing build environments are the prime reason for extending 2.7 maintenance. > Bug fixes aren't supposed to do this, of course, in the same way that > backporting of features do, but every so often something that was > introduced to fix bug X ends up breaking something else Y. If the > consequences of a bug can be 10s of thousands of Euros lost, you > can see the appeal of 'this isn't going to happen any more'. > > While nobody likes to get bit by bugs, there is some sort of fuzzy > belief out there that the bugs fixes that have gone into 2.7 are > more about things that we would never run into, and thus we get the > risk of change without the benefit of the bugfix. This belief isn't > one that people substantiate -- it is 'just a feeling'. > > So from this corner of the world, which admittedly is a very small corner, > yes, the news is 'Life is good. Please leave us alone.' This is in > large part, I think, due to the belief that 'if things aren't breaking, > things are perfect' which is completely untrue, but that's the way > people are thinking. The extended extended maintenance for 2.7 (from now to 2020) is primarily for security and build fixes. I am beginning to think that the ambiguity of 'secondarily for other fixes, on a case-by-case basis, as determined by the whim of individual core developers' is a disservice to most users as well as most core developers. -- Terry Jan Reedy From Cecil at decebal.nl Sun Jul 19 18:10:01 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Mon, 20 Jul 2015 00:10:01 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> Message-ID: <87a8uryf2e.fsf@Equus.decebal.nl> On Sunday 19 Jul 2015 22:28 CEST, Mark Lawrence wrote: > On 19/07/2015 21:05, Cecil Westerhof wrote: >> On Sunday 19 Jul 2015 21:01 CEST, Ian Kelly wrote: >> >>> On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof wrote: >>>> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >>>> >>>>> On 19/07/2015 03:13, Terry Reedy wrote: >>>>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>>>> to 2.7, surely bug fixes are also allowed? >>>>>> >>>>>> Of course, allowed. But should they be made, and if so, by who? >>>>> >>>>> The people who want the fixes. >>>> >>>> Babies want clean diapers. So babies have to change diapers >>>> themselves? >>> >>> Poor analogy. Babies need others to change their diapers for them >>> because they're not capable of doing it for themselves. >> >> That is why I think it is good analogy. I think that most of the >> users of 2.7 who would be delighted with fixes would have no idea >> how to get those fixes into 2.7. >> > > They could try reading the development guide to start with, or is > that also too much to ask? My impression is that you and some other people are in an ivory tower and find it very cosy. It reminds me about the man on dry land who responded to the person who fell in water and shouted ?Help, I cannot swim!? with ?Why are you screaming? I cannot swim also. Do you hear me yelling about it?" -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From python at mrabarnett.plus.com Sun Jul 19 18:13:48 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Jul 2015 23:13:48 +0100 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <20150719075601.779a4edb@bigbox.christie.dr> <20150719145520.5888c9e1@bigbox.christie.dr> Message-ID: <55AC211C.8050904@mrabarnett.plus.com> On 2015-07-19 22:16, Chris Angelico wrote: > On Mon, Jul 20, 2015 at 5:55 AM, Tim Chase > wrote: >> On 2015-07-20 04:07, Chris Angelico wrote: >>> The int() and float() functions accept, if I'm not mistaken, >>> anything with Unicode category "Nd" (Number, decimal digit). In >>> your examples, the fraction (U+215B) is No, and the Roman numerals >>> (U+2168, U+2182) are Nl, so they're not supported. Adding support >>> for these forms might be accepted as a feature request, but it's >>> not a bug. >> >> Ah, that makes sense. Some simple testing (thanks, unicodedata >> module) supports your conjecture. >> >> It's not a particularly big deal so not really worth the brain-cycles >> to add support for them. Just upon hearing "Python's int() does >> smart things with Unicode characters", those were some of my first >> characters to try. The failure struck me as odd until you explained >> the simple difference. > > The other part of the problem is: What should float("2?3") be? Should > it be equal to 21.0/83.0? Should the first part be parsed as a classic > mixed number (2 + 1/8), and then what should the 3 mean? While it's > easy to see what an individual character should represent (just check > unicodedata.numeric(ch) - for ? it's 0.125), the true meaning of a > string of such characters is less than clear. Similarly, Roman > numerals aren't meant to be used after the decimal point, so "?.?" > does not normally mean nine and a half... not to mention the confusing > situation that "??" would naively parse as 15 but "?" is definitely 4. > Since these kinds of complexities exist, it's safest to reserve this > level of parsing for a special-purpose function. If someone can come > up with a really strong argument for the float() and int() > constructors interpreting these, I'd expect to see it deployed as a > third-party module first, before being pointed out as "see, you can > use float() for all these, but if you want to use those, you should > use Float() instead". (Incidentally, I fully expect to see, some day, > pytz.localize() semantics brought into the standard library > datetime.datetime class, for precisely this reason.) > > Unicode is awesome, but it's not a panacea :) > What's the result of, say, float('1e.3')? It raises an exception. So float("2?3") should also raise an exception. From ballensr at gmail.com Sun Jul 19 18:14:42 2015 From: ballensr at gmail.com (W. D. Allen) Date: Sun, 19 Jul 2015 15:14:42 -0700 Subject: Procedure for downloading and Installing Python 2.7 Modules Message-ID: <55AC2152.3090005@gmail.com> Would like to locate and install numpy, scipy and matplotlib with Wing 101 for Python 2.7 Just beginning to use Python 2.7 for engineering work. Any guidance would be appreciated. Thanks, WDA ballensr at gmail.com end From tjreedy at udel.edu Sun Jul 19 18:19:08 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 18:19:08 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On 7/18/2015 10:48 PM, Zachary Ware wrote: > On Sat, Jul 18, 2015 at 9:13 PM, Terry Reedy wrote: >> I understand the general problem quite well. But feeling that one would >> have to do a 2.7 backport after writing, editing, or reviewing a 3.x patch >> can discourage doing a review in the first place. I am at that point now >> with respect to Idle patches. > > I wonder if it would be worth the significant one-time effort to port > IDLE to 2/3, so that future bugfixes/improvements don't require any > extra effort than testing them with all versions. I am not aware of any version problems with tkinter code. In general, in the modules I have looked at, the main necessary differences are the Tkinter/tkinter, MessageBox/messagebox imports. In some files, the exception changes in 3.3 are even more a nuisance, since the name differences can be anywhere in the file. Since 2.7 patching will end sooner or later, I am reluctant to add 'if version' to 3.x. The exception changes could be masked in 2.7 by rebinding exception names at the top, but I am not sure that this would be a good idea. I, and others, have already made some changes to eliminate differences that are unnecessary, at least for 2.7 versus 3.3+ or now 3.4+. For instance, I believe all 'except X, msg:' statements have been converted to 'except X as msg:'. Most of the files with 'print' still need conversion to a future imports + function call. I have eliminated most other differences in at least a couple of modules before patching, and in one module that needs multiple patches. Hmm. After manual insertion of future print imports in 2.7 files, 2to3 could be used to convert the 2.7 print statements. This would be much easier than manual conversion and or copying for 3.x. Thanks for the inspiration. https://bugs.python.org/issue24671 -- Terry Jan Reedy From Cecil at decebal.nl Sun Jul 19 18:19:49 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Mon, 20 Jul 2015 00:19:49 +0200 Subject: Is this a good way to work with init and exception References: <87380kzb8b.fsf@Equus.decebal.nl> <87r3o4xfhx.fsf@Equus.decebal.nl> <87io9gx8tb.fsf@Equus.decebal.nl> Message-ID: <87615fyem2.fsf@Equus.decebal.nl> On Sunday 19 Jul 2015 23:08 CEST, Chris Angelico wrote: > On Mon, Jul 20, 2015 at 5:10 AM, Cecil Westerhof wrote: >>> I think it's fine, then. As long as it makes absolutely no sense >>> to have two separately-initialized twitter connections, and as >>> long as it's okay for two separate modules to both import this and >>> to then share state, then what you have is fine. >> >> I do not see myself doing this, but I like to know ?everything?. >> When I have a program with two different modules that both import >> this, they would get in each-others way? How? > > If two modules import the same module, they get two references to > that same module, not two separate module instances. Since your > parameters appear only to affect the initialization itself, this is > not likely to be a problem (it's not like you'll need to > authenticate with two different sets of credentials, for instance), > but it will mean that the second one will import an > already-initialized module. That's why I suggested the try_init > function which would quietly return an immediate success if the > module had already been initialized. But if this isn't going to be > an issue, then your code's fine. Good to know. I would expect two different instances. I agree that in my case it would not be a problem, but I put the code on GitHub: https://github.com/CecilWesterhof/PythonLibrary/blob/master/twitterDecebal.py I should do my best to circumvent nasty surprises for users of the code. Someone else could use several Twitter accounts at the same time. Is there a way to do this? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From rosuav at gmail.com Sun Jul 19 18:40:36 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 08:40:36 +1000 Subject: Is this a good way to work with init and exception In-Reply-To: <87615fyem2.fsf@Equus.decebal.nl> References: <87380kzb8b.fsf@Equus.decebal.nl> <87r3o4xfhx.fsf@Equus.decebal.nl> <87io9gx8tb.fsf@Equus.decebal.nl> <87615fyem2.fsf@Equus.decebal.nl> Message-ID: On Mon, Jul 20, 2015 at 8:19 AM, Cecil Westerhof wrote: >> If two modules import the same module, they get two references to >> that same module, not two separate module instances. Since your >> parameters appear only to affect the initialization itself, this is >> not likely to be a problem (it's not like you'll need to >> authenticate with two different sets of credentials, for instance), >> but it will mean that the second one will import an >> already-initialized module. That's why I suggested the try_init >> function which would quietly return an immediate success if the >> module had already been initialized. But if this isn't going to be >> an issue, then your code's fine. > > Good to know. I would expect two different instances. > > I agree that in my case it would not be a problem, but I put the code > on GitHub: > https://github.com/CecilWesterhof/PythonLibrary/blob/master/twitterDecebal.py > I should do my best to circumvent nasty surprises for users of the > code. Someone else could use several Twitter accounts at the same > time. Is there a way to do this? Does the instantiation of Core() involve authentication? Is it possible to call Core() more than once and use different accounts? Your send_message() takes an account identifier, so it might be you don't need separate accounts. But if, just very occasionally, you do need multiple, here's a possible design style: Have init() return the Core as well as stashing it in _core, and then have send_message() take an optional keyword argument (in 3.x, keyword-only) to choose a different core. That way, it'll by default use the most recently initialized core, but you can create multiple and manage them yourself if you so choose. (Obviously you'd use reinit_allowed=True for all the initializations.) ChrisA From breamoreboy at yahoo.co.uk Sun Jul 19 18:51:23 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 19 Jul 2015 23:51:23 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87a8uryf2e.fsf@Equus.decebal.nl> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> Message-ID: On 19/07/2015 23:10, Cecil Westerhof wrote: > On Sunday 19 Jul 2015 22:28 CEST, Mark Lawrence wrote: > >> On 19/07/2015 21:05, Cecil Westerhof wrote: >>> On Sunday 19 Jul 2015 21:01 CEST, Ian Kelly wrote: >>> >>>> On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof wrote: >>>>> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >>>>> >>>>>> On 19/07/2015 03:13, Terry Reedy wrote: >>>>>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>>>>> to 2.7, surely bug fixes are also allowed? >>>>>>> >>>>>>> Of course, allowed. But should they be made, and if so, by who? >>>>>> >>>>>> The people who want the fixes. >>>>> >>>>> Babies want clean diapers. So babies have to change diapers >>>>> themselves? >>>> >>>> Poor analogy. Babies need others to change their diapers for them >>>> because they're not capable of doing it for themselves. >>> >>> That is why I think it is good analogy. I think that most of the >>> users of 2.7 who would be delighted with fixes would have no idea >>> how to get those fixes into 2.7. >>> >> >> They could try reading the development guide to start with, or is >> that also too much to ask? > > My impression is that you and some other people are in an ivory tower > and find it very cosy. > > It reminds me about the man on dry land who responded to the person > who fell in water and shouted > ?Help, I cannot swim!? > with > ?Why are you screaming? > I cannot swim also. > Do you hear me yelling about it?" > You are now suggesting that people shouldn't even bother reading the develoment guide, just great. Do they have to do anything themselves to get patches through? Presumably the core devs give up their paid work, holidays, families, other hobbies and the like, just so some bunch of lazy, bone idle gits can get what they want, for nothing, when it suits them? It appears that babies aren't the only people who need their nappies changing around here. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From tjreedy at udel.edu Sun Jul 19 18:54:56 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 18:54:56 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87r3o4wv4h.fsf@handshake.de> References: <87r3o4wv4h.fsf@handshake.de> Message-ID: On 7/19/2015 1:53 AM, dieter wrote: > Mark Lawrence writes: >> ... >>> If the vast majority of Python programmers are focused on 2.7, why are >>> volunteers to help fix 2.7 bugs so scarce? > > I have not done much work related to Python bug fixing. But, I had > bad experience with other open source projects: many of my patches > (and bug reports) have been ignored over decades. This caused me > to change my attitude: I now report bugs (sometimes with patches) > and publish a potential solution in a separate package > (--> "dm.zopepatches.*", "dm.zodbpatches.*"). This way, affected > people can use a solution even if the core developpers don't care. Patches uploaded to the cpython tracker are public and can be and sometimes are used by other people without or before being officially applied. Separate packages are fine too. > From my point of view: if you want help with fixing bugs, > you must ensure that there is a high probability that those contributions > really find their way into the main development lines. > As I understand from other messages in this thread, this is also > a problem with Python bug fixing. Yes. There are two competing proposals (PEPs) for improvement waiting for a decision from an appointed judge. >>> Does they all consider it perfect (or sufficient) as is? > > I have not much blame for Python 2.7. I see a few minor points > > * "pdb" is quite weak - but I could fix some (but > by far not all) aspects in "dm.pdb". This is not a security issue, so enhancements cannot go in 2.7. > * "https" has been weakly handled in earlier versions, > but someone has done the Python 3 backport work in > an external package before the backport finally arrived in > Python 2.7. This was determined to be an internet security fix. >>> Should the core developers who do not personally use 2.7 stop >>> backporting, because no one cares if they do? > > I am grateful that the above mentioned "https" backport > was finally integrated into Python 2.7 -- even though > I find it acceptable to use an external package to get it. > > Thus, there are people who care. Of course, I will not tell > core developers that they must do backporting. If they don't > more external packages will come into existence which contain > (unofficial) backports. Some core developers have backported new modules they wrote as external packages. Thank you for your comments. -- Terry Jan Reedy From craig.sirna at gmail.com Sun Jul 19 19:06:51 2015 From: craig.sirna at gmail.com (craig.sirna at gmail.com) Date: Sun, 19 Jul 2015 16:06:51 -0700 (PDT) Subject: Need assistance In-Reply-To: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> Message-ID: <99ad55c0-0c1c-4442-9db7-c762f17cde04@googlegroups.com> On Thursday, July 16, 2015 at 9:16:01 PM UTC-5, craig... at gmail.com wrote: > I need help writing a homework program. > > I'll write it, but I can't figure out how to incorporate what I have read in the book to work in code. > > The assignment wants us to take a users first, middle and last name in a single input ( name=('enter your full name: )). > > Then we must display the full name rearranged in Last, First Middle order. > > I tried to use the search function in Python to locate any spaces in the input. It spot back the index 5 (I used Craig Daniel Sirna) > > That is correct for the first space, but I can't figure out how to get it to continue to the next space. > > The indexing process is also a bit confusingto me. > > I get that I can use len(fullName) to set the length of the index, and how the index is counted, but after that I'm lost. > > I have emailed my professor a few times, but haven't gotten a response.(online course) > > Any help would be greatly appreciated. def main(): name= input('Enter your full name: ') split=name.split() Full_name=split[2],split[0], split[1] print(Full_name[2],',', Full_name[0], Full_name[1]) main() Sorry it took so long to get back to you guys and I greatly appreciate all the help!!! But I just did it now and it does work. I have been working on my College algebra homework for the past week and I am still not even finished or ready for the test....fml.... From tjreedy at udel.edu Sun Jul 19 19:13:07 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Jul 2015 19:13:07 -0400 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <1fc552fc-5504-434a-8fdd-2bdd88afc4d7@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <87twt07h3a.fsf@elektro.pacujo.net> <1fc552fc-5504-434a-8fdd-2bdd88afc4d7@googlegroups.com> Message-ID: On 7/19/2015 3:32 AM, Rustom Mody wrote: > Unix bc: > $ bc > bc 1.06.95 > Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. > This is free software with ABSOLUTELY NO WARRANTY. > For details type `warranty'. > 4+5 > 9 > obase=8 > 4+5 > 11 > > IOW bc has two (global) variables ibase and obase for input and output base. > If you dont provide these as settable you hardwire them at 10 (8/16 in some > assembly languages)? > > Hopefully you will agree that python is more full-featured than bc and should > subsume bc functionality? Nice try ;-) However, I think is not especially relevant. I do not believe that Guido would agree that bc should govern python design. Do *you* really think that? Python is fundamentally a general purpose batch-mode language. Interactive mode is secondary and generally subservient to writing real programs. I know that he has said that he is not inclined to add additional interactive-mode-only features to Python. -- Terry Jan Reedy From Cecil at decebal.nl Sun Jul 19 19:23:31 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Mon, 20 Jul 2015 01:23:31 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> Message-ID: <87zj2rwx3g.fsf@Equus.decebal.nl> On Monday 20 Jul 2015 00:51 CEST, Mark Lawrence wrote: > On 19/07/2015 23:10, Cecil Westerhof wrote: >> On Sunday 19 Jul 2015 22:28 CEST, Mark Lawrence wrote: >> >>> On 19/07/2015 21:05, Cecil Westerhof wrote: >>>> On Sunday 19 Jul 2015 21:01 CEST, Ian Kelly wrote: >>>> >>>>> On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof wrote: >>>>>> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >>>>>> >>>>>>> On 19/07/2015 03:13, Terry Reedy wrote: >>>>>>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>>>>>> to 2.7, surely bug fixes are also allowed? >>>>>>>> >>>>>>>> Of course, allowed. But should they be made, and if so, by >>>>>>>> who? >>>>>>> >>>>>>> The people who want the fixes. >>>>>> >>>>>> Babies want clean diapers. So babies have to change diapers >>>>>> themselves? >>>>> >>>>> Poor analogy. Babies need others to change their diapers for >>>>> them because they're not capable of doing it for themselves. >>>> >>>> That is why I think it is good analogy. I think that most of the >>>> users of 2.7 who would be delighted with fixes would have no idea >>>> how to get those fixes into 2.7. >>>> >>> >>> They could try reading the development guide to start with, or is >>> that also too much to ask? >> >> My impression is that you and some other people are in an ivory >> tower and find it very cosy. >> >> It reminds me about the man on dry land who responded to the person >> who fell in water and shouted >> ?Help, I cannot swim!? >> with >> ?Why are you screaming? >> I cannot swim also. >> Do you hear me yelling about it?" >> > > You are now suggesting that people shouldn't even bother reading the > develoment guide, just great. Do they have to do anything themselves > to get patches through? Presumably the core devs give up their paid > work, holidays, families, other hobbies and the like, just so some > bunch of lazy, bone idle gits can get what they want, for nothing, > when it suits them? It appears that babies aren't the only people > who need their nappies changing around here. No use replying anymore. You make a caricature of what I am saying and put words in my mouth I never said. Just stay in your cosy ivory tower. But please do not pretend that you are open for discussion, because you are not. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From Cecil at decebal.nl Sun Jul 19 19:27:46 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Mon, 20 Jul 2015 01:27:46 +0200 Subject: Is this a good way to work with init and exception References: <87380kzb8b.fsf@Equus.decebal.nl> <87r3o4xfhx.fsf@Equus.decebal.nl> <87io9gx8tb.fsf@Equus.decebal.nl> <87615fyem2.fsf@Equus.decebal.nl> Message-ID: <87vbdfwwwd.fsf@Equus.decebal.nl> On Monday 20 Jul 2015 00:40 CEST, Chris Angelico wrote: > On Mon, Jul 20, 2015 at 8:19 AM, Cecil Westerhof wrote: >>> If two modules import the same module, they get two references to >>> that same module, not two separate module instances. Since your >>> parameters appear only to affect the initialization itself, this >>> is not likely to be a problem (it's not like you'll need to >>> authenticate with two different sets of credentials, for >>> instance), but it will mean that the second one will import an >>> already-initialized module. That's why I suggested the try_init >>> function which would quietly return an immediate success if the >>> module had already been initialized. But if this isn't going to be >>> an issue, then your code's fine. >> >> Good to know. I would expect two different instances. >> >> I agree that in my case it would not be a problem, but I put the >> code on GitHub: >> https://github.com/CecilWesterhof/PythonLibrary/blob/master/twitterDecebal.py >> I should do my best to circumvent nasty surprises for users of the >> code. Someone else could use several Twitter accounts at the same >> time. Is there a way to do this? > > Does the instantiation of Core() involve authentication? Is it > possible to call Core() more than once and use different accounts? > Your send_message() takes an account identifier, so it might be you > don't need separate accounts. But if, just very occasionally, you do > need multiple, here's a possible design style: Have init() return > the Core as well as stashing it in _core, and then have > send_message() take an optional keyword argument (in 3.x, > keyword-only) to choose a different core. That way, it'll by default > use the most recently initialized core, but you can create multiple > and manage them yourself if you so choose. (Obviously you'd use > reinit_allowed=True for all the initializations.) You are right: core is a general initialisation, so in this case nothing to worry about. :-D When I write something where it could make a difference, I should use your tip. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From torriem at gmail.com Sun Jul 19 19:56:25 2015 From: torriem at gmail.com (Michael Torrie) Date: Sun, 19 Jul 2015 17:56:25 -0600 Subject: Need assistance In-Reply-To: <99ad55c0-0c1c-4442-9db7-c762f17cde04@googlegroups.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <99ad55c0-0c1c-4442-9db7-c762f17cde04@googlegroups.com> Message-ID: <55AC3929.5020309@gmail.com> On 07/19/2015 05:06 PM, craig.sirna at gmail.com wrote: > def main(): name= input('Enter your full name: ') > split=name.split() > Full_name=split[2],split[0], split[1] > print(Full_name[2],',', Full_name[0], Full_name[1]) > > main() > > Sorry it took so long to get back to you guys and I greatly > appreciate all the help!!! > > But I just did it now and it does work. I have been working on my > College algebra homework for the past week and I am still not even > finished or ready for the test....fml.... Now do you understand why it works and how? For example, if I said that the "full_name=...." line is redundant, do you understand why? From rantingrickjohnson at gmail.com Sun Jul 19 20:21:00 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 17:21:00 -0700 (PDT) Subject: Need assistance In-Reply-To: <99ad55c0-0c1c-4442-9db7-c762f17cde04@googlegroups.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <99ad55c0-0c1c-4442-9db7-c762f17cde04@googlegroups.com> Message-ID: <219b1f31-d34f-4ec2-846c-96ddd7170058@googlegroups.com> On Sunday, July 19, 2015 at 6:07:14 PM UTC-5, craig... at gmail.com wrote: > def main(): > name= input('Enter your full name: ') > split=name.split() > Full_name=split[2],split[0], split[1] > print(Full_name[2],',', Full_name[0], Full_name[1]) > > main() Sorry, but this code is no where near done yet. What happens when the user enters invalid input? *BANG* > split=name.split() Unpacking those variables would be wiser, and syntactically cleaner, than storing them behind a single variable. And split is a horrible symbol choice. first, middle, and last would be more descriptive. > Full_name=split[2],split[0], split[1] > print(Full_name[2],',', Full_name[0], Full_name[1]) Yuck. Too noisy. Always try to keep indexing to a minimum. And never, ever, repeat yourself. VALIDATE_YOUR_INPUT + REMOVE_THE_NOISE = A+ EXTRA_CREDIT: Repeatedly ask for input until validation passes. EXTRA_EXTRA_CREDIT: Allow clean exit if the user declines input. From breamoreboy at yahoo.co.uk Sun Jul 19 20:27:55 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 20 Jul 2015 01:27:55 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <87zj2rwx3g.fsf@Equus.decebal.nl> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> Message-ID: On 20/07/2015 00:23, Cecil Westerhof wrote: > On Monday 20 Jul 2015 00:51 CEST, Mark Lawrence wrote: > >> On 19/07/2015 23:10, Cecil Westerhof wrote: >>> On Sunday 19 Jul 2015 22:28 CEST, Mark Lawrence wrote: >>> >>>> On 19/07/2015 21:05, Cecil Westerhof wrote: >>>>> On Sunday 19 Jul 2015 21:01 CEST, Ian Kelly wrote: >>>>> >>>>>> On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof wrote: >>>>>>> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >>>>>>> >>>>>>>> On 19/07/2015 03:13, Terry Reedy wrote: >>>>>>>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>>>>>>> to 2.7, surely bug fixes are also allowed? >>>>>>>>> >>>>>>>>> Of course, allowed. But should they be made, and if so, by >>>>>>>>> who? >>>>>>>> >>>>>>>> The people who want the fixes. >>>>>>> >>>>>>> Babies want clean diapers. So babies have to change diapers >>>>>>> themselves? >>>>>> >>>>>> Poor analogy. Babies need others to change their diapers for >>>>>> them because they're not capable of doing it for themselves. >>>>> >>>>> That is why I think it is good analogy. I think that most of the >>>>> users of 2.7 who would be delighted with fixes would have no idea >>>>> how to get those fixes into 2.7. >>>>> >>>> >>>> They could try reading the development guide to start with, or is >>>> that also too much to ask? >>> >>> My impression is that you and some other people are in an ivory >>> tower and find it very cosy. >>> >>> It reminds me about the man on dry land who responded to the person >>> who fell in water and shouted >>> ?Help, I cannot swim!? >>> with >>> ?Why are you screaming? >>> I cannot swim also. >>> Do you hear me yelling about it?" >>> >> >> You are now suggesting that people shouldn't even bother reading the >> develoment guide, just great. Do they have to do anything themselves >> to get patches through? Presumably the core devs give up their paid >> work, holidays, families, other hobbies and the like, just so some >> bunch of lazy, bone idle gits can get what they want, for nothing, >> when it suits them? It appears that babies aren't the only people >> who need their nappies changing around here. > > No use replying anymore. You make a caricature of what I am saying and > put words in my mouth I never said. Just stay in your cosy ivory > tower. But please do not pretend that you are open for discussion, > because you are not. > Thank goodness for that as you make no sense at all. As for this ivory tower nonsense, you clearly haven't bothered reading anything I've said about the proposed improvements to the core workflow. But then of course you wouldn't bother with that, you again expect somebody else to do all the work for you, for free, and probably still complain that the benefits that you're getting aren't enough. Quite frankly your attitude throughout this thread makes me puke. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at gmail.com Sun Jul 19 20:45:15 2015 From: breamoreboy at gmail.com (breamoreboy at gmail.com) Date: Sun, 19 Jul 2015 17:45:15 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <0718ce1d-5560-49d8-832b-5d71404e31fc@googlegroups.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <3aa144a1-79f9-4008-bb24-f10761562f4d@googlegroups.com> <09a9e835-a826-4fc5-b101-246e4341c046@googlegroups.com> <0718ce1d-5560-49d8-832b-5d71404e31fc@googlegroups.com> Message-ID: On Sunday, July 19, 2015 at 10:27:58 PM UTC+1, Rick Johnson wrote: > On Sunday, July 19, 2015 at 3:36:21 PM UTC-5, bream... at gmail.com wrote: > > Wrong, not all programmers need the patches as a lot of > > people couldn't care two hoots about 2.7. > > Well you should. Because apparently, you're incapable of > recognizing that Py2 and Py3 are existentially joined at the > hip! The world of language survival is more complex than your > selfish desires. Wrong again, 2.7 doesn't have all the goodies now poring into 3.x, so there is nothing in 2.7 to make me care. Further as I'm a one man band I do what I like, so having canned it several years back, as have many core devs, it's staying canned. "Selfish desires", very funny, I'll have to remember that one, you really are excelling yourself. > > If you're unable to draw parallels between py2 and py3, > it's only because your focused is far too narrow. Negative > perception of py2 translates to negative perception of py3. I have no negative perception of 2.7, it simply no longer interests me, to repeat in the same way that it no longer interests some core devs. > > Python is the sum of all it's parts. Not merely the small > part (or rattle) that you happen to find amusing. And since > py3 is the smallest part of Python, and py2 is the largest, > you would be wise to consider the consequences of a failed, > or even perceived failure, of Py2. 2.7 is pretty much rock steady Eddie, so it is never going to be a perceived failure, let alone an actual failure. > > If you change the diapers in Py3 nursery but refuse to change > them in Py2 nursery, you might alleviate the your diaper rash, > but other babies poop will always smell worse than your own! I'll repeat, those who want 2.7 supported do the work, can it get any simpler? You can support it, or are you still too busy working on your fork, RickedPython? I'm not interested in it, I'm wouldn't touch it even if someone offered to pay me, end of story. From rantingrickjohnson at gmail.com Sun Jul 19 20:49:45 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 17:49:45 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> Message-ID: <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> On Sunday, July 19, 2015 at 7:28:28 PM UTC-5, Mark Lawrence wrote: > Thank goodness for that as you make no sense at all. As > for this ivory tower nonsense, [...] Cecil, don't pay too much attention to Mark, he's a glory hound. He's like the Python community version of Cerberus -- you know, the three headed dog guarding the entrance to the Greek underworld. Every time i defeat him, and drag him out through an opening in the "caverns of code", and take him to a secret grove owned by D'Aprano, he always escapes and returns to guard the entrance again -- he's very loyal! He won't allow you to enter because you're still alive, and as such, you still have the capacity to "feel" emotions like compassion. These emotions are forbidden in the underworld!!! But don't worry, his bark is worse than his bite, and he is just the first of many daemons you must defeat on your quest to challenge the benevolent Hades. From jeanpierreda at gmail.com Sun Jul 19 21:20:45 2015 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 19 Jul 2015 18:20:45 -0700 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Jul 18, 2015 at 9:45 PM, Steven D'Aprano wrote: >> It gets really boring submitting 2.7-specific patches, though, when >> they aren't accepted, and the committers have such a hostile attitude >> towards it. I was told by core devs that, instead of fixing bugs in >> Python 2, I should just rewrite my app in Python 3. > > Really? Can you point us to this discussion? Yes, really. It was on #python-dev IRC. > If you are right, and that was an official pronouncement, then it seems that > non-security bug fixes to 2.7 are forbidden. I never said it was a pronouncement, or official. It wasn't. I have no idea where you got that idea from, given that I specifically have said that I think non-security bug fixes are allowed. > I suspect though that it's not quite that black and white. Perhaps there was > some doubt about whether or not the patch in question was fixing a bug or > adding a feature (a behavioural change). Or the core dev in question was > speaking for themselves, not for all. They weren't speaking for all. And, I never said they were. Nor did I imply that they were. Search your logs for https://bugs.python.org/issue17094 and http://bugs.python.org/issue5315 I was most frustrated by the first case -- the patch was (informally) rejected in favor of the "right" fix, and the "right" fix was (informally) rejected because it changed behavior, leaving me only with the option of absurd workarounds of a bug in Python, or moving to python 3. >> It has even been >> implied that bugs in Python 2 are *good*, because that might help with >> Python 3 adoption. > > Really? Can you point us to this discussion? > > As they say on Wikipedia, Citation Needed. I would like to see the context > before taking that at face value. Of course, it was a joke. The format of the joke goes like this: people spend a lot of time debugging and writing bugfixes for Python 2.7, and you say: guido wants all python 3 features in python 2, so ssbr` maybe choose the right time to ask a backport ;-) oh. if i would be paid to contribute to cpython, i would probably be ok to backport anything from python 3 to python 2 since i'm not paid for that, i will to kill python 2, it must suffer a lot And that's about as close to logs as I am comfortable posting. Grep your logs for that, too. I don't like how this is being redirected to "surely you misunderstood" or "I don't believe you". The fact that some core devs are hostile to 2.x development is really bleedingly obvious, you shouldn't need quotes or context thrown at you. The rhetoric almost always shies _just_ short of ceasing bugfixes (until 2020, when that abruptly becomes a cracking good idea). e.g. in "2.7 is here until 2020, please don't call it a waste". I don't want to argue over who said what. I am sure everyone meant the best, and I misunderstood them given a complicated context and a rough day. Let's end this thread here, please. -- Devin From rantingrickjohnson at gmail.com Sun Jul 19 21:25:16 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 18:25:16 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <87y4icxh4r.fsf@Equus.decebal.nl> <3aa144a1-79f9-4008-bb24-f10761562f4d@googlegroups.com> <09a9e835-a826-4fc5-b101-246e4341c046@googlegroups.com> <0718ce1d-5560-49d8-832b-5d71404e31fc@googlegroups.com> Message-ID: <147c13aa-af49-4789-a844-ab3ed6f6f99d@googlegroups.com> On Sunday, July 19, 2015 at 7:45:43 PM UTC-5, bream... at gmail.com wrote: > I have no negative perception of 2.7, it simply no longer > interests me, to repeat in the same way that it no longer > interests some core devs. Your apathy towards Py2 will not shield you from the collateral damage caused by it's demise. What matters is what the *WORLD* thinks about Python. And if the global "perception" is that: "Python is buggy", or that: "the python community is fractured" -> then all hope in widespread future adoption is gone! Then, both Py2 and Py3 die. Then, you will be forced to use another language? GOT IT? This is *NOT* about you, or me, this is about the *PERCEPTION* of Python within the *ENTIRE* programming community. > are you still too busy working on your fork, RickedPython? I've never seen you before. Are you a regular hiding behind a fake name? From breamoreboy at gmail.com Sun Jul 19 21:26:42 2015 From: breamoreboy at gmail.com (breamoreboy at gmail.com) Date: Sun, 19 Jul 2015 18:26:42 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> Message-ID: On Monday, July 20, 2015 at 1:49:58 AM UTC+1, Rick Johnson wrote: > On Sunday, July 19, 2015 at 7:28:28 PM UTC-5, Mark Lawrence wrote: > > > Thank goodness for that as you make no sense at all. As > > for this ivory tower nonsense, [...] > > Cecil, don't pay too much attention to Mark, he's a glory > hound. He's like the Python community version of Cerberus -- > you know, the three headed dog guarding the entrance to the > Greek underworld. > > Every time i defeat him, and drag him out through an opening in > the "caverns of code", and take him to a secret grove owned > by D'Aprano, he always escapes and returns to guard the > entrance again -- he's very loyal! > > He won't allow you to enter because you're still alive, and > as such, you still have the capacity to "feel" emotions like > compassion. These emotions are forbidden in the underworld!!! > > But don't worry, his bark is worse than his bite, and he is > just the first of many daemons you must defeat on your quest > to challenge the benevolent Hades. Gosh you don't half spout some rubbish. Your total number of victories over me is zero, although I personally come here to give or get knowledge, not look for such things. As for the cobblers about Cerburus and "challenging the benevolent Hades" would you be kind enough to:- a) list just how many Python bugs you have worked on b) state how much work you intend doing on the planned core workflow improvements For the latter you can find the relevant PEPs easily enough for yourself, or just like Cecil do you expect someone to do that for you as well? From rantingrickjohnson at gmail.com Sun Jul 19 21:35:18 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 19 Jul 2015 18:35:18 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> Message-ID: On Sunday, July 19, 2015 at 8:26:52 PM UTC-5, bream... at gmail.com wrote: > On Monday, July 20, 2015 at 1:49:58 AM UTC+1, Rick Johnson wrote: > > On Sunday, July 19, 2015 at 7:28:28 PM UTC-5, Mark Lawrence wrote: > > Every time i defeat [MARK LAWRENCE], and drag him out > > through an opening in the "caverns of code", and take > > him to a secret grove owned by D'Aprano, he always > > escapes and returns to guard the entrance again -- he's > > very loyal! > > Your total number of victories over me is zero, although I > personally come here to give or get knowledge, not look > for such things. I figured that was you *MARK LAWRENCE*. I shall add sock-puppeting to your many egregious offenses! And poorly executed sock-puppeting as well! You're a zero. From breamoreboy at yahoo.co.uk Sun Jul 19 21:46:13 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 20 Jul 2015 02:46:13 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 20/07/2015 02:20, Devin Jeanpierre wrote: > > I don't like how this is being redirected to "surely you > misunderstood" or "I don't believe you". The fact that some core devs > are hostile to 2.x development is really bleedingly obvious, you > shouldn't need quotes or context thrown at you. The rhetoric almost > always shies _just_ short of ceasing bugfixes (until 2020, when that > abruptly becomes a cracking good idea). e.g. in "2.7 is here until > 2020, please don't call it a waste". > A couple of things. First "some core devs are hostile", actually some have stated that they're simply not interested in 2.7 and will not work on it. Second how has the thread got here, as it was originally asking about back porting bug fixes from 3.x to 2.7? Further it said:- If the vast majority of Python programmers are focused on 2.7, why are volunteers to help fix 2.7 bugs so scarce? So I most humbly suggest, as I may have hinted at once or twice earlier in this thread, that people either put up or shut up. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From rustompmody at gmail.com Sun Jul 19 22:02:35 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 19 Jul 2015 19:02:35 -0700 (PDT) Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <87twt07h3a.fsf@elektro.pacujo.net> <1fc552fc-5504-434a-8fdd-2bdd88afc4d7@googlegroups.com> Message-ID: On Monday, July 20, 2015 at 4:43:57 AM UTC+5:30, Terry Reedy wrote: > On 7/19/2015 3:32 AM, Rustom Mody wrote: > > > Unix bc: > > $ bc > > bc 1.06.95 > > Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. > > This is free software with ABSOLUTELY NO WARRANTY. > > For details type `warranty'. > > 4+5 > > 9 > > obase=8 > > 4+5 > > 11 > > > > IOW bc has two (global) variables ibase and obase for input and output base. > > If you dont provide these as settable you hardwire them at 10 (8/16 in some > > assembly languages)? > > > > Hopefully you will agree that python is more full-featured than bc and should > > subsume bc functionality? > > Nice try ;-) However, I think is not especially relevant. I do not > believe that Guido would agree that bc should govern python design. Do > *you* really think that? Python is fundamentally a general purpose > batch-mode language. Interactive mode is secondary and generally > subservient to writing real programs. I know that he has said that he > is not inclined to add additional interactive-mode-only features to Python. We will have to agree to disagree then. I wrote this in 2012 (that is to say not in context of this discussion): http://blog.languager.org/2012/10/functional-programming-lost-booty.html in which I list an REPL as one of the factors that distinguish a modern, powerful v hi-level language from stodgy old-fashioned blub languages. Regarding your earlier points about idle, I think you are (to use a traditional OS metaphor) mixing up policy with mechanism. Policy: Having a REPL (things like Idle) Mechanism: How exactly its bundled eg in pythonland python the interpreter and the interactive version are the same executable functioning in different modes In other languages (haskell has ghci, ruby has irb) the interactive interpreter is a different program (just a thin wrapper) on the main interpreter (compiler for haskell) Likewise in debian (ubuntu) vs windows the bundling is v different. In debian python comes for free and the system would not work without it but tkinter, idle etc need to be installed with their dependencies In windows, one needs to install one bundle and one gets the whole lot... Of course as recently discussed, it may be time to have ipython replace vanilla python and therefore break that off from the core. These are (to me) minor points compared to the existence/non-existence of an interactive interpreter. From rustompmody at gmail.com Sun Jul 19 22:16:57 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 19 Jul 2015 19:16:57 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> On Monday, July 20, 2015 at 7:16:50 AM UTC+5:30, Mark Lawrence wrote: > On 20/07/2015 02:20, Devin Jeanpierre wrote: > > > > > I don't like how this is being redirected to "surely you > > misunderstood" or "I don't believe you". The fact that some core devs > > are hostile to 2.x development is really bleedingly obvious, you > > shouldn't need quotes or context thrown at you. The rhetoric almost > > always shies _just_ short of ceasing bugfixes (until 2020, when that > > abruptly becomes a cracking good idea). e.g. in "2.7 is here until > > 2020, please don't call it a waste". > > > > A couple of things. > > First "some core devs are hostile", actually some have stated that > they're simply not interested in 2.7 and will not work on it. > > Second how has the thread got here, as it was originally asking about > back porting bug fixes from 3.x to 2.7? Further it said:- > > > If the vast majority of Python programmers are focused on 2.7, why are > volunteers to help fix 2.7 bugs so scarce? > > > So I most humbly suggest, as I may have hinted at once or twice earlier > in this thread, that people either put up or shut up. I just ran the following command $ hg log --template "{author|person}\n" | sort | uniq -c | sort -nr as giving all the committers to python in sorted order. I get the list below. Dont see any Mark Lawrence there Of course I dont know hg at all well... Just picked up the above command from http://stackoverflow.com/questions/6126678/how-to-list-commiters-sorted-by-number-of-commits-commit-count So... May I humbly ask where are your precious commits?? List of python committers: ------------------------- 11081 Guido van Rossum 6172 Fred Drake 6120 Georg Brandl 5603 Benjamin Peterson 4077 Raymond Hettinger 3874 Victor Stinner 3774 Antoine Pitrou 3157 Jack Jansen 3089 Martin v. L?wis 2668 Tim Peters 2372 Serhiy Storchaka 2219 Andrew M. Kuchling 2205 Barry Warsaw 2038 Ezio Melotti 2016 Neal Norwitz 2009 Mark Dickinson 1966 Brett Cannon 1307 R David Murray 1180 Christian Heimes 1159 Senthil Kumaran 1108 Gregory P. Smith 1075 ?ric Araujo 1071 Vinay Sajip 1065 Jeremy Hylton 903 Tarek Ziad? 872 Greg Ward 871 Thomas Heller 780 R. David Murray 777 Terry Jan Reedy 728 Skip Montanaro 695 Nick Coghlan 687 Ned Deily 581 Ronald Oussoren 579 Walter D?rwald 527 Kurt B. Kaiser 519 Michael W. Hudson 511 Amaury Forgeot d'Arc 481 Stefan Krah 450 Andrew Svetlov 432 Thomas Wouters 423 Zachary Ware 422 Anthony Baxter 403 Brian Curtin 400 Florent Xicluna 387 Eli Bendersky 383 Eric Smith 370 Hirokazu Yamamoto 364 Charles-Fran?ois Natali 362 Alexander Belopolsky 354 Just van Rossum 344 Marc-Andr? Lemburg 340 Alexandre Vassalotti 334 Michael Foord 317 Neil Schemenauer 314 Fredrik Lundh 293 Jesus Cea 285 Sandro Tosi 282 Larry Hastings 264 Yury Selivanov 260 Matthias Klose 259 Berker Peksag 239 Richard Oudkerk 233 Nadeem Vawda 202 Kristj?n Valur J?nsson 189 Petri Lehtinen 174 Collin Winter 166 Lars Gust?bel 163 Hye-Shik Chang 159 Mark Hammond 159 Facundo Batista 156 Armin Rigo 154 Andrew MacIntyre 153 Steve Dower 153 doko 153 Chris Jerdonek 152 Sjoerd Mullender 123 ?ukasz Langa 121 cvs2svn 118 Giampaolo Rodol? 112 Andrew Kuchling 109 Guilherme Polo 109 Giampaolo Rodola' 106 Eric Snow 102 Ka-Ping Yee 101 Meador Inge 101 Jesse Noller 101 Jason R. Coombs 97 Trent Nelson 97 Steven M. Gava 96 Hynek Schlawack 93 Tim Golden 93 Eric S. Raymond 91 Ethan Furman 87 Moshe Zadka 87 Johannes Gijsbers 87 Jeffrey Yasskin 79 Roger E. Masse 77 Ross Lagerwall 67 Donald Stufft 65 George Yoshida 63 Phillip J. Eby 63 Philip Jenvey 62 Gustavo Niemeyer 59 Jeroen Ruigrok van der Werven 58 Steven Bethard 51 Eric V. Smith 50 Roger Serwy 46 Bob Ippolito 45 Terry Reedy 45 Peter Schneider-Kamp 45 Gerhard H?ring 42 Tarek Ziade 42 Edward Loper 40 Peter Astrand 39 Alex Martelli 38 Daniel Stutzbach 37 Sean Reifscheider 37 Jason Tishler 36 Bill Janssen 34 Trent Mick 34 Piers Lauder 33 Jack Diederich 31 Mark Summerfield 31 Jim Fulton 29 Greg Stein 28 Nicholas Bastin 27 Andrew McNamara 23 Robert Schuppenies 23 Josiah Carlson 22 Vladimir Marangozov 21 Kristjan Valur Jonsson 21 Brian Quinlan 20 Paul Prescod 18 Tony Lownds 18 Steve Purcell 18 Andrew Dalke 17 Finn Bock 17 David Wolever 16 Steve Holden 16 Robert Collins 16 Jean-Paul Calderone 16 Charles-Francois Natali 15 ?iga Seilnacht 15 David Malcolm 15 Armin Ronacher 14 Travis E. Oliphant 14 Tal Einat 14 Richard Jones 14 Reid Kleckner 12 Frank Wierzbicki 12 Alex Gaynor 11 guido 10 David Goodger 10 Chui Tey 9 unknown 9 brian.curtin 8 Samuele Pedroni 8 Kushal Das 7 Sean Reifschneider 7 Martin v. Loewis 7 Ken Manheimer 7 Doug Hellmann 7 Dirkjan Ochtman 7 Chris Withers 7 Christian Tismer 7 briancurtin 6 Dave Cole 6 Ask Solem 5 Peter Moody 5 Marc-Andre Lemburg 5 Felix Crux 4 Walter Doerwald 4 Rusi 4 Martin Blais 4 Jerry Seutter 3 Matt Fleming 2 Ralf Schmitt 2 Paul Moore 2 Nicholas Riley 2 krisvale 2 Jeremy Kloth 2 David Ascher 2 bquinlan 2 Alexis Metaireau 1 Zbigniew J??drzejewski-Szmek 1 Robert Jordens 1 orsenthil 1 Gerhard Haering 1 David Scherer 1 Daniel Holth 1 Charles G. Waldman 1 Atsuo Ishimoto From steve at pearwood.info Sun Jul 19 22:30:03 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 20 Jul 2015 12:30:03 +1000 Subject: Off-topic: Europe [was Re: Noob in Python. Problem with fairly simple test case] References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <79mdneVqW9UGgzrInZ2dnUU7-cOdnZ2d@giganews.com> <049ae0f4-96d1-4155-8618-32c8931febb0@googlegroups.com> <85d372eb-f39d-459d-be71-50ed7c9b966c@googlegroups.com> <55a86c1b$0$1657$c3e8da3$5496439d@news.astraweb.com> <151e3d73-7284-40eb-b8b0-b2b28fc28dc1@googlegroups.com> <4760b41d-54c8-436f-a40b-40ecd9622c5b@googlegroups.com> Message-ID: <55ac5d2c$0$1662$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Jul 2015 03:25 am, Rick Johnson wrote: > On Sunday, July 19, 2015 at 4:18:31 AM UTC-5, Laura Creighton wrote: >> And, despite Norway not being part of the EU, Scandinavia >> is still in Europe. > > This is a bit off topic: But i don't consider Scandinavia to > be a part of the EU. Laura didn't say that Scandinavia (Finland, Sweden, Norway, Denmark) is part of the European Union (a political union), she explicitly stated that Norway is not. But it is part of Europe, which is a geographical area that runs from Ireland to the Ural mountains in Russia, from the Mediterranean to the Arctic Circle. > Not anymore than i would consider > America to be a part of the EU. Sure, we're all colloquially > known as "the west", "The West" has nothing to do with this. But for the record, "the West" includes Australia and New Zealand, which are in the south-east. > The only ubiquitous > binding agent between all the member countries is the > existential need to conglomerate military power against foes > in the east. You're thinking of NATO. The EU is primarily a political union designed to reduce the cost of business when dealing with other European countries. If it has any military influence, it is that countries that allow free trade and travel between themselves are less likely to war on each other than those that don't. Germany is less likely to invade France again, so long as German business and French business are all part of the same business. At least the sort of war that involves actual shooting. [Disclaimer: countries that have little or no contact at all are even less likely to go to war against each other.] > Beyond that, the union is superficial at best. > If the bailout fails, or another worldwide financial crisis > hits, the outcome could be disastrous for the EU. Actually, the best thing for the EU right now would probably be for Greece to withdraw from the Euro and float their own currency, but otherwise remain in the EU. Not only would that be the best outcome for Greece, but it would give the German bureaucrats and the Troika a kick to the seat of their pants for attempting to interfere in the democratic process. > When those pension checks stop coming in the mail, people get > violent! The pension cheques stopped coming about 18 months ago, and despite austerity, despite putting millions of people out of work, despite sticking a railway spike into the Greek economy (or perhaps because of these three factors) Greece owes more money now than it did when the Germans declared economic war on them on behalf of the banks. -- Steven From steve at pearwood.info Sun Jul 19 22:32:43 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 20 Jul 2015 12:32:43 +1000 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> Message-ID: <55ac5dca$0$1662$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Jul 2015 05:01 am, Ian Kelly wrote: > On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof > wrote: >> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >> >>> On 19/07/2015 03:13, Terry Reedy wrote: >>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>> to 2.7, surely bug fixes are also allowed? >>>> >>>> Of course, allowed. But should they be made, and if so, by who? >>> >>> The people who want the fixes. >> >> Babies want clean diapers. So babies have to change diapers >> themselves? > > Poor analogy. Babies need others to change their diapers for them > because they're not capable of doing it for themselves. Good analogy. Most Python programmers are no more able to write patches for Python than babies are able to change their own nappy. -- Steven From steve at pearwood.info Sun Jul 19 22:36:01 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 20 Jul 2015 12:36:01 +1000 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> <088e076d-90fc-46c4-a440-c1f04fdc747c@googlegroups.com> Message-ID: <55ac5e91$0$1642$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Jul 2015 06:21 am, breamoreboy at gmail.com wrote: > All in all though I have to admit that overall it's a really onerous task. > ?Once you've produced the patch you have to go to all the trouble of > logging on to the issue tracker, finding the appropriate issue and > uploading the patch. ?You may even be inclined to make a comment. ?In this > case this entire process could take as much as two whole minutes. It's very interesting that you ignore the two hardest parts of the process: (1) Producing the patch in the first place. (2) Convincing those with appropriate commit rights to accept the patch. -- Steven From steve at pearwood.info Sun Jul 19 22:49:10 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 20 Jul 2015 12:49:10 +1000 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> Message-ID: <55ac61a6$0$1673$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Jul 2015 08:51 am, Mark Lawrence wrote: > You are now suggesting that people shouldn't even bother reading the > develoment guide, just great. ?Do they have to do anything themselves to > get patches through? ?Presumably the core devs give up their paid work, > holidays, families, other hobbies and the like, just so some bunch of > lazy, bone idle gits can get what they want, for nothing, when it suits > them? Just a reminder that at least some of the core devs, including Guido, are paid to work on Python. And another reminder that open source software doesn't have any restrictions about only distributing software to those who are willing and able to write patches for it. Anyone can use Python, including children and non-programmers. Being able to hack on the interpreter C code and produce quality patches is not a pre-requisite. I know that I've reported bugs in Python that I was unqualified or incapable of fixing, at least without going through months or years of learning. At least one of those bugs has been fixed by others who have the skills. -- Steven From rustompmody at gmail.com Sun Jul 19 22:58:29 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 19 Jul 2015 19:58:29 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> Message-ID: <53490156-efea-4256-836c-0221cbf8c680@googlegroups.com> On Monday, July 20, 2015 at 6:19:58 AM UTC+5:30, Rick Johnson wrote: > But don't worry, his bark is worse than his bite, and he is > just the first of many daemons you must defeat on your quest > to challenge the benevolent Hades. Do you give lessons in rhetoric Rick? From rosuav at gmail.com Sun Jul 19 22:59:32 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 12:59:32 +1000 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> Message-ID: On Mon, Jul 20, 2015 at 12:16 PM, Rustom Mody wrote: > I just ran the following command > $ hg log --template "{author|person}\n" | sort | uniq -c | sort -nr > > as giving all the committers to python in sorted order. > I get the list below. > Dont see any Mark Lawrence there > Of course I dont know hg at all well... Just picked up the above command from > http://stackoverflow.com/questions/6126678/how-to-list-commiters-sorted-by-number-of-commits-commit-count > > So... May I humbly ask where are your precious commits?? Same place that mine aren't. Compare: http://bugs.python.org/issue24610 https://hg.python.org/cpython/rev/02b81a82a57d (It's a trivial docs patch, but that makes for a better demo than the messy PEP 479/issue22906 stuff, where different parts got committed at different times.) I create a patch on my local clone of the CPython repository, and rather than push it directly (which technically I _could_ do, but socially I don't have jurisdiction over the main source code), I create a tracker issue and attach the patch. Then someone else commits it - and it's his name that's on the commit. Same here: http://bugs.python.org/issue24435 https://hg.python.org/cpython/rev/a9c34db88d79 No matter how many patches I write (not that I write very many), I won't show up on your list unless I actually push my own code. Mark isn't a core committer, so you won't see him. A quick search of the tracker came up with this: http://bugs.python.org/issue19980 It's a closed issue with a patch by Mark Lawrence. (There may well be others, I have no idea. All I know is that this one came up in the search.) The author of the resulting commit is Serhiy, not Mark, so that's who you'll be counting in your stats. Sorry to say, the flaw is in your testing methodology. ChrisA From steve at pearwood.info Sun Jul 19 23:05:21 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 20 Jul 2015 13:05:21 +1000 Subject: Should non-security 2.7 bugs be fixed? References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55ac6571$0$1660$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Jul 2015 11:20 am, Devin Jeanpierre wrote: > On Sat, Jul 18, 2015 at 9:45 PM, Steven D'Aprano > wrote: >>> It gets really boring submitting 2.7-specific patches, though, when >>> they aren't accepted, and the committers have such a hostile attitude >>> towards it. I was told by core devs that, instead of fixing bugs in >>> Python 2, I should just rewrite my app in Python 3. >> >> Really? Can you point us to this discussion? > > Yes, really. It was on #python-dev IRC. Ah, pity, because I really would have liked to have seen the context. (I assume there are no archives of #python and #python-dev. At least, I've never found them.) >> If you are right, and that was an official pronouncement, then it seems >> that non-security bug fixes to 2.7 are forbidden. > > I never said it was a pronouncement, or official. It wasn't. I have no > idea where you got that idea from, given that I specifically have said > that I think non-security bug fixes are allowed. You said that core devs told you not to fix bugs in Python 2. Do you really think it's a big stretch to go from "core devs said don't fix Python 2 bugs" to "it's core dev policy to not fix Python 2 bugs"? > Search your logs for https://bugs.python.org/issue17094 and > http://bugs.python.org/issue5315 > > I was most frustrated by the first case -- the patch was (informally) > rejected in favor of the "right" fix, and the "right" fix was > (informally) rejected because it changed behavior, leaving me only > with the option of absurd workarounds of a bug in Python, or moving to > python 3. In the first case, 17094, your comments weren't added until TWO YEARS after the issue was closed. It's quite possible that nobody has even noticed them. In the second case, the issue is still open. So I don't understand your description above: there's no sign that the patch in 17094 was rejected, the patch had bugs and it was fixed and applied to 3.4. It wasn't applied to 2.7 for the reasons explained in the tracker: it could break code that is currently working. For the second issue, it has neither been applied nor rejected. > I don't like how this is being redirected to "surely you > misunderstood" or "I don't believe you". The fact that some core devs > are hostile to 2.x development is really bleedingly obvious, Not to me it isn't. At worst, I would say that some of them are indifferent to 2.7. > you > shouldn't need quotes or context thrown at you. The rhetoric almost > always shies _just_ short of ceasing bugfixes (until 2020, when that > abruptly becomes a cracking good idea). e.g. in "2.7 is here until > 2020, please don't call it a waste". Right. So you take an extended ten year maintenance period for Python 2.7 as evidence that the core devs are *hostile* to maintaining 2.7? That makes no sense to me. If you want to say that *some individuals* who happen to have commit rights are hostile to Python 2.7, I can't really argue with that. Individuals can have all sorts of ideas and opinions. But the core devs as a group are very supportive of Python 2.7, even going to the effort of back-porting performance improvements. -- Steven From ryanshuell at gmail.com Sun Jul 19 23:05:25 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Sun, 19 Jul 2015 20:05:25 -0700 (PDT) Subject: Can't Install Pandas Message-ID: <5ef13508-ad29-4c51-99dc-6ab94c44945e@googlegroups.com> Hello experts. I odwnloaded Pandas, and put it here. C:\Python34\Scripts\pandas-0.16.2 Then, I ran this in what most people call the c-prompt, but I call it the 'Python 3.4.3 Shell' "C:\Python34\Scripts\pandas-0.16.2>" "pip install 'setup.py'" It seems like everything ran fine, so I try this. import pandas as pd Then I get this error. Traceback (most recent call last): File "", line 1, in import pandas as pd ImportError: No module named 'pandas' Any idea what I'm doing wrong? I tried to follow the instructions here. https://pip.pypa.io/en/latest/installing.html That doesn't work either. python get-pip.py SyntaxError: invalid syntax I won't even ask the most obvious question, because I guess it's impossible to do. Rather, can someone please help me to get this working? Thanks. From steve at pearwood.info Sun Jul 19 23:12:02 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 20 Jul 2015 13:12:02 +1000 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> Message-ID: <55ac6703$0$1650$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Jul 2015 11:35 am, Rick Johnson wrote: > I figured that was you *MARK LAWRENCE*. I shall add sock-puppeting > to your many egregious offenses! And poorly executed sock-puppeting > as well! You're a zero. Rick, what the hell are you talking about? Mark is using the same email address as he has always used (unlike a certain person who shall remain unnamed, but used to go by the names RR and Ranting Rick and possibly others). Neglecting to include a sig containing your name at the bottom of your email is not "sock-puppeting". If it were, you would be guilty of it as well: you don't usually sign your posts. A bit of rough-and-tumble on discussion forums like this is one thing, but I think falsely accusing someone of sock-puppeting is going too far. If you aren't man enough to give Mark an apology, at least be man enough to acknowledge that you made a mistake. -- Steven From ryanshuell at gmail.com Sun Jul 19 23:25:14 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Sun, 19 Jul 2015 20:25:14 -0700 (PDT) Subject: Can't Install Pandas In-Reply-To: <5ef13508-ad29-4c51-99dc-6ab94c44945e@googlegroups.com> References: <5ef13508-ad29-4c51-99dc-6ab94c44945e@googlegroups.com> Message-ID: <1226260c-42a6-4e4c-af1e-8c251202cb42@googlegroups.com> On Sunday, July 19, 2015 at 11:05:46 PM UTC-4, ryguy7272 wrote: > Hello experts. I odwnloaded Pandas, and put it here. > C:\Python34\Scripts\pandas-0.16.2 > > Then, I ran this in what most people call the c-prompt, but I call it the 'Python 3.4.3 Shell' > "C:\Python34\Scripts\pandas-0.16.2>" "pip install 'setup.py'" > > It seems like everything ran fine, so I try this. > import pandas as pd > > Then I get this error. > Traceback (most recent call last): > File "", line 1, in > import pandas as pd > ImportError: No module named 'pandas' > > Any idea what I'm doing wrong? > > > I tried to follow the instructions here. > https://pip.pypa.io/en/latest/installing.html > > > That doesn't work either. > python get-pip.py > SyntaxError: invalid syntax > > I won't even ask the most obvious question, because I guess it's impossible to do. Rather, can someone please help me to get this working? > > Thanks. Well, I got everything to install on the cmd window, but I still can't run anything in the Shell. Here's two simple examples. import numpy as np Traceback (most recent call last): File "", line 1, in import numpy as np ImportError: No module named 'numpy' >>> import pandas as pd Traceback (most recent call last): File "", line 1, in import pandas as pd ImportError: No module named 'pandas' According to what I saw in the cmd window, these two things were installed. Nevertheless, they don't run in the Shell. I guess I spend 95% of my time trying to import stuff, and about 5% of my time doing something interesting or useful with Python. From ian.g.kelly at gmail.com Sun Jul 19 23:30:17 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 19 Jul 2015 21:30:17 -0600 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <55ac6703$0$1650$c3e8da3$5496439d@news.astraweb.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> <55ac6703$0$1650$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jul 19, 2015 at 9:12 PM, Steven D'Aprano wrote: > On Mon, 20 Jul 2015 11:35 am, Rick Johnson wrote: > >> I figured that was you *MARK LAWRENCE*. I shall add sock-puppeting >> to your many egregious offenses! And poorly executed sock-puppeting >> as well! You're a zero. > > Rick, what the hell are you talking about? Mark is using the same email > address as he has always used (unlike a certain person who shall remain > unnamed, but used to go by the names RR and Ranting Rick and possibly > others). Not quite; one is @yahoo.co.uk, and the other is @gmail.com. If the great Ranting Rick can't tell that these belong to the same person just based on the local part, then what chance do we mere mortals have? From rosuav at gmail.com Sun Jul 19 23:36:47 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 13:36:47 +1000 Subject: Can't Install Pandas In-Reply-To: <5ef13508-ad29-4c51-99dc-6ab94c44945e@googlegroups.com> References: <5ef13508-ad29-4c51-99dc-6ab94c44945e@googlegroups.com> Message-ID: On Mon, Jul 20, 2015 at 1:05 PM, ryguy7272 wrote: > Hello experts. I odwnloaded Pandas, and put it here. > C:\Python34\Scripts\pandas-0.16.2 > > Then, I ran this in what most people call the c-prompt, but I call it the 'Python 3.4.3 Shell' > "C:\Python34\Scripts\pandas-0.16.2>" "pip install 'setup.py'" > > It seems like everything ran fine Firstly, why would you call it the Python shell? It isn't. Secondly, what gave you the idea that everything ran fine? That is not the command you would use to install something you've already downloaded, nor is it a command that will successfully download and install a package using pip. (Thirdly, what's with the extraneous quotes all over the place?) I suggest you start by learning how to use pip to install packages. If that gives you trouble, *ask for help with pip*, do NOT just say "everything ran fine" and then point out that importing didn't work (which is proof that everything did NOT run fine with the install). If you're going to take a hostile attitude toward Python, *and* waste our time with the way you ask questions, you'll quickly find that people will just delete your posts and move on, which I was just about to do. ChrisA From jeanpierreda at gmail.com Sun Jul 19 23:41:45 2015 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 19 Jul 2015 20:41:45 -0700 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <55ac6571$0$1660$c3e8da3$5496439d@news.astraweb.com> References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <55ac6571$0$1660$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jul 19, 2015 at 8:05 PM, Steven D'Aprano wrote: > On Mon, 20 Jul 2015 11:20 am, Devin Jeanpierre wrote: >> I was most frustrated by the first case -- the patch was (informally) >> rejected in favor of the "right" fix, and the "right" fix was >> (informally) rejected because it changed behavior, leaving me only >> with the option of absurd workarounds of a bug in Python, or moving to >> python 3. > > In the first case, 17094, your comments weren't added until TWO YEARS after > the issue was closed. It's quite possible that nobody has even noticed > them. In the second case, the issue is still open. So I don't understand > your description above: there's no sign that the patch in 17094 was > rejected, the patch had bugs and it was fixed and applied to 3.4. It wasn't > applied to 2.7 for the reasons explained in the tracker: it could break > code that is currently working. > > For the second issue, it has neither been applied nor rejected. I meant search your #python-dev IRC logs, where this was discussed. As far as whether people notice patches after an issue is closed, Terry Reedy answered "yes" earlier in the thread. If the answer is actually "no", then we should fix how bugs are handled post-closure, in case e.g. someone posts a followup patch that fixes a remaining case, and so on. >> you >> shouldn't need quotes or context thrown at you. The rhetoric almost >> always shies _just_ short of ceasing bugfixes (until 2020, when that >> abruptly becomes a cracking good idea). e.g. in "2.7 is here until >> 2020, please don't call it a waste". > > Right. So you take an extended ten year maintenance period for Python 2.7 as > evidence that the core devs are *hostile* to maintaining 2.7? That makes no > sense to me. That isn't what I said at all. > If you want to say that *some individuals* who happen to have commit rights > are hostile to Python 2.7, I can't really argue with that. Individuals can > have all sorts of ideas and opinions. But the core devs as a group are very > supportive of Python 2.7, even going to the effort of back-porting > performance improvements. I do want to say that. It doesn't help that those same individuals are the only core devs I have interacted with while trying to patch 2.7. -- Devin From no.email at nospam.invalid Mon Jul 20 00:07:11 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Sun, 19 Jul 2015 21:07:11 -0700 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> <088e076d-90fc-46c4-a440-c1f04fdc747c@googlegroups.com> <55ac5e91$0$1642$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87oaj7xyj4.fsf@jester.gateway.sonic.net> Steven D'Aprano writes: > It's very interesting that you ignore the two hardest parts of the process: > (1) Producing the patch in the first place. > (2) Convincing those with appropriate commit rights to accept the patch. 2 is often harder than 1. Or consider the case when you report an obvious bug and then have to talk yourself blue in the face to convince others that it really is a bug. From qh.resu01 at gmail.com Mon Jul 20 00:54:44 2015 From: qh.resu01 at gmail.com (Kevin Peterson) Date: Mon, 20 Jul 2015 04:54:44 +0000 Subject: How we can send mail with attachment in Python? Message-ID: Hi, How we can send mail with attachment in Python? Is it any prerequisite for it? Thanks, Kevin Peterson From rosuav at gmail.com Mon Jul 20 01:01:34 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 15:01:34 +1000 Subject: How we can send mail with attachment in Python? In-Reply-To: References: Message-ID: On Mon, Jul 20, 2015 at 2:54 PM, Kevin Peterson wrote: > How we can send mail with attachment in Python? Is it any prerequisite for it? You could use your favourite search engine to look this up. Or you could poke around with the Python standard library and see if anything looks promising: https://docs.python.org/3/library/ Hint: There is something there. ChrisA From torriem at gmail.com Mon Jul 20 01:16:55 2015 From: torriem at gmail.com (Michael Torrie) Date: Sun, 19 Jul 2015 23:16:55 -0600 Subject: Need assistance In-Reply-To: <219b1f31-d34f-4ec2-846c-96ddd7170058@googlegroups.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <99ad55c0-0c1c-4442-9db7-c762f17cde04@googlegroups.com> <219b1f31-d34f-4ec2-846c-96ddd7170058@googlegroups.com> Message-ID: <55AC8447.80906@gmail.com> On 07/19/2015 06:21 PM, Rick Johnson wrote: > On Sunday, July 19, 2015 at 6:07:14 PM UTC-5, craig... at gmail.com wrote: >> def main(): >> name= input('Enter your full name: ') >> split=name.split() >> Full_name=split[2],split[0], split[1] >> print(Full_name[2],',', Full_name[0], Full_name[1]) >> >> main() > > Sorry, but this code is no where near done yet. What happens > when the user enters invalid input? *BANG* Give the guy a break. He's just barely been exposed to Python and he's simply trying to fulfill the assignment's requirements. Nothing more. Judge the professor and course all you want. But for a 100 level course just getting people to get any sort of input is a challenge. Once he's mastered that, then he can learn about input validation. You're probably someone who can't remember ever not knowing how to program. But most people aren't like that. Got to learn a little bit at a time, even if it's dangerous at the very first. It's not like he's going to be expected to hack kernel code for his next assignment. From arthi15smash at gmail.com Mon Jul 20 01:20:28 2015 From: arthi15smash at gmail.com (Arthi Vigneshwari) Date: Mon, 20 Jul 2015 10:50:28 +0530 Subject: New to python Message-ID: Hi, Am interested to learn python!Can you please guide me how to start with python which will help in my selenium automation? Regards, Arthi -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Jul 20 01:25:24 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 20 Jul 2015 15:25:24 +1000 Subject: Need assistance In-Reply-To: <55AC8447.80906@gmail.com> References: <225d4ac6-3b88-4844-805b-b4b00cd62ef4@googlegroups.com> <99ad55c0-0c1c-4442-9db7-c762f17cde04@googlegroups.com> <219b1f31-d34f-4ec2-846c-96ddd7170058@googlegroups.com> <55AC8447.80906@gmail.com> Message-ID: On Mon, Jul 20, 2015 at 3:16 PM, Michael Torrie wrote: > On 07/19/2015 06:21 PM, Rick Johnson wrote: >> On Sunday, July 19, 2015 at 6:07:14 PM UTC-5, craig... at gmail.com wrote: >>> def main(): >>> name= input('Enter your full name: ') >>> split=name.split() >>> Full_name=split[2],split[0], split[1] >>> print(Full_name[2],',', Full_name[0], Full_name[1]) >>> >>> main() >> >> Sorry, but this code is no where near done yet. What happens >> when the user enters invalid input? *BANG* > > Give the guy a break. He's just barely been exposed to Python and he's > simply trying to fulfill the assignment's requirements. Nothing more. > Judge the professor and course all you want. But for a 100 level course > just getting people to get any sort of input is a challenge. Once he's > mastered that, then he can learn about input validation. You're > probably someone who can't remember ever not knowing how to program. > But most people aren't like that. Got to learn a little bit at a time, > even if it's dangerous at the very first. It's not like he's going to be > expected to hack kernel code for his next assignment. Rick's idea of scope creep probably *does* include kernel hacking as part of Arithmetic 101. ChrisA From torriem at gmail.com Mon Jul 20 01:33:28 2015 From: torriem at gmail.com (Michael Torrie) Date: Sun, 19 Jul 2015 23:33:28 -0600 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> Message-ID: <55AC8828.7090703@gmail.com> On 07/19/2015 06:27 PM, Mark Lawrence wrote: > On 20/07/2015 00:23, Cecil Westerhof wrote: >> No use replying anymore. You make a caricature of what I am saying and >> put words in my mouth I never said. Just stay in your cosy ivory >> tower. But please do not pretend that you are open for discussion, >> because you are not. >> > > Thank goodness for that as you make no sense at all. > > As for this ivory tower nonsense, you clearly haven't bothered reading > anything I've said about the proposed improvements to the core workflow. > But then of course you wouldn't bother with that, you again expect > somebody else to do all the work for you, for free, and probably still > complain that the benefits that you're getting aren't enough. Quite > frankly your attitude throughout this thread makes me puke. You'll have to explain yourself a bit, attacking Cecil like this. I've been following this thread and I don't see anything in Cecil's attitude that is sickening. You both have good points, and it's unfortunate you're talking past one another, though it appears more like you are talking past Cecil more than he is talking past you. For the most part, it's been good to hear from Cecil (there have been a few snarky posts) as he has learned python and really run with it. I don't understand where your apparent frustration with Cecil is coming from. Seems like this last post of yours had more than a little attitude of the very type you're decrying. >From what I can tell, Cecil is simply challenging the conventional notion that many have that all software developers using Python are able and willing to participate in backporting and bug fixes to both CPython and the Python 2.7 standard library. You replied that the process for contributing to Python is going to be streamlined, which is good. However, like Cecil, I agree that many devs are still not going to be able to contribute for many reasons, be they time, skills, economics, or something else. That doesn't make them lazy, entitled folk. Certainly if potential contributors jumped on this list and viewed this thread, I think they might be discouraged by your post attacking Cecil. Given the lack of economic incentive, I'm sure most devs understand that Python 2.7 won't receive the same love as Python 3.4. And most probably accept that. We recognize that core devs put in a lot of time and energy for a variety of reasons, some of which are just for the love of the project, and we benefit at little to no cost We thank them for this. From steve+comp.lang.python at pearwood.info Mon Jul 20 01:59:39 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Mon, 20 Jul 2015 15:59:39 +1000 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> <55ac6703$0$1650$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55ac8e4b$0$1639$c3e8da3$5496439d@news.astraweb.com> On Monday 20 July 2015 13:30, Ian Kelly wrote: > On Sun, Jul 19, 2015 at 9:12 PM, Steven D'Aprano > wrote: >> On Mon, 20 Jul 2015 11:35 am, Rick Johnson wrote: >> >>> I figured that was you *MARK LAWRENCE*. I shall add sock-puppeting >>> to your many egregious offenses! And poorly executed sock-puppeting >>> as well! You're a zero. >> >> Rick, what the hell are you talking about? Mark is using the same email >> address as he has always used (unlike a certain person who shall remain >> unnamed, but used to go by the names RR and Ranting Rick and possibly >> others). > > Not quite; one is @yahoo.co.uk, and the other is @gmail.com. Ah, so they are. You're right, I was wrong, they're not the same email address. But still, accusations of sock-puppetry from a change in email provider is unreasonable, and I believe that Rick should acknowledge that he over-reacted. > If the > great Ranting Rick can't tell that these belong to the same person > just based on the local part, then what chance do we mere mortals > have? -- Steve From dieter at handshake.de Mon Jul 20 02:06:32 2015 From: dieter at handshake.de (dieter) Date: Mon, 20 Jul 2015 08:06:32 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> Message-ID: <877fpvs6qf.fsf@handshake.de> Mark Lawrence writes: > On 19/07/2015 17:10, Cecil Westerhof wrote: >> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: > ... >> Babies want clean diapers. So babies have to change diapers >> themselves? >> > > That has to be the worst analogy I've ever read. We are discussing > backporting working patches, *NOT* having to go through the whole > shooting match from scratch. Nevertheless, the task is (usually) far from trivial. Beside the pure functional aspect, you need at least also address testing againt interference with other features, i.e. you need detailed knowledge about Python's test suite and its setup. This obviously is non trivial - as I have seen fixes break other things. If C code is envolved, you need also understand Python's build environment -- another huge requirement of specific knowledge. Especially, because the Python build process must function on many platforms and typical users only use a single one. The first point causes me prefer external packages - where I (not a community) decide about the extent of testing. It is also easy to remove an external package should it really make problems. The second point causes me to prefer working around problems envolving C code rather than fixing it. From dieter at handshake.de Mon Jul 20 02:10:57 2015 From: dieter at handshake.de (dieter) Date: Mon, 20 Jul 2015 08:10:57 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> Message-ID: <87380js6j2.fsf@handshake.de> Ian Kelly writes: > On Sun, Jul 19, 2015 at 10:10 AM, Cecil Westerhof wrote: >> On Sunday 19 Jul 2015 15:42 CEST, Mark Lawrence wrote: >> >>> On 19/07/2015 03:13, Terry Reedy wrote: >>>> On 7/18/2015 7:50 PM, Devin Jeanpierre wrote: >>>>> to 2.7, surely bug fixes are also allowed? >>>> >>>> Of course, allowed. But should they be made, and if so, by who? >>> >>> The people who want the fixes. >> >> Babies want clean diapers. So babies have to change diapers >> themselves? > > Poor analogy. Babies need others to change their diapers for them > because they're not capable of doing it for themselves. I believe Cecil was aware of this and wanted to stress: not everyone who needs a fix is also able to backport a corresponding patch. From tjreedy at udel.edu Mon Jul 20 02:25:25 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 20 Jul 2015 02:25:25 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 7/19/2015 9:20 PM, Devin Jeanpierre wrote: > Search your logs for https://bugs.python.org/issue17094 > http://bugs.python.org/issue5315 > > I was most frustrated by the first case -- > the patch was (informally) rejected By 'the patch', I presume you mean current-frames-cleanup.patch by Stefan Ring, who said it "is certainly not the most complete solution, but it solves my problem.". It was reviewed a month later by a core dev, who said it had two defects. Do you expect us to apply defective patches? > in favor of the "right" fix, "right" is your word. Natali simply uploaded an alternate patch that did not have the defects cited. It went through 4 versions, two by Pitrou, before the commit and close 2 months later, with the comment "Hopefully there aren't any applications relying on the previous behaviour." >and the "right" fix was (informally) rejected because it changed behavior, The bugfix was rejected *for both 2.7 and 3.3* in msg186011. The rejection therefore does not indicate animus against 2.7 versus 3.x. The reason is that it did more than just fix the bug. When this is the case, we only apply to the upcoming release. If we broke working code as a side-effect, as opposed to a direct effect, of a bugfix, many people would be frustrated. See some of the other comments in this thread. Two years later, last May, you proposed and uploaded a patch with what looks to be a new and different approach. It has been ignored. In the absence of a core dev focused on 2.7, I expect that this will continue. Too bad you did not upload it in Feb 2013, before the review and fix started. > and http://bugs.python.org/issue5315 Another fairly obscure issue for most of us. Five years ago, this was turned into a doc issue, but no patch was ever submitted for either 2.x or 3.x. Again, no particular prejudice against 2.x. In May, you posted a bugfix which so far has been ignored. Not too surprising. I submitted a ping and updated the versions. If anyone responds, you might be asked for a patch against 3.4 or 3.5. -- Terry Jan Reedy From dieter at handshake.de Mon Jul 20 02:29:45 2015 From: dieter at handshake.de (dieter) Date: Mon, 20 Jul 2015 08:29:45 +0200 Subject: Should non-security 2.7 bugs be fixed? References: Message-ID: <87y4ibqr3a.fsf@handshake.de> Rick Johnson writes: > On Sunday, July 19, 2015 at 12:54:34 AM UTC-5, dieter wrote: >> From my point of view: if you want help with fixing bugs, >> you must ensure that there is a high probability that >> those contributions really find their way into the main >> development lines. As I understand from other messages in >> this thread, this is also a problem with Python bug >> fixing. > > (Not sure who said this, so my apologies if the attribution > is incorrect) > > Bug fixing is not something most programmers find enjoyable, > at least not for long durations. I prefer to spend my time > solving real world problems, and designing intuitive APIs, > this is what brings me joy. This was me. And I am like you. I do not hunt bugs I find in a bug tracker but only bugs I get hit in real world problems. But once hit, I usually find a solution (or work around) and like to share it with others who might get hit in the future. That's why I take the time to file bug reports (often with patches). But when those bug reports and patches seem to be ignored by the core development team - I look for other means, such as external packages. > Heck, there have been many times that i purposefully re- > invented the wheel simply because solving the problem is > much easier (and more enjoyable) than trying to understand > another programmer's atrocious spaghetti code. Therefor, we > should not be surprised that the bug list is so understaffed > and lacks vigor. In my experience (with other open source projects), I think almost none of my patches was ever taken over without modifications. In my view, the changes were usually of a cosmetic nature. For me, this is fine - as long as the problem gets fixed. > ... > What is becoming apparent to me though, is that most of the > complaints i had voiced (years ago) about the exclusive > attitudes, horrible interface, and the burdensome workflow > of submitting patches is contributing to the lack of > interest in this process -> and it seems i am not alone! > > I can remember twice getting excited about helping out, to > only quickly become frustrated with the politics and > interface. Why should i have to fight just to volunteer? Experience like this (in another project) causes me to be very reluctant to become a core contributor (in the sense of actively fixing things in the core). You need a lot of knowledge (coding conventions, test setup, change workflow, ...) whichs goes far beyond the functionality of the fix -- and you must be resilient, patient and maybe even fighting to get the work accepted. From dieter at handshake.de Mon Jul 20 02:36:49 2015 From: dieter at handshake.de (dieter) Date: Mon, 20 Jul 2015 08:36:49 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> Message-ID: <87twszqqri.fsf@handshake.de> Mark Lawrence writes: > On 19/07/2015 18:14, Cecil Westerhof wrote: >> On Sunday 19 Jul 2015 18:38 CEST, Mark Lawrence wrote: > ... >> You think so? I think that a lot of people who are using 2.7 would >> like to have the fixes. They know how to use Python, but they would >> not now how to implement a patch. That is why I made this comment. >> > > I don't think so, I know. If they want the patches that badly and > can't do it themselves they'll have to grin and bear it, or do a bit > of begging, or pay somebody to do it for them. Well, there might be "budget constraints" and the difficulty to find someone capable of doing a backport. We are doing here some form of "begging". Thus, we are in line with your recommendations ;-) From torriem at gmail.com Mon Jul 20 02:39:39 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 20 Jul 2015 00:39:39 -0600 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <55AC8828.7090703@gmail.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <55AC8828.7090703@gmail.com> Message-ID: <55AC97AB.5030403@gmail.com> On 07/19/2015 11:33 PM, Michael Torrie wrote: > For the most part, > it's been good to hear from Cecil (there have been a few snarky posts) > as he has learned python and really run with it. I don't understand > where your apparent frustration with Cecil is coming from. Come to think of it, I can't think of but one post, maybe, where he was short with someone, but not snarky. I take that back. Which is better than me, and probably others! From dieter at handshake.de Mon Jul 20 02:46:20 2015 From: dieter at handshake.de (dieter) Date: Mon, 20 Jul 2015 08:46:20 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> <088e076d-90fc-46c4-a440-c1f04fdc747c@googlegroups.com> Message-ID: <87pp3nqqbn.fsf@handshake.de> Rick Johnson writes: > On Sunday, July 19, 2015 at 1:44:25 PM UTC-5, bream... at gmail.com wrote: >> No, it's simply that nobody can force volunteers to back >> port something when they're just not interested in doing >> the work, for whatever reason. Hence my statement above, >> of which you have focused on the last eight words. > > Well i argue that the free labor *WOULD* exists *IF* the > patching mechanism were more inclusive and intuitive. Thinking of myself, I am not sure. Ensuring the quality of a "distribution" goes far beyond a single bug fix. While I usually are ready to share a bug fix I have found, I am reluctant to get involved in the complete quality ensurance process (such as the test suite, review process, style guides, ...). This would require far more time than that for analysing and fixing the initial problem. Thus, from my point of view, it calls for a "division of labor" -- where quality ensurance experts do the integration of my patch/backport. From dieter at handshake.de Mon Jul 20 02:58:55 2015 From: dieter at handshake.de (dieter) Date: Mon, 20 Jul 2015 08:58:55 +0200 Subject: Should non-security 2.7 bugs be fixed? References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87lhebqpqo.fsf@handshake.de> Mark Lawrence writes: > ... > So I most humbly suggest, as I may have hinted at once or twice > earlier in this thread, that people either put up or shut up. In another of your contributions to this thread, you spoke of another alternative: "do a bit of begging". That is what some of us are doing. From dieter at handshake.de Mon Jul 20 03:10:05 2015 From: dieter at handshake.de (dieter) Date: Mon, 20 Jul 2015 09:10:05 +0200 Subject: How we can send mail with attachment in Python? References: Message-ID: <87h9ozqp82.fsf@handshake.de> Kevin Peterson writes: > How we can send mail with attachment in Python? Is it any prerequisite for it? You look at the "email" package to build the message and the "smtplib" package to send the message - both are part of Python's runtime library and documented in its documentation. Note that you need access to an "smtp" server (aka "mail server"). It ensures in cooperation with other "smtp" servers the distribution of your email around the world. Access to an "smtp" server is a non-Python issue. From jeanpierreda at gmail.com Mon Jul 20 03:13:09 2015 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Mon, 20 Jul 2015 00:13:09 -0700 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: I think you're missing the line where I said all the relevant conversation happened in IRC, and that you should refer to logs. On Sun, Jul 19, 2015 at 11:25 PM, Terry Reedy wrote: > On 7/19/2015 9:20 PM, Devin Jeanpierre wrote: > >> Search your logs for https://bugs.python.org/issue17094 >> http://bugs.python.org/issue5315 >> >> I was most frustrated by the first case -- > >> the patch was (informally) rejected > > By 'the patch', I presume you mean current-frames-cleanup.patch > by Stefan Ring, who said it "is certainly not the most complete solution, > but it solves my problem.". It was reviewed a month later by a core dev, who > said it had two defects. Do you expect us to apply defective patches? No, I meant my patch. It was discussed in IRC, and I gave the search term to grep for. (The issue URL.) >> in favor of the "right" fix, > > > "right" is your word. Natali simply uploaded an alternate patch that did not > have the defects cited. It went through 4 versions, two by Pitrou, before > the commit and close 2 months later, with the comment "Hopefully there > aren't any applications relying on the previous behaviour." No, "right" is the word used by members of #python-dev, referrig to Antoine's fix. > Two years later, last May, you proposed and uploaded a patch with what looks > to be a new and different approach. It has been ignored. In the absence of > a core dev focused on 2.7, I expect that this will continue. Too bad you did > not upload it in Feb 2013, before the review and fix started. I'm not sure what you're implying here. It couldn't be helped. >> and http://bugs.python.org/issue5315 > > Another fairly obscure issue for most of us. Five years ago, this was turned > into a doc issue, but no patch was ever submitted for either 2.x or 3.x. > Again, no particular prejudice against 2.x. > > In May, you posted a bugfix which so far has been ignored. Not too > surprising. I submitted a ping and updated the versions. If anyone > responds, you might be asked for a patch against 3.4 or 3.5. Again, the prejudice was expressed in IRC. It was ignored because you can just use asyncio in 3.x, and because the bug was old. -- Devin From dpalao.python at gmail.com Mon Jul 20 03:49:56 2015 From: dpalao.python at gmail.com (David Palao) Date: Mon, 20 Jul 2015 09:49:56 +0200 Subject: New to python In-Reply-To: References: Message-ID: 2015-07-20 7:20 GMT+02:00 Arthi Vigneshwari : > Hi, > Am interested to learn python!Can you please guide me how to start with > python which will help in my selenium automation? > > Regards, > Arthi > > -- > https://mail.python.org/mailman/listinfo/python-list > Hi, If you enter "learning python" in a search engine, you'll probably get several interesting resources to start with it. For instance, have you had a look at https://www.python.org/about/gettingstarted/ ? Best regards From arthi15smash at gmail.com Mon Jul 20 04:56:29 2015 From: arthi15smash at gmail.com (Arthi Vigneshwari) Date: Mon, 20 Jul 2015 14:26:29 +0530 Subject: New to python In-Reply-To: References: Message-ID: Hey David, Yeah,I had an overall look at https://www.python.org/about/gettingstarted/! Let me dig deep into the websites you shared me with! Thanks, Arthi On Mon, Jul 20, 2015 at 1:19 PM, David Palao wrote: > 2015-07-20 7:20 GMT+02:00 Arthi Vigneshwari : > > Hi, > > Am interested to learn python!Can you please guide me how to start with > > python which will help in my selenium automation? > > > > Regards, > > Arthi > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > Hi, > If you enter "learning python" in a search engine, you'll probably get > several interesting resources to start with it. > For instance, have you had a look at > https://www.python.org/about/gettingstarted/ > ? > > Best regards > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at zwobble.org Mon Jul 20 05:59:28 2015 From: mike at zwobble.org (Michael Williamson) Date: Mon, 20 Jul 2015 10:59:28 +0100 Subject: Generating type annotations by tracing execution runs Message-ID: <20150720105928.1a84afa8@mwilliamson.workgroup> Hello, I've knocked together a quick proof-of-concept that allows type annotations to be automatically added to Python source code by running it: https://github.com/mwilliamson/farthing As the code, such as a test suite, runs, the types of arguments and return values (for functions in the file/directory to be annotated) are stored. After the code has finished, appropriate annotations are added. (There's a tiny example in the README.rst in case that makes things a little clearer.) At the moment, this is just a small prototype that I've cobbled together. I was curious if anybody knows if anybody else has done anything similar? Thanks Michael From subhabrata.banerji at gmail.com Mon Jul 20 06:13:04 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Mon, 20 Jul 2015 03:13:04 -0700 (PDT) Subject: File Upload in Restful Flask Message-ID: Dear Group, I am trying to learn Rest framework through Restful Flask. My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html Now I want to upload file through Restful Flask. I tried to check the web for reference. I got these urls, (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image (iii) http://blog.luisrei.com/articles/flaskrest.html But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. If any one of the esteemed members may kindly suggest. Regards, Subhabrata Banerjee. From breamoreboy at yahoo.co.uk Mon Jul 20 06:59:43 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 20 Jul 2015 11:59:43 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> Message-ID: On 20/07/2015 03:16, Rustom Mody wrote: > On Monday, July 20, 2015 at 7:16:50 AM UTC+5:30, Mark Lawrence wrote: >> On 20/07/2015 02:20, Devin Jeanpierre wrote: >> >>> >>> I don't like how this is being redirected to "surely you >>> misunderstood" or "I don't believe you". The fact that some core devs >>> are hostile to 2.x development is really bleedingly obvious, you >>> shouldn't need quotes or context thrown at you. The rhetoric almost >>> always shies _just_ short of ceasing bugfixes (until 2020, when that >>> abruptly becomes a cracking good idea). e.g. in "2.7 is here until >>> 2020, please don't call it a waste". >>> >> >> A couple of things. >> >> First "some core devs are hostile", actually some have stated that >> they're simply not interested in 2.7 and will not work on it. >> >> Second how has the thread got here, as it was originally asking about >> back porting bug fixes from 3.x to 2.7? Further it said:- >> >> >> If the vast majority of Python programmers are focused on 2.7, why are >> volunteers to help fix 2.7 bugs so scarce? >> >> >> So I most humbly suggest, as I may have hinted at once or twice earlier >> in this thread, that people either put up or shut up. > > I just ran the following command > $ hg log --template "{author|person}\n" | sort | uniq -c | sort -nr > > as giving all the committers to python in sorted order. > I get the list below. > Dont see any Mark Lawrence there > Of course I dont know hg at all well... Just picked up the above command from > http://stackoverflow.com/questions/6126678/how-to-list-commiters-sorted-by-number-of-commits-commit-count > > So... May I humbly ask where are your precious commits?? > Thank you for showing your complete ignorance as to how Python works. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From square.steve at gmail.com Mon Jul 20 07:09:28 2015 From: square.steve at gmail.com (Simmo) Date: Mon, 20 Jul 2015 12:09:28 +0100 Subject: File Upload in Restful Flask In-Reply-To: References: Message-ID: <55ACD6E8.3030101@bellissimmo.com> On 20/07/2015 11:13, subhabrata.banerji at gmail.com wrote: > Dear Group, > > I am trying to learn Rest framework through Restful Flask. > My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html > > Now I want to upload file through Restful Flask. I tried to check the web for reference. > I got these urls, > (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file > (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image > (iii) http://blog.luisrei.com/articles/flaskrest.html > > But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. > > If any one of the esteemed members may kindly suggest. > > Regards, > Subhabrata Banerjee. > I'm no expert on Python or REST but the example >>> url = 'http://httpbin.org/post' >>> files = {'file': open('report.xls', 'rb')} >>> r = requests.post(url, files=files) >>> r.text ... seems quite straightforward so I would suggest substituting your URL for 'http://httpbin.org' and your file name (possibly with full pathname) for 'report.xls'. Give it a try and report back... Steve S From steve at bellissimmo.com Mon Jul 20 07:09:28 2015 From: steve at bellissimmo.com (Simmo) Date: Mon, 20 Jul 2015 12:09:28 +0100 Subject: File Upload in Restful Flask In-Reply-To: References: Message-ID: <55ACD6E8.3030101@bellissimmo.com> On 20/07/2015 11:13, subhabrata.banerji at gmail.com wrote: > Dear Group, > > I am trying to learn Rest framework through Restful Flask. > My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html > > Now I want to upload file through Restful Flask. I tried to check the web for reference. > I got these urls, > (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file > (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image > (iii) http://blog.luisrei.com/articles/flaskrest.html > > But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. > > If any one of the esteemed members may kindly suggest. > > Regards, > Subhabrata Banerjee. > I'm no expert on Python or REST but the example >>> url = 'http://httpbin.org/post' >>> files = {'file': open('report.xls', 'rb')} >>> r = requests.post(url, files=files) >>> r.text ... seems quite straightforward so I would suggest substituting your URL for 'http://httpbin.org' and your file name (possibly with full pathname) for 'report.xls'. Give it a try and report back... Steve S From martine.carannante at atos.net Mon Jul 20 07:27:59 2015 From: martine.carannante at atos.net (CARANNANTE, MARTINE) Date: Mon, 20 Jul 2015 11:27:59 +0000 Subject: Does the Class UserGroup (issue 11588) exist for python 2.7 ? Message-ID: Hi Could you tell me if the Class UserGroup (method add_usage_group to support inclusive groups) exist for python 2.7 ? The patch that I found on internet is only for python 3. Thanks in advance for your answer Best regards Martine Carannante -------------- next part -------------- An HTML attachment was scrubbed... URL: From subhabrata.banerji at gmail.com Mon Jul 20 07:57:52 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Mon, 20 Jul 2015 04:57:52 -0700 (PDT) Subject: File Upload in Restful Flask In-Reply-To: References: Message-ID: <272103ac-dd95-439f-8e1e-77d36494fc09@googlegroups.com> On Monday, July 20, 2015 at 4:40:09 PM UTC+5:30, Simmo wrote: > On 20/07/2015 11:13, wrote: > > Dear Group, > > > > I am trying to learn Rest framework through Restful Flask. > > My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html > > > > Now I want to upload file through Restful Flask. I tried to check the web for reference. > > I got these urls, > > (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file > > (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image > > (iii) http://blog.luisrei.com/articles/flaskrest.html > > > > But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. > > > > If any one of the esteemed members may kindly suggest. > > > > Regards, > > Subhabrata Banerjee. > > > > I'm no expert on Python or REST but the example > > >>> url = 'http://httpbin.org/post' > >>> files = {'file': open('report.xls', 'rb')} > > >>> r = requests.post(url, files=files) > >>> r.text > ... > > seems quite straightforward so I would suggest substituting your URL for > 'http://httpbin.org' and your file name (possibly with full pathname) > for 'report.xls'. > > Give it a try and report back... > > Steve S Dear Sir, Thanks. I could change the quickstart api.py slightly. I ran your suggestion on it. Some result seems coming but I may have to improve some portion, I am not getting. Please see the same. >>> import requests >>> url='http://127.0.0.1:5000/toworks/post' >>> files = {'file': open('C:\Python27\NEWS.txt', 'rb')} >>> r = requests.post(url, files=files) >>> r.text u'{\n "message": "Method Not Allowed", \n "status": 405\n}\n' >>> Regards, Subhabrata Banerji From breamoreboy at yahoo.co.uk Mon Jul 20 08:15:49 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 20 Jul 2015 13:15:49 +0100 Subject: Does the Class UserGroup (issue 11588) exist for python 2.7 ? In-Reply-To: References: Message-ID: On 20/07/2015 12:27, CARANNANTE, MARTINE wrote: > Hi > Could you tell me if the Class UserGroup (method add_usage_group to > support inclusive groups) exist for python 2.7 ? > The patch that I found on internet is only for python 3. > Thanks in advance for your answer > Best regards > *Martine Carannante > * Almost certainly no as the patch has never been commited, which is why http://bugs.python.org/issue11588 is till open. Even if the patch were committed there is no guarantee that the patch will be back ported to 2.7. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From square.steve at gmail.com Mon Jul 20 09:08:40 2015 From: square.steve at gmail.com (Simmo) Date: Mon, 20 Jul 2015 14:08:40 +0100 Subject: File Upload in Restful Flask In-Reply-To: <272103ac-dd95-439f-8e1e-77d36494fc09@googlegroups.com> References: <272103ac-dd95-439f-8e1e-77d36494fc09@googlegroups.com> Message-ID: <55ACF2D8.8000502@bellissimmo.com> On 20/07/2015 12:57, subhabrata.banerji at gmail.com wrote: > On Monday, July 20, 2015 at 4:40:09 PM UTC+5:30, Simmo wrote: >> On 20/07/2015 11:13, wrote: >>> Dear Group, >>> >>> I am trying to learn Rest framework through Restful Flask. >>> My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html >>> >>> Now I want to upload file through Restful Flask. I tried to check the web for reference. >>> I got these urls, >>> (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file >>> (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image >>> (iii) http://blog.luisrei.com/articles/flaskrest.html >>> >>> But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. >>> >>> If any one of the esteemed members may kindly suggest. >>> >>> Regards, >>> Subhabrata Banerjee. >>> >> >> I'm no expert on Python or REST but the example >> >> >>> url = 'http://httpbin.org/post' >> >>> files = {'file': open('report.xls', 'rb')} >> >> >>> r = requests.post(url, files=files) >> >>> r.text >> ... >> >> seems quite straightforward so I would suggest substituting your URL for >> 'http://httpbin.org' and your file name (possibly with full pathname) >> for 'report.xls'. >> >> Give it a try and report back... >> >> Steve S > > Dear Sir, > > Thanks. I could change the quickstart api.py slightly. I ran your suggestion > on it. Some result seems coming but I may have to improve some portion, I am not getting. Please see the same. > >>>> import requests >>>> url='http://127.0.0.1:5000/toworks/post' >>>> files = {'file': open('C:\Python27\NEWS.txt', 'rb')} >>>> r = requests.post(url, files=files) >>>> r.text > u'{\n "message": "Method Not Allowed", \n "status": 405\n}\n' >>>> > > Regards, > Subhabrata Banerji > OK, so that message is telling you that whatever server is sitting behind 127.0.0.1 is not allowing you (your code) to POST to it. There are many reasons why this could be happening. Here are a couple for you to investigate... - port 5000 is not not 'open' for POSTs - your code may not have permission to POST to the server It would help if you could tell us what OS you are using (Windows or Linux or ...) and what server is sitting behind 127.0.0.1. I'n not going to be around for the next 24hrs but I'm sure someone else on the list will have some suggestions for you... Happy bug hunting Steve From steve at bellissimmo.com Mon Jul 20 09:08:40 2015 From: steve at bellissimmo.com (Simmo) Date: Mon, 20 Jul 2015 14:08:40 +0100 Subject: File Upload in Restful Flask In-Reply-To: <272103ac-dd95-439f-8e1e-77d36494fc09@googlegroups.com> References: <272103ac-dd95-439f-8e1e-77d36494fc09@googlegroups.com> Message-ID: <55ACF2D8.8000502@bellissimmo.com> On 20/07/2015 12:57, subhabrata.banerji at gmail.com wrote: > On Monday, July 20, 2015 at 4:40:09 PM UTC+5:30, Simmo wrote: >> On 20/07/2015 11:13, wrote: >>> Dear Group, >>> >>> I am trying to learn Rest framework through Restful Flask. >>> My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html >>> >>> Now I want to upload file through Restful Flask. I tried to check the web for reference. >>> I got these urls, >>> (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file >>> (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image >>> (iii) http://blog.luisrei.com/articles/flaskrest.html >>> >>> But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. >>> >>> If any one of the esteemed members may kindly suggest. >>> >>> Regards, >>> Subhabrata Banerjee. >>> >> >> I'm no expert on Python or REST but the example >> >> >>> url = 'http://httpbin.org/post' >> >>> files = {'file': open('report.xls', 'rb')} >> >> >>> r = requests.post(url, files=files) >> >>> r.text >> ... >> >> seems quite straightforward so I would suggest substituting your URL for >> 'http://httpbin.org' and your file name (possibly with full pathname) >> for 'report.xls'. >> >> Give it a try and report back... >> >> Steve S > > Dear Sir, > > Thanks. I could change the quickstart api.py slightly. I ran your suggestion > on it. Some result seems coming but I may have to improve some portion, I am not getting. Please see the same. > >>>> import requests >>>> url='http://127.0.0.1:5000/toworks/post' >>>> files = {'file': open('C:\Python27\NEWS.txt', 'rb')} >>>> r = requests.post(url, files=files) >>>> r.text > u'{\n "message": "Method Not Allowed", \n "status": 405\n}\n' >>>> > > Regards, > Subhabrata Banerji > OK, so that message is telling you that whatever server is sitting behind 127.0.0.1 is not allowing you (your code) to POST to it. There are many reasons why this could be happening. Here are a couple for you to investigate... - port 5000 is not not 'open' for POSTs - your code may not have permission to POST to the server It would help if you could tell us what OS you are using (Windows or Linux or ...) and what server is sitting behind 127.0.0.1. I'n not going to be around for the next 24hrs but I'm sure someone else on the list will have some suggestions for you... Happy bug hunting Steve From peter.heitzer at rz.uni-regensburg.de Mon Jul 20 09:10:10 2015 From: peter.heitzer at rz.uni-regensburg.de (Peter Heitzer) Date: 20 Jul 2015 13:10:10 GMT Subject: Fast 12 bit to 16 bit sample conversion? Message-ID: I am currently writing a python script to extract samples from old Roland 12 bit sample disks and save them as 16 bit wav files. The samples are layouted as follows 0 [S0 bit 11..4] [S0 bit 3..0|S1 bit 3..0] [S1 bit 11..4] 3 [S2 bit 11..4] [S2 bit 3..0|S3 bit 3..0] [S3 bit 11..4] In other words sample0=(data[0]<<4)|(data[1]>>4) sample1=(data[2]<<4)|(data[1] & 0x0f) I use this code for the conversion (using the struct module) import struct from array import array def getWaveData(diskBuffer): offset=0 words=array('H') for i in range(len(diskBuffer)/3): h0=struct.unpack_from('>h',diskBuffer,offset) h1=struct.unpack_from('hxhxhxhx' for 4 even samples and ' References: <272103ac-dd95-439f-8e1e-77d36494fc09@googlegroups.com> Message-ID: <582a8fb9-77c6-4173-aa9e-f4e9c24885f2@googlegroups.com> On Monday, July 20, 2015 at 6:39:29 PM UTC+5:30, Simmo wrote: > On 20/07/2015 12:57, wrote: > > On Monday, July 20, 2015 at 4:40:09 PM UTC+5:30, Simmo wrote: > >> On 20/07/2015 11:13, wrote: > >>> Dear Group, > >>> > >>> I am trying to learn Rest framework through Restful Flask. > >>> My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html > >>> > >>> Now I want to upload file through Restful Flask. I tried to check the web for reference. > >>> I got these urls, > >>> (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file > >>> (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image > >>> (iii) http://blog.luisrei.com/articles/flaskrest.html > >>> > >>> But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example. > >>> > >>> If any one of the esteemed members may kindly suggest. > >>> > >>> Regards, > >>> Subhabrata Banerjee. > >>> > >> > >> I'm no expert on Python or REST but the example > >> > >> >>> url = 'http://httpbin.org/post' > >> >>> files = {'file': open('report.xls', 'rb')} > >> > >> >>> r = requests.post(url, files=files) > >> >>> r.text > >> ... > >> > >> seems quite straightforward so I would suggest substituting your URL for > >> 'http://httpbin.org' and your file name (possibly with full pathname) > >> for 'report.xls'. > >> > >> Give it a try and report back... > >> > >> Steve S > > > > Dear Sir, > > > > Thanks. I could change the quickstart api.py slightly. I ran your suggestion > > on it. Some result seems coming but I may have to improve some portion, I am not getting. Please see the same. > > > >>>> import requests > >>>> url='http://127.0.0.1:5000/toworks/post' > >>>> files = {'file': open('C:\Python27\NEWS.txt', 'rb')} > >>>> r = requests.post(url, files=files) > >>>> r.text > > u'{\n "message": "Method Not Allowed", \n "status": 405\n}\n' > >>>> > > > > Regards, > > Subhabrata Banerji > > > > OK, so that message is telling you that whatever server is sitting > behind 127.0.0.1 is not allowing you (your code) to POST to it. There > are many reasons why this could be happening. Here are a couple for you > to investigate... > > - port 5000 is not not 'open' for POSTs > - your code may not have permission to POST to the server > > It would help if you could tell us what OS you are using (Windows or > Linux or ...) and what server is sitting behind 127.0.0.1. > > I'n not going to be around for the next 24hrs but I'm sure someone else > on the list will have some suggestions for you... > > Happy bug hunting > > Steve Dear Sir, Thanks. I am on MS-Windows 7 and I use mostly Firefox. I am checking other issues. Regards, Subhabrata Banerjee. From python at mrabarnett.plus.com Mon Jul 20 10:43:16 2015 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 20 Jul 2015 15:43:16 +0100 Subject: Fast 12 bit to 16 bit sample conversion? In-Reply-To: References: Message-ID: <55AD0904.8030904@mrabarnett.plus.com> On 2015-07-20 14:10, Peter Heitzer wrote: > I am currently writing a python script to extract samples from old Roland 12 bit sample > disks and save them as 16 bit wav files. > > The samples are layouted as follows > > 0 [S0 bit 11..4] [S0 bit 3..0|S1 bit 3..0] [S1 bit 11..4] > 3 [S2 bit 11..4] [S2 bit 3..0|S3 bit 3..0] [S3 bit 11..4] > > In other words > sample0=(data[0]<<4)|(data[1]>>4) > sample1=(data[2]<<4)|(data[1] & 0x0f) > > I use this code for the conversion (using the struct module) > > import struct > from array import array > > def getWaveData(diskBuffer): > offset=0 > words=array('H') > for i in range(len(diskBuffer)/3): If the 2 12-bit values are [0xABC, 0xDEF], the bytes will be [0xAB, 0xCF, 0xDE]. > h0=struct.unpack_from('>h',diskBuffer,offset) This gives 0xABCF, which is ANDed to give 0xABC0. Good. > h1=struct.unpack_from(' words.append(h0[0] & 0xfff0) > words.append(h1[0] & 0xfff0) > offset+=3 > return words > > I unpack the samples in an array of unsigned shorts for I later can use the byteswap() method > if the code is running on a big endian machine. > > What options using pure python do I have to make the conversion faster? > I thought of unpacking more bytes at once e.g. using a format '>hxhxhxhx' for 4 even samples > and ' Can I map the '& 0xfff0' to the whole array? > That's something the numpy could do. From edmondo.giovannozzi at gmail.com Mon Jul 20 11:14:51 2015 From: edmondo.giovannozzi at gmail.com (edmondo.giovannozzi at gmail.com) Date: Mon, 20 Jul 2015 08:14:51 -0700 (PDT) Subject: Fast 12 bit to 16 bit sample conversion? In-Reply-To: References: Message-ID: Il giorno luned? 20 luglio 2015 15:10:22 UTC+2, Peter Heitzer ha scritto: > I am currently writing a python script to extract samples from old Roland 12 bit sample > disks and save them as 16 bit wav files. > > The samples are layouted as follows > > 0 [S0 bit 11..4] [S0 bit 3..0|S1 bit 3..0] [S1 bit 11..4] > 3 [S2 bit 11..4] [S2 bit 3..0|S3 bit 3..0] [S3 bit 11..4] > > In other words > sample0=(data[0]<<4)|(data[1]>>4) > sample1=(data[2]<<4)|(data[1] & 0x0f) > > I use this code for the conversion (using the struct module) > > import struct > from array import array > > def getWaveData(diskBuffer): > offset=0 > words=array('H') > for i in range(len(diskBuffer)/3): > h0=struct.unpack_from('>h',diskBuffer,offset) > h1=struct.unpack_from(' words.append(h0[0] & 0xfff0) > words.append(h1[0] & 0xfff0) > offset+=3 > return words > > I unpack the samples in an array of unsigned shorts for I later can use the byteswap() method > if the code is running on a big endian machine. > > What options using pure python do I have to make the conversion faster? > I thought of unpacking more bytes at once e.g. using a format '>hxhxhxhx' for 4 even samples > and ' Can I map the '& 0xfff0' to the whole array? I'll try to read the binary data with numpy.fromfile, reshape the array in [n,3] matrix, and then you can operate with the columns to get what you want. :-) From peter.heitzer at rz.uni-regensburg.de Mon Jul 20 11:23:21 2015 From: peter.heitzer at rz.uni-regensburg.de (Peter Heitzer) Date: 20 Jul 2015 15:23:21 GMT Subject: Fast 12 bit to 16 bit sample conversion? References: Message-ID: MRAB wrote: >On 2015-07-20 14:10, Peter Heitzer wrote: >> I am currently writing a python script to extract samples from old Roland 12 bit sample >> disks and save them as 16 bit wav files. >> >> The samples are layouted as follows >> >> 0 [S0 bit 11..4] [S0 bit 3..0|S1 bit 3..0] [S1 bit 11..4] >> 3 [S2 bit 11..4] [S2 bit 3..0|S3 bit 3..0] [S3 bit 11..4] >> >> In other words >> sample0=(data[0]<<4)|(data[1]>>4) >> sample1=(data[2]<<4)|(data[1] & 0x0f) >> >> I use this code for the conversion (using the struct module) >> >> import struct >> from array import array >> >> def getWaveData(diskBuffer): >> offset=0 >> words=array('H') >> for i in range(len(diskBuffer)/3): >If the 2 12-bit values are [0xABC, 0xDEF], the bytes will be [0xAB, >0xCF, 0xDE]. >> h0=struct.unpack_from('>h',diskBuffer,offset) >This gives 0xABCF, which is ANDed to give 0xABC0. Good. >> h1=struct.unpack_from('This gives 0xDECF, which is ANDed to give 0xDEC0. Not what you want. You are right! It looked to me as if it was little endian, but only for the MSB. From sohcahtoa82 at gmail.com Mon Jul 20 12:40:41 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Mon, 20 Jul 2015 09:40:41 -0700 (PDT) Subject: how to play In-Reply-To: References: Message-ID: On Sunday, July 19, 2015 at 12:04:26 PM UTC-7, Aron Barsam wrote: > i have trouble trying to play python please can you respond soon? ... > play python http://i.imgur.com/x2KwTbw.jpg From rosuav at gmail.com Mon Jul 20 13:15:08 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 03:15:08 +1000 Subject: Does the Class UserGroup (issue 11588) exist for python 2.7 ? In-Reply-To: References: Message-ID: On Mon, Jul 20, 2015 at 10:15 PM, Mark Lawrence wrote: > On 20/07/2015 12:27, CARANNANTE, MARTINE wrote: >> >> Hi >> Could you tell me if the Class UserGroup (method add_usage_group to >> support inclusive groups) exist for python 2.7 ? >> The patch that I found on internet is only for python 3. >> Thanks in advance for your answer >> Best regards >> *Martine Carannante >> * > > > Almost certainly no as the patch has never been commited, which is why > http://bugs.python.org/issue11588 is till open. Even if the patch were > committed there is no guarantee that the patch will be back ported to 2.7. There's almost a guarantee that it will NOT be backported to 2.7, actually; it looks like a completely new feature. But if you're interested, you might be able to apply the patch to a backported argparse, such as: https://pypi.python.org/pypi/argparse Or just patch your own local version, but that's a bit dodgier. If you're willing to migrate your code to Python 3, and you want this feature, post in the tracker issue; even better, help with testing the patch. The patch was updated for Python 3.5 roughly a year ago, and I suspect that that version will still work; the lack of response after that suggests that nobody has the time to test it and make sure it works in all cases. Since argparse is written in Python, you don't even need to play around with a C compiler to test this. It's a nice easy thing to play with - have a shot! ChrisA From rosuav at gmail.com Mon Jul 20 13:18:01 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 03:18:01 +1000 Subject: Generating type annotations by tracing execution runs In-Reply-To: <20150720105928.1a84afa8@mwilliamson.workgroup> References: <20150720105928.1a84afa8@mwilliamson.workgroup> Message-ID: On Mon, Jul 20, 2015 at 7:59 PM, Michael Williamson wrote: > I've knocked together a quick proof-of-concept that allows type > annotations to be automatically added to Python source code by running > it: > > https://github.com/mwilliamson/farthing > > As the code, such as a test suite, runs, the types of arguments and > return values (for functions in the file/directory to be annotated) are > stored. After the code has finished, appropriate annotations are added. > (There's a tiny example in the README.rst in case that makes things a > little clearer.) Sounds to me like a type inference system. Can be pretty handy in some codebases. ChrisA From no.email at nospam.invalid Mon Jul 20 13:34:02 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Mon, 20 Jul 2015 10:34:02 -0700 Subject: Generating type annotations by tracing execution runs References: <20150720105928.1a84afa8@mwilliamson.workgroup> Message-ID: <87a8uqybqt.fsf@jester.gateway.sonic.net> Chris Angelico writes: >> As the code, such as a test suite, runs, the types of arguments and >> return values... > Sounds to me like a type inference system. Can be pretty handy in some > codebases. I haven't tried it out yet but it sounds more like the type extraction part of a JIT compiler, i.e. the types are collected from actual execution traces rather than statically. I think of "type inference" as meaning syntactic inference at compile time. From ian.g.kelly at gmail.com Mon Jul 20 13:48:05 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 20 Jul 2015 11:48:05 -0600 Subject: how to play In-Reply-To: References: Message-ID: On Mon, Jul 20, 2015 at 10:29 AM, Aron Barsam wrote: > what is an 0S comand line? What OS are you using? In Windows it's a program called Command Prompt. In Mac OS X it's an application called Terminal. In Linux it's usually called something like Terminal or xterm. However, if you don't know how to use the CLI (command-line interface), then you're probably better off using IDLE, a development environment that is included with the Python installation and includes an interactive interpreter. Just look for the IDLE program and run that. From jhihn at gmx.com Mon Jul 20 14:02:51 2015 From: jhihn at gmx.com (Jason H) Date: Mon, 20 Jul 2015 20:02:51 +0200 Subject: linux os.rename() not an actual rename? Message-ID: I have a server process that looks (watches via inotify) for files to be moved (renamed) into a particular directory from elsewhere on the same filesystem. We do this because it is an atomic operation, and our server process can see the modify events of the file being written before it is closed. The rename functions as a 'completed' event. We have a python script that attempts to perform this behavior - to os.rename() a file into the watched directory after it is done being written. However unlike other tools, we don't see a proper 'rename' event. Instead we just see a 'changed' event. I've changed the implementation of the script to os.system('mv ...') and we get the expected 'rename' event. Is this known issue? Should I be seeing a proper rename event? The only mention in the docs about the rename behavior is that it is atomic, as required by POSIX. From jon+usenet at unequivocal.co.uk Mon Jul 20 14:43:00 2015 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Mon, 20 Jul 2015 18:43:00 +0000 (UTC) Subject: linux os.rename() not an actual rename? References: Message-ID: On 2015-07-20, Jason H wrote: > I have a server process that looks (watches via inotify) for files > to be moved (renamed) into a particular directory from elsewhere on > the same filesystem. We do this because it is an atomic operation, > and our server process can see the modify events of the file being > written before it is closed. The rename functions as a 'completed' > event. We have a python script that attempts to perform this > behavior - to os.rename() a file into the watched directory after it > is done being written. However unlike other tools, we don't see a > proper 'rename' event. Instead we just see a 'changed' event. I've > changed the implementation of the script to os.system('mv ...') and > we get the expected 'rename' event. > > Is this known issue? Should I be seeing a proper rename event? The > only mention in the docs about the rename behavior is that it is > atomic, as required by POSIX. os.rename() should just be calling the operating system rename(2) function. I think you must be doing something wrong. From marko at pacujo.net Mon Jul 20 14:50:37 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 20 Jul 2015 21:50:37 +0300 Subject: linux os.rename() not an actual rename? References: Message-ID: <87d1zm64ua.fsf@elektro.pacujo.net> "Jason H" : > I have a server process that looks (watches via inotify) for files to > be moved (renamed) into a particular directory from elsewhere on the > same filesystem. We do this because it is an atomic operation, and our > server process can see the modify events of the file being written > before it is closed. The rename functions as a 'completed' event. We > have a python script that attempts to perform this behavior - to > os.rename() a file into the watched directory after it is done being > written. However unlike other tools, we don't see a proper 'rename' > event. Instead we just see a 'changed' event. I've changed the > implementation of the script to os.system('mv ...') and we get the > expected 'rename' event. Don't know about inotify(). However, strace reveals that python3's os.rename() performs a regular rename(2) system call. Marko From christian at python.org Mon Jul 20 14:58:24 2015 From: christian at python.org (Christian Heimes) Date: Mon, 20 Jul 2015 20:58:24 +0200 Subject: linux os.rename() not an actual rename? In-Reply-To: <87d1zm64ua.fsf@elektro.pacujo.net> References: <87d1zm64ua.fsf@elektro.pacujo.net> Message-ID: On 2015-07-20 20:50, Marko Rauhamaa wrote: > "Jason H" : > >> I have a server process that looks (watches via inotify) for files to >> be moved (renamed) into a particular directory from elsewhere on the >> same filesystem. We do this because it is an atomic operation, and our >> server process can see the modify events of the file being written >> before it is closed. The rename functions as a 'completed' event. We >> have a python script that attempts to perform this behavior - to >> os.rename() a file into the watched directory after it is done being >> written. However unlike other tools, we don't see a proper 'rename' >> event. Instead we just see a 'changed' event. I've changed the >> implementation of the script to os.system('mv ...') and we get the >> expected 'rename' event. > > Don't know about inotify(). However, strace reveals that python3's > os.rename() performs a regular rename(2) system call. So does Python 2.7: $ touch test $ strace -e trace=file -- python -c 'import os; os.rename("test", "test2")' execve("/bin/python", ["python", "-c", "import os; os.rename(\"test\", \"te"...], [/* 76 vars */]) = 0 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 ... rename("test", "test2") = 0 +++ exited with 0 +++ From jhihn at gmx.com Mon Jul 20 15:40:51 2015 From: jhihn at gmx.com (Jason H) Date: Mon, 20 Jul 2015 21:40:51 +0200 Subject: linux os.rename() not an actual rename? In-Reply-To: References: <87d1zm64ua.fsf@elektro.pacujo.net>, Message-ID: > From: "Christian Heimes" > On 2015-07-20 20:50, Marko Rauhamaa wrote: > > "Jason H" : > > > >> I have a server process that looks (watches via inotify) for files to > >> be moved (renamed) into a particular directory from elsewhere on the > >> same filesystem. We do this because it is an atomic operation, and our > >> server process can see the modify events of the file being written > >> before it is closed. The rename functions as a 'completed' event. We > >> have a python script that attempts to perform this behavior - to > >> os.rename() a file into the watched directory after it is done being > >> written. However unlike other tools, we don't see a proper 'rename' > >> event. Instead we just see a 'changed' event. I've changed the > >> implementation of the script to os.system('mv ...') and we get the > >> expected 'rename' event. > > > > Don't know about inotify(). However, strace reveals that python3's > > os.rename() performs a regular rename(2) system call. > > So does Python 2.7: > > $ touch test > $ strace -e trace=file -- python -c 'import os; os.rename("test", "test2")' > execve("/bin/python", ["python", "-c", "import os; os.rename(\"test\", > \"te"...], [/* 76 vars */]) = 0 > access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) > open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 > ... > rename("test", "test2") = 0 > +++ exited with 0 +++ Hrm, provably, you're right. But I was seeing 'rename', then two 'changed' events on the dest name, but the last thing the process did was rename before it exited. I'll look into it some more now that I know python should be using the OS implementation of rename. Thanks everyone. From breamoreboy at yahoo.co.uk Mon Jul 20 19:39:36 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 21 Jul 2015 00:39:36 +0100 Subject: Procedure for downloading and Installing Python 2.7 Modules In-Reply-To: <55AC2152.3090005@gmail.com> References: <55AC2152.3090005@gmail.com> Message-ID: On 19/07/2015 23:14, W. D. Allen wrote: > Would like to locate and install numpy, scipy and matplotlib > with Wing 101 for Python 2.7 > > Just beginning to use Python 2.7 for engineering work. > > Any guidance would be appreciated. > > Thanks, > > WDA > ballensr at gmail.com > > end > Just use pip from the command line for your OS. It might even be that:- pip install scipy grabs everything that you've asked for above, why not try it and see? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From steve at pearwood.info Mon Jul 20 22:17:03 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Tue, 21 Jul 2015 12:17:03 +1000 Subject: Procedure for downloading and Installing Python 2.7 Modules References: Message-ID: <55adab9f$0$1636$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Jul 2015 08:14 am, W. D. Allen wrote: > Would like to locate and install numpy, scipy and matplotlib > with Wing 101 for Python 2.7 Wing is an IDE, that is, a fancy editor. As far as I know, you shouldn't have to take any special steps to get numpy etc. working with Wing, you just install them in the usual fashion. Do you need help with installing Python packages? If you have pip installed, you can just type: pip install numpy scipy matplotlib from your *operating system* command prompt. Not the Python shell! On Linux, you would open a terminal and you should see a prompt that ends with a $ sign. On Windows, you run cmd.exe or command.com or whatever it is called, I forget. If you see a prompt >>> then you're in the Python shell and pip won't work. However, installing numpy and scipy from scratch like this is often difficult on Windows, as you need access to a Fortran or C compiler. Many people prefer to use a Python environment that has numpy etc. already pre-installed. Start here: https://courses.p2pu.org/he/groups/scientific-python/content/setting-up-a-scientific-python-environment/ Does this help? Feel free to reply to the group with any follow up questions. -- Steven From breamoreboy at yahoo.co.uk Mon Jul 20 22:45:56 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 21 Jul 2015 03:45:56 +0100 Subject: Fast 12 bit to 16 bit sample conversion? In-Reply-To: References: Message-ID: On 20/07/2015 14:10, Peter Heitzer wrote: > I am currently writing a python script to extract samples from old Roland 12 bit sample > disks and save them as 16 bit wav files. > > The samples are layouted as follows > > 0 [S0 bit 11..4] [S0 bit 3..0|S1 bit 3..0] [S1 bit 11..4] > 3 [S2 bit 11..4] [S2 bit 3..0|S3 bit 3..0] [S3 bit 11..4] > > In other words > sample0=(data[0]<<4)|(data[1]>>4) > sample1=(data[2]<<4)|(data[1] & 0x0f) > > I use this code for the conversion (using the struct module) > > import struct > from array import array > > def getWaveData(diskBuffer): > offset=0 > words=array('H') > for i in range(len(diskBuffer)/3): > h0=struct.unpack_from('>h',diskBuffer,offset) > h1=struct.unpack_from(' words.append(h0[0] & 0xfff0) > words.append(h1[0] & 0xfff0) > offset+=3 > return words > > I unpack the samples in an array of unsigned shorts for I later can use the byteswap() method > if the code is running on a big endian machine. > > What options using pure python do I have to make the conversion faster? By "pure python" I'm assuming you mean part of the stdlib. Referring to https://wiki.python.org/moin/PythonSpeed/PerformanceTips you could end with something like this (untested). def getWaveData(diskBuffer): offset = 0 words = array('H') wx = words.extend #saves two lookups and a function call su = struct.unpack_from #saves two lookups # 'i' not used in the loop so throw it away for _ in range(len(diskBuffer)/3): # use xrange on Python 2 h0 = su('>h',diskBuffer,offset) h1 = su(' I thought of unpacking more bytes at once e.g. using a format '>hxhxhxhx' for 4 even samples > and ' Can I map the '& 0xfff0' to the whole array? If it works :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From ryanshuell at gmail.com Mon Jul 20 22:49:56 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Mon, 20 Jul 2015 19:49:56 -0700 (PDT) Subject: Can I copy/paste Python code? Message-ID: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> I'm trying to copy some Python code from a PDF book that I'm reading. I want to test out the code, and I can copy it, but when I paste it into the Shell, everything is all screwed up because of the indentation. Every time I paste in any kind of code, it seems like everything is immediately left-justified, and then nothing works. Any idea how to make this work easily? Without re-typing hundreds of lines of code... Thanks to all. From ryanshuell at gmail.com Mon Jul 20 22:51:02 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Mon, 20 Jul 2015 19:51:02 -0700 (PDT) Subject: Can't Install Pandas In-Reply-To: <5ef13508-ad29-4c51-99dc-6ab94c44945e@googlegroups.com> References: <5ef13508-ad29-4c51-99dc-6ab94c44945e@googlegroups.com> Message-ID: <12a01cc0-ac0a-4b75-bce3-767ed81b623b@googlegroups.com> On Sunday, July 19, 2015 at 11:05:46 PM UTC-4, ryguy7272 wrote: > Hello experts. I odwnloaded Pandas, and put it here. > C:\Python34\Scripts\pandas-0.16.2 > > Then, I ran this in what most people call the c-prompt, but I call it the 'Python 3.4.3 Shell' > "C:\Python34\Scripts\pandas-0.16.2>" "pip install 'setup.py'" > > It seems like everything ran fine, so I try this. > import pandas as pd > > Then I get this error. > Traceback (most recent call last): > File "", line 1, in > import pandas as pd > ImportError: No module named 'pandas' > > Any idea what I'm doing wrong? > > > I tried to follow the instructions here. > https://pip.pypa.io/en/latest/installing.html > > > That doesn't work either. > python get-pip.py > SyntaxError: invalid syntax > > I won't even ask the most obvious question, because I guess it's impossible to do. Rather, can someone please help me to get this working? > > Thanks. Ok. Back to the basics. Thanks. From rosuav at gmail.com Mon Jul 20 22:55:09 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 12:55:09 +1000 Subject: Can I copy/paste Python code? In-Reply-To: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 12:49 PM, ryguy7272 wrote: > I'm trying to copy some Python code from a PDF book that I'm reading. I want to test out the code, and I can copy it, but when I paste it into the Shell, everything is all screwed up because of the indentation. Every time I paste in any kind of code, it seems like everything is immediately left-justified, and then nothing works. > > Any idea how to make this work easily? Without re-typing hundreds of lines of code... Sounds like a flaw in the PDF - it creates indentation in some way other than leading spaces/tabs. See if the PDF has a corresponding file of ready-to-go code, that might save you some trouble. ChrisA From rosuav at gmail.com Mon Jul 20 22:56:47 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 12:56:47 +1000 Subject: Can't Install Pandas In-Reply-To: <12a01cc0-ac0a-4b75-bce3-767ed81b623b@googlegroups.com> References: <5ef13508-ad29-4c51-99dc-6ab94c44945e@googlegroups.com> <12a01cc0-ac0a-4b75-bce3-767ed81b623b@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 12:51 PM, ryguy7272 wrote: > On Sunday, July 19, 2015 at 11:05:46 PM UTC-4, ryguy7272 wrote: >> Hello experts. I odwnloaded Pandas, and put it here. >> C:\Python34\Scripts\pandas-0.16.2 >> >> Then, I ran this in what most people call the c-prompt, but I call it the 'Python 3.4.3 Shell' >> "C:\Python34\Scripts\pandas-0.16.2>" "pip install 'setup.py'" >> >> It seems like everything ran fine, so I try this. >> import pandas as pd >> >> Then I get this error. >> Traceback (most recent call last): >> File "", line 1, in >> import pandas as pd >> ImportError: No module named 'pandas' >> >> Any idea what I'm doing wrong? >> >> >> I tried to follow the instructions here. >> https://pip.pypa.io/en/latest/installing.html >> >> >> That doesn't work either. >> python get-pip.py >> SyntaxError: invalid syntax >> >> I won't even ask the most obvious question, because I guess it's impossible to do. Rather, can someone please help me to get this working? >> >> Thanks. > > Ok. Back to the basics. > Thanks. If by "basics" you mean this, then yes. http://www.catb.org/esr/faqs/smart-questions.html ChrisA From ryanshuell at gmail.com Mon Jul 20 22:57:36 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Mon, 20 Jul 2015 19:57:36 -0700 (PDT) Subject: Is there a way to install ALL Python packages? Message-ID: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. I know R offers this as an option. I figure Python must allow it too. Any idea how to grab everything? Thanks all. From rantingrickjohnson at gmail.com Mon Jul 20 23:04:17 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 20 Jul 2015 20:04:17 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> Message-ID: <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> On Sunday, July 19, 2015 at 9:17:11 PM UTC-5, Rustom Mody wrote: > List of python committers: > ------------------------- > 11081 Guido van Rossum > [snip: long list] Thanks for posting this list of names. I had put in a pyFOIA request for this data a few years ago, but to my surprise, was flat out denied. I'm not sure how exhaustive this list may be, but publicly displaying the "commit hierarchy" within the Python community is very import for those who may want to get involved. [Talking to Mark Lawrence, Rustom said:] > So... May I humbly ask where are your precious commits?? Thanks for putting Mark in his place. He has been brow beating folks on this list (myself included) for years, and i'll bet he now feels as tiny as D'Aprano did -- when GvR scolded him for disrespecting a Noob on Python-ideas. Yeah, i was watching! I'M *ALWAYS* WATCHING! ?_? Now that Mark's lack of "commit cred" has been exposed, we can safely ignore his hollow and hypocritical bullying. And now that he has been de-fanged, he will be forced to seek employment elsewhere. Hmm, my suggestion is that he market himself as an on-call "peanut butter removal service". A venture that will no doubt be successful, seeing that he has two "heads up" on his competition! From rustompmody at gmail.com Mon Jul 20 23:15:42 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Mon, 20 Jul 2015 20:15:42 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> Message-ID: On Tuesday, July 21, 2015 at 8:34:30 AM UTC+5:30, Rick Johnson wrote: > On Sunday, July 19, 2015 at 9:17:11 PM UTC-5, Rustom Mody wrote: > > > > List of python committers: > > ------------------------- > > 11081 Guido van Rossum > > [snip: long list] > > Thanks for posting this list of names. I had put in a pyFOIA > request for this data a few years ago, but to my surprise, was > flat out denied. I'm not sure how exhaustive this list may be, > but publicly displaying the "commit hierarchy" within the Python > community is very import for those who may want to get involved. > > [Talking to Mark Lawrence, Rustom said:] > > So... May I humbly ask where are your precious commits?? > > Thanks for putting Mark in his place. He has been brow > beating folks on this list (myself included) for years, and > i'll bet he now feels as tiny as D'Aprano did -- when GvR > scolded him for disrespecting a Noob on Python-ideas. > > Yeah, i was watching! > > I'M *ALWAYS* WATCHING! > > ?_? > > Now that Mark's lack of "commit cred" has been exposed, we can > safely ignore his hollow and hypocritical bullying. And now > that he has been de-fanged, he will be forced to seek employment > elsewhere. Hmm, my suggestion is that he market himself as an > on-call "peanut butter removal service". A venture that will > no doubt be successful, seeing that he has two "heads up" on > his competition! Hey Rick! Lets have a useful discussion And cut the rhetoric Please [Chris already showed that this list is inaccurate -- probably related to hg not having sighoff distinct from commit like git] From rosuav at gmail.com Mon Jul 20 23:17:01 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 13:17:01 +1000 Subject: Is there a way to install ALL Python packages? In-Reply-To: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 12:57 PM, ryguy7272 wrote: > I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. > > I know R offers this as an option. I figure Python must allow it too. > > Any idea how to grab everything? > pip install `wget https://pypi.python.org/simple/ -qO- |html2text` Then figure out if there are any conflicts. And make sure you stay up-to-date as packages get new versions released. Good luck. ChrisA From rustompmody at gmail.com Mon Jul 20 23:24:39 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Mon, 20 Jul 2015 20:24:39 -0700 (PDT) Subject: Is there a way to install ALL Python packages? In-Reply-To: References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: <70f52ebb-5c00-41d2-880c-b14745db973a@googlegroups.com> On Tuesday, July 21, 2015 at 8:47:29 AM UTC+5:30, Chris Angelico wrote: > On Tue, Jul 21, 2015 at 12:57 PM, ryguy7272 wrote: > > I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. > > > > I know R offers this as an option. I figure Python must allow it too. > > > > Any idea how to grab everything? > > > > pip install `wget https://pypi.python.org/simple/ -qO- |html2text` > > Then figure out if there are any conflicts. > > And make sure you stay up-to-date as packages get new versions released. > > Good luck. > > ChrisA Dear Sir, This is to inform you we have just received your application which is being duly considered. Office of Bofh From rustompmody at gmail.com Mon Jul 20 23:30:48 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Mon, 20 Jul 2015 20:30:48 -0700 (PDT) Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> On Sunday, July 19, 2015 at 10:15:37 AM UTC+5:30, Steven D'Aprano wrote: > > JFTR: My kids (um... students) have just managed to add devanagari > > numerals to python. > > ie we can now do > > > >>>> ? + ? > > 3 > > That is actually quite awesome, and I would support a new feature that set > the numeric characters to a particular script, e.g. Latin, Arabic, > Devanagari, whatever, and printed them in that same script. It seems > unfortunate that ? + ? prints as 3 rather than ?. BTW my boys have just mailed me their latest: >>> ?.?? 9.99 Can some unicode/Chinese literate person inform me whether that ideograph is equivalent to roman '9' or roman 'nine'? From rosuav at gmail.com Mon Jul 20 23:33:48 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 13:33:48 +1000 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 1:15 PM, Rustom Mody wrote: > [Chris already showed that this list is inaccurate -- probably related > to hg not having sighoff distinct from commit like git] It's also the manner of workflow. If you want to accept patches and have them acknowledged to their original authors, the patches need to carry metadata identifying the authors. I went to the tracker and hit "Random Issue" and got one with an attached file as the first hit: http://bugs.python.org/issue12982 http://bugs.python.org/file26008/issue12982.diff Repeated the exercise and won again: http://bugs.python.org/issue4733 http://bugs.python.org/file12437/urlopen_text.diff Notice how the patch files start straight in with content. There's no authorship information retained. By comparison, a patch created with 'git format-patch' and applied with 'git am' starts with RFC 822 headers, provides a commit message, and generally is intended as a way of transmitting a *commit*, rather than simply some changes. I'm not overly familiar with Mercurial workflows, but I think 'hg export' and 'hg import' give the same sort of information; I tried on CPython and got this: # HG changeset patch # User Robert Collins # Date 1436838700 -43200 # Tue Jul 14 13:51:40 2015 +1200 # Branch 3.5 # Node ID 7021d46c490e8d9d3422737c69980dc1602f90db # Parent 0127b0cad5ecb83c39ce58a4be27bf6d43a78d91 Issue #23661: unittest.mock side_effects can now be exceptions again. This was a regression vs Python 3.4. Patch from Ignacio Rossi diff -r 0127b0cad5ec -r 7021d46c490e Lib/unittest/mock.py --- a/Lib/unittest/mock.py Sat Jul 11 16:33:39 2015 -0700 +++ b/Lib/unittest/mock.py Tue Jul 14 13:51:40 2015 +1200 @@ -506,7 +506,8 @@ if delegated is None: (chomp actual details) Whether it's possible to have authorship retained or not, though, a lot of patches can logically be credited to multiple people. Whose name goes on it? With the CPython workflow, it's always the core committer who applied it, nobody else. (That's consistent, at least.) So the names in the log are of the people who have write access to the repo, and nobody else. ChrisA From rosuav at gmail.com Mon Jul 20 23:37:11 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 13:37:11 +1000 Subject: Is there a way to install ALL Python packages? In-Reply-To: <70f52ebb-5c00-41d2-880c-b14745db973a@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> <70f52ebb-5c00-41d2-880c-b14745db973a@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 1:24 PM, Rustom Mody wrote: > Dear Sir, > > This is to inform you we have just received your application which is being duly considered. > > Office of Bofh Thank you for your consideration. I shall endeavour to provide satisfaction, unless you reject my application, in which case I shall publish what I know about you, the boss's secretary, and the low-light camera placed in the boardroom prior to the Christmas break-up party. ChrisA From torriem at gmail.com Mon Jul 20 23:39:51 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 20 Jul 2015 21:39:51 -0600 Subject: Is there a way to install ALL Python packages? In-Reply-To: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: <55ADBF07.5010703@gmail.com> On 07/20/2015 08:57 PM, ryguy7272 wrote: > I'd like to install ALL Python packages on my machine. Even if it > takes up 4-5GB, or more, I'd like to get everything, and then use it > when I need it. Now, I'd like to import packages, like numpy and > pandas, but nothing will install. I figure, if I can just install > everything, I can simply use it when I need it, and if I don't need > it, then I just won't use it. > > I know R offers this as an option. I figure Python must allow it > too. > > Any idea how to grab everything? Since I'm sure there are conflicts between some packages as well as completely broken packages, I suspect this isn't really possible or desirable. And it won't solve your problem. If you can't get numpy and pandas to install, you may have troubles with "everything" also. Are you sure you followed the instructions on the page you linked to in your pandas install thread? Seems like you typed "python get-pip.py" in a python prompt instead of your operating system command prompt. I recall telling you about this before. You download the get-pip.py file, put it somewhere, like on your desktop, then open the command prompt window, cd to that directory, and then run "python get-pip.py" from your cmd.exe C: prompt. From scoria.799 at gmail.com Mon Jul 20 23:41:05 2015 From: scoria.799 at gmail.com (Parul Mogra) Date: Mon, 20 Jul 2015 20:41:05 -0700 Subject: Can I copy/paste Python code? In-Reply-To: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: Hi, You could probably get the work done via the following script: https://pypi.python.org/pypi/PythonTidy/ On Mon, Jul 20, 2015 at 7:49 PM, ryguy7272 wrote: > I'm trying to copy some Python code from a PDF book that I'm reading. I > want to test out the code, and I can copy it, but when I paste it into the > Shell, everything is all screwed up because of the indentation. Every time > I paste in any kind of code, it seems like everything is immediately > left-justified, and then nothing works. > > Any idea how to make this work easily? Without re-typing hundreds of > lines of code... > > Thanks to all. > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Jul 20 23:43:35 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 13:43:35 +1000 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 1:30 PM, Rustom Mody wrote: > BTW my boys have just mailed me their latest: > >>>> ?.?? > > 9.99 > > Can some unicode/Chinese literate person inform me whether > that ideograph is equivalent to roman '9' or roman 'nine'? I'm not Chinese-literate, but I know how to dig up info from the Unicode side of things. '\u4e5d' CJK UNIFIED IDEOGRAPH-4E5D Thanks, very helpful. Perhaps slightly more useful: https://en.wiktionary.org/wiki/%E4%B9%9D But it still doesn't disambiguate digit vs word. Playing around with Google Translate suggests that it functions mostly like a digit; ?? means "Ninety-nine" and ?? means "Ninety-eight". But I'll leave further confirmation to someone who fits your second description. ChrisA From rantingrickjohnson at gmail.com Mon Jul 20 23:58:20 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 20 Jul 2015 20:58:20 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <55ac8e4b$0$1639$c3e8da3$5496439d@news.astraweb.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> <55ac6703$0$1650$c3e8da3$5496439d@news.astraweb.com> <55ac8e4b$0$1639$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2cc541bf-9ccb-42dc-a7c8-f2718226b305@googlegroups.com> On Monday, July 20, 2015 at 12:59:53 AM UTC-5, Steven D'Aprano wrote: > > Not quite; one is @yahoo.co.uk, and the other is @gmail.com. > > Ah, so they are. You're right, I was wrong, they're not > the same email address. But still, accusations of sock- > puppetry from a change in email provider is unreasonable, > and I believe that Rick should acknowledge that he over- > reacted. I'm not sure if i misinterpreted the puppetry, or not. I thought Mark was hiding behind the "bream" account, but i'm not so sure now. Weird things were happening yesterday with my quotes (i even mentioned the strangeness in one of my replies, check the archives). But even if i am wrong, the worse thing i did was mis- interpret his and another post. But since he still owes me an apology for insulting my integrity, i'd say we're even. Funny thing is, no one called for Mark to apologize... GO FIGURE! I guess pets get preferential treatment. From rantingrickjohnson at gmail.com Tue Jul 21 00:09:23 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 20 Jul 2015 21:09:23 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: <3a6dccbf-4518-4fae-8dc9-e27cfd73cd00@googlegroups.com> On Monday, July 20, 2015 at 1:30:03 AM UTC-5, dieter wrote: > Experience like this (in another project) causes me to be > very reluctant to become a core contributor (in the sense > of actively fixing things in the core). You need a lot of > knowledge (coding conventions, test setup, change > workflow, ...) whichs goes far beyond the functionality of > the fix -- and you must be resilient, patient and maybe > even fighting to get the work accepted. Thanks for sharing your experiences. I hope many more will come forward and do the same. We are obviously ignoring some talented people out there, and as i stressed before, we need to prevent further hemorrhaging of this talent. I know there are tons of folks who will get involved if we can remove the onerous barriers. From tjreedy at udel.edu Tue Jul 21 00:40:01 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 21 Jul 2015 00:40:01 -0400 Subject: Is there a way to install ALL Python packages? In-Reply-To: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: On 7/20/2015 10:57 PM, ryguy7272 wrote: > I'd like to install ALL Python packages on my machine. There is no official list of Python packages to upload all of. > Even if it takes up 4-5GB, or more, I'd like to get everything, There are 10000 packages on Pypi, and perhaps an equal number elsewhere. > and then use it when I need it. Many are just names or junk that you would never use and do not want on your machine. Many are specialized add-ons to another package. It seems that Python is different from R. pip can load a list of packages. This is used daily to build machines with Python + a specified list. It would be an interesting project for someone to make, publish, and update a 'sumo' list of the most useful packages that can all be loaded together. -- Terry Jan Reedy From tjreedy at udel.edu Tue Jul 21 00:45:11 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 21 Jul 2015 00:45:11 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> Message-ID: On 7/20/2015 11:33 PM, Chris Angelico wrote: > It's also the manner of workflow. If you want to accept patches and > have them acknowledged to their original authors, the patches need to > carry metadata identifying the authors. Notice how the patch files start straight in with content. There's no > authorship information retained. > > By comparison, a patch created with 'git format-patch' and applied > with 'git am' starts with RFC 822 headers, provides a commit message, > and generally is intended as a way of transmitting a *commit*, rather > than simply some changes. I'm not overly familiar with Mercurial > workflows, but I think 'hg export' and 'hg import' give the same sort > of information; I tried on CPython and got this: hg has an option to produce git-format patches. However, they do not work with the Rietveld code review tool, and so are discouraged. I do not know if the extra information would survive an hg commit. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Tue Jul 21 01:00:23 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 20 Jul 2015 22:00:23 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> <088e076d-90fc-46c4-a440-c1f04fdc747c@googlegroups.com> Message-ID: <3300157a-f080-453a-aaa7-f1f5f21f4154@googlegroups.com> On Monday, July 20, 2015 at 1:47:00 AM UTC-5, dieter wrote: > Thinking of myself, I am not sure. Ensuring the quality of > a "distribution" goes far beyond a single bug fix. While I > usually are ready to share a bug fix I have found, I am > reluctant to get involved in the complete quality > ensurance process (such as the test suite, review process, > style guides, ...). Of course. I believe there are many folks out there like yourself, who come across this or that bug, but don't bother sharing the patch because of the reluctance to deal with red tape or fear of a brow beating. Participation, on a regular basis, requires a special kind of person with special talents. For example: Terry Reedy has been working over at "pybugs" for years. I don't think everyone wants to be, or can be, a Terry Reedy. But i do believe the current system is presenting obstacles to those that could offer help in whatever limited capacity they can handle. OUTLINE OF FOUR POSSIBLE LEVELS OF PARTICIPATION: LEVEL1: Anyone, no matter what coding skills they have, can bring attention to a problem, and allow someone else to write the code. "HEY, I FOUND A PROBLEM -> BLAH, BLAH, BLAH". Also, not all programmers are experts with the written word. And a poorly described problem can result in it never getting the attention is deserves. We not only need coders, we need writer who can peruse the complaints and reformat them for comprehension and coherency. We need a diversity of talent, and not just "code monkey talent", all forms! LEVEL2: Even someone with "sketchy knowledge" of the fix can write up an outline, or a list of steps that could be taken, in order to fix the problem. Possibly pointing out some of the subtle bugs that may crop up if not carefully considered. Very few of us know *everything* about every module or dark corner of Python. For example, I've talked with a few "grand masters", who had little or no knowledge of Tkinter or IDLE. LEVEL3: The next level would be to write draft code. Maybe the code would not even be considered "professional". But it could serve as a "rough draft" that a more experienced programmer can build from. LEVEL4 The last level is a fully functioning patch. This would be written, or approved by, one of the trustees. And even if the "contributor" can only participate at level1 or level2, if they find the process is smooth, then they are more likely to participate again. And as they become more experienced, will offer help at a higher level of expertise. I know the wheel is being re-invented all the time, simply because of the obstacles inherent in the patching process. There needs to exist a linear path from bug to patch. We don't want Terry Reedy wasting his expertise on the first two or three levels, no, we need to place him at a level where his talents are not wasted reading ridiculous feature requests that will never go beyond level1 or level2. My point is, we're unproductive because: (1) we're scaring away intermediate and specialized talents (2) and we're mis- applying the limited talent we do have. From tjreedy at udel.edu Tue Jul 21 01:14:48 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 21 Jul 2015 01:14:48 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: On 7/19/2015 6:19 PM, Terry Reedy wrote: > I, and others, have already made some changes to eliminate differences > that are unnecessary, at least for 2.7 versus 3.3+ or now 3.4+. I just got smacked in the face by a difference I had not run into before. I added about 10 lines to a test file is a section that is identical in 2.7 and 3.4+. One line is self.assertEqual(type(obj), intended class) It failed in 2.7. Quiz: when is the type of an instance not the class that the instance is an instance of. (I expect Steven A. is raising his hand now.) Give up? Answer: When you write a class in 2.x without making it a subclass of object. >>> class Class(): pass >>> inst = Class() >>> type(inst) is Class False >>> type(inst) Since I do not remember how to fix the assert, and was not prepared to make the class, in a file other than the one tested, new-style, I just commented it out. This is an example of my claim that backports are best written by someone who is a current 2.x user with the particular 2.x knowledge needed. I am not sure I ever had all the knowledge needed to handle the backport properly and I now I would prefer to forget about old-style classes. -- Terry Jan Reedy From rustompmody at gmail.com Tue Jul 21 02:11:00 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Mon, 20 Jul 2015 23:11:00 -0700 (PDT) Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> Message-ID: <8bb8f312-5b24-41fd-891e-80de14279c6e@googlegroups.com> On Tuesday, July 21, 2015 at 9:13:49 AM UTC+5:30, Chris Angelico wrote: > On Tue, Jul 21, 2015 at 1:30 PM, Rustom Mody wrote: > > BTW my boys have just mailed me their latest: > > > >>>> ?.?? > > > > 9.99 > > > > Can some unicode/Chinese literate person inform me whether > > that ideograph is equivalent to roman '9' or roman 'nine'? > > I'm not Chinese-literate, but I know how to dig up info from the > Unicode side of things. > > '\u4e5d' CJK UNIFIED IDEOGRAPH-4E5D > > Thanks, very helpful. > > Perhaps slightly more useful: > > https://en.wiktionary.org/wiki/%E4%B9%9D > > But it still doesn't disambiguate digit vs word. > > Playing around with Google Translate suggests that it functions mostly > like a digit; ?? means "Ninety-nine" and ?? means "Ninety-eight". But > I'll leave further confirmation to someone who fits your second > description. > > ChrisA Well Cant make much sense of it: >>> import unicodedata as ud >>> ud.numeric('?') 2.0 >>> ud.category('?') 'Nd' >>> ud.numeric('?') 9.0 >>> ud.category('?') 'Lo' >>> From lac at openend.se Tue Jul 21 03:57:03 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 21 Jul 2015 09:57:03 +0200 Subject: Is there a way to install ALL Python packages? In-Reply-To: Message from Terry Reedy of "Tue, 21 Jul 2015 00:40:01 -0400." References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: <201507210757.t6L7v3Pk015250@fido.openend.se> >pip can load a list of packages. This is used daily to build machines >with Python + a specified list. It would be an interesting project for >someone to make, publish, and update a 'sumo' list of the most useful >packages that can all be loaded together. > >-- >Terry Jan Reedy For a list of the 360 most dowloaded packages from PyPi look here: http://pythonwheels.com/ Laura From lac at openend.se Tue Jul 21 04:10:26 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 21 Jul 2015 10:10:26 +0200 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: Message from Rustom Mody of "Mon, 20 Jul 2015 20:30:48 -0700." <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com><76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> Message-ID: <201507210810.t6L8AQb0015648@fido.openend.se> In a message of Mon, 20 Jul 2015 20:30:48 -0700, Rustom Mody writes: >BTW my boys have just mailed me their latest: > >>>> ?.?? > >9.99 > >Can some unicode/Chinese literate person inform me whether >that ideograph is equivalent to roman '9' or roman 'nine'? Ah, I don't understand you. What do you mean roman 'nine'? a phonetic way of saying things? What bankers use to help prevent forgeries? Something else? ? is a numberal. The numberal 9. For absolutely certain. But since I don't know what you mean by 'nine' it may mean that, as well. ? is not restricted to any particular dialect of Chinese -- if you speak any chinese you will know what this means. On the other hand the pinyan (phonetic) way to pronounce numbers can vary between dialects. Chinese has *many* ways of writing numbers, at least 4 I know about. See: https://en.wikipedia.org/wiki/Chinese_numerals Laura From lac at openend.se Tue Jul 21 04:24:19 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 21 Jul 2015 10:24:19 +0200 Subject: Can I copy/paste Python code? In-Reply-To: Message from ryguy7272 of "Mon, 20 Jul 2015 19:49:56 -0700." <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: <201507210824.t6L8OJDE015995@fido.openend.se> In a message of Mon, 20 Jul 2015 19:49:56 -0700, ryguy7272 writes: >I'm trying to copy some Python code from a PDF book that I'm reading. I want to test out the code, and I can copy it, but when I paste it into the Shell, everything is all screwed up because of the indentation. Every time I paste in any kind of code, it seems like everything is immediately left-justified, and then nothing works. > >Any idea how to make this work easily? Without re-typing hundreds of lines of code... > >Thanks to all. >-- >https://mail.python.org/mailman/listinfo/python-list What I do is run my pdf file through pdftotext https://en.wikipedia.org/wiki/Pdftotext and get a text version of the file. If the file is large, sometimes I just save the code I want to convert as separate pdf files and then convert them. Then I paste from the result, not the pdf. You want to give the -layout and -nopgbrk options to pdftotext. It's not perfect, but saves a lot of work. Make sure your pdf is writing your python code in a fixed width font before you try this, or it will be hopeless. If your python code is being displayed in the book in a variable width font, you will first have to hack your pdf to stop doing this, and then run it through the tool. Write back if you need more help. Laura From steve+comp.lang.python at pearwood.info Tue Jul 21 04:33:47 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Tue, 21 Jul 2015 18:33:47 +1000 Subject: Should non-security 2.7 bugs be fixed? References: <87y4icxh4r.fsf@Equus.decebal.nl> <87egk3ykui.fsf@Equus.decebal.nl> <87a8uryf2e.fsf@Equus.decebal.nl> <87zj2rwx3g.fsf@Equus.decebal.nl> <0abc1500-0e0b-44b3-b078-63aa51eaf5b5@googlegroups.com> <55ac6703$0$1650$c3e8da3$5496439d@news.astraweb.com> <55ac8e4b$0$1639$c3e8da3$5496439d@news.astraweb.com> <2cc541bf-9ccb-42dc-a7c8-f2718226b305@googlegroups.com> Message-ID: <55ae03eb$0$1587$c3e8da3$5496439d@news.astraweb.com> On Tuesday 21 July 2015 13:58, Rick Johnson wrote: > But even if i am wrong, the worse thing i did was mis- > interpret his and another post. But since he still owes me > an apology for insulting my integrity, Someone insulted your integrity? Poor integrity, I hope it wasn't too upset. > i'd say we're even. > Funny thing is, no one called for Mark to apologize... GO > FIGURE! I guess pets get preferential treatment. Perhaps nobody else read Mark's post. Perhaps they didn't think he insulted your integrity. Perhaps they thought you don't have any integrity to be insulted. Perhaps they thought you deserved it. Perhaps they wrote a post critical of Mark but suffered a fatal heart attack just before they could hit send. Anything is possible. I guess we'll just never know. -- Steve From peter.heitzer at rz.uni-regensburg.de Tue Jul 21 04:40:28 2015 From: peter.heitzer at rz.uni-regensburg.de (Peter Heitzer) Date: 21 Jul 2015 08:40:28 GMT Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: ryguy7272 wrote: >I'm trying to copy some Python code from a PDF book that I'm reading. I want to test out the code, and I can copy it, but when I paste it into the Shell, everything is all screwed up because of the indentation. Every time I paste in any kind of code, it seems like everything is immediately left-justified, and then nothing works. >Any idea how to make this work easily? Without re-typing hundreds of lines of code... try cat >testfile , paste in and type ^D or use a graphical text editor to paste the code in. From steve+comp.lang.python at pearwood.info Tue Jul 21 04:57:11 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Tue, 21 Jul 2015 18:57:11 +1000 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> Message-ID: <55ae0968$0$1647$c3e8da3$5496439d@news.astraweb.com> On Tuesday 21 July 2015 13:30, Rustom Mody wrote: > BTW my boys have just mailed me their latest: > >>>> ?.?? > > 9.99 > > Can some unicode/Chinese literate person inform me whether > that ideograph is equivalent to roman '9' or roman 'nine'? > I don't speak or read Chinese, so I could be completely wrong, but my understanding is that Chinese does not distinguish between the numeral 9 and the word 'nine', they are both spelled the same, ?. I think that the distinction you are looking for doesn't really exist in Chinese. However, 90 would not be written as nine-zero, ??, but as nine-ten ??. Ninety-one, I believe, would be written as nine-ten-nine: ???. Decimal numbers, however, copy the European usage: 91.1 = ??.?. See also: https://en.wiktionary.org/wiki/%E4%B9%9D https://en.wikipedia.org/wiki/Chinese_numerals -- Steve From marko at pacujo.net Tue Jul 21 05:10:58 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 21 Jul 2015 12:10:58 +0300 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> Message-ID: <87twsxj2ot.fsf@elektro.pacujo.net> Laura Creighton : > In a message of Mon, 20 Jul 2015 20:30:48 -0700, Rustom Mody writes: > >>Can some unicode/Chinese literate person inform me whether that >>ideograph is equivalent to roman '9' or roman 'nine'? > > Ah, I don't understand you. What do you mean roman 'nine'? a phonetic > way of saying things? What bankers use to help prevent forgeries? > Something else? This is getting deep. It is an embarrassing metamathematical fact that numbers cannot be defined. At least, mathematicians gave up trying a century ago. In mathematics, the essence of counting a set and finding a result n, is that it establishes a one to one correspondence (or bijection) of the set with the set of numbers {1, 2, ..., n}. Our ancestors defined the fingers (or digits) as "the set of numbers." Modern mathematicians have managed to enhance the definition quantitatively but not qualitatively. Marko From rosuav at gmail.com Tue Jul 21 05:18:33 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 21 Jul 2015 19:18:33 +1000 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <87twsxj2ot.fsf@elektro.pacujo.net> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 21, 2015 at 7:10 PM, Marko Rauhamaa wrote: > This is getting deep. It is an embarrassing metamathematical fact that > numbers cannot be defined. At least, mathematicians gave up trying a > century ago. > > In mathematics, the essence of counting a set and finding a result n, > is that it establishes a one to one correspondence (or bijection) of > the set with the set of numbers {1, 2, ..., n}. > AIUI, zero is defined as the cardinality of the empty set, one is defined as the cardinality of the set containing the empty set, two is defined as the cardinality of the set containing the empty set and the set containing the set containing the empty set... which makes mathematics the only language *more verbose* than the Shakespeare Programming Language in its definition of fundamental constants. ChrisA From marko at pacujo.net Tue Jul 21 06:13:38 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 21 Jul 2015 13:13:38 +0300 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> Message-ID: <87oaj5izsd.fsf@elektro.pacujo.net> Chris Angelico : > On Tue, Jul 21, 2015 at 7:10 PM, Marko Rauhamaa wrote: >> This is getting deep. It is an embarrassing metamathematical fact >> that numbers cannot be defined. At least, mathematicians gave up >> trying a century ago. >> >> In mathematics, the essence of counting a set and finding a result >> n, is that it establishes a one to one correspondence (or >> bijection) of the set with the set of numbers {1, 2, ..., n}. >> > > AIUI, zero is defined as the cardinality of the empty set, one is > defined as the cardinality of the set containing the empty set, two is > defined as the cardinality of the set containing the empty set and the > set containing the set containing the empty set... which makes > mathematics the only language *more verbose* than the Shakespeare > Programming Language in its definition of fundamental constants. There are two approaches to cardinality ? one which compares sets directly using bijections and injections, and another which uses cardinal numbers. The first approach is comparative, the second approach is quantitative. You must be referring to the latter meaning (cardinality ~ cardinal number). However: In mathematics, cardinal numbers, or cardinals for short, are a generalization of the natural numbers [...] IOW, cardinal numbers assume natural numbers as a given. Thus, your definition of natural numbers leads to a circular definition. Frege et al tried to do the natural thing and defined natural numbers as equivalence classes: 0 = the set of sets with no elements 1 = the set of sets with a single element 2 = the set of sets with precisely two elements etc Unfortunately, the natural thing leads to a contradiction and must be abandoned. Nowadays, mathematicians are content with working with one prototypical chain of beads: 0 = ? 1 = { 0 } 2 = { 0, 1 } 3 = { 0, 1, 2 } etc IOW: 0 = ? ?(n) = n ? { n } and forget about the true essence of numbers. Marko From breamoreboy at yahoo.co.uk Tue Jul 21 06:34:32 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 21 Jul 2015 11:34:32 +0100 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] In-Reply-To: <87twsxj2ot.fsf@elektro.pacujo.net> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> Message-ID: On 21/07/2015 10:10, Marko Rauhamaa wrote: > Laura Creighton : > >> In a message of Mon, 20 Jul 2015 20:30:48 -0700, Rustom Mody writes: >> >>> Can some unicode/Chinese literate person inform me whether that >>> ideograph is equivalent to roman '9' or roman 'nine'? >> >> Ah, I don't understand you. What do you mean roman 'nine'? a phonetic >> way of saying things? What bankers use to help prevent forgeries? >> Something else? > > This is getting deep. It is an embarrassing metamathematical fact that > numbers cannot be defined. At least, mathematicians gave up trying a > century ago. > > In mathematics, the essence of counting a set and finding a result n, > is that it establishes a one to one correspondence (or bijection) of > the set with the set of numbers {1, 2, ..., n}. > > > Our ancestors defined the fingers (or digits) as "the set of numbers." > Modern mathematicians have managed to enhance the definition > quantitatively but not qualitatively. > Not all of them http://www.languagesandnumbers.com/how-to-count-in-paici/en/pri/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From steve+comp.lang.python at pearwood.info Tue Jul 21 06:39:44 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Tue, 21 Jul 2015 20:39:44 +1000 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> Message-ID: <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> On Tuesday 21 July 2015 19:10, Marko Rauhamaa wrote: > This is getting deep. When things get too deep, stop digging. > It is an embarrassing metamathematical fact that > numbers cannot be defined. At least, mathematicians gave up trying a > century ago. That's not the case. It's not so much that they stopped trying (implying failure), but that they succeeded, for some definition of success (see below). The contemporary standard approach is from Zermelo-Fraenkel set theory: define 0 as the empty set, and the successor to n as the union of n and the set containing n: 0 = {} (the empty set) n + 1 = n ? {n} https://en.wikipedia.org/wiki/Set-theoretic_definition_of_natural_numbers > Our ancestors defined the fingers (or digits) as "the set of numbers." > Modern mathematicians have managed to enhance the definition > quantitatively but not qualitatively. So what? This is not a problem for the use of numbers in science, engineering or mathematics (including computer science, which may be considered a branch of all three). There may be still a few holdouts who hope that G?del is wrong and Russell's dream of being able to define all of mathematics in terms of logic can be resurrected, but everyone else has moved on, and don't consider it to be "an embarrassment" any more than it is an embarrassment that all of philosophy collapses in a heap when faced with solipsism. We have no reason to expect that the natural numbers are anything less than "absolutely fundamental and irreducible" (as the Wikipedia article above puts it). It's remarkable that we can reduce all of mathematics to essentially a single axiom: the concept of the set. -- Steve From marko at pacujo.net Tue Jul 21 06:54:05 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 21 Jul 2015 13:54:05 +0300 Subject: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87h9oxixwy.fsf@elektro.pacujo.net> Steven D'Aprano : > That's not the case. It's not so much that they stopped trying (implying > failure), but that they succeeded, for some definition of success (see > below). > > The contemporary standard approach is from Zermelo-Fraenkel set theory: > define 0 as the empty set, and the successor to n as the union of n and the > set containing n: > > 0 = {} (the empty set) > n + 1 = n ? {n} That definition barely captures the essence of what a number *is*. In fact, there have been different formulations of natural numbers. For example: 0 = {} 1 = {0} 2 = {1} 3 = {2} etc Marko From pavel at ivanov.io Tue Jul 21 06:57:08 2015 From: pavel at ivanov.io (pavel at ivanov.io) Date: Tue, 21 Jul 2015 03:57:08 -0700 (PDT) Subject: We're looking for a middle python developer in Moscow Message-ID: Hello everybody! We're looking for a well-experienced python developer who'd like to participate in educational startup in Moscow, Russia. It's going to be a contractor's job position for 6 months with possible prolongation. Here is the link: http://edumate.ru Main milestones for work completion: - The development of billing - The development of an external API for communication with partners - The design and development of additional tools for our clients Requirements: - Python, of course (you should know what does threads, GIL, yield mean, you've read PEP 8 etc.) - you've worked with Django 1.7 at least 1 year - you have an experience with NoSQL storages in production (MongoDB, Redis) - you've worked with Sphinx/Haystack - you have an experience of team work development with SVN or Git (if you active on GitHub - please, share your github account in your CV) If you're interested, please, send your CV to us: info at edumate.ru Thank you! From jcarmena at gmail.com Tue Jul 21 07:31:29 2015 From: jcarmena at gmail.com (jcarmena at gmail.com) Date: Tue, 21 Jul 2015 04:31:29 -0700 (PDT) Subject: Send data to asyncio coroutine Message-ID: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> Hello, I'm trying to understand and link asyncio with ordinary coroutines. Now I just want to understand how to do this on asyncio: def foo(): data = yield 8 print(data) yield "bye" def bar(): f = foo() n = f.next() print(n) message = f.send("hello") print(message) What is the equivalent for coro.send("some data") in asyncio? coro.send on an asyncio coroutine throws AssertionError: yield from wasn't used with future. Thank you From tandrewjohnson at outlook.com Tue Jul 21 08:10:40 2015 From: tandrewjohnson at outlook.com (tjohnson) Date: Tue, 21 Jul 2015 08:10:40 -0400 Subject: Is there a way to install ALL Python packages? In-Reply-To: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: <55AE36C0.4080007@outlook.com> On 7/20/2015 10:57 PM, ryguy7272 wrote: > I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. > > I know R offers this as an option. I figure Python must allow it too. > > Any idea how to grab everything? > > Thanks all. > As others have stated, this is not practical with Python. If you were to install every single package from PyPI, you'd end up with packages like funny 0.1 or Barun_Heehaw, which is described as "A sample junk project." (No, I'm not joking.) From tandrewjohnson at outlook.com Tue Jul 21 08:10:40 2015 From: tandrewjohnson at outlook.com (tjohnson) Date: Tue, 21 Jul 2015 08:10:40 -0400 Subject: Is there a way to install ALL Python packages? In-Reply-To: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: <55AE36C0.4080007@outlook.com> On 7/20/2015 10:57 PM, ryguy7272 wrote: > I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. > > I know R offers this as an option. I figure Python must allow it too. > > Any idea how to grab everything? > > Thanks all. > As others have stated, this is not practical with Python. If you were to install every single package from PyPI, you'd end up with packages like funny 0.1 or Barun_Heehaw, which is described as "A sample junk project." (No, I'm not joking.) From tandrewjohnson at outlook.com Tue Jul 21 08:20:21 2015 From: tandrewjohnson at outlook.com (tjohnson) Date: Tue, 21 Jul 2015 08:20:21 -0400 Subject: Need Help w. Getting the Eclipse Python Add-On. In-Reply-To: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> References: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> Message-ID: <55AE3905.9010007@outlook.com> On 7/17/2015 2:22 PM, Steve Burrus wrote: > I Need immediate Help w. Getting the Eclipse Python Add-On. I looked all around the Eclipse website to try to get this but didn't see the add-on for this. Can someone please help me to find it? Thanx. > The link Jerry posted should point you in the right direction. The PyDev manual contains detailed instructions on how to install PyDev in Eclipse: http://www.pydev.org/manual_101_root.html From tandrewjohnson at outlook.com Tue Jul 21 08:20:21 2015 From: tandrewjohnson at outlook.com (tjohnson) Date: Tue, 21 Jul 2015 08:20:21 -0400 Subject: Need Help w. Getting the Eclipse Python Add-On. In-Reply-To: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> References: <85c5ffbc-419a-4b5d-b432-d9391c598b4a@googlegroups.com> Message-ID: <55AE3905.9010007@outlook.com> On 7/17/2015 2:22 PM, Steve Burrus wrote: > I Need immediate Help w. Getting the Eclipse Python Add-On. I looked all around the Eclipse website to try to get this but didn't see the add-on for this. Can someone please help me to find it? Thanx. > The link Jerry posted should point you in the right direction. The PyDev manual contains detailed instructions on how to install PyDev in Eclipse: http://www.pydev.org/manual_101_root.html From auriocus at gmx.de Tue Jul 21 08:29:49 2015 From: auriocus at gmx.de (Christian Gollwitzer) Date: Tue, 21 Jul 2015 14:29:49 +0200 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: On 21.07.2015 04:55, Chris Angelico wrote: > On Tue, Jul 21, 2015 at 12:49 PM, ryguy7272 wrote: >> I'm trying to copy some Python code from a PDF book that I'm reading. I want to test out the code, and I can copy it, but when I paste it into the Shell, everything is all screwed up because of the indentation. Every time I paste in any kind of code, it seems like everything is immediately left-justified, and then nothing works. >> >> Any idea how to make this work easily? Without re-typing hundreds of lines of code... > > Sounds like a flaw in the PDF - it creates indentation in some way > other than leading spaces/tabs. PDF never uses tabs and spaces for indentation. In a PDF file, typically all words are placed using a drawing operator individually, the space is made up by your eyes when see the file. While space characters exist in fonts, they are practically never used. Often even inside a word there are breaks, because of kerning corrections. When copying the data, the PDF reader has to guess where the word breaks are and how the strings belong together. Acrobat does a good job, but fails in this special situation. Sometimes it even fails for a narrow running font and copies the string without any word breaks. Laura's method works, because pdftotext can simulate the PDF appearance using spaces in the output. Maybe an OCR program with good layout could also be used. Christian From ian.g.kelly at gmail.com Tue Jul 21 09:35:33 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 21 Jul 2015 07:35:33 -0600 Subject: Send data to asyncio coroutine In-Reply-To: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> References: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 5:31 AM, wrote: > Hello, I'm trying to understand and link asyncio with ordinary coroutines. Now I just want to understand how to do this on asyncio: > > > def foo(): > data = yield 8 > print(data) > yield "bye" > > def bar(): > f = foo() > n = f.next() > print(n) > message = f.send("hello") > print(message) > > > What is the equivalent for coro.send("some data") in asyncio? I don't know of any reason why you couldn't do it just like the above. However, the exchange would not be asynchronous, if that is your goal. > coro.send on an asyncio coroutine throws AssertionError: yield from wasn't used with future. So somehow a future got involved where it shouldn't have been. What was the actual code that you tried to run? Note that while "yield" and "yield from" look similar, they are quite different, and you cannot send to a generator that is currently paused at a "yield from". If you want to emulate bidirectional communication similar to coro.send asynchronously, I think you'll need to use Futures to mediate, something like this (lightly tested): @asyncio.coroutine def foo(fut): data, fut = yield from send_to_future(8, fut) print("foo", data) fut.set_result("bye") @asyncio.coroutine def bar(): n, fut = yield from start_coro(foo) print("bar", n) message = yield from send_to_future("hello", fut) print("bar", message) def start_coro(coro): future = asyncio.Future() asyncio.async(coro(future)) return future def send_to_future(data, future): new_future = asyncio.Future() future.set_result((data, new_future)) return new_future From rosuav at gmail.com Tue Jul 21 10:48:06 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 00:48:06 +1000 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 10:29 PM, Christian Gollwitzer wrote: > On 21.07.2015 04:55, Chris Angelico wrote: >> >> On Tue, Jul 21, 2015 at 12:49 PM, ryguy7272 wrote: >>> >>> I'm trying to copy some Python code from a PDF book that I'm reading. I >>> want to test out the code, and I can copy it, but when I paste it into the >>> Shell, everything is all screwed up because of the indentation. Every time I >>> paste in any kind of code, it seems like everything is immediately >>> left-justified, and then nothing works. >>> >>> Any idea how to make this work easily? Without re-typing hundreds of >>> lines of code... >> >> >> Sounds like a flaw in the PDF - it creates indentation in some way >> other than leading spaces/tabs. > > > PDF never uses tabs and spaces for indentation. In a PDF file, typically all > words are placed using a drawing operator individually, the space is made up > by your eyes when see the file. While space characters exist in fonts, they > are practically never used. Often even inside a word there are breaks, > because of kerning corrections. When copying the data, the PDF reader has to > guess where the word breaks are and how the strings belong together. Acrobat > does a good job, but fails in this special situation. Sometimes it even > fails for a narrow running font and copies the string without any word > breaks. Ah. I've never dug into PDF's internal details, but the above explanation completely doesn't surprise me. Tip, to document publishers: Don't use PDF for anything containing Python code. Thanks! Actually, maybe don't use PDF at all. I keep having to help my Mum deal with stupid problems with PDF documents she gets, and I'm never sure whether the fault is with the PDF creation software, the human operating said software, or limitations in the file format itself. ChrisA From ryanshuell at gmail.com Tue Jul 21 11:18:19 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Tue, 21 Jul 2015 08:18:19 -0700 (PDT) Subject: Can I copy/paste Python code? In-Reply-To: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: <1c6af915-d66a-4725-ae9f-40a2bf8c9dd7@googlegroups.com> On Monday, July 20, 2015 at 10:50:09 PM UTC-4, ryguy7272 wrote: > I'm trying to copy some Python code from a PDF book that I'm reading. I want to test out the code, and I can copy it, but when I paste it into the Shell, everything is all screwed up because of the indentation. Every time I paste in any kind of code, it seems like everything is immediately left-justified, and then nothing works. > > Any idea how to make this work easily? Without re-typing hundreds of lines of code... > > Thanks to all. Thanks for all the help everyone!! From ryanshuell at gmail.com Tue Jul 21 11:19:33 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Tue, 21 Jul 2015 08:19:33 -0700 (PDT) Subject: Is there a way to install ALL Python packages? In-Reply-To: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: On Monday, July 20, 2015 at 10:57:47 PM UTC-4, ryguy7272 wrote: > I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. > > I know R offers this as an option. I figure Python must allow it too. > > Any idea how to grab everything? > > Thanks all. Ok, this makes sense. Thanks for the insight everyone!! From toddrjen at gmail.com Tue Jul 21 11:30:06 2015 From: toddrjen at gmail.com (Todd) Date: Tue, 21 Jul 2015 17:30:06 +0200 Subject: Is there a way to install ALL Python packages? In-Reply-To: <55AE36C0.4080007@outlook.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> <55AE36C0.4080007@outlook.com> Message-ID: On Tue, Jul 21, 2015 at 2:10 PM, tjohnson wrote: > On 7/20/2015 10:57 PM, ryguy7272 wrote: > >> I'd like to install ALL Python packages on my machine. Even if it takes >> up 4-5GB, or more, I'd like to get everything, and then use it when I need >> it. Now, I'd like to import packages, like numpy and pandas, but nothing >> will install. I figure, if I can just install everything, I can simply use >> it when I need it, and if I don't need it, then I just won't use it. >> >> I know R offers this as an option. I figure Python must allow it too. >> >> Any idea how to grab everything? >> >> Thanks all. >> >> As others have stated, this is not practical with Python. If you were to > install every single package from PyPI, you'd end up with packages like > funny 0.1 or Barun_Heehaw, which is described as "A sample junk project." > (No, I'm not joking.) > The latter being, literally, a "Hello world" project and nothing else. -------------- next part -------------- An HTML attachment was scrubbed... URL: From i at introo.me Tue Jul 21 11:35:19 2015 From: i at introo.me (Shiyao Ma) Date: Tue, 21 Jul 2015 11:35:19 -0400 Subject: Where is the c source code of the import mechanism that ignores invalid directory? Message-ID: Hi, It looks to me that the import system of Python will ignore invalid directories and cache the result in memory. For example, the following code: paste here: https://bpaste.net/show/b144deb42620 #!/usr/bin/env python3 import sysimport osimport shutil sys.path.append("./test")shutil.rmtree("./test", ignore_errors=True) try: import fooexcept ImportError: os.mkdir("./test") with open("./test/foo.py", "w") as f: f.write("print(3)") import foo the second import foo will fail even though it's there. This is because when doing the first import foo, the directory .test doesn't exist, and Python ignores that directory forever. I am interested in the c side implementation of this "ignoring" part. Any body help me to pinpoint the exact c source location? Thanks. -- ????????????????https://introo.me ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.usenet at bsb.me.uk Tue Jul 21 12:12:13 2015 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Tue, 21 Jul 2015 17:12:13 +0100 Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: <87si8h5w2q.fsf@bsb.me.uk> Christian Gollwitzer writes: > On 21.07.2015 04:55, Chris Angelico wrote: >> On Tue, Jul 21, 2015 at 12:49 PM, ryguy7272 wrote: >>> [...] Every time I paste in any kind of code, it seems >>> like everything is immediately left-justified, and then nothing >>> works. >> Sounds like a flaw in the PDF - it creates indentation in some way >> other than leading spaces/tabs. > > PDF never uses tabs and spaces for indentation. In a PDF file, > typically all words are placed using a drawing operator individually, > the space is made up by your eyes when see the file. It's not really a PDF issue. It's to do with how the document is produced. I've just looked at a few PDF files and I have found all three layout methods used for code: positioning, spaces and tabs. Of course those that use spaces may be violating some PDF rule or other, but such files certainly exist in the wild. -- Ben. From breamoreboy at yahoo.co.uk Tue Jul 21 12:16:27 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 21 Jul 2015 17:16:27 +0100 Subject: Where is the c source code of the import mechanism that ignores invalid directory? In-Reply-To: References: Message-ID: On 21/07/2015 16:35, Shiyao Ma wrote: > Hi, > > It looks to me that the import system of Python will ignore invalid > directories and cache the result in memory. > > For example, the following code: > paste here: https://bpaste.net/show/b144deb42620 > > #!/usr/bin/env python3 > > import sys > import os > import shutil > > sys.path.append("./test") > shutil.rmtree("./test", ignore_errors=True) > > try: > import foo > except ImportError: > os.mkdir("./test") > with open("./test/foo.py", "w") as f: > f.write("print(3)") > > import foo > > the second import foo will fail even though it's there. This is because > when doing the first import foo, the directory .test doesn't exist, and > Python ignores that directory forever. > > > I am interested in the c side implementation of this "ignoring" part. > > > Any body help me to pinpoint the exact c source location? > > Thanks. > > -- > > ????????????????https://introo.me ? > Start here https://hg.python.org/cpython/file/6629773fef63/Python/import.c -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From i at introo.me Tue Jul 21 12:44:11 2015 From: i at introo.me (Shiyao Ma) Date: Tue, 21 Jul 2015 12:44:11 -0400 Subject: Where is the c source code of the import mechanism that ignores invalid directory? In-Reply-To: References: Message-ID: Yep. I followed from bltmodule.c(the import function) and got to the import.c file, and finally got lost. Regards. On Tue, Jul 21, 2015 at 12:16 PM, Mark Lawrence wrote: > On 21/07/2015 16:35, Shiyao Ma wrote: > >> Hi, >> >> It looks to me that the import system of Python will ignore invalid >> directories and cache the result in memory. >> >> For example, the following code: >> paste here: https://bpaste.net/show/b144deb42620 >> >> #!/usr/bin/env python3 >> >> import sys >> import os >> import shutil >> >> sys.path.append("./test") >> shutil.rmtree("./test", ignore_errors=True) >> >> try: >> import foo >> except ImportError: >> os.mkdir("./test") >> with open("./test/foo.py", "w") as f: >> f.write("print(3)") >> >> import foo >> >> the second import foo will fail even though it's there. This is because >> when doing the first import foo, the directory .test doesn't exist, and >> Python ignores that directory forever. >> >> >> I am interested in the c side implementation of this "ignoring" part. >> >> >> Any body help me to pinpoint the exact c source location? >> >> Thanks. >> >> -- >> >> ????????????????https://introo.me ? >> >> > Start here https://hg.python.org/cpython/file/6629773fef63/Python/import.c > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > -- > https://mail.python.org/mailman/listinfo/python-list > -- ????????????????https://introo.me ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Jul 21 12:47:02 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 02:47:02 +1000 Subject: Where is the c source code of the import mechanism that ignores invalid directory? In-Reply-To: References: Message-ID: On Wed, Jul 22, 2015 at 2:44 AM, Shiyao Ma wrote: > Yep. I followed from bltmodule.c(the import function) and got to the > import.c file, and finally got lost. > What version of CPython are you looking at? If it's a sufficiently recent version, you may want to look at importlib instead. https://docs.python.org/3/library/importlib.html That'll be a LOT easier to work through. ChrisA From oscar.j.benjamin at gmail.com Tue Jul 21 13:02:16 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Tue, 21 Jul 2015 17:02:16 +0000 Subject: Can I copy/paste Python code? In-Reply-To: <87si8h5w2q.fsf@bsb.me.uk> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <87si8h5w2q.fsf@bsb.me.uk> Message-ID: On Tue, 21 Jul 2015 at 17:16 Ben Bacarisse wrote: > Christian Gollwitzer writes: > > > On 21.07.2015 04:55, Chris Angelico wrote: > >> Sounds like a flaw in the PDF - it creates indentation in some way > >> other than leading spaces/tabs. > > > > PDF never uses tabs and spaces for indentation. In a PDF file, > > typically all words are placed using a drawing operator individually, > > the space is made up by your eyes when see the file. > > It's not really a PDF issue. It's to do with how the document is > produced. I've just looked at a few PDF files and I have found all > three layout methods used for code: positioning, spaces and tabs. Of > course those that use spaces may be violating some PDF rule or other, > but such files certainly exist in the wild. > They're not violating any PDF rule. PDF as a format was not designed with this kind of usage in mind. The idea of a PDF is that contains as much information as is required to unambiguously represent the *appearance* of a document. It's really a vectorised image format (like SVG) but with a few extra document-like features (e.g. pages). -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoon.pardon at rece.vub.ac.be Tue Jul 21 13:21:09 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Tue, 21 Jul 2015 19:21:09 +0200 Subject: Integers with leading zeroes In-Reply-To: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55AE7F85.6010609@rece.vub.ac.be> On 07/19/2015 07:39 AM, Steven D'Aprano wrote: > In Python 2, integer literals with leading zeroes are treated as octal, so > 09 is a syntax error and 010 is 8. > > This is confusing to those not raised on C-style octal literals, so in > Python 3 leading zeroes are prohibited in int literals. Octal is instead > written using the prefix 0o, similar to hex 0x and binary 0b. > > Consequently Python 3 makes both 09 and 010 a syntax error. > > However there is one exception: zero itself is allowed any number of leading > zeroes, so 00000 is a legal way to write zero as a base-10 int literal. > > Does anyone use that (mis)feature? > Yes. I like to sometime write numbers with leading zeros. Sometimes these numbers represent codeblocks of a fixed number of digits. Always writing those numbers with this number of digits helps being aware of this. It is also easier for when you need to know how many leading zero's such a number has. From lac at openend.se Tue Jul 21 13:25:32 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 21 Jul 2015 19:25:32 +0200 Subject: Can I copy/paste Python code? In-Reply-To: Message from Chris Angelico of "Wed, 22 Jul 2015 00:48:06 +1000." References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: <201507211725.t6LHPW1Y028074@fido.openend.se> In a message of Wed, 22 Jul 2015 00:48:06 +1000, Chris Angelico writes: >Actually, maybe don't use PDF at all. I keep having to help my Mum >deal with stupid problems with PDF documents she gets, and I'm never >sure whether the fault is with the PDF creation software, the human >operating said software, or limitations in the file format itself. > >ChrisA Lots of the problems are with the free reader, adobe acrobat. It is designed so that the user is kept very much in a straight-jacket which is a problem when your Mum needs, for instance, things to be in 36 point for her to be able to read things at all because she is nearly blind. Laura From antoon.pardon at rece.vub.ac.be Tue Jul 21 13:33:09 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Tue, 21 Jul 2015 19:33:09 +0200 Subject: Proposed keyword to transfer control to another function In-Reply-To: References: Message-ID: <55AE8255.5000704@rece.vub.ac.be> On 07/19/2015 02:21 AM, Chris Angelico wrote: > On Sun, Jul 19, 2015 at 9:32 AM, Gregory Ewing > wrote: >> Personally I'd be fine with your initial syntax, but >> something else might be needed to get it past Guido. >> He didn't like my 'cocall f()' construct in PEP 3152, >> which is syntactically isomorphic to 'transfer f()'. > > Maybe it should get written up and rejected, then, to be something to > point to any time anyone advocates TCO. Those who remember the history of pep 308 will not find that a strong deterrent. From rosuav at gmail.com Tue Jul 21 13:38:06 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 03:38:06 +1000 Subject: Proposed keyword to transfer control to another function In-Reply-To: <55AE8255.5000704@rece.vub.ac.be> References: <55AE8255.5000704@rece.vub.ac.be> Message-ID: On Wed, Jul 22, 2015 at 3:33 AM, Antoon Pardon wrote: > On 07/19/2015 02:21 AM, Chris Angelico wrote: >> On Sun, Jul 19, 2015 at 9:32 AM, Gregory Ewing >> wrote: > >>> Personally I'd be fine with your initial syntax, but >>> something else might be needed to get it past Guido. >>> He didn't like my 'cocall f()' construct in PEP 3152, >>> which is syntactically isomorphic to 'transfer f()'. >> >> Maybe it should get written up and rejected, then, to be something to >> point to any time anyone advocates TCO. > > Those who remember the history of pep 308 will not find > that a strong deterrent. It doesn't have to be a deterrent. It just has to say "Here's all the arguments we came up with in 2015, so find answers to those if you want to reopen the debate". It's effectively a way of rapidly onboarding the conclusions from a lengthy discussion, much more easily than pointing someone to the archive and expecting him/her to read through it all. ChrisA From suscricions at gmail.com Tue Jul 21 13:38:55 2015 From: suscricions at gmail.com (Jason P.) Date: Tue, 21 Jul 2015 10:38:55 -0700 (PDT) Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> Message-ID: <40474894-45e0-46fd-92b8-486b83d23d29@googlegroups.com> El mi?rcoles, 15 de julio de 2015, 14:12:08 (UTC+2), Chris Angelico escribi?: > On Wed, Jul 15, 2015 at 9:44 PM, Jason P. wrote: > > I can't understand very well what's happening. It seems that the main thread gets blocked listening to the web server. My intent was to spawn another process for the server independent of the test. Obviously I'm doing something wrong. I've made several guesses commenting pieces of code (tearDown method for example) but I didn't manage to solve the problem(s). > > > > When you find yourself making guesses to try to figure out what's > going on, here are two general tips: > > 1) Cut out as many pieces as you can. Test one small thing at a time. > 2) If In Doubt, Print It Out! Stick print() calls into the code at key > places, displaying the values of parameters or the results of > intermediate calculations - or just saying "Hi, I'm still here and I'm > running!". > > For #1, I would recommend first just trying to get the web service > going. Can you connect (using an external program) on port 8000 and > receive a text/plain HTTP response saying "Hello World!"? Never mind > about the test for the moment. > > And for #2, judicious placement of console output will help you figure > out things you're not sure about. For instance, you're suspecting that > the main thread is getting blocked handling the web server. Easy way > to check: > > def setUp(self): > # Start the forecast server > self.server = ForecastServer() > self.server.start(webservice.app) > > Just before you construct the server, print something out. After > you've constructed it but before you call start(), print something > out. And after starting it, print something out. Then run the program. > If you see the first line and no other, then it's blocking during the > construction. Other deductions I'm sure you can figure out. > > One small point: Probe even things that you think are trivial. In the > above example, I cannot see any reason why constructing > ForecastServer() could possibly block, because its init does nothing > but set a flag. But you can get surprised by things sometimes - maybe > the problem is actually that you're not running the code you think you > are, but there's some other ForecastServer kicking in, and it's > synchronous rather than subprocess-based. > > End-to-end testing is all very well, but when something goes wrong, > the key is to break the program down into smaller parts. Otherwise, > all you have is "it doesn't work", which is one of the most useless > error reports ever. If someone comes to python-list saying "it doesn't > work", we'll be asking him/her to give a lot more details; if your > aunt asks you for help printing out a document because "it doesn't > work", you'll probably have to go over and watch her attempt it; and > it's the same with your test cases - you make them tell you more > details. > > Hope that helps! The techniques I'm offering are completely > problem-independent, and even language-independent. IIDPIO debugging > works in anything that gives you a console, which is pretty much > everything - maybe it won't be print() but logging.debug(), but the > same technique works. > > ChrisA Thanks for your comments Chris. I've come back to the problem today after a few days on trip. Fortunately someone in other mailing list pointed me that the join method was hanging the main thread. Without this inconvenience I can focus on the exercise's main goal. Despite the impression that surely I gave, I'm quite familiar with programming and general bug hunting rules. The problem is that I'm inexperienced with Python and the subtle details of multiple threads ;) Thanks! From gheskett at wdtv.com Tue Jul 21 13:41:08 2015 From: gheskett at wdtv.com (Gene Heskett) Date: Tue, 21 Jul 2015 13:41:08 -0400 Subject: Can I copy/paste Python code? In-Reply-To: <201507211725.t6LHPW1Y028074@fido.openend.se> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: <201507211341.08134.gheskett@wdtv.com> On Tuesday 21 July 2015 13:25:32 Laura Creighton wrote: > In a message of Wed, 22 Jul 2015 00:48:06 +1000, Chris Angelico writes: > >Actually, maybe don't use PDF at all. I keep having to help my Mum > >deal with stupid problems with PDF documents she gets, and I'm never > >sure whether the fault is with the PDF creation software, the human > >operating said software, or limitations in the file format itself. > > > >ChrisA > > Lots of the problems are with the free reader, adobe acrobat. It is > designed so that the user is kept very much in a straight-jacket which > is a problem when your Mum needs, for instance, things to be in 36 > point for her to be able to read things at all because she is nearly > blind. > > Laura TBE, acroread is a P.O.E. Its first sin is in not sending the printer a blank page so that the printout of something novel sized at 450 pages or so, actually stays in synch with the ditch settings in your driver used in duplex mode. Linux has several replacements that do this better, and fast enough to keep even a fast laser printer busy. Look them over and I am sure you will find something that is both friendlier and more useful for your usage needs. Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page From rosuav at gmail.com Tue Jul 21 13:48:05 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 03:48:05 +1000 Subject: Noob in Python. Problem with fairly simple test case In-Reply-To: <40474894-45e0-46fd-92b8-486b83d23d29@googlegroups.com> References: <0165e508-b3b4-4a95-b1bb-e115893056f8@googlegroups.com> <40474894-45e0-46fd-92b8-486b83d23d29@googlegroups.com> Message-ID: On Wed, Jul 22, 2015 at 3:38 AM, Jason P. wrote: > Despite the impression that surely I gave, I'm quite familiar with programming and general bug hunting rules. The problem is that I'm inexperienced with Python and the subtle details of multiple threads ;) > Heh, it doesn't hurt to remind people of basic debugging techniques sometimes. Worst case, you come back and say "Yep, I tried that, and here's the result". Best case, someone else (who doesn't know what you know) will come along with a superficially similar problem, will see the suggested technique, and even if the actual issue is quite different, will be better able to diagnose it. ChrisA From madduranilkumar at gmail.com Tue Jul 21 13:52:25 2015 From: madduranilkumar at gmail.com (Madduri Anil kumar) Date: Tue, 21 Jul 2015 23:22:25 +0530 Subject: Python Schduling Message-ID: Hello Experts, I am new to Python Programming.I have to work on Python. I have a requirement to scheduling the script for every one hour. could you please let me know which packages will be more helpful for Scheduling. if you post any samples it would be more helpful. Thanks & Regards, Anilkumar.M. From sohcahtoa82 at gmail.com Tue Jul 21 13:58:10 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Tue, 21 Jul 2015 10:58:10 -0700 (PDT) Subject: Integers with leading zeroes In-Reply-To: References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> Message-ID: <559ead35-8f92-49de-8fa2-a78d257eb0d6@googlegroups.com> On Tuesday, July 21, 2015 at 10:22:44 AM UTC-7, Antoon Pardon wrote: > On 07/19/2015 07:39 AM, Steven D'Aprano wrote: > > In Python 2, integer literals with leading zeroes are treated as octal, so > > 09 is a syntax error and 010 is 8. > > > > This is confusing to those not raised on C-style octal literals, so in > > Python 3 leading zeroes are prohibited in int literals. Octal is instead > > written using the prefix 0o, similar to hex 0x and binary 0b. > > > > Consequently Python 3 makes both 09 and 010 a syntax error. > > > > However there is one exception: zero itself is allowed any number of leading > > zeroes, so 00000 is a legal way to write zero as a base-10 int literal. > > > > Does anyone use that (mis)feature? > > > > Yes. I like to sometime write numbers with leading zeros. > Sometimes these numbers represent codeblocks of a fixed > number of digits. Always writing those numbers with this > number of digits helps being aware of this. It is also > easier for when you need to know how many leading zero's > such a number has. IMO, leading zeroes just looks like visual noise, and if I wanted to align numbers, I'd just use spaces. From emile at fenx.com Tue Jul 21 14:06:39 2015 From: emile at fenx.com (Emile van Sebille) Date: Tue, 21 Jul 2015 11:06:39 -0700 Subject: Integers with leading zeroes In-Reply-To: <559ead35-8f92-49de-8fa2-a78d257eb0d6@googlegroups.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <559ead35-8f92-49de-8fa2-a78d257eb0d6@googlegroups.com> Message-ID: On 7/21/2015 10:58 AM, sohcahtoa82 at gmail.com wrote: > > IMO, leading zeroes just looks like visual noise, and if I wanted to align numbers, I'd just use spaces. > Aligning numbers using spaces doesn't always align -- using zeros does. Emile From sohcahtoa82 at gmail.com Tue Jul 21 14:38:33 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Tue, 21 Jul 2015 11:38:33 -0700 (PDT) Subject: Integers with leading zeroes In-Reply-To: References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <559ead35-8f92-49de-8fa2-a78d257eb0d6@googlegroups.com> Message-ID: <5ede3a45-fddc-41ec-9c96-8772e38f80a9@googlegroups.com> On Tuesday, July 21, 2015 at 11:07:43 AM UTC-7, Emile van Sebille wrote: > On 7/21/2015 10:58 AM, sohcahtoa82 at gmail.com wrote: > > > > IMO, leading zeroes just looks like visual noise, and if I wanted to align numbers, I'd just use spaces. > > > > Aligning numbers using spaces doesn't always align -- using zeros does. > > Emile You've got me confused. They should align just fine if you're using a fixed-width font. If you're not using a fixed-width font in your programming, then I don't know what to say to you. From sohcahtoa82 at gmail.com Tue Jul 21 14:41:30 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Tue, 21 Jul 2015 11:41:30 -0700 (PDT) Subject: Integers with leading zeroes In-Reply-To: <5ede3a45-fddc-41ec-9c96-8772e38f80a9@googlegroups.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <559ead35-8f92-49de-8fa2-a78d257eb0d6@googlegroups.com> <5ede3a45-fddc-41ec-9c96-8772e38f80a9@googlegroups.com> Message-ID: <7a9b1ac8-0a8c-4e98-b519-3cb00b7e54d2@googlegroups.com> On Tuesday, July 21, 2015 at 11:38:53 AM UTC-7, sohca... at gmail.com wrote: > On Tuesday, July 21, 2015 at 11:07:43 AM UTC-7, Emile van Sebille wrote: > > On 7/21/2015 10:58 AM, sohcahtoa82 at gmail.com wrote: > > > > > > IMO, leading zeroes just looks like visual noise, and if I wanted to align numbers, I'd just use spaces. > > > > > > > Aligning numbers using spaces doesn't always align -- using zeros does. > > > > Emile > > You've got me confused. They should align just fine if you're using a fixed-width font. > > If you're not using a fixed-width font in your programming, then I don't know what to say to you. I should probably state that I may use leading zeroes when using hexadecimal numbers. For example, I might write 0x000ABCDE, rather than 0xABCDE, but that's only if I'm using a lot of 32-bit values. If I only care about a single byte, I will use 0x01, for example. But for base-10, I would never use leading zeroes. From invalid at invalid.invalid Tue Jul 21 14:55:35 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 21 Jul 2015 18:55:35 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: On 2015-07-21, Laura Creighton wrote: > Lots of the problems are with the free reader, adobe acrobat. It is > designed so that the user is kept very much in a straight-jacket which > is a problem when your Mum needs, for instance, things to be in 36 point > for her to be able to read things at all because she is nearly blind. That's not a problem with acrobat. That's not even a "problem" with PDF itself, it's the whole _intent_ of PDF: to specify _exactly_ what the document should look like and not allow the reader to muck up the formatting, fonts, colors, alignment, page size, etc. It's supposed to mimic as closely as possible ink on paper: PDF is for when you want the document to look exactly like you want it to look everwhere and for everybody. If you want the reader to be able to change the layout, fonts/sizes, colors, alignments, page dimensions, etc, then PDF is just plain the wrong format. Complaining about a PDF reader not being able to change the appearance of PDF documents is like complaining that glue is sticky, oil is slippery, and knives have sharp edges. -- Grant Edwards grant.b.edwards Yow! Make me look like at LINDA RONSTADT again!! gmail.com From breamoreboy at yahoo.co.uk Tue Jul 21 15:58:25 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 21 Jul 2015 20:58:25 +0100 Subject: Can I copy/paste Python code? In-Reply-To: <201507211725.t6LHPW1Y028074@fido.openend.se> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 21/07/2015 18:25, Laura Creighton wrote: > In a message of Wed, 22 Jul 2015 00:48:06 +1000, Chris Angelico writes: >> Actually, maybe don't use PDF at all. I keep having to help my Mum >> deal with stupid problems with PDF documents she gets, and I'm never >> sure whether the fault is with the PDF creation software, the human >> operating said software, or limitations in the file format itself. >> >> ChrisA > > Lots of the problems are with the free reader, adobe acrobat. It is > designed so that the user is kept very much in a straight-jacket which > is a problem when your Mum needs, for instance, things to be in 36 point > for her to be able to read things at all because she is nearly blind. > > Laura > All I know is that I read a review about Foxit Reader https://www.foxitsoftware.com/products/pdf-reader/ and I've never looked back. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From invalid at invalid.invalid Tue Jul 21 16:32:57 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 21 Jul 2015 20:32:57 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 2015-07-21, Mark Lawrence wrote: > On 21/07/2015 18:25, Laura Creighton wrote: > >> Lots of the problems are with the free reader, adobe acrobat. It is >> designed so that the user is kept very much in a straight-jacket which >> is a problem when your Mum needs, for instance, things to be in 36 point >> for her to be able to read things at all because she is nearly blind. > All I know is that I read a review about Foxit Reader > https://www.foxitsoftware.com/products/pdf-reader/ and I've never > looked back. I'd have serious doubts about anybody who brags that their product has a "Microsoft Offic 2013 Style Ribbon Toolbar". ;) But, it apears foxit reader is Windows-only so it's a moot point for Linux/Unix/Mac users. -- Grant Edwards grant.b.edwards Yow! Hey, wait at a minute!! I want a gmail.com divorce!! ... you're not Clint Eastwood!! From breamoreboy at yahoo.co.uk Tue Jul 21 16:54:25 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 21 Jul 2015 21:54:25 +0100 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 21/07/2015 21:32, Grant Edwards wrote: > On 2015-07-21, Mark Lawrence wrote: >> On 21/07/2015 18:25, Laura Creighton wrote: >> >>> Lots of the problems are with the free reader, adobe acrobat. It is >>> designed so that the user is kept very much in a straight-jacket which >>> is a problem when your Mum needs, for instance, things to be in 36 point >>> for her to be able to read things at all because she is nearly blind. > >> All I know is that I read a review about Foxit Reader >> https://www.foxitsoftware.com/products/pdf-reader/ and I've never >> looked back. > > I'd have serious doubts about anybody who brags that their product has > a "Microsoft Offic 2013 Style Ribbon Toolbar". ;) > > But, it apears foxit reader is Windows-only so it's a moot point for > Linux/Unix/Mac users. > Who cares provided you can get a VMS version :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From emile at fenx.com Tue Jul 21 17:03:27 2015 From: emile at fenx.com (Emile van Sebille) Date: Tue, 21 Jul 2015 14:03:27 -0700 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 7/21/2015 1:32 PM, Grant Edwards wrote: > But, it apears foxit reader is Windows-only so it's a moot point for > Linux/Unix/Mac users. I've been happy with https://wiki.gnome.org/Apps/Evince on linux. Emile From oracle.blog3 at gmail.com Tue Jul 21 17:12:57 2015 From: oracle.blog3 at gmail.com (max scalf) Date: Tue, 21 Jul 2015 16:12:57 -0500 Subject: convert output to list(and nested dictionary) Message-ID: Hello all, For Each SecurityGroup, how can i convert that into a List that in turn will have a dictionary of the cidr block, protocol type and the port...so from output below, the SecurityGroup called "default" had 2 rules...allowing TCP port from 80 and 5500 to the source IP and then SecurityGroup called "Pub_HDP_SG" had only one rule...so on and so forth....here is the output that i am trying to get out in the form of a list.... what I am planning to do is, take the list(and nested dictionary) and pass that to a function that will in turn spitout a cloudformation template using troposphere (something like " http://imil.net/wp/2015/06/04/rock-your-cloudformation-with-troposphere-and-boto/ ") For Better Readablity (http://pastebin.com/rT6Aswwz) import boto.ec2 sgs = boto.ec2.connect_to_region('us-east-1').get_all_security_groups() for sg in sgs: for rule in sg.rules: print sg, sg.id, "inbound:", rule, " source:", rule.grants SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(80-80) source: [67.184.225.222/32] SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(5500-5500) source: [67.184.225.222/32] SecurityGroup:Pub_HDP_SG sg-e632d982 inbound: IPPermissions:tcp(80-80) source: [0.0.0.0/0] SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: IPPermissions:tcp(22-22) source: [0.0.0.0/0] SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: IPPermissions:tcp(80-80) source: [0.0.0.0/0] SecurityGroup:RDP Rule - open everyone sg-42d58d27 inbound: IPPermissions:-1(None-None) source: [0.0.0.0/0] SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: IPPermissions:tcp(22-22) source: [10.0.20.100/32] SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: IPPermissions:tcp(53-53) source: [10.0.20.100/32] SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:-1(None-None) source: [sg-e632d982-995635159130] SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:tcp(22-22) source: [67.184.225.222/32] SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:tcp(1024-65535) source: [10.0.20.100/32] SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:tcp(80-80) source: [24.12.30.198/32] SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:udp(138-138) source: [10.0.20.100/32] SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:udp(53-53) source: [24.12.30.198/32] SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:tcp(30015-30015) source: [0.0.0.0/0] SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:icmp(-1--1) source: [10.0.20.100/32] SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) source: [sg-c65a20a3-995635159130] SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) source: [sg-99c4befc-995635159130] SecurityGroup:sg3-MySecurityGroup2-1HGPN4UF57XN6 sg-4ee73729 inbound: IPPermissions:tcp(22-22) source: [192.168.1.12/32] SecurityGroup:AWS-AMI-SG sg-35568d51 inbound: IPPermissions:tcp(22-22) source: [0.0.0.0/0] SecurityGroup:launch-wizard-2 sg-932255f6 inbound: IPPermissions:tcp(22-22) source: [10.0.20.100/32] SecurityGroup:launch-wizard-2 sg-932255f6 inbound: IPPermissions:tcp(443-443) source: [0.0.0.0/0] >>> Here is the output i am looking for.... rule1 = [{ 'cidr': '67.184.225.222/32', 'proto': 'tcp', 'port': 80 },{ 'cidr': '67.184.225.222/32', 'proto': 'tcp', 'port': 5500 }] rule2 = [{ 'cidr': '[0.0.0.0/0', 'proto': 'tcp', 'port': 80 }] rule3 = [{ 'cidr': '0.0.0.0/0', 'proto': 'tcp', 'port': 22 },{ 'cidr': '0.0.0.0/0', 'proto': 'tcp', 'port': 80 }] -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at gmail.com Tue Jul 21 17:22:37 2015 From: breamoreboy at gmail.com (breamoreboy at gmail.com) Date: Tue, 21 Jul 2015 14:22:37 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> Message-ID: On Tuesday, July 21, 2015 at 4:04:30 AM UTC+1, Rick Johnson wrote: > On Sunday, July 19, 2015 at 9:17:11 PM UTC-5, Rustom Mody wrote: > > > > List of python committers: > > ------------------------- > > 11081 Guido van Rossum > > [snip: long list] > > Thanks for posting this list of names. I had put in a pyFOIA > request for this data a few years ago, but to my surprise, was > flat out denied. I'm not sure how exhaustive this list may be, > but publicly displaying the "commit hierarchy" within the Python > community is very import for those who may want to get involved. > > [Talking to Mark Lawrence, Rustom said:] > > So... May I humbly ask where are your precious commits?? > > Thanks for putting Mark in his place. He has been brow > beating folks on this list (myself included) for years, and > i'll bet he now feels as tiny as D'Aprano did -- when GvR > scolded him for disrespecting a Noob on Python-ideas. > Read on, oh great stupid one. > Yeah, i was watching! > > I'M *ALWAYS* WATCHING! > > ?_? > > Now that Mark's lack of "commit cred" has been exposed, we can > safely ignore his hollow and hypocritical bullying. And now > that he has been de-fanged, he will be forced to seek employment > elsewhere. Hmm, my suggestion is that he market himself as an > on-call "peanut butter removal service". A venture that will > no doubt be successful, seeing that he has two "heads up" on > his competition! Ever heard the saying "engage brain before putting mouth into gear"? It was actually Rustom who posted inaccurate data as only core-devs have commit rights. It would appear that your knowledge of the current development process is as good as your knowledge of European geography. I would say enjoy your future in the "peanut butter removal service" but it is quite clear that you haven't the skills needed to make it happen. In the mean time I'll quite happily carry on contributing to the Python community as best I can. Oh, and while I think about it, you'd better put that shovel down, or the hole will only get deeper. Have a nice day :) From irmen.NOSPAM at xs4all.nl Tue Jul 21 17:27:23 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Tue, 21 Jul 2015 23:27:23 +0200 Subject: Python Schduling In-Reply-To: References: Message-ID: <55aeb93c$0$2956$e4fe514c@news.xs4all.nl> On 21-7-2015 19:52, Madduri Anil kumar wrote: > Hello Experts, > > I am new to Python Programming.I have to work on Python. > I have a requirement to scheduling the script for every one hour. > could you please let me know which packages will be more helpful for Scheduling. > if you post any samples it would be more helpful. > > Thanks & Regards, > Anilkumar.M. > Unless you have specific reasons to do this from within Python itself, I advise to use your operating system's task scheduler instead. Let it invoke the Python program on the desired interval. So, make a cron job for unixes or configure the task scheduler on Windows. Irmen From invalid at invalid.invalid Tue Jul 21 17:47:50 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 21 Jul 2015 21:47:50 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 2015-07-21, Emile van Sebille wrote: > On 7/21/2015 1:32 PM, Grant Edwards wrote: > >> But, it apears foxit reader is Windows-only so it's a moot point for >> Linux/Unix/Mac users. > > I've been happy with https://wiki.gnome.org/Apps/Evince on linux. I'm trying to switch from acroread to evince, bit it has a few serious usability problems for me: 1) You can't copy/paste text from evince _at_all_. At least it works right most of the time with acroread. I really like being able paste example commands or bits of code or a sentance or three from PDF docs into a shell or editor window. Pasting tables is a bit more work, but it can at least be done with acroread. 2) You can't print the current view. I find that invaluable for printing portions of documents (e.g. I want just a section of a C size schematic printed on letter sized paper, or just one table table from a manual sized to fill a 8.5x11 page). If it did have 'print view' then lack of a marquee zoom would become another inconvenience. 3) There's no way to collapse-all in the TOC panel. When I open a 1200 page document with 30 sections and several hundred sections and subsections, I don't want to see all of them all of the time. Closing them one at a time by hand is pretty tedious. I find that about 20-30% of the time I start up evince, I end up closing it and re-opening the document in acroread. -- Grant Edwards grant.b.edwards Yow! ... I have read the at INSTRUCTIONS ... gmail.com From tandrewjohnson at outlook.com Tue Jul 21 17:53:18 2015 From: tandrewjohnson at outlook.com (tjohnson) Date: Tue, 21 Jul 2015 17:53:18 -0400 Subject: Is there a way to install ALL Python packages? In-Reply-To: References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: <55AEBF4E.4060700@outlook.com> On 7/21/2015 11:19 AM, ryguy7272 wrote: > On Monday, July 20, 2015 at 10:57:47 PM UTC-4, ryguy7272 wrote: >> I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. >> >> I know R offers this as an option. I figure Python must allow it too. >> >> Any idea how to grab everything? >> >> Thanks all. > > Ok, this makes sense. Thanks for the insight everyone!! > I forgot to mention in my previous post that there are Python bundles like Anaconda and Enthought available, which come with numerous packages preinstalled. You may want to check them out. From tandrewjohnson at outlook.com Tue Jul 21 17:53:18 2015 From: tandrewjohnson at outlook.com (tjohnson) Date: Tue, 21 Jul 2015 17:53:18 -0400 Subject: Is there a way to install ALL Python packages? In-Reply-To: References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: <55AEBF4E.4060700@outlook.com> On 7/21/2015 11:19 AM, ryguy7272 wrote: > On Monday, July 20, 2015 at 10:57:47 PM UTC-4, ryguy7272 wrote: >> I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. >> >> I know R offers this as an option. I figure Python must allow it too. >> >> Any idea how to grab everything? >> >> Thanks all. > > Ok, this makes sense. Thanks for the insight everyone!! > I forgot to mention in my previous post that there are Python bundles like Anaconda and Enthought available, which come with numerous packages preinstalled. You may want to check them out. From emile at fenx.com Tue Jul 21 18:35:25 2015 From: emile at fenx.com (Emile van Sebille) Date: Tue, 21 Jul 2015 15:35:25 -0700 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 7/21/2015 2:47 PM, Grant Edwards wrote: > On 2015-07-21, Emile van Sebille wrote: >> On 7/21/2015 1:32 PM, Grant Edwards wrote: >> >>> But, it apears foxit reader is Windows-only so it's a moot point for >>> Linux/Unix/Mac users. >> >> I've been happy with https://wiki.gnome.org/Apps/Evince on linux. > > I'm trying to switch from acroread to evince, bit it has a few serious > usability problems for me: > > 1) You can't copy/paste text from evince _at_all_. Hmm, i just copied "Acorsa Artichoke Heart - Quarter, Water, Can" from a catalog pdf, so _at_all_ depends on something -- I couldn't copy text from scanned documents, but that's to be expected. > At least it works > right most of the time with acroread. I really like being able > paste example commands or bits of code or a sentance or three Here's some copied text. When connecting a DataMan directly to an Ethernet port on a PC, both the PC and the DataMan must be configured for the same subnet. This can be done automatically though Link Local Addressing or you can manually configure your reader and your PC. > from > PDF docs into a shell or editor window. Pasting tables is a bit > more work, but it can at least be done with acroread. and a table (heading is screwed up but the data columns look ok): This also looks like it may be dependent on how the pdf was created as when I tried with a different table it wouldn't pick up all the columns cleanly. But I don't have acroreader so I couldn't compare. And when I last worked from the 4060 EDI pdf specs some ten years ago that copying most everything was a problem even in acroread -- again, a creation dependent issue I suspect. Attribute ID Access Rule Name Data Type 0x9 Set AcqTriggerEnable BOOL 0xA Set AcqTrigger BOOL 0xB Get AcqStatusRegister BYTE 0xC Set UserData ARRAY of BYTE 0xD Set BufferResultsEnable BOOL 0xE Get DecodeStatusRegister BYTE > 2) You can't print the current view. I almost never actually print these -- perhaps a page or two for notes or reference -- so I haven't hit this issue. > I find that invaluable for > printing portions of documents (e.g. I want just a section of a C > size schematic printed on letter sized paper, or just one table > table from a manual sized to fill a 8.5x11 page). If it did have > 'print view' then lack of a marquee zoom would become another > inconvenience. > > 3) There's no way to collapse-all in the TOC panel. I see a thumbnails side panel and index I can hide, but no TOC. > When I open a > 1200 page document with 30 sections and several hundred sections > and subsections, I don't want to see all of them all of the time. > Closing them one at a time by hand is pretty tedious. > > I find that about 20-30% of the time I start up evince, I end up > closing it and re-opening the document in acroread. As I don't have acroread, I find the 100% of the time evince suits my needs. When-all-you-have-is-a-hammer-ly yr's, Emile From torriem at gmail.com Tue Jul 21 18:36:43 2015 From: torriem at gmail.com (Michael Torrie) Date: Tue, 21 Jul 2015 16:36:43 -0600 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: <55AEC97B.4040401@gmail.com> On 07/21/2015 03:47 PM, Grant Edwards wrote: > I'm trying to switch from acroread to evince, bit it has a few serious > usability problems for me: > > 1) You can't copy/paste text from evince _at_all_. At least it works > right most of the time with acroread. I really like being able > paste example commands or bits of code or a sentance or three from > PDF docs into a shell or editor window. Pasting tables is a bit > more work, but it can at least be done with acroread. > > 2) You can't print the current view. I find that invaluable for > printing portions of documents (e.g. I want just a section of a C > size schematic printed on letter sized paper, or just one table > table from a manual sized to fill a 8.5x11 page). If it did have > 'print view' then lack of a marquee zoom would become another > inconvenience. > > 3) There's no way to collapse-all in the TOC panel. When I open a > 1200 page document with 30 sections and several hundred sections > and subsections, I don't want to see all of them all of the time. > Closing them one at a time by hand is pretty tedious. > > I find that about 20-30% of the time I start up evince, I end up > closing it and re-opening the document in acroread. Sounds like Evince has really gone down hill since I last used Gnome. I use Atril on Mate desktop and it works as well as Evince ever used to for me, which is expected seeing as it was forked from Gnome 2 sources. I have never had any problems cutting and pasting text. And you can definitely close the TOC panel. I wouldn't be at all surprised to see that Evince has lost capabilities. Seems to be the way Gnome apps are going these days. From breamoreboy at yahoo.co.uk Tue Jul 21 19:40:01 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 22 Jul 2015 00:40:01 +0100 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <55ac5e91$0$1642$c3e8da3$5496439d@news.astraweb.com> References: <87y4icxh4r.fsf@Equus.decebal.nl> <87mvysxe6y.fsf@Equus.decebal.nl> <991da320-d598-4ee0-865b-4cc302fe0e0a@googlegroups.com> <088e076d-90fc-46c4-a440-c1f04fdc747c@googlegroups.com> <55ac5e91$0$1642$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 20/07/2015 03:36, Steven D'Aprano wrote: > On Mon, 20 Jul 2015 06:21 am, breamoreboy at gmail.com wrote: > >> All in all though I have to admit that overall it's a really onerous task. >> Once you've produced the patch you have to go to all the trouble of >> logging on to the issue tracker, finding the appropriate issue and >> uploading the patch. You may even be inclined to make a comment. In this >> case this entire process could take as much as two whole minutes. > > It's very interesting that you ignore the two hardest parts of the process: > > (1) Producing the patch in the first place. > > (2) Convincing those with appropriate commit rights to accept the patch. > > I didn't actually intend to ignore anything, only the whole context has been altered as you've snipped the previous paragraph that led into the above. I don't know about the hardest part of the process, but I believe that the actual commit part is a PITA regardless of the size of the patch involved. The good news on that front is that the core workflow project has kick started again. The bad news is I haven't got the faintest idea what the timescale is, a year, two, I've simply no idea? One thing I do know is that it has to be made to work, as I doubt that there's a single member of the community who can be happy with the current workflow. Still in a way that is a good sign as it shows that currently Python is a victim of its own success. Once the core workflow project has succeeded, and I'll repeat that it has to, then Python will definitely achieve what Pinky and the Brain failed to do :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From rosuav at gmail.com Tue Jul 21 20:04:50 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 10:04:50 +1000 Subject: Can I copy/paste Python code? In-Reply-To: <55AEC97B.4040401@gmail.com> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> <55AEC97B.4040401@gmail.com> Message-ID: On Wed, Jul 22, 2015 at 8:36 AM, Michael Torrie wrote: > Sounds like Evince has really gone down hill since I last used Gnome. I > use Atril on Mate desktop and it works as well as Evince ever used to > for me, which is expected seeing as it was forked from Gnome 2 sources. > I have never had any problems cutting and pasting text. And you can > definitely close the TOC panel. I use Evince on Debian, where it came prepackaged with my Xfce desktop. It identifies itself as "GNOME Document Viewer 3.14.1", leaving me wondering if the next version would be 3.14.12 in Knuth-style numbering, but that's beside the point. Copying and pasting works perfectly from some documents, and imperfectly from others. Notably, it seems sometimes to be completely unaware of columns, and copy and paste text straight across the page, which leaves me staring at "zombie Ring Gates" and other gems. But it's generally good enough for my purposes. ChrisA From invalid at invalid.invalid Tue Jul 21 20:10:03 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 00:10:03 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 2015-07-21, Emile van Sebille wrote: > On 7/21/2015 2:47 PM, Grant Edwards wrote: >> On 2015-07-21, Emile van Sebille wrote: >>> On 7/21/2015 1:32 PM, Grant Edwards wrote: >>> >>>> But, it apears foxit reader is Windows-only so it's a moot point for >>>> Linux/Unix/Mac users. >>> >>> I've been happy with https://wiki.gnome.org/Apps/Evince on linux. >> >> I'm trying to switch from acroread to evince, bit it has a few serious >> usability problems for me: >> >> 1) You can't copy/paste text from evince _at_all_. > > Hmm, i just copied "Acorsa Artichoke Heart - Quarter, Water, Can" from a > catalog pdf, so _at_all_ depends on something -- I couldn't copy text > from scanned documents, but that's to be expected. Interesting. How do you do it? For all other apps, all you have to do is select the text and then center-click in the window where you want the selected text inserted. I've tried everything I can think of with evince, and it's not putting the selected text in any of the three X11 clipboards or buffers, so I'm stumped. -- Grant From invalid at invalid.invalid Tue Jul 21 20:12:34 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 00:12:34 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 2015-07-21, Michael Torrie wrote: > On 07/21/2015 03:47 PM, Grant Edwards wrote: >> I'm trying to switch from acroread to evince, bit it has a few serious >> usability problems for me: >> >> 1) You can't copy/paste text from evince _at_all_. At least it works >> right most of the time with acroread. I really like being able >> paste example commands or bits of code or a sentance or three from >> PDF docs into a shell or editor window. Pasting tables is a bit >> more work, but it can at least be done with acroread. >> >> 2) You can't print the current view. I find that invaluable for >> printing portions of documents (e.g. I want just a section of a C >> size schematic printed on letter sized paper, or just one table >> table from a manual sized to fill a 8.5x11 page). If it did have >> 'print view' then lack of a marquee zoom would become another >> inconvenience. >> >> 3) There's no way to collapse-all in the TOC panel. When I open a >> 1200 page document with 30 sections and several hundred sections >> and subsections, I don't want to see all of them all of the time. >> Closing them one at a time by hand is pretty tedious. >> >> I find that about 20-30% of the time I start up evince, I end up >> closing it and re-opening the document in acroread. > Sounds like Evince has really gone down hill since I last used Gnome. Even though I have quite a bit of Gnome stuff installed, I don't use the Gnome desktop, I use XFCE. That may be part of the problem: most "Gnome" apps seem to go out of their way not to work with other desktops. > I use Atril on Mate desktop and it works as well as Evince ever used > to for me, which is expected seeing as it was forked from Gnome 2 > sources. I have never had any problems cutting and pasting text. > And you can definitely close the TOC panel. I don't want to close the TOC panel. I want to collapse all the entries in the TOC tree widget _in_ the TOC panel. From rosuav at gmail.com Tue Jul 21 20:25:47 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 10:25:47 +1000 Subject: convert output to list(and nested dictionary) In-Reply-To: References: Message-ID: On Wed, Jul 22, 2015 at 7:12 AM, max scalf wrote: > SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(80-80) source: [67.184.225.222/32] > >>>> > > > Here is the output i am looking for.... > > > rule1 = [{ > > 'cidr': '67.184.225.222/32', > > 'proto': 'tcp', > > 'port': 80 > > },{ So if I'm understanding you correctly, one line (from your previous iteration) will become one dictionary, right? In that case, start by figuring out how to parse that line and produce that output. In the example I've quoted, it should be pretty easy (the 'rule' seems to have your proto and port, and your 'rule.grants' has the cidr), but looking over your data, I see some snags. Firstly, some of your port numbers are None-None or -1--1, and I'm not sure what those mean. (My guess: None-None occurs only when proto is -1, and -1--1 happens when proto is icmp, which doesn't use port numbers. But you'd have to investigate that.) Also, your cidr might be a list, rather than a single item. What do you do if it's empty, or if it has multiple? Third, your ports are very obviously a range (1024-65535 comes up), so you'll need to handle that. And finally, some of those rules look like things I would permit, and some look like things I'd reject. You may need to look into the rule definitions to see what you can find. But the first thing to try would be to get hold of one of those rule objects and start doing some introspection; dir(rule) and help(rule) would be where I'd start. Good luck! This shouldn't be too hard; the data seems to be all there already. ChrisA From steve at pearwood.info Tue Jul 21 20:45:29 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 22 Jul 2015 10:45:29 +1000 Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> Message-ID: <55aee7a8$0$1637$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Jul 2015 03:25 am, Laura Creighton wrote: > Lots of the problems are with the free reader, adobe acrobat. It is > designed so that the user is kept very much in a straight-jacket which > is a problem when your Mum needs, for instance, things to be in 36 point > for her to be able to read things at all because she is nearly blind. Surely Acrobat gives you the ability to set the scaling factor of the displayed page? E.g. 25%, 50%, 100%, 200%, etc? -- Steven From steve at pearwood.info Tue Jul 21 20:55:48 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 22 Jul 2015 10:55:48 +1000 Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Jul 2015 03:21 am, Antoon Pardon wrote: > On 07/19/2015 07:39 AM, Steven D'Aprano wrote: >> In Python 2, integer literals with leading zeroes are treated as octal, >> so 09 is a syntax error and 010 is 8. >> >> This is confusing to those not raised on C-style octal literals, so in >> Python 3 leading zeroes are prohibited in int literals. Octal is instead >> written using the prefix 0o, similar to hex 0x and binary 0b. >> >> Consequently Python 3 makes both 09 and 010 a syntax error. >> >> However there is one exception: zero itself is allowed any number of >> leading zeroes, so 00000 is a legal way to write zero as a base-10 int >> literal. >> >> Does anyone use that (mis)feature? >> > > Yes. I like to sometime write numbers with leading zeros. In Python 2, those numbers will be in octal: nums = [0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007, # 0008 and 0009 are syntax errors 0010, ... ] In Python 3, using leading zeroes is always a syntax error, unless all the numbers are zero: # Okay nums = [0000, 0000, 0000, 0000, ... ] # Fails nums = [0000, 0001, 0002, 0003, ...] I'm not interested in the Python 2 case with octal numbers. Can you show an example of how you would use this in Python 3? Or at least explain what benefit you get from typing out a block of all zeroes by hand, instead of (say) this? nums = [0]*10 > Sometimes these numbers represent codeblocks of a fixed > number of digits. Always writing those numbers with this > number of digits helps being aware of this. It is also > easier for when you need to know how many leading zero's > such a number has. I'm not sure what you mean here. Python ints don't have a fixed number of digits. -- Steven From torriem at gmail.com Tue Jul 21 21:03:05 2015 From: torriem at gmail.com (Michael Torrie) Date: Tue, 21 Jul 2015 19:03:05 -0600 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: <55AEEBC9.3020306@gmail.com> On 07/21/2015 06:12 PM, Grant Edwards wrote: > > I don't want to close the TOC panel. I want to collapse all the > entries in the TOC tree widget _in_ the TOC panel. Ahh. Atril does not do this either. It can collapse the TOC to the first level items but not the tree itself. I'm curious as to what good collapsing the whole tree down to one node would be. From plucena24 at gmail.com Tue Jul 21 21:03:14 2015 From: plucena24 at gmail.com (Pablo Lucena) Date: Tue, 21 Jul 2015 21:03:14 -0400 Subject: convert output to list(and nested dictionary) In-Reply-To: References: Message-ID: ?str.split and re are a nice quick way to do it: >>> def get_data(data): import re port_re = re.compile(r'(\w+)\((\S+-\S+)\)') cidr_re = re.compile(r'\[(.*?)\]') _, proto_port, cidr = data.rsplit(":", 2) port_match = port_re.search(proto_port) proto, port = port_match.group(1), port_match.group(2) port = port.split("-")[0] cidr_match = cidr_re.search(cidr) cidr = cidr_match.group(1) return dict(port=port, proto=proto, cidr=cidr) >>> get_data("SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(80-80) source: [67.184.225.222/32]") {'cidr': '67.184.225.222/32', 'proto': 'tcp', 'port': '80'} >>> get_data("SecurityGroup:wordpress-app-SG sg-99c4befc inbound: IPPermissions:-1(None-None) source: [sg-e632d982-995635159130]") {'cidr': 'sg-e632d982-995635159130', 'proto': '1', 'port': 'None'} ?You can alter this and add whatever extra checks you need as Chris A mentioned (when proto is -1 and port is None-None, or the icmp case). This is just a very crude example, but hopefully you get the drift. Most text parsing problems can easily be solved with these simple tools. Fire up your shell and test it - this is really the best way to learn how to do something like this. On Tue, Jul 21, 2015 at 5:12 PM, max scalf wrote: > Hello all, > > For Each SecurityGroup, how can i convert that into a List that in turn > will have a dictionary of the cidr block, protocol type and the port...so > from output below, the SecurityGroup called "default" had 2 > rules...allowing TCP port from 80 and 5500 to the source IP and then > SecurityGroup called "Pub_HDP_SG" had only one rule...so on and so > forth....here is the output that i am trying to get out in the form of a > list.... > > what I am planning to do is, take the list(and nested dictionary) and pass > that to a function that will in turn spitout a cloudformation template > using troposphere (something like " > http://imil.net/wp/2015/06/04/rock-your-cloudformation-with-troposphere-and-boto/ > ") > > > For Better Readablity (http://pastebin.com/rT6Aswwz) > > import boto.ec2 > > sgs = boto.ec2.connect_to_region('us-east-1').get_all_security_groups() > > for sg in sgs: > > for rule in sg.rules: > > print sg, sg.id, "inbound:", rule, " source:", rule.grants > > > SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(80-80) > source: [67.184.225.222/32] > > SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(5500-5500) > source: [67.184.225.222/32] > > SecurityGroup:Pub_HDP_SG sg-e632d982 inbound: IPPermissions:tcp(80-80) > source: [0.0.0.0/0] > > SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: > IPPermissions:tcp(22-22) source: [0.0.0.0/0] > > SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: > IPPermissions:tcp(80-80) source: [0.0.0.0/0] > > SecurityGroup:RDP Rule - open everyone sg-42d58d27 inbound: > IPPermissions:-1(None-None) source: [0.0.0.0/0] > > SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: > IPPermissions:tcp(22-22) source: [10.0.20.100/32] > > SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: > IPPermissions:tcp(53-53) source: [10.0.20.100/32] > > SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:-1(None-None) source: [sg-e632d982-995635159130] > > SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:tcp(22-22) source: [67.184.225.222/32] > > SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:tcp(1024-65535) source: [10.0.20.100/32] > > SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:tcp(80-80) source: [24.12.30.198/32] > > SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:udp(138-138) source: [10.0.20.100/32] > > SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:udp(53-53) source: [24.12.30.198/32] > > SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:tcp(30015-30015) source: [0.0.0.0/0] > > SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:icmp(-1--1) source: [10.0.20.100/32] > > SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) > source: [sg-c65a20a3-995635159130] > > SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) > source: [sg-99c4befc-995635159130] > > SecurityGroup:sg3-MySecurityGroup2-1HGPN4UF57XN6 sg-4ee73729 inbound: > IPPermissions:tcp(22-22) source: [192.168.1.12/32] > > SecurityGroup:AWS-AMI-SG sg-35568d51 inbound: IPPermissions:tcp(22-22) > source: [0.0.0.0/0] > > SecurityGroup:launch-wizard-2 sg-932255f6 inbound: > IPPermissions:tcp(22-22) source: [10.0.20.100/32] > > SecurityGroup:launch-wizard-2 sg-932255f6 inbound: > IPPermissions:tcp(443-443) source: [0.0.0.0/0] > > >>> > > > Here is the output i am looking for.... > > > rule1 = [{ > > 'cidr': '67.184.225.222/32', > > 'proto': 'tcp', > > 'port': 80 > > },{ > > 'cidr': '67.184.225.222/32', > > 'proto': 'tcp', > > 'port': 5500 > > }] > > > rule2 = [{ > > 'cidr': '[0.0.0.0/0', > > 'proto': 'tcp', > > 'port': 80 > > }] > > > rule3 = [{ > > 'cidr': '0.0.0.0/0', > > 'proto': 'tcp', > > 'port': 22 > > },{ > > 'cidr': '0.0.0.0/0', > > 'proto': 'tcp', > > 'port': 80 > > }] > > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -- *Pablo Lucena* -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at pearwood.info Tue Jul 21 21:08:13 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 22 Jul 2015 11:08:13 +1000 Subject: convert output to list(and nested dictionary) References: Message-ID: <55aeecfe$0$1638$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Jul 2015 07:12 am, max scalf wrote: > Hello all, > > For Each SecurityGroup, how can i convert that into a List that in turn > will have a dictionary of the cidr block, protocol type and the port... Start with this: def sg_to_list(sg): return [rule_to_dict(r) for r in sg.rules] def rule_to_dict(rule): d = {} # expected {'cidr': '0.0.0.0/0', 'proto': 'tcp', 'port': 80} d['cidr'] = rule.cidr d['proto'] = rule.proto d['port'] = rule.port return d and adjust until working. -- Steven From rosuav at gmail.com Tue Jul 21 21:10:45 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 11:10:45 +1000 Subject: Integers with leading zeroes In-Reply-To: <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Jul 22, 2015 at 10:55 AM, Steven D'Aprano wrote: >> Sometimes these numbers represent codeblocks of a fixed >> number of digits. Always writing those numbers with this >> number of digits helps being aware of this. It is also >> easier for when you need to know how many leading zero's >> such a number has. > > I'm not sure what you mean here. Python ints don't have a fixed number of > digits. Sometimes your numbers carry specific payloads or structures. A few examples: Date: 20150722 [decimal] Unix permissions: 10777 [octal] MAC address: 0014a466fba9 [hex] In the MAC address example, it doesn't make sense to elide the leading zeroes. I can't currently think of a common, real-world example that uses decimal and isn't gong to push itself to the full eight digits, apart from Northern Territory postcodes with their silly 08nn pattern, but I'm sure they exist. ChrisA From rosuav at gmail.com Tue Jul 21 21:11:53 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 11:11:53 +1000 Subject: convert output to list(and nested dictionary) In-Reply-To: References: Message-ID: On Wed, Jul 22, 2015 at 11:03 AM, Pablo Lucena wrote: > str.split and re are a nice quick way to do it: > >>>> def get_data(data): > import re > port_re = re.compile(r'(\w+)\((\S+-\S+)\)') > cidr_re = re.compile(r'\[(.*?)\]') > _, proto_port, cidr = data.rsplit(":", 2) > port_match = port_re.search(proto_port) > proto, port = port_match.group(1), port_match.group(2) > port = port.split("-")[0] > cidr_match = cidr_re.search(cidr) > cidr = cidr_match.group(1) > return dict(port=port, proto=proto, cidr=cidr) The textual output is coming from his quick little Python loop. No need to parse that when you can go to the underlying objects :) ChrisA From rosuav at gmail.com Tue Jul 21 21:12:56 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 11:12:56 +1000 Subject: Can I copy/paste Python code? In-Reply-To: <55AEEBC9.3020306@gmail.com> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> <55AEEBC9.3020306@gmail.com> Message-ID: On Wed, Jul 22, 2015 at 11:03 AM, Michael Torrie wrote: > On 07/21/2015 06:12 PM, Grant Edwards wrote: >> >> I don't want to close the TOC panel. I want to collapse all the >> entries in the TOC tree widget _in_ the TOC panel. > > Ahh. Atril does not do this either. It can collapse the TOC to the > first level items but not the tree itself. I'm curious as to what good > collapsing the whole tree down to one node would be. Collapse everything, then open out just the one you want. More compact display. And yes, it's a minor problem in evince, though not too bad for my usage (I can close one sub-branch, just not the whole tree). ChrisA From rantingrickjohnson at gmail.com Tue Jul 21 22:07:47 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 21 Jul 2015 19:07:47 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> Message-ID: <6e0311e4-6ff6-4160-b571-a61f927acb03@googlegroups.com> On Tuesday, July 21, 2015 at 4:22:50 PM UTC-5, bream... at gmail.com wrote: > It was actually Rustom who posted inaccurate data as only > core-devs have commit rights. Well-well. We now find ourselves before the royal court of logic: If we are to take your statement as fact, then only two possibilities exist: (a) Mark is a core dev who has committed patches and is a bully. (b) Mark is not a core dev, and therefor can not commit anything, therefor he's a bully *AND* a hypocrite! Which is it? > It would appear that your knowledge of the current > development process is as good as your knowledge of > European geography. So you've been lurking in that thread also? As with this thread, folks have mis-interpreted my words. When i get a chance to respond over there, you shall become enlightened and humbled. From steve at pearwood.info Tue Jul 21 22:14:08 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 22 Jul 2015 12:14:08 +1000 Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Jul 2015 11:10 am, Chris Angelico wrote: > On Wed, Jul 22, 2015 at 10:55 AM, Steven D'Aprano > wrote: >>> Sometimes these numbers represent codeblocks of a fixed >>> number of digits. Always writing those numbers with this >>> number of digits helps being aware of this. It is also >>> easier for when you need to know how many leading zero's >>> such a number has. >> >> I'm not sure what you mean here. Python ints don't have a fixed number of >> digits. > > Sometimes your numbers carry specific payloads or structures. A few > examples: > > Date: 20150722 [decimal] > Unix permissions: 10777 [octal] > MAC address: 0014a466fba9 [hex] I don't see the relevance of any of those examples. Only the date is kinda-sort in decimal, the others are in octal and hex and so need to be written as octal or hex numbers: perm = 0o10777 # not 25031 as the above will give addr = 0x0014a466fba9 # the above will give a syntax error The date example should be a string, not an integer. today = 20151231 tomorrow = today + 1 assert tomorrow == 20160101 # fails I guess you can have 0 as Unix permissions, there might even be a 0 MAC address, but would you write them in decimal as 0000 (etc.) when all the other perms and addresses are written in oct or hex? addresses = [ 0x0014a466fba9, 0x0014a00b3fb1, 000000000000, 0x003744a9012a, ] > In the MAC address example, it doesn't make sense to elide the leading > zeroes. I can't currently think of a common, real-world example that > uses decimal and isn't gong to push itself to the full eight digits, > apart from Northern Territory postcodes with their silly 08nn pattern, > but I'm sure they exist. Postcodes, or zip codes, also should be written as strings, even if they happen to be all digits. I'm still looking for an example of where somebody would write the int zero in decimal using more than one 0-digit. While I'm sure they are fascinating in and of themselves, examples of numbers written as strings, in hex or octal, non-zero numbers written without leading zeroes, or zero written with only a single digit don't interest me :-) -- Steven From oracle.blog3 at gmail.com Tue Jul 21 22:14:44 2015 From: oracle.blog3 at gmail.com (max scalf) Date: Tue, 21 Jul 2015 21:14:44 -0500 Subject: convert output to list(and nested dictionary) In-Reply-To: References: Message-ID: Thank you all. I have gotten some great response, so i am going to play around with this and see how it turns out. As Pablo pointed out, best way to learn is to try it out and see how it goes. Thanks again and i will keep the list posted. On Tue, Jul 21, 2015 at 8:03 PM, Pablo Lucena wrote: > ?str.split and re are a nice quick way to do it: > > >>> def get_data(data): > import re > port_re = re.compile(r'(\w+)\((\S+-\S+)\)') > cidr_re = re.compile(r'\[(.*?)\]') > _, proto_port, cidr = data.rsplit(":", 2) > port_match = port_re.search(proto_port) > proto, port = port_match.group(1), port_match.group(2) > port = port.split("-")[0] > cidr_match = cidr_re.search(cidr) > cidr = cidr_match.group(1) > return dict(port=port, proto=proto, cidr=cidr) > > >>> get_data("SecurityGroup:default sg-e1304484 inbound: > IPPermissions:tcp(80-80) source: [67.184.225.222/32]") > {'cidr': '67.184.225.222/32', 'proto': 'tcp', 'port': '80'} > >>> get_data("SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:-1(None-None) source: [sg-e632d982-995635159130]") > {'cidr': 'sg-e632d982-995635159130', 'proto': '1', 'port': 'None'} > > > ?You can alter this and add whatever extra checks you need as Chris A > mentioned (when proto is -1 and port is None-None, or the icmp case). This > is just a very crude example, but hopefully you get the drift. > > Most text parsing problems can easily be solved with these simple tools. > Fire up your shell and test it - this is really the best way to learn how > to do something like this. > > > On Tue, Jul 21, 2015 at 5:12 PM, max scalf wrote: > >> Hello all, >> >> For Each SecurityGroup, how can i convert that into a List that in turn >> will have a dictionary of the cidr block, protocol type and the port...so >> from output below, the SecurityGroup called "default" had 2 >> rules...allowing TCP port from 80 and 5500 to the source IP and then >> SecurityGroup called "Pub_HDP_SG" had only one rule...so on and so >> forth....here is the output that i am trying to get out in the form of a >> list.... >> >> what I am planning to do is, take the list(and nested dictionary) and >> pass that to a function that will in turn spitout a cloudformation template >> using troposphere (something like " >> http://imil.net/wp/2015/06/04/rock-your-cloudformation-with-troposphere-and-boto/ >> ") >> >> >> For Better Readablity (http://pastebin.com/rT6Aswwz) >> >> import boto.ec2 >> >> sgs = boto.ec2.connect_to_region('us-east-1').get_all_security_groups() >> >> for sg in sgs: >> >> for rule in sg.rules: >> >> print sg, sg.id, "inbound:", rule, " source:", rule.grants >> >> >> SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(80-80) >> source: [67.184.225.222/32] >> >> SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(5500-5500) >> source: [67.184.225.222/32] >> >> SecurityGroup:Pub_HDP_SG sg-e632d982 inbound: IPPermissions:tcp(80-80) >> source: [0.0.0.0/0] >> >> SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: >> IPPermissions:tcp(22-22) source: [0.0.0.0/0] >> >> SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: >> IPPermissions:tcp(80-80) source: [0.0.0.0/0] >> >> SecurityGroup:RDP Rule - open everyone sg-42d58d27 inbound: >> IPPermissions:-1(None-None) source: [0.0.0.0/0] >> >> SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: >> IPPermissions:tcp(22-22) source: [10.0.20.100/32] >> >> SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: >> IPPermissions:tcp(53-53) source: [10.0.20.100/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:-1(None-None) source: [sg-e632d982-995635159130] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:tcp(22-22) source: [67.184.225.222/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:tcp(1024-65535) source: [10.0.20.100/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:tcp(80-80) source: [24.12.30.198/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:udp(138-138) source: [10.0.20.100/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:udp(53-53) source: [24.12.30.198/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:tcp(30015-30015) source: [0.0.0.0/0] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:icmp(-1--1) source: [10.0.20.100/32] >> >> SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) >> source: [sg-c65a20a3-995635159130] >> >> SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) >> source: [sg-99c4befc-995635159130] >> >> SecurityGroup:sg3-MySecurityGroup2-1HGPN4UF57XN6 sg-4ee73729 inbound: >> IPPermissions:tcp(22-22) source: [192.168.1.12/32] >> >> SecurityGroup:AWS-AMI-SG sg-35568d51 inbound: IPPermissions:tcp(22-22) >> source: [0.0.0.0/0] >> >> SecurityGroup:launch-wizard-2 sg-932255f6 inbound: >> IPPermissions:tcp(22-22) source: [10.0.20.100/32] >> >> SecurityGroup:launch-wizard-2 sg-932255f6 inbound: >> IPPermissions:tcp(443-443) source: [0.0.0.0/0] >> >> >>> >> >> >> Here is the output i am looking for.... >> >> >> rule1 = [{ >> >> 'cidr': '67.184.225.222/32', >> >> 'proto': 'tcp', >> >> 'port': 80 >> >> },{ >> >> 'cidr': '67.184.225.222/32', >> >> 'proto': 'tcp', >> >> 'port': 5500 >> >> }] >> >> >> rule2 = [{ >> >> 'cidr': '[0.0.0.0/0', >> >> 'proto': 'tcp', >> >> 'port': 80 >> >> }] >> >> >> rule3 = [{ >> >> 'cidr': '0.0.0.0/0', >> >> 'proto': 'tcp', >> >> 'port': 22 >> >> },{ >> >> 'cidr': '0.0.0.0/0', >> >> 'proto': 'tcp', >> >> 'port': 80 >> >> }] >> >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> >> > > > -- > *Pablo Lucena* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanshuell at gmail.com Tue Jul 21 22:58:31 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Tue, 21 Jul 2015 19:58:31 -0700 (PDT) Subject: Is there a way to install ALL Python packages? In-Reply-To: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> Message-ID: <060f9fd7-d5d5-4f44-b5ac-b24ba4941ddd@googlegroups.com> On Monday, July 20, 2015 at 10:57:47 PM UTC-4, ryguy7272 wrote: > I'd like to install ALL Python packages on my machine. Even if it takes up 4-5GB, or more, I'd like to get everything, and then use it when I need it. Now, I'd like to import packages, like numpy and pandas, but nothing will install. I figure, if I can just install everything, I can simply use it when I need it, and if I don't need it, then I just won't use it. > > I know R offers this as an option. I figure Python must allow it too. > > Any idea how to grab everything? > > Thanks all. Thanks for the tip. I just downloaded and installed Anaconda. I just successfully ran my first Python script. So, so happy now. Thanks again!! From rosuav at gmail.com Wed Jul 22 00:16:17 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 14:16:17 +1000 Subject: Integers with leading zeroes In-Reply-To: <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Jul 22, 2015 at 12:14 PM, Steven D'Aprano wrote: > On Wed, 22 Jul 2015 11:10 am, Chris Angelico wrote: > >> On Wed, Jul 22, 2015 at 10:55 AM, Steven D'Aprano >> wrote: >>>> Sometimes these numbers represent codeblocks of a fixed >>>> number of digits. Always writing those numbers with this >>>> number of digits helps being aware of this. It is also >>>> easier for when you need to know how many leading zero's >>>> such a number has. >>> >>> I'm not sure what you mean here. Python ints don't have a fixed number of >>> digits. >> >> Sometimes your numbers carry specific payloads or structures. A few >> examples: >> >> Date: 20150722 [decimal] >> Unix permissions: 10777 [octal] >> MAC address: 0014a466fba9 [hex] > > I don't see the relevance of any of those examples. Only the date is > kinda-sort in decimal, the others are in octal and hex and so need to be > written as octal or hex numbers: > > perm = 0o10777 # not 25031 as the above will give > addr = 0x0014a466fba9 # the above will give a syntax error Right, I'm just giving examples of structured numbers. I don't have a good example of a decimal structured number, but there are good examples in other bases, and the possibility is there for someone to have one that makes sense in decimal. > The date example should be a string, not an integer. > > today = 20151231 > tomorrow = today + 1 > assert tomorrow == 20160101 # fails All that proves is that there are certain operations that don't work on date-stored-as-integer. The same operations equally won't work on date-stored-as-string. If you want date arithmetic, you MUST use a proper date/time library; but if all you want is simple and efficient comparisons, integers work fine. So do strings, but integers are right-justified. If you imagine a situation in which it's not dates with four digit years, but some other starting figure - maybe it's the year in some arbitrary calendar on which today is the 6th of Cuspis in the year 411 of the Common Reckoning. Those dates can go back before year 100, so the date numbers would lose a digit compared to today's 4110206. Hence it's useful to be able to right-justify them. Dates aren't a great example (because good date/time libraries do exist), but they're more universally understood than domain-specific examples. > I guess you can have 0 as Unix permissions, there might even be a 0 MAC > address, but would you write them in decimal as 0000 (etc.) when all the > other perms and addresses are written in oct or hex? > > addresses = [ > 0x0014a466fba9, > 0x0014a00b3fb1, > 000000000000, > 0x003744a9012a, > ] Right, so those aren't ideal examples either, because they're not decimal. > Postcodes, or zip codes, also should be written as strings, even if they > happen to be all digits. Hmm, maybe. I'm on the fence about that one. Of course, most of the time, I advocate a single multi-line text field "Address", and let people key them in free-form. No postcode field whatsoever. > I'm still looking for an example of where somebody would write the int zero > in decimal using more than one 0-digit. While I'm sure they are fascinating > in and of themselves, examples of numbers written as strings, in hex or > octal, non-zero numbers written without leading zeroes, or zero written > with only a single digit don't interest me :-) Frankly, I'm in broad agreement: using 00000000000 to represent 0 isn't particularly useful, given that 0001 is an error. But since C-like languages (and Py2) use the leading zero to mean octal, and mathematics ignores the leading zero, there's no way to avoid confusing people other than by having an instant error. There's probably code out there that uses 000 to mean 0, but personally, I wouldn't be against deprecating it. One thing that's really REALLY annoying is running into something that uses virtually the same syntax to mean something almost, but not entirely, identical... and completely incompatible. If Py3 allowed 0009 to mean 9, we would have nightmares all over the place, even without Py2/Py3 conversion. Unadorned octal still shows up in one place in Py3, and that's string escapes: >>> "\33" '\x1b' >>> b"\33" b'\x1b' I hope this *never* gets changed to decimal or hex. If it's considered a problem, the only solution is to excise it altogether. Please do NOT do what BIND9 did, and have "\033" mean 33 decimal... it bugged me no end when I tried to move some binary around between DNS and other systems... ChrisA From jsf80238 at gmail.com Wed Jul 22 00:31:53 2015 From: jsf80238 at gmail.com (Jason Friedman) Date: Tue, 21 Jul 2015 22:31:53 -0600 Subject: Address field [was: Integers with leading zeroes] Message-ID: > Of course, most of the > time, I advocate a single multi-line text field "Address", and let > people key them in free-form. No postcode field whatsoever. I'm curious about that statement. I could see accepting input as you describe above, but I'm thinking you'd want to *store* a postcode field. From rosuav at gmail.com Wed Jul 22 00:59:21 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 14:59:21 +1000 Subject: Address field [was: Integers with leading zeroes] In-Reply-To: References: Message-ID: On Wed, Jul 22, 2015 at 2:31 PM, Jason Friedman wrote: >> Of course, most of the >> time, I advocate a single multi-line text field "Address", and let >> people key them in free-form. No postcode field whatsoever. > > I'm curious about that statement. > I could see accepting input as you describe above, but I'm thinking > you'd want to *store* a postcode field. Actually, no. Apart from statisticking, there's not a lot I can do with a postcode. Due to the nature of international addressing, it's usually safest to go to one extreme or the other: either full-on address validation that knows about every delivery point in every nation that you support (viable if you support only one country, and that country's postal service offers an API - happens here in Australia), or no validation whatsoever, and a simple free-form field for people to enter what they will. Most of the times I've been setting things up, they're too low-end to justify the former, so I recommend the latter. Sure, there might be typos... but there might be those anyway, with a classic multi-part form. (I do recommend having a drop-down select box for the country, incidentally. That's easily validated.) Storing postcodes works nicely once you've settled that they're all part of a single country. When you want to do statistics on postcodes, it's not usually too hard to rip them out of the blob and work with them, but they're unreliable anyway unless you've gone the full-on validation route. So I tend to just not do the stats at all :) ChrisA From kartikjagdale11 at gmail.com Wed Jul 22 01:32:45 2015 From: kartikjagdale11 at gmail.com (Orochi) Date: Tue, 21 Jul 2015 22:32:45 -0700 (PDT) Subject: Interactive, test-driven coding challenges (algorithms and data structures) In-Reply-To: References: Message-ID: On Monday, 13 July 2015 16:50:54 UTC+5:30, donne.... at gmail.com wrote: > Repo: > https://github.com/donnemartin/interactive-coding-challenges > > Shortlink: > https://bit.ly/git-code > > Hi Everyone, > > I created a number of interactive, test-driven coding challenges. I will continue to add to the repo on a regular basis. I'm hoping you find it useful as a fun, hands-on way to learn or to sharpen your skills on algorithms and data structures, while helping yourself prep for coding interviews and coding challenges. > > Let me know if you have any questions or comments. Contributions are welcome! > > -Donne wow! Cool the challenges are awesome. will try them to improve my Algorithm and Data Structures Skills. Just a suggestion. why don't you set Python Algorithm and Data Structures challenges for "HackerRank.com" or "HackerEarth.com" From tjreedy at udel.edu Wed Jul 22 02:51:06 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 22 Jul 2015 02:51:06 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: <6e0311e4-6ff6-4160-b571-a61f927acb03@googlegroups.com> References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> <6e0311e4-6ff6-4160-b571-a61f927acb03@googlegroups.com> Message-ID: On 7/21/2015 10:07 PM, Rick Johnson wrote: > two possibilities exist: > > (a) Mark is a core dev who has committed patches and is a > bully. > > (b) Mark is not a core dev, and therefor can not commit > anything, therefor he's a bully *AND* a hypocrite! > > Which is it? Mark is not a core dev, cannot commit, and as far as I know, has never claimed such. However, he has participated on the tracker, has reviewed patches, and has submitted patches, at least one of which has been committed. His user name is BreamoreBoy and his tracker email is the same breamore@ address that recently upset you. 'BreamoreBoy' has been nosy on at least 1483 issues, over half as many as me. You, as 'RantingRick' have opened 1 issue, quickly closed, but not posted under than name on any others. https://bugs.python.org/issue8970 You sent one patch to me which I applied. Maybe there is some other activity that I missed. I would prefer it if you both stopped snipping and sniping at each other. -- Terry Jan Reedy From lac at openend.se Wed Jul 22 03:01:32 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 09:01:32 +0200 Subject: Can I copy/paste Python code? In-Reply-To: Message from "Steven D'Aprano" of "Wed, 22 Jul 2015 10:45:29 +1000." <55aee7a8$0$1637$c3e8da3$5496439d@news.astraweb.com> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <55aee7a8$0$1637$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507220701.t6M71WXg014171@fido.openend.se> In a message of Wed, 22 Jul 2015 10:45:29 +1000, "Steven D'Aprano" writes: >On Wed, 22 Jul 2015 03:25 am, Laura Creighton wrote: > >> Lots of the problems are with the free reader, adobe acrobat. It is >> designed so that the user is kept very much in a straight-jacket which >> is a problem when your Mum needs, for instance, things to be in 36 point >> for her to be able to read things at all because she is nearly blind. > >Surely Acrobat gives you the ability to set the scaling factor of the >displayed page? E.g. 25%, 50%, 100%, 200%, etc? > > > >-- >Steven The version my mother has, which is the most up to date version for her windows vista system, doesn't, for most of the documents people send her. She's absolutely stuck with the font choices somebody else made for everybody, and they aren't right for her. And this is way it is with the bulk of problems I end up having to deal with from people who get pdfs and have problems reading them -- what they want to do is outside of the range of what they are allowed to do. Laura From lac at openend.se Wed Jul 22 03:12:59 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 09:12:59 +0200 Subject: Integers with leading zeroes In-Reply-To: Message from "Steven D'Aprano" of "Wed, 22 Jul 2015 12:14:08 +1000." <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507220712.t6M7CxJO014614@fido.openend.se> The biggest use I have for decimal numbers that begin with 0 is in credit card numbers, account numbers and the like where the first check you do is 'does this thing have the correct number of digits'. So far, all the examples I've been able to find in my code -- which does this sort of stuff a lot -- is looking at string versions of decimal numbers, but I suspect there is old code out there in the wild which just used integers. Laura From lac at openend.se Wed Jul 22 03:13:54 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 09:13:54 +0200 Subject: Is there a way to install ALL Python packages? In-Reply-To: Message from ryguy7272 of "Tue, 21 Jul 2015 19:58:31 -0700." <060f9fd7-d5d5-4f44-b5ac-b24ba4941ddd@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com><060f9fd7-d5d5-4f44-b5ac-b24ba4941ddd@googlegroups.com> Message-ID: <201507220713.t6M7DsEi014658@fido.openend.se> In a message of Tue, 21 Jul 2015 19:58:31 -0700, ryguy7272 writes: >Thanks for the tip. I just downloaded and installed Anaconda. I just successfully ran my first Python script. So, so happy now. Thanks again!! Congratulations! Keep on going! :) Laura From lac at openend.se Wed Jul 22 03:31:42 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 09:31:42 +0200 Subject: Integers with leading zeroes In-Reply-To: Message from Laura Creighton of "Wed, 22 Jul 2015 09:12:59 +0200." <201507220712.t6M7CxJO014614@fido.openend.se> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com><201507220712.t6M7CxJO014614@fido.openend.se> Message-ID: <201507220731.t6M7VgTN015211@fido.openend.se> I wonder if bitcoin miners and other cryptological users need the leading 0s. Laura From breamoreboy at yahoo.co.uk Wed Jul 22 03:47:32 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 22 Jul 2015 08:47:32 +0100 Subject: Can I copy/paste Python code? In-Reply-To: <201507211725.t6LHPW1Y028074@fido.openend.se> References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 21/07/2015 18:25, Laura Creighton wrote: > In a message of Wed, 22 Jul 2015 00:48:06 +1000, Chris Angelico writes: >> Actually, maybe don't use PDF at all. I keep having to help my Mum >> deal with stupid problems with PDF documents she gets, and I'm never >> sure whether the fault is with the PDF creation software, the human >> operating said software, or limitations in the file format itself. >> >> ChrisA > > Lots of the problems are with the free reader, adobe acrobat. It is > designed so that the user is kept very much in a straight-jacket which > is a problem when your Mum needs, for instance, things to be in 36 point > for her to be able to read things at all because she is nearly blind. > > Laura > Just remembered alternativeto.net which is a rather useful site if you're looking for a replacement for some app. Just saying as I'm sure some folk will have heard of it, others won't. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From jpiitula at ling.helsinki.fi Wed Jul 22 03:55:13 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Wed, 22 Jul 2015 10:55:13 +0300 Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> <55AEC97B.4040401@gmail.com> Message-ID: Chris Angelico writes: > I use Evince on Debian, where it came prepackaged with my Xfce > desktop. It identifies itself as "GNOME Document Viewer 3.14.1", > leaving me wondering if the next version would be 3.14.12 in > Knuth-style numbering, but that's beside the point. Copying and The next digit of pi would not be 2. (But 5.) But I don't think they are doing that, because the point. From rosuav at gmail.com Wed Jul 22 04:13:56 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 18:13:56 +1000 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> <55AEC97B.4040401@gmail.com> Message-ID: On Wed, Jul 22, 2015 at 5:55 PM, Jussi Piitulainen wrote: > Chris Angelico writes: > >> I use Evince on Debian, where it came prepackaged with my Xfce >> desktop. It identifies itself as "GNOME Document Viewer 3.14.1", >> leaving me wondering if the next version would be 3.14.12 in >> Knuth-style numbering, but that's beside the point. Copying and > > The next digit of pi would not be 2. (But 5.) > > But I don't think they are doing that, because the point. Umm, yeah. Dunno why I typed a 2 there. But you knew what I meant. ChrisA From ben+python at benfinney.id.au Wed Jul 22 04:40:31 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 22 Jul 2015 18:40:31 +1000 Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> Message-ID: <85k2tsoa9s.fsf@benfinney.id.au> Laura Creighton writes: > The biggest use I have for decimal numbers that begin with 0 is in > credit card numbers, account numbers and the like where the first > check you do is 'does this thing have the correct number of digits'. The following are examples of types from the real world that people think of, and casually discuss, as ?numbers?. * Postal code * Credit card number * Telephone number * Car registration plate number * Personal Identification Number (PIN) You can no doubt come up with other examples. Despite that they are represented in text with digits, and the authority that generates them may even use some sequence of integers, the types should not be treated as numbers. They are not quantities. Performing arithmetic on them (adding two together, dividing by two, etc.) makes no sense. Representing them in a different number base (e.g. hexadecimal) utterly changes their meaning. And, as you've found, a leading zero makes a difference to the value. To a computer (ignoring the legacy of octal representation), that makes nonsense of the idea these are numbers. So these types are not numbers and should not be treated that way in the program. These are, from the point of view of your computer program, opaque tokens. They should be encoded not using a number type, but a type which represents them as only a string of decimal digits. Best if they're stored without spaces or punctuation; convert to and from some format for human use if you must, but only at the input/output borders of the program. > So far, all the examples I've been able to find in my code -- which > does this sort of stuff a lot -- is looking at string versions of > decimal numbers, but I suspect there is old code out there in the > wild which just used integers. Maybe so, but I consider the latter kind of code to be a terrible practice since it leads to assumptions in the code which are unfounded, and which no human would ever make. Treat them the way a human actually would: as an opaque tokem, a text (sequence of characters) that happen to contain digits. -- \ ?Simplicity is prerequisite for reliability.? ?Edsger W. | `\ Dijkstra | _o__) | Ben Finney From alister.nospam.ware at ntlworld.com Wed Jul 22 05:09:27 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Wed, 22 Jul 2015 09:09:27 +0000 (UTC) Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, 22 Jul 2015 09:12:59 +0200, Laura Creighton wrote: > The biggest use I have for decimal numbers that begin with 0 is in > credit card numbers, account numbers and the like where the first check > you do is 'does this thing have the correct number of digits'. > So far, all the examples I've been able to find in my code -- which does > this sort of stuff a lot -- is looking at string versions of decimal > numbers, but I suspect there is old code out there in the wild which > just used integers. > > Laura This type of information should be stored as a string not any type of numeric format, if you are not performing maths on it then it is a string & not a number. anyone doing anything else is heading or the front page on www.thedailywtf.com :-) -- Everybody likes a kidder, but nobody lends him money. -- Arthur Miller From marko at pacujo.net Wed Jul 22 05:10:55 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 22 Jul 2015 12:10:55 +0300 Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> Message-ID: <878ua8imlc.fsf@elektro.pacujo.net> Ben Finney : > Despite that they are represented in text with digits, and the > authority that generates them may even use some sequence of integers, > the types should not be treated as numbers. Let's just say that the word "number" has multiple meanings. Words with many meanings often lead to confusion. My native Finnish luckily has distinct words for the two things: "luku" (a quantity) and "numero" (a digit, numeral or label): luonnollinen luku (natural number) kokonaisluku (integer) rationaaliluku (rational number) reaaliluku (real number) kompleksiluku (complex number) liukuluku (floating-point number) desimaaliluku (decimal number) puhelinnumero (telephone number) rekisterinumero (registration number, license plate number) tilinumero (account number) huoneen numero (room number) sarjanumero (serial number) tuotenumero (product number) Obviously, the words "liukuluku" and "desimaaliluku" slide into the realms of numerals, but nevertheless, they deal with quantification rather than identification. Marko From lac at openend.se Wed Jul 22 05:38:46 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 11:38:46 +0200 Subject: Integers with leading zeroes In-Reply-To: Message from Marko Rauhamaa of "Wed, 22 Jul 2015 12:10:55 +0300." <878ua8imlc.fsf@elektro.pacujo.net> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> <878ua8imlc.fsf@elektro.pacujo.net> Message-ID: <201507220938.t6M9ck5A018054@fido.openend.se> In a message of Wed, 22 Jul 2015 12:10:55 +0300, Marko Rauhamaa writes: >My native Finnish luckily has distinct words for the two things: "luku" >(a quantity) and "numero" (a digit, numeral or label): > > luonnollinen luku (natural number) > kokonaisluku (integer) > rationaaliluku (rational number) > reaaliluku (real number) > kompleksiluku (complex number) > liukuluku (floating-point number) > desimaaliluku (decimal number) > > puhelinnumero (telephone number) > rekisterinumero (registration number, license plate number) > tilinumero (account number) > huoneen numero (room number) > sarjanumero (serial number) > tuotenumero (product number) > >Obviously, the words "liukuluku" and "desimaaliluku" slide into the >realms of numerals, but nevertheless, they deal with quantification >rather than identification. > > >Marko What I want to know is why is 'huoneen numero' 2 words? Laura From songofacandy at gmail.com Wed Jul 22 06:15:11 2015 From: songofacandy at gmail.com (INADA Naoki) Date: Wed, 22 Jul 2015 19:15:11 +0900 Subject: Integers with leading zeroes In-Reply-To: <55AE7F85.6010609@rece.vub.ac.be> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55AE7F85.6010609@rece.vub.ac.be> Message-ID: Permitting leading 0s may make it harder to port Python 2 projects to Python 3. 010 == 8 (Python 2) 010 == 10 (Python 3.x) SyntaxError is very important for porting code. So I'm -1 on permitting leading 0s for decimal numbers. I think original question is for leading 0s for only 0. Not for arbitrarily decimals. On Wed, Jul 22, 2015 at 2:21 AM, Antoon Pardon wrote: > On 07/19/2015 07:39 AM, Steven D'Aprano wrote: > > In Python 2, integer literals with leading zeroes are treated as octal, > so > > 09 is a syntax error and 010 is 8. > > > > This is confusing to those not raised on C-style octal literals, so in > > Python 3 leading zeroes are prohibited in int literals. Octal is instead > > written using the prefix 0o, similar to hex 0x and binary 0b. > > > > Consequently Python 3 makes both 09 and 010 a syntax error. > > > > However there is one exception: zero itself is allowed any number of > leading > > zeroes, so 00000 is a legal way to write zero as a base-10 int literal. > > > > Does anyone use that (mis)feature? > > > > Yes. I like to sometime write numbers with leading zeros. > Sometimes these numbers represent codeblocks of a fixed > number of digits. Always writing those numbers with this > number of digits helps being aware of this. It is also > easier for when you need to know how many leading zero's > such a number has. > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- INADA Naoki -------------- next part -------------- An HTML attachment was scrubbed... URL: From techtonik at gmail.com Wed Jul 22 06:17:59 2015 From: techtonik at gmail.com (anatoly techtonik) Date: Wed, 22 Jul 2015 13:17:59 +0300 Subject: Encoding of Python 2 string literals Message-ID: Hi, Is there a way to know encoding of string (bytes) literal defined in source file? For example, given that source: # -*- coding: utf-8 -*- from library import Entry Entry("?????") Is there any way for Entry() constructor to know that string "?????" passed into it is the utf-8 string? I need to better prepare SCons for Python 3 migration. Please, CC. -- anatoly t. -------------- next part -------------- An HTML attachment was scrubbed... URL: From marko at pacujo.net Wed Jul 22 06:26:36 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 22 Jul 2015 13:26:36 +0300 Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> <878ua8imlc.fsf@elektro.pacujo.net> Message-ID: <87zj2oh4ir.fsf@elektro.pacujo.net> Laura Creighton : > What I want to know is why is 'huoneen numero' 2 words? rummets nummer Marko From rosuav at gmail.com Wed Jul 22 08:39:56 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Jul 2015 22:39:56 +1000 Subject: Encoding of Python 2 string literals In-Reply-To: References: Message-ID: On Wed, Jul 22, 2015 at 8:17 PM, anatoly techtonik wrote: > Is there a way to know encoding of string (bytes) literal > defined in source file? For example, given that source: > > # -*- coding: utf-8 -*- > from library import Entry > Entry("?????") > > Is there any way for Entry() constructor to know that > string "?????" passed into it is the utf-8 string? I don't think so. However, if you declare that to be a Unicode string, the parser will decode it using the declared encoding, and it'll be a five-character string. At that point, it doesn't matter what your source encoding was, because the characters entered will match the characters seen. Entry(u"?????") ChrisA From rustompmody at gmail.com Wed Jul 22 09:34:28 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 22 Jul 2015 06:34:28 -0700 (PDT) Subject: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> Message-ID: <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> On Tuesday, July 21, 2015 at 4:09:56 PM UTC+5:30, Steven D'Aprano wrote: > We have no reason to expect that the natural numbers are anything less than > "absolutely fundamental and irreducible" (as the Wikipedia article above > puts it). It's remarkable that we can reduce all of mathematics to > essentially a single axiom: the concept of the set. These two statements above contradict each other. With the double-negatives and other lint removed they read: 1. We have reason to expect that the natural numbers are absolutely fundamental and irreducible 2. We can reduce all of mathematics to essentially a single axiom: the concept of the set. So are you on the number-side -- Poincare, Brouwer, Heyting... Or the set-side -- Cantor, Russel, Hilbert... ?? > On Tuesday 21 July 2015 19:10, Marko Rauhamaa wrote: > > Our ancestors defined the fingers (or digits) as "the set of numbers." > > Modern mathematicians have managed to enhance the definition > > quantitatively but not qualitatively. > > So what? > > This is not a problem for the use of numbers in science, engineering or > mathematics (including computer science, which may be considered a branch of > all three). There may be still a few holdouts who hope that G?del is wrong > and Russell's dream of being able to define all of mathematics in terms of > logic can be resurrected, but everyone else has moved on, and don't consider > it to be "an embarrassment" any more than it is an embarrassment that all of > philosophy collapses in a heap when faced with solipsism. That's a bizarre view. As a subjective view "I dont feel embarrassed by..." its not arguable other than to say embarrassment is like thick-skinnedness -- some have elephant-skins some have gossamer skins As an objective view its just wrong: Eminent mathematicians have disagreed so strongly with each other as to what putative math is kosher and what embarrassing that they've sent each other to mental institutions. And -- most important of all -- these arguments are at the root of why CS 'happened' : http://blog.languager.org/2015/03/cs-history-0.html The one reason why this view -- "the embarrassments in math/logic foundations are no longer relevant as they were in the 1930s" -- is because people think CS is mostly engineering, hardly math. So (the argument runs) just as general relativity is irrelevant to bridge-building, so also meta-mathematics is to pragmatic CS. The answer to this view -- unfortunately widely-held -- is the same as above: http://blog.languager.org/2015/03/cs-history-0.html A knowledge of the history will disabuse of the holder of these misunderstandings and misconceptions From invalid at invalid.invalid Wed Jul 22 09:51:14 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 13:51:14 +0000 (UTC) Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> Message-ID: On 2015-07-22, Ben Finney wrote: > Laura Creighton writes: > >> The biggest use I have for decimal numbers that begin with 0 is in >> credit card numbers, account numbers and the like where the first >> check you do is 'does this thing have the correct number of digits'. > > The following are examples of types from the real world that people > think of, and casually discuss, as ?numbers?. > > * Postal code > * Credit card number > * Telephone number > * Car registration plate number > * Personal Identification Number (PIN) Those are all strings. Not numbers. -- Grant Edwards grant.b.edwards Yow! does your DRESSING at ROOM have enough ASPARAGUS? gmail.com From invalid at invalid.invalid Wed Jul 22 09:54:22 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 13:54:22 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <55aee7a8$0$1637$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2015-07-22, Laura Creighton wrote: > She's absolutely stuck with the font choices somebody > else made for everybody, Once again, that is the whole _point_ of PDF. > and they aren't right for her. > And this is way it is with the bulk of problems I end up having > to deal with from people who get pdfs and have problems reading > them -- what they want to do is outside of the range of what > they are allowed to do. The entire purpose of PDF is to prevent people from changing the format and appearance of documents. -- Grant Edwards grant.b.edwards Yow! I hope I bought the at right relish ... zzzzzzzzz gmail.com ... From rustompmody at gmail.com Wed Jul 22 10:03:38 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 22 Jul 2015 07:03:38 -0700 (PDT) Subject: Integers with leading zeroes In-Reply-To: References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> Message-ID: <9e864177-9677-484a-9486-8961310fac8c@googlegroups.com> On Wednesday, July 22, 2015 at 7:21:29 PM UTC+5:30, Grant Edwards wrote: > On 2015-07-22, Ben Finney wrote: > > Laura Creighton writes: > > > >> The biggest use I have for decimal numbers that begin with 0 is in > >> credit card numbers, account numbers and the like where the first > >> check you do is 'does this thing have the correct number of digits'. > > > > The following are examples of types from the real world that people > > think of, and casually discuss, as "numbers". > > > > * Postal code > > * Credit card number > > * Telephone number > > * Car registration plate number > > * Personal Identification Number (PIN) > > Those are all strings. Not numbers. Cobol would represent these well (if I remember rightly) as PIC 9(n) USAGE DISPLAY The USAGE DISPLAY was the default and unnecessary to state explicitly whereas the alternative USAGE COMP(UTATIONAL) corresponds to what most post-COBOL programmers think of as (binary) numbers. [Just sayin'... NOT asking for python to have 'usage display' ints] From lac at openend.se Wed Jul 22 10:12:49 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 16:12:49 +0200 Subject: Encoding of Python 2 string literals In-Reply-To: Message from Chris Angelico of "Wed, 22 Jul 2015 22:39:56 +1000." References: Message-ID: <201507221412.t6MECne0024265@fido.openend.se> In a message of Wed, 22 Jul 2015 22:39:56 +1000, Chris Angelico writes: >On Wed, Jul 22, 2015 at 8:17 PM, anatoly techtonik wrote: >> Is there a way to know encoding of string (bytes) literal >> defined in source file? For example, given that source: >> >> # -*- coding: utf-8 -*- >> from library import Entry >> Entry("?????") >> >> Is there any way for Entry() constructor to know that >> string "?????" passed into it is the utf-8 string? > >I don't think so. However, if you declare that to be a Unicode string, >the parser will decode it using the declared encoding, and it'll be a >five-character string. At that point, it doesn't matter what your >source encoding was, because the characters entered will match the >characters seen. > >Entry(u"?????") > >ChrisA Since you are porting to 3.x, anatoly this will be of interest to you. https://www.python.org/dev/peps/pep-0414/ Having stuck all the u" into your codebase you won't immediately have to rip them all out again as long as you use Python 3.3 or above. Laura From lac at openend.se Wed Jul 22 10:37:22 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 16:37:22 +0200 Subject: Can I copy/paste Python code? In-Reply-To: Message from Grant Edwards of "Wed, 22 Jul 2015 13:54:22 -0000." References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <55aee7a8$0$1637$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507221437.t6MEbM8M024850@fido.openend.se> In a message of Wed, 22 Jul 2015 13:54:22 -0000, Grant Edwards writes: >On 2015-07-22, Laura Creighton wrote: > >> She's absolutely stuck with the font choices somebody >> else made for everybody, > >Once again, that is the whole _point_ of PDF. > >> and they aren't right for her. > >> And this is way it is with the bulk of problems I end up having >> to deal with from people who get pdfs and have problems reading >> them -- what they want to do is outside of the range of what >> they are allowed to do. > >The entire purpose of PDF is to prevent people from changing the >format and appearance of documents. > >-- >Grant Edwards grant.b.edwards Yow! I hope I bought the > at right relish ... zzzzzzzzz > gmail.com ... >-- My problem isn't that I don't understand this, my problem is that I think this is, in nearly all cases, morally the wrong thing to do. And very often not what the document creator wanted in the first place -- they are using 'the Portable Document Format' because they expect it to be readable by everybody. And the upshot of this is that people send me PDFs that they cannot use for some reason, and I get out reportlab and hack the PDF to be something they can use, and send it back to them -- which I can pretty much always do, unless the PDF uses a lot of bitmaps. So this means that producing a reader that could do exactly what I do is well within the abilities of Adobe. But people who aren't as technologically sophisticated as I am, or who don't have access to such a person have to suffer. This is not a tehcnical limitation, but a political one. Should Adobe get hit with a ton of lawsuits from disabled people claiming unfair discrimination, they could change this policy overnight. Have the possibility of unchanging documents for the very rare times when that is wanted and indeed needed, and the rest of the time let the readers look at their docs any way they like. Laura From steve at pearwood.info Wed Jul 22 10:38:16 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 00:38:16 +1000 Subject: Encoding of Python 2 string literals References: Message-ID: <55afaad8$0$1646$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Jul 2015 08:17 pm, anatoly techtonik wrote: > Hi, > > Is there a way to know encoding of string (bytes) literal > defined in source file? For example, given that source: > > # -*- coding: utf-8 -*- > from library import Entry > Entry("?????") > > Is there any way for Entry() constructor to know that > string "?????" passed into it is the utf-8 string? No. The entry constructor will receive a BYTE string, not a Unicode string, containing some sequence of bytes. If the coding cookie is accurate, then it will be the UTF-8 encoding of that string, namely: '\xd1\x82\xd0\xb5\xd0\xba\xd1\x81\xd1\x82' If you print those bytes, at least under Linux, your terminal will probably interpret them as UTF-8 and display it as ????? but don't be fooled, the string has length 10 (not 5). If the coding cookie is not accurate, you will get something else. Probably garbage, possibly a syntax error. Let's say you saved the text file using the koi8-r encoding, but the coding cookie says utf-8. Then the text file will actually contain bytes \xd4\xc5\xcb\xd3\xd4, but Python will try to read those bytes as UTF-8, which is invalid. So at best you will get a syntax error, at worst garbage text. The right way to deal with this is to use an actual Unicode string: Entry(u"?????") and make sure that the file is saved using UTF-8, as the encoding cookie says. > I need to better prepare SCons for Python 3 migration. The first step is to use proper Unicode strings u'' in Python 2. It is acceptable to drop support for Python 3.1 and 3.2, and only support 3.3 and better. The advantage of this is that 3.3 supports the u'' string prefix. If you must support 3.1 and 3.2 as well, there is no good solution, just ugly ones. -- Steven From invalid at invalid.invalid Wed Jul 22 10:53:42 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 14:53:42 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <55aee7a8$0$1637$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2015-07-22, Laura Creighton wrote: >>The entire purpose of PDF is to prevent people from changing the >>format and appearance of documents. > My problem isn't that I don't understand this, my problem is that I > think this is, in nearly all cases, morally the wrong thing to do. > > So this means that producing a reader that could do exactly what I do > is well within the abilities of Adobe. But people who aren't as > technologically sophisticated as I am, or who don't have access to > such a person have to suffer. This is not a tehcnical limitation, > but a political one. OK, so the problem is that apparently people are using PDF when they should be using something else (probably one of the e-book formats that allow the reader to select font and format -- or maybe just text). Personally, I've never seen an PDF document/reader combination that didn't allow magnification, but just magnifying then entire document is a pretty lousy way to make the letters bigger. > Should Adobe get hit with a ton of lawsuits from disabled people > claiming unfair discrimination, they could change this policy > overnight. It's not Adobe's fault. PDF isn't _supposed_ to allow the reader to change the format. It's the fault of people who are chosing to generate PDF documents when they should be using something else. Asking for PDF to allow the user to change the way the document looks is like asking for gasoline that isn't flammable. > Have the possibility of unchanging documents for the very rare times > when that is wanted and indeed needed, and the rest of the time let > the readers look at their docs any way they like. That's _exactly_ what HTML was supposed to be. Now it's been broken and turned into another PDF by "web designers" who think everybody has the exact same monitor, OS, browser, eyes and brain that they have. -- Grant Edwards grant.b.edwards Yow! I'm a fuschia bowling at ball somewhere in Brittany gmail.com From rosuav at gmail.com Wed Jul 22 10:54:16 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Jul 2015 00:54:16 +1000 Subject: Encoding of Python 2 string literals In-Reply-To: <55afaad8$0$1646$c3e8da3$5496439d@news.astraweb.com> References: <55afaad8$0$1646$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Jul 23, 2015 at 12:38 AM, Steven D'Aprano wrote: > On Wed, 22 Jul 2015 08:17 pm, anatoly techtonik wrote: > >> Hi, >> >> Is there a way to know encoding of string (bytes) literal >> defined in source file? For example, given that source: >> >> # -*- coding: utf-8 -*- >> from library import Entry >> Entry("?????") >> >> Is there any way for Entry() constructor to know that >> string "?????" passed into it is the utf-8 string? > > No. > > The entry constructor will receive a BYTE string, not a Unicode string, > containing some sequence of bytes. > > If the coding cookie is accurate, then it will be the UTF-8 encoding of that > string, namely: > > '\xd1\x82\xd0\xb5\xd0\xba\xd1\x81\xd1\x82' > > If you print those bytes, at least under Linux, your terminal will probably > interpret them as UTF-8 and display it as ????? but don't be fooled, the > string has length 10 (not 5). > > If the coding cookie is not accurate, you will get something else. Probably > garbage, possibly a syntax error. Let's say you saved the text file using > the koi8-r encoding, but the coding cookie says utf-8. Then the text file > will actually contain bytes \xd4\xc5\xcb\xd3\xd4, but Python will try to > read those bytes as UTF-8, which is invalid. So at best you will get a > syntax error, at worst garbage text. AIUI the problem is more along these lines: 1) Put Unicode text into .py file, with a correct coding cookie 2) Part of that text is a quoted byte-string literal, which will capture those bytes. 3) The byte string is then passed along to another module. 4) ??? 5) The other module decodes the bytes to Unicode, using the specified encoding. The hole is step 4, as there's no way (AFAIK) to find out what encoding a source file used. But the solution isn't to find out the encoding... the solution is... > The right way to deal with this is to use an actual Unicode string: > > Entry(u"?????") > > and make sure that the file is saved using UTF-8, as the encoding cookie > says. ... this. Downside is that this MAY require changes to the API, as it now has to take Unicode strings everywhere instead of byte strings. Upside: That's probably what your code is trying to do anyway. > It is acceptable to drop support for Python 3.1 and 3.2, and only support > 3.3 and better. The advantage of this is that 3.3 supports the u'' string > prefix. If you must support 3.1 and 3.2 as well, there is no good solution, > just ugly ones. Definitely. If you're only just migrating now, 3.2 is in security-fix-only mode, and will be out of that within a year. Aim at 3.3+ and take advantage of u"..." compatibility, or even go a bit further, aim at 3.5+ and make use of bytestring percent formatting. Depends what you need, but I wouldn't bother supporting 3.2 if it's any hassle. ChrisA From steve at pearwood.info Wed Jul 22 11:14:40 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 01:14:40 +1000 Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> Message-ID: <55afb360$0$1651$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Jul 2015 11:51 pm, Grant Edwards wrote: > On 2015-07-22, Ben Finney wrote: >> Laura Creighton writes: >> >>> The biggest use I have for decimal numbers that begin with 0 is in >>> credit card numbers, account numbers and the like where the first >>> check you do is 'does this thing have the correct number of digits'. >> >> The following are examples of types from the real world that people >> think of, and casually discuss, as ?numbers?. >> >> * Postal code >> * Credit card number >> * Telephone number >> * Car registration plate number >> * Personal Identification Number (PIN) > > Those are all strings. Not numbers. I'm pretty sure that was Ben's point :-) -- Steven From invalid at invalid.invalid Wed Jul 22 11:20:24 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 15:20:24 +0000 (UTC) Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> <55afb360$0$1651$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2015-07-22, Steven D'Aprano wrote: > On Wed, 22 Jul 2015 11:51 pm, Grant Edwards wrote: > >> On 2015-07-22, Ben Finney wrote: >>> Laura Creighton writes: >>> >>>> The biggest use I have for decimal numbers that begin with 0 is in >>>> credit card numbers, account numbers and the like where the first >>>> check you do is 'does this thing have the correct number of digits'. >>> >>> The following are examples of types from the real world that people >>> think of, and casually discuss, as ?numbers?. >>> >>> * Postal code >>> * Credit card number >>> * Telephone number >>> * Car registration plate number >>> * Personal Identification Number (PIN) >> >> Those are all strings. Not numbers. > > I'm pretty sure that was Ben's point :-) Ah yes, now I see it was. -- Grant Edwards grant.b.edwards Yow! HELLO, everybody, at I'm a HUMAN!! gmail.com From antoon.pardon at rece.vub.ac.be Wed Jul 22 11:27:47 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Wed, 22 Jul 2015 17:27:47 +0200 Subject: Integers with leading zeroes In-Reply-To: References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55AFB673.4040100@rece.vub.ac.be> On 07/22/2015 11:09 AM, alister wrote: > On Wed, 22 Jul 2015 09:12:59 +0200, Laura Creighton wrote: > >> The biggest use I have for decimal numbers that begin with 0 is in >> credit card numbers, account numbers and the like where the first check >> you do is 'does this thing have the correct number of digits'. >> So far, all the examples I've been able to find in my code -- which does >> this sort of stuff a lot -- is looking at string versions of decimal >> numbers, but I suspect there is old code out there in the wild which >> just used integers. >> >> Laura > > This type of information should be stored as a string not any type of > numeric format, if you are not performing maths on it then it is a string > & not a number. Does the same condition hold for strings? If you are not performing string operations on something, it is not a string? -- Antoon Pardon. From python at mrabarnett.plus.com Wed Jul 22 11:38:20 2015 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 22 Jul 2015 16:38:20 +0100 Subject: Integers with leading zeroes In-Reply-To: <55AFB673.4040100@rece.vub.ac.be> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <55AFB673.4040100@rece.vub.ac.be> Message-ID: <55AFB8EC.7070708@mrabarnett.plus.com> On 2015-07-22 16:27, Antoon Pardon wrote: > On 07/22/2015 11:09 AM, alister wrote: >> On Wed, 22 Jul 2015 09:12:59 +0200, Laura Creighton wrote: >> >>> The biggest use I have for decimal numbers that begin with 0 is in >>> credit card numbers, account numbers and the like where the first check >>> you do is 'does this thing have the correct number of digits'. >>> So far, all the examples I've been able to find in my code -- which does >>> this sort of stuff a lot -- is looking at string versions of decimal >>> numbers, but I suspect there is old code out there in the wild which >>> just used integers. >>> >>> Laura >> >> This type of information should be stored as a string not any type of >> numeric format, if you are not performing maths on it then it is a string >> & not a number. > > Does the same condition hold for strings? If you are not performing string > operations on something, it is not a string? > Tkinter comes to mind. You specify how widgets are laid out strings that are basically flags: text_widget.pack(side=LEFT, fill=BOTH, expand=YES) where LEFT, BOTH and YES are strings. From invalid at invalid.invalid Wed Jul 22 11:47:08 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 15:47:08 +0000 (UTC) Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2015-07-22, Antoon Pardon wrote: > Does the same condition hold for strings? If you are not performing string > operations on something, it is not a string? If you never need to do any string operations on it then you should not be using a string. -- Grant Edwards grant.b.edwards Yow! The PINK SOCKS were at ORIGINALLY from 1952!! gmail.com But they went to MARS around 1953!! From invalid at invalid.invalid Wed Jul 22 11:50:16 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 15:50:16 +0000 (UTC) Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <55AFB673.4040100@rece.vub.ac.be> Message-ID: On 2015-07-22, MRAB wrote: > On 2015-07-22 16:27, Antoon Pardon wrote: > >> Does the same condition hold for strings? If you are not performing string >> operations on something, it is not a string? > > Tkinter comes to mind. You specify how widgets are laid out strings > that are basically flags: > > text_widget.pack(side=LEFT, fill=BOTH, expand=YES) > > where LEFT, BOTH and YES are strings. That's Tcl's fault. They have to be passed to Tcl, and Tcl only has one data type: strings. -- Grant Edwards grant.b.edwards Yow! An INK-LING? Sure -- at TAKE one!! Did you BUY any gmail.com COMMUNIST UNIFORMS?? From oracle.blog3 at gmail.com Wed Jul 22 12:01:35 2015 From: oracle.blog3 at gmail.com (max scalf) Date: Wed, 22 Jul 2015 11:01:35 -0500 Subject: convert output to list(and nested dictionary) In-Reply-To: References: Message-ID: Hi Pablo, While playing around with the function you gave me(get_data)...i was thinking to do something like below. For each line create a dictionary then append that dictionary to a list...but before i even get to that part i get the below error and while researching it i am unable to figure out what is going on... could you point me in the right direction ? >>> for sg in sgs: for rule in sg.rules: pt = sg, sg.id, "inbound:", rule, " source:", rule.grants print pt #this is just for my own purpose get_data(pt) (SecurityGroup:wordpress-app-SG, u'sg-99c4befc', 'inbound:', IPPermissions:-1(None-None), ' source:', [sg-e632d982-995635159130]) Traceback (most recent call last): File "", line 5, in get_data(pt) File "", line 5, in get_data _, proto_port, cidr = data.rsplit(":", 2) AttributeError: 'tuple' object has no attribute 'rsplit' >>> get_data("SecurityGroup:wordpress-app-SG, u'sg-99c4befc', 'inbound:', IPPermissions:-1(None-None), ' source:', [sg-e632d982-995635159130]") {'cidr': 'sg-e632d982-995635159130', 'port': 'None', 'proto': '1'} >>> On Tue, Jul 21, 2015 at 8:03 PM, Pablo Lucena wrote: > ?str.split and re are a nice quick way to do it: > > >>> def get_data(data): > import re > port_re = re.compile(r'(\w+)\((\S+-\S+)\)') > cidr_re = re.compile(r'\[(.*?)\]') > _, proto_port, cidr = data.rsplit(":", 2) > port_match = port_re.search(proto_port) > proto, port = port_match.group(1), port_match.group(2) > port = port.split("-")[0] > cidr_match = cidr_re.search(cidr) > cidr = cidr_match.group(1) > return dict(port=port, proto=proto, cidr=cidr) > > >>> get_data("SecurityGroup:default sg-e1304484 inbound: > IPPermissions:tcp(80-80) source: [67.184.225.222/32]") > {'cidr': '67.184.225.222/32', 'proto': 'tcp', 'port': '80'} > >>> get_data("SecurityGroup:wordpress-app-SG sg-99c4befc inbound: > IPPermissions:-1(None-None) source: [sg-e632d982-995635159130]") > {'cidr': 'sg-e632d982-995635159130', 'proto': '1', 'port': 'None'} > > > ?You can alter this and add whatever extra checks you need as Chris A > mentioned (when proto is -1 and port is None-None, or the icmp case). This > is just a very crude example, but hopefully you get the drift. > > Most text parsing problems can easily be solved with these simple tools. > Fire up your shell and test it - this is really the best way to learn how > to do something like this. > > > On Tue, Jul 21, 2015 at 5:12 PM, max scalf wrote: > >> Hello all, >> >> For Each SecurityGroup, how can i convert that into a List that in turn >> will have a dictionary of the cidr block, protocol type and the port...so >> from output below, the SecurityGroup called "default" had 2 >> rules...allowing TCP port from 80 and 5500 to the source IP and then >> SecurityGroup called "Pub_HDP_SG" had only one rule...so on and so >> forth....here is the output that i am trying to get out in the form of a >> list.... >> >> what I am planning to do is, take the list(and nested dictionary) and >> pass that to a function that will in turn spitout a cloudformation template >> using troposphere (something like " >> http://imil.net/wp/2015/06/04/rock-your-cloudformation-with-troposphere-and-boto/ >> ") >> >> >> For Better Readablity (http://pastebin.com/rT6Aswwz) >> >> import boto.ec2 >> >> sgs = boto.ec2.connect_to_region('us-east-1').get_all_security_groups() >> >> for sg in sgs: >> >> for rule in sg.rules: >> >> print sg, sg.id, "inbound:", rule, " source:", rule.grants >> >> >> SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(80-80) >> source: [67.184.225.222/32] >> >> SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(5500-5500) >> source: [67.184.225.222/32] >> >> SecurityGroup:Pub_HDP_SG sg-e632d982 inbound: IPPermissions:tcp(80-80) >> source: [0.0.0.0/0] >> >> SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: >> IPPermissions:tcp(22-22) source: [0.0.0.0/0] >> >> SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: >> IPPermissions:tcp(80-80) source: [0.0.0.0/0] >> >> SecurityGroup:RDP Rule - open everyone sg-42d58d27 inbound: >> IPPermissions:-1(None-None) source: [0.0.0.0/0] >> >> SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: >> IPPermissions:tcp(22-22) source: [10.0.20.100/32] >> >> SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: >> IPPermissions:tcp(53-53) source: [10.0.20.100/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:-1(None-None) source: [sg-e632d982-995635159130] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:tcp(22-22) source: [67.184.225.222/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:tcp(1024-65535) source: [10.0.20.100/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:tcp(80-80) source: [24.12.30.198/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:udp(138-138) source: [10.0.20.100/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:udp(53-53) source: [24.12.30.198/32] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:tcp(30015-30015) source: [0.0.0.0/0] >> >> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:icmp(-1--1) source: [10.0.20.100/32] >> >> SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) >> source: [sg-c65a20a3-995635159130] >> >> SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) >> source: [sg-99c4befc-995635159130] >> >> SecurityGroup:sg3-MySecurityGroup2-1HGPN4UF57XN6 sg-4ee73729 inbound: >> IPPermissions:tcp(22-22) source: [192.168.1.12/32] >> >> SecurityGroup:AWS-AMI-SG sg-35568d51 inbound: IPPermissions:tcp(22-22) >> source: [0.0.0.0/0] >> >> SecurityGroup:launch-wizard-2 sg-932255f6 inbound: >> IPPermissions:tcp(22-22) source: [10.0.20.100/32] >> >> SecurityGroup:launch-wizard-2 sg-932255f6 inbound: >> IPPermissions:tcp(443-443) source: [0.0.0.0/0] >> >> >>> >> >> >> Here is the output i am looking for.... >> >> >> rule1 = [{ >> >> 'cidr': '67.184.225.222/32', >> >> 'proto': 'tcp', >> >> 'port': 80 >> >> },{ >> >> 'cidr': '67.184.225.222/32', >> >> 'proto': 'tcp', >> >> 'port': 5500 >> >> }] >> >> >> rule2 = [{ >> >> 'cidr': '[0.0.0.0/0', >> >> 'proto': 'tcp', >> >> 'port': 80 >> >> }] >> >> >> rule3 = [{ >> >> 'cidr': '0.0.0.0/0', >> >> 'proto': 'tcp', >> >> 'port': 22 >> >> },{ >> >> 'cidr': '0.0.0.0/0', >> >> 'proto': 'tcp', >> >> 'port': 80 >> >> }] >> >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> >> > > > -- > *Pablo Lucena* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Wed Jul 22 12:24:49 2015 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 22 Jul 2015 17:24:49 +0100 Subject: Integers with leading zeroes In-Reply-To: References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <55AFB673.4040100@rece.vub.ac.be> Message-ID: <55AFC3D1.10800@mrabarnett.plus.com> On 2015-07-22 16:50, Grant Edwards wrote: > On 2015-07-22, MRAB wrote: >> On 2015-07-22 16:27, Antoon Pardon wrote: >> >>> Does the same condition hold for strings? If you are not performing string >>> operations on something, it is not a string? >> >> Tkinter comes to mind. You specify how widgets are laid out strings >> that are basically flags: >> >> text_widget.pack(side=LEFT, fill=BOTH, expand=YES) >> >> where LEFT, BOTH and YES are strings. > > That's Tcl's fault. They have to be passed to Tcl, and Tcl only has > one data type: strings. > But _I'm_ writing in Python. Do I have to know how Tcl works underneath? From emile at fenx.com Wed Jul 22 12:49:26 2015 From: emile at fenx.com (Emile van Sebille) Date: Wed, 22 Jul 2015 09:49:26 -0700 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 7/21/2015 5:10 PM, Grant Edwards wrote: > On 2015-07-21, Emile van Sebille wrote: >> On 7/21/2015 2:47 PM, Grant Edwards wrote: >>> 1) You can't copy/paste text from evince _at_all_. >> >> Hmm, i just copied "Acorsa Artichoke Heart - Quarter, Water, Can" from a >> catalog pdf, so _at_all_ depends on something -- I couldn't copy text >> from scanned documents, but that's to be expected. > > Interesting. How do you do it? For all other apps, all you have to do > is select the text and then center-click in the window where you want > the selected text inserted. Well, I select and right click copy then right click paste in where I want it. I never got into the center click options. Emile From lac at openend.se Wed Jul 22 12:53:19 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 18:53:19 +0200 Subject: Can I copy/paste Python code? In-Reply-To: Message from Grant Edwards of "Wed, 22 Jul 2015 14:53:42 -0000." References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <55aee7a8$0$1637$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507221653.t6MGrJ2R027870@fido.openend.se> In a message of Wed, 22 Jul 2015 14:53:42 -0000, Grant Edwards writes: >On 2015-07-22, Laura Creighton wrote: > >>>The entire purpose of PDF is to prevent people from changing the >>>format and appearance of documents. > >> My problem isn't that I don't understand this, my problem is that I >> think this is, in nearly all cases, morally the wrong thing to do. >> >> So this means that producing a reader that could do exactly what I do >> is well within the abilities of Adobe. But people who aren't as >> technologically sophisticated as I am, or who don't have access to >> such a person have to suffer. This is not a tehcnical limitation, >> but a political one. > >OK, so the problem is that apparently people are using PDF when they >should be using something else (probably one of the e-book formats >that allow the reader to select font and format -- or maybe just >text). This is the standard way for people writing documents using libreoffice and microsoft word export them to a readership which cannot be expected to also have libreoffice and microsoft word. >It's not Adobe's fault. PDF isn't _supposed_ to allow the reader to >change the format. It's the fault of people who are chosing to >generate PDF documents when they should be using something else. >Asking for PDF to allow the user to change the way the document looks >is like asking for gasoline that isn't flammable. > >> Have the possibility of unchanging documents for the very rare times >> when that is wanted and indeed needed, and the rest of the time let >> the readers look at their docs any way they like. > >That's _exactly_ what HTML was supposed to be. Now it's been broken >and turned into another PDF by "web designers" who think everybody has >the exact same monitor, OS, browser, eyes and brain that they have. Could not agree more. Laura >Grant Edwards grant.b.edwards Yow! I'm a fuschia bowling > at ball somewhere in Brittany > gmail.com From steve at pearwood.info Wed Jul 22 12:58:39 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 02:58:39 +1000 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> Message-ID: <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Jul 2015 11:34 pm, Rustom Mody wrote: > On Tuesday, July 21, 2015 at 4:09:56 PM UTC+5:30, Steven D'Aprano wrote: > >> We have no reason to expect that the natural numbers are anything less >> than "absolutely fundamental and irreducible" (as the Wikipedia article >> above puts it). It's remarkable that we can reduce all of mathematics to >> essentially a single axiom: the concept of the set. > > These two statements above contradict each other. > With the double-negatives and other lint removed they read: I meant what I said. > 1. We have reason to expect that the natural numbers are absolutely > fundamental and irreducible That's wrong. If we had such a reason, we could state it: "the reason we expect natural numbers are irreducible is ..." and fill in the blank. But I don't believe that such a reason exists (or at least, as far as we know). However, neither do we have any reason to think that they are *not* irreducible. Hence, we have no reason to think that they are anything but irreducible. > 2. We can reduce all of mathematics to essentially a single axiom: the > concept of the set. Heh, yes, that is a bit funny. But I don't think it's really a contradiction, because I don't think that numbers "really are" sets. The set-theoretic definition of the natural numbers is quite nice, but is it really simpler than the old fashioned idea of natural numbers as "counting numbers"? Certainly it shows that we have a one-to-one correspondence from the natural numbers to sets, building from the empty set alone, and in some sense sets seem more primitive. But I think that proving that sets actually are more primitive is another story. I think that we can equally choose the natural numbers to be axiomatic, or sets to be axiomatic and derive natural numbers from them. Neither is more correct than the other. By the way, my comment about "essentially a single axiom" should be read informally. Formally, you need a whole bunch of axioms: http://math.stackexchange.com/questions/68659/set-theoretic-construction-of-the-natural-numbers I stated that the set-theoretic definition was generally accepted, but that's quite far from saying it is logically proven. The definition comes from Zermelo?Fraenkel set theory (ZF) plus the Axiom of Choice (ZFC), but the Axiom of Choice is not uncontroversial. E.g. the Banach-Tarski paradox follows from AC. https://en.wikipedia.org/wiki/Banach%E2%80%93Tarski_paradox Like any other Axiom, the Axiom of Choice is unprovable. You can either accept it or reject it, and there is also ZF?C. Jerry Bona jokes: "The Axiom of Choice is obviously true, the well-ordering principle obviously false, and who can tell about Zorn's lemma?" the joke being that all three are mathematically equivalent. > So are you on the number-side -- Poincare, Brouwer, Heyting... > Or the set-side -- Cantor, Russel, Hilbert... ?? Yes. I think both points of view are useful, even if only useful in understanding what the limits of that view are. >> On Tuesday 21 July 2015 19:10, Marko Rauhamaa wrote: >> > Our ancestors defined the fingers (or digits) as "the set of numbers." >> > Modern mathematicians have managed to enhance the definition >> > quantitatively but not qualitatively. >> >> So what? >> >> This is not a problem for the use of numbers in science, engineering or >> mathematics (including computer science, which may be considered a branch >> of all three). There may be still a few holdouts who hope that G?del is >> wrong and Russell's dream of being able to define all of mathematics in >> terms of logic can be resurrected, but everyone else has moved on, and >> don't consider it to be "an embarrassment" any more than it is an >> embarrassment that all of philosophy collapses in a heap when faced with >> solipsism. > > That's a bizarre view. Really? Which part(s) do you consider bizarre? (1) That the lack of any fundamental definition of numbers in terms is not a problem in practice? (2) That comp sci can be considered a branch of science, engineering and mathematics? (3) That there may still be a few people who hope G?del is wrong? (4) That everyone else (well, at least everyone else in mathematics, for some definition of "everyone") has moved on? (5) That philosophy is unable to cope with the problem of solipsism? I don't think any of those statements are *bizarre*, i.e. conspicuously or grossly unconventional or unusual; eccentric; freakish; gonzo; outlandish; outre; grotesque. In hindsight, my claim of "everyone else" having moved on is too strong -- there are millions of mathematicians in the world, and I'm sure that you can find one or two who don't fall into either of the two categories I gave. That is, they neither wish to dispute G?del nor do they accept the irreducibility of numbers as something matter-of-fact and not embarrassing. So let's just quietly insert an "almost" before "everyone" and move on, shall we? > As a subjective view "I dont feel embarrassed by..." its not arguable > other than to say embarrassment is like thick-skinnedness -- some have > elephant-skins some have gossamer skins I don't think any of my comments relies on embarrassment being an objective state. > As an objective view its just wrong: Eminent mathematicians have disagreed > so strongly with each other as to what putative math is kosher and what > embarrassing that they've sent each other to mental institutions. I think that the critical factor there is that it is all in the past tense. Today, I believe, the vast majority of mathematicians fall into two camps: (1) Those who just use numbers without worrying about defining them in some deep or fundamental sense; (2) Those who understand G?del and have given up or rejected Russell's program to define mathematics in terms of pure logic. > And -- most important of all -- these arguments are at the root of why CS > 'happened' : http://blog.languager.org/2015/03/cs-history-0.html Again, this is the past. > The one reason why this view -- "the embarrassments in math/logic > foundations are no longer relevant as they were in the 1930s" -- is > because people think CS is mostly engineering, hardly math. So (the > argument runs) just as general relativity is irrelevant to > bridge-building, so also meta-mathematics is to pragmatic CS. > > The answer to this view -- unfortunately widely-held -- is the same as > above: http://blog.languager.org/2015/03/cs-history-0.html > A knowledge of the history will disabuse of the holder of these > misunderstandings and misconceptions I am very aware of the history of both comp sci and mathematics. It's not that I think history is irrelevant. I think history is very important to understand where we are, how we got here, and to where we are going. It's that I think that Russell's program is a degenerate research program and irrelevant paradigm abandoned by nearly everyone. Not only does G?del prove the impossibility of Russell's attempt to ground mathematics in pure logic, but mathematicians have by and large rejected Russell's paradigm as irrelevant, like quintessence or aether to physicists, or how many angels can dance on the head of a pin to theologians. In simple terms, hardly anyone cares how you define numbers, so long as the definition gives you arithmetic. Quoting Wikipedia: "In the years following G?del's theorems, as it became clear that there is no hope of proving consistency of mathematics, and with development of axiomatic set theories such as Zermelo?Fraenkel set theory and the lack of any evidence against its consistency, most mathematicians lost interest in the topic." https://en.wikipedia.org/wiki/Finitism -- Steven From oracle.blog3 at gmail.com Wed Jul 22 13:04:10 2015 From: oracle.blog3 at gmail.com (max scalf) Date: Wed, 22 Jul 2015 12:04:10 -0500 Subject: convert output to list(and nested dictionary) In-Reply-To: References: Message-ID: I was able to solve the above problem i listed with the following...please let me know if that is the correct way of doing this...or i am way off? >>> for sg in sgs: for rule in sg.rules: st = sg, sg.id, "inbound:", rule, " source:", rule.grants s = str(st).replace(","," ") #print s get_data(s) {'cidr': 'sg-e632d982-995635159130', 'port': 'None', 'proto': '1'} {'cidr': '67.184.225.222/32', 'port': '22', 'proto': 'tcp'} {'cidr': '10.0.2.10/32', 'port': '1024', 'proto': 'tcp'} {'cidr': '24.12.30.198/32', 'port': '80', 'proto': 'tcp'} {'cidr': '10.0.2.10/32', 'port': '138', 'proto': 'udp'} {'cidr': '24.12.30.198/32', 'port': '53', 'proto': 'udp'} {'cidr': '0.0.0.0/0', 'port': '30015', 'proto': 'tcp'} {'cidr': '10.0.2.10/32', 'port': '', 'proto': 'icmp'} >>> On Wed, Jul 22, 2015 at 11:01 AM, max scalf wrote: > Hi Pablo, > > While playing around with the function you gave me(get_data)...i was > thinking to do something like below. For each line create a dictionary > then append that dictionary to a list...but before i even get to that part > i get the below error and while researching it i am unable to figure out > what is going on... could you point me in the right direction ? > > >>> for sg in sgs: > for rule in sg.rules: > pt = sg, sg.id, "inbound:", rule, " source:", rule.grants > print pt #this is just for my own purpose > get_data(pt) > > > (SecurityGroup:wordpress-app-SG, u'sg-99c4befc', 'inbound:', > IPPermissions:-1(None-None), ' source:', [sg-e632d982-995635159130]) > > Traceback (most recent call last): > File "", line 5, in > get_data(pt) > File "", line 5, in get_data > _, proto_port, cidr = data.rsplit(":", 2) > AttributeError: 'tuple' object has no attribute 'rsplit' > >>> get_data("SecurityGroup:wordpress-app-SG, u'sg-99c4befc', 'inbound:', > IPPermissions:-1(None-None), ' source:', [sg-e632d982-995635159130]") > {'cidr': 'sg-e632d982-995635159130', 'port': 'None', 'proto': '1'} > >>> > > On Tue, Jul 21, 2015 at 8:03 PM, Pablo Lucena wrote: > >> ?str.split and re are a nice quick way to do it: >> >> >>> def get_data(data): >> import re >> port_re = re.compile(r'(\w+)\((\S+-\S+)\)') >> cidr_re = re.compile(r'\[(.*?)\]') >> _, proto_port, cidr = data.rsplit(":", 2) >> port_match = port_re.search(proto_port) >> proto, port = port_match.group(1), port_match.group(2) >> port = port.split("-")[0] >> cidr_match = cidr_re.search(cidr) >> cidr = cidr_match.group(1) >> return dict(port=port, proto=proto, cidr=cidr) >> >> >>> get_data("SecurityGroup:default sg-e1304484 inbound: >> IPPermissions:tcp(80-80) source: [67.184.225.222/32]") >> {'cidr': '67.184.225.222/32', 'proto': 'tcp', 'port': '80'} >> >>> get_data("SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >> IPPermissions:-1(None-None) source: [sg-e632d982-995635159130]") >> {'cidr': 'sg-e632d982-995635159130', 'proto': '1', 'port': 'None'} >> >> >> ?You can alter this and add whatever extra checks you need as Chris A >> mentioned (when proto is -1 and port is None-None, or the icmp case). This >> is just a very crude example, but hopefully you get the drift. >> >> Most text parsing problems can easily be solved with these simple tools. >> Fire up your shell and test it - this is really the best way to learn how >> to do something like this. >> >> >> On Tue, Jul 21, 2015 at 5:12 PM, max scalf >> wrote: >> >>> Hello all, >>> >>> For Each SecurityGroup, how can i convert that into a List that in turn >>> will have a dictionary of the cidr block, protocol type and the port...so >>> from output below, the SecurityGroup called "default" had 2 >>> rules...allowing TCP port from 80 and 5500 to the source IP and then >>> SecurityGroup called "Pub_HDP_SG" had only one rule...so on and so >>> forth....here is the output that i am trying to get out in the form of a >>> list.... >>> >>> what I am planning to do is, take the list(and nested dictionary) and >>> pass that to a function that will in turn spitout a cloudformation template >>> using troposphere (something like " >>> http://imil.net/wp/2015/06/04/rock-your-cloudformation-with-troposphere-and-boto/ >>> ") >>> >>> >>> For Better Readablity (http://pastebin.com/rT6Aswwz) >>> >>> import boto.ec2 >>> >>> sgs = boto.ec2.connect_to_region('us-east-1').get_all_security_groups() >>> >>> for sg in sgs: >>> >>> for rule in sg.rules: >>> >>> print sg, sg.id, "inbound:", rule, " source:", rule.grants >>> >>> >>> SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(80-80) >>> source: [67.184.225.222/32] >>> >>> SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(5500-5500) >>> source: [67.184.225.222/32] >>> >>> SecurityGroup:Pub_HDP_SG sg-e632d982 inbound: IPPermissions:tcp(80-80) >>> source: [0.0.0.0/0] >>> >>> SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: >>> IPPermissions:tcp(22-22) source: [0.0.0.0/0] >>> >>> SecurityGroup:sg3-MySecurityGroup-LB0QF9UQAOEF sg-4fe73728 inbound: >>> IPPermissions:tcp(80-80) source: [0.0.0.0/0] >>> >>> SecurityGroup:RDP Rule - open everyone sg-42d58d27 inbound: >>> IPPermissions:-1(None-None) source: [0.0.0.0/0] >>> >>> SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: >>> IPPermissions:tcp(22-22) source: [10.0.20.100/32] >>> >>> SecurityGroup:us-east-open-all sg-97ffa7f2 inbound: >>> IPPermissions:tcp(53-53) source: [10.0.20.100/32] >>> >>> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >>> IPPermissions:-1(None-None) source: [sg-e632d982-995635159130] >>> >>> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >>> IPPermissions:tcp(22-22) source: [67.184.225.222/32] >>> >>> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >>> IPPermissions:tcp(1024-65535) source: [10.0.20.100/32] >>> >>> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >>> IPPermissions:tcp(80-80) source: [24.12.30.198/32] >>> >>> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >>> IPPermissions:udp(138-138) source: [10.0.20.100/32] >>> >>> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >>> IPPermissions:udp(53-53) source: [24.12.30.198/32] >>> >>> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >>> IPPermissions:tcp(30015-30015) source: [0.0.0.0/0] >>> >>> SecurityGroup:wordpress-app-SG sg-99c4befc inbound: >>> IPPermissions:icmp(-1--1) source: [10.0.20.100/32] >>> >>> SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) >>> source: [sg-c65a20a3-995635159130] >>> >>> SecurityGroup:default sg-c65a20a3 inbound: IPPermissions:-1(None-None) >>> source: [sg-99c4befc-995635159130] >>> >>> SecurityGroup:sg3-MySecurityGroup2-1HGPN4UF57XN6 sg-4ee73729 inbound: >>> IPPermissions:tcp(22-22) source: [192.168.1.12/32] >>> >>> SecurityGroup:AWS-AMI-SG sg-35568d51 inbound: IPPermissions:tcp(22-22) >>> source: [0.0.0.0/0] >>> >>> SecurityGroup:launch-wizard-2 sg-932255f6 inbound: >>> IPPermissions:tcp(22-22) source: [10.0.20.100/32] >>> >>> SecurityGroup:launch-wizard-2 sg-932255f6 inbound: >>> IPPermissions:tcp(443-443) source: [0.0.0.0/0] >>> >>> >>> >>> >>> >>> Here is the output i am looking for.... >>> >>> >>> rule1 = [{ >>> >>> 'cidr': '67.184.225.222/32', >>> >>> 'proto': 'tcp', >>> >>> 'port': 80 >>> >>> },{ >>> >>> 'cidr': '67.184.225.222/32', >>> >>> 'proto': 'tcp', >>> >>> 'port': 5500 >>> >>> }] >>> >>> >>> rule2 = [{ >>> >>> 'cidr': '[0.0.0.0/0', >>> >>> 'proto': 'tcp', >>> >>> 'port': 80 >>> >>> }] >>> >>> >>> rule3 = [{ >>> >>> 'cidr': '0.0.0.0/0', >>> >>> 'proto': 'tcp', >>> >>> 'port': 22 >>> >>> },{ >>> >>> 'cidr': '0.0.0.0/0', >>> >>> 'proto': 'tcp', >>> >>> 'port': 80 >>> >>> }] >>> >>> >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >>> >>> >> >> >> -- >> *Pablo Lucena* >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Wed Jul 22 13:17:30 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 19:17:30 +0200 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: Message from "Steven D'Aprano" of "Thu, 23 Jul 2015 02:58:39 +1000." <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com><55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507221717.t6MHHUbk028601@fido.openend.se> One way to look at this is to see that arithmetic is _behaviour_. Like all behaviours, it is subject to reification: see: https://en.wikipedia.org/wiki/Reification and especially as it is done in the German language, reification has this nasty habit of turning behaviours (i.e. things that are most like a verb) into nouns, or things that require nouns. Even the word _behaviour_ is suspect, as it is a noun. This noun-making can be contagious .... if we thought of the world, not as a thing, but happening-now (and see how hard it is to not have a noun like 'process' there) would we come to the question of 'Who made it?' For there would be no 'it' there to point at. It is not too surprising that the mathematicians have run into the limits of reification. There is only so much 'pretend this is a thing' you can do under relentless questioning before the 'thing-ness' just goes away ... Laura From steve at pearwood.info Wed Jul 22 13:21:24 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 03:21:24 +1000 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55afd113$0$1658$c3e8da3$5496439d@news.astraweb.com> On Thu, 23 Jul 2015 02:58 am, Steven D'Aprano wrote: >> 1. We have reason to expect that the natural numbers are absolutely >> fundamental and irreducible > > That's wrong. If we had such a reason, we could state it: "the reason we > expect natural numbers are irreducible is ..." and fill in the blank. But > I don't believe that such a reason exists (or at least, as far as we > know). Sorry, that's not as clear as I intended. By "a reason", I mean a direct reason for that choice, rather than some reason for the opposite choice. I hope that's clear? Perhaps an example will help. "Are tomatoes red?" We can have direct reasons for believing that tomatoes are red, e.g. "the light reflecting off these tomatoes peaks at frequency X, which is within the range of red light". Alternatively, we might not have any such reason, and be reduced to arguing against the alternatives. Only if all the alternatives are false could we then believe that tomatoes are red. "If tomatoes were blue, they would appear green when viewed under yellow light; since these tomatoes fail to appear green, they might be red." I'm suggesting that we have no direct reason for believing that the natural numbers are irreducible concepts, only indirect ones, namely that all the attempts to reduce them are unsatisfactory in some fashion or another. But neither do we have direct reasons for expecting them to be reducible. -- Steven From __peter__ at web.de Wed Jul 22 13:41:37 2015 From: __peter__ at web.de (Peter Otten) Date: Wed, 22 Jul 2015 19:41:37 +0200 Subject: convert output to list(and nested dictionary) References: Message-ID: max scalf wrote: > I was able to solve the above problem i listed with the following...please > let me know if that is the correct way of doing this...or i am way off? > > >>> for sg in sgs: > for rule in sg.rules: > st = sg, sg.id, "inbound:", rule, " source:", rule.grants > s = str(st).replace(","," ") > #print s > get_data(s) > > > {'cidr': 'sg-e632d982-995635159130', 'port': 'None', 'proto': '1'} > {'cidr': '67.184.225.222/32', 'port': '22', 'proto': 'tcp'} > {'cidr': '10.0.2.10/32', 'port': '1024', 'proto': 'tcp'} > {'cidr': '24.12.30.198/32', 'port': '80', 'proto': 'tcp'} > {'cidr': '10.0.2.10/32', 'port': '138', 'proto': 'udp'} > {'cidr': '24.12.30.198/32', 'port': '53', 'proto': 'udp'} > {'cidr': '0.0.0.0/0', 'port': '30015', 'proto': 'tcp'} > {'cidr': '10.0.2.10/32', 'port': '', 'proto': 'icmp'} As Chris hinted -- that's the wrong approach. You should instead look at the attributes. What does for sg in sgs: print "attributes of sg", dir(sg) for rule in sg.rules: print "attributes of rule", dir(rule) break break print? You should be able to determine the names of the interesting stuff from that. If not, try again with vars() instead of dir(), or, the horror!, see if you can find some documentation. Then build the dicts from these attributes, e. g. result = [] for sg in sgs: for rule in sg.rules: result.append(dict(cidr=sg.foo, port=rule.bar, proto=rule.baz)) print result It should be obvious that foo, bar, baz are not the correct attribute names, they are placeholders to convey the idea. From no.email at nospam.invalid Wed Jul 22 13:48:06 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Wed, 22 Jul 2015 10:48:06 -0700 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> Message-ID: <871tg0ulrd.fsf@jester.gateway.sonic.net> Steven D'Aprano writes: > That's wrong. If we had such a reason, we could state it: "the reason > we expect natural numbers are irreducible is ..." and fill in the > blank. But I don't believe that such a reason exists (or at least, as > far as we know). > > However, neither do we have any reason to think that they are *not* > irreducible. Hence, we have no reason to think that they are anything > but irreducible. But by the same reasoning, we have no reason to think they are anything but non-irreducible (reducible, I guess). What the heck does it mean for a natural number to be irreducible anyway? I know what it means for a polynomial to be irreducable, but the natural number analogy would be a composite number, and there are plenty of those. You might like this: https://web.archive.org/web/20110806055104/http://www.math.princeton.edu/~nelson/papers/hm.pdf Remember also that "in ultrafinitism, Peano Arithmetic goes from 1 to 88" (due to Shachaf on irc #haskell). ;-) From rustompmody at gmail.com Wed Jul 22 13:49:13 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 22 Jul 2015 10:49:13 -0700 (PDT) Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com><55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> Message-ID: <6b96ed18-ba44-4942-8333-a1955c8c0d0c@googlegroups.com> Nice Thanks for that Laura! I am reminded of | The toughest job Indians ever had was explaining to the whiteman who their | noun-god is. Repeat. That's because God isn't a noun in Native America. | God is a verb! >From http://hilgart.org/enformy/dma-god.htm On Wednesday, July 22, 2015 at 10:48:38 PM UTC+5:30, Laura Creighton wrote: > One way to look at this is to see that arithmetic is _behaviour_. > Like all behaviours, it is subject to reification: > see: https://en.wikipedia.org/wiki/Reification This is just a pointer to various disciplines/definitions... Which did you intend? By and large (for me, a CSist) I regard reification as philosophicalese for what programmers call first-classness. As someone brought up on Lisp and FP, was trained to regard reification/firstclassness as wonderful. However after seeing the overwhelming stupidity of OOP-treated-as-a-philosophy, Ive become suspect of this. If http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-nouns.html was just a joke it would be a laugh. I believe it is an accurate description of the brain-pickling it does to its religious adherents. And so now I am suspect of firstclassness in FP as well: http://blog.languager.org/2012/08/functional-programming-philosophical.html (last point) > > and especially as it is done in the German language, reification has > this nasty habit of turning behaviours (i.e. things that are most like > a verb) into nouns, or things that require nouns. Even the word > _behaviour_ is suspect, as it is a noun. > > This noun-making can be contagious .... if we thought of the world, not > as a thing, but happening-now (and see how hard it is to not have > a noun like 'process' there) would we come to the question of 'Who > made it?' For there would be no 'it' there to point at. > > It is not too surprising that the mathematicians have run into the > limits of reification. There is only so much 'pretend this is a > thing' you can do under relentless questioning before the 'thing-ness' > just goes away ... Yes but one person's threshold where thing-ness can be far away from another's. Newton used thingness of ? (infinitesimals) with impunity and invented calculus. Gauss found this very improper and re-invented calculus without 'completed infinity'. Yet mathematicians habitually find that, for example generating functions that are obviously divergent (? semantically meaningless) are perfectly serviceable to solve recurrences; solutions which can subsequently be verified without the generating functions. Which side should be embarrassed? From rustompmody at gmail.com Wed Jul 22 13:51:13 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 22 Jul 2015 10:51:13 -0700 (PDT) Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: <871tg0ulrd.fsf@jester.gateway.sonic.net> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <871tg0ulrd.fsf@jester.gateway.sonic.net> Message-ID: <1c256354-8609-4ab2-aedb-e31cc638bbbc@googlegroups.com> On Wednesday, July 22, 2015 at 11:18:23 PM UTC+5:30, Paul Rubin wrote: > Remember also that "in ultrafinitism, Peano Arithmetic goes from 1 to > 88" (due to Shachaf on irc #haskell). ;-) No No No Its 42; Dont you know? From oscar.j.benjamin at gmail.com Wed Jul 22 13:52:09 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Wed, 22 Jul 2015 17:52:09 +0000 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, 22 Jul 2015 at 18:01 Steven D'Aprano wrote: > > I think that the critical factor there is that it is all in the past tense. > Today, I believe, the vast majority of mathematicians fall into two camps: > > (1) Those who just use numbers without worrying about defining them in some > deep or fundamental sense; > Probably. I'd say that worrying too much about the true essence of numbers is just Platonism. Numbers are a construct (a very useful one). There are many other constructs used within mathematics and there are numerous ways to connect them or define them in terms of each other. Usually these are referred to as "connections" or sometimes more formally as "isomorphisms" and they can be useful but don't need to have any metaphysical meaning. Conventional mathematics treats the natural numbers as subsets of the complex numbers and usually treats the complex numbers as the most basic type of numbers. Exactly how you construct this out of sets is not as important as the usefulness of this concept when actually trying to use numbers. (2) Those who understand G?del and have given up or rejected Russell's > program to define mathematics in terms of pure logic. > > It's that I think that Russell's program is a degenerate research program > and irrelevant paradigm abandoned by nearly everyone. Not only does G?del > prove the impossibility of Russell's attempt to ground mathematics in pure > logic, but mathematicians have by and large rejected Russell's paradigm as > irrelevant, like quintessence or aether to physicists, or how many angels > can dance on the head of a pin to theologians. In simple terms, hardly > anyone cares how you define numbers, so long as the definition gives you > arithmetic. > Actually in the decades since the incompleteness theorems were published much of mathematics has simply ignored the problem. Hilbert's idea to construct everything out of formal systems of axioms and proof rules continues to be pushed to its limits. This is now a standard approach in the literature, in textbooks and published papers, and in undergraduate programs. In contrast G?del's (Platonist IMO) intuitionist idea of mathematical proof is ignored. The thing is that it turns out that even if you can't prove everything then you can at least prove a lot: G?del demonstrated the existence of at least one unprovable theorem. Since we know that there are loads of unproven theorems and that loads of them continue to be proven all the time we clearly haven't yet hit any kind of "G?del limit" that would impede further progress. > Quoting Wikipedia: > > "In the years following G?del's theorems, as it became clear that there is > no hope of proving consistency of mathematics, and with development of > axiomatic set theories such as Zermelo?Fraenkel set theory and the lack of > any evidence against its consistency, most mathematicians lost interest in > the topic." > They lost interest in the topic of proving consistency, completeness etc. They didn't lose interest in creating an explosion of different sets of axioms and proof systems, studying the limits of each and trying to push as much of conventional mathematics as possible into grand frameworks. For a modern example of Hilbert's legacy take a look at these guys: http://us.metamath.org/mpegif/mmtheorems.html They've tried to construct all of mathematics out of set theory using a fully formal (computer verifiable) proof database. They define the natural numbers as a subset of the complex numbers: http://us.metamath.org/mpegif/mmtheorems87.html#mm8625s The complex numbers themselves are defined in terms of the ordinal numbers which are similar to the natural numbers but have a distinct definition in terms of sets: http://us.metamath.org/mpegif/mmtheorems77.html#mm7635s I think they did it that way because it's just too awkward if the complex number 1 isn't the same as the natural number 1. -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From oracle.blog3 at gmail.com Wed Jul 22 13:57:21 2015 From: oracle.blog3 at gmail.com (max scalf) Date: Wed, 22 Jul 2015 12:57:21 -0500 Subject: convert output to list(and nested dictionary) In-Reply-To: References: Message-ID: Hi Peter, Could you please explain what i am doing wrong? I did inspected the "get_all_security_groups()" object using dir and i do need the get_data function for this to work...as i have to parse the output...just getting the rule and grants does not work...as it comes with extra verbiage that i do NOT need in my dictionary...see below... >>> for sg in sgs: for rule in sg.rules: print sg, sg.id, rule, rule.grants SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:-1(None-None) [sg-e632d982-995635159130] SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:tcp(22-22) [ 67.184.225.222/32] SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:tcp(1024-65535) [ 10.0.2.10/32] SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:tcp(80-80) [ 24.12.30.198/32] SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:udp(138-138) [ 10.0.2.10/32] SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:udp(53-53) [ 24.12.30.198/32] SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:tcp(30015-30015) [ 0.0.0.0/0] SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:icmp(-1--1) [ 10.0.2.10/32] >>> i was able to create a list(and nested dictionary) using below... i am open to making this better if there is a way... And please accept my apology(in case i am not following certain things) as i am very new to python... >>> mylist = [] >>> >>> for sg in sgs: for rule in sg.rules: st = sg, sg.id, "inbound:", rule, " source:", rule.grants # without the below, we get a comman(,) s = str(st).replace(","," ") #print s jt = get_data(s) mylist.append(jt) >>> mylist [{'cidr': 'sg-e632d982-995635159130', 'port': 'None', 'proto': '1'}, {'cidr': '67.184.225.222/32', 'port': '22', 'proto': 'tcp'}, {'cidr': ' 10.0.2.10/32', 'port': '1024', 'proto': 'tcp'}, {'cidr': '24.12.30.198/32', 'port': '80', 'proto': 'tcp'}, {'cidr': '10.0.2.10/32', 'port': '138', 'proto': 'udp'}, {'cidr': '24.12.30.198/32', 'port': '53', 'proto': 'udp'}, {'cidr': '0.0.0.0/0', 'port': '30015', 'proto': 'tcp'}, {'cidr': ' 10.0.2.10/32', 'port': '', 'proto': 'icmp'}] >>> >>> On Wed, Jul 22, 2015 at 12:41 PM, Peter Otten <__peter__ at web.de> wrote: > max scalf wrote: > > > I was able to solve the above problem i listed with the > following...please > > let me know if that is the correct way of doing this...or i am way off? > > > > >>> for sg in sgs: > > for rule in sg.rules: > > st = sg, sg.id, "inbound:", rule, " source:", rule.grants > > s = str(st).replace(","," ") > > #print s > > get_data(s) > > > > > > {'cidr': 'sg-e632d982-995635159130', 'port': 'None', 'proto': '1'} > > {'cidr': '67.184.225.222/32', 'port': '22', 'proto': 'tcp'} > > {'cidr': '10.0.2.10/32', 'port': '1024', 'proto': 'tcp'} > > {'cidr': '24.12.30.198/32', 'port': '80', 'proto': 'tcp'} > > {'cidr': '10.0.2.10/32', 'port': '138', 'proto': 'udp'} > > {'cidr': '24.12.30.198/32', 'port': '53', 'proto': 'udp'} > > {'cidr': '0.0.0.0/0', 'port': '30015', 'proto': 'tcp'} > > {'cidr': '10.0.2.10/32', 'port': '', 'proto': 'icmp'} > > As Chris hinted -- that's the wrong approach. You should instead look at > the > attributes. What does > > for sg in sgs: > print "attributes of sg", dir(sg) > for rule in sg.rules: > print "attributes of rule", dir(rule) > break > break > > print? You should be able to determine the names of the interesting stuff > from that. If not, try again with vars() instead of dir(), or, the horror!, > see if you can find some documentation. > > Then build the dicts from these attributes, e. g. > > result = [] > for sg in sgs: > for rule in sg.rules: > result.append(dict(cidr=sg.foo, port=rule.bar, proto=rule.baz)) > print result > > It should be obvious that foo, bar, baz are not the correct attribute > names, > they are placeholders to convey the idea. > > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Wed Jul 22 14:09:01 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 22 Jul 2015 11:09:01 -0700 (PDT) Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> Message-ID: <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> On Wednesday, July 22, 2015 at 11:22:57 PM UTC+5:30, Oscar Benjamin wrote: > On Wed, 22 Jul 2015 at 18:01 Steven D'Aprano wrote: > > > > I think that the critical factor there is that it is all in the past tense. > > Today, I believe, the vast majority of mathematicians fall into two camps: > > > > (1) Those who just use numbers without worrying about defining them in some > > deep or fundamental sense; > > > > Probably. I'd say that worrying too much about the true essence of numbers is just Platonism. Numbers are a construct (a very useful one). There are many other constructs used within mathematics and there are numerous ways to connect them or define them in terms of each other. Usually these are referred to as "connections" or sometimes more formally as "isomorphisms" and they can be useful but don't need to have any metaphysical meaning. Philosophers-of-mathematics decry platonism. However from my experience (I am not a professional mathematician, though Ive known good ones) most practicing-mathematicians proceed on the assumption that they *discover* math and not that they *invent* it. To me this says that though they may not know the meaning or spelling of platonism, they all layman-adhere to it. tl;dr To me (as unprofessional a musician as mathematician) I find it arbitrary that Newton *discovered* gravity whereas Beethoven *composed* the 9th symphony. Maybe Beethoven was sent my God to write Ode-to-Joy and reunite Europe? From lac at openend.se Wed Jul 22 14:14:50 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 22 Jul 2015 20:14:50 +0200 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: Message from Rustom Mody of "Wed, 22 Jul 2015 10:49:13 -0700." <6b96ed18-ba44-4942-8333-a1955c8c0d0c@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com><55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <6b96ed18-ba44-4942-8333-a1955c8c0d0c@googlegroups.com> Message-ID: <201507221814.t6MIEo7I029957@fido.openend.se> In a message of Wed, 22 Jul 2015 10:49:13 -0700, Rustom Mody writes: >Nice Thanks for that Laura! >I am reminded of > >| The toughest job Indians ever had was explaining to the whiteman who their >| noun-god is. Repeat. That's because God isn't a noun in Native America. >| God is a verb! >>From http://hilgart.org/enformy/dma-god.htm > >On Wednesday, July 22, 2015 at 10:48:38 PM UTC+5:30, Laura Creighton wrote: >> One way to look at this is to see that arithmetic is _behaviour_. >> Like all behaviours, it is subject to reification: >> see: https://en.wikipedia.org/wiki/Reification > >This is just a pointer to various disciplines/definitions... >Which did you intend? I meant -- depending on your background -- go find a meaning for reification that makes sense to you. And then extend this to some other areas. >By and large (for me, a CSist) I regard reification as philosophicalese for >what programmers call first-classness. Me too. But there are more people out there who know something about reification than there are that know about first classness. >As someone brought up on Lisp and FP, was trained to regard reification/firstclassness >as wonderful. However after seeing the overwhelming stupidity of OOP-treated-as-a-philosophy, >Ive become suspect of this. >If http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-nouns.html >was just a joke it would be a laugh. I believe it is an accurate description >of the brain-pickling it does to its religious adherents. >And so now I am suspect of firstclassness in FP as well: >http://blog.languager.org/2012/08/functional-programming-philosophical.html >(last point) > >> >> and especially as it is done in the German language, reification has >> this nasty habit of turning behaviours (i.e. things that are most like >> a verb) into nouns, or things that require nouns. Even the word >> _behaviour_ is suspect, as it is a noun. >> >> This noun-making can be contagious .... if we thought of the world, not >> as a thing, but happening-now (and see how hard it is to not have >> a noun like 'process' there) would we come to the question of 'Who >> made it?' For there would be no 'it' there to point at. >> >> It is not too surprising that the mathematicians have run into the >> limits of reification. There is only so much 'pretend this is a >> thing' you can do under relentless questioning before the 'thing-ness' >> just goes away ... > >Yes but one person's threshold where thing-ness can be far away from another's. >Newton used thingness of ? (infinitesimals) with impunity and invented calculus. >Gauss found this very improper and re-invented calculus without 'completed infinity'. >Yet mathematicians habitually find that, for example generating functions that >are obviously divergent (? semantically meaningless) are perfectly serviceable >to solve recurrences; solutions which can subsequently be verified without the >generating functions. >Which side should be embarrassed? Embarassment is a function of the ego. The ego is _another_ one of those nouns where if you try to stalk it, it falls apart because it was produced by behaviour, rather than the cause of behaviour. Descartes: I think, therefore I am. (Because there must be an I that is doing the thinking.) Modern Day Western Neurologist: Thinking is going on. Therefore an I is produced. Laura From invalid at invalid.invalid Wed Jul 22 15:35:41 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 19:35:41 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 2015-07-22, Emile van Sebille wrote: > On 7/21/2015 5:10 PM, Grant Edwards wrote: >> On 2015-07-21, Emile van Sebille wrote: >>> On 7/21/2015 2:47 PM, Grant Edwards wrote: > >>>> 1) You can't copy/paste text from evince _at_all_. >>> >>> Hmm, i just copied "Acorsa Artichoke Heart - Quarter, Water, Can" from a >>> catalog pdf, so _at_all_ depends on something -- I couldn't copy text >>> from scanned documents, but that's to be expected. >> >> Interesting. How do you do it? For all other apps, all you have to do >> is select the text and then center-click in the window where you want >> the selected text inserted. > > Well, I select and right click copy then right click paste in where I > want it. I never got into the center click options. That must be using something other than the standard X11 clipboard copy/paste mechnism. You shouldn't have to "right click copy", and many of the apps I paste into don't even have a "right click paste". It sounds like evince has abandoned the trie-and true X11 clipboard functionality that people have been using for 30 years. -- Grant Edwards grant.b.edwards Yow! Catsup and Mustard all at over the place! It's the gmail.com Human Hamburger! From breamoreboy at yahoo.co.uk Wed Jul 22 16:30:07 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 22 Jul 2015 21:30:07 +0100 Subject: Encoding of Python 2 string literals In-Reply-To: References: Message-ID: On 22/07/2015 11:17, anatoly techtonik wrote: > Hi, > > Is there a way to know encoding of string (bytes) literal > defined in source file? For example, given that source: > > # -*- coding: utf-8 -*- > from library import Entry > Entry("?????") > > Is there any way for Entry() constructor to know that > string "?????" passed into it is the utf-8 string? > > I need to better prepare SCons for Python 3 migration. > > Please, CC. > -- > anatoly t. > > Without question you are the most appalling person who should by definition be excluded from the Python community. You refuse point blank to contribute to the bug tracker, you've already been banned from several mailing lists, but still you have the audacity to ask for help. How dare you? @Rick Johnston considering the above and the fact that I have spoken up in support of you in the past regarding your knowledge of tkinter/IDLE, I'm perfectly happy to call a truce regarding our litle spiff over the last couple of days. Virtual handshake over the Atlantic Ocean? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Wed Jul 22 16:40:45 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 22 Jul 2015 21:40:45 +0100 Subject: convert output to list(and nested dictionary) In-Reply-To: References: Message-ID: On 22/07/2015 18:57, max scalf wrote: > Hi Peter, > > Could you please explain what i am doing wrong? Amongst other things you're top posting. That is heavily frowned on here. Please intersperse your replies or bottom post, thank you. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From invalid at invalid.invalid Wed Jul 22 16:49:01 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 20:49:01 +0000 (UTC) Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 2015-07-22, Emile van Sebille wrote: > On 7/21/2015 5:10 PM, Grant Edwards wrote: >> On 2015-07-21, Emile van Sebille wrote: >>> On 7/21/2015 2:47 PM, Grant Edwards wrote: > >>>> 1) You can't copy/paste text from evince _at_all_. >>> >>> Hmm, i just copied "Acorsa Artichoke Heart - Quarter, Water, Can" from a >>> catalog pdf, so _at_all_ depends on something -- I couldn't copy text >>> from scanned documents, but that's to be expected. >> >> Interesting. How do you do it? For all other apps, all you have to do >> is select the text and then center-click in the window where you want >> the selected text inserted. > > Well, I select and right click copy then right click paste in where I > want it. I never got into the center click options. Ah! I've narrowed down the problem with evince select/copy. It works fine as long as you do the paste on the same X11 display[1]. If you try to do the paste on a different display, you get nothing. None of the other apps I've tried have this problem. I've checked various X terminals, xemacs, firefox, chrome, libreoffce, acroread, meld, xfreerdp. [Yes, I can cut and paste from _Windows_ apps across displays but not from evince]. I filed a bug against evince, but I don't know how common multiple display setups are (as opposed to single display, multiple monitor setups like you get with Xinerama). So it may never get fixed (unless I get ambitious). [1] When I refer to a "display" in this context, I mean an X11 display (as in $DISPLAY) not a physical LCD/CRT monitor. -- Grant Edwards grant.b.edwards Yow! I want to dress you at up as TALLULAH BANKHEAD and gmail.com cover you with VASELINE and WHEAT THINS ... From tjreedy at udel.edu Wed Jul 22 16:52:42 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 22 Jul 2015 16:52:42 -0400 Subject: Encoding of Python 2 string literals In-Reply-To: References: Message-ID: On 7/22/2015 4:30 PM, Mark Lawrence wrote: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com><55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <6b96ed18-ba44-4942-8333-a1955c8c0d0c@googlegroups.com> <201507221814.t6MIEo7I029957@fido.openend.se> Message-ID: On 22/07/2015 19:14, Laura Creighton wrote: I don't suppose anybody could spare a bit of time for something that is slightly more important IMHO, like getting the core workflow going? I'm fairly well convinced that the vast majority of people here aren't in the slightest bit interested in actually doing anything, but just in case you could try reading. https://www.python.org/dev/peps/pep-0462/ https://www.python.org/dev/peps/pep-0474/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From auriocus at gmx.de Wed Jul 22 17:23:55 2015 From: auriocus at gmx.de (Christian Gollwitzer) Date: Wed, 22 Jul 2015 23:23:55 +0200 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <55aee7a8$0$1637$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 22.07.2015 16:53, Grant Edwards wrote: > It's not Adobe's fault. PDF isn't _supposed_ to allow the reader to > change the format. It's the fault of people who are chosing to > generate PDF documents when they should be using something else. Classic PDF, yes. It is essentially a vector drawing format with capabilities for font embedding etc. to ensure the identical rendering everywhere. > Asking for PDF to allow the user to change the way the document looks > is like asking for gasoline that isn't flammable. There is an enhancement called "tagged PDF", which allows the text to reflow. This was invented by Adobe exactly for that purpose, to display text for disabled people etc. > That's _exactly_ what HTML was supposed to be. Not a bad choice either. Christian From breamoreboy at yahoo.co.uk Wed Jul 22 17:26:55 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 22 Jul 2015 22:26:55 +0100 Subject: Encoding of Python 2 string literals In-Reply-To: References: Message-ID: On 22/07/2015 21:52, Terry Reedy wrote: > On 7/22/2015 4:30 PM, Mark Lawrence wrote: > > > Mark, back off. Anatoly has not been banned from python-list. In fact, > he has been told that this is where he *should* post, and not be > off-topic. Not having the temperament to work with core Python, he is, > apparently, trying to contribute to another open-source Python project, > Scons. > http://www.scons.org/ > In particular, he is, according to him, trying to make it possible to > port it to 3.x. This is something we both want to encourage. > I didn't say he was banned from the Python list. He has been banned from the issue tracker, possibly other places, I'm not sure. He refuses point blank to contribute to core python because he will not sign the CLA. One rather well known core dev refused point blank to contribute to the core workflow mailing list because of him. Oh, and please do not tell me to back off. It has been show in recent days that despite my problems I have contributed to core Python. Anatoly will contribute to any project, but on his terms, and his terms only. I have never done any such thing, and wouldn't even contemplate it. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From emile at fenx.com Wed Jul 22 17:39:51 2015 From: emile at fenx.com (Emile van Sebille) Date: Wed, 22 Jul 2015 14:39:51 -0700 Subject: Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 7/22/2015 12:35 PM, Grant Edwards wrote: > On 2015-07-22, Emile van Sebille wrote: >> On 7/21/2015 5:10 PM, Grant Edwards wrote: >>> On 2015-07-21, Emile van Sebille wrote: >>>> On 7/21/2015 2:47 PM, Grant Edwards wrote: >> >>>>> 1) You can't copy/paste text from evince _at_all_. >>>> >>>> Hmm, i just copied "Acorsa Artichoke Heart - Quarter, Water, Can" from a >>>> catalog pdf, so _at_all_ depends on something -- I couldn't copy text >>>> from scanned documents, but that's to be expected. >>> >>> Interesting. How do you do it? For all other apps, all you have to do >>> is select the text and then center-click in the window where you want >>> the selected text inserted. >> >> Well, I select and right click copy then right click paste in where I >> want it. I never got into the center click options. > > That must be using something other than the standard X11 clipboard > copy/paste mechnism. You shouldn't have to "right click copy", and > many of the apps I paste into don't even have a "right click paste". > > It sounds like evince has abandoned the trie-and true X11 clipboard > functionality that people have been using for 30 years. > Well, that may be more my issue than evince's -- my unix-ish habits grew up with the command line more so that X. At any rate, I did try middle click after you mentioned it and it worked as you'd indicated it should. Not-that-that-helps-you-any-ly yr's, Emile From torriem at gmail.com Wed Jul 22 17:56:57 2015 From: torriem at gmail.com (Michael Torrie) Date: Wed, 22 Jul 2015 15:56:57 -0600 Subject: [OT] Can I copy/paste Python code? In-Reply-To: References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: <55B011A9.6000404@gmail.com> On 07/22/2015 01:35 PM, Grant Edwards wrote: > That must be using something other than the standard X11 clipboard > copy/paste mechnism. You shouldn't have to "right click copy", and > many of the apps I paste into don't even have a "right click paste". > > It sounds like evince has abandoned the trie-and true X11 clipboard > functionality that people have been using for 30 years. Sadly, yes. Gnome has indeed pushed to abandon this. And the wayland display server also abandons this, though it practice it do so by pushing the implementation of such neat shortcuts into the toolkit instead of the windowing system, and if the recent past is any indication, GTK devs are not going to go out of their way to implement middle click paste. But perhaps someone will release patches to add it into the popular GUI toolkits. The Putty app on Windows implements this style of pasting in the app, as an example. I could be wrong but I think highlight and middle-click paste is a happy accident that became a feature in X. And there could be some application security implications surrounding it, which is part of the hesitancy of gnome developers, and wayland developers, to carry this feature. Though it seems to me Linux desktops are becoming more and more like Windows in the ways that drove me to really like X11 desktops. For example, client-side decorations always bugged me in Windows especially when an app would freeze and I couldn't move it. From oracle.blog3 at gmail.com Wed Jul 22 18:09:21 2015 From: oracle.blog3 at gmail.com (max scalf) Date: Wed, 22 Jul 2015 17:09:21 -0500 Subject: unexpected output while using list(and nested dictionary) Message-ID: Hello List, I have posted a question on stack overflow for better readability ... but is intended for python list.... Please see question below... http://stackoverflow.com/questions/31574860/unexpected-output-while-using-listand-nested-dictionary ? ?Any pointers is much appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Wed Jul 22 18:32:28 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Jul 2015 08:32:28 +1000 Subject: Integers with leading zeroes In-Reply-To: <55AFB8EC.7070708@mrabarnett.plus.com> References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <55AFB673.4040100@rece.vub.ac.be> <55AFB8EC.7070708@mrabarnett.plus.com> Message-ID: On Thu, Jul 23, 2015 at 1:38 AM, MRAB wrote: >> Does the same condition hold for strings? If you are not performing string >> operations on something, it is not a string? >> > Tkinter comes to mind. You specify how widgets are laid out strings > that are basically flags: > > text_widget.pack(side=LEFT, fill=BOTH, expand=YES) > > where LEFT, BOTH and YES are strings. The nearest term I can come up with here is that those three are *atoms*. They might be implemented as integers (most C-style APIs work that way), or as strings (which is apparently the case in Tkinter), or as instances of object() that exist solely so their identities can be checked (Python function default arguments are often done that way), but there's only one operation you're allowed to do: Ask if one atom is identical to another atom. ChrisA From invalid at invalid.invalid Wed Jul 22 18:50:55 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Jul 2015 22:50:55 +0000 (UTC) Subject: [OT] Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: On 2015-07-22, Michael Torrie wrote: > On 07/22/2015 01:35 PM, Grant Edwards wrote: >> That must be using something other than the standard X11 clipboard >> copy/paste mechnism. You shouldn't have to "right click copy", and >> many of the apps I paste into don't even have a "right click paste". >> >> It sounds like evince has abandoned the trie-and true X11 clipboard >> functionality that people have been using for 30 years. It turns out that select and middle-click _does_ work for evince, but only if you are "middle clicking" on the same X11 display where evince is. I'm not quite sure how they managed to accomplish this, since every other app I tried handles multiple displays just fine (and I'm pretty sure they didn't all go to any extra work to do so). > Sadly, yes. Gnome has indeed pushed to abandon this. They do seem to be trying pretty hard to alienate people outside the Gnome project. > And the wayland display server also abandons this, though it practice > it do so by pushing the implementation of such neat shortcuts into > the toolkit instead of the windowing system, and if the recent past > is any indication, GTK devs are not going to go out of their way to > implement middle click paste. But perhaps someone will release > patches to add it into the popular GUI toolkits. The Putty app on > Windows implements this style of pasting in the app, as an example. > > I could be wrong but I think highlight and middle-click paste is a happy > accident that became a feature in X. Could be, but it's a "feature" that's been there for 30 years. In the real world we call that a "standard". :) > And there could be some application security implications surrounding > it, which is part of the hesitancy of gnome developers, and wayland > developers, to carry this feature. Personally, I think it's all rampant NIH syndrome. They all think the fancy new (and incompatible) scheme they cooked up over a few beers last weekend is better than everything everybody else on the planet has developed in the past 30 years. > Though it seems to me Linux desktops are becoming more and more like > Windows in the ways that drove me to really like X11 desktops. For > example, client-side decorations always bugged me in Windows > especially when an app would freeze and I couldn't move it. Yep. -- Grant Edwards grant.b.edwards Yow! My face is new, my at license is expired, and I'm gmail.com under a doctor's care!!!! From rdavis7408 at gmail.com Wed Jul 22 18:54:06 2015 From: rdavis7408 at gmail.com (Robert Davis) Date: Wed, 22 Jul 2015 15:54:06 -0700 (PDT) Subject: Find Minimum for element in multiple dimensional array Message-ID: Given a set of arrays within an array how do I find the arrays with the minimum values based on two elements/columns in the array? Those two elements/columns are the destination zip code and distance. I have an array of arrays that have a origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points. I need to keep only those combinations that represent the minimum mileage between to the destination zip code. For example a point in New Jersey may have a distance from the Philadelphia Office that is 45 miles, from the Newark Office that is 78 miles and one from the Delaware Office that is 58 miles. I need to keep the mileage from the Philadelphia Office that is 45 miles and produce a .csv file that has origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points. The array looks like this: [['37015', 'TN31', 36.2777, -87.0046, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 77.338920003], ['72202', 'ARB1', 34.739224, -92.27765, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 1099.7837975322097]] My code looks like this : import csv import math def calculate_distance(lat1, lon1, lat2, lon2): if (not lat1) or (not lon1) or (not lat2) or (not lon2): return -1 lat1 = float(lat1) * math.pi/180 lon1 = float(lon1) * math.pi/180 lat2 = float(lat2) * math.pi/180 lon2 = float(lon2) * math.pi/180 return 3959.0 * math.acos(math.sin(lat1) * math.sin(lat2) + math.cos(lat1) * math.cos(lat2) * math.cos(lon2-lon1)) #Above function changed from the following URL: http://iamtgc.com/geocoding- with-python/ InputPath = "C:\\Users\\jacobs\\Downloads\\ZipCodes\\" ZipCodes = "zipcode.csv" RptgOfficeFile = "Reporting_Office_2015072001.csv" InputFile = InputPath+RptgOfficeFile zInputFile = InputPath+ZipCodes zOutputFile = InputPath+'Zip_Code_Distance.csv' z1OutputFile = InputPath+'Minimum_Distance_Zip_Code_File.csv' f = open(InputFile, 'r') zO = open(zOutputFile,'w') z1 = open(z1OutputFile,'w') lines = [ ] OfficeZipcodes = [] ZipRptOffice = {} OLatitude = [ ] OLongitude = [ ] OLocationCode = [] dzip = [] dLatitude = [] dLongitude = [] dCity = [] dState = [] Combined =[] Answers = [] for line in f: l = [i.strip() for i in line.split(',')] OfficeZipcodes.append(l[4]) ZipRptOffice[l[4]]= l[3] OLatitude.append(l[5]) OLongitude.append(l[6]) OLocationCode.append(l[3]) del OfficeZipcodes[0] del OLatitude[0] del OLongitude[0] del OLocationCode[0] zf = csv.DictReader(open(zInputFile)) #http://courses.cs.washington.edu/courses/cse140/13wi/csv-parsing.html for row in zf: dzip.append(row["zip"]) dLatitude.append(float(row["latitude"])) dLongitude.append(float(row["longitude"])) dCity.append(row["city"]) dState.append(row["state"]) for i in range(len(OfficeZipcodes)): for j in range(len(dzip)): Distance = calculate_distance(OLatitude[i], OLongitude[i],dLatitude[j],dLongitude[j]) Combined.append([OfficeZipcodes[i], OLocationCode[i],float(OLatitude[i]),float(OLongitude[i]),dState[j],dCity[j],dzip[j], dLatitude[j],dLongitude[j],Distance]) for i in range(len(Combined)): zO.write(str(Combined[i][0])+","+str(Combined[i][1])+","+str(Combined[i][2])+","+ str(Combined[i][3])+","+str(Combined[i][4])+","+ str(Combined[i][5])+","+ str(Combined[i][6])+","+str(Combined[i][7])+","+ str(Combined[i][8])+","+str(Combined[i][9])+"\n") zO.close() f.close() I am using Python 2.7 on a Windows 7 machine. Please help me get my head around how to accomplish this task. Thank you very much. Robert Davis From ben+python at benfinney.id.au Wed Jul 22 19:05:35 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 23 Jul 2015 09:05:35 +1000 Subject: unexpected output while using list(and nested dictionary) References: Message-ID: <85fv4foksg.fsf@benfinney.id.au> max scalf writes: > I have posted a question on stack overflow for better readability ... but > is intended for python list.... Please see question below... Please post (as a reply to your initial post, if you like) with the full question text in a message. Keep the discussion here in this forum self-contained; linking to context elsewhere is less reliable across time. -- \ ?Come on, if your religion is so vulnerable that a little bit | `\ of disrespect is going to bring it down, it's not worth | _o__) believing in, frankly.? ?Terry Gilliam, 2005-01-18 | Ben Finney From emile at fenx.com Wed Jul 22 19:26:58 2015 From: emile at fenx.com (Emile van Sebille) Date: Wed, 22 Jul 2015 16:26:58 -0700 Subject: Find Minimum for element in multiple dimensional array In-Reply-To: References: Message-ID: On 7/22/2015 3:54 PM, Robert Davis wrote: > I have an array of arrays that have a origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points. > > I need to keep only those combinations that represent the minimum mileage between to the destination zip code. For example a point in New Jersey may have a distance from the Philadelphia Office that is 45 miles, from the Newark Office that is 78 miles and one from the Delaware Office that is 58 miles. > > I need to keep the mileage from the Philadelphia Office that is 45 miles and produce a .csv file that has origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points. > > The array looks like this: > > [['37015', 'TN31', 36.2777, -87.0046, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 77.338920003], > ['72202', 'ARB1', 34.739224, -92.27765, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 1099.7837975322097]] Assume the array in A: ---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<--- A= [['37015', 'TN31', 36.2777, -87.0046, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 77.338920003], ['72202', 'ARB1', 34.739224, -92.27765, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 1099.7837975322097]] # transform to a dict ignoring dups D = dict( [ ( ((r[6],r[0]),r[-1]), r) for r in A ] ) # convert to a sorted list L = sorted(D.items()) # then print and filter out any duplicated entries lastzippair = (None,None) for ky,rec in L: if ky[:2] == lastzippair: continue print ky,":",rec lastzippair=ky[:2] ---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<--- The results are what you'd write to the csv file. Tested only with the data you provided. HTH, Emile From garyroach at verizon.net Wed Jul 22 19:35:00 2015 From: garyroach at verizon.net (Gary Roach) Date: Wed, 22 Jul 2015 16:35:00 -0700 Subject: password authentication failed In-Reply-To: References: <55A694AB.2020408@verizon.net> <55A83F93.4030403@verizon.net> Message-ID: <55B028A4.9090901@verizon.net> On 07/16/2015 04:53 PM, Chris Angelico wrote: > On Fri, Jul 17, 2015 at 9:34 AM, Gary Roach wrote: >> On 07/15/2015 11:25 AM, Chris Angelico wrote: >> >>> You should then be able to create a regular user, and grant >>> appropriate permissions: >>> >>> postgres=# create user archives password >>> 'traded-links-linguistics-informal'; >>> CREATE ROLE >>> postgres=# grant all on database archivedb to archives; >>> GRANT >> I really appreciate the help Chris. I created a user archive with password >> 'xxxxxx' and changed the settings.py file accordingly. When I tried python >> manage.py migrate I got the following error with it's traceback: >> >> (archivedb)root at supercrunch:~/archivedb# python manage.py migrate >> [chomp] >> django.db.utils.ProgrammingError: permission denied for relation >> django_migrations > This suggests that your new user doesn't have permissions set yet. Did > you do the grant command as listed above? If so, you may have to also > do this: > > $ sudo sudo -u postgres psql archivedb > postgres=# grant all on all tables in schema X to archives; I did the above. > Replace X with the name of the database schema you use - possibly > "public" or some other user name. You can list multiple schema names, > separated by commas, if you need to. > > To list all schemas in the database: > > select distinct table_schema from information_schema.tables; I did all of the above. Since I only plan on one datebase - excluding the system db's - I'm dumping everything into the public schema. > Hope that helps! > > ChrisA I'm still getting the same migration error. At this point, I'm confused about a few things. Does the postgresql server and my archivedb reside globally or are they inside my archivedb virtual environment. I think globally. To get pgAdmin3 to work, I have to have it set so that it logs in as gary ( no choice with this) and set group to root. Then in application > advanced options set run as different user to root. This assumes that you are using a KDE4 desktop and have these option by right clicking the icons. pgAdmin3 data: Server Group > Server(1) > archivedb |_ Host name - 127.0.0.1 |_ username - archive |_ connected - no Archivedb requires a password to go deeper and takes the xxxxxx password that is in the django settings.py file. This opens up access to archivedb and lists archivedb > Schema(1) > public > tables(10). At this point I found that all of the sequences and all of the tables are owned by root. This is probably the root (no pun intended) cause. Now what do I do about it. I'm not sure how this came about so don't know how to fix it. In the OS I have a postgres user in the passwd file and in the group file have the following: gary:x:1000:root,backuppc,sudo,postgres,users root:x:0:backuppc,gary,staff,postgres,users postgres:x:117:root,gary Normally, I don't have to worry too much about security because my two user network resides behind a verizon router firewall. I don't have much in the way of sensitive data either. This project may be different. So maybe I need to tighten things up a bit. Thanks for your help Gary R From gary719_list1 at verizon.net Wed Jul 22 19:35:58 2015 From: gary719_list1 at verizon.net (Gary Roach) Date: Wed, 22 Jul 2015 16:35:58 -0700 Subject: password authentication failed In-Reply-To: References: <55A694AB.2020408@verizon.net> <55A83F93.4030403@verizon.net> Message-ID: <55B028DE.2040600@verizon.net> On 07/16/2015 04:53 PM, Chris Angelico wrote: > On Fri, Jul 17, 2015 at 9:34 AM, Gary Roach wrote: >> On 07/15/2015 11:25 AM, Chris Angelico wrote: >> >>> You should then be able to create a regular user, and grant >>> appropriate permissions: >>> >>> postgres=# create user archives password >>> 'traded-links-linguistics-informal'; >>> CREATE ROLE >>> postgres=# grant all on database archivedb to archives; >>> GRANT >> I really appreciate the help Chris. I created a user archive with password >> 'xxxxxx' and changed the settings.py file accordingly. When I tried python >> manage.py migrate I got the following error with it's traceback: >> >> (archivedb)root at supercrunch:~/archivedb# python manage.py migrate >> [chomp] >> django.db.utils.ProgrammingError: permission denied for relation >> django_migrations > This suggests that your new user doesn't have permissions set yet. Did > you do the grant command as listed above? If so, you may have to also > do this: > > $ sudo sudo -u postgres psql archivedb > postgres=# grant all on all tables in schema X to archives; I did the above. > Replace X with the name of the database schema you use - possibly > "public" or some other user name. You can list multiple schema names, > separated by commas, if you need to. > > To list all schemas in the database: > > select distinct table_schema from information_schema.tables; I did all of the above. Since I only plan on one datebase - excluding the system db's - I'm dumping everything into the public schema. > Hope that helps! > > ChrisA I'm still getting the same migration error. At this point, I'm confused about a few things. Does the postgresql server and my archivedb reside globally or are they inside my archivedb virtual environment. I think globally. To get pgAdmin3 to work, I have to have it set so that it logs in as gary ( no choice with this) and set group to root. Then in application > advanced options set run as different user to root. This assumes that you are using a KDE4 desktop and have these option by right clicking the icons. pgAdmin3 data: Server Group > Server(1) > archivedb |_ Host name - 127.0.0.1 |_ username - archive |_ connected - no Archivedb requires a password to go deeper and takes the xxxxxx password that is in the django settings.py file. This opens up access to archivedb and lists archivedb > Schema(1) > public > tables(10). At this point I found that all of the sequences and all of the tables are owned by root. This is probably the root (no pun intended) cause. Now what do I do about it. I'm not sure how this came about so don't know how to fix it. In the OS I have a postgres user in the passwd file and in the group file have the following: gary:x:1000:root,backuppc,sudo,postgres,users root:x:0:backuppc,gary,staff,postgres,users postgres:x:117:root,gary Normally, I don't have to worry too much about security because my two user network resides behind a verizon router firewall. I don't have much in the way of sensitive data either. This project may be different. So maybe I need to tighten things up a bit. Thanks for your help Gary R From rantingrickjohnson at gmail.com Wed Jul 22 19:37:01 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 22 Jul 2015 16:37:01 -0700 (PDT) Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: <55ab2b73$0$1664$c3e8da3$5496439d@news.astraweb.com> <622d0c72-5946-4067-84cd-255907688630@googlegroups.com> <3c265a7b-4a7c-4709-a553-f3bcbe218b70@googlegroups.com> <6e0311e4-6ff6-4160-b571-a61f927acb03@googlegroups.com> Message-ID: On Wednesday, July 22, 2015 at 1:51:57 AM UTC-5, Terry Reedy wrote: > > Which is it? > > Mark is not a core dev [...] However His user name is > BreamoreBoy and his tracker email is the same breamore@ > address that recently upset you. Thank you for confirming my suspicion. You have always been honest, and that is why i carry a great respect for you. It seems that D'Aprano's attempt at "gas lighting" me will not only fail, but also expose him as one of the cohorts. It's no surprise though, Steven & Chris & Mark have been bullying me for years. > I would prefer it if you both stopped snipping and sniping > at each other. I agree. But you don't need to convince me. Tell Mark, Chris and Steven. The few times i did try to contribute i was toyed with. (except for the one time i provided you with a patch, of course). Why would i subject myself to those childish games again? Until people start treating me like a respected member, i'm going to be a thorn in the gluteus maximus of this group. I can be either a friend or a foe -- their choice! PS: One thing i have noticed, in my many years here, is that: When the truth starts to support my argument, the thread "mysteriously" forks on some OT subject, and usually a subject that involves heavy emotional or philosophical debate. Such as is the case now. I think the mainstream media could learn a thing or two about diversionary tactics simply from watching this group. From rosuav at gmail.com Wed Jul 22 19:44:03 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Jul 2015 09:44:03 +1000 Subject: password authentication failed In-Reply-To: <55B028DE.2040600@verizon.net> References: <55A694AB.2020408@verizon.net> <55A83F93.4030403@verizon.net> <55B028DE.2040600@verizon.net> Message-ID: On Thu, Jul 23, 2015 at 9:35 AM, Gary Roach wrote: > At this point, I'm confused about a few things. Does the postgresql server > and my archivedb reside globally or are they inside my archivedb virtual > environment. I think globally. Your virtual environment is a Python construct only. That's where Python packages get installed, so if you don't activate it, you might not be able to use psycopg2, but as you surmise, the database itself is elsewhere on the system. > To get pgAdmin3 to work, I have to have it set so that it logs in as gary ( > no choice with this) and set group to root. Then in application > advanced > options set run as different user to root. This assumes that you are using a > KDE4 desktop and have these option by right clicking the icons. > > pgAdmin3 data: > Server Group > Server(1) > archivedb > |_ Host name - 127.0.0.1 > |_ username - archive > |_ connected - no > Archivedb requires a password to go deeper and takes the xxxxxx password > that is in the django settings.py file. This opens up access to archivedb > and lists archivedb > Schema(1) > public > tables(10). At this point I found > that all of the sequences and all of the tables are owned by root. This is > probably the root (no pun intended) cause. Now what do I do about it. I'm > not sure how this came about so don't know how to fix it. Ah, all owned by root. Okay! I've never actually tried this, but you might be able to directly reassign a bunch of things: http://www.postgresql.org/docs/9.4/static/sql-reassign-owned.html Make sure you have a backup. Reassigning root in this way is quite possibly a bad idea. If there aren't too many tables, you could use ALTER TABLE: http://www.postgresql.org/docs/9.4/static/sql-altertable.html ALTER TABLE tablename OWNER TO archives; But in theory, you shouldn't need to worry about owners at all - just make sure permissions are all assigned. Which you have done. So it's entirely possible none of this will change anything. :( Worst case, you may need to do an SQL dump of the entire database, then check the export, make sure ownership is correct, and reimport into a brand new database. Tedious, but it's certain to fix the problem. ChrisA From rosuav at gmail.com Wed Jul 22 22:00:22 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Jul 2015 12:00:22 +1000 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <55afd113$0$1658$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Jul 23, 2015 at 11:44 AM, Dennis Lee Bieber wrote: > On Thu, 23 Jul 2015 03:21:24 +1000, Steven D'Aprano > declaimed the following: > >> >>"Are tomatoes red?" >> > In answer I offer a novel: /Fried Green Tomatoes at the Whistle Stop > Cafe/ (and lots of recipes for such on Google) I think we can take it as red. *dives for cover* ChrisA From torriem at gmail.com Wed Jul 22 22:11:47 2015 From: torriem at gmail.com (Michael Torrie) Date: Wed, 22 Jul 2015 20:11:47 -0600 Subject: Integers with leading zeroes In-Reply-To: References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> Message-ID: <55B04D63.4010109@gmail.com> On 07/22/2015 07:51 AM, Grant Edwards wrote: > On 2015-07-22, Ben Finney wrote: >> Laura Creighton writes: >> >>> The biggest use I have for decimal numbers that begin with 0 is in >>> credit card numbers, account numbers and the like where the first >>> check you do is 'does this thing have the correct number of digits'. >> >> The following are examples of types from the real world that people >> think of, and casually discuss, as ?numbers?. >> >> * Postal code >> * Credit card number >> * Telephone number >> * Car registration plate number >> * Personal Identification Number (PIN) > > Those are all strings. Not numbers. That depends. A credit card number is indeed a number, and there are mathematical formulas for determining if a particular number is a valid (as in well-formed) credit card number, and possibly to identify what kind of card it is. From denismfmcmahon at gmail.com Wed Jul 22 22:38:50 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 23 Jul 2015 02:38:50 +0000 (UTC) Subject: unexpected output while using list(and nested dictionary) References: Message-ID: On Wed, 22 Jul 2015 17:09:21 -0500, max scalf wrote: > I have posted a question on stack overflow for better readability ... > but is intended for python list.... Please see question below... It's quite obvious that your list and dictionary processing is not doing what you think it is. However, the question you have posted is a long and complex one. Perhaps you could reduce it to a simpler example. Your problem seems to be that in a list of dictionaries that is itself several levels of dictionary deep, you only see a single dictionary when you do the json conversion. perhaps you could try a simpler structure, such as: import json d1 = {'c':'0.0.0.0', 'f':'1', 'p':'icmp', 't':'1'} d2 = {'c':'1.1.1.1', 'f':'22', 'p':'tcp', 't':'22'} l = [d1,d2] d3 = {'g': 'text', 's': l} d4 = {'p': d3} d5 = {'r': d4} print d5 print json.dumps(d5) This correctly gives the following output, so I guess your problem is in how you create the list of dictionaries (l in my example). {'r': {'p': {'s': [{'p': 'icmp', 'c': '0.0.0.0', 't': '1', 'f': '1'}, {'p': 'tcp', 'c': '1.1.1.1', 't': '22', 'f': '22'}], 'g': 'text'}}} {"r": {"p": {"s": [{"p": "icmp", "c": "0.0.0.0", "t": "1", "f": "1"}, {"p": "tcp", "c": "1.1.1.1", "t": "22", "f": "22"}], "g": "text"}}} I would suggest you look closely at your makesg function, and the data that you are actually feeding to it and how it is using that data. makesg expects a collection as the third param, you seem to be passing it a list of one port element. makesg returns a list of sg, with an entry for every port. You then use this as tsg.SecurityGroupIngress. However, the way your code is written, you process all the 'i' in mylist, and for each 'i' overwrite tsg.SecurityGroupIngress with a new single element list sg from makesg. I suspect you've refactored some code from processing a list of things inside a function to processing them in the main body, or vice versa, or have just got confused about what you're processing where. I suggest that you rename your makesg function to makesgr, and have it return the rule appropriate to one entry in mylist. Then you can append the returned rule to tsg.SecurityGroupIngress with: tsg.SecurityGroupIngress.append(mksgr(param,param,param)) Alternatively, pass mylist to makesg, and return the whole list of rules. tsg.SecurityGroupIngress = mksg(mylist) Either method will require some rewriting of both the mksg[r] function and the main code to work together, but as the existing problem is that they don't seem to work together to create the data structure you expect them to create, that's not going to be a bad thing. -- Denis McMahon, denismfmcmahon at gmail.com From esj at harvee.org Wed Jul 22 23:10:17 2015 From: esj at harvee.org (eric johansson) Date: Thu, 23 Jul 2015 06:10:17 +0300 (EEST) Subject: problem with selecting remote procedure calls In-Reply-To: <29701817.315.1437619102225.JavaMail.eric@aho> Message-ID: <21624840.357.1437621015246.JavaMail.eric@aho> https://docs.google.com/drawings/d/1M-TzfRaSaAhFXQk1OmcmHNOaW31_7W_7q0bf8CAJqSw/edit?usp=sharing while this is related to my speech recognition through the next project, is actually a good question for RPCs in general. Specifically, are there any good-RPCs out there that are fast, supported, and easy to use? The Google Doc image given above shows the kind of things I'm doing to make speech recognition, running on windows, drive linux. The relay and emitter pair are almost trivially easy. The RPC is used to communicate the Windows scan code or codes for a given key and then the inner side translates that scan code into an actual code understood by Linux and it is shoved into the input queue. it's much harder to create a natlink module with a matching object in the RPC server. In this case, the class "data jammer" queries the application I built and extracts data necessary to inform the grammar back in the natlink module. Once the grammar executes, "data jammer" is called again to transform the results of the recognized grammar into usable data that will drive another application. In this case, I stuffed the data into the Windows input queue which in turn gets injected into win_relay. At this point, this is where I'm having some trouble with the RPC choices. I initially settled on rpyc because it was easy, it looked like it would do what I needed and it might even be fast enough. The problem being that the user community is mostly inhabited by crickets. Second problem is that it's not clear if I can export multiple objects from a single server. Ideally, I want there to be a pair of Python programs executing for any given grammar. The first would be the module imported into natlink and the other would be it's matching partner in crime on the linux side. I'm looking for ways to implement a plug-in architecture with independent objects. I would welcome advice on pieces I can recycle to meet my needs. for example, which Python RPC environment would best suit my needs. Remember, it needs to be relatively light because execution time does have an influence on recognition accuracy and speed. thanks in advance --- eric From jason.swails at gmail.com Thu Jul 23 00:26:27 2015 From: jason.swails at gmail.com (Jason Swails) Date: Thu, 23 Jul 2015 00:26:27 -0400 Subject: Should non-security 2.7 bugs be fixed? In-Reply-To: References: Message-ID: I am a little late to the party, but I feel that I have something to contribute to this discussion. Apologies for the top-post, but it's really in response to any particular question; more of a "this is my story with Python 2.7". I still use primarily Python 2.7, although I write code using six to support both Py2 and 3 in the same code base and I'm slowly making the transition. I have written Python code for primarily Linux machines only since 2008, and until the last year or two, exclusively for Python 2. In my brief, early forays into Python 3, I experienced mostly discomfort. Discovering 2to3 alleviated some of that. But my general lack of need for anything beyond ASCII meant that when my abstracted file reading/writing routines started returning/requiring a mishmash of bytes and str depending on what kind of file was opened sent me into a TypeError/AttributeError rabbithole and made me give up. But Python 2 continued to get developed (eventually culminating in Python 2.7 and its continual improvements), and many good features of Python 3 found its way into Python 2.7 for awhile. As I got better with Python 2.7, and finally abandoned Python <2.7, I revisited Python 3 support through the six module and found that it was really not too bad maintaining a single code base for both Python 2.7 and Python 3+. While I was working on that, though, I still had Python 2.7 to rely on as a safety net. Basically, Python 2.7 was my gateway into Python 3. Where it was more similar to Python 3, the transition was easier (modules like urllib and website processing as well as Tkinter coding are some of my more difficult tasks, since I have to constantly look up where stuff has moved and figure out how compatible they are between versions). I have also since discovered TextIOWrapper and come to understand the nature of the bytes/str split and when to expect which, so that's no longer a problem (even though I still never need Unicode). And the more I use six, the more I find that I'm discarding Python 2 baggage (like range and zip in exchange for xrange and izip) and using the Python 3 replacements through six or __future__ (absolute imports, print function, division, ...). And gems like OrderedDict being made available to Python 2.7 did a lot to convince me to shed my allegiance to Python <=2.6, getting me even closer to Python 3. Where I used to see the Py3 overhaul of I/O as an incomprehensible mess (because it broke all my code!), It now appears as an elegant solution and I find myself having to patch (fortunately only a few) deficiencies in Python 2 that simply don't exist in Python 3's superior design. For example: # Works in Python 3, not in Python 2 from six.moves.urllib.request import urlopen import bz2 import gzip from io import TextIOWrapper TextIOWrapper(bz2.BZ2File(urlopen(' http://www.somewebsite.com/path/to/file.bz2'))) TextIOWrapper(gzip.GzipFile(fileobj=urlopen(' http://www.somewebsite.com/path/to/file.gz'))) So for Python 2, my file handling routine has to download the entire contents to a BytesIO and feed *that* to bz2.decompress or gzip.GzipFile, which can be a bottleneck if I only want to inspect the headers of many large files (which I sometimes do). But the workaround exists and my code can be written to support both Python 2 and Python 3 without much hassle. If I run that code under Python 3, I get a huge performance boost in some corner cases thanks to the improved underlying design. Python 3 is the future, and thanks to how *good* Python 2.7 is, I am ready to make that leap and shed some extra code baggage when the popular versions of the popular Linux distros make the move to a default system Python 3 (and they will... someday). I know my experiences don't hold true for everybody, but I also don't think they are uncommon (I know several colleagues that share many aspects of them). And for me, the *better* Python 2.7 becomes, and the longer it's kept around, the easier (and more fun!) it makes my transition to Python 3. So for me at least, arguments like "don't make Python 2.7 too good or people won't switch" are not only wrong, but in actuality counter-productive. Apologies for the novel, Jason On Sat, Jul 18, 2015 at 7:36 PM, Terry Reedy wrote: > I asked the following as an off-topic aside in a reply on another thread. > I got one response which presented a point I had not considered. I would > like more viewpoints from 2.7 users. > > Background: each x.y.0 release normally gets up to 2 years of bugfixes, > until x.(y+1).0 is released. For 2.7, released summer 2010, the bugfix > period was initially extended to 5 years, ending about now. At the spring > pycon last year, the period was extended to 10 years, with an emphasis on > security and build fixed. My general question is what other fixes should > be made? Some specific forms of this question are the following. > > If the vast majority of Python programmers are focused on 2.7, why are > volunteers to help fix 2.7 bugs so scarce? > > Does they all consider it perfect (or sufficient) as is? > > Should the core developers who do not personally use 2.7 stop backporting, > because no one cares if they do? > > -- > Terry Jan Reedy > > -- > https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason.swails at gmail.com Thu Jul 23 00:31:53 2015 From: jason.swails at gmail.com (Jason Swails) Date: Thu, 23 Jul 2015 00:31:53 -0400 Subject: Is there a way to install ALL Python packages? In-Reply-To: <060f9fd7-d5d5-4f44-b5ac-b24ba4941ddd@googlegroups.com> References: <3e71ac8f-7976-455a-8432-f3986b2f78b1@googlegroups.com> <060f9fd7-d5d5-4f44-b5ac-b24ba4941ddd@googlegroups.com> Message-ID: On Tue, Jul 21, 2015 at 10:58 PM, ryguy7272 wrote: > On Monday, July 20, 2015 at 10:57:47 PM UTC-4, ryguy7272 wrote: > > I'd like to install ALL Python packages on my machine. Even if it takes > up 4-5GB, or more, I'd like to get everything, and then use it when I need > it. Now, I'd like to import packages, like numpy and pandas, but nothing > will install. I figure, if I can just install everything, I can simply use > it when I need it, and if I don't need it, then I just won't use it. > > > > I know R offers this as an option. I figure Python must allow it too. > > > > Any idea how to grab everything? > > > > Thanks all. > > > Thanks for the tip. I just downloaded and installed Anaconda. I just > successfully ran my first Python script. So, so happy now. Thanks again!! > ?Anaconda (or the freely-available miniconda) is what I was going to suggest. If you are coming from R, then you likely want the scientific computing stack (scipy, numpy, pandas, scikit-learn, pytables, statsmodels, matplotlib, ... the list goes on). And for that (which links extensively to C and even Fortran libraries), conda blows pip out of the water.? There are other solutions (like Enthought's Canopy distribution, for example), but conda is so nice that I really have little incentive to try others. All the best, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Thu Jul 23 01:14:21 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 15:14:21 +1000 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <871tg0ulrd.fsf@jester.gateway.sonic.net> Message-ID: <55b0782d$0$1587$c3e8da3$5496439d@news.astraweb.com> On Thursday 23 July 2015 03:48, Paul Rubin wrote: > Steven D'Aprano writes: >> That's wrong. If we had such a reason, we could state it: "the reason >> we expect natural numbers are irreducible is ..." and fill in the >> blank. But I don't believe that such a reason exists (or at least, as >> far as we know). >> >> However, neither do we have any reason to think that they are *not* >> irreducible. Hence, we have no reason to think that they are anything >> but irreducible. > > But by the same reasoning, we have no reason to think they are anything > but non-irreducible (reducible, I guess). What the heck does it mean > for a natural number to be irreducible anyway? Reducible in the sense that we can define the natural numbers in terms of a simpler concept. E.g. the rationals can be reduced to the quotient of integers. One might argue that defining them in terms of sets is precisely that, but then we get into an argument as to which is simpler, natural numbers or sets? -- Steve From steve+comp.lang.python at pearwood.info Thu Jul 23 01:22:01 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 15:22:01 +1000 Subject: Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: <55b079f9$0$1587$c3e8da3$5496439d@news.astraweb.com> On Thursday 23 July 2015 05:35, Grant Edwards wrote: > On 2015-07-22, Emile van Sebille wrote: >> Well, I select and right click copy then right click paste in where I >> want it. I never got into the center click options. > > That must be using something other than the standard X11 clipboard > copy/paste mechnism. You shouldn't have to "right click copy", and > many of the apps I paste into don't even have a "right click paste". > > It sounds like evince has abandoned the trie-and true X11 clipboard > functionality that people have been using for 30 years. It works for me. Unlike many other apps, the X11 clipboard doesn't integrate with my GUI clipboard manager Clipman. That is, if I drag over text in Evince, it *does* copy into the X11 copy/paste buffer, but *does not* replace the regular Ctrl-C clipboard, and does not show up in Clipman's menu. You may consider that either a bug or a feature :-) -- Steve From steve+comp.lang.python at pearwood.info Thu Jul 23 01:26:04 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 15:26:04 +1000 Subject: convert output to list(and nested dictionary) References: Message-ID: <55b07aeb$0$1587$c3e8da3$5496439d@news.astraweb.com> On Thursday 23 July 2015 06:40, Mark Lawrence wrote: > On 22/07/2015 18:57, max scalf wrote: >> Hi Peter, >> >> Could you please explain what i am doing wrong? > > Amongst other things you're top posting. That is heavily frowned on > here. Please intersperse your replies or bottom post, thank you. Mark, please don't give bad advice. Bottom posting at the end of a long post is *far worse* than top posting. Please don't bottom post unless all the quoted text is short enough that your response shows up in the first ten or twenty lines, like this. If your response doesn't show up on the first half screenful of text, trim the quoting. In fact, you should trim the quoting to the minimal relevant amount. -- Steve From steve+comp.lang.python at pearwood.info Thu Jul 23 01:34:35 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 15:34:35 +1000 Subject: Encoding of Python 2 string literals References: Message-ID: <55b07ceb$0$1587$c3e8da3$5496439d@news.astraweb.com> On Thursday 23 July 2015 07:26, Mark Lawrence wrote: > Oh, and please do not tell me to back off. It has been show in recent > days that despite my problems I have contributed to core Python. > Anatoly will contribute to any project, but on his terms, and his terms > only. I have never done any such thing, and wouldn't even contemplate it. Contributing to issues on the tracker doesn't give you a licence to be a dick. Anatoly asked a perfectly reasonable question in the right forum. Disregarding his polite request to CC him, which in my opinion is a bit cheeky but not always unreasonable and certainly not a bannable offense, he has done nothing wrong in this thread and didn't deserve your hostile and vindictive attack. So, back off. Please. -- Steve From steve+comp.lang.python at pearwood.info Thu Jul 23 01:36:27 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 15:36:27 +1000 Subject: unexpected output while using list(and nested dictionary) References: Message-ID: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> On Thursday 23 July 2015 08:09, max scalf wrote: > Hello List, > > I have posted a question on stack overflow for better readability ... but > is intended for python list.... Please see question below... If it's intended for here, please ask it here. Consider that there may be people here who are willing and able to answer your question, but either don't have an account on Stackoverflow, have access to SO blocked, or simply don't like the culture and ethos of SO and won't use it. -- Steve From steve+comp.lang.python at pearwood.info Thu Jul 23 01:39:05 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 15:39:05 +1000 Subject: [OT] Can I copy/paste Python code? References: <0f0c6018-50e7-4e95-a798-313d767ce177@googlegroups.com> <201507211725.t6LHPW1Y028074@fido.openend.se> Message-ID: <55b07df8$0$1587$c3e8da3$5496439d@news.astraweb.com> On Thursday 23 July 2015 07:56, Michael Torrie wrote: > Though it seems to me Linux desktops are becoming more and more like > Windows in the ways that drove me to really like X11 desktops. For > example, client-side decorations always bugged me in Windows especially > when an app would freeze and I couldn't move it. Yes, this, a thousand times this. I moved to Linux because it was a better platform than Windows for the things I care about, not just the whole FOSS thing. As Linux has gotten more popular, the GUI developers are stripping all the best parts of the platform in order to more closely ape the more disagreeable parts of Windows. A cautionary tale of what happens when you open the doors too widely and allow the riff-raff in. You get KDE 4 and Gnome 3. -- Steve From steve+comp.lang.python at pearwood.info Thu Jul 23 01:41:28 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 15:41:28 +1000 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> Message-ID: <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com> On Thursday 23 July 2015 04:09, Rustom Mody wrote: > tl;dr To me (as unprofessional a musician as mathematician) I find it > arbitrary that Newton *discovered* gravity whereas Beethoven *composed* > the 9th symphony. Newton didn't precisely *discover* gravity. I'm pretty sure that people before him didn't think that they were floating through the air weightless... *wink* Did gravity exist before Newton? Then he discovered it (in some sense). Did the 9th Symphony exist before Beethoven? No? Then he composed it. -- Steve From dieter at handshake.de Thu Jul 23 01:54:05 2015 From: dieter at handshake.de (dieter) Date: Thu, 23 Jul 2015 07:54:05 +0200 Subject: Encoding of Python 2 string literals References: Message-ID: <87h9ovo1vm.fsf@handshake.de> Mark Lawrence writes: > On 22/07/2015 11:17, anatoly techtonik wrote: > ... > Without question you are the most appalling person who should by > definition be excluded from the Python community. You refuse point > blank to contribute to the bug tracker, you've already been banned > from several mailing lists, but still you have the audacity to ask for > help. How dare you? Mark, you are starting to annoy me. If I can, I am ready to help anyone with a Python-related question via this list. If you don't, you could just ignore respective posts rather than insult the poster. From dieter at handshake.de Thu Jul 23 01:58:35 2015 From: dieter at handshake.de (dieter) Date: Thu, 23 Jul 2015 07:58:35 +0200 Subject: Encoding of Python 2 string literals References: <55afaad8$0$1646$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87d1zjo1o4.fsf@handshake.de> Steven D'Aprano writes: > On Wed, 22 Jul 2015 08:17 pm, anatoly techtonik wrote: >> Is there a way to know encoding of string (bytes) literal >> defined in source file? For example, given that source: >> >> # -*- coding: utf-8 -*- >> from library import Entry >> Entry("?????") >> >> Is there any way for Entry() constructor to know that >> string "?????" passed into it is the utf-8 string? > ... > The right way to deal with this is to use an actual Unicode string: > > Entry(u"?????") > > and make sure that the file is saved using UTF-8, as the encoding cookie > says. In order to follow this recommendation, is there an easy way to learn about the "encoding cookie"'s value -- rather than parsing the first two lines of the source file (which may not always be available). From rosuav at gmail.com Thu Jul 23 02:13:02 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Jul 2015 16:13:02 +1000 Subject: Encoding of Python 2 string literals In-Reply-To: <87d1zjo1o4.fsf@handshake.de> References: <55afaad8$0$1646$c3e8da3$5496439d@news.astraweb.com> <87d1zjo1o4.fsf@handshake.de> Message-ID: On Thu, Jul 23, 2015 at 3:58 PM, dieter wrote: > Steven D'Aprano writes: >> On Wed, 22 Jul 2015 08:17 pm, anatoly techtonik wrote: >>> Is there a way to know encoding of string (bytes) literal >>> defined in source file? For example, given that source: >>> >>> # -*- coding: utf-8 -*- >>> from library import Entry >>> Entry("?????") >>> >>> Is there any way for Entry() constructor to know that >>> string "?????" passed into it is the utf-8 string? >> ... >> The right way to deal with this is to use an actual Unicode string: >> >> Entry(u"?????") >> >> and make sure that the file is saved using UTF-8, as the encoding cookie >> says. > > In order to follow this recommendation, is there an easy way to > learn about the "encoding cookie"'s value -- rather than parsing > the first two lines of the source file (which may not always be available). No; you don't need to. If you use a Unicode string literal (as marked by the u"..." notation), the Python compiler will handle the decoding for you. The string that's passed to Entry() will simply be a string of Unicode codepoints - no encoding information needed. If you then want that in UTF-8, you can encode it explicitly. ChrisA From greg.ewing at canterbury.ac.nz Thu Jul 23 02:57:58 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 23 Jul 2015 18:57:58 +1200 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> Message-ID: Rustom Mody wrote: > Ive known good ones) most practicing-mathematicians proceed on the assumption > that they *discover* math and not that they *invent* it. For something purely abstract like mathematics, I don't see how there's any distinction between "discovering" and "inventing". They're two words for the same thing. I don't know what kind of -ist that makes me... -- Greg From marko at pacujo.net Thu Jul 23 04:24:22 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 23 Jul 2015 11:24:22 +0300 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87si8fgu2x.fsf@elektro.pacujo.net> Steven D'Aprano : > I think that we can equally choose the natural numbers to be > axiomatic, or sets to be axiomatic and derive natural numbers from > them. Neither is more correct than the other. Mathematicians quit trying to define what natural numbers mean and just chose a standard enumerable sequence as *the* set of natural numbers. That's analogous to physicists defining the meter as a particular rod in a vault in Paris. So not even the length of the rod but the rod itself. To modern mathematicians, the concept "three" simply means the fourth element in the standard enumeration. When mathematicians need to use natural numbers to count, they have to escape to predicate logic. For example, to express that a natural number n has precisely two divisors, you have to say, ?x?N ?y?N ?x=y ? x|n ? y|n (which avoids counting) or: ?B?P({x?N : x|n}?2) (?x?{x?N : x|n} ?y?2 ((x,y)?B ? ?z?2 (x,z)?B?y=z) ? ?x?2 ?y?{x?N : x|n} ((y,x)?B ? ?z?{x?N : x|n} (z,x)?B?y=z)) This latter clumsy expression captures the notion of counting. However, in programming terms, you could say counting is not first-class in mathematics. Counting is done as a "macro" if you will. If the logicians had managed to define natural numbers the way they wanted, counting would be first class and simple: {x?N : x|n}?2 Marko From cs at zip.com.au Thu Jul 23 04:41:02 2015 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 23 Jul 2015 18:41:02 +1000 Subject: on keeping things civil (was: Encoding of Python 2 string literals) In-Reply-To: References: Message-ID: <20150723084102.GA44365@cskk.homeip.net> On 22Jul2015 22:26, Mark Lawrence wrote: >He refuses point blank to contribute to core python because he will not sign the CLA. So? That's his prerogative. There's plenty of work I won't undertake because of the conditions attached. Defense/military comes to mind as an example. >Oh, and please do not tell me to back off. It has been show in recent >days that despite my problems I have contributed to core Python. >Anatoly will contribute to any project, but on his terms, and his >terms only. Shrug. I'm the same, and I suspect in real terms so are you. It is just where the boundaries lie that differ. He asked a simple, direct, on topic, relevant, clear question, with a clear use case. As far as I'm concerned he's entirely welcome, and I'm glad he's received what look like informative and somewhat helpful responses. (With the notable exception of your response and now, regrettably, mine.) If you don't want to deal with him, then don't deal with him. That means shutting up, not mouthing off. On a personal basis, I have found the best way to keep discussions civil and on point is to simply ignore posts and posters which incite anger in me. I urge you to consider this approach. Venting, I remain, Cameron Simpson From rustompmody at gmail.com Thu Jul 23 05:12:11 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Thu, 23 Jul 2015 02:12:11 -0700 (PDT) Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> Message-ID: <3c1004b6-f947-49ea-8891-29dad4f3151b@googlegroups.com> On Thursday, July 23, 2015 at 12:28:19 PM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > Ive known good ones) most practicing-mathematicians proceed on the assumption > > that they *discover* math and not that they *invent* it. > > For something purely abstract like mathematics, I don't > see how there's any distinction between "discovering" and > "inventing". They're two words for the same thing. > > I don't know what kind of -ist that makes me... Ummm... Clever! You give few clues... except for 'purely abstract'. Does that mean entirely in your consciousness? Or does it mean completely independent of the (physical) world and even time. Latter is more or less definition of platonist Former is some kind of combo of intuitionist and formalist (I guess!). JFTR: I believe that post-Cantor 'platonism' is an abuse of Plato's original https://en.wikipedia.org/wiki/Allegory_of_the_Cave From hemla21 at gmail.com Thu Jul 23 05:21:33 2015 From: hemla21 at gmail.com (Heli Nix) Date: Thu, 23 Jul 2015 02:21:33 -0700 (PDT) Subject: Optimizing if statement check over a numpy value Message-ID: <65c45685-dee1-41f8-a16a-7a062f4e7b02@googlegroups.com> Dear all, I have the following piece of code. I am reading a numpy dataset from an hdf5 file and I am changing values to a new value if they equal 1. There is 90 percent chance that (if id not in myList:) is true and in 10 percent of time is false. with h5py.File(inputFile, 'r') as f1: with h5py.File(inputFile2, 'w') as f2: ds=f1["MyDataset"].value myList=[list of Indices that must not be given the new_value] new_value=1e-20 for index,val in np.ndenumerate(ds): if val==1.0 : id=index[0]+1 if id not in myList: ds[index]=new_value dset1 = f2.create_dataset("Cell Ids", data=cellID_ds) dset2 = f2.create_dataset("Porosity", data=poros_ds) My numpy array has 16M data and it takes 9 hrs to run. If I comment my if statement (if id not in myList:) it only takes 5 minutes to run. Is there any way that I can optimize this if statement. Thank you very much in Advance for your help. Best Regards, From python at mrabarnett.plus.com Thu Jul 23 05:55:58 2015 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 23 Jul 2015 10:55:58 +0100 Subject: Optimizing if statement check over a numpy value In-Reply-To: <65c45685-dee1-41f8-a16a-7a062f4e7b02@googlegroups.com> References: <65c45685-dee1-41f8-a16a-7a062f4e7b02@googlegroups.com> Message-ID: <55B0BA2E.1040909@mrabarnett.plus.com> On 2015-07-23 10:21, Heli Nix wrote: > Dear all, > > I have the following piece of code. I am reading a numpy dataset from an hdf5 file and I am changing values to a new value if they equal 1. > > There is 90 percent chance that (if id not in myList:) is true and in 10 percent of time is false. > > with h5py.File(inputFile, 'r') as f1: > with h5py.File(inputFile2, 'w') as f2: > ds=f1["MyDataset"].value > myList=[list of Indices that must not be given the new_value] > > new_value=1e-20 > for index,val in np.ndenumerate(ds): > if val==1.0 : > id=index[0]+1 > if id not in myList: > ds[index]=new_value > > dset1 = f2.create_dataset("Cell Ids", data=cellID_ds) > dset2 = f2.create_dataset("Porosity", data=poros_ds) > > My numpy array has 16M data and it takes 9 hrs to run. If I comment my if statement (if id not in myList:) it only takes 5 minutes to run. > > Is there any way that I can optimize this if statement. > > Thank you very much in Advance for your help. > > Best Regards, > When checking for presence in a list, it has to check every entry. The time taken is proportional to the length of the list. The time taken to check for presence in a set, however, is a constant. Replace the list myList with a set. From __peter__ at web.de Thu Jul 23 05:59:21 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 23 Jul 2015 11:59:21 +0200 Subject: convert output to list(and nested dictionary) References: Message-ID: max scalf wrote: > Hi Peter, > > Could you please explain what i am doing wrong? I did inspected the > "get_all_security_groups()" object using dir and i do need the get_data > function for this to work...as i have to parse the output...just getting > the rule and grants does not work...as it comes with extra verbiage that i > do NOT need in my dictionary...see below... > >>>> for sg in sgs: > for rule in sg.rules: > print sg, sg.id, rule, rule.grants > > > SecurityGroup:wordpress-app-SG sg-99c4befc IPPermissions:-1(None-None) > [sg-e632d982-995635159130] ... It's not "extra verbiage", you print the whole sg object, and the author of the SecurityGroup class has chosen one way to convert SecurityGroup instances into strings, the one that he deems most useful, probably for debugging purposes. But you are only interested in some attributes of the sg object. Instead of print sg you should only print print sg.foo, sg.bar foo and bar are fictitious attribute names, but you can find candiates for these attributes with print dir(sg) which will print the actual names. From lac at openend.se Thu Jul 23 06:13:21 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 23 Jul 2015 12:13:21 +0200 Subject: Optimizing if statement check over a numpy value In-Reply-To: Message from Heli Nix of "Thu, 23 Jul 2015 02:21:33 -0700." <65c45685-dee1-41f8-a16a-7a062f4e7b02@googlegroups.com> References: <65c45685-dee1-41f8-a16a-7a062f4e7b02@googlegroups.com> Message-ID: <201507231013.t6NADLam019213@fido.openend.se> Take a look at the sorted collection recipe: http://code.activestate.com/recipes/577197-sortedcollection/ You want myList to be a sorted List. You want lookups to be fast. See if that improves things enough for you. It may be possible to have better speedups if instead of myList you write myTree and store the values in a tree, depending on what the values of id are -- it could be completely useless for you, as well. Laura From c.candide at laposte.net Thu Jul 23 06:24:13 2015 From: c.candide at laposte.net (candide) Date: Thu, 23 Jul 2015 03:24:13 -0700 (PDT) Subject: global and loop control variable Message-ID: About global declarations, Python Language Ref (PLR) explains: [https://docs.python.org/3.4/reference/simple_stmts.html#the-global-statement] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Names listed in a global statement must not be used in the same code block textually preceding that global statement. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ What I understand is that the following code is incorrect: # --------------------------------------- def f(): x=42 global x f() print(x) # --------------------------------------- And indeed, executing this piece of code "raises" a warning : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.py:3: SyntaxWarning: name 'x' is assigned to before global declaration global x 42 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Now, global declaration has another restriction, as PLR explains: [https://docs.python.org/3.4/reference/simple_stmts.html#the-global-statement] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Names listed in a global statement must not be defined as formal parameters or in a for loop control target, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ What I understand is that the following is a must-not-code: # --------------------------------------- def f(): global i for i in range(1,3): print(10*i) f() print(i) # --------------------------------------- But, the later code executes silently without any warning: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10 20 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So my question is: what is the restriction about global as loop control variable the docs is referring to? From chenchao at inhand.com.cn Thu Jul 23 06:25:03 2015 From: chenchao at inhand.com.cn (chenchao at inhand.com.cn) Date: Thu, 23 Jul 2015 18:25:03 +0800 Subject: ImportError: No module named site Message-ID: <55B0C0FF.1000507@inhand.com.cn> hi: I'm Needing to get python 2.7.10 to cross compile correctly for an ARM embedded device. When I execute python using shell, it comes out this error:ImportError: No module named site.I have setted environment varible:PYTHONHOME and PYTHONPATH. Is there some good idea to sovle this issue? -------------- next part -------------- An HTML attachment was scrubbed... URL: From lorenzofsutton at gmail.com Thu Jul 23 07:20:47 2015 From: lorenzofsutton at gmail.com (Lorenzo Sutton) Date: Thu, 23 Jul 2015 13:20:47 +0200 Subject: global and loop control variable In-Reply-To: References: Message-ID: <55B0CE0F.4070200@gmail.com> On 23/07/2015 12:24, candide wrote: [...] > > Now, global declaration has another restriction, as PLR explains: > > [https://docs.python.org/3.4/reference/simple_stmts.html#the-global-statement] > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Names listed in a global statement must not be defined as formal parameters > or in a for loop control target, > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > What I understand is that the following is a must-not-code: > > # --------------------------------------- > def f(): > global i > for i in range(1,3): > print(10*i) > > f() > print(i) > # --------------------------------------- > > But, the later code executes silently without any warning: > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 10 > 20 > 2 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > So my question is: what is the restriction about global as loop control variable the docs is referring to? > I think for situations like this one? # --------------------------------------- def f(): global temperature for temperature in range(1,3): print "In f temperature is:", temperature temperature = 500 print "temperature is now", temperature f() print"temperature is now:", temperature # temperature is now "broken" if temperature <= 100: print "Launching rocket" else: # this never happens print "temperature too high! Aborting launch." # --------------------------------------- From mail at timgolden.me.uk Thu Jul 23 07:39:26 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 23 Jul 2015 12:39:26 +0100 Subject: problem with selecting remote procedure calls In-Reply-To: <21624840.357.1437621015246.JavaMail.eric@aho> References: <21624840.357.1437621015246.JavaMail.eric@aho> Message-ID: <55B0D26E.7080802@timgolden.me.uk> On 23/07/2015 04:10, eric johansson wrote: > https://docs.google.com/drawings/d/1M-TzfRaSaAhFXQk1OmcmHNOaW31_7W_7q0bf8CAJqSw/edit?usp=sharing > > while this is related to my speech recognition through the next > project, is actually a good question for RPCs in general. > Specifically, are there any good-RPCs out there that are fast, > supported, and easy to use? It looks like a decent fit for Pyro: https://github.com/irmen/Pyro4 http://pythonhosted.org/Pyro4/ https://pypi.python.org/pypi/Pyro4 Pyro's certainly actively maintained and I've seen its developer, Irmen de Jong, pop up on this list fairly recently. Exactly how good a fit it is would depend on your precise setup. But I think it's worth exploring. I can't speak as to its speed -- I've only used it where speed wasn't really an issue. TJG From jeremy at jeremysanders.net Thu Jul 23 07:42:31 2015 From: jeremy at jeremysanders.net (Jeremy Sanders) Date: Thu, 23 Jul 2015 13:42:31 +0200 Subject: Optimizing if statement check over a numpy value References: <65c45685-dee1-41f8-a16a-7a062f4e7b02@googlegroups.com> Message-ID: Heli Nix wrote: > Is there any way that I can optimize this if statement. Array processing is much faster in numpy. Maybe this is close to what you want import numpy as N # input data vals = N.array([42, 1, 5, 3.14, 53, 1, 12, 11, 1]) # list of items to exclude exclude = [1] # convert to a boolean array exclbool = N.zeros(vals.shape, dtype=bool) exclbool[exclude] = True # do replacement ones = vals==1.0 # Note: ~ is numpy.logical_not vals[ones & (~exclbool)] = 1e-20 I think you'll have to convert your HDF array into a numpy array first, using numpy.array(). Jeremy From rdavis7408 at gmail.com Thu Jul 23 08:31:35 2015 From: rdavis7408 at gmail.com (Robert Davis) Date: Thu, 23 Jul 2015 05:31:35 -0700 (PDT) Subject: Find Minimum for element in multiple dimensional array In-Reply-To: References: Message-ID: <01420576-dbe1-4645-9d76-a6b56ab99999@googlegroups.com> On Wednesday, July 22, 2015 at 5:54:30 PM UTC-5, Robert Davis wrote: > Given a set of arrays within an array how do I find the arrays with the minimum values based on two elements/columns in the array? Those two elements/columns are the destination zip code and distance. > > I have an array of arrays that have a origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points. > > I need to keep only those combinations that represent the minimum mileage between to the destination zip code. For example a point in New Jersey may have a distance from the Philadelphia Office that is 45 miles, from the Newark Office that is 78 miles and one from the Delaware Office that is 58 miles. > > I need to keep the mileage from the Philadelphia Office that is 45 miles and produce a .csv file that has origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points. > > The array looks like this: > > [['37015', 'TN31', 36.2777, -87.0046, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 77.338920003], > ['72202', 'ARB1', 34.739224, -92.27765, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 1099.7837975322097]] > > My code looks like this : > > import csv > import math > > > def calculate_distance(lat1, lon1, lat2, lon2): > > if (not lat1) or (not lon1) or (not lat2) or (not lon2): > return -1 > > lat1 = float(lat1) * math.pi/180 > lon1 = float(lon1) * math.pi/180 > lat2 = float(lat2) * math.pi/180 > lon2 = float(lon2) * math.pi/180 > > return 3959.0 * math.acos(math.sin(lat1) * math.sin(lat2) + math.cos(lat1) * math.cos(lat2) * math.cos(lon2-lon1)) > > #Above function changed from the following URL: http://iamtgc.com/geocoding- with-python/ > > > InputPath = "C:\\Users\\jacobs\\Downloads\\ZipCodes\\" > > ZipCodes = "zipcode.csv" > RptgOfficeFile = "Reporting_Office_2015072001.csv" > InputFile = InputPath+RptgOfficeFile > zInputFile = InputPath+ZipCodes > zOutputFile = InputPath+'Zip_Code_Distance.csv' > z1OutputFile = InputPath+'Minimum_Distance_Zip_Code_File.csv' > > > f = open(InputFile, 'r') > > zO = open(zOutputFile,'w') > z1 = open(z1OutputFile,'w') > > lines = [ ] > OfficeZipcodes = [] > ZipRptOffice = {} > OLatitude = [ ] > OLongitude = [ ] > OLocationCode = [] > dzip = [] > dLatitude = [] > dLongitude = [] > dCity = [] > dState = [] > Combined =[] > Answers = [] > > for line in f: > l = [i.strip() for i in line.split(',')] > OfficeZipcodes.append(l[4]) > ZipRptOffice[l[4]]= l[3] > OLatitude.append(l[5]) > OLongitude.append(l[6]) > OLocationCode.append(l[3]) > > del OfficeZipcodes[0] > del OLatitude[0] > del OLongitude[0] > del OLocationCode[0] > > > zf = csv.DictReader(open(zInputFile)) > #http://courses.cs.washington.edu/courses/cse140/13wi/csv-parsing.html > > for row in zf: > dzip.append(row["zip"]) > dLatitude.append(float(row["latitude"])) > dLongitude.append(float(row["longitude"])) > dCity.append(row["city"]) > dState.append(row["state"]) > > > for i in range(len(OfficeZipcodes)): > for j in range(len(dzip)): > Distance = calculate_distance(OLatitude[i], OLongitude[i],dLatitude[j],dLongitude[j]) > Combined.append([OfficeZipcodes[i], OLocationCode[i],float(OLatitude[i]),float(OLongitude[i]),dState[j],dCity[j],dzip[j], dLatitude[j],dLongitude[j],Distance]) > for i in range(len(Combined)): > zO.write(str(Combined[i][0])+","+str(Combined[i][1])+","+str(Combined[i][2])+","+ str(Combined[i][3])+","+str(Combined[i][4])+","+ str(Combined[i][5])+","+ str(Combined[i][6])+","+str(Combined[i][7])+","+ str(Combined[i][8])+","+str(Combined[i][9])+"\n") > > zO.close() > f.close() > > I am using Python 2.7 on a Windows 7 machine. > > Please help me get my head around how to accomplish this task. > > Thank you very much. > > Robert Davis Emile, Thank you I will give it a try and see if I can get it to work. I really do appreciate your effort. Robert From steve at pearwood.info Thu Jul 23 08:31:54 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Thu, 23 Jul 2015 22:31:54 +1000 Subject: global and loop control variable References: Message-ID: <55b0deb9$0$1664$c3e8da3$5496439d@news.astraweb.com> On Thu, 23 Jul 2015 09:20 pm, Lorenzo Sutton wrote: > On 23/07/2015 12:24, candide wrote: >> Now, global declaration has another restriction, as PLR explains: >> [https://docs.python.org/3.4/reference/simple_stmts.html#the-global-statement] >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> Names listed in a global statement must not be defined as formal >> parameters or in a for loop control target, >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> >> What I understand is that the following is a must-not-code: >> >> def f(): >> global i >> for i in range(1,3): >> print(10*i) [...] >> So my question is: what is the restriction about global as loop control >> variable the docs is referring to? You are correct. The above example is exactly the restriction mentions. The very next paragraph in the docs says: "CPython implementation detail: The current implementation does not enforce the two restrictions, but programs should not abuse this freedom, as future implementations may enforce them or silently change the meaning of the program." In other words, the behaviour of global loop variables is not guaranteed, and you should not use it even if the compiler/interpreter fails to raise a syntax error. > I think for situations like this one? > > def f(): > global temperature > for temperature in range(1,3): > print "In f temperature is:", temperature There's no meaningful difference between the example Candide gave (for i in range) and the example you give (for temperature in range). They both use a global for the loop variable. Only the names differ. -- Steven From rustompmody at gmail.com Thu Jul 23 08:52:53 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Thu, 23 Jul 2015 05:52:53 -0700 (PDT) Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> Message-ID: <62df49ab-1fe1-4750-b5cc-79c71d6a34f1@googlegroups.com> On Thursday, July 23, 2015 at 12:28:19 PM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > Ive known good ones) most practicing-mathematicians proceed on the assumption > > that they *discover* math and not that they *invent* it. > > For something purely abstract like mathematics, I don't > see how there's any distinction between "discovering" and > "inventing". They're two words for the same thing. > > I don't know what kind of -ist that makes me... By some strange coincidence, a colleague just sent me this article on the mathematician John Horton Conway: http://www.theguardian.com/science/2015/jul/23/john-horton-conway-the-most-charismatic-mathematician-in-the-world In which is this paragraph: -------------------------- "Conway is the rare sort of mathematician whose ability to connect his pet mathematical interests makes one wonder if he isn't, at some level, shaping mathematical reality and not just exploring it," James Propp, a professor of mathematics at the University of Massachusetts Lowell, once told me. "The example of this that I know best is a connection he discovered between sphere packing and games. These were two separate areas of study that Conway had arrived at by two different paths. So there's no reason for them to be linked. But somehow, through the force of his personality, and the intensity of his passion, he bent the mathematical universe to his will." -------------------------- From lorenzofsutton at gmail.com Thu Jul 23 09:58:55 2015 From: lorenzofsutton at gmail.com (Lorenzo Sutton) Date: Thu, 23 Jul 2015 15:58:55 +0200 Subject: global and loop control variable In-Reply-To: <55b0deb9$0$1664$c3e8da3$5496439d@news.astraweb.com> References: <55b0deb9$0$1664$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55B0F31F.3070104@gmail.com> On 23/07/2015 14:31, Steven D'Aprano wrote: > On Thu, 23 Jul 2015 09:20 pm, Lorenzo Sutton wrote: > >> On 23/07/2015 12:24, candide wrote: >>> Now, global declaration has another restriction, as PLR explains: >>> > [https://docs.python.org/3.4/reference/simple_stmts.html#the-global-statement] >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> Names listed in a global statement must not be defined as formal >>> parameters or in a for loop control target, >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> >>> What I understand is that the following is a must-not-code: >>> >>> def f(): >>> global i >>> for i in range(1,3): >>> print(10*i) > [...] >>> So my question is: what is the restriction about global as loop control >>> variable the docs is referring to? > > You are correct. The above example is exactly the restriction mentions. The > very next paragraph in the docs says: > > "CPython implementation detail: The current implementation does not enforce > the two restrictions, but programs should not abuse this freedom, as future > implementations may enforce them or silently change the meaning of the > program." > > In other words, the behaviour of global loop variables is not guaranteed, > and you should not use it even if the compiler/interpreter fails to raise a > syntax error. > > >> I think for situations like this one? >> >> def f(): >> global temperature >> for temperature in range(1,3): >> print "In f temperature is:", temperature > > > There's no meaningful difference between the example Candide gave (for i in > range) and the example you give (for temperature in range). They both use a > global for the loop variable. Only the names differ. Of course... it was just to highlight that it could be potentially, especially if your programme is going to launch a rocket - eventually (see my entire code example) :-) Lorenzo. From oracle.blog3 at gmail.com Thu Jul 23 10:04:38 2015 From: oracle.blog3 at gmail.com (max scalf) Date: Thu, 23 Jul 2015 09:04:38 -0500 Subject: unexpected output while using list(and nested dictionary) In-Reply-To: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> References: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> Message-ID: I am sorry for doing what i did (asking question in Stackoverflow and pasting the link here). I will keep this in mind for the future. I am very much new to this list, so was not sure. Do you guys have any suggestion as to what to use if the code is lone, as the formatting gets lost in an email... On Thu, Jul 23, 2015 at 12:36 AM, Steven D'Aprano < steve+comp.lang.python at pearwood.info> wrote: > On Thursday 23 July 2015 08:09, max scalf wrote: > > > Hello List, > > > > I have posted a question on stack overflow for better readability ... but > > is intended for python list.... Please see question below... > > If it's intended for here, please ask it here. > > Consider that there may be people here who are willing and able to answer > your question, but either don't have an account on Stackoverflow, have > access to SO blocked, or simply don't like the culture and ethos of SO and > won't use it. > > > -- > Steve > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From subhabrata.banerji at gmail.com Thu Jul 23 10:20:04 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Thu, 23 Jul 2015 07:20:04 -0700 (PDT) Subject: Search in Flask Restful Message-ID: Dear Group, I am trying to build one REST framework using Restful Flask. To put or get I am trying to use the requests module, as given in the following lines. >>> var2=requests.put('http://127.0.0.1:5000/todos/todo1', data={'task': 'It is my challenge'}) >>> var3=requests.get('http://127.0.0.1:5000/todos/todo1') Now I like to search plain as well as Boolean over this Rest. If I could understand the problem fine, the exercises are given in the following URL. http://flask-restless.readthedocs.org/en/latest/searchformat.html#examples But I am looking for examples with requests. I searched for help with requests in http://docs.python-requests.org/en/latest/, it did not help much. If anyone of the esteemed members may kindly suggest. I am using Python2.7+ on Windows 7. Apology for any indentation error. Regards, Subhabrata Banerjee From steve at pearwood.info Thu Jul 23 10:57:42 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 24 Jul 2015 00:57:42 +1000 Subject: unexpected output while using list(and nested dictionary) References: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55b100e6$0$1640$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Jul 2015 12:04 am, max scalf wrote: > I am sorry for doing what i did (asking question in Stackoverflow and > pasting the link here). I will keep this in mind for the future. I am > very much new to this list, so was not sure. > > Do you guys have any suggestion as to what to use if the code is lone, as > the formatting gets lost in an email... Use a tool that doesn't break your emails. If you turn "Rich Text" or "Formatted Text" on, your mail will be sent as HTML code. That is a poor choice for formatting text, but it's a standard now, no matter the disadvantages (and there are many). HTML will wreck your formatting. If you turn "Rich Text" or "Formatting" off, and send as regular plain text with no bold, italics, inline pictures, dancing paperclips, embedded music or whatever other nonsense people like to stick in their emails these days, then any decent mail client will send *exactly what you type* with no frills or mangling. So if you type: def function(a, b): return a + 2*b # that's four spaces at the start of the line then that's exactly what will be sent, including the four spaces. If your mail program doesn't do that, then it is broken, like a car that can only turn left or a toaster that sets fire to the bread. Use a better email program. Another alternative is to save your code in a .py file, then attach it to the email as an attachment. Even the most obnoxious email program doesn't mangle attachments, at least not deliberately. But that can be inconvenient. Worst case, you can post your code in a pastebin, or some other website. But by doing so, understand that (1) you are limiting the usefulness of your question to others, who might learn from it in the future, and (2) limiting the number of people who are willing and able to answer. -- Steven From ben+python at benfinney.id.au Thu Jul 23 11:52:54 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 24 Jul 2015 01:52:54 +1000 Subject: unexpected output while using list(and nested dictionary) References: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> Message-ID: <857fpqooq1.fsf@benfinney.id.au> max scalf writes: > I am sorry for doing what i did (asking question in Stackoverflow and > pasting the link here). No harm done. The rule isn't special to this forum; it's best to minimise the fragility of your message by not relying on many sites all staying the same over a long time. > Do you guys have any suggestion as to what to use if the code is lone, > as the formatting gets lost in an email... First, always post in ?plain text?; don't present program code in a ?rich text? or ?HTML mail? or any other magical formatting tool. Second, don't post long code examples. Work up a small, self-contained, complete compilable example so that there isn't any extraneous material, only the code that demonstrates the behaviour that confuses you. The reason to do that for presentation here is that you want the code to be short enough that people will find it worth their time to volunteer to help you. But an important side benefit is: in stripping the example down so that it doesn't contain anything not needed to demonstrate the behaviour, you may end up understanding it well enough to solve the problem yourself ? which is a valuable skill and very much worth your while :-) -- \ ?If you always want the latest and greatest, then you have to | `\ buy a new iPod at least once a year.? ?Steve Jobs, MSNBC | _o__) interview 2006-05-25 | Ben Finney From lac at openend.se Thu Jul 23 11:54:44 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 23 Jul 2015 17:54:44 +0200 Subject: unexpected output while using list(and nested dictionary) In-Reply-To: Message from max scalf of "Thu, 23 Jul 2015 09:04:38 -0500." References: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507231554.t6NFsiF0026920@fido.openend.se> In a message of Thu, 23 Jul 2015 09:04:38 -0500, max scalf writes: >I am sorry for doing what i did (asking question in Stackoverflow and >pasting the link here). I will keep this in mind for the future. I am >very much new to this list, so was not sure. > >Do you guys have any suggestion as to what to use if the code is lone, as >the formatting gets lost in an email... You need to set up your mailer to send "plain text mail". Since you are using a gmail account, I assume you are using gmail. Googling for 'gmail plain text email' gives lots of hits -- apparantly Google has changed how composing email works at least once, and I cannot tell which of these hits is for current gmail and not gmail-of-5-years-ago If you aren't using gmail, you need to google for whatever mailer you are using and "plain text email". Laura From lac at openend.se Thu Jul 23 12:10:27 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 23 Jul 2015 18:10:27 +0200 Subject: unexpected output while using list(and nested dictionary) In-Reply-To: Message from "Steven D'Aprano" of "Fri, 24 Jul 2015 00:57:42 +1000." <55b100e6$0$1640$c3e8da3$5496439d@news.astraweb.com> References: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> <55b100e6$0$1640$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507231610.t6NGARD7027399@fido.openend.se> In a message of Fri, 24 Jul 2015 00:57:42 +1000, "Steven D'Aprano" writes: >On Fri, 24 Jul 2015 12:04 am, max scalf wrote: >Another alternative is to save your code in a .py file, then attach it to >the email as an attachment. Even the most obnoxious email program doesn't >mangle attachments, at least not deliberately. But that can be >inconvenient. python.org scrubs all attatchments on some lists. I am not sure if this is one of them -- convincing his email client to send plain text emails is the correct thing to do here. Laura From rustompmody at gmail.com Thu Jul 23 12:28:16 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Thu, 23 Jul 2015 09:28:16 -0700 (PDT) Subject: unexpected output while using list(and nested dictionary) In-Reply-To: References: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thursday, July 23, 2015 at 9:25:46 PM UTC+5:30, Laura Creighton wrote: > In a message of Thu, 23 Jul 2015 09:04:38 -0500, max scalf writes: > >I am sorry for doing what i did (asking question in Stackoverflow and > >pasting the link here). I will keep this in mind for the future. I am > >very much new to this list, so was not sure. > > > >Do you guys have any suggestion as to what to use if the code is lone, as > >the formatting gets lost in an email... > > You need to set up your mailer to send "plain text mail". > > Since you are using a gmail account, I assume you are using gmail. > Googling for 'gmail plain text email' gives lots of hits -- apparantly > Google has changed how composing email works at least once, and I > cannot tell which of these hits is for current gmail and not > gmail-of-5-years-ago gmail ? Compose ? Tiny downward triangle in right bottom of compose window ? Select plain text From rdavis7408 at gmail.com Thu Jul 23 12:37:36 2015 From: rdavis7408 at gmail.com (Robert Davis) Date: Thu, 23 Jul 2015 09:37:36 -0700 (PDT) Subject: How we can send mail with attachment in Python? In-Reply-To: References: Message-ID: <31638e19-0936-475b-97cb-c0a3c59b250b@googlegroups.com> On Monday, July 20, 2015 at 12:01:49 AM UTC-5, Chris Angelico wrote: > On Mon, Jul 20, 2015 at 2:54 PM, Kevin Peterson wrote: > > How we can send mail with attachment in Python? Is it any prerequisite for it? > > You could use your favourite search engine to look this up. Or you > could poke around with the Python standard library and see if anything > looks promising: > > https://docs.python.org/3/library/ > > Hint: There is something there. > > ChrisA Take a look at an article written by Ashish Jain at the following link: http://ashishpython.blogspot.com/2014/06/send-email-with-outlook-in-python.html I use something very similar to automate sending of monthly reports. HTH Robert From invalid at invalid.invalid Thu Jul 23 13:08:39 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 23 Jul 2015 17:08:39 +0000 (UTC) Subject: unexpected output while using list(and nested dictionary) References: <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com> <55b100e6$0$1640$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2015-07-23, Steven D'Aprano wrote: > On Fri, 24 Jul 2015 12:04 am, max scalf wrote: [...] >> Do you guys have any suggestion as to what to use if the code is >> lone, as the formatting gets lost in an email... > > Use a tool that doesn't break your emails. > > If you turn "Rich Text" or "Formatted Text" on, your mail will be > sent as HTML code. That is a poor choice for formatting text, but > it's a standard now, no matter the disadvantages (and there are > many). HTML will wreck your formatting. In theory, code inside a
       tag should be more-or-less OK
      (most of the time), but people sending HTML e-mail never seem to know
      how to do that.  [Or probably their e-mail client is too broken to
      even allow such a thing.]
      
      > If you turn "Rich Text" or "Formatting" off, and send as regular
      > plain text with no bold, italics, inline pictures, dancing
      > paperclips, embedded music or whatever other nonsense people like to
      > stick in their emails these days, then any decent mail client will
      > send *exactly what you type* with no frills or mangling. So if you
      > type:
      >
      > def function(a, b):
      >     return a + 2*b  # that's four spaces at the start of the line
      >
      > then that's exactly what will be sent, including the four spaces.
      
      That's definitely, by far, the very best option.
      
      > If your mail program doesn't do that, then it is broken, like a car
      > that can only turn left or a toaster that sets fire to the bread. Use
      > a better email program.
      
      I recomment mutt if you really want to stick with getting everything
      e-mailed to you (which I personally don't like).  Better yet (IMO)
      point slrn or your favorite NNTP client at comp.lang.python on your
      friendly local Usenet server or at gmane's nntp server at
      nntp://news.gmane.org/gmane.comp.python.general.
      
      > Another alternative is to save your code in a .py file, then attach
      > it to the email as an attachment. Even the most obnoxious email
      > program doesn't mangle attachments, at least not deliberately. But
      > that can be inconvenient.
      
      A lot of people are not going to open attachments sent by some random
      stranger.  Some people might (even though they probably should not),
      but it could be the person who knows the answer to your problem won't
      bother -- either because of the effor or risk involved.  Especially on
      Windows, opening e-mail attachments seems to be a rather dangerous
      thing to do.
      
      Do attachments sent to the mailing list make it realiably through
      gateways to places like comp.lang.python or into gmane's "view" of the
      mailing list?
      
      -- 
      Grant Edwards               grant.b.edwards        Yow! Let me do my TRIBUTE
                                        at               to FISHNET STOCKINGS ...
                                    gmail.com            
      
      
      From ryan.xgamer99 at gmail.com  Thu Jul 23 13:31:21 2015
      From: ryan.xgamer99 at gmail.com (Ryan Holmes)
      Date: Thu, 23 Jul 2015 10:31:21 -0700 (PDT)
      Subject: Stripping sRGB profile from PNGs in python
      Message-ID: <06483a3b-c4e3-4c95-8c14-2ab01228f414@googlegroups.com>
      
      We're getting this error when trying to load some of out projects images:
         
          libpng warning: iCCP: known incorrect sRGB profile
      
      The source files that we have some with incorrect sRGB profiles. We don't have control over the source files, but what we normally do is take them and scale them down for our own project. To fix this issue, we can use this shell one-liner:
      
          find . -type f -name "*.png" -exec convert {} {} \;
      
      Which basically converts the ONGs into themselves, but it strips the profile (or maybe overwrites with a correct profile).
      
      We would like to incorporate this functionality into our python script which scales the source images, but we haven' found a way to do this. Any thoughts?
      
          
      
      
      From emile at fenx.com  Thu Jul 23 13:42:01 2015
      From: emile at fenx.com (Emile van Sebille)
      Date: Thu, 23 Jul 2015 10:42:01 -0700
      Subject: Stripping sRGB profile from PNGs in python
      In-Reply-To: <06483a3b-c4e3-4c95-8c14-2ab01228f414@googlegroups.com>
      References: <06483a3b-c4e3-4c95-8c14-2ab01228f414@googlegroups.com>
      Message-ID: 
      
      On 7/23/2015 10:31 AM, Ryan Holmes wrote:
      > We're getting this error when trying to load some of out projects images:
      >
      >      libpng warning: iCCP: known incorrect sRGB profile
      >
      > The source files that we have some with incorrect sRGB profiles. We don't have control over the source files, but what we normally do is take them and scale them down for our own project. To fix this issue, we can use this shell one-liner:
      >
      >      find . -type f -name "*.png" -exec convert {} {} \;
      >
      > Which basically converts the ONGs into themselves, but it strips the profile (or maybe overwrites with a correct profile).
      >
      > We would like to incorporate this functionality into our python script which scales the source images, but we haven' found a way to do this. Any thoughts?
      
      
      Use the appropriate shell out command for your python version.  There've 
      been too many over the years -- on the system I'm at today running 
      Python 2.5 I'm using the commands module.
      
      For example:
      
      commands.getoutput('for ii in /proc/[0-9]*/environ; do echo $ii; strings 
      $ii ; done').split()
      
      Emile
      
      
      
      
      
      From breamoreboy at yahoo.co.uk  Thu Jul 23 13:45:53 2015
      From: breamoreboy at yahoo.co.uk (Mark Lawrence)
      Date: Thu, 23 Jul 2015 18:45:53 +0100
      Subject: unexpected output while using list(and nested dictionary)
      In-Reply-To: 
      References: 
       <55b07d5a$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <55b100e6$0$1640$c3e8da3$5496439d@news.astraweb.com>
       
      Message-ID: 
      
      On 23/07/2015 18:08, Grant Edwards wrote:
      > I recomment mutt if you really want to stick with getting everything
      > e-mailed to you (which I personally don't like).  Better yet (IMO)
      > point slrn or your favorite NNTP client at comp.lang.python on your
      > friendly local Usenet server or at gmane's nntp server at
      > nntp://news.gmane.org/gmane.comp.python.general.
      
      For those who aren't aware and as a reminder for those who are, there 
      are 387 Python related lists at 
      http://news.gmane.org/index.php?prefix=gmane.comp.python.
      
      -- 
      My fellow Pythonistas, ask not what our language can do for you, ask
      what you can do for our language.
      
      Mark Lawrence
      
      
      
      From lac at openend.se  Thu Jul 23 14:16:46 2015
      From: lac at openend.se (Laura Creighton)
      Date: Thu, 23 Jul 2015 20:16:46 +0200
      Subject: Stripping sRGB profile from PNGs in python
      In-Reply-To: Message from Ryan Holmes  of "Thu,
       23 Jul 2015 10:31:21 -0700."
       <06483a3b-c4e3-4c95-8c14-2ab01228f414@googlegroups.com>
      References: <06483a3b-c4e3-4c95-8c14-2ab01228f414@googlegroups.com>
      Message-ID: <201507231816.t6NIGkmr030290@fido.openend.se>
      
      To scale images, you should get Pillow, which can construct new images
      based on old ones for arbitrary size. see:
      http://pillow.readthedocs.org/en/latest/reference/Image.html
      
      Pillow is a fork of PIL.  PIL isn't being maintained, Pillow is.
      
      Note that reading this is a good idea:
      http://united-coders.com/christian-harms/image-resizing-tips-every-coder-should-know/
      
      It even has some code that you can probably use, though I haven't tested it.
      It just, ah, looks right. :)
      
      Laura
      
      
      
      From irmen.NOSPAM at xs4all.nl  Thu Jul 23 14:57:00 2015
      From: irmen.NOSPAM at xs4all.nl (Irmen de Jong)
      Date: Thu, 23 Jul 2015 20:57:00 +0200
      Subject: problem with selecting remote procedure calls
      In-Reply-To: 
      References: <21624840.357.1437621015246.JavaMail.eric@aho>
       
      Message-ID: <55b138fb$0$2832$e4fe514c@news.xs4all.nl>
      
      On 23-7-2015 13:39, Tim Golden wrote:
      > On 23/07/2015 04:10, eric johansson wrote:
      >> https://docs.google.com/drawings/d/1M-TzfRaSaAhFXQk1OmcmHNOaW31_7W_7q0bf8CAJqSw/edit?usp=sharing
      >>
      >>  while this is related to my speech recognition through the next
      >> project, is actually a good question for RPCs in general.
      >> Specifically, are there any good-RPCs out there that are fast,
      >> supported, and easy to use?
      > 
      > It looks like a decent fit for Pyro:
      > 
      >   https://github.com/irmen/Pyro4
      >   http://pythonhosted.org/Pyro4/
      >   https://pypi.python.org/pypi/Pyro4
      > 
      > Pyro's certainly actively maintained and I've seen its developer, Irmen
      > de Jong, pop up on this list fairly recently.
      
      Hi!
      
      
      > Exactly how good a fit it is would depend on your precise setup. But I
      > think it's worth exploring. I can't speak as to its speed -- I've only
      > used it where speed wasn't really an issue.
      
      Performance depends on many factors. I used to have a table with numbers in the manual
      but since replaced it by a more general indication;
      http://pythonhosted.org/Pyro4/intro.html#performance
      
      Eric, if you're concerned about performance, Pyro4 (the source distribution) comes with
      several examples that do simple performance related tests. You could run these and see
      what figures you get on your setup to see if it's anywhere acceptable, before even
      building anything with Pyro yourself.
      
      Interesting project btw.
      Good luck!
      
      Irmen
      
      
      
      
      
      From ian.g.kelly at gmail.com  Thu Jul 23 15:34:11 2015
      From: ian.g.kelly at gmail.com (Ian Kelly)
      Date: Thu, 23 Jul 2015 11:34:11 -0800
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
      Message-ID: 
      
      On Jul 22, 2015 9:46 PM, "Steven D'Aprano" <
      steve+comp.lang.python at pearwood.info> wrote:
      >
      > On Thursday 23 July 2015 04:09, Rustom Mody wrote:
      >
      > > tl;dr To me (as unprofessional a musician as mathematician) I find it
      > > arbitrary that Newton *discovered* gravity whereas Beethoven *composed*
      > > the 9th symphony.
      >
      > Newton didn't precisely *discover* gravity. I'm pretty sure that people
      > before him didn't think that they were floating through the air
      > weightless...
      >
      > *wink*
      >
      >
      > Did gravity exist before Newton? Then he discovered it (in some sense).
      >
      > Did the 9th Symphony exist before Beethoven? No? Then he composed it.
      
      Gravity existed before Newton, but the *theory* of gravity did not, so he
      composed the theory?
      -------------- next part --------------
      An HTML attachment was scrubbed...
      URL: 
      
      From marko at pacujo.net  Thu Jul 23 16:59:11 2015
      From: marko at pacujo.net (Marko Rauhamaa)
      Date: Thu, 23 Jul 2015 23:59:11 +0300
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
      Message-ID: <87egjy380w.fsf@elektro.pacujo.net>
      
      Ian Kelly :
      
      > Gravity existed before Newton, but the *theory* of gravity did not, so
      > he composed the theory?
      
      Ironically, gravity is maybe the least well understood phenomenon in
      modern physics.
      
      
      Marko
      
      
      From rosuav at gmail.com  Thu Jul 23 17:03:24 2015
      From: rosuav at gmail.com (Chris Angelico)
      Date: Fri, 24 Jul 2015 07:03:24 +1000
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: <87egjy380w.fsf@elektro.pacujo.net>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
      Message-ID: 
      
      On Fri, Jul 24, 2015 at 6:59 AM, Marko Rauhamaa  wrote:
      > Ian Kelly :
      >
      >> Gravity existed before Newton, but the *theory* of gravity did not, so
      >> he composed the theory?
      >
      > Ironically, gravity is maybe the least well understood phenomenon in
      > modern physics.
      
      Fortunately, we don't need to completely understand it. New Horizons
      reached Pluto right on time after a decade of flight that involved
      taking a left turn at Jupiter... we can predict exactly what angle to
      fire the rockets at in order to get where we want to go, even without
      knowing how that gravity yank works.
      
      Practicality beats purity?
      
      ChrisA
      
      
      From abder.rahman.ali at gmail.com  Thu Jul 23 17:09:38 2015
      From: abder.rahman.ali at gmail.com (Abder-Rahman Ali)
      Date: Thu, 23 Jul 2015 23:09:38 +0200
      Subject: Object Pool design pattern
      Message-ID: 
      
      Hello,
      
      How can we implement the Object Pool design pattern in Python, especially
      when the pool consists of array data types?
      
      Thanks.
      -------------- next part --------------
      An HTML attachment was scrubbed...
      URL: 
      
      From marko at pacujo.net  Thu Jul 23 17:29:28 2015
      From: marko at pacujo.net (Marko Rauhamaa)
      Date: Fri, 24 Jul 2015 00:29:28 +0300
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
      Message-ID: <878ua636mf.fsf@elektro.pacujo.net>
      
      Chris Angelico :
      
      > Fortunately, we don't need to completely understand it. New Horizons
      > reached Pluto right on time after a decade of flight that involved
      > taking a left turn at Jupiter... we can predict exactly what angle to
      > fire the rockets at in order to get where we want to go, even without
      > knowing how that gravity yank works.
      >
      > Practicality beats purity?
      
      Engineer!
      
      At the time I was in college I heard topology was very fashionable among
      mathematicians. That was because it was one of the last remaining
      research topics that didn't yet have an application.
      
      
      Marko
      
      
      From rdavis7408 at gmail.com  Thu Jul 23 17:50:06 2015
      From: rdavis7408 at gmail.com (Robert Davis)
      Date: Thu, 23 Jul 2015 14:50:06 -0700 (PDT)
      Subject: Find Minimum for element in multiple dimensional array
      In-Reply-To: 
      References: 
      Message-ID: <462065e7-88b6-4324-86e6-8f15a62c5c7e@googlegroups.com>
      
      On Wednesday, July 22, 2015 at 5:54:30 PM UTC-5, Robert Davis wrote:
      > Given a set of arrays within an array how do I find the arrays with the minimum values based on two elements/columns in the array? Those two elements/columns are the destination zip code and distance.
      > 
      > I have an array of arrays that have a origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points.
      > 
      > I need to keep only those combinations that represent the minimum mileage between to the destination zip code. For example a point in New Jersey may have a distance from the Philadelphia Office that is 45 miles, from the Newark Office that is 78 miles and one from the Delaware Office that is 58 miles.
      > 
      > I need to keep the mileage from the Philadelphia Office that is 45 miles and produce a .csv file that has origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points.
      > 
      > The array looks like this:
      > 
      > [['37015', 'TN31', 36.2777, -87.0046, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 77.338920003], 
      > ['72202', 'ARB1', 34.739224, -92.27765, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 1099.7837975322097]]
      > 
      > My code looks like this :
      > 
      > import csv
      > import math
      > 
      > 
      > def calculate_distance(lat1, lon1, lat2, lon2):
      > 
      >     if (not lat1) or (not lon1) or (not lat2) or (not lon2):
      >             return -1
      > 
      >     lat1 = float(lat1) * math.pi/180
      >     lon1 = float(lon1) * math.pi/180
      >     lat2 = float(lat2) * math.pi/180
      >     lon2 = float(lon2) * math.pi/180
      > 
      >     return 3959.0 * math.acos(math.sin(lat1) * math.sin(lat2) +   math.cos(lat1) * math.cos(lat2) * math.cos(lon2-lon1))
      > 
      > #Above function changed from the following URL: http://iamtgc.com/geocoding- with-python/
      > 
      > 
      > InputPath = "C:\\Users\\jacobs\\Downloads\\ZipCodes\\"
      > 
      > ZipCodes = "zipcode.csv"
      > RptgOfficeFile = "Reporting_Office_2015072001.csv"
      > InputFile = InputPath+RptgOfficeFile
      > zInputFile = InputPath+ZipCodes
      > zOutputFile = InputPath+'Zip_Code_Distance.csv'
      > z1OutputFile = InputPath+'Minimum_Distance_Zip_Code_File.csv'
      > 
      > 
      > f = open(InputFile, 'r')
      > 
      > zO = open(zOutputFile,'w')
      > z1 = open(z1OutputFile,'w')
      > 
      > lines = [ ]
      > OfficeZipcodes = []
      > ZipRptOffice = {}
      > OLatitude = [ ]
      > OLongitude = [ ]
      > OLocationCode = []
      > dzip = []
      > dLatitude = []
      > dLongitude = []
      > dCity = []
      > dState = []
      > Combined =[]
      > Answers = []
      > 
      > for line in f:
      >   l = [i.strip() for i in line.split(',')]
      >   OfficeZipcodes.append(l[4])
      >   ZipRptOffice[l[4]]= l[3]
      >   OLatitude.append(l[5])
      >   OLongitude.append(l[6])
      >   OLocationCode.append(l[3])
      > 
      > del OfficeZipcodes[0]
      > del OLatitude[0] 
      > del OLongitude[0]
      > del OLocationCode[0]
      > 
      > 
      > zf = csv.DictReader(open(zInputFile))
      > #http://courses.cs.washington.edu/courses/cse140/13wi/csv-parsing.html
      > 
      > for row in zf:
      >     dzip.append(row["zip"])
      >     dLatitude.append(float(row["latitude"]))
      >     dLongitude.append(float(row["longitude"]))
      >     dCity.append(row["city"])
      >     dState.append(row["state"])
      > 
      > 
      > for i in range(len(OfficeZipcodes)):
      >     for j in range(len(dzip)):
      >         Distance = calculate_distance(OLatitude[i], OLongitude[i],dLatitude[j],dLongitude[j])
      >         Combined.append([OfficeZipcodes[i], OLocationCode[i],float(OLatitude[i]),float(OLongitude[i]),dState[j],dCity[j],dzip[j], dLatitude[j],dLongitude[j],Distance])
      > for i in range(len(Combined)):
      >   zO.write(str(Combined[i][0])+","+str(Combined[i][1])+","+str(Combined[i][2])+","+ str(Combined[i][3])+","+str(Combined[i][4])+","+ str(Combined[i][5])+","+ str(Combined[i][6])+","+str(Combined[i][7])+","+ str(Combined[i][8])+","+str(Combined[i][9])+"\n")
      > 
      > zO.close()
      > f.close()
      > 
      > I am using Python 2.7 on a Windows 7 machine.
      > 
      > Please help me get my head around how to accomplish this task.
      > 
      > Thank you very much.
      > 
      > Robert Davis
      
      Emile,
      
      Thanks so much works wonderfully. It is certainly a brilliant way of seeing the resolution.
      
      Robert
      
      
      From breamoreboy at yahoo.co.uk  Thu Jul 23 17:50:51 2015
      From: breamoreboy at yahoo.co.uk (Mark Lawrence)
      Date: Thu, 23 Jul 2015 22:50:51 +0100
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: <878ua636mf.fsf@elektro.pacujo.net>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net>
      Message-ID: 
      
      On 23/07/2015 22:29, Marko Rauhamaa wrote:
      > Chris Angelico :
      >
      >> Fortunately, we don't need to completely understand it. New Horizons
      >> reached Pluto right on time after a decade of flight that involved
      >> taking a left turn at Jupiter... we can predict exactly what angle to
      >> fire the rockets at in order to get where we want to go, even without
      >> knowing how that gravity yank works.
      >>
      >> Practicality beats purity?
      >
      > Engineer!
      >
      
      Heard the one about the three engineers in the car that breaks down?
      
      The chemical engineer suggests that they could have contaminated fuel. 
      They should try and get a sample and get someone to take it to a lab for 
      analysis.
      
      The electrical engineer suggests that they check the battery and the 
      leads for any problems.
      
      The Microsoft engineer suggests that they close all the windows, get out 
      of the car, get back in the car, open all the windows and see what happens.
      
      -- 
      My fellow Pythonistas, ask not what our language can do for you, ask
      what you can do for our language.
      
      Mark Lawrence
      
      
      
      From lac at openend.se  Thu Jul 23 17:52:43 2015
      From: lac at openend.se (Laura Creighton)
      Date: Thu, 23 Jul 2015 23:52:43 +0200
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: Message from Marko Rauhamaa 
       of "Fri, 24 Jul 2015 00:29:28 +0300." <878ua636mf.fsf@elektro.pacujo.net>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       <878ua636mf.fsf@elektro.pacujo.net>
      Message-ID: <201507232152.t6NLqhDT003189@fido.openend.se>
      
      In a message of Fri, 24 Jul 2015 00:29:28 +0300, Marko Rauhamaa writes:
      >Chris Angelico :
      >
      >> Fortunately, we don't need to completely understand it. New Horizons
      >> reached Pluto right on time after a decade of flight that involved
      >> taking a left turn at Jupiter... we can predict exactly what angle to
      >> fire the rockets at in order to get where we want to go, even without
      >> knowing how that gravity yank works.
      >>
      >> Practicality beats purity?
      >
      >Engineer!
      >
      >At the time I was in college I heard topology was very fashionable among
      >mathematicians. That was because it was one of the last remaining
      >research topics that didn't yet have an application.
      >
      >
      >Marko
      
      I have a very good freind who is a knot-theorist.  (Chad Musick, who
      may have proven something wonderful.) see: http://chadmusick.wikidot.com/knots
      He says there are lots of applications for this in the field of circuit
      board layouts.  And most mathematicians accept knot-theory as part of
      topology.
      
      Laura
      
      
      From marko at pacujo.net  Thu Jul 23 17:59:53 2015
      From: marko at pacujo.net (Marko Rauhamaa)
      Date: Fri, 24 Jul 2015 00:59:53 +0300
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net>
       
      Message-ID: <87zj2m1qna.fsf@elektro.pacujo.net>
      
      Laura Creighton :
      
      > In a message of Fri, 24 Jul 2015 00:29:28 +0300, Marko Rauhamaa writes:
      >>At the time I was in college I heard topology was very fashionable
      >>among mathematicians. That was because it was one of the last
      >>remaining research topics that didn't yet have an application.
      >
      > I have a very good freind who is a knot-theorist. (Chad Musick, who
      > may have proven something wonderful.) see:
      > http://chadmusick.wikidot.com/knots He says there are lots of
      > applications for this in the field of circuit board layouts. And most
      > mathematicians accept knot-theory as part of topology.
      
      So topology, too, is lost.
      
      
      Marko
      
      
      From rosuav at gmail.com  Thu Jul 23 18:00:15 2015
      From: rosuav at gmail.com (Chris Angelico)
      Date: Fri, 24 Jul 2015 08:00:15 +1000
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: 
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net> 
      Message-ID: 
      
      On Fri, Jul 24, 2015 at 7:50 AM, Mark Lawrence  wrote:
      > Heard the one about the three engineers in the car that breaks down?
      >
      > The chemical engineer suggests that they could have contaminated fuel. They
      > should try and get a sample and get someone to take it to a lab for
      > analysis.
      >
      > The electrical engineer suggests that they check the battery and the leads
      > for any problems.
      >
      > The Microsoft engineer suggests that they close all the windows, get out of
      > the car, get back in the car, open all the windows and see what happens.
      >
      
      And the data scientist proved that the phenomenon is not wholly
      unlikely, given the predicted average reliability of cars; further
      studies would require improved sample size.
      
      ChrisA
      
      
      From python at mrabarnett.plus.com  Thu Jul 23 18:01:51 2015
      From: python at mrabarnett.plus.com (MRAB)
      Date: Thu, 23 Jul 2015 23:01:51 +0100
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: 
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net> 
      Message-ID: <55B1644F.5070300@mrabarnett.plus.com>
      
      On 2015-07-23 22:50, Mark Lawrence wrote:
      > On 23/07/2015 22:29, Marko Rauhamaa wrote:
      >> Chris Angelico :
      >>
      >>> Fortunately, we don't need to completely understand it. New Horizons
      >>> reached Pluto right on time after a decade of flight that involved
      >>> taking a left turn at Jupiter... we can predict exactly what angle to
      >>> fire the rockets at in order to get where we want to go, even without
      >>> knowing how that gravity yank works.
      >>>
      >>> Practicality beats purity?
      >>
      >> Engineer!
      >>
      >
      > Heard the one about the three engineers in the car that breaks down?
      >
      > The chemical engineer suggests that they could have contaminated fuel.
      > They should try and get a sample and get someone to take it to a lab for
      > analysis.
      >
      > The electrical engineer suggests that they check the battery and the
      > leads for any problems.
      >
      > The Microsoft engineer suggests that they close all the windows, get out
      > of the car, get back in the car, open all the windows and see what happens.
      >
      And an Apple engineer would suggest buying a new car that runs only on
      its manufacturer's brand of fuel. :-)
      
      
      
      From rosuav at gmail.com  Thu Jul 23 18:02:55 2015
      From: rosuav at gmail.com (Chris Angelico)
      Date: Fri, 24 Jul 2015 08:02:55 +1000
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: <87zj2m1qna.fsf@elektro.pacujo.net>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net>
       
       <87zj2m1qna.fsf@elektro.pacujo.net>
      Message-ID: 
      
      On Fri, Jul 24, 2015 at 7:59 AM, Marko Rauhamaa  wrote:
      > Laura Creighton :
      >
      >> In a message of Fri, 24 Jul 2015 00:29:28 +0300, Marko Rauhamaa writes:
      >>>At the time I was in college I heard topology was very fashionable
      >>>among mathematicians. That was because it was one of the last
      >>>remaining research topics that didn't yet have an application.
      >>
      >> I have a very good freind who is a knot-theorist. (Chad Musick, who
      >> may have proven something wonderful.) see:
      >> http://chadmusick.wikidot.com/knots He says there are lots of
      >> applications for this in the field of circuit board layouts. And most
      >> mathematicians accept knot-theory as part of topology.
      >
      > So topology, too, is lost.
      
      You remind me of the hipster mathematician cook, who burned himself by
      calculating pie before it was cool.
      
      ChrisA
      
      
      From lac at openend.se  Thu Jul 23 18:19:30 2015
      From: lac at openend.se (Laura Creighton)
      Date: Fri, 24 Jul 2015 00:19:30 +0200
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: Message from MRAB 
       of "Thu, 23 Jul 2015 23:01:51 +0100." <55B1644F.5070300@mrabarnett.plus.com>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net>
       <55B1644F.5070300@mrabarnett.plus.com>
      Message-ID: <201507232219.t6NMJU4P003991@fido.openend.se>
      
      In a message of Thu, 23 Jul 2015 23:01:51 +0100, MRAB writes:
      
      >And an Apple engineer would suggest buying a new car that runs only on
      >its manufacturer's brand of fuel. :-)
      
      Before you do that, read this:
      http://teslaclubsweden.se/test-drive-of-a-petrol-car/
      (ps, if you can read Swedish, the Swedish version is a little more fun.)
      
      Laura
      
      
      From rantingrickjohnson at gmail.com  Thu Jul 23 18:49:46 2015
      From: rantingrickjohnson at gmail.com (Rick Johnson)
      Date: Thu, 23 Jul 2015 15:49:46 -0700 (PDT)
      Subject: Should non-security 2.7 bugs be fixed?
      In-Reply-To: 
      References: 
       
      Message-ID: <69ec07d2-eae9-409c-b54a-ba0fccd47015@googlegroups.com>
      
      On Wednesday, July 22, 2015 at 11:26:50 PM UTC-5, Jason Swails wrote:
      > I know my experiences don't hold true for everybody, but I
      > also don't think they are uncommon (I know several
      > colleagues that share many aspects of them).? And for me,
      > the *better* Python 2.7 becomes, and the longer it's kept
      > around, the easier (and more fun!) it makes my transition
      > to Python 3.? So for me at least, arguments like "don't
      > make Python 2.7 too good or people won't switch" are not
      > only wrong, but in actuality counter-productive.
      
      Thanks for sharing your story. You offer a compelling
      argument for maintaining Py2.x in peak condition for many 
      years. 
      
      
      
      From breamoreboy at yahoo.co.uk  Thu Jul 23 18:56:08 2015
      From: breamoreboy at yahoo.co.uk (Mark Lawrence)
      Date: Thu, 23 Jul 2015 23:56:08 +0100
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: <55B1644F.5070300@mrabarnett.plus.com>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net> 
       <55B1644F.5070300@mrabarnett.plus.com>
      Message-ID: 
      
      On 23/07/2015 23:01, MRAB wrote:
      > On 2015-07-23 22:50, Mark Lawrence wrote:
      >> On 23/07/2015 22:29, Marko Rauhamaa wrote:
      >>> Chris Angelico :
      >>>
      >>>> Fortunately, we don't need to completely understand it. New Horizons
      >>>> reached Pluto right on time after a decade of flight that involved
      >>>> taking a left turn at Jupiter... we can predict exactly what angle to
      >>>> fire the rockets at in order to get where we want to go, even without
      >>>> knowing how that gravity yank works.
      >>>>
      >>>> Practicality beats purity?
      >>>
      >>> Engineer!
      >>>
      >>
      >> Heard the one about the three engineers in the car that breaks down?
      >>
      >> The chemical engineer suggests that they could have contaminated fuel.
      >> They should try and get a sample and get someone to take it to a lab for
      >> analysis.
      >>
      >> The electrical engineer suggests that they check the battery and the
      >> leads for any problems.
      >>
      >> The Microsoft engineer suggests that they close all the windows, get out
      >> of the car, get back in the car, open all the windows and see what
      >> happens.
      >>
      > And an Apple engineer would suggest buying a new car that runs only on
      > its manufacturer's brand of fuel. :-)
      >
      
      Like it, marks out of 10, 15 :)
      
      -- 
      My fellow Pythonistas, ask not what our language can do for you, ask
      what you can do for our language.
      
      Mark Lawrence
      
      
      
      From invalid at invalid.invalid  Thu Jul 23 20:07:51 2015
      From: invalid at invalid.invalid (Grant Edwards)
      Date: Fri, 24 Jul 2015 00:07:51 +0000 (UTC)
      Subject: OT Re: Math-embarrassment results in CS [was: Should
       non-security 2.7 bugs be fixed?]
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net>
      Message-ID: 
      
      On 2015-07-23, Marko Rauhamaa  wrote:
      > Chris Angelico :
      >
      >> Fortunately, we don't need to completely understand it. New Horizons
      >> reached Pluto right on time after a decade of flight that involved
      >> taking a left turn at Jupiter... we can predict exactly what angle to
      >> fire the rockets at in order to get where we want to go, even without
      >> knowing how that gravity yank works.
      >>
      >> Practicality beats purity?
      >
      > Engineer!
      >
      > At the time I was in college I heard topology was very fashionable among
      > mathematicians. That was because it was one of the last remaining
      > research topics that didn't yet have an application.
      
      You can always pick out the topologist at a conference: he's the one
      trying to dunk his coffee cup in his doughnut.
      
      [Hey, how often do you get to use a topology  joke.]
      
      --
      Grant
      
      
      
      From denismfmcmahon at gmail.com  Thu Jul 23 20:18:15 2015
      From: denismfmcmahon at gmail.com (Denis McMahon)
      Date: Fri, 24 Jul 2015 00:18:15 +0000 (UTC)
      Subject: Find Minimum for element in multiple dimensional array
      References: 
      Message-ID: 
      
      On Wed, 22 Jul 2015 15:54:06 -0700, Robert Davis wrote:
      
      > Given a set of arrays within an array how do I find the arrays with the
      > minimum values based on two elements/columns in the array? Those two
      > elements/columns are the destination zip code and distance.
      
      create a new dictionary
      
      for each source/destination pair in your list of source destination pairs:
      
      if the destination zip code is not in the new dictionary, copy the entry 
      to the new dictionary keyed on the destination zip code.
      
      if the destination zip code is in the new dictionary, copy the entry to 
      the new dictionary keyed on the destination zip code only if the distance 
      is less than the distance of the current entry in the new dictionary.
      
      convert the values of the new dictionary to a list.
      
      write the list as csv
      
      Here is an example, note that I'm just using 2 bits of data, the first 
      bit of data in each sub list simulates the destination area code, and the 
      second simulates the distance from the associated source zip code. 
      Obviously you need to adjust these to match the actual parameters in your 
      list of lists.
      
      import csv
      
      info = [['a',15],['a',17],['a',21],['b',96],['b',45],['b',38],['c',71],
      ['c',18],['c',54]]
      
      tmp = {}
      
      for thing in info:
          if thing[0] in tmp:
              if thing[1] < tmp[thing[0]][1]:
                  tmp[thing[0]] = thing
          else:
              tmp[thing[0]] = thing
      
      with open("output.csv", "wb") as f:
          writer = csv.writer(f)
          writer.writerows(tmp.values())
      
      and lo:
      
      $ cat output.csv
      a,15
      c,18
      b,38
      $ 
      
      
      -- 
      Denis McMahon, denismfmcmahon at gmail.com
      
      
      From steveburrus28 at gmail.com  Thu Jul 23 21:28:02 2015
      From: steveburrus28 at gmail.com (Steve Burrus)
      Date: Thu, 23 Jul 2015 18:28:02 -0700 (PDT)
      Subject: Python 3.4 Idle?
      Message-ID: 
      
      Listen I got back the Idle EAditor the other day but I had to install the older, version 2.7, version of Python to get it. So naturally I w onder if I can get Idle for version 3.4.*?
      
      
       
      
      
      From steveburrus28 at gmail.com  Thu Jul 23 21:34:36 2015
      From: steveburrus28 at gmail.com (Steve Burrus)
      Date: Thu, 23 Jul 2015 18:34:36 -0700 (PDT)
      Subject: Python 3.4 Idle?
      Message-ID: <9f2eea0f-2e1b-42a6-8510-feba034769c0@googlegroups.com>
      
      I got Idle the other day biut had to get the older version, 2.7, of python to get it. So I wonder if there is an Idle version  that comes with python 3.4.*? 
      
      
      From chenchao at inhand.com.cn  Thu Jul 23 21:37:35 2015
      From: chenchao at inhand.com.cn (chenchao at inhand.com.cn)
      Date: Fri, 24 Jul 2015 09:37:35 +0800
      Subject: Fwd: ImportError: No module named site
      In-Reply-To: <55B0C0FF.1000507@inhand.com.cn>
      References: <55B0C0FF.1000507@inhand.com.cn>
      Message-ID: <55B196DF.80808@inhand.com.cn>
      
      hi:
      I'm Needing to get python 2.7.10 to cross compile correctly for an ARM 
      embedded device. When I execute python using shell, it comes out this 
      error:ImportError: No module named site.I have setted environment 
      varible:PYTHONHOME and PYTHONPATH. Is there some good idea to sovle this 
      issue?
      
      
      -------------- next part --------------
      An HTML attachment was scrubbed...
      URL: 
      
      From rosuav at gmail.com  Thu Jul 23 21:40:16 2015
      From: rosuav at gmail.com (Chris Angelico)
      Date: Fri, 24 Jul 2015 11:40:16 +1000
      Subject: Python 3.4 Idle?
      In-Reply-To: <9f2eea0f-2e1b-42a6-8510-feba034769c0@googlegroups.com>
      References: <9f2eea0f-2e1b-42a6-8510-feba034769c0@googlegroups.com>
      Message-ID: 
      
      On Fri, Jul 24, 2015 at 11:34 AM, Steve Burrus  wrote:
      > I got Idle the other day biut had to get the older version, 2.7, of python to get it. So I wonder if there is an Idle version  that comes with python 3.4.*?
      
      What system are you on? What did you do to install Python? On Windows,
      the python.org installers usually come with IDLE; on some Linuxes,
      it's separately distributed; if you got a third-party Python distro,
      it's up to them what they put in it. But yes, you most certainly can
      get 3.4+ with IDLE.
      
      ChrisA
      
      
      From rantingrickjohnson at gmail.com  Thu Jul 23 21:40:21 2015
      From: rantingrickjohnson at gmail.com (Rick Johnson)
      Date: Thu, 23 Jul 2015 18:40:21 -0700 (PDT)
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: 
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net> 
      Message-ID: <295f8273-c710-44de-9fe1-b177c76f223d@googlegroups.com>
      
      On Thursday, July 23, 2015 at 7:08:10 PM UTC-5, Grant Edwards wrote:
      > You can always pick out the topologist at a conference:
      > he's the one trying to dunk his coffee cup in his
      > doughnut.
      > 
      > [Hey, how often do you get to use a topology  joke.]
      
      Don't sale yourself short Grant. You get extra bonus points
      here: (1) told a rare joke and (2) perpetuated the off topic
      ramblings in an effort to deflect from main subject. Nice
      multitasking dude!
      
      
      
      
      
      
      From steveburrus28 at gmail.com  Thu Jul 23 21:50:35 2015
      From: steveburrus28 at gmail.com (Steve Burrus)
      Date: Thu, 23 Jul 2015 18:50:35 -0700 (PDT)
      Subject: Python 3.4 Idle?
      In-Reply-To: 
      References: <9f2eea0f-2e1b-42a6-8510-feba034769c0@googlegroups.com>
       
      Message-ID: <0d7bd697-e9bc-45f4-9278-c0bdfb8124fb@googlegroups.com>
      
      On Thursday, July 23, 2015 at 8:41:03 PM UTC-5, Chris Angelico wrote:
      > On Fri, Jul 24, 2015 at 11:34 AM, Steve Burrus  wrote:
      > > I got Idle the other day biut had to get the older version, 2.7, of python to get it. So I wonder if there is an Idle version  that comes with python 3.4.*?
      > 
      > What system are you on? What did you do to install Python? On Windows,
      > the python.org installers usually come with IDLE; on some Linuxes,
      > it's separately distributed; if you got a third-party Python distro,
      > it's up to them what they put in it. But yes, you most certainly can
      > get 3.4+ with IDLE.
      > 
      > ChrisA
      
      Well I am exactly on Windows 10 beta preview on a 64 bit system. Idle is on my Programs menu but I cannot actually activate it.
      
      
      From no.email at nospam.invalid  Thu Jul 23 22:03:03 2015
      From: no.email at nospam.invalid (Paul Rubin)
      Date: Thu, 23 Jul 2015 19:03:03 -0700
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net> 
      Message-ID: <878ua6tiqw.fsf@jester.gateway.sonic.net>
      
      Grant Edwards  writes:
      > You can always pick out the topologist at a conference: he's the one
      > trying to dunk his coffee cup in his doughnut.
      > [Hey, how often do you get to use a topology  joke.]
      
      Did you hear about the idiot topologist?  He couldn't tell his butt from
      a hole in the ground, but he *could* tell his butt from two holes in the
      ground.
      
      
      From lac at openend.se  Thu Jul 23 22:12:25 2015
      From: lac at openend.se (Laura Creighton)
      Date: Fri, 24 Jul 2015 04:12:25 +0200
      Subject: Fwd: ImportError: No module named site
      In-Reply-To: Message from "chenchao@inhand.com.cn" 
       of "Fri, 24 Jul 2015 09:37:35 +0800." <55B196DF.80808@inhand.com.cn>
      References: <55B0C0FF.1000507@inhand.com.cn><55B196DF.80808@inhand.com.cn>
      Message-ID: <201507240212.t6O2CPIj009281@fido.openend.se>
      
      In a message of Fri, 24 Jul 2015 09:37:35 +0800, "chenchao at inhand.com.cn" write
      s:
      >hi:
      >I'm Needing to get python 2.7.10 to cross compile correctly for an ARM 
      >embedded device. When I execute python using shell, it comes out this 
      >error:ImportError: No module named site.I have setted environment 
      >varible:PYTHONHOME and PYTHONPATH. Is there some good idea to sovle this 
      >issue?
      
      You might want to try that question over here:
      https://mail.python.org/mailman/listinfo/mobile-sig
      
      I think you have an issue with dynamic library linking, but I don't
      know how to find out for sure.   People there do.
      
      Laura
      
      
      From christopherrmullins at gmail.com  Thu Jul 23 22:20:32 2015
      From: christopherrmullins at gmail.com (Christopher Mullins)
      Date: Thu, 23 Jul 2015 21:20:32 -0500
      Subject: Fwd: ImportError: No module named site
      In-Reply-To: <201507240212.t6O2CPIj009281@fido.openend.se>
      References: <55B0C0FF.1000507@inhand.com.cn> 
       <55B196DF.80808@inhand.com.cn>
       <201507240212.t6O2CPIj009281@fido.openend.se>
      Message-ID: 
      
      What did you set those variables to?
      
      Also, output from python -v would be helpful.
      On Jul 23, 2015 10:15 PM, "Laura Creighton"  wrote:
      
      > In a message of Fri, 24 Jul 2015 09:37:35 +0800, "chenchao at inhand.com.cn"
      > write
      > s:
      > >hi:
      > >I'm Needing to get python 2.7.10 to cross compile correctly for an ARM
      > >embedded device. When I execute python using shell, it comes out this
      > >error:ImportError: No module named site.I have setted environment
      > >varible:PYTHONHOME and PYTHONPATH. Is there some good idea to sovle this
      > >issue?
      >
      > You might want to try that question over here:
      > https://mail.python.org/mailman/listinfo/mobile-sig
      >
      > I think you have an issue with dynamic library linking, but I don't
      > know how to find out for sure.   People there do.
      >
      > Laura
      > --
      > https://mail.python.org/mailman/listinfo/python-list
      >
      -------------- next part --------------
      An HTML attachment was scrubbed...
      URL: 
      
      From rantingrickjohnson at gmail.com  Thu Jul 23 23:16:48 2015
      From: rantingrickjohnson at gmail.com (Rick Johnson)
      Date: Thu, 23 Jul 2015 20:16:48 -0700 (PDT)
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: <878ua6tiqw.fsf@jester.gateway.sonic.net>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net> 
       <878ua6tiqw.fsf@jester.gateway.sonic.net>
      Message-ID: <0069fe22-5d75-413f-8993-1faedb0c65f2@googlegroups.com>
      
      On Thursday, July 23, 2015 at 9:03:15 PM UTC-5, Paul Rubin wrote:
      > Did you hear about the idiot topologist?  He couldn't tell his butt from
      > a hole in the ground, but he *could* tell his butt from two holes in the
      > ground.
      
      This sounds more like a riddle than a joke. So in other
      words: the message passing requires himself in one hole and
      a clone of himself in another hole speaking the message
      simultaneously?
      
      
      From lac at openend.se  Fri Jul 24 01:10:19 2015
      From: lac at openend.se (Laura Creighton)
      Date: Fri, 24 Jul 2015 07:10:19 +0200
      Subject: Object Pool design pattern
      In-Reply-To: Message from Abder-Rahman Ali 
       of "Thu, 23 Jul 2015 23:09:38 +0200."
       
      References: 
      Message-ID: <201507240510.t6O5AJrw013403@fido.openend.se>
      
      In a message of Thu, 23 Jul 2015 23:09:38 +0200, Abder-Rahman Ali writes:
      >Hello,
      >
      >How can we implement the Object Pool design pattern in Python, especially
      >when the pool consists of array data types?
      >
      >Thanks.
      
      Is your problem 'I don't know how to implement the Object Pool Design pattern
      at all?' -- in which case Googling "python object pool design pattern"
      gets you some nice hits -- or you are having some particular problem
      related to your use of arrays -- in which case post code (and errors
      if you have any) and we will see what we can do.
      
      Laura
      
      
      From rustompmody at gmail.com  Fri Jul 24 01:15:28 2015
      From: rustompmody at gmail.com (Rustom Mody)
      Date: Thu, 23 Jul 2015 22:15:28 -0700 (PDT)
      Subject: OT Re: Math-embarrassment results in CS [was: Should non-security
       2.7 bugs be fixed?]
      In-Reply-To: <878ua636mf.fsf@elektro.pacujo.net>
      References:  
       
       
       <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com>
       <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com>
       <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com>
       
       <87twsxj2ot.fsf@elektro.pacujo.net>
       <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com>
       <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com>
       <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com>
       
       <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com>
       <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com>
       
       <87egjy380w.fsf@elektro.pacujo.net>
       
       <878ua636mf.fsf@elektro.pacujo.net>
      Message-ID: 
      
      On Friday, July 24, 2015 at 2:59:41 AM UTC+5:30, Marko Rauhamaa wrote:
      > Chris :
      > 
      > > Fortunately, we don't need to completely understand it. New Horizons
      > > reached Pluto right on time after a decade of flight that involved
      > > taking a left turn at Jupiter... we can predict exactly what angle to
      > > fire the rockets at in order to get where we want to go, even without
      > > knowing how that gravity yank works.
      > >
      > > Practicality beats purity?
      > 
      > Engineer!
      > 
      > At the time I was in college I heard topology was very fashionable among
      > mathematicians. That was because it was one of the last remaining
      > research topics that didn't yet have an application.
      
      Probably shows more than anything else how siloed university depts are:
      
      http://www.amazon.in/Topology-Cambridge-Theoretical-Computer-Science/dp/0521576512
      
      
      From greg.ewing at canterbury.ac.nz  Fri Jul 24 02:23:09 2015
      From: greg.ewing at canterbury.ac.nz (Gregory Ewing)
      Date: Fri, 24 Jul 2015 18:23:09 +1200
      Subject: Integers with leading zeroes
      In-Reply-To: 
      References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com>
       
       <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com>
       
       <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com>
       <201507220712.t6M7CxJO014614@fido.openend.se>
       
       
       
      Message-ID: 
      
      Michael Torrie wrote:
      > A credit card number is indeed a number, and there are
      > mathematical formulas for determining if a particular number is a valid
      > (as in well-formed) credit card number,
      
      If you're talking about the check-digit algorithm,
      that doesn't treat the whole number as an integer,
      it works on the individual digits:
      
      http://www.datagenetics.com/blog/july42013/
      
      > and possibly to identify what kind of card it is.
      
      That's determined by the leading digits, and can
      be done just as well by treating them as characters.
      
      -- 
      Greg
      
      
      From rosuav at gmail.com  Fri Jul 24 02:28:47 2015
      From: rosuav at gmail.com (Chris Angelico)
      Date: Fri, 24 Jul 2015 16:28:47 +1000
      Subject: Integers with leading zeroes
      In-Reply-To: 
      References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com>
       
       <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com>
       
       <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com>
       <201507220712.t6M7CxJO014614@fido.openend.se>
       
       
       
       
      Message-ID: 
      
      On Fri, Jul 24, 2015 at 4:23 PM, Gregory Ewing
       wrote:
      > Michael Torrie wrote:
      >>
      >> A credit card number is indeed a number, and there are
      >> mathematical formulas for determining if a particular number is a valid
      >> (as in well-formed) credit card number,
      >
      >
      > If you're talking about the check-digit algorithm,
      > that doesn't treat the whole number as an integer,
      > it works on the individual digits:
      >
      > http://www.datagenetics.com/blog/july42013/
      >
      >> and possibly to identify what kind of card it is.
      >
      >
      > That's determined by the leading digits, and can
      > be done just as well by treating them as characters.
      
      So, the definition of a number is: Something on which you perform
      numeric operations. Aside from being circular, wouldn't this mean that
      "rope" is a number, since its square root is string?
      
      ChrisA
      
      
      From chenchao at inhand.com.cn  Fri Jul 24 02:29:10 2015
      From: chenchao at inhand.com.cn (chenchao at inhand.com.cn)
      Date: Fri, 24 Jul 2015 14:29:10 +0800
      Subject: Fwd: ImportError: No module named site
      In-Reply-To: 
      References: <55B0C0FF.1000507@inhand.com.cn>		<55B196DF.80808@inhand.com.cn>	<201507240212.t6O2CPIj009281@fido.openend.se>
       
      Message-ID: <55B1DB36.8090700@inhand.com.cn>
      
      hi:
          Do you know, where can I download the python2.7.10-xcompile.patch 
      file?thanks.
      
      On 07/24/2015 10:20 AM, Christopher Mullins wrote:
      >
      > What did you set those variables to?
      >
      > Also, output from python -v would be helpful.
      >
      > On Jul 23, 2015 10:15 PM, "Laura Creighton"  > wrote:
      >
      >     In a message of Fri, 24 Jul 2015 09:37:35 +0800,
      >     "chenchao at inhand.com.cn " write
      >     s:
      >     >hi:
      >     >I'm Needing to get python 2.7.10 to cross compile correctly for
      >     an ARM
      >     >embedded device. When I execute python using shell, it comes out this
      >     >error:ImportError: No module named site.I have setted environment
      >     >varible:PYTHONHOME and PYTHONPATH. Is there some good idea to
      >     sovle this
      >     >issue?
      >
      >     You might want to try that question over here:
      >     https://mail.python.org/mailman/listinfo/mobile-sig
      >
      >     I think you have an issue with dynamic library linking, but I don't
      >     know how to find out for sure.   People there do.
      >
      >     Laura
      >     --
      >     https://mail.python.org/mailman/listinfo/python-list
      >
      
      -------------- next part --------------
      An HTML attachment was scrubbed...
      URL: 
      
      From robin at reportlab.com  Fri Jul 24 06:20:04 2015
      From: robin at reportlab.com (Robin Becker)
      Date: Fri, 24 Jul 2015 11:20:04 +0100
      Subject: what windows compiler for python 3.5?
      Message-ID: <55B21154.9060103@chamonix.reportlab.co.uk>
      
      I read this
      
      https://docs.python.org/dev/whatsnew/3.5.html which incidentally marks the 
      release as 3.6.0a0 :)
      
      but failed to find any details regarding which windows compiler is required.
      -- 
      Robin Becker
      
      
      
      From robin at reportlab.com  Fri Jul 24 06:25:35 2015
      From: robin at reportlab.com (Robin Becker)
      Date: Fri, 24 Jul 2015 11:25:35 +0100
      Subject: what windows compiler for python 3.5?
      In-Reply-To: <55B21154.9060103@chamonix.reportlab.co.uk>
      References: <55B21154.9060103@chamonix.reportlab.co.uk>
      Message-ID: <55B2129F.8060906@chamonix.reportlab.co.uk>
      
      On 24/07/2015 11:20, Robin Becker wrote:
      > I read this
      >
      > https://docs.python.org/dev/whatsnew/3.5.html which incidentally marks the
      > release as 3.6.0a0 :)
      >
      > but failed to find any details regarding which windows compiler is required.
      
      more searching I find this on the 3.5 b1 download page
      
      "Windows users: The Windows binaries were built with Microsoft Visual Studio 
      2015, which is not yet officially released. (It's currently offered in "Preview" 
      mode, which is akin to a "beta".) It is our intention to ship Python 3.5 using 
      VS2015, although right now VS2015's final release date is unclear."
      
      
      
      -- 
      Robin Becker
      
      
      
      From rosuav at gmail.com  Fri Jul 24 06:38:29 2015
      From: rosuav at gmail.com (Chris Angelico)
      Date: Fri, 24 Jul 2015 20:38:29 +1000
      Subject: what windows compiler for python 3.5?
      In-Reply-To: <55B2129F.8060906@chamonix.reportlab.co.uk>
      References: <55B21154.9060103@chamonix.reportlab.co.uk>
       <55B2129F.8060906@chamonix.reportlab.co.uk>
      Message-ID: 
      
      On Fri, Jul 24, 2015 at 8:25 PM, Robin Becker  wrote:
      > On 24/07/2015 11:20, Robin Becker wrote:
      >>
      >> I read this
      >>
      >> https://docs.python.org/dev/whatsnew/3.5.html which incidentally marks the
      >> release as 3.6.0a0 :)
      >>
      >> but failed to find any details regarding which windows compiler is
      >> required.
      >
      >
      > more searching I find this on the 3.5 b1 download page
      >
      > "Windows users: The Windows binaries were built with Microsoft Visual Studio
      > 2015, which is not yet officially released. (It's currently offered in
      > "Preview" mode, which is akin to a "beta".) It is our intention to ship
      > Python 3.5 using VS2015, although right now VS2015's final release date is
      > unclear."
      
      That would be correct, if you're seeking to match the python.org
      builds (eg if you're building an extension module). I've no idea what
      the compiler requirements are if you simply want to build CPython from
      source.
      
      ChrisA
      
      
      From robin at reportlab.com  Fri Jul 24 06:53:27 2015
      From: robin at reportlab.com (Robin Becker)
      Date: Fri, 24 Jul 2015 11:53:27 +0100
      Subject: what windows compiler for python 3.5?
      In-Reply-To: 
      References: <55B21154.9060103@chamonix.reportlab.co.uk>
       <55B2129F.8060906@chamonix.reportlab.co.uk>
       
      Message-ID: <55B21927.2040605@chamonix.reportlab.co.uk>
      
      On 24/07/2015 11:38, Chris Angelico wrote:
      > On Fri, Jul 24, 2015 at 8:25 PM, Robin Becker  wrote:
      .......
      >> more searching I find this on the 3.5 b1 download page
      >>
      >> "Windows users: The Windows binaries were built with Microsoft Visual Studio
      >> 2015, which is not yet officially released. (It's currently offered in
      >> "Preview" mode, which is akin to a "beta".) It is our intention to ship
      >> Python 3.5 using VS2015, although right now VS2015's final release date is
      >> unclear."
      >
      > That would be correct, if you're seeking to match the python.org
      > builds (eg if you're building an extension module). I've no idea what
      > the compiler requirements are if you simply want to build CPython from
      > source.
      >
      .......
      
      yes I build extensions for reportlab. Unfortunately, despite our MSDN 
      subscription to the Visual Studio stuff we have no access to the Visual Studio 
      Version 2015. Last one in my downloads is currently 2013. Pity.
      -- 
      Robin Becker
      
      
      
      From rosuav at gmail.com  Fri Jul 24 07:04:31 2015
      From: rosuav at gmail.com (Chris Angelico)
      Date: Fri, 24 Jul 2015 21:04:31 +1000
      Subject: what windows compiler for python 3.5?
      In-Reply-To: <55B21927.2040605@chamonix.reportlab.co.uk>
      References: <55B21154.9060103@chamonix.reportlab.co.uk>
       <55B2129F.8060906@chamonix.reportlab.co.uk>
       
       <55B21927.2040605@chamonix.reportlab.co.uk>
      Message-ID: 
      
      On Fri, Jul 24, 2015 at 8:53 PM, Robin Becker  wrote:
      > yes I build extensions for reportlab. Unfortunately, despite our MSDN
      > subscription to the Visual Studio stuff we have no access to the Visual
      > Studio Version 2015. Last one in my downloads is currently 2013. Pity.
      
      Ah. You may well be somewhat out of luck for the moment, then; I've no
      idea what status is during the betas. Once Python 3.5 is released, VS
      2015 should also be available, or else the official compiler for
      CPython 3.5 will probably be changed.
      
      In the meantime, you could possibly ask on python-dev; Steve Dower of
      Microsoft hangs out there, and he's the one who's driving the compiler
      choice - he may be able to advise as to where to get the prerelease
      compiler.
      
      ChrisA
      
      
      From breamoreboy at yahoo.co.uk  Fri Jul 24 07:23:34 2015
      From: breamoreboy at yahoo.co.uk (Mark Lawrence)
      Date: Fri, 24 Jul 2015 12:23:34 +0100
      Subject: what windows compiler for python 3.5?
      In-Reply-To: <55B21927.2040605@chamonix.reportlab.co.uk>
      References: <55B21154.9060103@chamonix.reportlab.co.uk>
       <55B2129F.8060906@chamonix.reportlab.co.uk>
       
       <55B21927.2040605@chamonix.reportlab.co.uk>
      Message-ID: 
      
      On 24/07/2015 11:53, Robin Becker wrote:
      > On 24/07/2015 11:38, Chris Angelico wrote:
      >> On Fri, Jul 24, 2015 at 8:25 PM, Robin Becker 
      >> wrote:
      > .......
      >>> more searching I find this on the 3.5 b1 download page
      >>>
      >>> "Windows users: The Windows binaries were built with Microsoft Visual
      >>> Studio
      >>> 2015, which is not yet officially released. (It's currently offered in
      >>> "Preview" mode, which is akin to a "beta".) It is our intention to ship
      >>> Python 3.5 using VS2015, although right now VS2015's final release
      >>> date is
      >>> unclear."
      >>
      >> That would be correct, if you're seeking to match the python.org
      >> builds (eg if you're building an extension module). I've no idea what
      >> the compiler requirements are if you simply want to build CPython from
      >> source.
      >>
      > .......
      >
      > yes I build extensions for reportlab. Unfortunately, despite our MSDN
      > subscription to the Visual Studio stuff we have no access to the Visual
      > Studio Version 2015. Last one in my downloads is currently 2013. Pity.
      
      I'm successfully building with Visual Studio Version 2015 Community 
      Edition RC.  It's a good job that modern drives have so much space as it 
      takes up *EIGHT GIG* of space, so the download and install takes quite a 
      time.  I'm aware that Steve Dower is trying to get a much smaller 
      install made available for those who just want to build from the command 
      line.
      
      -- 
      My fellow Pythonistas, ask not what our language can do for you, ask
      what you can do for our language.
      
      Mark Lawrence
      
      
      
      From esj at harvee.org  Fri Jul 24 07:32:03 2015
      From: esj at harvee.org (eric johansson)
      Date: Fri, 24 Jul 2015 14:32:03 +0300 (EEST)
      Subject: problem with selecting remote procedure calls
      In-Reply-To: <55b138fb$0$2832$e4fe514c@news.xs4all.nl>
      References: <21624840.357.1437621015246.JavaMail.eric@aho>
       
       <55b138fb$0$2832$e4fe514c@news.xs4all.nl>
      Message-ID: <29590162.109.1437737517863.JavaMail.eric@aho>
      
      
      
      ----- Original Message -----
      
      
      
      From: "Irmen de Jong"  
      
      Eric, if you're concerned about performance, Pyro4 (the source 
      distribution) comes with 
      several examples that do simple performance related tests. You could 
      run these and see 
      what figures you get on your setup to see if it's anywhere 
      acceptable, before even 
      building anything with Pyro yourself. 
      
      
      sounds like a plan. I managed to get around the initial problem I had because apparently the natlink extension for NaturallySpeaking is semi-persistent. Sometimes the statically created RPC connection would work, other times it wouldn't. The current workaround is to place the RPC connection initialization in the code that activates the grammar. 
      
      
      
      Interesting project btw.
      it has been a long time since a project like this has made me smile ear-to-ear. For example, yesterday I had to create twelve open VPN configuration files and key pairs. With broken hands like mine, it would be an extremely painful hour to two hours to entering the data over and over again even with easy RSA. I was able to complete this task in about 10 to 15 minutes. Now that's what accessibility is all about. I believe my experiment shows that a two dimensional grid with names for both rows and columns can allow a speech recognition dependent user much faster data entry than one could have with straight speech recognition. With some enhancements, it should be possible to use this technique to remember something on the fly. ideally I'd like to take a tool like treesheets , put some Python power underneath the grid, and explore how a grid tool can help accessibility but I'd need a volunteer to make that happen. -------------- next part -------------- An HTML attachment was scrubbed... URL: From blindanagram at nowhere.net Fri Jul 24 08:24:22 2015 From: blindanagram at nowhere.net (Brian Gladman) Date: Fri, 24 Jul 2015 13:24:22 +0100 Subject: what windows compiler for python 3.5? In-Reply-To: References: <55B21154.9060103@chamonix.reportlab.co.uk> <55B2129F.8060906@chamonix.reportlab.co.uk> <55B21927.2040605@chamonix.reportlab.co.uk> Message-ID: <55B22E76.9020304@nowhere.net> On 24/07/2015 12:04, Chris Angelico wrote: > On Fri, Jul 24, 2015 at 8:53 PM, Robin Becker wrote: >> yes I build extensions for reportlab. Unfortunately, despite our MSDN >> subscription to the Visual Studio stuff we have no access to the Visual >> Studio Version 2015. Last one in my downloads is currently 2013. Pity. > > Ah. You may well be somewhat out of luck for the moment, then; I've no > idea what status is during the betas. Once Python 3.5 is released, VS > 2015 should also be available, or else the official compiler for > CPython 3.5 will probably be changed. > > In the meantime, you could possibly ask on python-dev; Steve Dower of > Microsoft hangs out there, and he's the one who's driving the compiler > choice - he may be able to advise as to where to get the prerelease > compiler. Visual Studio 2015 Community was relased earlier this week so there is no need to work with the prerelease version. From blindanagram at nowhere.net Fri Jul 24 08:24:22 2015 From: blindanagram at nowhere.net (Brian Gladman) Date: Fri, 24 Jul 2015 13:24:22 +0100 Subject: what windows compiler for python 3.5? In-Reply-To: References: <55B21154.9060103@chamonix.reportlab.co.uk> <55B2129F.8060906@chamonix.reportlab.co.uk> <55B21927.2040605@chamonix.reportlab.co.uk> Message-ID: <55B22E76.9020304@nowhere.net> On 24/07/2015 12:04, Chris Angelico wrote: > On Fri, Jul 24, 2015 at 8:53 PM, Robin Becker wrote: >> yes I build extensions for reportlab. Unfortunately, despite our MSDN >> subscription to the Visual Studio stuff we have no access to the Visual >> Studio Version 2015. Last one in my downloads is currently 2013. Pity. > > Ah. You may well be somewhat out of luck for the moment, then; I've no > idea what status is during the betas. Once Python 3.5 is released, VS > 2015 should also be available, or else the official compiler for > CPython 3.5 will probably be changed. > > In the meantime, you could possibly ask on python-dev; Steve Dower of > Microsoft hangs out there, and he's the one who's driving the compiler > choice - he may be able to advise as to where to get the prerelease > compiler. Visual Studio 2015 Community was relased earlier this week so there is no need to work with the prerelease version. From alister.nospam.ware at ntlworld.com Fri Jul 24 09:16:03 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Fri, 24 Jul 2015 13:16:03 +0000 (UTC) Subject: Integers with leading zeroes References: <55ab37fb$0$1661$c3e8da3$5496439d@news.astraweb.com> <55aeea13$0$1669$c3e8da3$5496439d@news.astraweb.com> <55aefc70$0$1656$c3e8da3$5496439d@news.astraweb.com> <201507220712.t6M7CxJO014614@fido.openend.se> Message-ID: On Wed, 22 Jul 2015 20:11:47 -0600, Michael Torrie wrote: > On 07/22/2015 07:51 AM, Grant Edwards wrote: >> On 2015-07-22, Ben Finney wrote: >>> Laura Creighton writes: >>> >>>> The biggest use I have for decimal numbers that begin with 0 is in >>>> credit card numbers, account numbers and the like where the first >>>> check you do is 'does this thing have the correct number of digits'. >>> >>> The following are examples of types from the real world that people >>> think of, and casually discuss, as ?numbers?. >>> >>> * Postal code * Credit card number * Telephone number * Car >>> registration plate number * Personal Identification Number (PIN) >> >> Those are all strings. Not numbers. > > That depends. A credit card number is indeed a number, and there are > mathematical formulas for determining if a particular number is a valid > (as in well-formed) credit card number, and possibly to identify what > kind of card it is. no it is a string,that happens to be made up out of digits. the digits can be manipulated but you do not perform maths on a credit card number as a whole -- Did I do an INCORRECT THING?? From rdavis7408 at gmail.com Fri Jul 24 09:17:30 2015 From: rdavis7408 at gmail.com (Robert Davis) Date: Fri, 24 Jul 2015 06:17:30 -0700 (PDT) Subject: Find Minimum for element in multiple dimensional array In-Reply-To: References: Message-ID: <02bb73b5-7a8a-43fa-ab5d-2325464f3d81@googlegroups.com> On Wednesday, July 22, 2015 at 5:54:30 PM UTC-5, Robert Davis wrote: > Given a set of arrays within an array how do I find the arrays with the minimum values based on two elements/columns in the array? Those two elements/columns are the destination zip code and distance. > > I have an array of arrays that have a origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points. > > I need to keep only those combinations that represent the minimum mileage between to the destination zip code. For example a point in New Jersey may have a distance from the Philadelphia Office that is 45 miles, from the Newark Office that is 78 miles and one from the Delaware Office that is 58 miles. > > I need to keep the mileage from the Philadelphia Office that is 45 miles and produce a .csv file that has origin zip code, origin latitude, origin longitude, destination zip code, destination latitude, destination longitude, and miles between the two points. > > The array looks like this: > > [['37015', 'TN31', 36.2777, -87.0046, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 77.338920003], > ['72202', 'ARB1', 34.739224, -92.27765, 'NY', 'White Plains', '10629', 41.119008, -73.732996, 1099.7837975322097]] > > My code looks like this : > > import csv > import math > > > def calculate_distance(lat1, lon1, lat2, lon2): > > if (not lat1) or (not lon1) or (not lat2) or (not lon2): > return -1 > > lat1 = float(lat1) * math.pi/180 > lon1 = float(lon1) * math.pi/180 > lat2 = float(lat2) * math.pi/180 > lon2 = float(lon2) * math.pi/180 > > return 3959.0 * math.acos(math.sin(lat1) * math.sin(lat2) + math.cos(lat1) * math.cos(lat2) * math.cos(lon2-lon1)) > > #Above function changed from the following URL: http://iamtgc.com/geocoding- with-python/ > > > InputPath = "C:\\Users\\jacobs\\Downloads\\ZipCodes\\" > > ZipCodes = "zipcode.csv" > RptgOfficeFile = "Reporting_Office_2015072001.csv" > InputFile = InputPath+RptgOfficeFile > zInputFile = InputPath+ZipCodes > zOutputFile = InputPath+'Zip_Code_Distance.csv' > z1OutputFile = InputPath+'Minimum_Distance_Zip_Code_File.csv' > > > f = open(InputFile, 'r') > > zO = open(zOutputFile,'w') > z1 = open(z1OutputFile,'w') > > lines = [ ] > OfficeZipcodes = [] > ZipRptOffice = {} > OLatitude = [ ] > OLongitude = [ ] > OLocationCode = [] > dzip = [] > dLatitude = [] > dLongitude = [] > dCity = [] > dState = [] > Combined =[] > Answers = [] > > for line in f: > l = [i.strip() for i in line.split(',')] > OfficeZipcodes.append(l[4]) > ZipRptOffice[l[4]]= l[3] > OLatitude.append(l[5]) > OLongitude.append(l[6]) > OLocationCode.append(l[3]) > > del OfficeZipcodes[0] > del OLatitude[0] > del OLongitude[0] > del OLocationCode[0] > > > zf = csv.DictReader(open(zInputFile)) > #http://courses.cs.washington.edu/courses/cse140/13wi/csv-parsing.html > > for row in zf: > dzip.append(row["zip"]) > dLatitude.append(float(row["latitude"])) > dLongitude.append(float(row["longitude"])) > dCity.append(row["city"]) > dState.append(row["state"]) > > > for i in range(len(OfficeZipcodes)): > for j in range(len(dzip)): > Distance = calculate_distance(OLatitude[i], OLongitude[i],dLatitude[j],dLongitude[j]) > Combined.append([OfficeZipcodes[i], OLocationCode[i],float(OLatitude[i]),float(OLongitude[i]),dState[j],dCity[j],dzip[j], dLatitude[j],dLongitude[j],Distance]) > for i in range(len(Combined)): > zO.write(str(Combined[i][0])+","+str(Combined[i][1])+","+str(Combined[i][2])+","+ str(Combined[i][3])+","+str(Combined[i][4])+","+ str(Combined[i][5])+","+ str(Combined[i][6])+","+str(Combined[i][7])+","+ str(Combined[i][8])+","+str(Combined[i][9])+"\n") > > zO.close() > f.close() > > I am using Python 2.7 on a Windows 7 machine. > > Please help me get my head around how to accomplish this task. > > Thank you very much. > > Robert Davis Thank you Denis. From invalid at invalid.invalid Fri Jul 24 10:13:31 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 24 Jul 2015 14:13:31 +0000 (UTC) Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com> <87egjy380w.fsf@elektro.pacujo.net> <878ua636mf.fsf@elektro.pacujo.net> <878ua6tiqw.fsf@jester.gateway.sonic.net> Message-ID: On 2015-07-24, Paul Rubin wrote: > Grant Edwards writes: > >> You can always pick out the topologist at a conference: he's the one >> trying to dunk his coffee cup in his doughnut. > > Did you hear about the idiot topologist? He couldn't tell his butt > from a hole in the ground, but he *could* tell his butt from two > holes in the ground. Wow. Now I know _two_ topologist jokes. The girls are going to be impressed! -- Grant Edwards grant.b.edwards Yow! I just got my PRINCE at bumper sticker ... But now gmail.com I can't remember WHO he is ... From ndbecker2 at gmail.com Fri Jul 24 10:57:30 2015 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 24 Jul 2015 10:57:30 -0400 Subject: register cleanup handler Message-ID: I have code like: if (condition): do_something_needing_cleanup code_executed_unconditionally Now, how can I make sure cleanup happens? Actually, what I really would like, is: if (condition): do_something_needing_cleanup register_scoped_cleanup (cleanup_fnc) code_executed_unconditionally So, any thoughts/hopes of python being able to do something like this? I know we have try/finally, but I don't think that helps here, because code_executed_unconditionally couldn't be inside the try. Or am I missing something obvious? From no.email at nospam.invalid Fri Jul 24 11:45:10 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 24 Jul 2015 08:45:10 -0700 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com> <87egjy380w.fsf@elektro.pacujo.net> <878ua636mf.fsf@elektro.pacujo.net> <878ua6tiqw.fsf@jester.gateway.sonic.net> Message-ID: <87pp3hsgop.fsf@jester.gateway.sonic.net> Grant Edwards writes: >> Did you hear about the idiot topologist? He couldn't tell his butt >> from a hole in the ground, but he *could* tell his butt from two >> holes in the ground. > > Wow. Now I know _two_ topologist jokes. The girls are going to be > impressed! I got it from here: http://mathoverflow.net/questions/1083/do-good-math-jokes-exist From lac at openend.se Fri Jul 24 11:47:43 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 24 Jul 2015 17:47:43 +0200 Subject: register cleanup handler In-Reply-To: Message from Neal Becker of "Fri, 24 Jul 2015 10:57:30 -0400." References: Message-ID: <201507241547.t6OFlh5t027843@fido.openend.se> In a message of Fri, 24 Jul 2015 10:57:30 -0400, Neal Becker writes: >I know we have try/finally, but I don't think that helps here, because >code_executed_unconditionally couldn't be inside the try. Or am I missing >something obvious? I think so. Either that or I am badly misunderstanding you. What is wrong with try: if (condition): do_something_needing_cleanup else: do_something_else code_executed_unconditionally finally: do_cleanup Laura From breamoreboy at yahoo.co.uk Fri Jul 24 11:58:32 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Jul 2015 16:58:32 +0100 Subject: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] In-Reply-To: References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <76252f32-64e9-405b-84a2-996200a6fa6f@googlegroups.com> <87twsxj2ot.fsf@elektro.pacujo.net> <55ae2171$0$1646$c3e8da3$5496439d@news.astraweb.com> <890a3d61-2824-48e3-be19-56d0ff63d6d9@googlegroups.com> <55afcbbf$0$1648$c3e8da3$5496439d@news.astraweb.com> <574fa1a7-0d40-405f-ada6-183f2f50cc82@googlegroups.com> <55b07e87$0$1587$c3e8da3$5496439d@news.astraweb.com> <87egjy380w.fsf@elektro.pacujo.net> <878ua636mf.fsf@elektro.pacujo.net> <878ua6tiqw.fsf@jester.gateway.sonic.net> Message-ID: On 24/07/2015 15:13, Grant Edwards wrote: > On 2015-07-24, Paul Rubin wrote: >> Grant Edwards writes: >> >>> You can always pick out the topologist at a conference: he's the one >>> trying to dunk his coffee cup in his doughnut. >> >> Did you hear about the idiot topologist? He couldn't tell his butt >> from a hole in the ground, but he *could* tell his butt from two >> holes in the ground. > > Wow. Now I know _two_ topologist jokes. The girls are going to be > impressed! > Here comes the third. Q: How many topologists does it take to change a light bulb? A: It really doesn't matter, since they'd rather knot. https://www.ocf.berkeley.edu/~mbarrien/jokes/lightblb.txt -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From ndbecker2 at gmail.com Fri Jul 24 12:01:58 2015 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 24 Jul 2015 12:01:58 -0400 Subject: register cleanup handler References: <201507241547.t6OFlh5t027843@fido.openend.se> Message-ID: Laura Creighton wrote: > In a message of Fri, 24 Jul 2015 10:57:30 -0400, Neal Becker writes: >>I know we have try/finally, but I don't think that helps here, because >>code_executed_unconditionally couldn't be inside the try. Or am I missing >>something obvious? > > I think so. Either that or I am badly misunderstanding you. What is > wrong with > > try: > if (condition): > do_something_needing_cleanup > else: > do_something_else > code_executed_unconditionally > finally: > do_cleanup > > Laura do_cleanup has do be done only if do_something_needing_cleanup was done first. This would work, but is not very elegant. I hope for a better way. need_cleanup = False try: if (condition): do_something_needing_cleanup need_cleanup = True else: do_something_else code_executed_unconditionally finally: if need_cleanup: do_cleanup From irmen.NOSPAM at xs4all.nl Fri Jul 24 12:41:52 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Fri, 24 Jul 2015 18:41:52 +0200 Subject: register cleanup handler In-Reply-To: References: Message-ID: <55b26ad1$0$2920$e4fe514c@news.xs4all.nl> On 24-7-2015 16:57, Neal Becker wrote: > I have code like: > > if (condition): > do_something_needing_cleanup > > code_executed_unconditionally > > or exception> > > Now, how can I make sure cleanup happens? Actually, what I really would > like, is: > > if (condition): > do_something_needing_cleanup > register_scoped_cleanup (cleanup_fnc) > > code_executed_unconditionally > > > So, any thoughts/hopes of python being able to do something like this? > > I know we have try/finally, but I don't think that helps here, because > code_executed_unconditionally couldn't be inside the try. Or am I missing > something obvious? > Sounds like you want a context manager, see https://docs.python.org/3/library/contextlib.html#replacing-any-use-of-try-finally-and-flag-variables Irmen From subhabrata.banerji at gmail.com Fri Jul 24 13:25:38 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Fri, 24 Jul 2015 10:25:38 -0700 (PDT) Subject: How may I learn Python Web Frameworks Message-ID: <16e4bdef-db76-4bc7-90f3-d81d7c2e0c35@googlegroups.com> Dear Group, I am slightly new in Python Web Frameworks. I could learn bit of Django, Flask and Bottle. But I am looking for a good web based tutorial like Python or NLTK. Somehow, I did not find documentations for web frameworks are very good, one has to do lot of experiments even to learn basic things. I am looking for a good book like Dive into Python or some good web based tutorials. I tried to search but unfortunately could not find. I am using Python2.7+ on Windows 7. If any one of the members may kindly suggest. Regards, Subhabrata Banerjee. From ndbecker2 at gmail.com Fri Jul 24 13:35:12 2015 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 24 Jul 2015 13:35:12 -0400 Subject: register cleanup handler References: <55b26ad1$0$2920$e4fe514c@news.xs4all.nl> Message-ID: Irmen de Jong wrote: > On 24-7-2015 16:57, Neal Becker wrote: >> I have code like: >> >> if (condition): >> do_something_needing_cleanup >> >> code_executed_unconditionally >> >> > continue or exception> >> >> Now, how can I make sure cleanup happens? Actually, what I really would >> like, is: >> >> if (condition): >> do_something_needing_cleanup >> register_scoped_cleanup (cleanup_fnc) >> >> code_executed_unconditionally >> >> >> So, any thoughts/hopes of python being able to do something like this? >> >> I know we have try/finally, but I don't think that helps here, because >> code_executed_unconditionally couldn't be inside the try. Or am I >> missing something obvious? >> > > Sounds like you want a context manager, see > https://docs.python.org/3/library/contextlib.html#replacing-any-use-of-try-finally-and-flag-variables > > Irmen Yes, that looks great! I'm using py2.7.10, so I tried 'contexter' package. if (condition): with ExitStack() as stack: if condition: do_something() def cleanup_resources(): some_cleanup_using_closure() stack.callback(cleanup_resources) unconditionally_executed_code_no_worrying_about_cleanup() From lac at openend.se Fri Jul 24 13:36:19 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 24 Jul 2015 19:36:19 +0200 Subject: How may I learn Python Web Frameworks In-Reply-To: Message from subhabrata.banerji@gmail.com of "Fri, 24 Jul 2015 10:25:38 -0700." <16e4bdef-db76-4bc7-90f3-d81d7c2e0c35@googlegroups.com> References: <16e4bdef-db76-4bc7-90f3-d81d7c2e0c35@googlegroups.com> Message-ID: <201507241736.t6OHaJuP030286@fido.openend.se> web2py http://www.web2py.com/ has extensive tutorials, videos, and a book. Laura From p_s_d_a_s_i_l_v_a_ns at netcabo.pt Fri Jul 24 14:31:36 2015 From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva) Date: Fri, 24 Jul 2015 19:31:36 +0100 Subject: Which GUI? Message-ID: Hi all! I am about to write an application (python3 in linux) that needs: 1. Display time series graphics dynamically changed as the application runs, i.e. the graphics should reflect some internal variables states. 2. The same but for some network like diagrams. Basically nodes and connections (straight lines). Nodes can have different colors depending on their activity levels and also, together with connection lines, may be created and deleted dynamically. 3. Interaction with the user (not sure yet, here). 4. Some modules may need to be moved to C++ in case of lack of enough speed. So, the possibility of the GUI libs be used with C++ may be an advantage. Anyway I can always stay in Python and write a C++ extension. 5. Several multi processor segments. 6. For now single user - possible but unlikely multi-user in the future. Which technology is better? matplotlib? tkinter? wxwidgets? qt? Web: ajax (I don't know much about this - need to learn), using cherrypy or django? Any other? Thanks for any help or comments. From christopherrmullins at gmail.com Fri Jul 24 14:37:49 2015 From: christopherrmullins at gmail.com (Christopher Mullins) Date: Fri, 24 Jul 2015 13:37:49 -0500 Subject: Which GUI? In-Reply-To: References: Message-ID: You might checkout pyqtgraph. I think a ton of the examples will be relevant to your use case. On Fri, Jul 24, 2015 at 1:31 PM, Paulo da Silva < p_s_d_a_s_i_l_v_a_ns at netcabo.pt> wrote: > Hi all! > > I am about to write an application (python3 in linux) that needs: > > 1. Display time series graphics dynamically changed as the application > runs, i.e. the graphics should reflect some internal variables states. > > 2. The same but for some network like diagrams. Basically nodes and > connections (straight lines). Nodes can have different colors depending > on their activity levels and also, together with connection lines, may > be created and deleted dynamically. > > 3. Interaction with the user (not sure yet, here). > > 4. Some modules may need to be moved to C++ in case of lack of enough > speed. So, the possibility of the GUI libs be used with C++ may be an > advantage. Anyway I can always stay in Python and write a C++ extension. > > 5. Several multi processor segments. > > 6. For now single user - possible but unlikely multi-user in the future. > > Which technology is better? > matplotlib? > tkinter? > wxwidgets? > qt? > Web: ajax (I don't know much about this - need to learn), using cherrypy > or django? > Any other? > > Thanks for any help or comments. > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From elchino at cnn.cn Fri Jul 24 14:53:09 2015 From: elchino at cnn.cn (ElChino) Date: Fri, 24 Jul 2015 20:53:09 +0200 Subject: what windows compiler for python 3.5? In-Reply-To: References: <55B21154.9060103@chamonix.reportlab.co.uk> <55B2129F.8060906@chamonix.reportlab.co.uk> <55B21927.2040605@chamonix.reportlab.co.uk> Message-ID: Brian Gladman wrote: > Visual Studio 2015 Community was relased earlier this week so there is > no need to work with the prerelease version. Hope MS have fixed all the "internal compiler errors". E.g. trying to compile GeoIpApi-C [1], consistently reports: libGeoIP/regionName.c(7596): fatal error C1026: parser stack overflow, program too complex here. The regionName.c look pretty lame, but not that complex IMHO. [1] https://github.com/maxmind/geoip-api-c/blob/master/libGeoIP/regionName.c From lac at openend.se Fri Jul 24 15:18:59 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 24 Jul 2015 21:18:59 +0200 Subject: Which GUI? In-Reply-To: Message from Paulo da Silva of "Fri, 24 Jul 2015 19:31:36 +0100." References: Message-ID: <201507241918.t6OJIxTX032553@fido.openend.se> You may be interested in bokeh. http://bokeh.pydata.org/en/latest/ It's a python interactive visualisation library. Laura From none at mailinator.com Fri Jul 24 15:20:25 2015 From: none at mailinator.com (mm0fmf) Date: Fri, 24 Jul 2015 20:20:25 +0100 Subject: what windows compiler for python 3.5? In-Reply-To: References: <55B21154.9060103@chamonix.reportlab.co.uk> <55B2129F.8060906@chamonix.reportlab.co.uk> Message-ID: <0ewsx.26742$pF1.15799@fx41.am4> On 24/07/2015 11:53, Robin Becker wrote: > yes I build extensions for reportlab. Unfortunately, despite our MSDN > subscription to the Visual Studio stuff we have no access to the Visual > Studio Version 2015. Last one in my downloads is currently 2013. Pity. I received an email today re my work MSDN subscription telling me VS2015 was now available to download. Sorry I didn't study it to see if all the versions were available now or just some. I've only just started using VS2013 at work so wasn't worried about VS2015! From darnold992000 at yahoo.com Fri Jul 24 15:42:42 2015 From: darnold992000 at yahoo.com (darnold) Date: Fri, 24 Jul 2015 12:42:42 -0700 (PDT) Subject: How may I learn Python Web Frameworks In-Reply-To: <16e4bdef-db76-4bc7-90f3-d81d7c2e0c35@googlegroups.com> References: <16e4bdef-db76-4bc7-90f3-d81d7c2e0c35@googlegroups.com> Message-ID: you'll find a very extensive Flask tutorial at http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world . From Cecil at decebal.nl Fri Jul 24 16:11:56 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 24 Jul 2015 22:11:56 +0200 Subject: Which GUI? References: Message-ID: <87twstmi2b.fsf@Equus.decebal.nl> On Friday 24 Jul 2015 20:37 CEST, Christopher Mullins wrote: > You might checkout pyqtgraph. I think a ton of the examples will be > relevant to your use case. Top-posting is (rightly) frowned upon in this group. Could you use inline posting next time? A3: Please. Q3: Should I avoid top posting on this mailing list? A2: Because, by reversing the order of a conversation, it leaves the reader without much context, and makes them read a message in an unnatural order. Q2: Why is top posting irritating? A1: It is the practice of putting your reply to a message before the quoted message, instead of after the (trimmed) message. Q1: What is top posting? > On Fri, Jul 24, 2015 at 1:31 PM, Paulo da Silva > wrote: > > Hi all! > > I am about to write an application (python3 in linux) that needs: > > 1. Display time series graphics dynamically changed as the > application > runs, i.e. the graphics should reflect some internal variables > states. > > 2. The same but for some network like diagrams. Basically nodes and > connections (straight lines). Nodes can have different colors > depending > on their activity levels and also, together with connection lines, > may > be created and deleted dynamically. > > 3. Interaction with the user (not sure yet, here). > > 4. Some modules may need to be moved to C++ in case of lack of > enough > speed. So, the possibility of the GUI libs be used with C++ may be > an > advantage. Anyway I can always stay in Python and write a C++ > extension. > > 5. Several multi processor segments. > > 6. For now single user - possible but unlikely multi-user in the > future. > > Which technology is better? > matplotlib? > tkinter? > wxwidgets? > qt? > Web: ajax (I don't know much about this - need to learn), using > cherrypy > or django? > Any other? > > Thanks for any help or comments. > -- > https://mail.python.org/mailman/listinfo/python-list -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From stephane at wirtel.be Fri Jul 24 16:27:26 2015 From: stephane at wirtel.be (=?utf-8?q?St=C3=A9phane?= Wirtel) Date: Fri, 24 Jul 2015 22:27:26 +0200 Subject: About this mailing list Message-ID: Hi all, This mail is just to check if you receive it because I think I have a problem with this list. Could you reply me to check it works ? Thank you -- St?phane Wirtel - http://wirtel.be - @matrixise From breamoreboy at yahoo.co.uk Fri Jul 24 16:38:33 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Jul 2015 21:38:33 +0100 Subject: About this mailing list In-Reply-To: References: Message-ID: On 24/07/2015 21:27, St?phane Wirtel wrote: > Hi all, > > This mail is just to check if you receive it because I think I have a > problem with this list. > > Could you reply me to check it works ? > > Thank you > > -- > St?phane Wirtel - http://wirtel.be - @matrixise No, sorry :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From rgaddi at technologyhighland.invalid Fri Jul 24 16:44:28 2015 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Fri, 24 Jul 2015 20:44:28 +0000 (UTC) Subject: register cleanup handler References: <201507241547.t6OFlh5t027843@fido.openend.se> Message-ID: On Fri, 24 Jul 2015 12:01:58 -0400, Neal Becker wrote: > > This would work, but is not very elegant. I hope for a better way. > > need_cleanup = False try: > if (condition): > do_something_needing_cleanup need_cleanup = True > else: > do_something_else > code_executed_unconditionally > finally: > if need_cleanup: > do_cleanup if condition: try: do_something_needing_cleanup() code_executed_unconditionally() finally: do_cleanup() else: do_something_else() code_executed_unconditionally() -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From gary719_list1 at verizon.net Fri Jul 24 16:50:07 2015 From: gary719_list1 at verizon.net (Gary Roach) Date: Fri, 24 Jul 2015 13:50:07 -0700 Subject: password authentication failed (SOLVED) In-Reply-To: References: <55A694AB.2020408@verizon.net> <55A83F93.4030403@verizon.net> <55B028DE.2040600@verizon.net> Message-ID: <55B2A4FF.3000703@verizon.net> On 07/22/2015 04:44 PM, Chris Angelico wrote: > On Thu, Jul 23, 2015 at 9:35 AM, Gary Roach wrote: >> At this point, I'm confused about a few things. Does the postgresql server >> and my archivedb reside globally or are they inside my archivedb virtual >> environment. I think globally. > Your virtual environment is a Python construct only. That's where > Python packages get installed, so if you don't activate it, you might > not be able to use psycopg2, but as you surmise, the database itself > is elsewhere on the system. > >> To get pgAdmin3 to work, I have to have it set so that it logs in as gary ( >> no choice with this) and set group to root. Then in application > advanced >> options set run as different user to root. This assumes that you are using a >> KDE4 desktop and have these option by right clicking the icons. >> >> pgAdmin3 data: >> Server Group > Server(1) > archivedb >> |_ Host name - 127.0.0.1 >> |_ username - archive >> |_ connected - no >> Archivedb requires a password to go deeper and takes the xxxxxx password >> that is in the django settings.py file. This opens up access to archivedb >> and lists archivedb > Schema(1) > public > tables(10). At this point I found >> that all of the sequences and all of the tables are owned by root. This is >> probably the root (no pun intended) cause. Now what do I do about it. I'm >> not sure how this came about so don't know how to fix it. > Ah, all owned by root. Okay! I've never actually tried this, but you > might be able to directly reassign a bunch of things: > > http://www.postgresql.org/docs/9.4/static/sql-reassign-owned.html > > Make sure you have a backup. Reassigning root in this way is quite > possibly a bad idea. > > If there aren't too many tables, you could use ALTER TABLE: > > http://www.postgresql.org/docs/9.4/static/sql-altertable.html > > ALTER TABLE tablename OWNER TO archives; > > But in theory, you shouldn't need to worry about owners at all - just > make sure permissions are all assigned. Which you have done. So it's > entirely possible none of this will change anything. :( > > Worst case, you may need to do an SQL dump of the entire database, > then check the export, make sure ownership is correct, and reimport > into a brand new database. Tedious, but it's certain to fix the > problem. > > ChrisA pgAdmin3 showed two potential problems. The first connection listed in pg_hba.conf was: local all postgres radius. I removed this line so that the first line would be: local all all trust. Since all connections will be handled through Django? there should not be a problem with keeping loose security at this point. The second problem was that all fo the sequence and table files in archivedb showed the owner to be root. I changed them all to archive - the user listed in Django's settings.py file. Python manage.py migrate now works with no errors. Thank you for your help. I found an O'Reilly book - PosgreSQL Up & Running, 2nd Edition, by Regina Obe and Leo Hsu that is very good. If I had read the book first, I would have avoided some of these problems. One of the things that I have found very frustrating is that most of the documentation is too compartmentalized. If an author is writing about Django they get sloppy with the database setup and visa versa. It now seems to me that: Postgresql should be set up first, the setup being completely disconnected from the Python / Django project All communication with the database will pass through Django with the exception of admin maintenance. Please correct me if I'm wrong. Gary R. From c.candide at laposte.net Fri Jul 24 16:54:54 2015 From: c.candide at laposte.net (candide) Date: Fri, 24 Jul 2015 13:54:54 -0700 (PDT) Subject: 42**1000000 is CPU time free Message-ID: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> Of course, computing 42**1000000 is not free: # ------------------ import time a=time.clock() N=1000000 42**N b=time.clock() print("CPU TIME :", b - a) # ------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CPU TIME : 2.37 real 0m2.412s user 0m2.388s sys 0m0.016s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So please, explain the following: # ------------------ import time a=time.clock() 42**1000000 b=time.clock() print("CPU TIME :", b - a) # ------------------ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CPU TIME : 0.0 real 0m2.410s user 0m2.400s sys 0m0.008s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (focus on the CPU TIME!!) From stephane at wirtel.be Fri Jul 24 16:57:40 2015 From: stephane at wirtel.be (=?utf-8?q?St=C3=A9phane?= Wirtel) Date: Fri, 24 Jul 2015 22:57:40 +0200 Subject: About this mailing list In-Reply-To: References: Message-ID: Blast ;) On 24 Jul 2015, at 22:38, Mark Lawrence wrote: > On 24/07/2015 21:27, St?phane Wirtel wrote: >> Hi all, >> >> This mail is just to check if you receive it because I think I have a >> problem with this list. >> >> Could you reply me to check it works ? >> >> Thank you >> >> -- >> St?phane Wirtel - http://wirtel.be - @matrixise > > No, sorry :) > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > -- > https://mail.python.org/mailman/listinfo/python-list -- St?phane Wirtel - http://wirtel.be - @matrixise From ckaynor at zindagigames.com Fri Jul 24 17:08:56 2015 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Fri, 24 Jul 2015 14:08:56 -0700 Subject: 42**1000000 is CPU time free In-Reply-To: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> References: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> Message-ID: As you are doing an operation on a literal, Python is computing the value at import time, which occurs before your time.clock() calls run. Basically, what you really wrote in your code is: import time a = time.clock() 42000000000000000000000000000000000000000...0000000000 # Replace the ... with zeros until you have the actual value. b = time.clock() The computation time is still being shown in the real and user times reported by the external call. Similarly, if you were to put time.clock() calls around the import statement, you would see the time there, for the first import statement (Python caches imports, so they generally only run once per instance). The first example can measure the time as you are using a variable, which bypasses Python's literal optimization. Chris On Fri, Jul 24, 2015 at 1:54 PM, candide wrote: > Of course, computing 42**1000000 is not free: > > > # ------------------ > import time > > a=time.clock() > > N=1000000 > 42**N > > b=time.clock() > > print("CPU TIME :", b - a) > # ------------------ > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > CPU TIME : 2.37 > > real 0m2.412s > user 0m2.388s > sys 0m0.016s > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > So please, explain the following: > > > # ------------------ > import time > > a=time.clock() > > 42**1000000 > > b=time.clock() > > print("CPU TIME :", b - a) > # ------------------ > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > CPU TIME : 0.0 > > real 0m2.410s > user 0m2.400s > sys 0m0.008s > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > (focus on the CPU TIME!!) > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zachary.ware+pylist at gmail.com Fri Jul 24 17:09:36 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Fri, 24 Jul 2015 16:09:36 -0500 Subject: 42**1000000 is CPU time free In-Reply-To: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> References: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> Message-ID: On Fri, Jul 24, 2015 at 3:54 PM, candide wrote: > Of course, computing 42**1000000 is not free: > So please, explain the following: > > (focus on the CPU TIME!!) In your second example, the peephole optimizer gets hold of it and does the calculation at compile time: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from dis import dis >>> def with_var(): N = 100; return 42**N ... >>> def no_var(): return 42**100 ... >>> dis(with_var) 1 0 LOAD_CONST 1 (100) 3 STORE_FAST 0 (N) 6 LOAD_CONST 2 (42) 9 LOAD_FAST 0 (N) 12 BINARY_POWER 13 RETURN_VALUE >>> dis(no_var) 1 0 LOAD_CONST 3 (2113143741011360736530044045523113991698878330713580061264477934391564919875497777688215057732151811172029315247932158994879668553186145824710950394684126712037376) 3 RETURN_VALUE >>> -- Zach From breamoreboy at yahoo.co.uk Fri Jul 24 17:14:50 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Jul 2015 22:14:50 +0100 Subject: 42**1000000 is CPU time free In-Reply-To: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> References: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> Message-ID: On 24/07/2015 21:54, candide wrote: > Of course, computing 42**1000000 is not free: > > > # ------------------ > import time > > a=time.clock() > > N=1000000 > 42**N > > b=time.clock() > > print("CPU TIME :", b - a) > # ------------------ > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > CPU TIME : 2.37 > > real 0m2.412s > user 0m2.388s > sys 0m0.016s > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > So please, explain the following: > > > # ------------------ > import time > > a=time.clock() > > 42**1000000 > > b=time.clock() > > print("CPU TIME :", b - a) > # ------------------ > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > CPU TIME : 0.0 > > real 0m2.410s > user 0m2.400s > sys 0m0.008s > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > (focus on the CPU TIME!!) > I suggest that you use the dis module to compare the code generated for the snippet using 'N' and that using the constant 1000000. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From Cecil at decebal.nl Fri Jul 24 17:23:12 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 24 Jul 2015 23:23:12 +0200 Subject: 42**1000000 is CPU time free References: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> Message-ID: <87d1zhmerj.fsf@Equus.decebal.nl> On Friday 24 Jul 2015 22:54 CEST, candide wrote: > Of course, computing 42**1000000 is not free: > > > # ------------------ > import time > > a=time.clock() > > N=1000000 > 42**N > > b=time.clock() > > print("CPU TIME :", b - a) > # ------------------ > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > CPU TIME : 2.37 > > real 0m2.412s > user 0m2.388s > sys 0m0.016s > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > So please, explain the following: > > > # ------------------ > import time > > a=time.clock() > > 42**1000000 > > b=time.clock() > > print("CPU TIME :", b - a) > # ------------------ > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > CPU TIME : 0.0 > > real 0m2.410s > user 0m2.400s > sys 0m0.008s > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > (focus on the CPU TIME!!) I cannot reproduce this. The first gives: CPU TIME : 0.6262789999999999 and the second: CPU TIME : 0.634364999999999 -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From c.candide at laposte.net Fri Jul 24 17:35:46 2015 From: c.candide at laposte.net (candide) Date: Fri, 24 Jul 2015 14:35:46 -0700 (PDT) Subject: 42**1000000 is CPU time free In-Reply-To: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> References: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> Message-ID: Thanks to all for your response, I was not aware that the interpreter evaluated pure litteral expressions at compile time. From fpm at u.washington.edu Fri Jul 24 18:20:07 2015 From: fpm at u.washington.edu (Frank Miles) Date: Fri, 24 Jul 2015 22:20:07 +0000 (UTC) Subject: Which GUI? References: Message-ID: On Fri, 24 Jul 2015 19:31:36 +0100, Paulo da Silva wrote: [snip] > Which technology is better? > matplotlib? > tkinter? > wxwidgets? > qt? Sadly - I don't think wxpython has been ported to python3 yet. From breamoreboy at yahoo.co.uk Fri Jul 24 19:15:42 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Jul 2015 00:15:42 +0100 Subject: Which GUI? In-Reply-To: References: Message-ID: On 24/07/2015 23:20, Frank Miles wrote: > On Fri, 24 Jul 2015 19:31:36 +0100, Paulo da Silva wrote: > > [snip] > > >> Which technology is better? >> matplotlib? >> tkinter? >> wxwidgets? >> qt? > > Sadly - I don't think wxpython has been ported to python3 yet. > http://wxpython.org/Phoenix/docs/html/main.html -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From nonami.ayo at gmail.com Fri Jul 24 19:34:05 2015 From: nonami.ayo at gmail.com (Nonami Animashaun) Date: Sat, 25 Jul 2015 00:34:05 +0100 Subject: About this mailing list In-Reply-To: References: Message-ID: On Fri, Jul 24, 2015 at 9:27 PM, St?phane Wirtel wrote: > Hi all, > > This mail is just to check if you receive it because I think I have a > problem with this list. > > Could you reply me to check it works ? > We hear you loud and clear > > Thank you > > You are welcome > -- > St?phane Wirtel - http://wirtel.be - @matrixise > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nonami.ayo at gmail.com Fri Jul 24 19:44:56 2015 From: nonami.ayo at gmail.com (Nonami Animashaun) Date: Sat, 25 Jul 2015 00:44:56 +0100 Subject: How may I learn Python Web Frameworks In-Reply-To: <16e4bdef-db76-4bc7-90f3-d81d7c2e0c35@googlegroups.com> References: <16e4bdef-db76-4bc7-90f3-d81d7c2e0c35@googlegroups.com> Message-ID: The official Django docs is pretty detailed https://docs.djangoproject.com/en/1.8/ You could also look at the Django book but it confesses to being written for version 1.4 even though it goes ahead to assure us that it's not outdated https://django-book.readthedocs.org/en/latest/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Fri Jul 24 20:33:56 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Jul 2015 01:33:56 +0100 Subject: what windows compiler for python 3.5? In-Reply-To: <55B22E76.9020304@nowhere.net> References: <55B21154.9060103@chamonix.reportlab.co.uk> <55B2129F.8060906@chamonix.reportlab.co.uk> <55B21927.2040605@chamonix.reportlab.co.uk> <55B22E76.9020304@nowhere.net> Message-ID: On 24/07/2015 13:24, Brian Gladman wrote: > On 24/07/2015 12:04, Chris Angelico wrote: >> On Fri, Jul 24, 2015 at 8:53 PM, Robin Becker wrote: >>> yes I build extensions for reportlab. Unfortunately, despite our MSDN >>> subscription to the Visual Studio stuff we have no access to the Visual >>> Studio Version 2015. Last one in my downloads is currently 2013. Pity. >> >> Ah. You may well be somewhat out of luck for the moment, then; I've no >> idea what status is during the betas. Once Python 3.5 is released, VS >> 2015 should also be available, or else the official compiler for >> CPython 3.5 will probably be changed. >> >> In the meantime, you could possibly ask on python-dev; Steve Dower of >> Microsoft hangs out there, and he's the one who's driving the compiler >> choice - he may be able to advise as to where to get the prerelease >> compiler. > > Visual Studio 2015 Community was relased earlier this week so there is > no need to work with the prerelease version. > No idea how I managed to miss that. Still upgrade achieved and it only took around four hours 30 minutes. We've terms like software, middleware, firmware, vapourware and so on and so forth, but I'm not certain what VS2015 comes under, explodedware possibly? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From spluque at gmail.com Sat Jul 25 00:18:21 2015 From: spluque at gmail.com (Seb) Date: Fri, 24 Jul 2015 23:18:21 -0500 Subject: scalar vs array and program control Message-ID: <87vbd850qa.fsf@gmail.com> Hello, I'm fairly new to Python, struggling to write in a more object-oriented, functional style. I just wrote a function that takes two arrays representing sine (y) and cosine (x) angle coordinates, and returns the angle in degrees. I had initially written the function to take array-like arguments x/y, but I'd like to generalize and take scalars as well. However, the function has a subsetting operations, which don't work with scalars: vmag = np.sqrt((x ** 2) + (y ** 2)) ang = np.arctan2(y, x) ang[ang < 0] = ang[ang < 0] + (2 * np.pi) # output range 0 - 2*pi ang[vmag == 0] = 0 # when magnitude is 0 the angle is also 0 ang[ang == 0] = 2 * np.pi # convention If I want to take scalars x/y, I naively thought about implementing an if/else statement right before the subsetting operations. However, my intuition tells me there must be a proper object-oriented solution to this. Any tips appreciated. Cheers, -- Seb From coolji1022 at gmail.com Sat Jul 25 01:30:07 2015 From: coolji1022 at gmail.com (=?UTF-8?B?6rmA7KeA7ZuI?=) Date: Sat, 25 Jul 2015 14:30:07 +0900 Subject: Hi Message-ID: Hi. I recently changed my path to be a programmer so I decided to learn python. I downloaded files(Python 2.7.10 - 2015-05-23 ) to setup on your website. (also got the version of x64 because of my cpu) But when I try to install it, there is an error. The error is "There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor." I searched on google but I couldn't find the answer. My computer is 64bit windows 7. I'm looking forward to receiving your reply ASAP. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From edgrsprj at ix.netcom.com Sat Jul 25 05:39:43 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sat, 25 Jul 2015 04:39:43 -0500 Subject: Python Questions - July 25, 2015 Message-ID: Posted by E.D.G. July 25, 2015 This posting involves general interest matters and some specific questions regarding Python code usage. Any help would be appreciated. 1. Program conversion effort 2. Specific code questions 1. PROGRAM CONVERSION EFFORT An effort is underway by several people including myself to convert a complex Perl language program to some other language such as Python so that, among other things, the program's numerous calculations will run faster. Perl with the PDL module would probably work. But we could not get the needed type of support for the PDL module. We also looked at Julia and several versions of Basic. But they also did not appear to presently have the type of support that is needed. Fortran was tried. It is great for calculation speed and the Fortran users were quite helpful. But we could not get certain important questions answered regarding using Fortran to create Windows "Pipes" to other running programs etc. We are presently checking to see if Python has the needed features and adequate support from Python newsgroups or forums. At the moment our Perl programs use Windows "Pipes" plus files in an interactive mode to send data to Gnuplot so that the data can be plotted. That actually produces good results. But it is a complex and inefficient process. So part of the conversion process involves learning how to have Python or some other program plot data in the same interactive mode. In this case "interactive" means that when a chart is being displayed on the computer screen for example, a key such as a Right Arrow Key can be pressed. My main Perl program checks for key presses perhaps 10 times a second and if it detects one it sends the appropriate information to Gnuplot through a "Pipe" so that Gnuplot will open some data file and use its contents to draw a new chart. That redrawing process on a moderately fast computer occurs so rapidly the transition cannot even be seen. The Perl program does not simply wait for a key to be pressed because it is at times processing data in the background. It has been my experience that sending large amounts of data from one program to another using a Windows pipe doesn't work very well. So files are presently being used for bulk data transfers. 2. SPECIFIC CODE QUESTIONS It will likely take some time to get all of these questions completely answered, especially the ones involving graphics. 1. The initial version of Python being used has to be a free download that is easy to understand. And it has to be compatible with Windows. Where can the best free download version of Python be obtained? Is the ActiveState version the best one for people who are not Python experts? I always found it quite easy to install ActiveState versions of Perl. 2. Graphics - This is likely a fairly complicated question. What are some of the graphics options available with Python? Does it have its own internal graphics routines? Perl does not as far as I can tell. And we never had time to explore Fortran's graphics capabilities. I am aware of the existence of Matlab. But as stated, everything involved with this present effort has to be a free download so that programmers around the world can easily and inexpensively generate program subroutines etc. 3. Fast Calculations It is my expectation that Python by itself does not do calculations very fast when compared to a language such as Fortran. So, what options are available for increasing the speed of Python calculations? Python could call a Fortran program to do the calculations just as Perl could. But we would like to avoid having to use more than one language with this effort. 4. What is the code for opening a Windows "Pipe" between a running Python program and some other program such as another Python or Perl program that can work with pipes? Three examples are needed if possible, one for just sending, one for just receiving, and one that allows both sending and receiving. I know how to open Windows pipes using Perl. 5. We would want Python to check for a key press now and then without actually waiting until a key is pressed. What would be the command for that? It is likely something like Get_Key 6. What is Python's version of the DOS level "System" command that many programs use as in: system "open notepad.exe" 7. What is Python's version of the SendKey command that many programs use to send information to an active Windows program as in: SendKey("Message to be printed on the Notepad screen") or SendKey(Right Arrow Key) 8. What commands does Python use to send to, and retrieve information from, the Windows clipboard? Regards, and thanks again for any assistance with this. E.D.G. From jonas at wielicki.name Sat Jul 25 06:58:51 2015 From: jonas at wielicki.name (Jonas Wielicki) Date: Sat, 25 Jul 2015 12:58:51 +0200 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: <55B36BEB.50206@wielicki.name> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi, These are quite a few questions and I?ll try to answer some of them. I have cut out the windows specific questions because I cannot answer them . On 25.07.2015 11:39, E.D.G. wrote: > At the moment our Perl programs use Windows "Pipes" plus files in > an interactive mode to send data to Gnuplot so that the data can > be plotted. That actually produces good results. But it is a > complex and inefficient process. So part of the conversion process > involves learning how to have Python or some other program plot > data in the same interactive mode. Using pipes should be no problem, but for plotting, see below. > It has been my experience that sending large amounts of data from > one program to another using a Windows pipe doesn't work very well. > So files are presently being used for bulk data transfers. This may be off topic, but I guess that should in fact be fast. Otherwise, have you tried using localhost TCP sockets? > 2. SPECIFIC CODE QUESTIONS > 2. Graphics - This is likely a fairly complicated question. > > What are some of the graphics options available with Python? Python comes with support for tk and there are bindings available for Qt and Gtk, but I think for your special use case, there are better options. > Does it have its own internal graphics routines? Perl does not as > far as I can tell. And we never had time to explore Fortran's > graphics capabilities. > > I am aware of the existence of Matlab. But as stated, everything > involved with this present effort has to be a free download so > that programmers around the world can easily and inexpensively > generate program subroutines etc. There is a python package called matplotlib [1]. I think it?s interface is in fact inspired by Matlab and it provides powerful and interactive plotting capabilities. > 3. Fast Calculations > > It is my expectation that Python by itself does not do calculations > very fast when compared to a language such as Fortran. You are correct. > > So, what options are available for increasing the speed of Python > calculations? Numpy and Scipy [2] are packages which were made just for that. > > Python could call a Fortran program to do the calculations just as > Perl could. But we would like to avoid having to use more than > one language with this effort. In fact, Numpy and Scipy use compiled Fortran code as far as I know -- but that is of no matter for a python user, they just see the very comfortable pythonic interface. > 6. What is Python's version of the DOS level "System" command that > many programs use as in: > > system "open notepad.exe" import subprocess # this blocks until `open` returns subprocess.check_call(["open", "notepad.exe"]) # returns immediately, `open` continues to run in the background subprocess.Popen(["open", "notepad.exe"]) regards, jwi [1]: http://matplotlib.org/ [2]: http://docs.scipy.org/doc/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCgAGBQJVs2vbAAoJEMBiAyWXYliKAeYP/3463zB43n4f5xcQXR0wdzWb Hea4qRuZdDyA/FywgNSay8KZ1tUKCk/LWL7rrP8Dpy2oBagdCYICdxJ11X0i0Oz/ 3fRVj1mbvYC3i4StcGH/wfz54bDsKF3whVtpTqF/Kz9dgSf6KeM608GdfI/yPSjv xh0dRuhkaf62Mx/PD3uhLGhHAxB9ZQhoYXlN8Mbc0sKzhnTJJIR4gfBhKSfpxzta 33hiRDXuHDx7zTO5AlIudFk+UGycrH8WGvsQ4fw/PhPEvOcFQz544GKo/+qCKGi0 y6QMtpchdhay3dZKc8ova8pF4ITdlU2Ojt+7MB4AthquNwje+rD4M388PFfQUWGf yMnWN3vato+uPUWECyi+bktKKS79McFDLn7QdncJI5lGZ216d8Y2uCWVyAw5aie3 2sweWnXmXy/zCeqnn4I4EfWO1jbMZ3fUitf7+rRywmGmq/1GhYg5TDgCC3GIYotU lrETp3Cpt0VCeELpQAODp+BWhU2z/n7Zf4FTrAsb5Ncxw9N08LgiJy0gaoAxGplb jabDFUka0Viof+TY/N8GYdoowR8AZA7E+1h0+aReWqW6N9H7YMpBdgLtI0BOHcuc vBVPWFUg8UtIYCQxLqkcQHb5UXq//eOsl9Bf6tPYWTVxAk4WfLxXE48Udj6Vu6E8 sa2zaDL0kMgoTowiF6Sr =tkL5 -----END PGP SIGNATURE----- From lac at openend.se Sat Jul 25 07:01:21 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 13:01:21 +0200 Subject: scalar vs array and program control In-Reply-To: Message from Seb of "Fri, 24 Jul 2015 23:18:21 -0500." <87vbd850qa.fsf@gmail.com> References: <87vbd850qa.fsf@gmail.com> Message-ID: <201507251101.t6PB1LqE021165@fido.openend.se> You have a bit of a problem, in that "functional" and "object-oriented" are two different styles of programming. You really cannot make your code 'more functional' and 'more object-oriented' at the same time -- more in one style implies less in the other. I think you may have got the mistaken idea that 'object-orientated' means 'well-written' or 'professional' or some such. However, if your intuition was telling you that it would be bad to write code that goes: if type(x) is str: do_something() elif type(x) is float: do_something_else() elif type(x) is int: do_another_thing() else: scream_loudly_and_dont_do_anything() then your intuition is working perfectly. Don't stick typechecks in all over your code. It makes it fragile and hard to maintain. It also means that you have to anticipate all the perfectly good input you might have, and nobody can do that. For instance, might somebody want to feed your functions complex numbers one day? Or, here is a good one -- python has a Decimal datatype which does Decimal floating point arithmetic. You don't want your code to not work for people using Decimal numbers just because you didn't put in a check for >>> type(Decimal(10.5)) If you find you need to check the type of something, it is better to use the isinstance function. if isinstance(x, str): do something() else: do_something_else() The python builtin types are all included here. For the sort of work you do it is useful to know about from numbers import Number isinstance(x, Number) which will happily return True for all sorts of numbers, complex, Decimal numbers even number classes which you define yourself. So if you need to do this sort of 'look before you leap' checking, isinstance is the way to do it. And sometimes this _is_ the sort of checking you want to do. But, aside from when you are writing test code, where it happens all over the place, most of the type in writing Python code we don't do this either. We don't look before we leap. We leap, and then if there are any problems, we deal with it. Instead we do something like this: consider a function that converts a string to a number def string_to_number(s): try: return int(s) except ValueError: return float(s) If all your input is guaranteed to be ints or floats this will work fine. It also works if you feed it things that are already ints and floats (not strings). And this is nice . How did I know to look for ValueErrors? >>> int("1.2") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1.2' Cause that is what Python gives you. If it had given you a TypeError instead -- which is what I expected it to do, but so it goes -- I would have said except TypeError. You can stack these things. >>> def string_to_number(x): try: return int(x) except ValueError: try: return float(x) except ValueError: return complex(x) So now it handles complex numbers as well. So this is, quite likely, the pattern that you are looking for: try: all_your_code_which_is_happy_with_non_scalars except WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: whatever_you_want_to_do_when_this_happens This is the usual way to do things. If you find that your try/except pairs are walking themselves all the way to the right hand side of the screen it is time to consider restructuring your code. The great advantage of this approach is that you don't have to pretend to omniscience about the sort of input you will get. If I decide to call your code with an array of Decimal floating point integers instead of regular floats, it's great if it just works, whether or not you had the idea of Decimal floating point in mind when you wrote the code. Sorry to be so longwinded. I need to go now and don't have time to revise it, though it probably should be made a whole bunch less preachy. Hope it helps, Laura From rosuav at gmail.com Sat Jul 25 07:34:11 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Jul 2015 21:34:11 +1000 Subject: scalar vs array and program control In-Reply-To: <201507251101.t6PB1LqE021165@fido.openend.se> References: <87vbd850qa.fsf@gmail.com> <201507251101.t6PB1LqE021165@fido.openend.se> Message-ID: On Sat, Jul 25, 2015 at 9:01 PM, Laura Creighton wrote: > How did I know to look for ValueErrors? > >>>> int("1.2") > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '1.2' > > Cause that is what Python gives you. If it had given you a TypeError > instead -- which is what I expected it to do, but so it goes -- I > would have said except TypeError. The difference between "12", which is valid input for int(), and "1.2", which isn't, is not the type of the object (both are str), but their values. That's why the exception is a ValueError. If you pass it a completely invalid *type*, then you get this: >>> int([]) Traceback (most recent call last): File "", line 1, in TypeError: int() argument must be a string, a bytes-like object or a number, not 'list' ChrisA From tandrewjohnson at outlook.com Sat Jul 25 07:36:04 2015 From: tandrewjohnson at outlook.com (tandrewjohnson at outlook.com) Date: Sat, 25 Jul 2015 04:36:04 -0700 (PDT) Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> 1. Download the Windows installer from Python.org to get started. It's the simplest and most common way to get started with Python on Windows. 2. Your assumption that Python does not have GUI capabilities built into the language is not correct. But unlike Perl, it has the GUI library Tkinter bundled with it. There are several more capable choices available: PyGTK, PyQt/PySide, and wxPython. For intensive numerical calculations, I'd recommend using the NumPy module, as well as the 64-bit version of Python is possible. I'm on my phone right now, so I apologize for my short answer with no links. I'll try to write a more detailed answer when I have access to my PC. From tandrewjohnson at outlook.com Sat Jul 25 07:39:15 2015 From: tandrewjohnson at outlook.com (tandrewjohnson at outlook.com) Date: Sat, 25 Jul 2015 04:39:15 -0700 (PDT) Subject: Python Questions - July 25, 2015 In-Reply-To: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: <058b3394-ff4c-42ff-8d1c-4d7bd6b74772@googlegroups.com> Sorry, in #2 I meant to say that your assumption *is* correct. My bad. From lac at openend.se Sat Jul 25 08:44:43 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 14:44:43 +0200 Subject: scalar vs array and program control In-Reply-To: Message from Laura Creighton of "Sat, 25 Jul 2015 13:01:21 +0200." <201507251101.t6PB1LqE021165@fido.openend.se> References: <87vbd850qa.fsf@gmail.com><201507251101.t6PB1LqE021165@fido.openend.se> Message-ID: <201507251244.t6PCihmd023479@fido.openend.se> And because I was rushed and posted without revision I left out something important. >So this is, quite likely, the pattern that you are looking for: > >try: > all_your_code_which_is_happy_with_non_scalars >except WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: > whatever_you_want_to_do_when_this_happens > >This is the usual way to do things. I forgot to tell you that you are supposed to stick the try/except around the smallest chunk of code that you expect to get the exception. So you write this as code_you_expect_always_to_work more_code_you_expect_always_to_work try: these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar except ValueError: # whatever kind of error the real error is whatever_you_want_to_do_when_that_happens The reason is that if you get any Value Errors in the part of the code you always expect to work, then you don't want your program to run happily along running the code for 'its a scalar'. You don't want to hide real errors here. The other thing I forgot to mention is that sometimes you don't want to do anything but ignore any errors of this sort. Thats written like this: code_you_expect_always_to_work more_code_you_expect_always_to_work try: these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar except ValueError: pass # just ignore it Laura From PointedEars at web.de Sat Jul 25 08:57:14 2015 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Sat, 25 Jul 2015 14:57:14 +0200 Subject: scalar vs array and program control References: <87vbd850qa.fsf@gmail.com> Message-ID: <1619647.1FW7hyz6Jq@PointedEars.de> Laura Creighton wrote: > [?] You really cannot make your code 'more functional' and 'more object- > oriented' at the same time -- more in one style implies less in the other. How did you get that idea? -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. From edgrsprj at ix.netcom.com Sat Jul 25 09:16:10 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sat, 25 Jul 2015 08:16:10 -0500 Subject: Python Questions - July 25, 2015 In-Reply-To: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: wrote in message news:2adac4ce-976f-4a8a-849d-c76e484eba77 at googlegroups.com... > 1. Download the Windows installer from Python.org to get started. It's the > simplest and most common way to get started with Python on Windows. > 2. Your assumption that Python does not have GUI capabilities built into > the language is not correct. But unlike Perl, it has the GUI library > Tkinter bundled with it. There are several more capable choices > available: PyGTK, PyQt/PySide, and wxPython. > For intensive numerical calculations, I'd recommend using the NumPy > module, as well as the 64-bit version of Python is possible. Posted by E.D.G. July 25, 2015 Thanks for the comments. I saw your other response as well. And it sounds like this effort is off to a good start. I myself have not yet started working with Python. But a retired professional programmer who is part of this effort did attempt to install Python. And he stated to me that he had encountered some difficulties with the installation. I am assuming that he got his download from Python.org. I don't yet know why he ran into problems. But as I have used the ActiveState version of Perl for quite a few years and have never had any trouble installing it I thought that their Python download might be a fairly easy version to install. Exactly which version should be used should be an easy matter to resolve. Most of the computers that people will be using are 64 bit machines. But at the same time, most people will be using 32 bit versions of Windows including XP. And I believe that this means that a 32 bit version of Python has to be used as well. This is somewhat unfortunate as I was once told that with 32 bit Windows, the most RAM type memory that a single program can use is 2 gigabytes. I have found that to be the case with my Perl programs. With 64 bit Windows that memory limit reportedly does not apply. So, since many of the people involved with this type of effort will likely be using 32 bit Windows XP or Vista, we won't have a choice on this. Another question: With my Perl programs, when I want to run the programs on a new computer or even from a flash drive, basically all I do is copy an entire existing Perl program directory to the new computer or flash drive. And that works. However, to make certain that it will work I might also actually install the Perl language program, delete everything in the Perl directory, and then copy all of the contents of an existing Perl directory to that new Perl directory. That way all of the various Perl modules don't have to be individually downloaded and linked with the main program. Will that work with Python as well. Or does each installation need to be created from scratch? Regards, E.D.G. From lac at openend.se Sat Jul 25 09:30:53 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 15:30:53 +0200 Subject: Python Questions - July 25, 2015 In-Reply-To: Message from "E.D.G." of "Sat, 25 Jul 2015 04:39:43 -0500." References: Message-ID: <201507251330.t6PDUrPa024535@fido.openend.se> I can answer some of these. In a message of Sat, 25 Jul 2015 04:39:43 -0500, "E.D.G." writes: > At the moment our Perl programs use Windows "Pipes" plus files in an >interactive mode to send data to Gnuplot so that the data can be plotted. >That actually produces good results. But it is a complex and inefficient >process. So part of the conversion process involves learning how to have >Python or some other program plot data in the same interactive mode. check out matplotlib http://matplotlib.org/ mayavi http://docs.enthought.com/mayavi/mayavi/ bokeh http://bokeh.pydata.org/en/latest/ seaborn: http://stanford.edu/~mwaskom/software/seaborn/ There are others. It sounds to me as if bokeh or mayavi animations are what you will be most interested in, but we can discuss this more. >1. The initial version of Python being used has to be a free download that >is easy to understand. And it has to be compatible with Windows. > > Where can the best free download version of Python be obtained? > > Is the ActiveState version the best one for people who are not Python >experts? For you, I think not. Your use case sounds like you are seriously on the 'scientific python' end of things. So you would be most interested in installing either the Enthought Scientific Python Collection (Canopy) https://store.enthought.com/ Or the Anaconda Scientific Python Suite: https://store.continuum.io/cshop/anaconda/ Enthought has been the leader in Scientific Python for many, many years. Anaconda is the new kid on the block. I cannot state which is better -- Anaconda is what we are using here at Chalmers University for the most part. They both duplicate the same functionality, for the most part, but the conda package manager that comes with Anaconda is really terrific. They bundle in all sorts of graphics and visualisation things. This is where you should start your looking. >2. Graphics - This is likely a fairly complicated question. > > What are some of the graphics options available with Python? see Anaconda and Enthought for a good start. If they don't do what you want, come back and discuss this more, we have plenty more options. >3. Fast Calculations > > It is my expectation that Python by itself does not do calculations >very fast when compared to a language such as Fortran. For the C version of Python, yes. There are many options for speeding up your python, but for your purposes numpy -- which is integrated into both the Enthought and Anaconda distribuitions is likely to be the most useful. You can also integrate with Fortran libraries should you want to here. >4. What is the code for opening a Windows "Pipe" between a running Python >program and some other program such as another Python or Perl program that >can work with pipes? No, clue, I don't know very much at all about Windows. >5. We would want Python to check for a key press now and then without >actually waiting until a key is pressed. What would be the command for >that? It is likely something like Get_Key Python knows _nothing_ about keys, keyboard input and the like. Capturing that stuff is the function of the graphical user interface program you use. Python has many of these. They all do it slightly differently but you won't have any problems whatever one you pick. >6. What is Python's version of the DOS level "System" command that many >programs use as in: > >system "open notepad.exe" Again, not a windows person but I am pretty sure you are looking for the subprocess module: For Python 2 https://docs.python.org/2/library/subprocess.html#module-subprocess For Python 3 https://docs.python.org/3.5/library/subprocess.html#module-subprocess >7. What is Python's version of the SendKey command that many programs use to >send information to an active Windows program as in: > >SendKey("Message to be printed on the Notepad screen") > >or > >SendKey(Right Arrow Key) We don't have one. You have to talk to your GUI toolkit for this. >8. What commands does Python use to send to, and retrieve information from, >the Windows clipboard? I don't know, again, I think you have to talk to your GUI toolkit. So, if I were you I would go check out the Enthought and Anaconda links and see if you like what they have to offer. What Gui toolkit you should use is partly a matter of personal preference, but often a matter of what kit works best with whatever visualisation tool you choose. In terms of the talking to people who heavily use the graphics toolkits mentioned, well, this list isn't a bad place to look for people but The scientific Python mailing list may get be a better place. http://www.scipy.org/scipylib/mailing-lists.html Anaconda also has a google group https://groups.google.com/a/continuum.io/forum/#!forum/anaconda And, of course, the various visualisers have their own mailing lists and forums which may be of use. Hope this helps, come back with any more questions Laura Creighton From lac at openend.se Sat Jul 25 09:43:59 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 15:43:59 +0200 Subject: scalar vs array and program control In-Reply-To: Message from "Thomas 'PointedEars' Lahn" of "Sat, 25 Jul 2015 14:57:14 +0200." <1619647.1FW7hyz6Jq@PointedEars.de> References: <87vbd850qa.fsf@gmail.com> <1619647.1FW7hyz6Jq@PointedEars.de> Message-ID: <201507251343.t6PDhxY8024899@fido.openend.se> In a message of Sat, 25 Jul 2015 14:57:14 +0200, "Thomas 'PointedEars' Lahn" wr ites: >Laura Creighton wrote: > >> [?] You really cannot make your code 'more functional' and 'more object- >> oriented' at the same time -- more in one style implies less in the other. > >How did you get that idea? Because pure object oriented techniques are best when you have a fixed set of operations on things, and as your code evolves you primarily add new things. Things written in a functional style work best when you have a fixed set of things, and your code evolves you add new operations for the existing things. Laura From edgrsprj at ix.netcom.com Sat Jul 25 09:45:07 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sat, 25 Jul 2015 08:45:07 -0500 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: "Laura Creighton" wrote in message news:mailman.977.1437831069.3674.python-list at python.org... >I can answer some of these. Posted by E.D.G. July 25, 2015 Thanks for all of the comments. My retired professional programming colleague is now going to have plenty of projects to work on. I myself am neither retired nor a professional programmer and usually rely on him to do the programming language exploration work. Most of those "system," "Pipe", and "SendKey" type commands usually refer to programs that are going to be running in a Windows environment. And many or most of the experienced programmers who are using Perl, Python, or Fortran appear to me to be using UNIX or Linux. So they might not be familiar with some Windows related commands such as "system." It took me a long, long time to learn how to get the Perl versions of those commands to work. Regards, E.D.G. From __peter__ at web.de Sat Jul 25 09:46:03 2015 From: __peter__ at web.de (Peter Otten) Date: Sat, 25 Jul 2015 15:46:03 +0200 Subject: scalar vs array and program control References: <87vbd850qa.fsf@gmail.com> Message-ID: Seb wrote: > Hello, > > I'm fairly new to Python, struggling to write in a more object-oriented, > functional style. I just wrote a function that takes two arrays > representing sine (y) and cosine (x) angle coordinates, and returns the > angle in degrees. I had initially written the function to take > array-like arguments x/y, but I'd like to generalize and take scalars as > well. However, the function has a subsetting operations, which don't > work with scalars: > > vmag = np.sqrt((x ** 2) + (y ** 2)) > ang = np.arctan2(y, x) > ang[ang < 0] = ang[ang < 0] + (2 * np.pi) # output range 0 - 2*pi > ang[vmag == 0] = 0 # when magnitude is 0 the angle is also 0 > ang[ang == 0] = 2 * np.pi # convention > > If I want to take scalars x/y, I naively thought about implementing an > if/else statement right before the subsetting operations. However, my > intuition tells me there must be a proper object-oriented solution to > this. Any tips appreciated. Here's a "duck-typed" solution: import numpy as np def _f(x, y): vmag = np.sqrt((x ** 2) + (y ** 2)) ang = np.arctan2(y, x) ang[ang < 0] = ang[ang < 0] + (2 * np.pi) # output range 0 - 2*pi ang[vmag == 0] = 0 # when magnitude is 0 the angle is also 0 ang[ang == 0] = 2 * np.pi # convention return ang def f(x, y): try: return _f(x, y) except IndexError: return _f(np.array([x]), y)[0] However, this is quite inefficient for scalars. Personally I'd implement two versions, one for scalars and one for vectors. This may be a little less convenient, but most of the time the client code has to deal either with scalars or vectors, not both. From lac at openend.se Sat Jul 25 09:59:22 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 15:59:22 +0200 Subject: Python Questions - July 25, 2015 In-Reply-To: Message from "E.D.G." of "Sat, 25 Jul 2015 08:16:10 -0500." References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: <201507251359.t6PDxM8v025219@fido.openend.se> >Another question: > > With my Perl programs, when I want to run the programs on a new >computer or even from a flash drive, basically all I do is copy an entire >existing Perl program directory to the new computer or flash drive. And >that works. However, to make certain that it will work I might also >actually install the Perl language program, delete everything in the Perl >directory, and then copy all of the contents of an existing Perl directory >to that new Perl directory. That way all of the various Perl modules don't >have to be individually downloaded and linked with the main program. > > Will that work with Python as well. Or does each installation need >to be created from scratch? > >Regards, > >E.D.G. The most common way to do things is to tell your users to install whatever python distribution you pick and then optionally install these extra packages (if you need any) and then give them a python program to run. But you can also package everything up into a .exe for them if they need this. Laura From spluque at gmail.com Sat Jul 25 11:30:58 2015 From: spluque at gmail.com (Sebastian P. Luque) Date: Sat, 25 Jul 2015 10:30:58 -0500 Subject: scalar vs array and program control References: <87vbd850qa.fsf@gmail.com> <201507251101.t6PB1LqE021165@fido.openend.se> <201507251244.t6PCihmd023479@fido.openend.se> Message-ID: <87lhe445l9.fsf@gmail.com> On Sat, 25 Jul 2015 14:44:43 +0200, Laura Creighton wrote: > And because I was rushed and posted without revision I left out > something important. >> So this is, quite likely, the pattern that you are looking for: >> try: all_your_code_which_is_happy_with_non_scalars except >> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: >> whatever_you_want_to_do_when_this_happens >> This is the usual way to do things. > I forgot to tell you that you are supposed to stick the try/except > around the smallest chunk of code that you expect to get the > exception. > So you write this as > code_you_expect_always_to_work more_code_you_expect_always_to_work > try: these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar > except ValueError: # whatever kind of error the real error is > whatever_you_want_to_do_when_that_happens > The reason is that if you get any Value Errors in the part of the code > you always expect to work, then you don't want your program to run > happily along running the code for 'its a scalar'. You don't want to > hide real errors here. > The other thing I forgot to mention is that sometimes you don't want > to do anything but ignore any errors of this sort. > Thats written like this: > code_you_expect_always_to_work more_code_you_expect_always_to_work > try: these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar > except ValueError: pass # just ignore it Thanks so much for all the pointers, and especially how `try` is used in practice. Avoiding the tangle of checks for kind of input is precisely what my intuition was telling me. -- Seb From steveburrus28 at gmail.com Sat Jul 25 12:00:18 2015 From: steveburrus28 at gmail.com (Steve Burrus) Date: Sat, 25 Jul 2015 09:00:18 -0700 (PDT) Subject: Python 3.4 Idle? In-Reply-To: <0d7bd697-e9bc-45f4-9278-c0bdfb8124fb@googlegroups.com> References: <9f2eea0f-2e1b-42a6-8510-feba034769c0@googlegroups.com> <0d7bd697-e9bc-45f4-9278-c0bdfb8124fb@googlegroups.com> Message-ID: <96406e1a-6fe6-4ac4-a576-c43f6a48212b@googlegroups.com> On Thursday, July 23, 2015 at 8:50:47 PM UTC-5, Steve Burrus wrote: > On Thursday, July 23, 2015 at 8:41:03 PM UTC-5, Chris Angelico wrote: > > On Fri, Jul 24, 2015 at 11:34 AM, Steve Burrus wrote: > > > I got Idle the other day biut had to get the older version, 2.7, of python to get it. So I wonder if there is an Idle version that comes with python 3.4.*? > > > > What system are you on? What did you do to install Python? On Windows, > > the python.org installers usually come with IDLE; on some Linuxes, > > it's separately distributed; if you got a third-party Python distro, > > it's up to them what they put in it. But yes, you most certainly can > > get 3.4+ with IDLE. > > > > ChrisA > > Well I am exactly on Windows 10 beta preview on a 64 bit system. Idle is on my Programs menu but I cannot actually activate it. I am sorry folks biut this isn't resolved yet about not being able to get the Idle in Python 3.4! Does it not work in WIndows 10? From lac at openend.se Sat Jul 25 12:34:30 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 18:34:30 +0200 Subject: Gmail eats Python Message-ID: <201507251634.t6PGYUvo028820@fido.openend.se> Gmail eats Python. We just saw this mail back from Sebastian Luque which says in part: >>> try: all_your_code_which_is_happy_with_non_scalars except >>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: >>> whatever_you_want_to_do_when_this_happens Ow! Gmail is understanding the >>> I stuck in as 'this is from the python console as a quoting marker and thinks it can reflow that. I think that splunqe must already have gmail set for plain text or else even worse mangling must show up. How do you teach gmail not to reflow what it thinks of as 'other people's quoted text'? Laura From lac at openend.se Sat Jul 25 12:42:56 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 18:42:56 +0200 Subject: Python 3.4 Idle? In-Reply-To: Message from Steve Burrus of "Sat, 25 Jul 2015 09:00:18 -0700." <96406e1a-6fe6-4ac4-a576-c43f6a48212b@googlegroups.com> References: <9f2eea0f-2e1b-42a6-8510-feba034769c0@googlegroups.com> <0d7bd697-e9bc-45f4-9278-c0bdfb8124fb@googlegroups.com><96406e1a-6fe6-4ac4-a576-c43f6a48212b@googlegroups.com> Message-ID: <201507251642.t6PGgu18029084@fido.openend.se> In a message of Sat, 25 Jul 2015 09:00:18 -0700, Steve Burrus writes: >On Thursday, July 23, 2015 at 8:50:47 PM UTC-5, Steve Burrus wrote: >> On Thursday, July 23, 2015 at 8:41:03 PM UTC-5, Chris Angelico wrote: >> > On Fri, Jul 24, 2015 at 11:34 AM, Steve Burrus wrote: >> > > I got Idle the other day biut had to get the older version, 2.7, of python to get it. So I wonder if there is an Idle version that comes with python 3.4.*? >> > >> > What system are you on? What did you do to install Python? On Windows, >> > the python.org installers usually come with IDLE; on some Linuxes, >> > it's separately distributed; if you got a third-party Python distro, >> > it's up to them what they put in it. But yes, you most certainly can >> > get 3.4+ with IDLE. >> > >> > ChrisA >> >> Well I am exactly on Windows 10 beta preview on a 64 bit system. Idle is on my Programs menu but I cannot actually activate it. > >I am sorry folks biut this isn't resolved yet about not being able to get the Idle in Python 3.4! Does it not work in WIndows 10? I don't know. But Idle depends on Tkinter. I would ask if Tkinter works on a Windows 10 beta preview over here: https://mail.python.org/mailman/listinfo/tkinter-discuss and see what they say. If tkinter doesn't work, then idle won't. If you have to do something special to get tkinter to work they will know what it is. And if they say -- no, works great here --- then we have a different problem, probably a bug. Laura From zachary.ware+pylist at gmail.com Sat Jul 25 12:51:49 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Sat, 25 Jul 2015 11:51:49 -0500 Subject: Gmail eats Python In-Reply-To: <201507251634.t6PGYUvo028820@fido.openend.se> References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: On Jul 25, 2015 11:35 AM, "Laura Creighton" wrote: > > Gmail eats Python. > > We just saw this mail back from Sebastian Luque which says in part: > > >>> try: all_your_code_which_is_happy_with_non_scalars except > >>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: > >>> whatever_you_want_to_do_when_this_happens > > Ow! Gmail is understanding the >>> I stuck in as 'this is from the > python console as a quoting marker and thinks it can reflow that. > > I think that splunqe must already have gmail set for plain text or > else even worse mangling must show up. > > How do you teach gmail not to reflow what it thinks of as > 'other people's quoted text'? Add same whitespace in front of the >'s, in plain text mode: >>> def test(): pass ... >>> print('Hi world') Hi world >>> (Hopefully that will work from my phone) -- Zach (On a phone) -------------- next part -------------- An HTML attachment was scrubbed... URL: From PointedEars at web.de Sat Jul 25 12:53:33 2015 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Sat, 25 Jul 2015 18:53:33 +0200 Subject: scalar vs array and program control References: <87vbd850qa.fsf@gmail.com> <1619647.1FW7hyz6Jq@PointedEars.de> Message-ID: <1757573.rN60lcJNyZ@PointedEars.de> Laura Creighton wrote: > [?] "Thomas 'PointedEars' Lahn" [writes]: >> Laura Creighton wrote: >>> [?] You really cannot make your code 'more functional' and 'more >>> object-oriented' at the same time -- more in one style implies less >>> in the other. >> How did you get that idea? > > Because pure object oriented techniques are best when you have > a fixed set of operations on things, and as your code evolves > you primarily add new things. Things written in a functional style > work best when you have a fixed set of things, and your code evolves > you add new operations for the existing things. Your logic is flawed. ?*Pure* object oriented? is your raising the bar. First of all, object-oriented programming and functional programming are programming *paradigms*, not merely techniques. Second, they are _not_ mutually exclusive paradigms. Third, Python supports both because in Python, functions are first-class objects. (In fact, if I am not mistaken, everything except None is an object in Python.) For example, let us make this original Python code more object-oriented and more functional at the same time: #------------------------------------------------------------------------ def foo (a, b): return a + b print(foo(42, 23)) #------------------------------------------------------------------------ First, more functional: #------------------------------------------------------------------------ def foo (f, a, b): return f(a, b) print(foo(lambda a, b: return a + b, 42, 23)) #------------------------------------------------------------------------ Instead of hard-coding the ?+? operation, (a reference to) a function (object) can be passed that is passed the remaining arguments, and the return value of the function is returned instead (you could overload the operator, and the ?foo? call here could be inlined, of course; this is just an example). Second, more object-oriented: #------------------------------------------------------------------------ class A: def __init__ (self, v=0): self._value = v def foo (self, f, b): return f(f, self._value, b) print(A(42).foo(lambda a, b: return a + b, 23)) #------------------------------------------------------------------------ The first operand now is an object, an instance of a class, and the former ?foo? function has become a method of that class that the object inherits. The method could be further inherited from a superclass, or overwritten by a subclass, for polymorphism. The callback could also be a public method provided by a class. There are probably better examples. In any case it should be possible for you to see that you are mistaken: One *can* make code more functional and more object-oriented at the same time, and more in one "style" does _not_ imply less in the other. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. From PointedEars at web.de Sat Jul 25 12:56:32 2015 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Sat, 25 Jul 2015 18:56:32 +0200 Subject: scalar vs array and program control References: <87vbd850qa.fsf@gmail.com> <1619647.1FW7hyz6Jq@PointedEars.de> <1757573.rN60lcJNyZ@PointedEars.de> Message-ID: <3271934.brgO5pjKeM@PointedEars.de> Thomas 'PointedEars' Lahn wrote: > #------------------------------------------------------------------------ > class A: > def __init__ (self, v=0): > self._value = v > > def foo (self, f, b): > return f(f, self._value, b) I mean return f(self._value, b) -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. From lac at openend.se Sat Jul 25 13:04:15 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 19:04:15 +0200 Subject: Gmail eats Python In-Reply-To: Message from Zachary Ware of "Sat, 25 Jul 2015 11:51:49 -0500." References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: <201507251704.t6PH4FNx029638@fido.openend.se> In a message of Sat, 25 Jul 2015 11:51:49 -0500, Zachary Ware writes: >On Jul 25, 2015 11:35 AM, "Laura Creighton" wrote: >> >> Gmail eats Python. >> >> We just saw this mail back from Sebastian Luque which says in part: >> >> >>> try: all_your_code_which_is_happy_with_non_scalars except >> >>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: >> >>> whatever_you_want_to_do_when_this_happens >> >> Ow! Gmail is understanding the >>> I stuck in as 'this is from the >> python console as a quoting marker and thinks it can reflow that. >> >> I think that splunqe must already have gmail set for plain text or >> else even worse mangling must show up. >> >> How do you teach gmail not to reflow what it thinks of as >> 'other people's quoted text'? > >Add same whitespace in front of the >'s, in plain text mode: > > >>> def test(): pass > ... > >>> print('Hi world') > Hi world > >>> > >(Hopefully that will work from my phone) > >-- >Zach >(On a phone) Worked great. So it was my fault by sending him a reply with >>> to the far left. I need to indent my text by some whitespace after I paste in the results from a Python console? Thank you Zach, I had no idea. I will change my behaviour. Laura From nils at meditalk.com Sat Jul 25 13:10:53 2015 From: nils at meditalk.com (Nils) Date: Sat, 25 Jul 2015 19:10:53 +0200 Subject: UDP and Python2.7 and 2.7 documentation gives error! Message-ID: <55B3C31D.7000205@meditalk.com> An HTML attachment was scrubbed... URL: From irmen.NOSPAM at xs4all.nl Sat Jul 25 13:33:16 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Sat, 25 Jul 2015 19:33:16 +0200 Subject: Python 3.4 Idle? In-Reply-To: <96406e1a-6fe6-4ac4-a576-c43f6a48212b@googlegroups.com> References: <9f2eea0f-2e1b-42a6-8510-feba034769c0@googlegroups.com> <0d7bd697-e9bc-45f4-9278-c0bdfb8124fb@googlegroups.com> <96406e1a-6fe6-4ac4-a576-c43f6a48212b@googlegroups.com> Message-ID: <55b3c85c$0$2966$e4fe514c@news.xs4all.nl> On 25-7-2015 18:00, Steve Burrus wrote: > On Thursday, July 23, 2015 at 8:50:47 PM UTC-5, Steve Burrus wrote: >> On Thursday, July 23, 2015 at 8:41:03 PM UTC-5, Chris Angelico wrote: >>> On Fri, Jul 24, 2015 at 11:34 AM, Steve Burrus wrote: >>>> I got Idle the other day biut had to get the older version, 2.7, of python to >>>> get it. So I wonder if there is an Idle version that comes with python 3.4.*? >>> >>> What system are you on? What did you do to install Python? On Windows, the >>> python.org installers usually come with IDLE; on some Linuxes, it's separately >>> distributed; if you got a third-party Python distro, it's up to them what they >>> put in it. But yes, you most certainly can get 3.4+ with IDLE. >>> >>> ChrisA >> >> Well I am exactly on Windows 10 beta preview on a 64 bit system. Idle is on my >> Programs menu but I cannot actually activate it. > > I am sorry folks biut this isn't resolved yet about not being able to get the Idle in > Python 3.4! Does it not work in WIndows 10? > "i cannot activate it" is very little information, there's no way without you giving more details to tell what could be wrong. My results on a Windows 10 preview machine: installed the python 3.4.3 msi from python.org, installed "for all users", default options: Idle is on the start menu ("IDLE - python 3.4 gui - 32 bit") and starts without problems. Python seems to work just fine. I suggest downloading the msi installer again and running the installation again (or chose 'repair' if prompted). Irmen From stephane at wirtel.be Sat Jul 25 13:43:45 2015 From: stephane at wirtel.be (=?utf-8?q?St=C3=A9phane?= Wirtel) Date: Sat, 25 Jul 2015 19:43:45 +0200 Subject: UDP and Python2.7 and 2.7 documentation gives error! In-Reply-To: <55B3C31D.7000205@meditalk.com> References: <55B3C31D.7000205@meditalk.com> Message-ID: the bind function is for the server, not for the client. here is an example: https://wiki.python.org/moin/UdpCommunication Stephane On 25 Jul 2015, at 19:10, Nils wrote: > UDP and Python2.7 and 2.7 documentation gives error! > I am trying to send UDP messages from one PC to another, using P2.7. > BUT I get an error I do not understand, this as I am following the > doc's for Python2.7! Listing of the script with error result > following: > > import socket > > UDP_IP = '192.168.0.90' > UDP_PORT = 45121 > msg = '7654321' > > print ("UDP target IP:", UDP_IP) > print ("UDP target port:", UDP_PORT) > print ("message:", msg) > > sock = socket.socket(socket.AF_INET, # Internet > ???????????????????? socket.SOCK_DGRAM) # UDP > sock.bind((UDP_IP, UDP_PORT)) > sock.send( msg ) > > > C:\Utveckling\Counter_python>Counter_send.py > ('UDP target IP:', '192.168.0.90') > ('UDP target port:', 45121) > ('message:', '7654321') > Traceback (most recent call last): > ? File "C:\Utveckling\Counter_python\Counter_send.py", line 13, in > > ??? sock.bind((UDP_IP, UDP_PORT)) > ? File "C:\Python27\lib\socket.py", line 228, in meth > ??? return getattr(self._sock,name)(*args) > socket.error: [Errno 10049] The requested address is not valid in its > context > > C:\Utveckling\Counter_python> > > So, please tell me where I am doing wrong, or is doc's wrong?? > Nils in Uppsala > > -- > > > > > > -- > https://mail.python.org/mailman/listinfo/python-list -- St?phane Wirtel - http://wirtel.be - @matrixise From lac at openend.se Sat Jul 25 13:45:34 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 19:45:34 +0200 Subject: scalar vs array and program control In-Reply-To: Message from "Thomas 'PointedEars' Lahn" of "Sat, 25 Jul 2015 18:53:33 +0200." <1757573.rN60lcJNyZ@PointedEars.de> References: <87vbd850qa.fsf@gmail.com> <1619647.1FW7hyz6Jq@PointedEars.de> <1757573.rN60lcJNyZ@PointedEars.de> Message-ID: <201507251745.t6PHjYwL030585@fido.openend.se> In a message of Sat, 25 Jul 2015 18:53:33 +0200, "Thomas 'PointedEars' Lahn" wr ites: >Laura Creighton wrote: > >> [?] "Thomas 'PointedEars' Lahn" [writes]: >>> Laura Creighton wrote: >>>> [?] You really cannot make your code 'more functional' and 'more >>>> object-oriented' at the same time -- more in one style implies less >>>> in the other. >>> How did you get that idea? >> >> Because pure object oriented techniques are best when you have >> a fixed set of operations on things, and as your code evolves >> you primarily add new things. Things written in a functional style >> work best when you have a fixed set of things, and your code evolves >> you add new operations for the existing things. > >Your logic is flawed. ?*Pure* object oriented? is your raising the bar. Yes. But I could have said, and probably should have said 'pure functional style' as well. >First of all, object-oriented programming and functional programming are >programming *paradigms*, not merely techniques. Second, they are _not_ >mutually exclusive paradigms. Third, Python supports both because in >Python, functions are first-class objects. (In fact, if I am not mistaken, >everything except None is an object in Python.) Ah, digression here. I generalise between paradigms that generate useful techniques, (functional programming and object oriented programming both do this) and those that do not (the Marxist paradigm of the labour theory of value). It still may be very useful and instructive to think on the Marxist Labour Theory of value, and it may have new utility if we can replace all labour with computer/robotic/IT ... but for now, do not run your economy on this theory, ok, because it does not work.) Second digression: that a thing uses objects does not make the thing more object oriented. >For example, let us make this original Python code more object-oriented and >more functional at the same time: > >#------------------------------------------------------------------------ >def foo (a, b): > return a + b > >print(foo(42, 23)) >#------------------------------------------------------------------------ > >First, more functional: > >#------------------------------------------------------------------------ >def foo (f, a, b): > return f(a, b) > >print(foo(lambda a, b: return a + b, 42, 23)) >#------------------------------------------------------------------------ > >Instead of hard-coding the ?+? operation, (a reference to) a function >(object) can be passed that is passed the remaining arguments, and the >return value of the function is returned instead (you could overload the >operator, and the ?foo? call here could be inlined, of course; this is just >an example). >Second, more object-oriented: > >#------------------------------------------------------------------------ >class A: > def __init__ (self, v=0): > self._value = v > > def foo (self, f, b): > return f(f, self._value, b) > >print(A(42).foo(lambda a, b: return a + b, 23)) >#------------------------------------------------------------------------ > >The first operand now is an object, an instance of a class, and the former >?foo? function has become a method of that class that the object inherits. >The method could be further inherited from a superclass, or overwritten by a >subclass, for polymorphism. The callback could also be a public method >provided by a class. > >There are probably better examples. In any case it should be possible for >you to see that you are mistaken: One *can* make code more functional and >more object-oriented at the same time, and more in one "style" does _not_ >imply less in the other. Okay, I give. It's possible, and I overstated things. But I suspect that it is only possible in things that are in the behavioural middle. You needed a lambda to make the thing more functional, and to create a class where none was before to make it more object-oriented. But this means that the thing wasn't all that functional nor object-oriented -- most likely procedural -- to start with. So, very clever. But still the general rule in refactoring, is that you want to go more oo or more functional, not both at the same time. Laura From jpiitula at ling.helsinki.fi Sat Jul 25 13:47:50 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Sat, 25 Jul 2015 20:47:50 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: Zachary Ware writes: > On Jul 25, 2015 11:35 AM, "Laura Creighton" wrote: >> >> Gmail eats Python. >> >> We just saw this mail back from Sebastian Luque which says in part: >> >> >>> try: all_your_code_which_is_happy_with_non_scalars except >> >>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: >> >>> whatever_you_want_to_do_when_this_happens >> >> Ow!?? Gmail is understanding the >>> I stuck in as 'this is >> from the python console as a quoting marker and thinks it can reflow >> that. >> >> I think that splunqe must already have gmail set for plain text or >> else even worse mangling must show up. >> >> How do you teach gmail not to reflow what it thinks of as >> 'other people's quoted text'? > > Add same whitespace in front of the >'s, in plain text mode: > > ???? >>> def test(): pass > ???? ... > ???? >>> print('Hi world') > ???? Hi world > ???? >>> > > (Hopefully that will work from my phone) Just in case anyone cares, Gnus shows me those indentations as octal codes, \302\240\302\240 (followed by one ASCII space). I guess a \302\240 is a NO-BREAK SPACE in UTF-8, and I guess Gnus does not know this because there is no charset specification in the headers. That seems to be missing whenever I see these codes instead of properly rendered characters and bother to check the headers. Has the world adopted UTF-8 as the default charset now or what? (I'll be only glad to hear that it has, if it has, but a reference to some sort of internet standard would be nice.) From jpiitula at ling.helsinki.fi Sat Jul 25 13:52:38 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Sat, 25 Jul 2015 20:52:38 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: Jussi Piitulainen writes: > Zachary Ware writes: [snip what I quoted from him] Oh well - Gnus made me go through some hoops to send the characters that were in the unknown-to-it encoding, and then mangled them. This is what I had added: > Just in case anyone cares, Gnus shows me those indentations as octal > codes, \302\240\302\240 (followed by one ASCII space). I guess a > \302\240 is a NO-BREAK SPACE in UTF-8, and I guess Gnus does not know > this because there is no charset specification in the headers. That > seems to be missing whenever I see these codes instead of properly > rendered characters and bother to check the headers. > > Has the world adopted UTF-8 as the default charset now or what? (I'll > be only glad to hear that it has, if it has, but a reference to some > sort of internet standard would be nice.) And any information is appreciated. Thanks. From lac at openend.se Sat Jul 25 13:56:54 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 19:56:54 +0200 Subject: UDP and Python2.7 and 2.7 documentation gives error! In-Reply-To: Message from Nils of "Sat, 25 Jul 2015 19:10:53 +0200." <55B3C31D.7000205@meditalk.com> References: <55B3C31D.7000205@meditalk.com> Message-ID: <201507251756.t6PHusEe030908@fido.openend.se> In a message of Sat, 25 Jul 2015 19:10:53 +0200, Nils writes: >UDP and Python2.7 and 2.7 documentation gives error! >I am trying to send UDP messages from one PC to another, using P2.7. >BUT I get an error I do not understand, this as I am following the doc's >for Python2.7! Listing of the script with error result following: > >import socket > >UDP_IP = '192.168.0.90' >UDP_PORT = 45121 >msg = '7654321' > >print ("UDP target IP:", UDP_IP) >print ("UDP target port:", UDP_PORT) >print ("message:", msg) > >sock = socket.socket(socket.AF_INET, # Internet >???????????????????? socket.SOCK_DGRAM) # UDP >sock.bind((UDP_IP, UDP_PORT)) >sock.send( msg ) > > >C:\Utveckling\Counter_python>Counter_send.py >('UDP target IP:', '192.168.0.90') >('UDP target port:', 45121) >('message:', '7654321') >Traceback (most recent call last): >? File "C:\Utveckling\Counter_python\Counter_send.py", line 13, in >??? sock.bind((UDP_IP, UDP_PORT)) >? File "C:\Python27\lib\socket.py", line 228, in meth >??? return getattr(self._sock,name)(*args) >socket.error: [Errno 10049] The requested address is not valid in its >context > >C:\Utveckling\Counter_python> > >So, please tell me where I am doing wrong, or is doc's wrong?? >Nils in Uppsala Does ipconfig report that 192.168.0.90 is something you can bind to? If not, that is your problem. It needs to be something on localhost that you can bind to. Laura From lac at openend.se Sat Jul 25 14:05:39 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 20:05:39 +0200 Subject: Gmail eats Python In-Reply-To: Message from Jussi Piitulainen of "Sat, 25 Jul 2015 20:52:38 +0300." References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: <201507251805.t6PI5doR031214@fido.openend.se> In a message of Sat, 25 Jul 2015 20:52:38 +0300, Jussi Piitulainen writes: >Jussi Piitulainen writes: >> Has the world adopted UTF-8 as the default charset now or what? (I'll >> be only glad to hear that it has, if it has, but a reference to some >> sort of internet standard would be nice.) I don't think so. Americans and other English speakers still love ASCII. but the ISO charsets are rapidly going the way of the buggywhip. :) http://www.loc.gov/standards/iso639-2/php/English_list.php Laura From lac at openend.se Sat Jul 25 14:08:01 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 25 Jul 2015 20:08:01 +0200 Subject: UDP and Python2.7 and 2.7 documentation gives error! In-Reply-To: Message from "=?utf-8?q?St=C3=A9phane?= Wirtel" of "Sat, 25 Jul 2015 19:43:45 +0200." References: <55B3C31D.7000205@meditalk.com> Message-ID: <201507251808.t6PI81Ks031340@fido.openend.se> In a message of Sat, 25 Jul 2015 19:43:45 +0200, "St?phane Wirtel" writes: >the bind function is for the server, not for the client. > >here is an example: https://wiki.python.org/moin/UdpCommunication > >Stephane >On 25 Jul 2015, at 19:10, Nils wrote: > >> UDP and Python2.7 and 2.7 documentation gives error! >> I am trying to send UDP messages from one PC to another, using P2.7. >> BUT I get an error I do not understand, this as I am following the >> doc's for Python2.7! Listing of the script with error result >> following: >> >> import socket >> >> UDP_IP = '192.168.0.90' >> UDP_PORT = 45121 >> msg = '7654321' >> >> print ("UDP target IP:", UDP_IP) >> print ("UDP target port:", UDP_PORT) >> print ("message:", msg) >> >> sock = socket.socket(socket.AF_INET, # Internet >> ???????????????????? socket.SOCK_DGRAM) # UDP >> sock.bind((UDP_IP, UDP_PORT)) >> sock.send( msg ) >> >> >> C:\Utveckling\Counter_python>Counter_send.py >> ('UDP target IP:', '192.168.0.90') >> ('UDP target port:', 45121) >> ('message:', '7654321') >> Traceback (most recent call last): >> ? File "C:\Utveckling\Counter_python\Counter_send.py", line 13, in >> >> ??? sock.bind((UDP_IP, UDP_PORT)) >> ? File "C:\Python27\lib\socket.py", line 228, in meth >> ??? return getattr(self._sock,name)(*args) >> socket.error: [Errno 10049] The requested address is not valid in its >> context >> >> C:\Utveckling\Counter_python> >> >> So, please tell me where I am doing wrong, or is doc's wrong?? >> Nils in Uppsala Stephane is correct, of course. I read things too superficially, sorry. (but if ipcpnfig doesn't find it, you will still have this problem:) Laura From christopherrmullins at gmail.com Sat Jul 25 14:20:25 2015 From: christopherrmullins at gmail.com (Christopher Mullins) Date: Sat, 25 Jul 2015 13:20:25 -0500 Subject: Hi In-Reply-To: References: Message-ID: > > I downloaded files(Python 2.7.10 - 2015-05-23 > ) to setup on your > website. > (also got the version of x64 because of my cpu) > But when I try to install it, there is an error. > The error is "There is a problem with this Windows Installer package. A > DLL required for this install to complete could not be run. Contact your > support personnel or package vendor." > According to this link, it could be a permissions issue [1]. [1] http://superuser.com/questions/478631/dll-could-not-be-run-for-msi-installers -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Sat Jul 25 14:26:54 2015 From: emile at fenx.com (Emile van Sebille) Date: Sat, 25 Jul 2015 11:26:54 -0700 Subject: Hi In-Reply-To: References: Message-ID: On 7/24/2015 10:30 PM, ??? wrote: > Hi. > I recently changed my path to be a programmer so I decided to learn python. > I downloaded files(Python 2.7.10 - 2015-05-23 > ) to setup on your > website. > (also got the version of x64 because of my cpu) > But when I try to install it, there is an error. > The error is "There is a problem with this Windows Installer package. A DLL > required for this install to complete could not be run. Contact your > support personnel or package vendor." > > I searched on google but I couldn't find the answer. > My computer is 64bit windows 7. You may find the activestate distribution works better for you. See http://www.activestate.com/activepython/downloads Emile From jon+usenet at unequivocal.co.uk Sat Jul 25 14:44:42 2015 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sat, 25 Jul 2015 18:44:42 +0000 (UTC) Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: On 2015-07-25, Jussi Piitulainen wrote: > Just in case anyone cares, Gnus shows me those indentations as octal > codes, \302\240\302\240 (followed by one ASCII space). I guess a > \302\240 is a NO-BREAK SPACE in UTF-8, and I guess Gnus does not know > this because there is no charset specification in the headers. It is not true that there were was no charset specification in the headers of the post you were responding to. It was specified as UTF-8. From breamoreboy at yahoo.co.uk Sat Jul 25 14:55:55 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Jul 2015 19:55:55 +0100 Subject: Python 3.4 Idle? In-Reply-To: <0d7bd697-e9bc-45f4-9278-c0bdfb8124fb@googlegroups.com> References: <9f2eea0f-2e1b-42a6-8510-feba034769c0@googlegroups.com> <0d7bd697-e9bc-45f4-9278-c0bdfb8124fb@googlegroups.com> Message-ID: On 24/07/2015 02:50, Steve Burrus wrote: > On Thursday, July 23, 2015 at 8:41:03 PM UTC-5, Chris Angelico wrote: >> On Fri, Jul 24, 2015 at 11:34 AM, Steve Burrus wrote: >>> I got Idle the other day biut had to get the older version, 2.7, of python to get it. So I wonder if there is an Idle version that comes with python 3.4.*? >> >> What system are you on? What did you do to install Python? On Windows, >> the python.org installers usually come with IDLE; on some Linuxes, >> it's separately distributed; if you got a third-party Python distro, >> it's up to them what they put in it. But yes, you most certainly can >> get 3.4+ with IDLE. >> >> ChrisA > > Well I am exactly on Windows 10 beta preview on a 64 bit system. Idle is on my Programs menu but I cannot actually activate it. > Please state how you tried to run IDLE and exactly what happened, then we should be able to advise. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From llanitedave at birdandflower.com Sat Jul 25 15:06:07 2015 From: llanitedave at birdandflower.com (llanitedave) Date: Sat, 25 Jul 2015 12:06:07 -0700 (PDT) Subject: Which GUI? In-Reply-To: References: Message-ID: On Friday, July 24, 2015 at 4:16:19 PM UTC-7, Mark Lawrence wrote: > On 24/07/2015 23:20, Frank Miles wrote: > > On Fri, 24 Jul 2015 19:31:36 +0100, Paulo da Silva wrote: > > > > [snip] > > > > > >> Which technology is better? > >> matplotlib? > >> tkinter? > >> wxwidgets? > >> qt? > > > > Sadly - I don't think wxpython has been ported to python3 yet. > > > > http://wxpython.org/Phoenix/docs/html/main.html > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence Matplotlib apparently still has some issues with wxPhoenix. Not that Matplotlib is a necessity for the OP's application, but it could address some of the speed issues he was concerned about. From marko at pacujo.net Sat Jul 25 15:42:12 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 25 Jul 2015 22:42:12 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: <87d1zgyqgb.fsf@elektro.pacujo.net> Jussi Piitulainen : >> ???? >>> def test(): pass >> ???? ... >> ???? >>> print('Hi world') >> ???? Hi world >> ???? >>> > > Just in case anyone cares, Gnus shows me those indentations as octal > codes, \302\240\302\240 (followed by one ASCII space). I guess a > \302\240 is a NO-BREAK SPACE in UTF-8, and I guess Gnus does not know > this because there is no charset specification in the headers. That > seems to be missing whenever I see these codes instead of properly > rendered characters and bother to check the headers. > > Has the world adopted UTF-8 as the default charset now or what? (I'll > be only glad to hear that it has, if it has, but a reference to some > sort of internet standard would be nice.) The gnus command C-u g displays the raw message. It demonstrates that the posting was sent as Content-Type: multipart/alternative; boundary=001a1134d474c99321051bb5ef45 The first part has: Content-Type: text/plain; charset=UTF-8 The second part has: Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The text/plain variant expresses the indentations with plain whitespace (SPC) characters. However, the text/html variant has:

      =C2=A0=C2=A0 >>> def test(): pass
      =C2=A0=C2=A0 ...
      =C2=A0=C2=A0 >>> print('Hi world')
      =C2=A0=C2=A0 Hi world
      =C2=A0=C2=A0 >>>

      =C2=A0 stands for '\u00a0' (NO-BREAK SPACE). When I have Gnus display the HTML variant, the indentation is not displayed at all. I don't know why. (It's another question what place text/html has on this forum in the first place.) Marko From zachary.ware+pylist at gmail.com Sat Jul 25 16:09:32 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Sat, 25 Jul 2015 15:09:32 -0500 Subject: Gmail eats Python In-Reply-To: <87d1zgyqgb.fsf@elektro.pacujo.net> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> Message-ID: On Jul 25, 2015 2:45 PM, "Marko Rauhamaa" wrote: > (It's another question what place text/html has on this forum in the > first place.) If the gmail app on my phone had the option, I'd only send the plain text. As is, I'm just glad it does send a plain text version :) -- Zach (On a phone) -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Sat Jul 25 16:10:58 2015 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 25 Jul 2015 16:10:58 -0400 Subject: Which GUI? In-Reply-To: <87twstmi2b.fsf@Equus.decebal.nl> References: <87twstmi2b.fsf@Equus.decebal.nl> Message-ID: On 7/24/15 4:11 PM, Cecil Westerhof wrote: > Top-posting is (rightly) frowned upon in this group. Could you use > inline posting next time? Meta is definitely NOT discouraged on this list, but it should be. Nothing like derailing an interesting thread with lectures on where to post. Aaaaand someone will chime in with a diatribe against Google groups...wait for it...wait for it... To address the OP's query, I recommend Tkinter. Plays very nicely with C and C++. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From tandrewjohnson at outlook.com Sat Jul 25 18:16:50 2015 From: tandrewjohnson at outlook.com (tjohnson) Date: Sat, 25 Jul 2015 15:16:50 -0700 (PDT) Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: <36504953-b446-4ec5-a3ff-8ba4fc746a99@googlegroups.com> On Saturday, July 25, 2015 at 5:40:02 AM UTC-4, E.D.G. wrote: > Posted by E.D.G. July 25, 2015 > > This posting involves general interest matters and some specific > questions regarding Python code usage. Any help would be appreciated. > > 1. Program conversion effort > 2. Specific code questions > > > 1. PROGRAM CONVERSION EFFORT > > An effort is underway by several people including myself to convert a > complex Perl language program to some other language such as Python so that, > among other things, the program's numerous calculations will run faster. > > Perl with the PDL module would probably work. But we could not get > the needed type of support for the PDL module. We also looked at Julia and > several versions of Basic. But they also did not appear to presently have > the type of support that is needed. > > Fortran was tried. It is great for calculation speed and the Fortran > users were quite helpful. But we could not get certain important questions > answered regarding using Fortran to create Windows "Pipes" to other running > programs etc. > > We are presently checking to see if Python has the needed features > and adequate support from Python newsgroups or forums. > > At the moment our Perl programs use Windows "Pipes" plus files in an > interactive mode to send data to Gnuplot so that the data can be plotted. > That actually produces good results. But it is a complex and inefficient > process. So part of the conversion process involves learning how to have > Python or some other program plot data in the same interactive mode. > > In this case "interactive" means that when a chart is being displayed > on the computer screen for example, a key such as a Right Arrow Key can be > pressed. My main Perl program checks for key presses perhaps 10 times a > second and if it detects one it sends the appropriate information to Gnuplot > through a "Pipe" so that Gnuplot will open some data file and use its > contents to draw a new chart. That redrawing process on a moderately fast > computer occurs so rapidly the transition cannot even be seen. > > The Perl program does not simply wait for a key to be pressed because > it is at times processing data in the background. > > It has been my experience that sending large amounts of data from one > program to another using a Windows pipe doesn't work very well. So files > are presently being used for bulk data transfers. > > > 2. SPECIFIC CODE QUESTIONS > > It will likely take some time to get all of these questions > completely answered, especially the ones involving graphics. > > > 1. The initial version of Python being used has to be a free download that > is easy to understand. And it has to be compatible with Windows. > > Where can the best free download version of Python be obtained? > > Is the ActiveState version the best one for people who are not Python > experts? > > I always found it quite easy to install ActiveState versions of Perl. > > > 2. Graphics - This is likely a fairly complicated question. > > What are some of the graphics options available with Python? > > Does it have its own internal graphics routines? Perl does not as > far as I can tell. And we never had time to explore Fortran's graphics > capabilities. > > I am aware of the existence of Matlab. But as stated, everything > involved with this present effort has to be a free download so that > programmers around the world can easily and inexpensively generate program > subroutines etc. > > > 3. Fast Calculations > > It is my expectation that Python by itself does not do calculations > very fast when compared to a language such as Fortran. > > So, what options are available for increasing the speed of Python > calculations? > > Python could call a Fortran program to do the calculations just as > Perl could. But we would like to avoid having to use more than one language > with this effort. > > > 4. What is the code for opening a Windows "Pipe" between a running Python > program and some other program such as another Python or Perl program that > can work with pipes? > > Three examples are needed if possible, one for just sending, one for > just receiving, and one that allows both sending and receiving. I know how > to open Windows pipes using Perl. > > > 5. We would want Python to check for a key press now and then without > actually waiting until a key is pressed. What would be the command for > that? It is likely something like Get_Key > > > 6. What is Python's version of the DOS level "System" command that many > programs use as in: > > system "open notepad.exe" > > > 7. What is Python's version of the SendKey command that many programs use to > send information to an active Windows program as in: > > SendKey("Message to be printed on the Notepad screen") > > or > > SendKey(Right Arrow Key) > > > 8. What commands does Python use to send to, and retrieve information from, > the Windows clipboard? > > > Regards, and thanks again for any assistance with this. > > E.D.G. It looks like Laura has answered most of your questions pretty well. I'm sorry that I forgot about your questions until now. I was busy because the hard drive on my primary PC failed last night. The only thing I can think of right now to add is that regarding #8, you can also use the PyWin32 module on Windows for clipboard access. If your code needs to be cross-platform, this isn't an option, but if not, you might find it to be very useful. It might also have capabilities for #3 and #7, but I don't have it installed anymore, so I'm not sure. From ben+python at benfinney.id.au Sat Jul 25 20:49:40 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 26 Jul 2015 10:49:40 +1000 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <201507251704.t6PH4FNx029638@fido.openend.se> Message-ID: <85twsrn3ob.fsf@benfinney.id.au> Laura Creighton writes: > So it was my fault by sending him a reply with >>> to the far left. No, it was Google Mail's failt for messing with the content of the message. Never forget that these services are meant to serve us. When they fail to do so because they're violating internet standards, it's not our fault. > Thank you Zach, I had no idea. I will change my behaviour. Google can't force you to change your behaviour; they only have that power if you give it to them. -- \ ?People come up to me and say, ?Emo, do people really come up | `\ to you??? ?Emo Philips | _o__) | Ben Finney From ben+python at benfinney.id.au Sat Jul 25 20:52:46 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 26 Jul 2015 10:52:46 +1000 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> Message-ID: <85pp3fn3j5.fsf@benfinney.id.au> Zachary Ware writes: > If the gmail app on my phone had the option, I'd only send the plain > text. Isn't that a good reason to avoid composing email messages on a program that lacks the correct capability? If the GMail app lacks the ability to send plain text, there are better alternatives (including avoiding GMail entirely). -- \ ?If I had known what it would be like to have it all... I might | `\ have been willing to settle for less.? ?Jane Wagner, via Lily | _o__) Tomlin | Ben Finney From rosuav at gmail.com Sat Jul 25 20:58:07 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Jul 2015 10:58:07 +1000 Subject: Gmail eats Python In-Reply-To: <85pp3fn3j5.fsf@benfinney.id.au> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <85pp3fn3j5.fsf@benfinney.id.au> Message-ID: On Sun, Jul 26, 2015 at 10:52 AM, Ben Finney wrote: > Zachary Ware writes: > >> If the gmail app on my phone had the option, I'd only send the plain >> text. > > Isn't that a good reason to avoid composing email messages on a program > that lacks the correct capability? > > If the GMail app lacks the ability to send plain text, there are better > alternatives (including avoiding GMail entirely). Phones suck. If you can't do stuff on your phone because it's all locked down, take a hammer to your phone and use a device that gives you more freedom. Most people I know claim to own phones, but really just use what they're given; the phone provider truly owns those phones. ChrisA From invalid at invalid.invalid Sat Jul 25 20:58:08 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 26 Jul 2015 00:58:08 +0000 (UTC) Subject: Gmail eats Python References: Message-ID: On 2015-07-25, Laura Creighton wrote: > Gmail eats Python. > > We just saw this mail back from Sebastian Luque which says in part: > >>>> try: all_your_code_which_is_happy_with_non_scalars except >>>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: >>>> whatever_you_want_to_do_when_this_happens > > Ow! [...] You use mutt or something else decent as your MUA. -- Grant From invalid at invalid.invalid Sat Jul 25 21:01:13 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 26 Jul 2015 01:01:13 +0000 (UTC) Subject: UDP and Python2.7 and 2.7 documentation gives error! References: <55B3C31D.7000205@meditalk.com> Message-ID: On 2015-07-25, =?utf-8?q?St=C3=A9phane?= Wirtel wrote: > the bind function is for the server, not for the client. It's for both. When you're sending, it is used to specify the source port. -- Grant From steve at pearwood.info Sun Jul 26 00:03:06 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 26 Jul 2015 14:03:06 +1000 Subject: scalar vs array and program control References: Message-ID: <55b45bfa$0$1643$c3e8da3$5496439d@news.astraweb.com> On Sat, 25 Jul 2015 02:18 pm, Seb wrote: > Hello, > > I'm fairly new to Python, struggling to write in a more object-oriented, > functional style. I just wrote a function that takes two arrays > representing sine (y) and cosine (x) angle coordinates, and returns the > angle in degrees. Alas, your description is not entirely clear. I think you mean you take the rectangular coordinates x and y, and return the angle of the line from the origin to the point (x, y) in degrees. E.g. given x = y = 1, return 45. Try this: def angle_deg(x, y): return np.rad2deg(np.arctan(y/x)) And in action, it works with both scalars and arrays. py> angle_deg(1, 2) 63.43494882292201 py> angle_deg(np.array([1, 2, 3, 4]), np.array([1, 3, 2, 0])) array([ 45. , 56.30993247, 33.69006753, 0. ]) An alternative would be this: def angle_deg2(x, y): return np.rad2deg(np.arctan2(y, x)) py> angle_deg2(np.array([1, 2, 3, 4]), np.array([1, 3, 2, 0])) array([ 45. , 56.30993247, 33.69006753, 0. ]) There may be differences in results for points not in the first quadrant. If you're only using numpy functions, or (most) operators like + - * etc, they already work on both scalars and numpy arrays. If you write your own functions using only those things, your functions will gain the same ability. But if you find yourself needing to use functions which numpy doesn't provide, you can emulate a similar style like this: from number import Number def my_function(arg): if isinstance(arg, Number): # code treating arg as a scalar else: # assume arg is a vector for x in arg: # code treating x as a scalar You'll probably find duplicated code. You can remove that duplicated code this way: # note the leading underscore; that is the Python convention for "Private" def _my_function(x): if isinstance(x, Number): # code treating x as a scalar else: raise TypeError("expected a number, got %s" % type(x).__name__) def my_function(arg): if isinstance(arg, Number): return _my_function(arg) else: for x in arg: y = _my_function(x) # stick y in some sort of array # return the array of y values -- Steven From steve at pearwood.info Sun Jul 26 00:04:53 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 26 Jul 2015 14:04:53 +1000 Subject: Gmail eats Python References: Message-ID: <55b45c64$0$1643$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Jul 2015 02:34 am, Laura Creighton wrote: > Gmail eats Python. > > We just saw this mail back from Sebastian Luque which says in part: > >>>> try: all_your_code_which_is_happy_with_non_scalars except >>>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: >>>> whatever_you_want_to_do_when_this_happens > > Ow! Gmail is understanding the >>> I stuck in as 'this is from the > python console as a quoting marker and thinks it can reflow that. That's one of the reasons I have my Python prompt set to "py> ". -- Steven From catalinfest at gmail.com Sun Jul 26 00:47:35 2015 From: catalinfest at gmail.com (blue) Date: Sat, 25 Jul 2015 21:47:35 -0700 (PDT) Subject: Which GUI? In-Reply-To: References: Message-ID: <77b7b182-da35-40c4-b8f1-8a753eb7d970@googlegroups.com> Hi . I tested all. Now I think the PySide can more. https://pyside.readthedocs.org/en/latest/ See also http://free-tutorials.org/pyside-introduction-part-001/ http://python-catalin.blogspot.ro/ From steve at pearwood.info Sun Jul 26 00:49:54 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 26 Jul 2015 14:49:54 +1000 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: <55b466f2$0$1674$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Jul 2015 03:47 am, Jussi Piitulainen wrote: > Just in case anyone cares, Gnus shows me those indentations as octal > codes, \302\240\302\240 (followed by one ASCII space). I guess a > \302\240 is a NO-BREAK SPACE in UTF-8, and I guess Gnus does not know > this because there is no charset specification in the headers. That > seems to be missing whenever I see these codes instead of properly > rendered characters and bother to check the headers. Some of us care :-) Zachary's post that you are referring to does have the charset declared, but it uses individual declarations for each of the multipart/alternative parts: --001a1134d474c99321051bb5ef45 Content-Type: text/plain; charset=UTF-8 --001a1134d474c99321051bb5ef45 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On the other hand, your post sent from Gnus is lying. Despite containing non-ASCII bytes (i.e. octal \302\240), it sends these headers: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit US-ASCII is 7-bit only and only defines values for ord \0 through \177 in octal. -- Steven From catalinfest at gmail.com Sun Jul 26 00:52:18 2015 From: catalinfest at gmail.com (blue) Date: Sat, 25 Jul 2015 21:52:18 -0700 (PDT) Subject: Hi In-Reply-To: References: Message-ID: <5dc4545a-79e2-4c4b-811a-3e8f5239808f@googlegroups.com> ... also you can have all python modules from : http://www.lfd.uci.edu/~gohlke/pythonlibs/ read this mini tutorial ( working also with python 2.7) : http://python-catalin.blogspot.ro/2014/10/windows-all-modules-for-python-34.html From steve at pearwood.info Sun Jul 26 00:52:56 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 26 Jul 2015 14:52:56 +1000 Subject: 42**1000000 is CPU time free References: <97d39924-f41a-48b1-a71c-49970889b7a9@googlegroups.com> Message-ID: <55b467a7$0$1674$c3e8da3$5496439d@news.astraweb.com> On Sat, 25 Jul 2015 07:35 am, candide wrote: > Thanks to all for your response, I was not aware that the interpreter > evaluated pure litteral expressions at compile time. This is an implementation-dependent optimization, so different versions of Python may do more, or less, or even no, optimization. -- Steven From jpiitula at ling.helsinki.fi Sun Jul 26 01:01:09 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Sun, 26 Jul 2015 08:01:09 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> Message-ID: Marko Rauhamaa writes: > Jussi Piitulainen writes: >> Just in case anyone cares, Gnus shows me those indentations as octal >> codes, \302\240\302\240 (followed by one ASCII space). I guess a >> \302\240 is a NO-BREAK SPACE in UTF-8, and I guess Gnus does not know >> this because there is no charset specification in the headers. That >> seems to be missing whenever I see these codes instead of properly >> rendered characters and bother to check the headers. > The gnus command > > C-u g > > displays the raw message. Thanks! I was just typing t to see what I thought were the full headers. > It demonstrates that the posting was sent as > > Content-Type: multipart/alternative; boundary=001a1134d474c99321051bb5ef45 > > The first part has: > > Content-Type: text/plain; charset=UTF-8 > > The second part has: > > Content-Type: text/html; charset=UTF-8 > Content-Transfer-Encoding: quoted-printable Yes, with C-u g, I see them. > The text/plain variant expresses the indentations with plain > whitespace (SPC) characters. However, the text/html variant has: > >

      =C2=A0=C2=A0 >>> def test(): pass
      > =C2=A0=C2=A0 ...
      > =C2=A0=C2=A0 >>> print('Hi world')
      > =C2=A0=C2=A0 Hi world
      > =C2=A0=C2=A0 >>>

      > > =C2=A0 stands for '\u00a0' (NO-BREAK SPACE). I suppose that's a valid HTML fragment when the charset is declared, but the Gnus version I use fails to use the charset information when it renders the message. Annoying that it chooses text/html over text/plain and then fails. (Probably I can customize it now that I have a precise idea of what it is that is going wrong.) > When I have Gnus display the HTML variant, the indentation is not > displayed at all. I don't know why. So many ways to fail :) From jpiitula at ling.helsinki.fi Sun Jul 26 01:26:58 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Sun, 26 Jul 2015 08:26:58 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: Laura Creighton writes: > In a message of Sat, 25 Jul 2015 20:52:38 +0300, Jussi Piitulainen writes: >>Jussi Piitulainen writes: >>> Has the world adopted UTF-8 as the default charset now or what? >>> (I'll be only glad to hear that it has, if it has, but a reference >>> to some sort of internet standard would be nice.) > > I don't think so. Americans and other English speakers still love > ASCII. but the ISO charsets are rapidly going the way of the > buggywhip. :) > http://www.loc.gov/standards/iso639-2/php/English_list.php I thought the ISO-8859 sets are going away in favour of UTF-8, and I welcome that development. ASCII is still fine as a subset of UTF-8. What's not fine is the use of encoded characters outside ASCII without a corresponding declaration (possibly a default) of the encoding (or my mail reader failing to understand that the declaration is there). But how is that link to a set of language codes relevant? From rustompmody at gmail.com Sun Jul 26 01:28:17 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 25 Jul 2015 22:28:17 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> Message-ID: <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> On Sunday, July 26, 2015 at 10:31:20 AM UTC+5:30, Jussi Piitulainen wrote: > Marko Rauhamaa writes: > > > Jussi Piitulainen writes: > > >> Just in case anyone cares, Gnus shows me those indentations as octal > >> codes, \302\240\302\240 (followed by one ASCII space). I guess a > >> \302\240 is a NO-BREAK SPACE in UTF-8, and I guess Gnus does not know > >> this because there is no charset specification in the headers. That > >> seems to be missing whenever I see these codes instead of properly > >> rendered characters and bother to check the headers. > > > The gnus command > > > > C-u g > > > > displays the raw message. > > Thanks! I was just typing t to see what I thought were the full headers. > > > It demonstrates that the posting was sent as > > > > Content-Type: multipart/alternative; boundary=001a1134d474c99321051bb5ef45 > > > > The first part has: > > > > Content-Type: text/plain; charset=UTF-8 > > > > The second part has: > > > > Content-Type: text/html; charset=UTF-8 > > Content-Transfer-Encoding: quoted-printable > > Yes, with C-u g, I see them. > > > The text/plain variant expresses the indentations with plain > > whitespace (SPC) characters. However, the text/html variant has: > > > >

      =C2=A0=C2=A0 >>> def test(): pass
      > > =C2=A0=C2=A0 ...
      > > =C2=A0=C2=A0 >>> print('Hi world')
      > > =C2=A0=C2=A0 Hi world
      > > =C2=A0=C2=A0 >>>

      > > > > =C2=A0 stands for '\u00a0' (NO-BREAK SPACE). > > I suppose that's a valid HTML fragment when the charset is declared, but > the Gnus version I use fails to use the charset information when it > renders the message. Annoying that it chooses text/html over text/plain > and then fails. (Probably I can customize it now that I have a precise > idea of what it is that is going wrong.) Emacs belongs to the age when choice (and freedom, and democracy and brotherhood and ...) are an unqualified good. A 500-page gnus manual used to be the height of cuteness -- kittens, milk and all. Not so post https://en.wikipedia.org/wiki/The_Paradox_of_Choice > So many ways to fail :) Combinatorially increases with choices... Mostly spurious ones. JFTR: Ive been using emacs for 20+ years. And I have the increasing feeling that my students are getting fedup with it (and me). Used Idle for my last python course without too much grief. If only it were an option for 25 programming languages, and org-mode and unicode/devanagari/tex input and. From rosuav at gmail.com Sun Jul 26 01:34:02 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Jul 2015 15:34:02 +1000 Subject: Gmail eats Python In-Reply-To: <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> Message-ID: On Sun, Jul 26, 2015 at 3:28 PM, Rustom Mody wrote: > JFTR: Ive been using emacs for 20+ years. And I have the increasing feeling > that my students are getting fedup with it (and me). Used Idle for my last python > course without too much grief. If only it were an option for 25 programming languages, and org-mode and unicode/devanagari/tex input and. Not sure whether you're making the point deliberately or accidentally, but that's exactly why emacs is so big and heavy: "if only, if only". Simpler things do less. ChrisA From jpiitula at ling.helsinki.fi Sun Jul 26 01:37:14 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Sun, 26 Jul 2015 08:37:14 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <55b466f2$0$1674$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano writes: > On Sun, 26 Jul 2015 03:47 am, Jussi Piitulainen wrote: > >> Just in case anyone cares, Gnus shows me those indentations as octal >> codes, \302\240\302\240 (followed by one ASCII space). I guess a >> \302\240 is a NO-BREAK SPACE in UTF-8, and I guess Gnus does not know >> this because there is no charset specification in the headers. That >> seems to be missing whenever I see these codes instead of properly >> rendered characters and bother to check the headers. > > Some of us care :-) Thank you. > On the other hand, your post sent from Gnus is lying. Despite > containing non-ASCII bytes (i.e. octal \302\240), it sends these > headers: > > Content-Type: text/plain; charset=us-ascii > Content-Transfer-Encoding: 8bit > > US-ASCII is 7-bit only and only defines values for ord \0 through \177 > in octal. Yes. Gnus made me go through a dialogue to send the message, and I didn't understand what all the options meant. So I probably told it to lie. My bad. From ian.g.kelly at gmail.com Sun Jul 26 01:59:17 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 25 Jul 2015 21:59:17 -0800 Subject: Gmail eats Python In-Reply-To: <201507251634.t6PGYUvo028820@fido.openend.se> References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: On Jul 25, 2015 8:36 AM, "Laura Creighton" wrote: > Ow! Gmail is understanding the >>> I stuck in as 'this is from the > python console as a quoting marker and thinks it can reflow that. You didn't use >>> in the email that I saw. That's actually three levels of quoting: one added in your reply to yourself, the second in Sebastian's reply to your reply, and the third apparently added in your first post in this thread. -------------- next part -------------- An HTML attachment was scrubbed... URL: From john_ladasky at sbcglobal.net Sun Jul 26 02:15:13 2015 From: john_ladasky at sbcglobal.net (John Ladasky) Date: Sat, 25 Jul 2015 23:15:13 -0700 (PDT) Subject: Hi In-Reply-To: References: Message-ID: On Saturday, July 25, 2015 at 10:39:48 AM UTC-7, ??? wrote: > Hi. > I recently changed my path to be a programmer so I decided to learn python. > I downloaded files(Python 2.7.10 - 2015-05-23)?to setup on your website. Unless you need to maintain someone's older software, I would personally recommend that you use Python 3 instead of Python 2. From rustompmody at gmail.com Sun Jul 26 02:15:22 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 25 Jul 2015 23:15:22 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> Message-ID: <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> On Sunday, July 26, 2015 at 11:05:14 AM UTC+5:30, Chris Angelico wrote: > On Sun, Jul 26, 2015 at 3:28 PM, Rustom Mody wrote: > > JFTR: Ive been using emacs for 20+ years. And I have the increasing feeling > > that my students are getting fedup with it (and me). Used Idle for my last python > > course without too much grief. If only it were an option for 25 programming languages, and org-mode and unicode/devanagari/tex input and. > > Not sure whether you're making the point deliberately or accidentally, > but that's exactly why emacs is so big and heavy: "if only, if only". > Simpler things do less. Well Almost. Emacs used to stand for "Eight Megabytes And Constantly Swapping" At a time when 8 MB was large. Is it today? So let me ask you: Do you not use ? dozen (at least) languages? And their interpreters (when they exist) And their ancilliary tools (make autoconf etc) And do you not type plain text? Emails? PIM (reminders, timesheets and planning) Docs (more fancy than plain text, maybe libreoffice/MS/latex...) Lilypond? Use, experiment, play-around with (non-ASCII) unicode? If you have one app to do them all, I'd like (and pay!) for it If not I bet they are mutually inconsistent. No... Emacs is big (its not actually) and heavy (yeah) because there's no BDFL to clean up the mess and take the flak. Lehman's law of software deterioration (7th in this list https://en.wikipedia.org/wiki/Lehman%27s_laws_of_software_evolution ) is about as inexorable as entropy in thermodynamics From rosuav at gmail.com Sun Jul 26 02:25:20 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Jul 2015 16:25:20 +1000 Subject: Gmail eats Python In-Reply-To: <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> Message-ID: On Sun, Jul 26, 2015 at 4:15 PM, Rustom Mody wrote: > Well Almost. > Emacs used to stand for "Eight Megabytes And Constantly Swapping" > At a time when 8 MB was large. Is it today? > So let me ask you: > Do you not use ? dozen (at least) languages? > And their interpreters (when they exist) > And their ancilliary tools (make autoconf etc) > And do you not type plain text? > Emails? > PIM (reminders, timesheets and planning) > Docs (more fancy than plain text, maybe libreoffice/MS/latex...) > Lilypond? > Use, experiment, play-around with (non-ASCII) unicode? > > If you have one app to do them all, I'd like (and pay!) for it > If not I bet they are mutually inconsistent. > For the most part, I use a single text editor. But all their ancillary tools are separate. Emacs tries to be absolutely everything, not just editing text files; that's why it's big. Size isn't just a matter of disk or RAM footprint, it's also (and much more importantly) UI complexity. It's a trade-off, of course. If you constantly have to switch programs to do your work, that's a different form of UI complexity. ChrisA From ian.g.kelly at gmail.com Sun Jul 26 02:43:07 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 25 Jul 2015 22:43:07 -0800 Subject: Gmail eats Python In-Reply-To: <85twsrn3ob.fsf@benfinney.id.au> References: <201507251634.t6PGYUvo028820@fido.openend.se> <201507251704.t6PH4FNx029638@fido.openend.se> <85twsrn3ob.fsf@benfinney.id.au> Message-ID: On Jul 25, 2015 4:51 PM, "Ben Finney" wrote: > > Laura Creighton writes: > > > So it was my fault by sending him a reply with >>> to the far left. > > No, it was Google Mail's failt for messing with the content of the > message. > > Never forget that these services are meant to serve us. When they fail > to do so because they're violating internet standards, it's not our > fault. What Internet standard is being violated by reflowing text content in the message body? I'm also skeptical that this was caused by Gmail, which I've never seen do this and did not do this when I tried to repro it just now. Also, unless I'm misinterpreting the headers of the message in question, it appears to have been sent via Gmane, not Gmail. From marko at pacujo.net Sun Jul 26 02:55:29 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 26 Jul 2015 09:55:29 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> Message-ID: <87twsrxva6.fsf@elektro.pacujo.net> Chris Angelico : > Emacs tries to be absolutely everything, not just editing text files; > that's why it's big. I use emacs for most of my text inputting needs. Sometimes I even use it to type in web forms (prepare it in emacs and copy the text over into the form). I'm typing now. Hence, I'm using emacs. It's great that I don't have to settle for less. No matter what I'm typing, M-$ spell-checks the word under the cursor. No matter what I'm typing, M-x picture-mode allows me to draw a picture in ASCII graphics. And C-x ( starts a macro -- immensely useful in many circumstances. Emacs also works over text terminal connections. I use it all the time to access virtual machines at the office as well as my home machine from overseas. Marko From lac at openend.se Sun Jul 26 03:02:44 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 26 Jul 2015 09:02:44 +0200 Subject: Gmail eats Python In-Reply-To: Message from Grant Edwards of "Sun, 26 Jul 2015 00:58:08 -0000." References: Message-ID: <201507260702.t6Q72ioX016223@fido.openend.se> In a message of Sun, 26 Jul 2015 00:58:08 -0000, Grant Edwards writes: >You use mutt or something else decent as your MUA. > I do -- the problem is all the gmail users out there. Laura From mircaviar at gmail.com Sun Jul 26 03:22:47 2015 From: mircaviar at gmail.com (mircaviar at gmail.com) Date: Sun, 26 Jul 2015 00:22:47 -0700 (PDT) Subject: O'Reilly Python Certification In-Reply-To: <9e5d10eb-9111-4843-a106-6d1c4610472c@googlegroups.com> References: <6657943d-4924-4f8f-8894-8e7541a9d5a5@googlegroups.com> <9e5d10eb-9111-4843-a106-6d1c4610472c@googlegroups.com> Message-ID: <912b0218-c7ce-4b55-8e06-b5e006deb7bd@googlegroups.com> On Wednesday, September 10, 2014 at 9:19:05 PM UTC+3, mjkan... at gmail.com wrote: > I just completed all four modules and Kirby was my instructor. I really enjoyed the class and got a lot out of it. I am not a developer, so common concepts like objects were new to me, whereas standard data structures like lists, dicts, etc. were already known. It definitely allowed me to increase my overall understanding of common programming concepts while I learned the pythonic way to implement them. > > I recommend the class. It's a bit pricey, so best if your employer can foot the bill. Hi there, I just started the classes, I want to ask you long does take you to finish the four modules? thanks From jwayodi at gmail.com Sun Jul 26 03:46:51 2015 From: jwayodi at gmail.com (Joseph Wayodi) Date: Sun, 26 Jul 2015 10:46:51 +0300 Subject: Hi In-Reply-To: References: Message-ID: On Sat, Jul 25, 2015 at 8:30 AM, ??? wrote: > Hi. > I recently changed my path to be a programmer so I decided to learn python. > I downloaded files(Python 2.7.10 - 2015-05-23) to setup on your website. > (also got the version of x64 because of my cpu) > But when I try to install it, there is an error. > The error is "There is a problem with this Windows Installer package. A DLL > required for this install to complete could not be run. Contact your support > personnel or package vendor." > > I searched on google but I couldn't find the answer. > My computer is 64bit windows 7. > > I'm looking forward to receiving your reply ASAP. > > Thanks. > A similar question has been asked on Super User: . You might want to try the suggestions provided on there. From rustompmody at gmail.com Sun Jul 26 04:20:02 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 26 Jul 2015 01:20:02 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: <87twsrxva6.fsf@elektro.pacujo.net> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> Message-ID: <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> On Sunday, July 26, 2015 at 12:25:42 PM UTC+5:30, Marko Rauhamaa wrote: > Chris Angelico: > > > Emacs tries to be absolutely everything, not just editing text files; > > that's why it's big. > > I use emacs for most of my text inputting needs. Sometimes I even use it > to type in web forms (prepare it in emacs and copy the text over into > the form). > > I'm typing now. Hence, I'm using emacs. It's great that I don't have to > settle for less. > > No matter what I'm typing, M-$ spell-checks the word under the cursor. > No matter what I'm typing, M-x picture-mode allows me to draw a picture > in ASCII graphics. And C-x ( starts a macro -- immensely useful in many > circumstances. > > Emacs also works over text terminal connections. I use it all the time > to access virtual machines at the office as well as my home machine from > overseas. Emacs 'tries to be everything' in exactly the same way that a 'general purpose programming language' is too general and by pretending to solve all problems actually solves none (until you hire a programmer). Problem with emacs (culture) is that its aficionados assume that a superb conceptual design trumps technological relevance, UI clunkiness etc. Which is true... within reasonable limits. For something a little more contemporary (and successful) than mail clients here's emacs doing git: https://www.youtube.com/watch?v=zobx3T7hGNA [Did you notice that you used the locutions 'M-$', 'M-x'? What sense does this 80s terminology make to an emacs uninitiate in 2015? >From seeing my 20-year-olf students suffer all this combined with the hopelessness of convincing the emacs folks that we are in 2015, not 1980, I conclude this is a losing battle ] From cs at zip.com.au Sun Jul 26 04:20:56 2015 From: cs at zip.com.au (Cameron Simpson) Date: Sun, 26 Jul 2015 18:20:56 +1000 Subject: Gmail eats Python In-Reply-To: References: Message-ID: <20150726082056.GA21788@cskk.homeip.net> On 25Jul2015 22:43, Ian Kelly wrote: >On Jul 25, 2015 4:51 PM, "Ben Finney" wrote: >> Laura Creighton writes: >> > So it was my fault by sending him a reply with >>> to the far left. >> >> No, it was Google Mail's failt for messing with the content of the >> message. Specificly, by manking the text without leave(*). >What Internet standard is being violated by reflowing text content in >the message body? RFC3676: http://tools.ietf.org/rfcmarkup?doc=3676 See also: http://joeclark.org/ffaq.html There is a variant on plain old text/plain, namely the format= parameter. (This message is using it.) If you set it to format=flowed then the user agent is allowed to reflow te text to fit the display width. It also specifies a tighter interpretation of the quoted-message indentation markers (i.e. the ">>>") allow for reflow of the quoted material as well. >I'm also skeptical that this was caused by Gmail, which I've never >seen do this and did not do this when I tried to repro it just now. >Also, unless I'm misinterpreting the headers of the message in >question, it appears to have been sent via Gmane, not Gmail. Who knows if it was caused by GMail. Hard to tell at this point. (*) However, it does look like something may have treated a plain text message as plain text in format=flowed form. Or perhaps some user agent has just gone rogue. Cheers, Cameron Simpson in rec.moto, jsh wrote: > Dan Nitschke wrote: > > Ged Martin wrote: > > > On Sat, 17 May 1997 16:53:33 +0000, Dan Nitschke scribbled: > > > >(And you stay *out* of my dreams, you deviant little > > > >weirdo.) > > > Yeah, yeah, that's what you're saying in _public_.... > > Feh. You know nothing of my dreams. I dream entirely in text (New Century > > Schoolbook bold oblique 14 point), and never in color. I once dreamed I > > was walking down a flowchart of my own code, and a waterfall of semicolons > > was chasing me. (I hid behind a global variable until they went by.) > You write code in a proportional serif? No wonder you got extra > semicolons falling all over the place. No, I *dream* about writing code in a proportional serif font. It's much more exciting than my real life. /* dan: THE Anti-Ged -- Ignorant Yank (tm) #1, none-%er #7 */ Dan Nitschke peDANtic at best.com nitschke at redbrick.com From cs at zip.com.au Sun Jul 26 04:22:29 2015 From: cs at zip.com.au (Cameron Simpson) Date: Sun, 26 Jul 2015 18:22:29 +1000 Subject: Gmail eats Python In-Reply-To: <201507260702.t6Q72ioX016223@fido.openend.se> References: <201507260702.t6Q72ioX016223@fido.openend.se> Message-ID: <20150726082229.GA49570@cskk.homeip.net> On 26Jul2015 09:02, Laura Creighton wrote: >In a message of Sun, 26 Jul 2015 00:58:08 -0000, Grant Edwards writes: >>You use mutt or something else decent as your MUA. > >I do -- the problem is all the gmail users out there. Take heart - gmail used to do much worse than this:-) Cheers, Cameron Simpson From marko at pacujo.net Sun Jul 26 04:35:46 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 26 Jul 2015 11:35:46 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> Message-ID: <87pp3fxqn1.fsf@elektro.pacujo.net> Rustom Mody : > Emacs 'tries to be everything' in exactly the same way that a 'general > purpose programming language' is too general and by pretending to > solve all problems actually solves none (until you hire a programmer). Emacs isn't too general. It's just right. > Problem with emacs (culture) is that its aficionados assume that a > superb conceptual design trumps technological relevance, It's relevant to me every day, for business and pleasure. > [Did you notice that you used the locutions 'M-$', 'M-x'? What sense > does this 80s terminology make to an emacs uninitiate in 2015? They can be initiated in mere seconds to that esoteric knowledge. > From seeing my 20-year-olf students suffer all this What do your students suffer from? The beauty of the matter is that they can use any editor they like. They don't have to like or use emacs. (In some shops you actually virtually *have* to use Eclipse or Visual Studio or the some such thing. That *is* painful.) > combined with the hopelessness of convincing the emacs folks that we > are in 2015, not 1980, What do you need to convince emacs folks about? Emacs isn't perfect at everything, but the emacs developers have kept it admirably up to date. It has been following the quirks of Java, git and MS Exchange even if it has been an uphill battle. > I conclude this is a losing battle What would you like to achieve, exactly? Marko From rustompmody at gmail.com Sun Jul 26 04:50:21 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 26 Jul 2015 01:50:21 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: <87pp3fxqn1.fsf@elektro.pacujo.net> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> Message-ID: On Sunday, July 26, 2015 at 2:06:00 PM UTC+5:30, Marko Rauhamaa wrote: > Rustom Mody : > > > Emacs 'tries to be everything' in exactly the same way that a 'general > > purpose programming language' is too general and by pretending to > > solve all problems actually solves none (until you hire a programmer). > > Emacs isn't too general. It's just right. > > > Problem with emacs (culture) is that its aficionados assume that a > > superb conceptual design trumps technological relevance, > > It's relevant to me every day, for business and pleasure. > > > [Did you notice that you used the locutions 'M-$', 'M-x'? What sense > > does this 80s terminology make to an emacs uninitiate in 2015? > > They can be initiated in mere seconds to that esoteric knowledge. You are being obtuse Marko! Yeah that 'M-' is what everyone calls Alt can be conveyed in a few seconds But there are a hundred completely useless pieces of comtemporary-to-emacs inconsistency: - What everyone calls a window, emacs calls a frame - And what emacs calls a window, everyone calls a pane - What everyone does with C-x emacs does with C-w (and woe betide if you mix that up) - What everyone calls head (of a list) emacs calls Car (Toyota?) > > > From seeing my 20-year-olf students suffer all this > > What do your students suffer from? The beauty of the matter is that they > can use any editor they like. They don't have to like or use emacs. > > (In some shops you actually virtually *have* to use Eclipse or Visual > Studio or the some such thing. That *is* painful.) > > > combined with the hopelessness of convincing the emacs folks that we > > are in 2015, not 1980, > > What do you need to convince emacs folks about? Emacs isn't perfect at > everything, but the emacs developers have kept it admirably up to date. > It has been following the quirks of Java, git and MS Exchange even if it > has been an uphill battle. > > > I conclude this is a losing battle > > What would you like to achieve, exactly? Some attitude correction? That emacs starts its tutorial showing how to use C-p and C-n for what everyone uses arrows is bad enough. That the arrow-keys are later found to work quite alright is even worse and speaks of a ridiculous attitude From abder.rahman.ali at gmail.com Sun Jul 26 05:11:13 2015 From: abder.rahman.ali at gmail.com (Abder-Rahman Ali) Date: Sun, 26 Jul 2015 11:11:13 +0200 Subject: AttributeError: LineLogic instance has no attribute 'probe' Message-ID: Hello, I'm quite puzzled with an error I'm having in my code. In the class ---> LineLogic I have the following portion of code: def __init__(self): self.probe = vtk.vtkProbeFilter() probe.SetInputConnection(line.GetOutputPort()) probe.SetSourceData(volumeNode.GetImageData()) probe.Update() In another class ---> LineLogicTest I had the following portion of code: logic = LineLogic() probe = logic.probe data = probe.GetOutput().GetPointData().GetScalars() When I try running the program, I get the following error: AttributeError: LineLogic instance has no attribute 'probe' How can I solve this error? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at pearwood.info Sun Jul 26 05:21:27 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 26 Jul 2015 19:21:27 +1000 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <201507251704.t6PH4FNx029638@fido.openend.se> <85twsrn3ob.fsf@benfinney.id.au> Message-ID: <55b4a697$0$1665$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Jul 2015 04:43 pm, Ian Kelly wrote: > I'm also skeptical that this was caused by Gmail, which I've never > seen do this and did not do this when I tried to repro it just now. > Also, unless I'm misinterpreting the headers of the message in > question, it appears to have been sent via Gmane, not Gmail. The message that Laura is referring to is this: https://mail.python.org/pipermail/python-list/2015-July/694570.html There's no easy way to get to the headers from the list archive, but looking at the version I downloaded via Usenet, I agree that Gmail appears to be a red-herring. I can't be sure how it was sent to the list, but my guess is sent to the newsgroup comp.lang.python via Gmane, which forwards to the mailing list. Sebastian's post claims to be sent by Gnus: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) and although he uses a Gmail account, I see no sign that this particular message went via Gmail. -- Steven From alister.nospam.ware at ntlworld.com Sun Jul 26 05:21:30 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Sun, 26 Jul 2015 09:21:30 +0000 (UTC) Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> Message-ID: On Sun, 26 Jul 2015 01:50:21 -0700, Rustom Mody wrote: > On Sunday, July 26, 2015 at 2:06:00 PM UTC+5:30, Marko Rauhamaa wrote: >> Rustom Mody : >> >> > Emacs 'tries to be everything' in exactly the same way that a >> > 'general purpose programming language' is too general and by >> > pretending to solve all problems actually solves none (until you hire >> > a programmer). >> >> Emacs isn't too general. It's just right. >> >> > Problem with emacs (culture) is that its aficionados assume that a >> > superb conceptual design trumps technological relevance, >> >> It's relevant to me every day, for business and pleasure. >> >> > [Did you notice that you used the locutions 'M-$', 'M-x'? What sense >> > does this 80s terminology make to an emacs uninitiate in 2015? >> >> They can be initiated in mere seconds to that esoteric knowledge. > > You are being obtuse Marko! > > Yeah that 'M-' is what everyone calls Alt can be conveyed in a few > seconds But there are a hundred completely useless pieces of > comtemporary-to-emacs inconsistency: > - What everyone calls a window, emacs calls a frame - And what emacs > calls a window, everyone calls a pane - What everyone does with C-x > emacs does with C-w (and woe betide if you mix that up) > - What everyone calls head (of a list) emacs calls Car (Toyota?) > > >> > From seeing my 20-year-olf students suffer all this >> >> What do your students suffer from? The beauty of the matter is that >> they can use any editor they like. They don't have to like or use >> emacs. >> >> (In some shops you actually virtually *have* to use Eclipse or Visual >> Studio or the some such thing. That *is* painful.) >> >> > combined with the hopelessness of convincing the emacs folks that we >> > are in 2015, not 1980, >> >> What do you need to convince emacs folks about? Emacs isn't perfect at >> everything, but the emacs developers have kept it admirably up to date. >> It has been following the quirks of Java, git and MS Exchange even if >> it has been an uphill battle. >> >> > I conclude this is a losing battle >> >> What would you like to achieve, exactly? > > Some attitude correction? > That emacs starts its tutorial showing how to use C-p and C-n for what > everyone uses arrows is bad enough. > That the arrow-keys are later found to work quite alright is even worse > and speaks of a ridiculous attitude emacs is a great operating system - the only thing it lacks is a good text editor ;-) -- Home is the place where, when you have to go there, they have to take you in. -- Robert Frost, "The Death of the Hired Man" From marko at pacujo.net Sun Jul 26 05:51:57 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 26 Jul 2015 12:51:57 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> Message-ID: <87lhe3xn42.fsf@elektro.pacujo.net> Rustom Mody : > You are being obtuse Marko! > > Yeah that 'M-' is what everyone calls Alt can be conveyed in a few > seconds Often Alt doesn't work. For example, the stupid GUI thinks it can intercept some Alt key combinations. Then, it's good to know the ESC prefix functions as Alt. Also, in some settings, it is not Alt but some other funny Windows or Mac keyboard key that serves as Meta. It's all explained at the beginning of the builtin tutorial (C-h t). > - What everyone calls a window, emacs calls a frame Emacs called its windows windows long before there were windowing systems. For example the command M-x other-window (ordinarily bound to C-x o) would have to be renamed in a radically backward-incompatible manner if terminology were changed. > - And what emacs calls a window, everyone calls a pane Uh, I believe "pane" is used by GUI programmers only. And the meaning is not exactly the same as the emacs window. Thing is, an emacs window is a true window in a windowing system implemented by emacs itself. I must say, too, that it is much more comfortable to stick to emacs windows in a single frame than working with multiple frames. > - What everyone does with C-x emacs does with C-w (and woe betide if you > mix that up) I hate typing outside emacs, where the keys mean wrong things. > - What everyone calls head (of a list) emacs calls Car (Toyota?) Now you're inventing things. > That emacs starts its tutorial showing how to use C-p and C-n for what > everyone uses arrows is bad enough. >From said tutorial: Moving from screenful to screenful is useful, but how do you move to a specific place within the text on the screen? There are several ways you can do this. You can use the arrow keys, but it's more efficient to keep your hands in the standard position and use the commands C-p, C-b, C-f, and C-n. These characters are equivalent to the four arrow keys, like this: Previous line, C-p : : Backward, C-b .... Current cursor position .... Forward, C-f : : Next line, C-n There's nothing I would change in this explanation. I do use the arrow keys occasionally, but I mostly use the C-p et al. > That the arrow-keys are later found to work quite alright is even > worse and speaks of a ridiculous attitude Please read the tutorial passage again. Marko From rosuav at gmail.com Sun Jul 26 06:03:27 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Jul 2015 20:03:27 +1000 Subject: Gmail eats Python In-Reply-To: <87lhe3xn42.fsf@elektro.pacujo.net> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> <87lhe3xn42.fsf@elektro.pacujo.net> Message-ID: On Sun, Jul 26, 2015 at 7:51 PM, Marko Rauhamaa wrote: >> - What everyone calls head (of a list) emacs calls Car (Toyota?) > > Now you're inventing things. No, but it's LISP rather than Emacs that calls it that. And it dates back to an assembly language opcode. Why that got perpetuated in a high level language, I don't know - it'd be like building a language today and using "interrupt" as the name of its call mechanism, because it's built on the Intel INT opcode. ChrisA From PointedEars at web.de Sun Jul 26 06:26:41 2015 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Sun, 26 Jul 2015 12:26:41 +0200 Subject: scalar vs array and program control References: <87vbd850qa.fsf@gmail.com> <1619647.1FW7hyz6Jq@PointedEars.de> <1757573.rN60lcJNyZ@PointedEars.de> Message-ID: <1852361.ZT26voajJO@PointedEars.de> Laura Creighton wrote: > [?] "Thomas 'PointedEars' Lahn" writes: >> Laura Creighton wrote: >>> [?] "Thomas 'PointedEars' Lahn" [writes]: >>>> Laura Creighton wrote: >>>>> [?] You really cannot make your code 'more functional' and 'more >>>>> object-oriented' at the same time -- more in one style implies less >>>>> in the other. >>>> How did you get that idea? >>> Because pure object oriented techniques are best when you have >>> a fixed set of operations on things, and as your code evolves >>> you primarily add new things. Things written in a functional style >>> work best when you have a fixed set of things, and your code evolves >>> you add new operations for the existing things. >> Your logic is flawed. ?*Pure* object oriented? is your raising the bar. > > Yes. But I could have said, and probably should have said 'pure > functional style' as well. That would not have changed anything. It is the ?pure? that makes your argument fallacious. The ?pure? falsely implies that you cannot have both at the same time, that you can have either function or object-oriented code. And ISTM that you are extending on the questionable idea that only ?pure? is ?good? to say that it would be inadvisable to have both at the same time. That is circular, for *that* property alone fallacious, logic. >>First of all, object-oriented programming and functional programming are >>programming *paradigms*, not merely techniques. Second, they are _not_ >>mutually exclusive paradigms. Third, Python supports both because in >>Python, functions are first-class objects. (In fact, if I am not >>mistaken, everything except None is an object in Python.) > > Ah, digression here. I generalise between paradigms that generate > useful techniques, (functional programming and object oriented programming > both do this) and those that do not (the Marxist paradigm of the > labour theory of value). You may not find them useful; several other people do. > It still may be very useful and instructive to think on the Marxist Labour > Theory of value, and it may have new utility if we can replace all labour > with computer/robotic/IT ... but for now, do not run your economy on this > theory, ok, because it does not work.) Trollish nonsense. Leave politics outside the door, it has nothing to do with this. > Second digression: that a thing uses objects does not make the thing > more object oriented. Yes, it does. That is the very definition of *object*-*oriented*. > But I suspect that it is only possible in things that are in > the behavioural middle. Now you are making up terminology. > You needed a lambda to make the thing more functional, I did not; it was merely a better visible shortcut, for a lambda expression is obviously a part of functional programming. I could have defined a function instead and used the function identifier, and AISB I could also have used a reference to a method of an object. The functional aspect of it was not the ?lambda? but that I passed (a reference to) a function (a lambda expression is an inline function definition). That is only possible if functions are first-class objects, meaning that they can be rvalues [sic] (?object? is not necessarily to be understood as the ?object? in OOP, but for several programming languages, including Python, the other meaning applies as well; I used the term too loosely in my previous followup). > and to create a class where none was before to make it more object- > oriented. I did not need to, but, again, it was more obvious that way. I could also have used an existing class, and its existing or newly added method. AISB, almost everything in Python is an object; therefore, almost everything in Python has a class (try ?print((42)).__class__)? in Py3k). And Python is not the only object-oriented programming language for which this is true. Other object-oriented programming languages, for example ECMAScript implementations (which are my primary research topic), still have primitive values as well, but those are implicitly converted into object values when OOP patterns are used, and then those objects inherit properties as well. > But this means that the thing wasn't all that> functional nor object- > oriented -- most likely procedural -- to start with. Obviously nonsense. The procedural programming paradigm is neither the antithesis of the functional nor of the object-oriented programming one. > So, very clever. But still the general rule in refactoring, is that > you want to go more oo or more functional, not both at the same time. Nonsense. You are projecting your misconceptions and ignorance (of Python, and programming paradigms in general) onto others. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. From marko at pacujo.net Sun Jul 26 06:31:44 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 26 Jul 2015 13:31:44 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> <87lhe3xn42.fsf@elektro.pacujo.net> Message-ID: <87h9orxl9r.fsf@elektro.pacujo.net> Chris Angelico : > On Sun, Jul 26, 2015 at 7:51 PM, Marko Rauhamaa wrote: >>> - What everyone calls head (of a list) emacs calls Car (Toyota?) >> >> Now you're inventing things. > > No, but it's LISP rather than Emacs that calls it that. You'd have to get into programming lisp before you encountered "car" in emacs. It's much easier to grasp than "class" in Python. Python still retains "lambda", BTW. And what are "strings", "floats", "braces" and "sockets"? Only "bubblegum" and "ducktape" are missing (however, "ducktype" is included). > And it dates back to an assembly language opcode. Why that got > perpetuated in a high level language, I don't know - it'd be like > building a language today and using "interrupt" as the name of its > call mechanism, because it's built on the Intel INT opcode. It is funny, that's for sure. It comes from the time when the mechanics of a computer inspired much more awe with the theorists than it does nowadays. The separation between layers of abstraction is a never-ending challenge in our profession. An anecdote: Back in the late 80's I had to deal with the GSM MAP protocol. In protocol layers, you would find MAP on top of the protocol stack as follows (go go gadget M-x picture-mode): +-------+ | MAP | application +-------+ | ASN.1 | presentation +-------+ | TCAP | transaction +-------+ | SCCP | session +-------+ | MTP3 | network +-------+ | MTP2 | link +-------+ | T1/E1 | wire +-------+ Now you express MAP data abstractly using ASN.1's abstract notation. Phone numbers are defined (somewhat less abstractly) as hexstrings. If the phone number is 1234567 you express that in MAP as '214365F7'H Huh? I wondered that aloud to Nokia Network's GSM specialist. He thought about it for a while and then said, "Well, that way the phone number bits go out on the wire in the right order." In telephony protocols, the least significant bit is transmitted first on the serial wire. So, if you want the first digit (1) to go out first, you have to place it in the lower nibble of the first octet (in the BER encoding of ASN.1). I was left speechless. Marko From PointedEars at web.de Sun Jul 26 06:35:53 2015 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Sun, 26 Jul 2015 12:35:53 +0200 Subject: scalar vs array and program control References: <87vbd850qa.fsf@gmail.com> <1619647.1FW7hyz6Jq@PointedEars.de> <1757573.rN60lcJNyZ@PointedEars.de> <1852361.ZT26voajJO@PointedEars.de> Message-ID: <2035096.cBO6vpb5vr@PointedEars.de> Thomas 'PointedEars' Lahn wrote: > Laura Creighton wrote: >> and to create a class where none was before to make it more object- >> oriented. > > I did not need to, but, again, it was more obvious that way. I could also > have used an existing class, and its existing or newly added method. > AISB, almost everything in Python is an object; therefore, almost > everything in Python has a class (try ?print((42)).__class__)? in Py3k). ^ > [?] | >>> print((42).__class__) | Most interesting (but understandable): | >>> print(42..__class__) | BTW, another common misconception that I read from your argument is that ?object-oriented? would be synonymous with ?class-based?; that one needs a class for OOP. In fact, however, there are several object-oriented programming languages, again for example most ECMAScript implementations, that are prototype-based: one object/instance inherits from another, its prototype. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. From jpiitula at ling.helsinki.fi Sun Jul 26 06:43:04 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Sun, 26 Jul 2015 13:43:04 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> Message-ID: Rustom Mody writes: > On Sunday, July 26, 2015 at 2:06:00 PM UTC+5:30, Marko Rauhamaa wrote: >> What would you like to achieve, exactly? > > Some attitude correction? With all respect, take your own advice. And use an editor that works for you. > That emacs starts its tutorial showing how to use C-p and C-n for what > everyone uses arrows is bad enough. It doesn't. Those keys come three screens down the tutorial (C-h t, line 70) and are introduced as follows: There are several ways you can do this. You can use the arrow keys, but it's more efficient to keep your hands in the standard position and use the commands C-p, C-b, C-f, and C-n. These characters are equivalent to the four arrow keys, like this: > That the arrow-keys are later found to work quite alright is even > worse and speaks of a ridiculous attitude Notice what the tutorial actually says about the arrow keys? That it actually says something about the arrow keys, and it says it before it introduces the mnemonic bindings? There was a time when the arrow keys were not found to work. Quite a while ago, but older versions of the tutorial may still be around. An Alt is still not always available as Meta: I notice it mainly works in my current setup, but Alt-C-(left arrow) is interpreted by my desktop manager. Yet M-C-b works, and M-C-(left arrow) works with Esc as Meta. It's a *system*. But, by all means, do use an editor that works for you, and a newsreader that works for you. I only mentioned Gnus because it's what I prefer to use and I've had this one issue with it that turned up in a thread about formatting code for the newsgroup. (And Emacs came up because Gnus is implemented in Emacs.) From drekin at gmail.com Sun Jul 26 06:44:26 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Sun, 26 Jul 2015 12:44:26 +0200 Subject: Capturing stdin and stdout using ctypes Message-ID: Hello, how can I capture C stdin and stdout file pointers using ctypes in Python 3? I want them to be able to call PyOS_Readline via ctypes. Thank you, Adam Barto? -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Sun Jul 26 07:25:40 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 26 Jul 2015 12:25:40 +0100 Subject: Gmail eats Python In-Reply-To: <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> Message-ID: On 26/07/2015 07:15, Rustom Mody wrote: > On Sunday, July 26, 2015 at 11:05:14 AM UTC+5:30, Chris Angelico wrote: >> On Sun, Jul 26, 2015 at 3:28 PM, Rustom Mody wrote: >>> JFTR: Ive been using emacs for 20+ years. And I have the increasing feeling >>> that my students are getting fedup with it (and me). Used Idle for my last python >>> course without too much grief. If only it were an option for 25 programming languages, and org-mode and unicode/devanagari/tex input and. >> >> Not sure whether you're making the point deliberately or accidentally, >> but that's exactly why emacs is so big and heavy: "if only, if only". >> Simpler things do less. > > Do you not use ? dozen (at least) languages? No, I use precisely one as it fits my purposes. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Sun Jul 26 07:27:55 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 26 Jul 2015 12:27:55 +0100 Subject: Gmail eats Python In-Reply-To: References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> Message-ID: On 26/07/2015 10:21, alister wrote: > > emacs is a great operating system - the only thing it lacks is a good > text editor ;-) > notepad -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From jpiitula at ling.helsinki.fi Sun Jul 26 07:30:36 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: Sun, 26 Jul 2015 14:30:36 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> <87lhe3xn42.fsf@elektro.pacujo.net> Message-ID: Chris Angelico writes: > On Sun, Jul 26, 2015 at 7:51 PM, Marko Rauhamaa wrote: >>> - What everyone calls head (of a list) emacs calls Car (Toyota?) >> >> Now you're inventing things. > > No, but it's LISP rather than Emacs that calls it that. And it dates > back to an assembly language opcode. Why that got perpetuated in a > high level language, I don't know - it'd be like building a language > today and using "interrupt" as the name of its call mechanism, because > it's built on the Intel INT opcode. It's stuck partly *because* it's meaningless. Original LISP used two-field cells (cons cells aka pairs) to build all structured data, and it wouldn't have been appropriate to tie otherwise useful names for the two fields. Should "second" mean "cdr" or should it mean "car-of-cdr"? That depends on what data structure is being implemented by the pair. There's also a tradition of having composites of car and cdr, up to four deep (down to four deep?), named like cadr (meaning car of cdr), and Lispers used to find these transparent (caar "meant" the first key in an association list and cdar was the associated value, caadr and cdadr were the second key and value ...). They've resisted the loss of this. Data structure habits are more abstract now, and some conventional uses of the concrete list structures come with aliases, notably "first" for "car", "second" for "cadr", "rest" for "cdr" in Common Lisp. I suppose early hackers were also incredibly tolerant of obscure names in general. From marko at pacujo.net Sun Jul 26 07:48:47 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 26 Jul 2015 14:48:47 +0300 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> <87lhe3xn42.fsf@elektro.pacujo.net> Message-ID: <87d1zfxhpc.fsf@elektro.pacujo.net> Jussi Piitulainen : > I suppose early hackers were also incredibly tolerant of obscure names > in general. At first, there was only the machine language. Assembly languages introduced "mnemonics" for the weaklings who couldn't remember the opcodes by heart. (Playing cards went through a somewhat similar transition when Americans added numbers for those who couldn't immediately perceive the number of dots on the card.) To this day, assembly language programmers prefer to keep the mnemonics short and leave the nonpreschoolers wondering what EIEIO could possibly stand for. Marko From bc at freeuk.com Sun Jul 26 08:49:57 2015 From: bc at freeuk.com (BartC) Date: Sun, 26 Jul 2015 13:49:57 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On 25/07/2015 12:36, tandrewjohnson at outlook.com wrote: > For intensive numerical calculations, I'd recommend using the NumPy module, as well as the 64-bit version of Python is possible. How do you actually install Numpy in Windows? I had a go a month or two ago and couldn't get anywhere. I realise that this is something that apparently no-one else on the planet has no problem with except me, but nevertheless it would be interesting to know exactly how it's done. I've just at numpy.org, they direct me to scipy.org, which talks about sources and binaries at sourceforge. The only thing on offer there is numpy-1.9.2.zip, which I duly download and install onto my machine. Now I have a directory tree with some 1200 files in it. I look at README.txt, which tells me nothing much, except how to test it after installing. So I look at INSTALL.txt instead, which is now going on about *building* Numpy; but I thought this was the binary of it! Then it goes on to suggest suitable free compilers to use. My thought at that point was, 'forget it'! I can't be the only one either. (I know from experience that building complex packages under Windows, especially those that originate under Unix or Linux, is a bloody nightmare, and hardly ever works.) Apart from which, INSTALL.txt doesn't actually say what do next. Is this DIY approach really the only way to get numpy, or is there a proper installer that takes care of all the details? And is there anything I've done wrong above? (Apart from trying to use Windows.) -- Bartc From rosuav at gmail.com Sun Jul 26 09:07:12 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Jul 2015 23:07:12 +1000 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On Sun, Jul 26, 2015 at 10:49 PM, BartC wrote: > > And is there anything I've done wrong above? (Apart from trying to use > Windows.) Not sure about done *wrong*, per se, but there's something that you didn't mention doing: search the web for "numpy windows", which brought me to this page: http://www.scipy.org/install.html The recommendation there is to grab a prepackaged Python like Anaconda. I haven't tried it myself (never needed numpy on Windows) but it does seem to be the easiest way to go about it. ChrisA From drekin at gmail.com Sun Jul 26 09:08:32 2015 From: drekin at gmail.com (=?UTF-8?B?QWRhbSBCYXJ0b8Wh?=) Date: Sun, 26 Jul 2015 15:08:32 +0200 Subject: Python Questions - July 25, 2015 Message-ID: > How do you actually install Numpy in Windows? In theory, `pip install numpy` should work, but there are currently no wheels for Windows, see https://github.com/numpy/numpy/issues/5479. Try `pip install -i https://pypi.binstar.org/carlkl/simple numpy` (see last posts in the issue). Adam Barto? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Sun Jul 26 09:16:52 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 26 Jul 2015 06:16:52 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> Message-ID: On Sunday, July 26, 2015 at 4:13:17 PM UTC+5:30, Jussi Piitulainen wrote: > Rustom Mody writes: > > On Sunday, July 26, 2015 at 2:06:00 PM UTC+5:30, Marko Rauhamaa wrote: > > >> What would you like to achieve, exactly? > > > > Some attitude correction? > > With all respect, take your own advice. And use an editor that works for > you. > > > That emacs starts its tutorial showing how to use C-p and C-n for what > > everyone uses arrows is bad enough. > > It doesn't. Those keys come three screens down the tutorial (C-h t, line > 70) and are introduced as follows: > > There are several ways you can do this. You can use the arrow keys, > but it's more efficient to keep your hands in the standard position > and use the commands C-p, C-b, C-f, and C-n. These characters are > equivalent to the four arrow keys, like this: > > > That the arrow-keys are later found to work quite alright is even > > worse and speaks of a ridiculous attitude > > Notice what the tutorial actually says about the arrow keys? That it > actually says something about the arrow keys, and it says it before it > introduces the mnemonic bindings? Ok I was wrong on that one, sorry. [Im not sure when the last time I looked and I didnt find it] Doesn't change the fact that there are dozens of obsoleteisms For the old user they are mostly irrelevant For the new they steepen the learning curve with trivia. Funny thing is I said much the same on the emacs list just a few weeks ago: http://lists.gnu.org/archive/html/help-gnu-emacs/2015-05/msg00230.html And nobody pointed out what you are Marko just did [Unless I missed somethin' there as well??] From breamoreboy at yahoo.co.uk Sun Jul 26 09:19:19 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 26 Jul 2015 14:19:19 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On 26/07/2015 13:49, BartC wrote: > On 25/07/2015 12:36, tandrewjohnson at outlook.com wrote: > >> For intensive numerical calculations, I'd recommend using the NumPy >> module, as well as the 64-bit version of Python is possible. > > How do you actually install Numpy in Windows? > http://www.lfd.uci.edu/~gohlke/pythonlibs/ You should be able to point pip there to get numpy. If you can't then download the whl file for your Python version and install from the local file name. Completely ignore the big title at the top of the site "Unofficial Windows Binaries for Python Extension Packages", I've been using stuff from there for years and never once had a problem. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From steve at pearwood.info Sun Jul 26 10:22:25 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 27 Jul 2015 00:22:25 +1000 Subject: Python Questions - July 25, 2015 References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: <55b4ed21$0$1645$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Jul 2015 10:49 pm, BartC wrote: > How do you actually install Numpy in Windows? Are you installing from source, or a pre-built binary? To install from source, you need a C or Fortran compiler, and a bunch of extra libraries (I think BLAS is one of them?). > I had a go a month or two ago and couldn't get anywhere. > > I realise that this is something that apparently no-one else on the > planet has no problem with except me, but nevertheless it would be > interesting to know exactly how it's done. No, it's not just you. > I've just at numpy.org, they direct me to scipy.org, which talks about > sources and binaries at sourceforge. Well, did you read what they said? Paragraph two: "For most users, especially on Windows and Mac, the easiest way to install the packages of the SciPy stack is to download one of these Python distributions, which includes all the key packages: ..." > The only thing on offer there is numpy-1.9.2.zip, which I duly download > and install onto my machine. The sourceforge UI is rubbish. Ignore the link to the zip file at the top of the page, and click into the version number you want. Presumably you want the latest version. Click through to here: http://sourceforge.net/projects/numpy/files/NumPy/1.9.2/ Look ma, pre-built installers for Windows! -- Steven From bc at freeuk.com Sun Jul 26 10:30:12 2015 From: bc at freeuk.com (BartC) Date: Sun, 26 Jul 2015 15:30:12 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On 26/07/2015 14:07, Chris Angelico wrote: > On Sun, Jul 26, 2015 at 10:49 PM, BartC wrote: >> >> And is there anything I've done wrong above? (Apart from trying to use >> Windows.) > > Not sure about done *wrong*, per se, but there's something that you > didn't mention doing: search the web for "numpy windows", which > brought me to this page: > > http://www.scipy.org/install.html I saw that but it was about installing the SciPy Stack, whatever that is. The only mention of numpy there is to do with linux systems, except for a link near the end which takes me to that same Sourceforge site. > The recommendation there is to grab a prepackaged Python like > Anaconda. I haven't tried it myself (never needed numpy on Windows) > but it does seem to be the easiest way to go about it. OK, I've done that now, and it works, thanks. Now 'import numpy' doesn't report an error. (But Christ, it's massive! A 0.3GB download that took ages to install, and occupied 1.3GB on disk (32000 files), about 20-40 times as big as a normal Python install. It was also Python 2.7, which I didn't notice until it was too late. Presumably I must have clicked the wrong button at some point. I dread think how big a Python 3.x version might be!) -- Bartc From larry at hastings.org Sun Jul 26 10:37:20 2015 From: larry at hastings.org (Larry Hastings) Date: Sun, 26 Jul 2015 16:37:20 +0200 Subject: [RELEASED] Python 3.5.0b4 is now available Message-ID: On behalf of the Python development community and the Python 3.5 release team, I'm delighted to announce the availability of Python 3.5.0b4. Python 3.5.0b4 is scheduled to be the last beta release; the next release will be Python 3.5.0rc1, or Release Candidate 1. Python 3.5 has now entered "feature freeze". By default new features may no longer be added to Python 3.5. This is a preview release, and its use is not recommended for production settings. An important reminder for Windows users about Python 3.5.0b4: if installing Python 3.5.0b4 as a non-privileged user, you may need to escalate to administrator privileges to install an update to your C runtime libraries. You can find Python 3.5.0b4 here: https://www.python.org/downloads/release/python-350b4/ Happy hacking, */arry* -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane at wirtel.be Sun Jul 26 10:41:09 2015 From: stephane at wirtel.be (Stephane Wirtel) Date: Sun, 26 Jul 2015 16:41:09 +0200 Subject: [Python-Dev] [RELEASED] Python 3.5.0b4 is now available In-Reply-To: References: Message-ID: \o/ > On 26 juil. 2015, at 4:37 PM, Larry Hastings wrote: > > > On behalf of the Python development community and the Python 3.5 release team, I'm delighted to announce the availability of Python 3.5.0b4. Python 3.5.0b4 is scheduled to be the last beta release; the next release will be Python 3.5.0rc1, or Release Candidate 1. > > Python 3.5 has now entered "feature freeze". By default new features may no longer be added to Python 3.5. > > This is a preview release, and its use is not recommended for production settings. > > An important reminder for Windows users about Python 3.5.0b4: if installing Python 3.5.0b4 as a non-privileged user, you may need to escalate to administrator privileges to install an update to your C runtime libraries. > > > You can find Python 3.5.0b4 here: > https://www.python.org/downloads/release/python-350b4/ > Happy hacking, > > > /arry > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/stephane%40wirtel.be -------------- next part -------------- An HTML attachment was scrubbed... URL: From bc at freeuk.com Sun Jul 26 10:58:25 2015 From: bc at freeuk.com (BartC) Date: Sun, 26 Jul 2015 15:58:25 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: <55b4ed21$0$1645$c3e8da3$5496439d@news.astraweb.com> References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <55b4ed21$0$1645$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 26/07/2015 15:22, Steven D'Aprano wrote: > On Sun, 26 Jul 2015 10:49 pm, BartC wrote: > >> How do you actually install Numpy in Windows? > > Are you installing from source, or a pre-built binary? > > To install from source, you need a C or Fortran compiler, and a bunch of > extra libraries (I think BLAS is one of them?). > > >> I had a go a month or two ago and couldn't get anywhere. >> >> I realise that this is something that apparently no-one else on the >> planet has no problem with except me, but nevertheless it would be >> interesting to know exactly how it's done. > > No, it's not just you. > >> I've just at numpy.org, they direct me to scipy.org, which talks about >> sources and binaries at sourceforge. > > Well, did you read what they said? On which site, numpy, scipy or sourceforge? I tried this: numpy.org; nothing on that page. Click 'Getting Numpy' => Obtaining Numpy & SciFi libraries. The only references to Windows takes me to the sourceforge site (ignoring the link to do with building). The sourceforge site (http://sourceforge.net/projects/numpy/files/) has nothing like that either. It just has 'Looking for the latest version? Download numpy-1.9.2.zip'. That's the obvious link. Or I can ignore that and click on the 'NumPy' link. That takes me to a long list of versions (1.9.2 to 1.0.4). Nothing that looks like your paragraph 2, or the proper installers. It's only after examining your link that I realise that each version number such as 1.9.2 actually opens up a new directory of files. And *now* I can see that some files are proper installers (which I've installed and it was a lot smaller and quicker than the Anacondo one). > Paragraph two: > > "For most users, especially on Windows and Mac, the easiest way to install > the packages of the SciPy stack is to download one of these Python > distributions, which includes all the key packages: ..." But I've still found of the above quote. You see the problem however? Loads of confusing links that all look very similar, and sometimes just go around in circles? Why can't they just have that direct link on the numpy home page? Just for Windows users as presumably everyone else has any problem. And no one wants to mess around building things from scratch. -- Bartc From invalid at invalid.invalid Sun Jul 26 11:42:59 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 26 Jul 2015 15:42:59 +0000 (UTC) Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> Message-ID: On 2015-07-26, Chris Angelico wrote: > On Sun, Jul 26, 2015 at 4:15 PM, Rustom Mody wrote: >> Well Almost. >> >> Emacs used to stand for "Eight Megabytes And Constantly Swapping" >> At a time when 8 MB was large. Is it today? >> So let me ask you: [...] >> If you have one app to do them all, I'd like (and pay!) for it >> If not I bet they are mutually inconsistent. > > For the most part, I use a single text editor. But all their > ancillary tools are separate. Emacs tries to be absolutely > everything, not just editing text files; that's why it's big. Size > isn't just a matter of disk or RAM footprint, it's also (and much > more importantly) UI complexity. > > It's a trade-off, of course. If you constantly have to switch programs > to do your work, that's a different form of UI complexity. There's always Eclipse, where you spend 30% of your time trying to get plugins to work, 30% upgrading it, 30% trying to figure out why a project somebody else created won't work for you, and 10% shopping for more RAM. -- Grant From invalid at invalid.invalid Sun Jul 26 11:47:01 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 26 Jul 2015 15:47:01 +0000 (UTC) Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> Message-ID: On 2015-07-26, Rustom Mody wrote: > JFTR: Ive been using emacs for 20+ years. And I have the increasing > feeling that my students are getting fedup with it (and me). I don't understand. Why do your students even _know_ (let alone care!) what editor you use? I admit it was years ago, but after attending three universities and getting a BS in Computer Engineering and an MS in Computer Science and Electrical Engieneering, I hadn't the foggiest idea what editors any of the faculty used. Nor would I have cared one way or the other if I had known. -- Grant From invalid at invalid.invalid Sun Jul 26 11:50:47 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 26 Jul 2015 15:50:47 +0000 (UTC) Subject: Gmail eats Python References: Message-ID: On 2015-07-26, Laura Creighton wrote: > In a message of Sun, 26 Jul 2015 00:58:08 -0000, Grant Edwards writes: > >>You use mutt or something else decent as your MUA. >> > > I do -- the problem is all the gmail users out there. So am I, and I use mutt as my MUA pretty much exclusively. [I sometimes use the web UI when I want to do fancy searches.] -- Grant From rustompmody at gmail.com Sun Jul 26 11:59:04 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 26 Jul 2015 08:59:04 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> Message-ID: <1950d85b-507c-4468-a0b9-0bbd00e69472@googlegroups.com> On Sunday, July 26, 2015 at 9:17:16 PM UTC+5:30, Grant Edwards wrote: > On 2015-07-26, Rustom Mody wrote: > > > JFTR: Ive been using emacs for 20+ years. And I have the increasing > > feeling that my students are getting fedup with it (and me). > > I don't understand. > > Why do your students even _know_ (let alone care!) what editor you > use? > > I admit it was years ago, but after attending three universities and > getting a BS in Computer Engineering and an MS in Computer Science and > Electrical Engieneering, I hadn't the foggiest idea what editors any > of the faculty used. Nor would I have cared one way or the other if I > had known. Its 2015 now and any ? decent teacher of programming, writes programs in front of the class. And debugs and hacks and pokes around OS-related stuff (ps, top and more arcane) etc. [Yeah I did hear complaints about an OS teacher who puts up PPTs and reads them out. So the set < ?-decent is not empty I guess] So while emacs makes everything else look rather puerile, setting it up is such a bitch that last python course I just switched to idle. Must admit it was more pleasant than I expected. Except that sometimes we need C and C++ and assembly and haskell and make and config files and git commits and... And so emacs (or eclipse!!) remains the only option From p_s_d_a_s_i_l_v_a_ns at netcabo.pt Sun Jul 26 13:19:18 2015 From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva) Date: Sun, 26 Jul 2015 18:19:18 +0100 Subject: Which GUI? References: <77b7b182-da35-40c4-b8f1-8a753eb7d970@googlegroups.com> Message-ID: On 26-07-2015 05:47, blue wrote: > Hi . > I tested all. Now I think the PySide can more. No python3! Besides ... any differences to pyqt4? Thanks From breamoreboy at yahoo.co.uk Sun Jul 26 13:21:19 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 26 Jul 2015 18:21:19 +0100 Subject: Gmail eats Python In-Reply-To: <1950d85b-507c-4468-a0b9-0bbd00e69472@googlegroups.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <1950d85b-507c-4468-a0b9-0bbd00e69472@googlegroups.com> Message-ID: On 26/07/2015 16:59, Rustom Mody wrote: > > So while emacs makes everything else look rather puerile, setting it up > is such a bitch that last python course I just switched to idle. > Must admit it was more pleasant than I expected. > Except that sometimes we need C and C++ and assembly and haskell and make and > config files and git commits and... > And so emacs (or eclipse!!) remains the only option > Here's what you need http://www.infoworld.com/article/2949917/application-development/visual-studio-2015-expands-language-roster-mobile-support.html Only takes around four hours 30 minutes to install and up to 8G of disk space. Ideal for most people I'd have thought :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From steve at pearwood.info Sun Jul 26 13:40:42 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 27 Jul 2015 03:40:42 +1000 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <1950d85b-507c-4468-a0b9-0bbd00e69472@googlegroups.com> Message-ID: <55b51b9a$0$1666$c3e8da3$5496439d@news.astraweb.com> On Mon, 27 Jul 2015 01:59 am, Rustom Mody wrote: > Its 2015 now and any ? decent teacher of programming, writes programs in > front of the class. Yeah, but the fully decent teachers prepare before hand, so the students don't have to wait while they type out the (buggy) program in front of them. *half a smiley* > And debugs and hacks and pokes around OS-related stuff > (ps, top and more arcane) etc. And you do that in Emacs instead of the shell? Or IPython? > [Yeah I did hear complaints about an OS teacher who puts up PPTs and reads > [them out. So the set < ?-decent is not empty I guess] Did the students really complain "Teacher X came to class prepared with code already written"? Or was the complaint about the technology used? Or something else? I really don't know how I feel about this. I did maths and physics at uni, and it seems natural for the lecturer to work through the mathematics in front of you. I also did computer science, and it feels completely natural for the lecturer to hand out notes with the code already written. (These days, I suppose, you would use slides, or give them a URL and tell them to download the code.) Except for the most trivial interactive examples in the Python REPR, I can't imagine why anyone would want to watch the lecturer type the code out in front of them. I can think of one exception... watching somebody go through the iterative process of debugging code. > So while emacs makes everything else look rather puerile, setting it up > is such a bitch that last python course I just switched to idle. > Must admit it was more pleasant than I expected. > Except that sometimes we need C and C++ and assembly and haskell and make > and config files and git commits and... > And so emacs (or eclipse!!) remains the only option Um... your students are probably using Macs, Windows, and a small minority with Linux, yes? On laptops? Your Linux students are probably fine. Some of them probably know more than you :-) Mac users have access to a full BSB environment, even if most of them don't know it. Your Windows users are the problem. You could try GnuWin and Gnu Core Utilities for a set of GNU tools for Windows. You could build a bootable USB stick containing the Linux installation of your choice, and get them to use that. (Of course, I can imagine your school/university having a conniption fit at the thought of the liability issues if the software erased somebody's hard drive...) Things were much better in my day. Nobody expected the students to have access to a computer at home. You used a dumb workstation to log into a VAX running Unix, and used the tools the uni supplied, or a standalone Mac 512K (if you were lucky) or Mac 128K (if you weren't), and again, you used the tools they supplied. -- Steven From edgrsprj at ix.netcom.com Sun Jul 26 13:49:57 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sun, 26 Jul 2015 12:49:57 -0500 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: <5ZOdnRjTI6RfgCjInZ2dnUU7-RednZ2d@earthlink.com> "Laura Creighton" wrote in message news:mailman.980.1437832769.3674.python-list at python.org... > The most common way to do things is to tell your users to install > whatever python distribution you pick and then optionally > install these extra packages (if you need any) and then give them a python > program to run. > But you can also package everything up into a .exe for them if they > need this. Posted by E.D.G. July 26, 2015 For general interest purposes, as you can see, with my posts I usually include E.D.G. and the date of the posting. This is because the projects that I work on involve scientific research. And this way printed versions of the posts can be made. And they will include references that people can use. The printed versions would not have the types of information that are included with the electronic newsgroup distributions. What I was asking about in that earlier post is something that very few programmers or perhaps even no programmers are familiar with. Most people know what the .exe versions of programs are. But what I was asking about is more basic. It can take a considerable amount of time and effort to get a programming language installed and running with all of the features that are needed. It probably took me 5 to 10 years to get Perl organized on my computer like that. Once that process is done, people who are not professional programmers don't want to have to constantly update and change the basic language they have running on their computers. So, they might do what I do though I have never heard of anyone else doing that. My entire Perl language is in a directory called "Perl" on my computer. I use ActiveState 5.10 Perl which is a very old version. But it does everything that needs to be done except graphics and fast calculations. For the graphics I use a Perl to Gnuplot "Pipe" that works quite well and which took a long time for me to develop. A very old version of Gnuplot is also used for simplicity. I consists of just 2 small .exe files. Then if I want to run a .pl program on any computer or even from a flash drive I simply copy the entire 5.10 Perl directory to the new computer or flash drive. And any Perl program will then run on the new computer or from the flash drive. Windows let you specify that a .pl program should always be opened with perl.exe. The same is probably true with Python. So, Perl itself does not actually need to be installed on a computer to get .pl programs to run. However, it is probably a good idea to do that so that the perl.exe address is in the right Windows Environment variables. So, that is what I was asking about Python. Once it is installed and running properly, can people simply copy the entire Python directory to some other computer or flash drive and a Python language program will then run? If necessary, to get Perl programs to run faster we were planning to use a Perl to Fortran "Pipe" plus file storage of bulk data. Fortran would then process the files and tell the Perl program when it was done. But before doing that we decided to see if we could find another language that would do everything that my version of Perl does plus graphics and fast calculations. It appears that Python will do that. But it also appears that it would take quite a while to select a specific version of Python and then learn how to get everything organized and running. Another of my posts will probably go into more detail regarding that subject. Thanks for the comments. Regards, E.D.G. From spluque at gmail.com Sun Jul 26 14:15:03 2015 From: spluque at gmail.com (Sebastian P. Luque) Date: Sun, 26 Jul 2015 13:15:03 -0500 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> Message-ID: <87lhe2ss48.fsf@gmail.com> On Sat, 25 Jul 2015 18:34:30 +0200, Laura Creighton wrote: > Gmail eats Python. We just saw this mail back from Sebastian Luque > which says in part: >>>> try: all_your_code_which_is_happy_with_non_scalars except >>>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: >>>> whatever_you_want_to_do_when_this_happens > Ow! Gmail is understanding the >>> I stuck in as 'this is from the > python console as a quoting marker and thinks it can reflow that. > I think that splunqe must already have gmail set for plain text or > else even worse mangling must show up. > How do you teach gmail not to reflow what it thinks of as 'other > people's quoted text'? Apologies for all the concern the formatting of the quoted message in my reply has generated. I actually cannot see the multiple ">" you quote here on my original follow-up message. I can tell you I'm using Emacs Gnus, and when viewing my un-processed message, that snippet looks like this: >> try: all_your_code_which_is_happy_with_non_scalars except >> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: >> whatever_you_want_to_do_when_this_happens Sure, the reflowing is probably a feature I've set up to wrap long lines. I know it annoys some people (mildly myself, as I haven't found a fix), but when reading coding fora, I never really take quoted code snippets seriously and always check the original post for these... -- Seb From lac at openend.se Sun Jul 26 14:38:10 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 26 Jul 2015 20:38:10 +0200 Subject: Python Questions - July 25, 2015 In-Reply-To: Message from "E.D.G." of "Sun, 26 Jul 2015 12:49:57 -0500." <5ZOdnRjTI6RfgCjInZ2dnUU7-RednZ2d@earthlink.com> References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <5ZOdnRjTI6RfgCjInZ2dnUU7-RednZ2d@earthlink.com> Message-ID: <201507261838.t6QIcAQ7030835@fido.openend.se> > It can take a considerable amount of time and effort to get a >programming language installed and running with all of the features that are >needed. It probably took me 5 to 10 years to get Perl organized on my >computer like that. > So, that is what I was asking about Python. Once it is installed and >running properly, can people simply copy the entire Python directory to some >other computer or flash drive and a Python language program will then run? Yes. That is actually the usual way to do things for quite a few years now. What you are talking about is what we call a Python virtual environment. see: http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ http://simononsoftware.com/virtualenv-tutorial-part-2/ for an introduction to them. It is common to have many of them for different purposes. The bottom line is that it lets you utterly ignore (at least from the python point of view) any system packages you have on your machine. Instead, in a directory, you end up with exactly the tools, modules, etc that you want for this project. Works fine on a memory stick, too. You don't have to worry about conflicts because you are, in effect, doing a clean build from scratch for every project you have -- or indeed I usually have many of them even with a single project so I can test that my code works with different combinations of different versions of other software. Laura From edgrsprj at ix.netcom.com Sun Jul 26 14:48:32 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sun, 26 Jul 2015 13:48:32 -0500 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <5ZOdnRjTI6RfgCjInZ2dnUU7-RednZ2d@earthlink.com> Message-ID: "Laura Creighton" wrote in message news:mailman.1018.1437935917.3674.python-list at python.org... > Yes. That is actually the usual way to do things for quite a few years > now. > What you are talking about is what we call a Python virtual environment. > see: http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ > http://simononsoftware.com/virtualenv-tutorial-part-2/ > for an introduction to them. Posted by E.D.G. July 26, 2015 Great! That is exactly what I needed to know. And in response to my original post I am going to post another note about this general programming effort. Regards, E.D.G. From edgrsprj at ix.netcom.com Sun Jul 26 15:17:59 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sun, 26 Jul 2015 14:17:59 -0500 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: "E.D.G." wrote in message news:jf6dnQiMOZ_GxC7InZ2dnUU7-S2dnZ2d at earthlink.com... Posted by E.D.G. July 26, 2015 These are some additional comments related to my original post. The effort I have been discussing actually involves developing a totally free version of some language that scientists around the world could easily install and use. 1. With my own science related Perl programs I provide people with .exe versions in addition to the .pl versions. And for the .pl versions, at one of my Web sites there is actually an entire Perl programming language directory available in a .zip package. So, people can download the file, unzip it, and then save it as the Perl directory and .pl programs will then run on that computer. We would like to be able to do the same thing with Python if we start working with that language. And a response in another post indicates that this should be possible. 2. Python looks especially attractive because so many people are using it. And I myself have a friend who is a very experienced professional Python programmer. On the other hand, there are so many versions of Python that it might be difficult at first to determine which one to start with. 3. I asked that Python programmer if Python could run on an Internet server as a CGI program. And the answer was "I have no idea." So, amusingly, apparently even experienced professional programmers don't know everything there is to know about a given programming language! 4. I myself know that Perl programs will run on Internet servers as CGI programs and have written several myself using a development program called Xampp to create and test them before installing them on the server computer. 5. My retired professional programming colleague has now told me that he downloaded and installed the ActiveState Windows version of Python with no difficulties. So, that is encouraging news. 6. He said that he is looking around for a good IDE for Python and found one called "Eric" that he is checking. 7. With my Perl language programs I have developed a resource that will do the following. And I imagine that this could also be done with Python. This resource can't be developed with many and probably most programming languages. In part because of limited calculation speeds it can take one of my important probability calculation Perl programs as much a two hours to run and create all of the necessary data arrays. Many, many millions of calculations are involved. And once everything is set, for time limitation reasons it would be ordinarily be impossible to make any changes to the data or to the original program code without losing all of the data. So, I have developed a special Perl program that makes that possible. And as I said, I am guessing that this approach would also work with Python. When the Perl program is done with its calculations, instead of ending it jumps to another Perl program. But all of the data in the arrays it created remain active in memory. The original program code can then be changed. The second Perl program is then told that the changes are complete and that it should return to the first program. Perl then attempt to recompile the original code. If it is successful it then uses the new code and does whatever is specified. The previously created arrays are still active in memory using the same array names etc. If there was an error in the new code, a Windows screen appears explaining that there was an error and the compilation ends. But, the data remain in the active computer memory. Changes can then be are made to the program code to fix the error. And, the second Perl program is told to try again. If there are no new errors the first program recompiles and runs using the already created arrays etc. This is a very useful resource for scientists as it lets them create and test new program code without having to recreate all of the data arrays. And as I stated, it would probably not be possible to develop such a resource with most programming languages. Regards, E.D.G. From invalid at invalid.invalid Sun Jul 26 15:45:15 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 26 Jul 2015 19:45:15 +0000 (UTC) Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <1950d85b-507c-4468-a0b9-0bbd00e69472@googlegroups.com> Message-ID: On 2015-07-26, Rustom Mody wrote: > On Sunday, July 26, 2015 at 9:17:16 PM UTC+5:30, Grant Edwards wrote: >> On 2015-07-26, Rustom Mody wrote: >> >>> JFTR: Ive been using emacs for 20+ years. And I have the increasing >>> feeling that my students are getting fedup with it (and me). [...] >> Why do your students even _know_ (let alone care!) what editor you >> use? >> >> I admit it was years ago, but after attending three universities and >> getting a BS in Computer Engineering and an MS in Computer Science and >> Electrical Engieneering, I hadn't the foggiest idea what editors any >> of the faculty used. Nor would I have cared one way or the other if I >> had known. > > Its 2015 now and any ? decent teacher of programming, writes programs > in front of the class. And debugs and hacks and pokes around > OS-related stuff (ps, top and more arcane) etc. I still don't get it. You're not teaching the _editor_, so why would it matter to anybody which editor you're using to show them the code? They can see the code, and they can see what it does. Are they too stupid to figure out how to insert or delete a line using whatever editor they prefer? I remember being shown live examples in a numerical programming class, and not only was the _editor_ one I had never touched (or would), the language and OS were ones I had never used and never would. It didn't detract from what was actually being _taught_ -- which was not "how to edit and run programs on an Apple-something-or-other". The live examples we were shown for APL not only used a differnt editor, OS, and virtual machine that we used, it didn't even use the same character set! I guess I have unealisitically high expections of modern students. ... and back then all we had were zeros! -- Grant From m at funkyhat.org Sun Jul 26 16:04:25 2015 From: m at funkyhat.org (Matt Wheeler) Date: Sun, 26 Jul 2015 20:04:25 +0000 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: I'll just answer the one part I don't feel has had enough attention yet, all other parts chopped... On Sat, 25 Jul 2015 10:39 E.D.G. wrote: Posted by E.D.G. July 25, 2015 6. What is Python's version of the DOS level "System" command that many programs use as in: system "open notepad.exe" You can use the subprocess module from the standard library for this but... 7. What is Python's version of the SendKey command that many programs use to send information to an active Windows program as in: SendKey("Message to be printed on the Notepad screen") or SendKey(Right Arrow Key) pywinauto would be my recommendation here. It can be used to automate sending of keys and button presses, filling in text fields etc., all within the context of a "connected" application... 8. What commands does Python use to send to, and retrieve information from, the Windows clipboard? ...And it has an interface for manipulating the clipboard, pywinauto.clipboard Behind the scenes it makes heavy use of the PyWin32 library, and it hides a lot of the complexity you would have to deal with quite nicely. http://pywinauto.github.io/ has examples and docs. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Sun Jul 26 17:11:57 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 26 Jul 2015 13:11:57 -0800 Subject: Gmail eats Python In-Reply-To: <20150726082056.GA21788@cskk.homeip.net> References: <20150726082056.GA21788@cskk.homeip.net> Message-ID: On Sun, Jul 26, 2015 at 12:20 AM, Cameron Simpson wrote: > On 25Jul2015 22:43, Ian Kelly wrote: >> >> On Jul 25, 2015 4:51 PM, "Ben Finney" wrote: >>> >>> Laura Creighton writes: >>> > So it was my fault by sending him a reply with >>> to the far left. >>> >>> No, it was Google Mail's failt for messing with the content of the >>> message. > > > Specificly, by manking the text without leave(*). > >> What Internet standard is being violated by reflowing text content in >> the message body? > > > RFC3676: http://tools.ietf.org/rfcmarkup?doc=3676 > See also: http://joeclark.org/ffaq.html Thanks for the link. However, this only describes how reflowing is permitted on Format=Flowed messages. Both the message in question and the message it replied to omitted the Format parameter, which per the linked RFC makes them Format=Fixed by default. I can't find any standard discussing how Format=Fixed messages may or may not be reflowed when quoted. The > character that is commonly used as a prefix by virtually all (?) MUAs is also a form of mangling. As far as I know, it is not an Internet standard, just common convention (RFC 3676 specifies it, but again only for Format=Flowed plain text). Is there some standard I'm not aware of that permits quoting but forbids reflowing? Note that RFC 5322 recommends a line length limit of 78 characters and requires a limit of 998 characters, so in a sufficiently long exchange, reflowing would eventually become necessary. From none at mailinator.com Sun Jul 26 17:15:19 2015 From: none at mailinator.com (mm0fmf) Date: Sun, 26 Jul 2015 22:15:19 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: On 26/07/2015 20:17, E.D.G. wrote: > "E.D.G." wrote in message > news:jf6dnQiMOZ_GxC7InZ2dnUU7-S2dnZ2d at earthlink.com... > > Posted by E.D.G. July 26, 2015 > > These are some additional comments related to my original post. > > The effort I have been discussing actually involves developing a > totally free version of some language that scientists around the world > could easily install and use. > > > 1. With my own science related Perl programs I provide people with .exe > versions in addition to the .pl versions. And for the .pl versions, at > one of my Web sites there is actually an entire Perl programming > language directory available in a .zip package. So, people can download > the file, unzip it, and then save it as the Perl directory and .pl > programs will then run on that computer. We would like to be able to do > the same thing with Python if we start working with that language. And > a response in another post indicates that this should be possible. > > 2. Python looks especially attractive because so many people are using > it. And I myself have a friend who is a very experienced professional > Python programmer. On the other hand, there are so many versions of > Python that it might be difficult at first to determine which one to > start with. > > 3. I asked that Python programmer if Python could run on an Internet > server as a CGI program. And the answer was "I have no idea." So, > amusingly, apparently even experienced professional programmers don't > know everything there is to know about a given programming language! > > 4. I myself know that Perl programs will run on Internet servers as CGI > programs and have written several myself using a development program > called Xampp to create and test them before installing them on the > server computer. > > 5. My retired professional programming colleague has now told me that > he downloaded and installed the ActiveState Windows version of Python > with no difficulties. So, that is encouraging news. > > 6. He said that he is looking around for a good IDE for Python and > found one called "Eric" that he is checking. > > 7. With my Perl language programs I have developed a resource that will > do the following. And I imagine that this could also be done with > Python. This resource can't be developed with many and probably most > programming languages. > > In part because of limited calculation speeds it can take one of > my important probability calculation Perl programs as much a two hours > to run and create all of the necessary data arrays. Many, many millions > of calculations are involved. And once everything is set, for time > limitation reasons it would be ordinarily be impossible to make any > changes to the data or to the original program code without losing all > of the data. > > So, I have developed a special Perl program that makes that > possible. And as I said, I am guessing that this approach would also > work with Python. > > When the Perl program is done with its calculations, instead of > ending it jumps to another Perl program. But all of the data in the > arrays it created remain active in memory. The original program code > can then be changed. The second Perl program is then told that the > changes are complete and that it should return to the first program. > Perl then attempt to recompile the original code. If it is successful > it then uses the new code and does whatever is specified. The > previously created arrays are still active in memory using the same > array names etc. > > If there was an error in the new code, a Windows screen appears > explaining that there was an error and the compilation ends. But, the > data remain in the active computer memory. > > Changes can then be are made to the program code to fix the > error. And, the second Perl program is told to try again. If there are > no new errors the first program recompiles and runs using the already > created arrays etc. > > This is a very useful resource for scientists as it lets them > create and test new program code without having to recreate all of the > data arrays. And as I stated, it would probably not be possible to > develop such a resource with most programming languages. > > Regards, > > E.D.G. > Am I the only person thinking Troll? From rustompmody at gmail.com Sun Jul 26 17:34:46 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 26 Jul 2015 14:34:46 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: <55b51b9a$0$1666$c3e8da3$5496439d@news.astraweb.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <1950d85b-507c-4468-a0b9-0bbd00e69472@googlegroups.com> <55b51b9a$0$1666$c3e8da3$5496439d@news.astraweb.com> Message-ID: <70dc258b-43be-4a2d-879a-ceb4fc496ccb@googlegroups.com> On Sunday, July 26, 2015 at 11:11:04 PM UTC+5:30, Steven D'Aprano wrote: > On Mon, 27 Jul 2015 01:59 am, Rustom Mody wrote: > > > Its 2015 now and any ? decent teacher of programming, writes programs in > > front of the class. > > Yeah, but the fully decent teachers prepare before hand, so the students > don't have to wait while they type out the (buggy) program in front of > them. > > *half a smiley* > > > > And debugs and hacks and pokes around OS-related stuff > > (ps, top and more arcane) etc. > > And you do that in Emacs instead of the shell? > > Or IPython? > > > > [Yeah I did hear complaints about an OS teacher who puts up PPTs and reads > > [them out. So the set < ?-decent is not empty I guess] > > Did the students really complain "Teacher X came to class prepared with code > already written"? Or was the complaint about the technology used? Or > something else? > > I really don't know how I feel about this. I did maths and physics at uni, > and it seems natural for the lecturer to work through the mathematics in > front of you. I also did computer science, and it feels completely natural > for the lecturer to hand out notes with the code already written. (These > days, I suppose, you would use slides, or give them a URL and tell them to > download the code.) Except for the most trivial interactive examples in the > Python REPR, I can't imagine why anyone would want to watch the lecturer > type the code out in front of them. > > I can think of one exception... watching somebody go through the iterative > process of debugging code. > > > > So while emacs makes everything else look rather puerile, setting it up > > is such a bitch that last python course I just switched to idle. > > Must admit it was more pleasant than I expected. > > Except that sometimes we need C and C++ and assembly and haskell and make > > and config files and git commits and... > > And so emacs (or eclipse!!) remains the only option > > Um... your students are probably using Macs, Windows, and a small minority > with Linux, yes? On laptops? > > Your Linux students are probably fine. Some of them probably know more than > you :-) > > Mac users have access to a full BSB environment, even if most of them don't > know it. > > Your Windows users are the problem. Pretty much. ? Linux ? Windows, 1 mac Tried to get everyone onto linux. Most did. Some failed to install it. [I actually called these stragglers for one special ubuntu-setup session. Didn't happen for some silly reasons] So I couldn't dictate linux, just 'suggest' it :-) Policy-wise: College provides machines (supposedly) setup Practically: If one relies on that, the hours the students spend with these will end up being ? what they would spend on their own laptops > You could try GnuWin and Gnu Core > Utilities for a set of GNU tools for Windows. You could build a bootable > USB stick containing the Linux installation of your choice, and get them to > use that. (Of course, I can imagine your school/university having a > conniption fit at the thought of the liability issues if the software > erased somebody's hard drive...) > > Things were much better in my day. Nobody expected the students to have > access to a computer at home. You used a dumb workstation to log into a VAX > running Unix, and used the tools the uni supplied, or a standalone Mac 512K > (if you were lucky) or Mac 128K (if you weren't), and again, you used the > tools they supplied. > > > > -- > Steven From spluque at gmail.com Sun Jul 26 17:36:58 2015 From: spluque at gmail.com (Seb) Date: Sun, 26 Jul 2015 16:36:58 -0500 Subject: Gmail eats Python References: <201507251634.t6PGYUvo028820@fido.openend.se> <87lhe2ss48.fsf@gmail.com> Message-ID: <87fv4asirp.fsf@gmail.com> And for those interested in how I received Laura's message (the one I replied to): ---<--------------------cut here---------------start------------------->--- Path: news.gmane.org!not-for-mail From: Laura Creighton Newsgroups: gmane.comp.python.general Subject: Re: scalar vs array and program control Date: Sat, 25 Jul 2015 14:44:43 +0200 Lines: 44 Approved: news at gmane.org Message-ID: <201507251244.t6PCihmd023479 at fido.openend.se> References: <87vbd850qa.fsf at gmail.com><201507251101.t6PB1LqE021165 at fido.openend.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1437828370 13839 80.91.229.3 (25 Jul 2015 12:46:10 GMT) X-Complaints-To: usenet at ger.gmane.org NNTP-Posting-Date: Sat, 25 Jul 2015 12:46:10 +0000 (UTC) Cc: Seb To: python-list at python.org Original-X-From: python-list-bounces+python-python-list=m.gmane.org at python.org Sat Jul 25 14:46:03 2015 Return-path: Envelope-to: python-python-list at m.gmane.org Original-Received: from mail.python.org ([82.94.164.166]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZIyq2-0002GT-Ta for python-python-list at m.gmane.org; Sat, 25 Jul 2015 14:46:03 +0200 Original-Received: from albatross.python.org (localhost [127.0.0.1]) by mail.python.org (Postfix) with ESMTP id 3mdnFQ2j3LzPgt for ; Sat, 25 Jul 2015 14:46:02 +0200 (CEST) X-Original-To: python-list at python.org Delivered-To: python-list at mail.python.org Original-Received: from albatross.python.org (localhost [127.0.0.1]) by mail.python.org (Postfix) with ESMTP id 3mdnD81R8jzPZj for ; Sat, 25 Jul 2015 14:44:56 +0200 (CEST) X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'revision': 0.05; 'chunk': 0.07; 'exception.': 0.07; 'smallest': 0.07; 'thats': 0.07; 'valueerror:': 0.07; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'skip:t 60': 0.09; 'ignore': 0.14; 'things.': 0.15; '>try:': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'happily': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:89.233': 0.16; 'received:89.233.217': 0.16; 'received:89.233.217.133': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'subject:array': 0.16; 'subject:program': 0.16; 'try/except': 0.16; 'laura': 0.18; 'stick': 0.18; 'try:': 0.18; 'cc:2**0': 0.20; 'posted': 0.21; 'work,': 0.21; 'pass': 0.22; 'errors': 0.23; 'forgot': 0.23; 'this:': 0.23; 'cc:addr:gmail.com': 0.24; 'written': 0.24; 'header :In-Reply-To:1': 0.24; 'skip:m 30': 0.27; 'e Original-Received: from localhost (HELO mail.python.org) (127.0.0.1) by albatross.python.org with SMTP; 25 Jul 2015 14:44:56 +0200 Original-Received: from theraft.openend.se (theraft.ipv6.openend.se [IPv6:2001:16d8:ffca::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.python.org (Postfix) with ESMTPS for ; Sat, 25 Jul 2015 14:44:55 +0200 (CEST) Original-Received: from fido.openend.se (root at fido.openend.se [89.233.217.133]) by theraft.openend.se (8.14.4/8.14.4/Debian-4) with ESMTP id t6PCihR6024800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 25 Jul 2015 14:44:45 +0200 Original-Received: from fido (lac at localhost [127.0.0.1]) by fido.openend.se (8.14.9/8.14.9/Debian-1) with ESMTP id t6PCihmd023479; Sat, 25 Jul 2015 14:44:43 +0200 In-Reply-To: Message from Laura Creighton of "Sat, 25 Jul 2015 13:01:21 +0200." <201507251101.t6PB1LqE021165 at fido.openend.se> Content-ID: <23477.1437828283.1 at fido> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [89.233.217.130]); Sat, 25 Jul 2015 14:44:45 +0200 (CEST) X-BeenThere: python-list at python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: python-list-bounces+python-python-list=m.gmane.org at python.org Original-Sender: "Python-list" Xref: news.gmane.org gmane.comp.python.general:780612 Archived-At: And because I was rushed and posted without revision I left out something important. >So this is, quite likely, the pattern that you are looking for: > >try: > all_your_code_which_is_happy_with_non_scalars >except WhateverErrorPythonGivesYouWhenYouTryThisWithScalars: > whatever_you_want_to_do_when_this_happens > >This is the usual way to do things. I forgot to tell you that you are supposed to stick the try/except around the smallest chunk of code that you expect to get the exception. So you write this as code_you_expect_always_to_work more_code_you_expect_always_to_work try: these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar except ValueError: # whatever kind of error the real error is whatever_you_want_to_do_when_that_happens The reason is that if you get any Value Errors in the part of the code you always expect to work, then you don't want your program to run happily along running the code for 'its a scalar'. You don't want to hide real errors here. The other thing I forgot to mention is that sometimes you don't want to do anything but ignore any errors of this sort. Thats written like this: code_you_expect_always_to_work more_code_you_expect_always_to_work try: these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar except ValueError: pass # just ignore it Laura ---<--------------------cut here---------------end--------------------->--- Cheers, -- Seb From rustompmody at gmail.com Sun Jul 26 17:54:27 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 26 Jul 2015 14:54:27 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <1950d85b-507c-4468-a0b9-0bbd00e69472@googlegroups.com> Message-ID: On Monday, July 27, 2015 at 1:15:29 AM UTC+5:30, Grant Edwards wrote: > On 2015-07-26, Rustom Mody wrote: > > On Sunday, July 26, 2015 at 9:17:16 PM UTC+5:30, Grant Edwards wrote: > >> On 2015-07-26, Rustom Mody wrote: > >> > >>> JFTR: Ive been using emacs for 20+ years. And I have the increasing > >>> feeling that my students are getting fedup with it (and me). > > [...] > >> Why do your students even _know_ (let alone care!) what editor you > >> use? > >> > >> I admit it was years ago, but after attending three universities and > >> getting a BS in Computer Engineering and an MS in Computer Science and > >> Electrical Engieneering, I hadn't the foggiest idea what editors any > >> of the faculty used. Nor would I have cared one way or the other if I > >> had known. > > > > Its 2015 now and any ? decent teacher of programming, writes programs > > in front of the class. And debugs and hacks and pokes around > > OS-related stuff (ps, top and more arcane) etc. > > I still don't get it. > > You're not teaching the _editor_, so why would it matter to anybody > which editor you're using to show them the code? They can see the > code, and they can see what it does. Are they too stupid to figure > out how to insert or delete a line using whatever editor they prefer? > > I remember being shown live examples in a numerical programming class, > and not only was the _editor_ one I had never touched (or would), the > language and OS were ones I had never used and never would. It didn't > detract from what was actually being _taught_ -- which was not "how to > edit and run programs on an Apple-something-or-other". > > The live examples we were shown for APL not only used a differnt > editor, OS, and virtual machine that we used, it didn't even use the > same character set! > > I guess I have unealisitically high expections of modern students. > > ... and back then all we had were zeros! Was setting up machines for use a job you did in your days? I know we didn't set up any -- there were no machines to set up other than the privately unaffordable public resources. Today a machine is about as personal and private as a toothbrush. DevOps is a fashionable term these days. We used to call it system-administration. As expected CS education is about 10 years behind the curve in seeing its importance From edgrsprj at ix.netcom.com Sun Jul 26 18:08:03 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sun, 26 Jul 2015 17:08:03 -0500 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: "mm0fmf" wrote in message news:J5ctx.20800$IK6.11473 at fx46.am4... > Am I the only person thinking Troll? Posted by E.D.G. July 26, 2015 In my opinion, one of the most important aspects in considering the selection of a new programming language is the willingness of people posting notes to the language's newsgroup to be friendly and cooperative. And in that regard, I have found the Fortran people to be the best. I never encountered an unfriendly note in that newsgroup. Unfortunately, Fortran just "ran out of steam" when it came to Windows applications. As far as I can recall, yours is only the second time I have encountered a Python newsgroup note that, in my opinion, did not have a friendly tone to it. And if that appears to be the general case here then all of the people with whom I work will just dump Python as a language to consider. The Perl newsgroup is yet another matter. And we have all largely decided to abandon Perl as the language of choice because it has seemed to be so difficult to get any help in that newsgroup. Regards, E.D.G. From edgrsprj at ix.netcom.com Sun Jul 26 18:32:02 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sun, 26 Jul 2015 17:32:02 -0500 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: "E.D.G." wrote in message news:Q5SdnTejbKKjxyjInZ2dnUU7-TednZ2d at earthlink.com... Posted by E.D.G. July 26, 2015 There is an additional comment for people who are interested in scientific programming efforts. Most people are aware that when the U.S. Government tried to get a Web site running in connection with the Affordable Care Act a while ago, the government Web site crashed. One of the major problems with government programming efforts appears to me to be the fact that people working in different government agencies are often using different programming languages. And those people don't communicate with one another. The results are inefficiency. To demonstrate that the programming effort I am discussing is quite serious I am providing the following indirect link. This is for a proposed effort to get as many government scientists etc. as possible connected with one another and moving in the same direction at the same time. http://www.freewebs.com/eq-forecasting/DSAT.html If that type of program does eventually get created then the government scientists are still going to want some computer language that they can all work with. And an important question at this time is, "Might one of the languages of choice be Python?" Regards, E.D.G. From ned at nedbatchelder.com Sun Jul 26 19:12:05 2015 From: ned at nedbatchelder.com (Ned Batchelder) Date: Sun, 26 Jul 2015 16:12:05 -0700 (PDT) Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: On Sunday, July 26, 2015 at 5:15:31 PM UTC-4, mm0fmf wrote: > On 26/07/2015 20:17, E.D.G. wrote: > > "E.D.G." wrote in message > > news:jf6dnQiMOZ_GxC7InZ2dnUU7-S2dnZ2d at earthlink.com... > > > > Posted by E.D.G. July 26, 2015 > > > > These are some additional comments related to my original post. > > > > The effort I have been discussing actually involves developing a > > totally free version of some language that scientists around the world > > could easily install and use. > > > > > > 1. With my own science related Perl programs I provide people with .exe > > versions in addition to the .pl versions. And for the .pl versions, at > > one of my Web sites there is actually an entire Perl programming > > language directory available in a .zip package. So, people can download > > the file, unzip it, and then save it as the Perl directory and .pl > > programs will then run on that computer. We would like to be able to do > > the same thing with Python if we start working with that language. And > > a response in another post indicates that this should be possible. > > > > 2. Python looks especially attractive because so many people are using > > it. And I myself have a friend who is a very experienced professional > > Python programmer. On the other hand, there are so many versions of > > Python that it might be difficult at first to determine which one to > > start with. > > > > 3. I asked that Python programmer if Python could run on an Internet > > server as a CGI program. And the answer was "I have no idea." So, > > amusingly, apparently even experienced professional programmers don't > > know everything there is to know about a given programming language! > > > > 4. I myself know that Perl programs will run on Internet servers as CGI > > programs and have written several myself using a development program > > called Xampp to create and test them before installing them on the > > server computer. > > > > 5. My retired professional programming colleague has now told me that > > he downloaded and installed the ActiveState Windows version of Python > > with no difficulties. So, that is encouraging news. > > > > 6. He said that he is looking around for a good IDE for Python and > > found one called "Eric" that he is checking. > > > > 7. With my Perl language programs I have developed a resource that will > > do the following. And I imagine that this could also be done with > > Python. This resource can't be developed with many and probably most > > programming languages. > > > > In part because of limited calculation speeds it can take one of > > my important probability calculation Perl programs as much a two hours > > to run and create all of the necessary data arrays. Many, many millions > > of calculations are involved. And once everything is set, for time > > limitation reasons it would be ordinarily be impossible to make any > > changes to the data or to the original program code without losing all > > of the data. > > > > So, I have developed a special Perl program that makes that > > possible. And as I said, I am guessing that this approach would also > > work with Python. > > > > When the Perl program is done with its calculations, instead of > > ending it jumps to another Perl program. But all of the data in the > > arrays it created remain active in memory. The original program code > > can then be changed. The second Perl program is then told that the > > changes are complete and that it should return to the first program. > > Perl then attempt to recompile the original code. If it is successful > > it then uses the new code and does whatever is specified. The > > previously created arrays are still active in memory using the same > > array names etc. > > > > If there was an error in the new code, a Windows screen appears > > explaining that there was an error and the compilation ends. But, the > > data remain in the active computer memory. > > > > Changes can then be are made to the program code to fix the > > error. And, the second Perl program is told to try again. If there are > > no new errors the first program recompiles and runs using the already > > created arrays etc. > > > > This is a very useful resource for scientists as it lets them > > create and test new program code without having to recreate all of the > > data arrays. And as I stated, it would probably not be possible to > > develop such a resource with most programming languages. > > > > Regards, > > > > E.D.G. > > > > Am I the only person thinking Troll? Yes. --Ned. From rantingrickjohnson at gmail.com Sun Jul 26 19:22:03 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 26 Jul 2015 16:22:03 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: References: Message-ID: <1c992112-e55b-421f-afc1-14d47c7d7495@googlegroups.com> On Saturday, July 25, 2015 at 11:35:02 AM UTC-5, Laura Creighton wrote: > How do you teach gmail not to reflow what it thinks of as > 'other people's quoted text'? My simple solution is to bulk replace ">>> " with "py> ". Also has the benefit of differentiating between languages when a proper "tag" is used. py> # Python code rb> # Ruby code From edgrsprj at ix.netcom.com Sun Jul 26 19:58:14 2015 From: edgrsprj at ix.netcom.com (E.D.G.) Date: Sun, 26 Jul 2015 18:58:14 -0500 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: <1c6dnRzGjJyP6SjInZ2dnUU7-S-dnZ2d@earthlink.com> "Ned Batchelder" wrote in message news:b68af3d4-6f12-49d6-8c15-f18a95441eda at googlegroups.com... >> Am I the only person thinking Troll? > Yes. Posted by E.D.G. July 26, 2015 With some humor intended, thanks for the supportive note. This is an indirect URL for a potentially important computer program that I feel needs to be developed. Unfortunately, although Python could be used to create PC or Mac versions of the program I don't think that those programs would run on Internet server computers. But I don't yet know enough about Python to be able to tell if that is the case or not. http://www.freewebs.com/eq-forecasting/Disaster_Response_System.html There are two Perl programs that I have developed that I believe many Python users would like to have available in Python versions. And at some point I might create a Web page that will discuss them in detail. For the moment I have just made the decision to combine them into a single program that would be quite helpful for the scientific community. People don't actually even need my assistance with developing these types of programs. Some versions are likely already available for free. The first program can do things such as automatically go to a Web site that provides weather information for example, feed information to the Web page program running at that site, wait for the results, copy them to a PC or Mac, and start processing the data. It is a tremendously powerful and versatile program that can save scientists etc. large amounts of time by helping them automate repetitive tasks that take a lot of time if done manually. Microsoft at one time had a Windows program available that did things like that. I seem to remember that it was called "Recorder." My own Perl version of the program is many times more powerful. The second program acts as a type of universal communicator for Windows programs. It would actually work with any operating system. Running in the background it can start, stop, and interact with any Windows compatible programs such as other Perl programs, Notepad.exe, Excel, Fortran, Python undoubtedly, and also execute DOS shell commands etc. With word processor programs and spreadsheet programs like Excel it makes life much easier as a person needs to learn how to program in only one language to get things done instead of all of those individual macro languages. Regards, E.D.G. From breamoreboy at yahoo.co.uk Sun Jul 26 20:18:26 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 27 Jul 2015 01:18:26 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: On 27/07/2015 00:12, Ned Batchelder wrote: > On Sunday, July 26, 2015 at 5:15:31 PM UTC-4, mm0fmf wrote: >> On 26/07/2015 20:17, E.D.G. wrote: [around 90 lines snipped] >> >> Am I the only person thinking Troll? > > Yes. > > --Ned. > Was it really necessary to resend all of the original for the sake of a seven word question and a one word answer? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From rosuav at gmail.com Sun Jul 26 21:47:10 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Jul 2015 11:47:10 +1000 Subject: Gmail eats Python In-Reply-To: <55b51b9a$0$1666$c3e8da3$5496439d@news.astraweb.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <1950d85b-507c-4468-a0b9-0bbd00e69472@googlegroups.com> <55b51b9a$0$1666$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jul 27, 2015 at 3:40 AM, Steven D'Aprano wrote: >> So while emacs makes everything else look rather puerile, setting it up >> is such a bitch that last python course I just switched to idle. >> Must admit it was more pleasant than I expected. >> Except that sometimes we need C and C++ and assembly and haskell and make >> and config files and git commits and... >> And so emacs (or eclipse!!) remains the only option > > Um... your students are probably using Macs, Windows, and a small minority > with Linux, yes? On laptops? > > Your Linux students are probably fine. Some of them probably know more than > you :-) > > Mac users have access to a full BSB environment, even if most of them don't > know it. > > Your Windows users are the problem. You could try GnuWin and Gnu Core > Utilities for a set of GNU tools for Windows. You could build a bootable > USB stick containing the Linux installation of your choice, and get them to > use that. (Of course, I can imagine your school/university having a > conniption fit at the thought of the liability issues if the software > erased somebody's hard drive...) There's another option, and it's what we use at Thinkful: direct all your students to a browser-based IDE that's backed by a consistent Linux VM. At the moment, we're recommending Cloud 9; we used to use Nitrous, and there are plenty of other options out there. It may not be as fast as working natively, but believe you me, it's a huge boon to have all your students start off with something consistent! (Those who know what they're doing are welcome to diverge from the recommendation; I have several students who use their own desktops, usually either Mac OS or Linux, but one uses Windows. But the same thing still applies: playing around with the C9 IDE is the reliable fallback for when they have trouble.) In terms of dev environments, Linux is usually the easiest to set up - even when you try to support umpteen distros. Partly this is because most people who use Linux are aware of what their package manager is, so you can say "Go and install the python-numpy package" and most of them can figure that out (apt-get, yum, pacman, GUI front-end, anything). Macs aren't overly difficult; as Steven says, there's plenty of stuff available, plus it's reasonably easy to describe path names and such in the Unix way, and have them be compatible with Linux and Mac OS. Even the shell is almost always consistent - I've yet to meet any student who isn't using some variant of bash. Windows, on the other hand, is a pest to support, because so much is different. Do you tell people to install Git Bash and work in Cygwin? Do you tell them to grab one of the scientific Python stacks and use PowerShell? The default shell is sufficiently weak that it needs to be replaced, but there's no one obvious answer. So a browser-based alternative is the way to go for us. ChrisA From chenchao at inhand.com.cn Sun Jul 26 22:00:27 2015 From: chenchao at inhand.com.cn (chenchao at inhand.com.cn) Date: Mon, 27 Jul 2015 10:00:27 +0800 Subject: ImportError: No module named site In-Reply-To: <55B59006.5080402@inhand.com.cn> References: <55B59006.5080402@inhand.com.cn> Message-ID: <55B590BB.2040104@inhand.com.cn> hi: I'm Needing to get python 2.7.10 to cross compile correctly for an ARM embedded device. When I execute python using shell, it comes out this error:ImportError: No module named site.I have setted environment varible:PYTHONHOME and PYTHONPATH. Is there some good idea to sovle this issue? who can tell me how can I download the python2.7.10-xcompile.patch file?thanks. PYTHONHOME='/usr/sbin'. Python installing dir PYTHONPATH='/usr/lib' .The reference lib of python dir. This is the result of executingpython -v: -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 168900 bytes Desc: not available URL: From tjreedy at udel.edu Mon Jul 27 02:37:51 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 27 Jul 2015 02:37:51 -0400 Subject: Python 3.4 Idle? In-Reply-To: References: Message-ID: On 7/23/2015 9:28 PM, Steve Burrus wrote: > Listen I got back the Idle EAditor the other day but I had to install > the older, version 2.7, version of Python to get it. So naturally I w > onder if I can get Idle for version 3.4.*? Yes, just install 3.4.3. -- Terry Jan Reedy From lac at openend.se Mon Jul 27 05:15:40 2015 From: lac at openend.se (Laura Creighton) Date: Mon, 27 Jul 2015 11:15:40 +0200 Subject: Python Questions - July 25, 2015 In-Reply-To: Message from "E.D.G." of "Sun, 26 Jul 2015 18:58:14 -0500." <1c6dnRzGjJyP6SjInZ2dnUU7-S-dnZ2d@earthlink.com> References: <1c6dnRzGjJyP6SjInZ2dnUU7-S-dnZ2d@earthlink.com> Message-ID: <201507270915.t6R9Feq2017579@fido.openend.se> In a message of Sun, 26 Jul 2015 18:58:14 -0500, "E.D.G." writes: > This is an indirect URL for a potentially important computer program >that I feel needs to be developed. Unfortunately, although Python could be >used to create PC or Mac versions of the program I don't think that those >programs would run on Internet server computers. But I don't yet know >enough about Python to be able to tell if that is the case or not. Sure they will. That thing about the Affordable Health Care Act you mentioned -- do you know how this got _fixed_? People in this community, notably Alex Gaynor went and turned the lot into a Django Python app. He's now working for the US department of Veteran Affairs, turning more things into Django apps so that veterans can get their claims processed in weeks (they are aiming for days) rather than 6-8 months which was the norm before he got their. His plan is to speed up the US government with Python one agency at a time. There are many techniques you can use to make your Python code fast. I think we are much better off in that regard than the Perl users are. If you need better than CPython performance, you might be able to just use numpy numerical arrays and get the improvement you need. Or you might just stop using CPython, and use PyPy, which is a completely different implementation and which has a JIT that gives rather good performance, often on the order of pure C code. see http://speed.pypy.org/ Or you can use Cython http://cython.org/ to make C extensions out of the part of your python code you would like to run faster. Or maybe there already is a C or Fortran library that already does what you want, you just want to use it in your code. There are techniques for just doing this -- and if the library is well known then chances are somebody else has already made python bindings for it so you can just use it with CPython. I wouldn't worry about speed. If you want to reimplement your webscraping Perl program in Python, I suggest you start with this library http://scrapy.org/ rather than reinventing things from scratch. The scrapy community is very happy to get code with new techniques which they add to the library, and then we all benefit. Laura From info at egenix.com Mon Jul 27 05:40:38 2015 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Mon, 27 Jul 2015 11:40:38 +0200 Subject: =?UTF-8?Q?ANN:_Python_Meeting_D=c3=bcsseldorf_-_29.07.2015?= Message-ID: <55B5FC96.9090403@egenix.com> [This announcement is in German since it targets a local user group meeting in D?sseldorf, Germany] ________________________________________________________________________ ANK?NDIGUNG Python Meeting D?sseldorf http://pyddf.de/ Ein Treffen von Python Enthusiasten und Interessierten in ungezwungener Atmosph?re. Mittwoch, 29.07.2015, 18:00 Uhr Raum 1, 2.OG im B?rgerhaus Stadtteilzentrum Bilk D?sseldorfer Arcaden, Bachstr. 145, 40217 D?sseldorf Diese Nachricht ist auch online verf?gbar: http://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2015-07-29 ________________________________________________________________________ NEUIGKEITEN * Bereits angemeldete Vortr?ge: Charlie Clark "Eine Einf?hrung in das Routing von Pyramid" Marc-Andre Lemburg "Python Idioms - Tipps und Anleitungen f?r besseren Python Code" "Bericht von der EuroPython 2015" Weitere Vortr?ge k?nnen gerne noch angemeldet werden: info at pyddf.de * Startzeit und Ort: Wir treffen uns um 18:00 Uhr im B?rgerhaus in den D?sseldorfer Arcaden. Das B?rgerhaus teilt sich den Eingang mit dem Schwimmbad und befindet sich an der Seite der Tiefgarageneinfahrt der D?sseldorfer Arcaden. ?ber dem Eingang steht ein gro?es ?Schwimm?'in Bilk? Logo. Hinter der T?r direkt links zu den zwei Aufz?gen, dann in den 2. Stock hochfahren. Der Eingang zum Raum 1 liegt direkt links, wenn man aus dem Aufzug kommt. Google Street View: http://bit.ly/11sCfiw ________________________________________________________________________ EINLEITUNG Das Python Meeting D?sseldorf ist eine regelm??ige Veranstaltung in D?sseldorf, die sich an Python Begeisterte aus der Region wendet: * http://pyddf.de/ Einen guten ?berblick ?ber die Vortr?ge bietet unser YouTube-Kanal, auf dem wir die Vortr?ge nach den Meetings ver?ffentlichen: * http://www.youtube.com/pyddf/ Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting & Research, D?sseldorf: * http://www.egenix.com/ * http://www.clark-consulting.eu/ ________________________________________________________________________ PROGRAMM Das Python Meeting D?sseldorf nutzt eine Mischung aus Open Space und Lightning Talks, wobei die Gewitter bei uns auch schon mal 20 Minuten dauern k?nnen ;-). Lightning Talks k?nnen vorher angemeldet werden, oder auch spontan w?hrend des Treffens eingebracht werden. Ein Beamer mit XGA Aufl?sung steht zur Verf?gung. Folien bitte als PDF auf USB Stick mitbringen. Lightning Talk Anmeldung bitte formlos per EMail an info at pyddf.de ________________________________________________________________________ KOSTENBETEILIGUNG Das Python Meeting D?sseldorf wird von Python Nutzern f?r Python Nutzer veranstaltet. Um die Kosten zumindest teilweise zu refinanzieren, bitten wir die Teilnehmer um einen Beitrag in H?he von EUR 10,00 inkl. 19% Mwst, Sch?ler und Studenten zahlen EUR 5,00 inkl. 19% Mwst. Wir m?chten alle Teilnehmer bitten, den Betrag in bar mitzubringen. ________________________________________________________________________ ANMELDUNG Da wir nur f?r ca. 20 Personen Sitzpl?tze haben, m?chten wir bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung eingegangen. Es erleichtert uns allerdings die Planung. Meeting Anmeldung bitte formlos per EMail an info at pyddf.de ________________________________________________________________________ WEITERE INFORMATIONEN Weitere Informationen finden Sie auf der Webseite des Meetings: http://pyddf.de/ Mit freundlichen Gr??en, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 27 2015) >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2015-07-29: Python Meeting Duesseldorf ... 2 days to go ::::: Try our mxODBC.Connect Python Database Interface for free ! :::::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From tandrewjohnson at outlook.com Mon Jul 27 06:24:27 2015 From: tandrewjohnson at outlook.com (tjohnson) Date: Mon, 27 Jul 2015 03:24:27 -0700 (PDT) Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: #6: I don't know what your colleague will think, but I've read too many negative things about Eric (lots of dependencies, poor documentation, etc.) to ever try it. For a powerful Free Python IDE, I'd recommend either Eclipse with PyDev (what I use), or PyCharm. From ralph.rajko.nenow at gmail.com Mon Jul 27 08:34:19 2015 From: ralph.rajko.nenow at gmail.com (=?UTF-8?B?UmFmYcWCIFJhamtvLU5lbm93?=) Date: Mon, 27 Jul 2015 05:34:19 -0700 (PDT) Subject: amfast - serialising back which was deserialised - trying to produce same output Message-ID: Hi, I think it's really amfast issue, and has not much in common with mitmproxy, but last days this problem became urgent to me so I'm asking here hoping that anyone succeeded this before. I am using mitmdump with some inline scripts to track AMF serialised flex remoting traffic. As I'm deserialising big amounts od data, I'm using amfast instead of slower pyamf, trying to avoid performance issues. One way used to limit amount of data I need to deserialize was to look for existence of some particular patterns (eg. variable names) in serialized binary data, and deserializing only payloads who match. as cons of this approach I can't provide amfast decoder with data context, and this forced me to deserialize payloads using amfast.decoder.decode_packet() nowadays I am struggling trying to alter AMF data passing by. I've tried decoding traffic and then encoding it again as described here https://code.google.com/p/amfast/wiki/EncodeAndDecode but each time I tried, originally serialised (untouched) payloads differs from those serialised by me. (even without applying any changes to data) ############# EXAMPLE: coded_content = just_captured_untouched_allready_serialised_payload from amfast.decoder import Decoder from amfast.encoder import Encoder # Decode an AMF Packet... dec = Decoder(amf3=True) packet_obj = dec.decode_packet(coded_content) # ...and encode it again enc = Encoder(amf3=True) encoded_back = encoder.encode_packet(packet_obj) ######## now, suprisingly, 'coded_content' differs from 'encoded_back' a bit any ideas? I'm looking forward to your reply. Ralph Rajko-Nenow From toddrjen at gmail.com Mon Jul 27 08:51:02 2015 From: toddrjen at gmail.com (Todd) Date: Mon, 27 Jul 2015 14:51:02 +0200 Subject: Which GUI? In-Reply-To: References: <77b7b182-da35-40c4-b8f1-8a753eb7d970@googlegroups.com> Message-ID: On Sun, Jul 26, 2015 at 7:19 PM, Paulo da Silva < p_s_d_a_s_i_l_v_a_ns at netcabo.pt> wrote: > On 26-07-2015 05:47, blue wrote: > > Hi . > > I tested all. Now I think the PySide can more. > > No python3! > Besides ... any differences to pyqt4? > Thanks > pyside has supported python 3 for a long time now. As for differences, the main difference is the license. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon at panix.com Mon Jul 27 09:43:31 2015 From: gordon at panix.com (John Gordon) Date: Mon, 27 Jul 2015 13:43:31 +0000 (UTC) Subject: AttributeError: LineLogic instance has no attribute 'probe' References: Message-ID: In Abder-Rahman Ali writes: > In the class ---> LineLogic > def __init__(self): > self.probe = vtk.vtkProbeFilter() > In another class ---> LineLogicTest > logic = LineLogic() > probe = logic.probe > data = probe.GetOutput().GetPointData().GetScalars() > When I try running the program, I get the following error: > AttributeError: LineLogic instance has no attribute 'probe' Since you haven't posted the actual complete code, we can only guess at the problem. My guess is that you have two different definitions of the LineLogic class, one of them lacking the probe attribute. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From none at mailinator.com Mon Jul 27 12:46:08 2015 From: none at mailinator.com (mm0fmf) Date: Mon, 27 Jul 2015 17:46:08 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: Message-ID: On 27/07/2015 01:18, Mark Lawrence wrote: > On 27/07/2015 00:12, Ned Batchelder wrote: >> On Sunday, July 26, 2015 at 5:15:31 PM UTC-4, mm0fmf wrote: >>> On 26/07/2015 20:17, E.D.G. wrote: > > [around 90 lines snipped] > >>> >>> Am I the only person thinking Troll? >> >> Yes. >> >> --Ned. >> > > Was it really necessary to resend all of the original for the sake of a > seven word question and a one word answer? Yes? ;-) From neubyr at gmail.com Mon Jul 27 13:24:34 2015 From: neubyr at gmail.com (neubyr) Date: Mon, 27 Jul 2015 10:24:34 -0700 Subject: sys path modification Message-ID: I am trying to understand sys.path working and best practices for managing it within a program or script. Is it fine to modify sys.path using sys.path.insert(0, EXT_MODULES_DIR)? One stackoverflow answer - http://stackoverflow.com/a/10097543 - suggests that it may break external 3'rd party code as by convention first item of sys.path list, path[0], is the directory containing the script that was used to invoke the Python interpreter. So what are best practices to prepend sys.path in the program itself? Any further elaboration would be helpful. - thanks, N -------------- next part -------------- An HTML attachment was scrubbed... URL: From cfkaran2 at gmail.com Mon Jul 27 14:56:07 2015 From: cfkaran2 at gmail.com (Cem Karan) Date: Mon, 27 Jul 2015 14:56:07 -0400 Subject: sys path modification In-Reply-To: References: Message-ID: <9F39B71F-18AD-4C13-8FE3-B22E90D454C2@gmail.com> On Jul 27, 2015, at 1:24 PM, neubyr wrote: > > I am trying to understand sys.path working and best practices for managing it within a program or script. Is it fine to modify sys.path using sys.path.insert(0, EXT_MODULES_DIR)? One stackoverflow answer - http://stackoverflow.com/a/10097543 - suggests that it may break external 3'rd party code as by convention first item of sys.path list, path[0], is the directory containing the script that was used to invoke the Python interpreter. So what are best practices to prepend sys.path in the program itself? Any further elaboration would be helpful. Why are you trying to modify sys.path? I'm not judging, there are many good reasons to do so, but there may be safer ways of getting the effect you want that don't rely on modifying sys.path. One simple method is to modify PYTHONPATH (https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH) instead. In order of preference: 1) Append to sys.path. This will cause you the fewest headaches. 2) If you absolutely have to insert into the list, insert after the first element. As you noted from SO, and noted in the docs (https://docs.python.org/3/library/sys.html#sys.path), the first element of sys.path is the path to the directory of the script itself. If you modify this, you **will** break third-party code at some point. Thanks, Cem Karan From tjreedy at udel.edu Mon Jul 27 15:08:41 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 27 Jul 2015 15:08:41 -0400 Subject: ImportError: No module named site In-Reply-To: <55B590BB.2040104@inhand.com.cn> References: <55B59006.5080402@inhand.com.cn> <55B590BB.2040104@inhand.com.cn> Message-ID: On 7/26/2015 10:00 PM, chenchao at inhand.com.cn wrote: > > hi: > I'm Needing to get python 2.7.10 to cross compile correctly for an > ARM embedded device. When I execute python using shell, it comes out > this error:ImportError: No module named site.I have setted environment > varible:PYTHONHOME and PYTHONPATH. Is there some good idea to sovle this > issue? who can tell me how can I download the > python2.7.10-xcompile.patch file?thanks. > PYTHONHOME='/usr/sbin'. Python installing dir > PYTHONPATH='/usr/lib' .The reference lib of python dir. > This is the result of executingpython -v: The stdlib /Lib directory *must* contain a site.py module. The standard version starts with """Append module search paths for third-party packages to sys.path. **************************************************************** * This module is automatically imported during initialization. * **************************************************************** This will append site-specific paths to the module search path. ... -- Terry Jan Reedy From ned at nedbatchelder.com Mon Jul 27 15:45:47 2015 From: ned at nedbatchelder.com (Ned Batchelder) Date: Mon, 27 Jul 2015 12:45:47 -0700 (PDT) Subject: sys path modification In-Reply-To: References: Message-ID: <9be986d7-0085-401f-8be0-cdad48c36a6c@googlegroups.com> On Monday, July 27, 2015 at 1:24:50 PM UTC-4, neubyr wrote: > I am trying to understand sys.path working and best practices for managing it within a program or script. Is it fine to modify sys.path using sys.path.insert(0, EXT_MODULES_DIR)? One stackoverflow answer - http://stackoverflow.com/a/10097543 - suggests that it may break external 3'rd party code as by convention first item of sys.path list, path[0], is the directory containing the script that was used to invoke the Python interpreter. So what are best practices to prepend sys.path in the program itself? Any further elaboration would be helpful.? The best practice is not to modify sys.path at all, and instead to install modules you need to import. That way they can be imported without resorting to sys.path fiddling in the first place. Is there a reason you can't install the modules? Maybe we can help solve that. --Ned. From lac at openend.se Mon Jul 27 16:00:28 2015 From: lac at openend.se (Laura Creighton) Date: Mon, 27 Jul 2015 22:00:28 +0200 Subject: ImportError: No module named site In-Reply-To: Message from Terry Reedy of "Mon, 27 Jul 2015 15:08:41 -0400." References: <55B59006.5080402@inhand.com.cn> <55B590BB.2040104@inhand.com.cn> Message-ID: <201507272000.t6RK0Sjx032546@fido.openend.se> What I want to know is can you import anything else? If site.py is just the first thing in a long list of modules, and you cannot find any of them, which is what I think is the case, and I'd start looking for problems with the PYTHONPATH then you have a different problem than if you can find other modules just fine, just, for some reason not site.py Laura From neubyr at gmail.com Mon Jul 27 17:09:27 2015 From: neubyr at gmail.com (neubyr) Date: Mon, 27 Jul 2015 14:09:27 -0700 Subject: sys path modification In-Reply-To: <9be986d7-0085-401f-8be0-cdad48c36a6c@googlegroups.com> References: <9be986d7-0085-401f-8be0-cdad48c36a6c@googlegroups.com> Message-ID: Modules are installed, but they are in a different directory than standard modules directory. I considered an option to add a site specific directory, but I want to make module path application specific rather than installing it in system-wide directory. virtualenv is one option, but that means anyone who wants to run this particular script will need to activate virtualenv each time. I thought allowing application to find/use it's dependencies would be easier. Are there any other options? On Mon, Jul 27, 2015 at 12:45 PM, Ned Batchelder wrote: > On Monday, July 27, 2015 at 1:24:50 PM UTC-4, neubyr wrote: > > I am trying to understand sys.path working and best practices for > managing it within a program or script. Is it fine to modify sys.path using > sys.path.insert(0, EXT_MODULES_DIR)? One stackoverflow answer - > http://stackoverflow.com/a/10097543 - suggests that it may break external > 3'rd party code as by convention first item of sys.path list, path[0], is > the directory containing the script that was used to invoke the Python > interpreter. So what are best practices to prepend sys.path in the program > itself? Any further elaboration would be helpful. > > The best practice is not to modify sys.path at all, and instead to install > modules you need to import. That way they can be imported without > resorting > to sys.path fiddling in the first place. > > Is there a reason you can't install the modules? Maybe we can help solve > that. > > --Ned. > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From deusex12345678 at gmail.com Mon Jul 27 17:16:26 2015 From: deusex12345678 at gmail.com (deus ex) Date: Mon, 27 Jul 2015 23:16:26 +0200 Subject: Usage of P(C)ython Logo for Coffee Mug Message-ID: Dear sirs or madam, I would like to let produce a p(c)ython coffee mug for myself for non-commerical use. Am I allowed to use your designed logo like: https://www.python.org/static/community_logos/python-logo-generic.svg https://upload.wikimedia.org/wikipedia/de/thumb/c/ce/Cython-logo.svg/640px-Cython-logo.svg.png or other versions? If you possibly be so kind to provide me a SVG Version please, that I am allowed to modify and use? Thanks in advance. Greetings, dex -------------- next part -------------- An HTML attachment was scrubbed... URL: From cs at zip.com.au Mon Jul 27 18:55:00 2015 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 28 Jul 2015 08:55:00 +1000 Subject: sys path modification In-Reply-To: References: Message-ID: <20150727225500.GA85332@cskk.homeip.net> On 27Jul2015 14:09, neubyr wrote: >Modules are installed, but they are in a different directory than standard >modules directory. I considered an option to add a site specific directory, >but I want to make module path application specific rather than installing >it in system-wide directory. virtualenv is one option, but that means >anyone who wants to run this particular script will need to activate >virtualenv each time. Personally I almost always recommend virtualenv over installing in the system areas - the system package manager can fight with you there. Rather than forcing users to activate the virtualenv, instead provide a trivial wrapper script which activates the virtualenv and runs their command, and tell them about that, not the direct path to the app: #!/bin/sh . /path/to/virtualenv/bin/activate exec python /path/to/app ${1+"$@"} If you stick that in (say) /usr/local/bin with a sensible name they need never care. >I thought allowing application to find/use it's >dependencies would be easier. Are there any other options? Well, I actually have an app which imports from a separate location in order to support user supplied functions that plug into the app. I wrote an "import_module_name" function to support this: https://bitbucket.org/cameron_simpson/css/src/tip/lib/python/cs/py/modules.py which optionally installs a different sys.path for the duration of the import operation, then reinstalls the old one again. You can even "pip install cs.py.modules", in theory. Then you could go: import_module_name('your.app.modulename', 'YourAppClass', ['path/to/your/app/lib'] + sys.path) app = YourAppClass(...) app(args,...) to suck in the app, instantiate it, and run it. Or some obvious variation on that. There are two caveats I'd provide if you go this route: Since the stdlib's importlib provides no overt exclusion, if you have other imports taking place in other threads when you run this it is possible that they may import while your modified sys.path is in place. Any time you pull from an exterior place, you need to be sure the exterior place doesn't have unexpected code - if someone untrusted can insert python code into the extra lib path then they may get it imported. Cheers, Cameron Simpson From percy.k1234 at gmail.com Mon Jul 27 19:01:53 2015 From: percy.k1234 at gmail.com (Prasad Katti) Date: Mon, 27 Jul 2015 16:01:53 -0700 (PDT) Subject: Authenticate users using command line tool against AD in python Message-ID: I am writing a command line tool in python to generate one time passwords/tokens. The command line tool will have certain sub-commands like --generate-token and --list-all-tokens for example. I want to restrict access to certain sub-commands. In this case, when user tries to generate a new token, I want him/her to authenticate against AD server first. I have looked at python-ldap and I am even able to bind to the AD server. In my application I have a function def authenticate_user(username, password): pass which gets username and plain-text password. How do I use the LDAPObject instance to validate these credentials? From ryanshuell at gmail.com Mon Jul 27 19:13:29 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Mon, 27 Jul 2015 16:13:29 -0700 (PDT) Subject: Error: valueError: ordinal must be >= 1 Message-ID: <5538a8f6-8c47-4da8-8517-92d860948d93@googlegroups.com> Hello experts. I'm working in Python > Anaconda > Spyder. I'm reading a book called 'Python for Finance' and I'm trying to run this sample code: import numpy as np import pandas as pd import pandas.io.data as web sp500 = web.DataReader('^GSPC', data_source='yahoo', start='1/1/2000', end='4/14/2014') sp500.info() sp500['Close'].plot(grid=True, figsize=(8, 5)) sp500['42d'] = np.round(pd.rolling_mean(sp500['Close'], window=42), 2) sp500['252d'] = np.round(pd.rolling_mean(sp500['Close'], window=252), 2) sp500[['Close', '42d', '252d']].tail() sp500[['Close', '42d', '252d']].plot(grid=True, figsize=(8, 5)) sp500['42-252'] = sp500['42d'] - sp500['252d'] sp500['42-252'].tail() sp500['42-252'].head() It seems to work perfectly find when I see the results in the book, but all I'm getting is this . . . *** ValueError: ordinal must be >= 1 (Pdb) Does anyone have any idea what I'm doing wrong? Thanks, all. From rgaddi at technologyhighland.invalid Mon Jul 27 19:14:50 2015 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Mon, 27 Jul 2015 23:14:50 +0000 (UTC) Subject: Python Questions - July 25, 2015 References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On Sun, 26 Jul 2015 13:49:57 +0100, BartC wrote: > How do you actually install Numpy in Windows? > > I had a go a month or two ago and couldn't get anywhere. > As I recall you noodle around with it for a few hours making things that look like progress but turn out to be rabbit holes. Then you break down sobbing, go off, get drunk, come back the next day with your head pounding, delete your existing installation in a fit of pique, install Anaconda's distribution with the whole SciPy stack already built in, and have it just magically work. I suppose you could try skipping the earlier steps, but at that point I wouldn't be able to vouch for the process. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From lijpbasin at 126.com Mon Jul 27 19:21:21 2015 From: lijpbasin at 126.com (=?GBK?B?wO68zsX0?=) Date: Tue, 28 Jul 2015 07:21:21 +0800 (CST) Subject: What happens when python seeks a text file Message-ID: <22f8fb9f.10135.14ed1d210fb.Coremail.lijpbasin@126.com> Hi, I tried using seek to reverse a text file after reading about the subject in the documentation: https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects https://docs.python.org/3/library/io.html#io.TextIOBase.seek The script "reverse_text_by_seek3.py" produces expected result on a UTF-8 encoded text file "Moon-utf8.txt" (several lines of Chinese characters): $ ./reverse_text_by_seek3.py Moon-utf8.txt [0, 10, 11, 27, 28, 44, 60, 76, 92] ????? ????? ????? ????? ????? ??? or $ ./reverse_text_by_seek3.py Moon-utf8.txt seek [0, 10, 11, 27, 28, 44, 60, 76, 92] ????? ????? ????? ????? ????? ??? However, an exception is raised if a file with the same content encoded in GBK is provided: $ ./reverse_text_by_seek3.py Moon-gbk.txt [0, 7, 8, 19, 21, 32, 42, 53, 64] ????? ????? Traceback (most recent call last): File "./reverse_text_by_seek3.py", line 21, in print(f.readline(), end="") UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 8: illegal multibyte sequence While everything works fine again when a seek operation is applied after each readline invocation: $ ./reverse_text_by_seek3.py Moon-gbk.txt seek [0, 7, 8, 19, 20, 31, 42, 53, 64] ????? ????? ????? ????? ????? ??? Some of the printed positions are also different. A python2 counterpart "reverse_text_by_seek2.py" is written, which decodes the lines upon printing instead of reading, no exception occurs. It's just fun doing this, not for anything useful. Can anyone reproduce the above results? What's really happening here? Is it a bug? Other information: Distribution: Arch Linux Python3 package: 3.4.3-2 (official) Python2 package: 2.7.10-1 (official) $ uname -rvom 4.1.2-2-ARCH #1 SMP PREEMPT Wed Jul 15 08:30:32 UTC 2015 x86_64 GNU/Linux $ env | grep -e LC -e LANG LC_ALL=en_US.UTF-8 LC_COLLATE=C LANG=en_US.UTF-8 -------------- next part -------------- A non-text attachment was scrubbed... Name: reverse_text_by_seek3.py Type: application/octet-stream Size: 552 bytes Desc: not available URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Moon-gbk.txt URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Moon-utf8.txt URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: reverse_text_by_seek2.py Type: application/octet-stream Size: 542 bytes Desc: not available URL: From emile at fenx.com Mon Jul 27 19:25:17 2015 From: emile at fenx.com (Emile van Sebille) Date: Mon, 27 Jul 2015 16:25:17 -0700 Subject: Error: valueError: ordinal must be >= 1 In-Reply-To: <5538a8f6-8c47-4da8-8517-92d860948d93@googlegroups.com> References: <5538a8f6-8c47-4da8-8517-92d860948d93@googlegroups.com> Message-ID: On 7/27/2015 4:13 PM, ryguy7272 wrote: > It seems to work perfectly find when I see the results in the book, but all I'm getting is this . . . > *** ValueError: ordinal must be >= 1 > (Pdb) > > Does anyone have any idea what I'm doing wrong? You've been dropped into the python debugger. I'd suspect you've hit a 'import pdb; pdb.set_trace()' or similar line. You can type in 'l' (lower case L) to see the context (you may need to 's' (step) to the appropriate line depending on your version of python.) Alternately, use 'c' to allow the script to continue processing. Otherwise, you'll need to complete debugging the code (as indicated by the break) or comment out/remove the set_trace. Emile From cs at zip.com.au Mon Jul 27 21:44:28 2015 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 28 Jul 2015 11:44:28 +1000 Subject: AttributeError: LineLogic instance has no attribute 'probe' In-Reply-To: References: Message-ID: <20150728014428.GA2321@cskk.homeip.net> On 27Jul2015 13:43, John Gordon wrote: >In Abder-Rahman Ali writes: >> In the class ---> LineLogic > >> def __init__(self): >> self.probe = vtk.vtkProbeFilter() > >> In another class ---> LineLogicTest > >> logic = LineLogic() >> probe = logic.probe >> data = probe.GetOutput().GetPointData().GetScalars() > >> When I try running the program, I get the following error: > >> AttributeError: LineLogic instance has no attribute 'probe' > >Since you haven't posted the actual complete code, we can only guess >at the problem. > >My guess is that you have two different definitions of the LineLogic >class, one of them lacking the probe attribute. Alternatively, if the code he did quote is accurate, he may have not indented the definition of __init__. Example: class LineLogic(object): ''' doc string ''' def __init__(self): ... This is legal, but wrong. It will result in LineLogic having the default initialisation i.e. nothing, as the __init__ function is not part of the class. But yes, this would all be clearer had the OP posted the code instead of a tiny out of context snippet. Cheers, Cameron Simpson Motorcycling is indeed a delightful pastime. - Honda Rider Training Film From michael at stroeder.com Tue Jul 28 03:56:16 2015 From: michael at stroeder.com (=?UTF-8?Q?Michael_Str=c3=b6der?=) Date: Tue, 28 Jul 2015 09:56:16 +0200 Subject: Authenticate users using command line tool against AD in python In-Reply-To: References: Message-ID: Prasad Katti wrote: > I am writing a command line tool in python to generate one time > passwords/tokens. The command line tool will have certain sub-commands like > --generate-token and --list-all-tokens for example. I want to restrict > access to certain sub-commands. In this case, when user tries to generate a > new token, I want him/her to authenticate against AD server first. This does not sound secure: The user can easily use a modified copy of your script. > I have looked at python-ldap and I am even able to bind to the AD server. > In my application I have a function > > def authenticate_user(username, password): pass > > which gets username and plain-text password. How do I use the LDAPObject instance to validate these credentials? You probably want to use http://www.python-ldap.org/doc/html/ldap.html#ldap.LDAPObject.simple_bind_s Check whether password is non-zero before because most LDAP servers consider an empty password as anon simple bind even if the bind-DN is set. Ciao, Michael. From tjreedy at udel.edu Tue Jul 28 04:50:55 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 28 Jul 2015 04:50:55 -0400 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On 7/27/2015 7:14 PM, Rob Gaddi wrote: > On Sun, 26 Jul 2015 13:49:57 +0100, BartC wrote: >> How do you actually install Numpy in Windows? I believe 'pip install numpy' works > As I recall you noodle around with it for a few hours making things that > look like progress but turn out to be rabbit holes. To me, this is nonsense. If the above does not work, go to http://www.lfd.uci.edu/~gohlke/pythonlibs/ One of the above worked for me a year ago. 10 minutes max. -- Terry Jan Reedy From bc at freeuk.com Tue Jul 28 05:46:04 2015 From: bc at freeuk.com (BartC) Date: Tue, 28 Jul 2015 10:46:04 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On 28/07/2015 09:50, Terry Reedy wrote: > On 7/27/2015 7:14 PM, Rob Gaddi wrote: >> On Sun, 26 Jul 2015 13:49:57 +0100, BartC wrote: >>> How do you actually install Numpy in Windows? > > I believe 'pip install numpy' works C:>pip install numpy 'pip' is not recognized as an internal or external command, operable program or batch file. So you try and install pip, and it's a .whl file: 'Windows can't open this file'. It seems that you might need pip to install pip. But you investigate, and find .whl is just a .zip file. So you try renaming it to .zip, unzip it, and now get 200 files, none of which is called pip! A half-hearted attempt to run wheel.py gives an error, not unexpected. But what were we trying to do? It was to install numpy, not pip! It is fun however seeing how many layers of complexity people like adding, in order to make things 'simpler'. A couple more of layers, and things will become completely impossible I think. Either that or the machine will grind to a halt first. (I'm still reeling from the size of that Anaconda download. Apparently it contains a whole bunch of stuff, nothing to do with numpy, that I don't need. But one of the listed packages was 'libffi', which is puzzling. This library lets a C-like language call functions with runtime-determined argument types. How would that be used in Python?) -- Bartc From rosuav at gmail.com Tue Jul 28 06:17:52 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 28 Jul 2015 20:17:52 +1000 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On Tue, Jul 28, 2015 at 7:46 PM, BartC wrote: > On 28/07/2015 09:50, Terry Reedy wrote: >> I believe 'pip install numpy' works > > > C:>pip install numpy > > 'pip' is not recognized as an internal or external command, > operable program or batch file. Then go and update your Python, because the newer versions automatically install pip. Or if you already have a recent Python and pip is installed, you may need to sort out your PATH, information on which is readily available on the internet. > So you try and install pip, and it's a .whl file: > > 'Windows can't open this file'. > > It seems that you might need pip to install pip. But you investigate, and > find .whl is just a .zip file. So you try renaming it to .zip, unzip it, and > now get 200 files, none of which is called pip! An Open Document Format file is also a zip. Do you rename those to .zip, unzip them, and then wonder why you can't read the document? The "is just a zip file" bit is purely an implementation detail, and while it may be of curiosity interest to explore the internals, it won't help you get something basic going. This is why you were previously advised to get one of the ready-made distributions. > (I'm still reeling from the size of that Anaconda download. Apparently it > contains a whole bunch of stuff, nothing to do with numpy, that I don't > need. But one of the listed packages was 'libffi', which is puzzling. This > library lets a C-like language call functions with runtime-determined > argument types. How would that be used in Python?) That's what you asked for. You sought a ready-to-use distribution with heaps of stuff in it. Want one with less stuff? Look for something else. Want carte blanche? Pick up the pieces individually instead. This is how the internet works. ChrisA From bc at freeuk.com Tue Jul 28 06:44:12 2015 From: bc at freeuk.com (BartC) Date: Tue, 28 Jul 2015 11:44:12 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: <22Jtx.96974$ad5.25622@fx06.am4> On 28/07/2015 11:17, Chris Angelico wrote: > On Tue, Jul 28, 2015 at 7:46 PM, BartC wrote: >> On 28/07/2015 09:50, Terry Reedy wrote: >>> I believe 'pip install numpy' works >> >> >> C:>pip install numpy >> >> 'pip' is not recognized as an internal or external command, >> operable program or batch file. > > Then go and update your Python, because the newer versions > automatically install pip. Or if you already have a recent Python and > pip is installed, you may need to sort out your PATH, information on > which is readily available on the internet. Right you are. There is a pip.exe in the ./Scripts directory of Python 3.4. I don't agree with the PATH set-up however; I try and avoid those and generally don't need them; my simple IDE knows where to look for binaries, and PATHs for different versions would clash. (The actual pip command was tried in the same place as python.exe, not from the root path as my example suggests. A search for pip.exe failed because that was 3.1.) >> (I'm still reeling from the size of that Anaconda download. Apparently it >> contains a whole bunch of stuff, nothing to do with numpy, that I don't >> need. > That's what you asked for. You sought a ready-to-use distribution with > heaps of stuff in it. Want one with less stuff? Look for something > else. Want carte blanche? Pick up the pieces individually instead. > This is how the internet works. No, I asked for how to install numpy, and was told to install Anaconda. I didn't know it was so big. It's like asking where to buy a pint of milk, and inadvertently buying the whole store! Which does, after all, come with the milk I wanted... -- Bartc From breamoreboy at yahoo.co.uk Tue Jul 28 08:47:49 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 28 Jul 2015 13:47:49 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: <22Jtx.96974$ad5.25622@fx06.am4> References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <22Jtx.96974$ad5.25622@fx06.am4> Message-ID: On 28/07/2015 11:44, BartC wrote: > > Right you are. There is a pip.exe in the ./Scripts directory of Python 3.4. > A handy tip for windows users is that there is a versioned number of pip, e.g. pip3.4.exe. Very useful indeed when you've multiple Python versions installed as I have, as it prevents you spending time and effort updating an unintended installation. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Tue Jul 28 08:58:02 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 28 Jul 2015 13:58:02 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: On 28/07/2015 09:50, Terry Reedy wrote: > On 7/27/2015 7:14 PM, Rob Gaddi wrote: >> On Sun, 26 Jul 2015 13:49:57 +0100, BartC wrote: >>> How do you actually install Numpy in Windows? > > I believe 'pip install numpy' works > >> As I recall you noodle around with it for a few hours making things that >> look like progress but turn out to be rabbit holes. > > To me, this is nonsense. If the above does not work, go to > http://www.lfd.uci.edu/~gohlke/pythonlibs/ > > One of the above worked for me a year ago. 10 minutes max. > You are able to use pip to go directly to sites to get files, which is extremely useful if you don't have Visual Studio and hence need to bypass the files directly available from pypi. I've used the following successfuly to get the Phoenix (Python 3) version of wxPython. pip install --trusted-host wxPython.org -U --pre -f http://wxPython.org/Phoenix/snapshot-builds/ wxPython_Phoenix So in theory you should be able to go straight to pythonlibs although I've not tried it myself. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From victorhooi at gmail.com Tue Jul 28 09:55:08 2015 From: victorhooi at gmail.com (Victor Hooi) Date: Tue, 28 Jul 2015 06:55:08 -0700 (PDT) Subject: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? Message-ID: I have a line that looks like this: 14 *0 330 *0 760 411|0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m 1538 ComputedCartRS PRI 09:40:26 I'd like to split this line on multiple separators - in this case, consecutive whitespace, as well as the pipe symbol (|). If I run .split() on the line, it will split on consecutive whitespace: In [17]: f.split() Out[17]: ['14', '*0', '330', '*0', '760', '411|0', '0', '770g', '1544g', '117g', '1414', 'computedshopcartdb:103.5%', '0', '30|0', '0|1', '19m', '97m', '1538', 'ComputedCartRS', 'PRI', '09:40:26'] If I try to run .split(' |'), however, I get: f.split(' |') Out[18]: [' 14 *0 330 *0 760 411|0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m 1538 ComputedCartRS PRI 09:40:26'] I know the regex library also has a split, unfortunately, that does not collapse consecutive whitespace: In [19]: re.split(' |', f) Out[19]: ['', '', '', '', '14', '', '', '', '', '*0', '', '', '', '330', '', '', '', '', '*0', '', '', '', '', '760', '', '', '411|0', '', '', '', '', '', '', '0', '', '', '770g', '', '1544g', '', '', '117g', '', '', '1414', 'computedshopcartdb:103.5%', '', '', '', '', '', '', '', '', '', '0', '', '', '', '', '', '30|0', '', '', '', '', '0|1', '', '', '', '19m', '', '', '', '97m', '', '1538', 'ComputedCartRS', '', 'PRI', '', '', '09:40:26'] Is there an easy way to split on multiple characters, and also treat consecutive delimiters as a single delimiter? From mvoicem at gmail.com Tue Jul 28 09:59:03 2015 From: mvoicem at gmail.com (m) Date: Tue, 28 Jul 2015 15:59:03 +0200 Subject: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? In-Reply-To: References: Message-ID: <55b78aa3$0$2206$65785112@news.neostrada.pl> W dniu 28.07.2015 o 15:55, Victor Hooi pisze: > I know the regex library also has a split, unfortunately, that does not collapse consecutive whitespace: > > In [19]: re.split(' |', f) Try ' *\|' p. m. From oscar.j.benjamin at gmail.com Tue Jul 28 10:09:09 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Tue, 28 Jul 2015 14:09:09 +0000 Subject: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? In-Reply-To: References: Message-ID: On Tue, 28 Jul 2015 at 15:01 Victor Hooi wrote: > I have a line that looks like this: > > 14 *0 330 *0 760 411|0 0 770g 1544g 117g > 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m > 1538 ComputedCartRS PRI 09:40:26 > > I'd like to split this line on multiple separators - in this case, > consecutive whitespace, as well as the pipe symbol (|). > Is this what you want: In [5]: def split(s): ...: elements = [] ...: for x in s.split(): # Split whitespace ...: elements.extend(x.split('|')) ...: return elements ...: In [6]: s = "14 *0 330 *0 760 411|0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m 1538 ComputedCartRS PRI 09:40:26" In [7]: split(s) Out[7]: ['14', '*0', '330', '*0', '760', '411', '0', '0', '770g', '1544g', '117g', '1414', 'computedshopcartdb:103.5%', '0', '30', '0', '0', '1', '19m', '97m', '1538', 'ComputedCartRS', 'PRI', '09:40:26'] -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From victorhooi at gmail.com Tue Jul 28 10:09:45 2015 From: victorhooi at gmail.com (Victor Hooi) Date: Tue, 28 Jul 2015 07:09:45 -0700 (PDT) Subject: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? In-Reply-To: <55b78aa3$0$2206$65785112@news.neostrada.pl> References: <55b78aa3$0$2206$65785112@news.neostrada.pl> Message-ID: On Tuesday, 28 July 2015 23:59:11 UTC+10, m wrote: > W dniu 28.07.2015 o 15:55, Victor Hooi pisze: > > I know the regex library also has a split, unfortunately, that does not collapse consecutive whitespace: > > > > In [19]: re.split(' |', f) > > Try ' *\|' > > p. m. Hmm, that seems to be getting closer (it returns a four-element list): In [23]: re.split(' *\|', f) Out[23]: [' 14 *0 330 *0 760 411', '0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30', '0 0', '1 19m 97m 1538 ComputedCartRS PRI 09:40:26'] From python at mrabarnett.plus.com Tue Jul 28 10:30:25 2015 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 28 Jul 2015 15:30:25 +0100 Subject: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? In-Reply-To: References: <55b78aa3$0$2206$65785112@news.neostrada.pl> Message-ID: <55B79201.1060207@mrabarnett.plus.com> On 2015-07-28 15:09, Victor Hooi wrote: > On Tuesday, 28 July 2015 23:59:11 UTC+10, m wrote: >> W dniu 28.07.2015 o 15:55, Victor Hooi pisze: >> > I know the regex library also has a split, unfortunately, that does not collapse consecutive whitespace: >> > >> > In [19]: re.split(' |', f) >> >> Try ' *\|' >> >> p. m. > > Hmm, that seems to be getting closer (it returns a four-element list): > > In [23]: re.split(' *\|', f) > Out[23]: > [' 14 *0 330 *0 760 411', > '0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30', > '0 0', > '1 19m 97m 1538 ComputedCartRS PRI 09:40:26'] > Try '[ |]+'. From devnzyme1 at use.startmail.com Tue Jul 28 11:34:59 2015 From: devnzyme1 at use.startmail.com (devnzyme1 at use.startmail.com) Date: Tue, 28 Jul 2015 08:34:59 -0700 (PDT) Subject: Using requests with an Authorization header? Message-ID: Has anyone ever used an authorization header with the requests library? I tried using: >>> from requests.auth import HTTPBasicAuth >>> requests.get('https://api.github.com/user', auth=HTTPBasicAuth('user', 'pass') from their docs online but that's not working and I don't see anything about authorization headers http://docs.python-requests.org/en/latest/user/authentication/#basic-authentication From rosuav at gmail.com Tue Jul 28 11:49:04 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 29 Jul 2015 01:49:04 +1000 Subject: Using requests with an Authorization header? In-Reply-To: References: Message-ID: On Wed, Jul 29, 2015 at 1:34 AM, wrote: > but that's not working This is, I'm sorry to say, almost completely unhelpful - and also extremely common. Can you please post the full details of (a) what you did, (b) what happened or didn't happen, and (c) what you expect to happen? For example, are you sure the server supports what you're trying to do? ChrisA From steve at pearwood.info Tue Jul 28 12:02:33 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 29 Jul 2015 02:02:33 +1000 Subject: Python Questions - July 25, 2015 References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <22Jtx.96974$ad5.25622@fx06.am4> Message-ID: <55b7a798$0$1636$c3e8da3$5496439d@news.astraweb.com> On Tue, 28 Jul 2015 08:44 pm, BartC wrote: > No, I asked for how to install numpy, and was told to install Anaconda. > I didn't know it was so big. It's like asking where to buy a pint of > milk, and inadvertently buying the whole store! Which does, after all, > come with the milk I wanted... Bart, you can't blame us for your failure to do your own investigation before clicking Download. Don't you read the instructions? Anaconda installs a full-featured scientific Python stack, not just numpy. The *very first paragraph* of the download page says: "It includes over 195 of the most popular Python packages for science, math, engineering, data analysis." http://continuum.io/downloads If the installer is 300MB or so, what were you expecting the full installation to be? Further down on that same page, it describes Miniconda, which is a bare-bones installation of Python + the conda package manager only, so you can pick and choose which of those 195 packages are installed. -- Steven From steve at pearwood.info Tue Jul 28 12:12:37 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 29 Jul 2015 02:12:37 +1000 Subject: Python Questions - July 25, 2015 References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> Message-ID: <55b7a9f5$0$1668$c3e8da3$5496439d@news.astraweb.com> On Tue, 28 Jul 2015 07:46 pm, BartC wrote: > (I'm still reeling from the size of that Anaconda download. Apparently > it contains a whole bunch of stuff, nothing to do with numpy, that I > don't need. But one of the listed packages was 'libffi', which is > puzzling. This library lets a C-like language call functions with > runtime-determined argument types. How would that be used in Python?) https://en.wikipedia.org/wiki/Libffi -- Steven From bc at freeuk.com Tue Jul 28 12:45:00 2015 From: bc at freeuk.com (BartC) Date: Tue, 28 Jul 2015 17:45:00 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: <55b7a9f5$0$1668$c3e8da3$5496439d@news.astraweb.com> References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <55b7a9f5$0$1668$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 28/07/2015 17:12, Steven D'Aprano wrote: > On Tue, 28 Jul 2015 07:46 pm, BartC wrote: > >> (I'm still reeling from the size of that Anaconda download. Apparently >> it contains a whole bunch of stuff, nothing to do with numpy, that I >> don't need. But one of the listed packages was 'libffi', which is >> puzzling. This library lets a C-like language call functions with >> runtime-determined argument types. How would that be used in Python?) > > https://en.wikipedia.org/wiki/Libffi Yes, I know (I was looking at it myself a few days ago for another project). But while it might be used for implementing some of Python's internals, I was wondering what it was doing in a user-level set of libraries, given that it's mostly a bunch of C code. Perhaps they were just padding the list to make it look more impressive. -- Bartc From ltc.hotspot at gmail.com Tue Jul 28 12:59:13 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Tue, 28 Jul 2015 16:59:13 +0000 Subject: =?utf-8?Q?Help_Command_Question?= Message-ID: <55b7b533.ab8c460a.ce4fc.2e2a@mx.google.com> Hi Everyone, I'm trying to print a command of list options by using the help command in the iPython interpreter. Read captured copy of the printout as follows: 'Python 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, 16:44:52) [MSC v. 1500 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information. IPython 3.2.0 -- An enhanced Interactive Python. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://anaconda.org In [1]: help list File "", line 1 help list ^ SyntaxError: invalid syntax.' Question: What is the correct help command? Regards, Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From rgaddi at technologyhighland.invalid Tue Jul 28 14:46:30 2015 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Tue, 28 Jul 2015 18:46:30 +0000 (UTC) Subject: Python Questions - July 25, 2015 References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <55b7a9f5$0$1668$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, 28 Jul 2015 17:45:00 +0100, BartC wrote: > On 28/07/2015 17:12, Steven D'Aprano wrote: >> On Tue, 28 Jul 2015 07:46 pm, BartC wrote: >> >>> (I'm still reeling from the size of that Anaconda download. Apparently >>> it contains a whole bunch of stuff, nothing to do with numpy, that I >>> don't need. But one of the listed packages was 'libffi', which is >>> puzzling. This library lets a C-like language call functions with >>> runtime-determined argument types. How would that be used in Python?) >> >> https://en.wikipedia.org/wiki/Libffi > > Yes, I know (I was looking at it myself a few days ago for another > project). But while it might be used for implementing some of Python's > internals, I was wondering what it was doing in a user-level set of > libraries, given that it's mostly a bunch of C code. > > Perhaps they were just padding the list to make it look more impressive. It underpins the ctypes implementation, which is neither here nor there. If I remember right, numpy does dynamic loading of one of a couple different (FORTRAN?) algebra libraries depending on which ones it can find installed. That would be a pretty clear use case for libffi. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From hannahgracemcdonald16 at gmail.com Tue Jul 28 14:50:31 2015 From: hannahgracemcdonald16 at gmail.com (hannahgracemcdonald16 at gmail.com) Date: Tue, 28 Jul 2015 11:50:31 -0700 (PDT) Subject: Concatenating columns via Python Message-ID: I extracted a table from a PDF so the data is quite messy and the data that should be in 1 row is in 3 colums, like so: year color location 1 1997 blue, MD 2 green, 3 and yellow SO far my code is below, but I know I am missing data I am just not sure what to put in it: # Simply read and split an example Table 4 import sys # Assigning count number and getting rid of right space def main(): count = 0 pieces = [] for line in open(infile, 'U'): if count < 130: data = line.replace('"', '').rstrip().split("\t") data = clean_data(data) if data[1] == "year" and data[1] != "": write_pieces(pieces) pieces = data str.join(pieces) else: for i in range(len(data)): pieces[i] = pieces[i] + data[i] str.join(pieces) # Executing command to remove right space def clean_data(s): return [x.rstrip() for x in s] def write_pieces(pieces): print if __name__ == '__main__': infile = "file.txt" main() From python at mrabarnett.plus.com Tue Jul 28 15:17:15 2015 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 28 Jul 2015 20:17:15 +0100 Subject: Concatenating columns via Python In-Reply-To: References: Message-ID: <55B7D53B.4060801@mrabarnett.plus.com> On 2015-07-28 19:50, hannahgracemcdonald16 at gmail.com wrote: > I extracted a table from a PDF so the data is quite messy and the data that should be in 1 row is in 3 colums, like so: > year color location > 1 1997 blue, MD > 2 green, > 3 and yellow > > SO far my code is below, but I know I am missing data I am just not sure what to put in it: > > # Simply read and split an example Table 4 > import sys > The indentation is messed up, which makes it hard to follow. > # Assigning count number and getting rid of right space > def main(): > count = 0 > pieces = [] > for line in open(infile, 'U'): > if count < 130: > data = line.replace('"', '').rstrip().split("\t") > data = clean_data(data) > if data[1] == "year" and data[1] != "": If the first test is true, then the second test is definitely true, and is unnecessary. > write_pieces(pieces) > pieces = data > str.join(pieces) str.join _returns_ its result. > else: > for i in range(len(data)): > pieces[i] = pieces[i] + data[i] > str.join(pieces) > > # Executing command to remove right space > def clean_data(s): > return [x.rstrip() for x in s] > > def write_pieces(pieces): > print > > if __name__ == '__main__': > infile = "file.txt" > main() > From ltc.hotspot at gmail.com Tue Jul 28 16:21:59 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Tue, 28 Jul 2015 20:21:59 +0000 Subject: =?utf-8?Q?line_error_on_no._7?= Message-ID: <55b7e499.c590420a.2c00.3f74@mx.google.com> Hi Everyone, I'm writing python code to read a data text file, split the file into a list of words using the split(function) and to print the results in alphabetical order. The raw python code is located at http://tinyurl.com/oua9uqx The sample data is located at http://tinyurl.com/odt9nhe Desired Output: ['Arise', 'But', 'It', 'Juliet', 'Who', 'already', 'and', 'breaks', 'east', 'envious', 'fair', 'grief', 'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft', 'sun', 'the', 'through', 'what', 'window', 'with', 'yonder'] There is a line error on no. 7 What is the cause of this error? Regards, Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcarmena at gmail.com Tue Jul 28 17:17:48 2015 From: jcarmena at gmail.com (Javier) Date: Tue, 28 Jul 2015 14:17:48 -0700 (PDT) Subject: Send data to asyncio coroutine In-Reply-To: References: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> Message-ID: <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> El martes, 21 de julio de 2015, 15:42:47 (UTC+2), Ian escribi?: > On Tue, Jul 21, 2015 at 5:31 AM, wrote: > > Hello, I'm trying to understand and link asyncio with ordinary coroutines. Now I just want to understand how to do this on asyncio: > > > > > > def foo(): > > data = yield 8 > > print(data) > > yield "bye" > > > > def bar(): > > f = foo() > > n = f.next() > > print(n) > > message = f.send("hello") > > print(message) > > > > > > What is the equivalent for coro.send("some data") in asyncio? > > I don't know of any reason why you couldn't do it just like the above. > However, the exchange would not be asynchronous, if that is your goal. > > > coro.send on an asyncio coroutine throws AssertionError: yield from wasn't used with future. > > So somehow a future got involved where it shouldn't have been. What > was the actual code that you tried to run? > > Note that while "yield" and "yield from" look similar, they are quite > different, and you cannot send to a generator that is currently paused > at a "yield from". > > If you want to emulate bidirectional communication similar to > coro.send asynchronously, I think you'll need to use Futures to > mediate, something like this (lightly tested): > > @asyncio.coroutine > def foo(fut): > data, fut = yield from send_to_future(8, fut) > print("foo", data) > fut.set_result("bye") > > @asyncio.coroutine > def bar(): > n, fut = yield from start_coro(foo) > print("bar", n) > message = yield from send_to_future("hello", fut) > print("bar", message) > > def start_coro(coro): > future = asyncio.Future() > asyncio.async(coro(future)) > return future > > def send_to_future(data, future): > new_future = asyncio.Future() > future.set_result((data, new_future)) > return new_future Hello again. I have been investigating a bit your example. I don't understand why I can't write something like this: -------- import asyncio def foo(): print("start foo") try: while True: val = yield print("foo:", val) yield from asyncio.sleep(3) except GeneratorExit: print("foo closed") print("exit foo") def bar(next): print("start bar") next.send(None) try: while True: val = yield next.send("bar/"+val) except GeneratorExit: print("bar closed") print("exit bar") def fun(next): next.send(None) for e in ["hello", "world", "I'm", "pythonist"]: next.send(e) @asyncio.coroutine def run(): fun(bar(foo())) loop = asyncio.get_event_loop() loop.run_until_complete(run()) loop.close() ------- The expected output is: start bar start foo foo: bar/hello foo: bar/world foo: bar/I'm foo: bar/phytonist bar closed exit bar foo closed exit foo But the yield from asyncio.sleep(3) call raises AssertionError, however it's inside a Task! I think this is a big flaw in python/asyncio design. From no.email at nospam.invalid Tue Jul 28 17:28:55 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Tue, 28 Jul 2015 14:28:55 -0700 Subject: Another tail recursion example Message-ID: <87bnewott4.fsf@jester.gateway.sonic.net> Chris Angelico was asking for examples of tail recursion that didn't have obvious looping equivalents. Here's an Euler problem solution using memoization and (except that Python doesn't implement it) tail recursion with an accumulator. # Solution to Euler problem 14, using memoization # https://projecteuler.net/problem=14 import sys sys.setrecursionlimit(10000) def memoize(func): def mf(n, a, func=func, memo={}): if n in memo: return memo[n]+a return memo.setdefault(n,func(n,0))+a return mf @memoize def col(n, a): if n==1: return a if n%2==0: return col(n//2, 1+a) return col(3*n+1, 1+a) def main(): print max((col(i,0),i) for i in xrange(1,1000001)) If I have it right, this should result in fewer calls to the col (short for Collatz) function than turning it into the obvious explicit loop. To get the same gain you'd have to thread the memoization through the function in a probably ugly way. It's certainly doable, but as the saying goes, why trouble your beautiful mind over something like that. The above solution seems pretty natural to me. From no.email at nospam.invalid Tue Jul 28 17:30:23 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Tue, 28 Jul 2015 14:30:23 -0700 Subject: Another tail recursion example References: <87bnewott4.fsf@jester.gateway.sonic.net> Message-ID: <874mkootqo.fsf@jester.gateway.sonic.net> Paul Rubin writes: > Chris Angelico was asking for examples of tail recursion that didn't > have obvious looping equivalents. Here's an Euler problem solution > using memoization and (except that Python doesn't implement it) tail > recursion with an accumulator. Actually that's wrong, it's not really tail recursive because of the addition in the memo combinator, whoops ;-). From ian.g.kelly at gmail.com Tue Jul 28 18:06:23 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 28 Jul 2015 14:06:23 -0800 Subject: Another tail recursion example In-Reply-To: <874mkootqo.fsf@jester.gateway.sonic.net> References: <87bnewott4.fsf@jester.gateway.sonic.net> <874mkootqo.fsf@jester.gateway.sonic.net> Message-ID: On Jul 28, 2015 1:36 PM, "Paul Rubin" wrote: > > Paul Rubin writes: > > Chris Angelico was asking for examples of tail recursion that didn't > > have obvious looping equivalents. Here's an Euler problem solution > > using memoization and (except that Python doesn't implement it) tail > > recursion with an accumulator. > > Actually that's wrong, it's not really tail recursive because of the > addition in the memo combinator, whoops ;-). Not just the addition, but the setdefault call as well. Without the addition that call could be tail-call optimized, but that's not the recursive call; the call to func is. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcarmena at gmail.com Tue Jul 28 18:41:05 2015 From: jcarmena at gmail.com (Javier) Date: Tue, 28 Jul 2015 15:41:05 -0700 (PDT) Subject: Send data to asyncio coroutine In-Reply-To: <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> References: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> Message-ID: El martes, 28 de julio de 2015, 23:18:11 (UTC+2), Javier escribi?: > El martes, 21 de julio de 2015, 15:42:47 (UTC+2), Ian escribi?: > > On Tue, Jul 21, 2015 at 5:31 AM, wrote: > > > Hello, I'm trying to understand and link asyncio with ordinary coroutines. Now I just want to understand how to do this on asyncio: > > > > > > > > > def foo(): > > > data = yield 8 > > > print(data) > > > yield "bye" > > > > > > def bar(): > > > f = foo() > > > n = f.next() > > > print(n) > > > message = f.send("hello") > > > print(message) > > > > > > > > > What is the equivalent for coro.send("some data") in asyncio? > > > > I don't know of any reason why you couldn't do it just like the above. > > However, the exchange would not be asynchronous, if that is your goal. > > > > > coro.send on an asyncio coroutine throws AssertionError: yield from wasn't used with future. > > > > So somehow a future got involved where it shouldn't have been. What > > was the actual code that you tried to run? > > > > Note that while "yield" and "yield from" look similar, they are quite > > different, and you cannot send to a generator that is currently paused > > at a "yield from". > > > > If you want to emulate bidirectional communication similar to > > coro.send asynchronously, I think you'll need to use Futures to > > mediate, something like this (lightly tested): > > > > @asyncio.coroutine > > def foo(fut): > > data, fut = yield from send_to_future(8, fut) > > print("foo", data) > > fut.set_result("bye") > > > > @asyncio.coroutine > > def bar(): > > n, fut = yield from start_coro(foo) > > print("bar", n) > > message = yield from send_to_future("hello", fut) > > print("bar", message) > > > > def start_coro(coro): > > future = asyncio.Future() > > asyncio.async(coro(future)) > > return future > > > > def send_to_future(data, future): > > new_future = asyncio.Future() > > future.set_result((data, new_future)) > > return new_future > > > > > Hello again. I have been investigating a bit your example. I don't understand why I can't write something like this: > > -------- > > import asyncio > > def foo(): > print("start foo") > try: > while True: > val = yield > print("foo:", val) > yield from asyncio.sleep(3) > except GeneratorExit: > print("foo closed") > print("exit foo") > > def bar(next): > print("start bar") > next.send(None) > try: > while True: > val = yield > next.send("bar/"+val) > except GeneratorExit: > print("bar closed") > print("exit bar") > > def fun(next): > next.send(None) > for e in ["hello", "world", "I'm", "pythonist"]: > next.send(e) > > @asyncio.coroutine > def run(): > fun(bar(foo())) > > loop = asyncio.get_event_loop() > loop.run_until_complete(run()) > loop.close() > > ------- > > The expected output is: > > start bar > start foo > foo: bar/hello > foo: bar/world > foo: bar/I'm > foo: bar/phytonist > bar closed > exit bar > foo closed > exit foo > > But the yield from asyncio.sleep(3) call raises AssertionError, however it's inside a Task! > I think this is a big flaw in python/asyncio design. I think that force the developer to 'yield from' all function calls to keep async capabilities is a big mistake, it should be more flexible, like this: import asyncio @asyncio.coroutine fun non_blocking_io(): """ Everybody knows I'm doing non blocking IO """ ... fun foo(): """ I invoke functions that do IO stuff """ data = yield from non_blocking_io() yield from store_data_db(data) ... fun bar(): """ I don't know what foo implementation does """ foo() asyncio.async(bar()) Does python 3.5 await/async solve this? From ian.g.kelly at gmail.com Tue Jul 28 19:06:23 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 28 Jul 2015 15:06:23 -0800 Subject: Send data to asyncio coroutine In-Reply-To: <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> References: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> Message-ID: On Tue, Jul 28, 2015 at 1:17 PM, Javier wrote: > Hello again. I have been investigating a bit your example. I don't understand why I can't write something like this: > > -------- > > import asyncio > > def foo(): > print("start foo") > try: > while True: > val = yield > print("foo:", val) > yield from asyncio.sleep(3) > except GeneratorExit: > print("foo closed") > print("exit foo") > > def bar(next): > print("start bar") > next.send(None) > try: > while True: > val = yield > next.send("bar/"+val) > except GeneratorExit: > print("bar closed") > print("exit bar") > > def fun(next): > next.send(None) > for e in ["hello", "world", "I'm", "pythonist"]: > next.send(e) > > @asyncio.coroutine > def run(): > fun(bar(foo())) > > loop = asyncio.get_event_loop() > loop.run_until_complete(run()) > loop.close() Because "yield from asyncio.sleep(3)" doesn't magically pause the coroutine as you want it to. It yields a future, which is meant to be yielded back up the coroutine chain to the event loop. The event loop would then resume the coroutine once the future is done, which in the case of asyncio.sleep will happen after the sleep timer completes. In your example, the future never makes it back to the event loop. asyncio.sleep yields the future to foo, and since foo is suspended by a yield from, foo yields the future to bar, where it is the result of the next.send call. The return value of next.send is ignored, so the future just gets dropped on the floor at this point. bar yields to fun, which sends bar the next string in its list, "world". bar sends "world" to foo, and since foo is still suspended by a yield from, it sends "world" on to the asyncio.sleep future. Not a new asyncio.sleep future, but the same one that it's still yielding from. The future then realizes that something is wrong, because its generator code is running again but it doesn't have a result yet, so it throws that AssertionError. If you want the yield from in foo to work properly, then you need to make sure that the future gets back to the event loop, and if you do that in some tricky way other than a yield from chain, you'll also need to make sure that you're not trying to send it more data before foo has resumed. > I think this is a big flaw in python/asyncio design. I don't entirely disagree. I think that the implementation of async coroutines on top of synchronous coroutines on top of generators is overly clever and results in a somewhat leaky abstraction and a fair amount of confusion. From ian.g.kelly at gmail.com Tue Jul 28 19:20:27 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 28 Jul 2015 15:20:27 -0800 Subject: Send data to asyncio coroutine In-Reply-To: References: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> Message-ID: On Tue, Jul 28, 2015 at 2:41 PM, Javier wrote: > I think that force the developer to 'yield from' all function calls to keep async capabilities is a big mistake, it should be more flexible, like this: > > import asyncio > > @asyncio.coroutine > fun non_blocking_io(): > """ Everybody knows I'm doing non blocking IO """ > ... > > fun foo(): > """ I invoke functions that do IO stuff """ > data = yield from non_blocking_io() > yield from store_data_db(data) > ... > > fun bar(): > """ I don't know what foo implementation does """ > foo() > > asyncio.async(bar()) Do you have a proposal for implementing this? What does "yield from" actually do here? How does the event loop know that foo is waiting for something and what it is waiting for? > Does python 3.5 await/async solve this? Yes and no. await is basically equivalent to yield from with extra validation, so you still can't use them like what you have above. But native coroutines are also clearly not generators as they lack __next__ and __iter__ methods, so maybe there will be less temptation to try to use them without using await / yield from. From ltc.hotspot at gmail.com Tue Jul 28 19:38:15 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Tue, 28 Jul 2015 23:38:15 +0000 Subject: =?utf-8?Q?String_Attribute?= Message-ID: <55b81292.aaf5420a.ff2b1.4bb8@mx.google.com> Hi Everyone: What is the source of the syntax error to the String Attribute? Go to the following URL links and view a copy of the raw data file code and sample data: 1.) http://tinyurl.com/p2xxxhl 2.) http://tinyurl.com/nclg6pq Here is the desired output: stephen.marquard at uct.ac.za louis at media.berkeley.edu .... Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Jul 28 20:08:21 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 29 Jul 2015 10:08:21 +1000 Subject: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? In-Reply-To: References: Message-ID: On Tue, Jul 28, 2015 at 11:55 PM, Victor Hooi wrote: > I have a line that looks like this: > > 14 *0 330 *0 760 411|0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m 1538 ComputedCartRS PRI 09:40:26 > > I'd like to split this line on multiple separators - in this case, consecutive whitespace, as well as the pipe symbol (|). Correct me if I'm misanalyzing this, but it sounds to me like a simple transform-then-split would do the job: f.replace("|"," ").split() Turn those pipe characters into spaces, then split on whitespace. Or, reading it differently: Declare that pipe is another form of whitespace, then split on whitespace. Python lets you declare anything you like, same as mathematics does :) ChrisA From daixtr at gmail.com Tue Jul 28 21:18:52 2015 From: daixtr at gmail.com (daixtr) Date: Tue, 28 Jul 2015 18:18:52 -0700 (PDT) Subject: ctypes for AIX In-Reply-To: References: <9C240725D2ABD949A80B46DD93AB107042E8D44101@XCH-NW-08V.nw.nos.boeing.com> <50697b2c1001240630r33845a1bl7f94b40a4f0c4436@mail.gmail.com> Message-ID: I'm facing the same issue. No 'ctypes' in python 2.6/2.7 that i'm able to succesfully install via an AIX ppc rpm package. what's the story here? On Friday, 22 April 2011 22:30:07 UTC+8, Anssi Saari wrote: > "Waddle, Jim" writes: > > > I do not have sufficient knowledge to know how to fix this. I would think that this error somehow is related to compiling on aix. If you have any suggestions on how to correct this problem , I would appreciate it > > I'd have to guess your main problem is not using gcc to compile. From > a quick look, that's what the guys at the pware site did. From joel.goldstick at gmail.com Tue Jul 28 21:28:24 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Tue, 28 Jul 2015 21:28:24 -0400 Subject: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? In-Reply-To: References: Message-ID: +1 Chris On Tue, Jul 28, 2015 at 8:08 PM, Chris Angelico wrote: > On Tue, Jul 28, 2015 at 11:55 PM, Victor Hooi wrote: >> I have a line that looks like this: >> >> 14 *0 330 *0 760 411|0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m 1538 ComputedCartRS PRI 09:40:26 >> >> I'd like to split this line on multiple separators - in this case, consecutive whitespace, as well as the pipe symbol (|). > > Correct me if I'm misanalyzing this, but it sounds to me like a simple > transform-then-split would do the job: > > f.replace("|"," ").split() > > Turn those pipe characters into spaces, then split on whitespace. Or, > reading it differently: Declare that pipe is another form of > whitespace, then split on whitespace. Python lets you declare anything > you like, same as mathematics does :) > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com From rustompmody at gmail.com Tue Jul 28 22:41:55 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Tue, 28 Jul 2015 19:41:55 -0700 (PDT) Subject: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? In-Reply-To: References: Message-ID: <153c2ad1-a5c7-4ac0-86a4-0e62cd2a92cd@googlegroups.com> On Wednesday, July 29, 2015 at 6:45:45 AM UTC+5:30, Chris Angelico wrote: > On Tue, Jul 28, 2015 at 11:55 PM, Victor Hooi wrote: > > I have a line that looks like this: > > > > 14 *0 330 *0 760 411|0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m 1538 ComputedCartRS PRI 09:40:26 > > > > I'd like to split this line on multiple separators - in this case, consecutive whitespace, as well as the pipe symbol (|). > > Correct me if I'm misanalyzing this, but it sounds to me like a simple > transform-then-split would do the job: > > f.replace("|"," ").split() > > Turn those pipe characters into spaces, then split on whitespace. Or, > reading it differently: Declare that pipe is another form of > whitespace, then split on whitespace. Python lets you declare anything > you like, same as mathematics does :) I dont see how anything can beat MRABs in declarativeness, neatness succinctness s= "14 *0 330 *0 760 411|0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30|0 0|1 19m 97m 1538 ComputedCartRS PRI 09:40:26" >>> split('[ |]+', s) ['14', '*0', '330', '*0', '760', '411', '0', '0', '770g', '1544g', '117g', '1414', 'computedshopcartdb:103.5%', '0', '30', '0', '0', '1', '19m', '97m', '1538', 'ComputedCartRS', 'PRI', '09:40:26'] And if you dont mind two steps here is another longer-looking but more straightforward (IMHO of course): >>> [z for y in s.split() for z in y.split('|')] ['14', '*0', '330', '*0', '760', '411', '0', '0', '770g', '1544g', '117g', '1414', 'computedshopcartdb:103.5%', '0', '30', '0', '0', '1', '19m', '97m', '1538', 'ComputedCartRS', 'PRI', '09:40:26'] From tjreedy at udel.edu Tue Jul 28 22:47:11 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 28 Jul 2015 22:47:11 -0400 Subject: Another tail recursion example In-Reply-To: <87bnewott4.fsf@jester.gateway.sonic.net> References: <87bnewott4.fsf@jester.gateway.sonic.net> Message-ID: On 7/28/2015 5:28 PM, Paul Rubin wrote: > Chris Angelico was asking for examples of tail recursion that didn't > have obvious looping equivalents. Since there is a mechanical procedure for producing the equivalent *under the assumption that the function name will not be rebound*, he is effectively asking for a unicorn. > Here's an Euler problem solution using memoization and > (except that Python doesn't implement it) > tail recursion with an accumulator. Python does tail recursion (and tail calls) just fine until stack space runs out. What it does not do is automatic tail call or tail recursion conversion/elimination. The example below illustrate > # Solution to Euler problem 14, using memoization > # https://projecteuler.net/problem=14 > > import sys > sys.setrecursionlimit(10000) > > def memoize(func): > def mf(n, a, func=func, memo={}): > if n in memo: return memo[n]+a > return memo.setdefault(n,func(n,0))+a > return mf > > @memoize > def col(n, a): > if n==1: return a > if n%2==0: return col(n//2, 1+a) > return col(3*n+1, 1+a) > > def main(): > print max((col(i,0),i) for i in xrange(1,1000001)) (col(13,0) returns 9, but the chain has 10 items. Makes no difference for the problem as stated.) Because Python allows names in python-coded modules to be rebound, including from other modules, and because names in python-coded function are resolved to objects only when the name is encountered at runtime, 'recursiveness' is not an operational property of python-coded functions. It is only an operational property of a particular call at a particular time. If one wants to guarantee that a function operates 'recursively', in the sense of continuing at the top of the function with parameters rebound to altered arguments, then one should use iterative rather than recursive syntax. > If I have it right, this should result in fewer calls to the col (short > for Collatz) function than turning it into the obvious explicit loop. So you should be glad that Python does *not* automatically replace the apparently-but-not-really-recursive tail call with an internal jump (ie, tail recursion elimination). > To get the same gain you'd have to thread the memoization through the > function in a probably ugly way. Yes and no. If one is computing a typical f(n) = g(f(n-1)) recursion, such as factorial, for 0, 1, 2, ..., the cache should be a list rather than a dict. A smart cache will skip over values already computed. Here is an intertwined version that you probably consider ugly. It directly accesses a nonlocal cache from a closure instead of bouncing back and forth between function and memo wrapper. def _fac(): cache = [1, 1] csize = 2 def _(n): nonlocal csize for i in range(csize, n+1): cache.append(cache[-1] * i) csize += 1 return cache[n] return _ fac = _fac() However, when one wants to generate and save an indefinite number of values for a function in f(0), f(1), ... order, then in Python one should use a generator. It is easy to combine a specific generator with a generic cache. class Gen_memo(list): def __init__(self, genf): self.next = genf().__next__ def __call__(self, n): for i in range(self.__len__(), n+1): self.append(self.next()) return self[n] @Gen_memo def fac2(): n, fac = 0, 1 while True: yield fac n += 1 fac *= n fac and fac2 pass this test: for n in (1,2,6,3,5,7,4,5): print(n, fac(n), fac2(n)) > It's certainly doable, but as the > saying goes, why trouble your beautiful mind over something like that. I consider fac2 above to be more 'pythonic' in using a generator rather than a pseudo-tail-recursive function. Some people like faster functions. > The above solution seems pretty natural to me. I agree for this function, which is somewhat unusual. -- Terry Jan Reedy From rustompmody at gmail.com Tue Jul 28 22:52:21 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Tue, 28 Jul 2015 19:52:21 -0700 (PDT) Subject: Send data to asyncio coroutine In-Reply-To: References: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> Message-ID: On Wednesday, July 29, 2015 at 4:37:22 AM UTC+5:30, Ian wrote: > I don't entirely disagree. I think that the implementation of async > coroutines on top of synchronous coroutines on top of generators is > overly clever and results in a somewhat leaky abstraction and a fair > amount of confusion. Hear Hear! I think the 'overly clever' started with yield becoming an expression. At an operational level coroutines and generators are very similar At a conceptual level they are quite apart: coroutines generalize subroutines whereas generators generalize lists to possibly infinite, possibly incomplete lists From rustompmody at gmail.com Tue Jul 28 23:35:15 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Tue, 28 Jul 2015 20:35:15 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> Message-ID: <07752be2-63fd-4dfa-936b-ff6a58b12b72@googlegroups.com> A bizarre current gnus sob-story brought me back to this thread: http://lists.gnu.org/archive/html/help-gnu-emacs/2015-07/msg00738.html Starts here http://lists.gnu.org/archive/html/help-gnu-emacs/2015-07/msg00591.html On Sunday, July 26, 2015 at 4:13:17 PM UTC+5:30, Jussi Piitulainen wrote: > Rustom Mody writes: > > On Sunday, July 26, 2015 at 2:06:00 PM UTC+5:30, Marko Rauhamaa wrote: > > >> What would you like to achieve, exactly? > > > > Some attitude correction? > > With all respect, take your own advice. And use an editor that works for > you. Sorry if I seemed insulting to you and/or the emacs-devs. I meant to say attitude of *general emacs users* is ridiculous. Try out emacs stackexchange and tell me] Here is a classic flamewar from one 'emacs-oldbie' ranting against changes: http://ergoemacs.org/misc/Mark_Crispin_emacs_line_wrap_rant_2011-06-03.txt Some snippets: --------------------------------- - Why should users - who presumably have work to do - be obliged to do this? [find surprises in new versions] - It sounds like Microsoft Word is more suitable for the sort of work that you do. Perhaps you ought to use Word instead of seeking to make emacs become more like Word. - It does no good whatsoever to tell me that I should get used to the change. Other machines don't have that change. Some are still in emacs 18?. Others are bleeding edge. - I should not have to customize emacs so that CTRL/A, CTRL/E, CTRL/N, and CTRL/P continue to work the way they've done since the mid-1970s. etc etc -------------------------------- ? emacs 18 dates from around 1992 (!!) The whole point of the rant being that (some old fart thinks that) emacs should stay the same as it was 25 years ago and is going to scream hellfire if a single keystroke changes. From dieter at handshake.de Wed Jul 29 01:52:28 2015 From: dieter at handshake.de (dieter) Date: Wed, 29 Jul 2015 07:52:28 +0200 Subject: What happens when python seeks a text file References: <22f8fb9f.10135.14ed1d210fb.Coremail.lijpbasin@126.com> Message-ID: <876153v7c3.fsf@handshake.de> "=?GBK?B?wO68zsX0?=" writes: > Hi, I tried using seek to reverse a text file after reading about the > subject in the documentation: > > https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects > > https://docs.python.org/3/library/io.html#io.TextIOBase.seek > ... > However, an exception is raised if a file with the same content encoded in > GBK is provided: > > $ ./reverse_text_by_seek3.py Moon-gbk.txt > [0, 7, 8, 19, 21, 32, 42, 53, 64] > ?????????? > ?????????? > Traceback (most recent call last): > File "./reverse_text_by_seek3.py", line 21, in > print(f.readline(), end="") > UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 8: illegal multibyte sequence The "seek" works on byte level while decoding works on character level where some characters can be composed of several bytes. The error you observe indicates that you have "seeked" somewhere inside a character, not at a legal character beginning. That you get an error for "gbk" and not for "utf-8" is a bit of an "accident". The same problem can happen for "utf-8" but the probability might by sligtly inferior. Seek only to byte position for which you know that they are also character beginnings -- e.g. line beginnings. From dieter at handshake.de Wed Jul 29 02:01:54 2015 From: dieter at handshake.de (dieter) Date: Wed, 29 Jul 2015 08:01:54 +0200 Subject: Using requests with an Authorization header? References: Message-ID: <871tfrv6wd.fsf@handshake.de> devnzyme1 at use.startmail.com writes: > Has anyone ever used an authorization header with the requests library? I tried using: > > >>>> from requests.auth import HTTPBasicAuth >>>> requests.get('https://api.github.com/user', auth=HTTPBasicAuth('user', 'pass') > > from their docs online but that's not working and I don't see anything about authorization headers We are using it like this (successfully): requests.post(url, data=data, params=params, auth=(user, passwd), timeout=timeout, verify=verify, headers=jsonHeaders, ) i.e. "user" and "password" are not wrapped into an "HTTPBasicAuth" but directly passed as tuple. However, I expect that it would also work with an "HTTPBasicAuth" wrapping. Note that you must pass the real username and password, not the literals "'user'" and "'pass'". From johnreysecoya at gmail.com Wed Jul 29 03:20:27 2015 From: johnreysecoya at gmail.com (john) Date: Wed, 29 Jul 2015 00:20:27 -0700 (PDT) Subject: My code won't work if I double click the saved file Message-ID: <04881038-a14e-4469-be33-7fcd77496f67@googlegroups.com> I have windows 8 running on my computer and I think I downloaded python 2 and 3 simultaneously or I think my computer has built in python 2 and I downloaded python 3. And now when I ran my code in IDLE, the code works fine but when I save my program and double click the save file, it will run but it doesn't worked like it used to work in IDLE. Can someone explain the possible problem I'm currently facing? I just want my program to run perfectly in both IDLE and when I double click the saved file. I posted my question in stackoverflow but I didn't find an answer. http://stackoverflow.com/questions/31692156/i-think-my-computer-has-built-in-python-2-and-i-installed-python-3 From cs at zip.com.au Wed Jul 29 03:58:55 2015 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 29 Jul 2015 17:58:55 +1000 Subject: What happens when python seeks a text file In-Reply-To: <876153v7c3.fsf@handshake.de> References: <876153v7c3.fsf@handshake.de> Message-ID: <20150729075855.GA54137@cskk.homeip.net> On 29Jul2015 07:52, dieter wrote: >"=?GBK?B?wO68zsX0?=" writes: >> Hi, I tried using seek to reverse a text file after reading about the >> subject in the documentation: >> https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects >> https://docs.python.org/3/library/io.html#io.TextIOBase.seek >> ... >> However, an exception is raised if a file with the same content encoded in >> GBK is provided: >> $ ./reverse_text_by_seek3.py Moon-gbk.txt >> [0, 7, 8, 19, 21, 32, 42, 53, 64] >> ?????????? >> ?????????? >> Traceback (most recent call last): >> File "./reverse_text_by_seek3.py", line 21, in >> print(f.readline(), end="") >> UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 8: illegal multibyte sequence > >The "seek" works on byte level while decoding works on character level >where some characters can be composed of several bytes. > >The error you observe indicates that you have "seeked" somewhere >inside a character, not at a legal character beginning. > >That you get an error for "gbk" and not for "utf-8" is a bit of >an "accident". The same problem can happen for "utf-8" but the probability >might by sligtly inferior. > >Seek only to byte position for which you know that they are also >character beginnings -- e.g. line beginnings. You may also keep in mind that while you can't do arithmetic on these things without knowning the length of the _encoded_ text, what you can do is note the value returned by f.tell() whenever you like. If you are reading a text file (== an encoding of the text in a specific character set, be it GBK or UTF8) then after any read you will be on a character boundary, and can return there. Actually, on reflection, there may be some character encodings where this is not true; I think some encodings of Japanese employ some kind of mode shift sequence, so you might need knowledge of those - a plain seek() might not be enough. But for any encoding where the character encoded at a spot is everything needed then a seek() to any position obtained by tell() should be reliable. In short: line beginnings are not the only places where you can safely seek. Though they may be conveniently available. Cheers, Cameron Simpson From saber.chelaghma at gmail.com Wed Jul 29 08:12:19 2015 From: saber.chelaghma at gmail.com (saber.chelaghma at gmail.com) Date: Wed, 29 Jul 2015 05:12:19 -0700 (PDT) Subject: Use python script to create a part for Abaqus Message-ID: Hi all, I want to create a part in 2D composed by: -A square -Inside the square there is a lot of circles I have a input file .dat where we can find the coordinates of the circles' centers and their radius. I want to create this part using a python script and import it in Abaqus/CAE. Does anyone have an idea (or examples) on how I can do this ? Regards, Saber From davide.darenzo at gmail.com Wed Jul 29 08:52:29 2015 From: davide.darenzo at gmail.com (Davide D'Arenzo) Date: Wed, 29 Jul 2015 14:52:29 +0200 Subject: Fwd: Request for Information XML-RPC (Python) In-Reply-To: References: Message-ID: Goodmorning dear Team, I'm Davide D'Arenzo and I'm working with Python using the standard xmlrpclib library communicating between a JavaServer (that host xmlrpc server) and my python client. I have a problem and I hope that you should solve my issue. I want to send a DOM instance through xmlrpc protocol. I know that the istance are impossible to manage by xmlrpclib library in Python but this is what I need. I'm trying to understand why is not possible to marshal the class Nodelist and I recognize that the target function is dumps(self, values) in class Marshaller because she couldn't find this type of Python Object. For Instance, the Fault code is this: Traceback (most recent call last): File "testRestSwi.py", line 31, in conn.xxx.xxx(dom3,"xxx","xxx") File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__ return self.__send(self.__name, args) File "/usr/lib/python2.7/xmlrpclib.py", line 1572, in __request allow_none=self.__allow_none) File "/usr/lib/python2.7/xmlrpclib.py", line 1085, in dumps data = m.dumps(params) File "/usr/lib/python2.7/xmlrpclib.py", line 632, in dumps dump(v, write) File "/usr/lib/python2.7/xmlrpclib.py", line 654, in __dump f(self, value, write) File "/usr/lib/python2.7/xmlrpclib.py", line 756, in dump_instance self.dump_struct(value.__dict__, write) File "/usr/lib/python2.7/xmlrpclib.py", line 735, in dump_struct dump(v, write) File "/usr/lib/python2.7/xmlrpclib.py", line 646, in __dump raise TypeError, "cannot marshal %s objects" % type(value) TypeError: cannot marshal objects Now, I would want to solve this problem and for sure there are many solutions. But I don't know how to develop or implement something within the xmlrpclib in order to avoid the "marshalling" problem. Keep in mind that the file object must be a DOM, is aim, uncheangeable. For Instance, I'm developing the following: import xml.dom.minidom as parser import xmlrpclib dom3 = parser.parseString("xxx") conn = xmlrpclib.ServerProxy('xxx',allow_none=True,verbose=True) conn.xxx.xxx(dom3,"xxx","xxx") #<--- The problem Here. Might you help me? Thank you a lot. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanshuell at gmail.com Wed Jul 29 09:19:02 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Wed, 29 Jul 2015 06:19:02 -0700 (PDT) Subject: Run Python Script; Nothing Happens Message-ID: I am using Spyder Python 2.7. I'm running this sample code. import numpy as np import numpy.random as npr import matplotlib.pyplot as plt S0 = 100 r = 0.05 sigma = 0.25 T = 30 / 365. I = 10000 ST = S0 * np.exp((r - 0.5 * sigma ** 2) * T + sigma * np.sqrt(T) * npr.standard_normal(I)) R_gbm = np.sort(ST - S0) plt.hist(R_gbm, bins=50) plt.xlabel('absolute return') plt.ylabel('frequency') plt.grid(True) I found it in a book, and I'm trying to run various samples of code, in an effort to learn Python. So, I click the debug button, and this is what I get. > c:\users\rshuell001\untitled12.py(1)() -> import numpy as np (Pdb) It seems like it doesn't really do anything. So, I click the exit debug button and then click the run button and nothing happens. I get nothing at all. In the book, the author got a graph. I get nothing. I think, and I could be totally wrong, Python is sending something to a Console, but I can't tell where it goes. I opened every Console I could find, and I still see nothing happening whatsoever. Any idea what's wrong here? From toddrjen at gmail.com Wed Jul 29 09:25:22 2015 From: toddrjen at gmail.com (Todd) Date: Wed, 29 Jul 2015 15:25:22 +0200 Subject: Run Python Script; Nothing Happens In-Reply-To: References: Message-ID: On Wed, Jul 29, 2015 at 3:19 PM, ryguy7272 wrote: > I am using Spyder Python 2.7. I'm running this sample code. > import numpy as np > import numpy.random as npr > import matplotlib.pyplot as plt > S0 = 100 > r = 0.05 > sigma = 0.25 > T = 30 / 365. > I = 10000 > ST = S0 * np.exp((r - 0.5 * sigma ** 2) * T + sigma * np.sqrt(T) * > npr.standard_normal(I)) > R_gbm = np.sort(ST - S0) > plt.hist(R_gbm, bins=50) > plt.xlabel('absolute return') > plt.ylabel('frequency') > plt.grid(True) > > I found it in a book, and I'm trying to run various samples of code, in an > effort to learn Python. So, I click the debug button, and this is what I > get. > > c:\users\rshuell001\untitled12.py(1)() > -> import numpy as np > (Pdb) > > It seems like it doesn't really do anything. So, I click the exit debug > button and then click the run button and nothing happens. I get nothing at > all. In the book, the author got a graph. I get nothing. I think, and I > could be totally wrong, Python is sending something to a Console, but I > can't tell where it goes. I opened every Console I could find, and I still > see nothing happening whatsoever. > > Any idea what's wrong here? > > First, you need to call plt.show() at the end in order to see anything. Second, when you run the debugger it immediately waits for you to tell it what to do. So you need to tell it continue running. But normally you wouldn't run it in the debugger. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanshuell at gmail.com Wed Jul 29 09:47:51 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Wed, 29 Jul 2015 06:47:51 -0700 (PDT) Subject: Run Python Script; Nothing Happens In-Reply-To: References: Message-ID: <8ab22764-19db-4643-ac92-f1ca85022e7f@googlegroups.com> On Wednesday, July 29, 2015 at 9:19:19 AM UTC-4, ryguy7272 wrote: > I am using Spyder Python 2.7. I'm running this sample code. > import numpy as np > import numpy.random as npr > import matplotlib.pyplot as plt > S0 = 100 > r = 0.05 > sigma = 0.25 > T = 30 / 365. > I = 10000 > ST = S0 * np.exp((r - 0.5 * sigma ** 2) * T + sigma * np.sqrt(T) * npr.standard_normal(I)) > R_gbm = np.sort(ST - S0) > plt.hist(R_gbm, bins=50) > plt.xlabel('absolute return') > plt.ylabel('frequency') > plt.grid(True) > > I found it in a book, and I'm trying to run various samples of code, in an effort to learn Python. So, I click the debug button, and this is what I get. > > c:\users\rshuell001\untitled12.py(1)() > -> import numpy as np > (Pdb) > > It seems like it doesn't really do anything. So, I click the exit debug button and then click the run button and nothing happens. I get nothing at all. In the book, the author got a graph. I get nothing. I think, and I could be totally wrong, Python is sending something to a Console, but I can't tell where it goes. I opened every Console I could find, and I still see nothing happening whatsoever. > > Any idea what's wrong here? YOU ARE RIGHT!! THAT WORKED PERFECT!! I wonder why the author of the book didn't put that in there. Thanks. From ryanshuell at gmail.com Wed Jul 29 09:58:58 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Wed, 29 Jul 2015 06:58:58 -0700 (PDT) Subject: How to Calculate NPV? Message-ID: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> I am using Spyder Python 2.7. I'm running this sample code. import scipy as sp cashflows=[50,40,20,10,50] npv=sp.npv(0.1,cashflows) round(npv,2) Now, I'm trying to get the NPV, and I don't see any obvious way to get it. The author of the book that I'm reading gets 144.56. I think that's wrong, but I don't know for sure, as Python won't do any calculation at all. It's easy to enter code and run it, but I can't tell how to get Python to actually DO the calculation. Any idea what I'm doing wrong? From saber.chelaghma at gmail.com Wed Jul 29 10:09:00 2015 From: saber.chelaghma at gmail.com (Saber Ayoub Chelaghma) Date: Wed, 29 Jul 2015 07:09:00 -0700 (PDT) Subject: How to Calculate NPV? In-Reply-To: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> References: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> Message-ID: On Wednesday, July 29, 2015 at 3:59:10 PM UTC+2, ryguy7272 wrote: > I am using Spyder Python 2.7. I'm running this sample code. > > import scipy as sp > cashflows=[50,40,20,10,50] > npv=sp.npv(0.1,cashflows) > round(npv,2) > > > Now, I'm trying to get the NPV, and I don't see any obvious way to get it. > The author of the book that I'm reading gets 144.56. I think that's wrong, but I don't know for sure, as Python won't do any calculation at all. It's easy to enter code and run it, but I can't tell how to get Python to actually DO the calculation. > > Any idea what I'm doing wrong? Hi, Just do at the end of your scrip: print(npv) Regards From ryanshuell at gmail.com Wed Jul 29 10:21:22 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Wed, 29 Jul 2015 07:21:22 -0700 (PDT) Subject: How to Calculate NPV? In-Reply-To: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> References: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> Message-ID: <757d1a56-fc27-4996-acff-8bb7e07204d6@googlegroups.com> On Wednesday, July 29, 2015 at 9:59:10 AM UTC-4, ryguy7272 wrote: > I am using Spyder Python 2.7. I'm running this sample code. > > import scipy as sp > cashflows=[50,40,20,10,50] > npv=sp.npv(0.1,cashflows) > round(npv,2) > > > Now, I'm trying to get the NPV, and I don't see any obvious way to get it. > The author of the book that I'm reading gets 144.56. I think that's wrong, but I don't know for sure, as Python won't do any calculation at all. It's easy to enter code and run it, but I can't tell how to get Python to actually DO the calculation. > > Any idea what I'm doing wrong? PERFECT!! SO SIMPLE!! I don't know why the author didn't do that in the book. Thanks! From hemla21 at gmail.com Wed Jul 29 10:23:07 2015 From: hemla21 at gmail.com (Heli Nix) Date: Wed, 29 Jul 2015 07:23:07 -0700 (PDT) Subject: Optimizing if statement check over a numpy value In-Reply-To: References: <65c45685-dee1-41f8-a16a-7a062f4e7b02@googlegroups.com> Message-ID: On Thursday, July 23, 2015 at 1:43:00 PM UTC+2, Jeremy Sanders wrote: > Heli Nix wrote: > > > Is there any way that I can optimize this if statement. > > Array processing is much faster in numpy. Maybe this is close to what you > want > > import numpy as N > # input data > vals = N.array([42, 1, 5, 3.14, 53, 1, 12, 11, 1]) > # list of items to exclude > exclude = [1] > # convert to a boolean array > exclbool = N.zeros(vals.shape, dtype=bool) > exclbool[exclude] = True > # do replacement > ones = vals==1.0 > # Note: ~ is numpy.logical_not > vals[ones & (~exclbool)] = 1e-20 > > I think you'll have to convert your HDF array into a numpy array first, > using numpy.array(). > > Jeremy Dear all, I tried the sorted python list, but this did not really help the runtime. I haven?t had time to check the sorted collections. I solved my runtime problem by using the script from Jeremy up here. It was a life saviour and it is amazing how powerful numpy is. Thanks a lot Jeremy for this. By the way, I did not have to do any array conversion. The array read from hdf5 file using h5py is already a numpy array. The runtime over an array of around 16M reduced from around 12 hours (previous script) to 3 seconds using numpy on the same machine. Thanks alot for your help, From jeanmichel at sequans.com Wed Jul 29 10:23:20 2015 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 29 Jul 2015 16:23:20 +0200 (CEST) Subject: line error on no. 7 In-Reply-To: <55b7e499.c590420a.2c00.3f74@mx.google.com> Message-ID: <1057631477.698271.1438179800046.JavaMail.root@sequans.com> ----- Original Message ----- > From: "ltc hotspot" > To: "python-list at python.org" > Sent: Tuesday, 28 July, 2015 10:21:59 PM > Subject: line error on no. 7 > Hi Everyone, > I'm writing python code to read a data text file, split the file into > a list of words using the split(function) and to print the results > in alphabetical order. > The raw python code is located at http://tinyurl.com/oua9uqx > The sample data is located at > http://tinyurl.com/odt9nhe > Desired Output: ['Arise', 'But', 'It', 'Juliet', 'Who', 'already', > 'and', 'breaks', 'east', 'envious', 'fair', 'grief', 'is', 'kill', > 'light', 'moon', 'pale', 'sick', 'soft', 'sun', 'the', 'through', > 'what', 'window', 'with', 'yonder'] > There is a line error on no. 7 > What is the cause of this error? > Regards, > Hal > Sent from Surface Hi, It's better to post the code with your question. Python 2.7 fname = raw_input("Enter file name: ") fh = open(fname) lst = list() for line in fh: if fh == list: continue list.split() list.append sorted("fh") print line.rstrip() The main issue is that you've misspelled 'lst' in the for loop. You've used 'list' instead. 'list' is a built-in constructor for lists. You cannot split it. I'm also not sure what """ if fh == list:continue """ is supposed to achieve. Try the following untested code: words = [] for line in open(fname): # what if fname does not exist ? words.extend(line.split()) print sorted(words) Regards, JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From jcarmena at gmail.com Wed Jul 29 10:24:12 2015 From: jcarmena at gmail.com (Javier) Date: Wed, 29 Jul 2015 07:24:12 -0700 (PDT) Subject: Send data to asyncio coroutine In-Reply-To: References: <97b62bfd-8b6d-45f0-8597-7799ba0ea4af@googlegroups.com> <1195c0a3-05b5-4213-92a7-db005ad7d547@googlegroups.com> Message-ID: <0470186c-6afe-4b4b-a355-8f876a0a3193@googlegroups.com> El mi?rcoles, 29 de julio de 2015, 1:07:22 (UTC+2), Ian escribi?: > On Tue, Jul 28, 2015 at 1:17 PM, Javier wrote: > > Hello again. I have been investigating a bit your example. I don't understand why I can't write something like this: > > > > -------- > > > > import asyncio > > > > def foo(): > > print("start foo") > > try: > > while True: > > val = yield > > print("foo:", val) > > yield from asyncio.sleep(3) > > except GeneratorExit: > > print("foo closed") > > print("exit foo") > > > > def bar(next): > > print("start bar") > > next.send(None) > > try: > > while True: > > val = yield > > next.send("bar/"+val) > > except GeneratorExit: > > print("bar closed") > > print("exit bar") > > > > def fun(next): > > next.send(None) > > for e in ["hello", "world", "I'm", "pythonist"]: > > next.send(e) > > > > @asyncio.coroutine > > def run(): > > fun(bar(foo())) > > > > loop = asyncio.get_event_loop() > > loop.run_until_complete(run()) > > loop.close() > > Because "yield from asyncio.sleep(3)" doesn't magically pause the > coroutine as you want it to. It yields a future, which is meant to be > yielded back up the coroutine chain to the event loop. The event loop > would then resume the coroutine once the future is done, which in the > case of asyncio.sleep will happen after the sleep timer completes. > > In your example, the future never makes it back to the event loop. > asyncio.sleep yields the future to foo, and since foo is suspended by > a yield from, foo yields the future to bar, where it is the result of > the next.send call. The return value of next.send is ignored, so the > future just gets dropped on the floor at this point. bar yields to > fun, which sends bar the next string in its list, "world". bar sends > "world" to foo, and since foo is still suspended by a yield from, it > sends "world" on to the asyncio.sleep future. Not a new asyncio.sleep > future, but the same one that it's still yielding from. The future > then realizes that something is wrong, because its generator code is > running again but it doesn't have a result yet, so it throws that > AssertionError. > > If you want the yield from in foo to work properly, then you need to > make sure that the future gets back to the event loop, and if you do > that in some tricky way other than a yield from chain, you'll also > need to make sure that you're not trying to send it more data before > foo has resumed. > > > I think this is a big flaw in python/asyncio design. > > I don't entirely disagree. I think that the implementation of async > coroutines on top of synchronous coroutines on top of generators is > overly clever and results in a somewhat leaky abstraction and a fair > amount of confusion. I see, so I was wrong. I used to see event loop, and yield from as a language improvement but it's actually a library improvement that, as a side effect, prevents you from usign some language features like ordinary generator/coroutine communication. That is a pity. Thank you very much for your time and explanations, now I understand some points. I'll keep on learning asyncio. From jeanmichel at sequans.com Wed Jul 29 10:27:00 2015 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 29 Jul 2015 16:27:00 +0200 (CEST) Subject: Help Command Question In-Reply-To: <55b7b533.ab8c460a.ce4fc.2e2a@mx.google.com> Message-ID: <1612578748.698534.1438180020319.JavaMail.root@sequans.com> ----- Original Message ----- > From: "ltc hotspot" > To: "python-list at python.org" > Sent: Tuesday, 28 July, 2015 6:59:13 PM > Subject: Help Command Question > Hi Everyone, > I'm trying to print a command of list options by using the help > command in the iPython interpreter. Read captured copy of the > printout as follows: > 'Python 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, > 16:44:52) [MSC v. > 1500 64 bit (AMD64)] > Type "copyright", "credits" or "license" for more information. > IPython 3.2.0 -- An enhanced Interactive Python. > Anaconda is brought to you by Continuum Analytics. > Please check out: http://continuum.io/thanks and https://anaconda.org > In [1]: help list > File "", line 1 > help list > ^ > SyntaxError: invalid syntax.' > Question: What is the correct help command? > Regards, > Hal These are very basic questions for which you can find the answer with google. Did you check the ipython documentation ? Anyway, > help(list) or > list? are what you're looking for. JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From ryanshuell at gmail.com Wed Jul 29 10:27:51 2015 From: ryanshuell at gmail.com (ryguy7272) Date: Wed, 29 Jul 2015 07:27:51 -0700 (PDT) Subject: How to Calculate NPV? In-Reply-To: <757d1a56-fc27-4996-acff-8bb7e07204d6@googlegroups.com> References: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> <757d1a56-fc27-4996-acff-8bb7e07204d6@googlegroups.com> Message-ID: <9f04969b-6b6b-4773-a1f1-37e23706aecf@googlegroups.com> On Wednesday, July 29, 2015 at 10:21:35 AM UTC-4, ryguy7272 wrote: > On Wednesday, July 29, 2015 at 9:59:10 AM UTC-4, ryguy7272 wrote: > > I am using Spyder Python 2.7. I'm running this sample code. > > > > import scipy as sp > > cashflows=[50,40,20,10,50] > > npv=sp.npv(0.1,cashflows) > > round(npv,2) > > > > > > Now, I'm trying to get the NPV, and I don't see any obvious way to get it. > > The author of the book that I'm reading gets 144.56. I think that's wrong, but I don't know for sure, as Python won't do any calculation at all. It's easy to enter code and run it, but I can't tell how to get Python to actually DO the calculation. > > > > Any idea what I'm doing wrong? > > PERFECT!! SO SIMPLE!! > I don't know why the author didn't do that in the book. > > Thanks! One last thing, for Excel users, leave out the initial CF. Do the NPV on the other CFs, and then add in the initial CF at the end of the NPV function. It's almost like a PV + 1stCF. I don't know why Excel does it like that... From random832 at fastmail.us Wed Jul 29 10:42:33 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Wed, 29 Jul 2015 10:42:33 -0400 Subject: Gmail eats Python In-Reply-To: References: <201507251634.t6PGYUvo028820@fido.openend.se> <201507251704.t6PH4FNx029638@fido.openend.se> <85twsrn3ob.fsf@benfinney.id.au> Message-ID: <1438180953.3231122.336322001.2C32910F@webmail.messagingengine.com> On Sun, Jul 26, 2015, at 02:43, Ian Kelly wrote: > What Internet standard is being violated by reflowing text content in > the message body? Well, implicitly, text is only supposed to be reflowed when format=flowed is in use, and only then when each physical line of the file ends with a space character. If there were _no_ internet standard on reflowing that would be one thing (new feature whereas the standards are behind the times), but the standard for reflowing is actually well-established (RFC 2646, dated 1999) and there's no real reason for not following it. From random832 at fastmail.us Wed Jul 29 10:51:13 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Wed, 29 Jul 2015 10:51:13 -0400 Subject: Gmail eats Python In-Reply-To: <87d1zfxhpc.fsf@elektro.pacujo.net> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> <87lhe3xn42.fsf@elektro.pacujo.net> <87d1zfxhpc.fsf@elektro.pacujo.net> Message-ID: <1438181473.3233902.336329649.4B869E37@webmail.messagingengine.com> On Sun, Jul 26, 2015, at 07:48, Marko Rauhamaa wrote: > At first, there was only the machine language. Assembly languages > introduced "mnemonics" for the weaklings who couldn't remember the > opcodes by heart. To be fair, x86 is also a particularly terrible example of a machine language, from the perspective of someone imagining being expected to memorize it. Compare it with PDP-11, which had eight registers and eight addressing modes and a whole lot less to memorize (since each of these appears in every instruction as a single octal digit). From larry.martell at gmail.com Wed Jul 29 10:53:12 2015 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 29 Jul 2015 10:53:12 -0400 Subject: Gmail eats Python In-Reply-To: <1438181473.3233902.336329649.4B869E37@webmail.messagingengine.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> <87lhe3xn42.fsf@elektro.pacujo.net> <87d1zfxhpc.fsf@elektro.pacujo.net> <1438181473.3233902.336329649.4B869E37@webmail.messagingengine.com> Message-ID: On Wed, Jul 29, 2015 at 10:51 AM, wrote: > On Sun, Jul 26, 2015, at 07:48, Marko Rauhamaa wrote: >> At first, there was only the machine language. Assembly languages >> introduced "mnemonics" for the weaklings who couldn't remember the >> opcodes by heart. > > To be fair, x86 is also a particularly terrible example of a machine > language, from the perspective of someone imagining being expected to > memorize it. Compare it with PDP-11, which had eight registers and eight > addressing modes and a whole lot less to memorize (since each of these > appears in every instruction as a single octal digit). 6809 was the best machine language. From lac at openend.se Wed Jul 29 11:55:36 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 29 Jul 2015 17:55:36 +0200 Subject: Usage of P(C)ython Logo for Coffee Mug In-Reply-To: Message from deus ex of "Mon, 27 Jul 2015 23:16:26 +0200." References: Message-ID: <201507291555.t6TFtaCs022990@fido.openend.se> In a message of Mon, 27 Jul 2015 23:16:26 +0200, deus ex writes: >Dear sirs or madam, > >I would like to let produce a p(c)ython coffee mug for myself for >non-commerical use. Am I allowed to use your designed logo like: > >https://www.python.org/static/community_logos/python-logo-generic.svg >https://upload.wikimedia.org/wikipedia/de/thumb/c/ce/Cython-logo.svg/640px-Cython-logo.svg.png > >or other versions? > >If you possibly be so kind to provide me a SVG Version please, that I am >allowed to modify and use? > >Thanks in advance. > >Greetings, > >dex You will have to talk to the Cython developers for use of their image -- but I doubt there will be any problem. We have SVG versions here: https://www.python.org/community/logos/ Good luck and have fun, Laura Creighton From lac at openend.se Wed Jul 29 12:13:27 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 29 Jul 2015 18:13:27 +0200 Subject: Python Questions - July 25, 2015 In-Reply-To: Message from BartC of "Tue, 28 Jul 2015 17:45:00 +0100." References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <55b7a9f5$0$1668$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201507291613.t6TGDRPo026982@fido.openend.se> In a message of Tue, 28 Jul 2015 17:45:00 +0100, BartC writes: >On 28/07/2015 17:12, Steven D'Aprano wrote: >> On Tue, 28 Jul 2015 07:46 pm, BartC wrote: >> >>> (I'm still reeling from the size of that Anaconda download. Apparently >>> it contains a whole bunch of stuff, nothing to do with numpy, that I >>> don't need. But one of the listed packages was 'libffi', which is >>> puzzling. This library lets a C-like language call functions with >>> runtime-determined argument types. How would that be used in Python?) >> >> https://en.wikipedia.org/wiki/Libffi > >Yes, I know (I was looking at it myself a few days ago for another >project). But while it might be used for implementing some of Python's >internals, I was wondering what it was doing in a user-level set of >libraries, given that it's mostly a bunch of C code. > >Perhaps they were just padding the list to make it look more impressive. People who use numpy also want to load up their c extensions a whole lot. If you have a hunk of C code (a library, ususually) and you want to call it from your python code, and play with its objects just like they were python objects, this is one of the most common ways to do this. Laura From buzzard at invalid.invalid Wed Jul 29 12:14:40 2015 From: buzzard at invalid.invalid (duncan smith) Date: Wed, 29 Jul 2015 17:14:40 +0100 Subject: How to Calculate NPV? In-Reply-To: <9f04969b-6b6b-4773-a1f1-37e23706aecf@googlegroups.com> References: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> <757d1a56-fc27-4996-acff-8bb7e07204d6@googlegroups.com> <9f04969b-6b6b-4773-a1f1-37e23706aecf@googlegroups.com> Message-ID: <55b8fbf1$0$10731$862e30e2@ngroups.net> On 29/07/15 15:27, ryguy7272 wrote: > On Wednesday, July 29, 2015 at 10:21:35 AM UTC-4, ryguy7272 wrote: >> On Wednesday, July 29, 2015 at 9:59:10 AM UTC-4, ryguy7272 wrote: >>> I am using Spyder Python 2.7. I'm running this sample code. >>> >>> import scipy as sp >>> cashflows=[50,40,20,10,50] >>> npv=sp.npv(0.1,cashflows) >>> round(npv,2) >>> >>> >>> Now, I'm trying to get the NPV, and I don't see any obvious way to get it. >>> The author of the book that I'm reading gets 144.56. I think that's wrong, but I don't know for sure, as Python won't do any calculation at all. It's easy to enter code and run it, but I can't tell how to get Python to actually DO the calculation. >>> >>> Any idea what I'm doing wrong? >> >> PERFECT!! SO SIMPLE!! >> I don't know why the author didn't do that in the book. >> >> Thanks! > > One last thing, for Excel users, leave out the initial CF. Do the NPV on the other CFs, and then add in the initial CF at the end of the NPV function. It's almost like a PV + 1stCF. I don't know why Excel does it like that... > I don't know what Excel does, but the first value shouldn't require any special treatment, 1.1**0 = 1. >>> sum([x/(1.1)**i for i, x in enumerate([50,40,20,10,50])]) 144.55638276074038 >>> Duncan From lac at openend.se Wed Jul 29 12:32:46 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 29 Jul 2015 18:32:46 +0200 Subject: Gmail eats Python In-Reply-To: Message from Rustom Mody of "Tue, 28 Jul 2015 20:35:15 -0700." <07752be2-63fd-4dfa-936b-ff6a58b12b72@googlegroups.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <87d1zgyqgb.fsf@elektro.pacujo.net> <228d9572-6cff-4f89-bd68-e31ecbb8e46a@googlegroups.com> <327a9975-b079-4d44-998d-0d1168ba7a59@googlegroups.com> <87twsrxva6.fsf@elektro.pacujo.net> <2d0388e4-f880-4537-8e18-1d470b2c9620@googlegroups.com> <87pp3fxqn1.fsf@elektro.pacujo.net> <07752be2-63fd-4dfa-936b-ff6a58b12b72@googlegroups.com> Message-ID: <201507291632.t6TGWkvn031297@fido.openend.se> In a message of Tue, 28 Jul 2015 20:35:15 -0700, Rustom Mody writes: >- I should not have to customize emacs so that CTRL/A, CTRL/E, CTRL/N, and >CTRL/P continue to work the way they've done since the mid-1970s. > >etc etc >-------------------------------- >? emacs 18 dates from around 1992 (!!) No, the original one was written in 1976. These control characters are the very basic move characters in emacs. People have always been free to remap them if they want them to do something else, but waking up in the morning and discovering that you cannot move to the front of your current line, to the end ot it, one line up and one line down because somebody has changed this ***for everybody*** would get me quite upset, too. Laura (happy emacs user since 1979) From bc at freeuk.com Wed Jul 29 12:50:37 2015 From: bc at freeuk.com (BartC) Date: Wed, 29 Jul 2015 17:50:37 +0100 Subject: Python Questions - July 25, 2015 In-Reply-To: References: <2adac4ce-976f-4a8a-849d-c76e484eba77@googlegroups.com> <55b7a9f5$0$1668$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 29/07/2015 17:13, Laura Creighton wrote: > In a message of Tue, 28 Jul 2015 17:45:00 +0100, BartC writes: >> On 28/07/2015 17:12, Steven D'Aprano wrote: >>> https://en.wikipedia.org/wiki/Libffi >> >> Yes, I know (I was looking at it myself a few days ago for another >> project). But while it might be used for implementing some of Python's >> internals, I was wondering what it was doing in a user-level set of >> libraries, given that it's mostly a bunch of C code. >> >> Perhaps they were just padding the list to make it look more impressive. > > People who use numpy also want to load up their c extensions a > whole lot. If you have a hunk of C code (a library, ususually) and > you want to call it from your python code, and play with its > objects just like they were python objects, this is one of the > most common ways to do this. If it's in the form where you start by writing along the lines of: import libffi then it must be something very different to what I looked at. (Which seemed to consists of lots of C files, headers and ASM modules, for dozens of different targets and compilers.) I would also expect a foreign-function interface to be built-in, or to have all the details taken care of by an add-on, so that the very low level libffi wouldn't figure at all. -- Bartc From ian.g.kelly at gmail.com Wed Jul 29 13:08:35 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 29 Jul 2015 09:08:35 -0800 Subject: Gmail eats Python In-Reply-To: <1438180953.3231122.336322001.2C32910F@webmail.messagingengine.com> References: <201507251634.t6PGYUvo028820@fido.openend.se> <201507251704.t6PH4FNx029638@fido.openend.se> <85twsrn3ob.fsf@benfinney.id.au> <1438180953.3231122.336322001.2C32910F@webmail.messagingengine.com> Message-ID: On Wed, Jul 29, 2015 at 6:42 AM, wrote: > On Sun, Jul 26, 2015, at 02:43, Ian Kelly wrote: >> What Internet standard is being violated by reflowing text content in >> the message body? > > Well, implicitly, text is only supposed to be reflowed when > format=flowed is in use, and only then when each physical line of the > file ends with a space character. An implicit requirement is not a standard. The whole point of having a standard is to make the requirements formal and explicit. From gordon at panix.com Wed Jul 29 13:32:28 2015 From: gordon at panix.com (John Gordon) Date: Wed, 29 Jul 2015 17:32:28 +0000 (UTC) Subject: AttributeError: LineLogic instance has no attribute 'probe' References: Message-ID: In Cameron Simpson writes: > >Since you haven't posted the actual complete code, we can only guess > >at the problem. > > > >My guess is that you have two different definitions of the LineLogic > >class, one of them lacking the probe attribute. > Alternatively, if the code he did quote is accurate, he may have not indented > the definition of __init__. Example: > class LineLogic(object): > ''' doc string > ''' > def __init__(self): > ... > This is legal, but wrong. It will result in LineLogic having the default > initialisation i.e. nothing, as the __init__ function is not part of the class. Ooh, I like your guess better. :-) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From tjreedy at udel.edu Wed Jul 29 13:49:56 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Jul 2015 13:49:56 -0400 Subject: String Attribute In-Reply-To: <55b81292.aaf5420a.ff2b1.4bb8@mx.google.com> References: <55b81292.aaf5420a.ff2b1.4bb8@mx.google.com> Message-ID: On 7/28/2015 7:38 PM, ltc.hotspot at gmail.com wrote: > What is the source of the syntax error to the String Attribute? > > Go to the following URL links and view a copy of the raw data file code > and sample data: > > 1.) http://tinyurl.com/p2xxxhl > 2.) http://tinyurl.com/nclg6pq If you want help here, reduce your code and input to the minimum needed, put the input in the code as a string, and if you still do not see the problem, post here, along with the traceback. > Here is the desired output: > > stephen.marquard at uct.ac.za > louis at media.berkeley.edu -- Terry Jan Reedy From Joe.Sanders at sandisk.com Wed Jul 29 13:52:29 2015 From: Joe.Sanders at sandisk.com (Joe Sanders) Date: Wed, 29 Jul 2015 17:52:29 +0000 Subject: Which Python do I need for the below? Message-ID: <377640C91279E84D9B61F71C964BA3424A1ACDB8@SACMBXIP02.sdcorp.global.sandisk.com> Hello- Which Python do I need for the below? with instructions please! [cid:image001.png at 01D0C9FD.677CDED0] Kind Regards, Gerald"Joe"Sanders Customer Global Quality Accounts 951 SanDisk Drive, building #5 | Milpitas, CA 95035 USA | cell +1,512.818.7798 corporate + 1.408.801.1000 | joe.sanders at sandisk.com [sd logo] ________________________________ PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies). -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 19912 bytes Desc: image001.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.png Type: image/png Size: 7274 bytes Desc: image002.png URL: From tjreedy at udel.edu Wed Jul 29 13:59:53 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Jul 2015 13:59:53 -0400 Subject: Use python script to create a part for Abaqus In-Reply-To: References: Message-ID: On 7/29/2015 8:12 AM, saber.chelaghma at gmail.com wrote: > Hi all, I want to create a part in 2D composed by: > > -A square -Inside the square there is a lot of circles > > I have a input file .dat where we can find the coordinates of the > circles' centers and their radius. You can easily display a square with circles using tkinter. However, it can only export a postscript file that not all postscript readers can read. > I want to create this part using a python script and import it in > Abaqus/CAE. Does anyone have an idea (or examples) on how I can do this ? What input file formats does Abaqus/CAE recognize? If you know that, you can potentially write a file in the proper format. -- Terry Jan Reedy From suburb4nfilth at gmail.com Wed Jul 29 14:27:48 2015 From: suburb4nfilth at gmail.com (Martin Spasov) Date: Wed, 29 Jul 2015 11:27:48 -0700 (PDT) Subject: how to Message-ID: Hello, i have been learning python for the past year and i did a few projects. Now i want to step up my game a bit and i want to build a real estate app . Its not going to be commercially released, its just for learning. My idea is the following, the app can have 2 types of users - brokers that would be able to add, remove and edit properties and clients that would be able to search and view different properties and send messages that the broker would be able to answer through the app. Its not said that i would do all of that in one go, its just the plan. Until now all my projects used shelve as my database, so everything was in memory and there was no need to share the data between users. For example > User A has his own notes , User B has his own notes and so on. Now i want there to be global database and when a broker updates a property i want to update the database so when a user requests the said property it would be updated. What i think i could do is write a socketserver and keep the data in the socket server object. then define a protocol and send the data when it is requested. Or i could use a database like MySQL with ORM like SQLAlchemy and then query the database from the server object. If i do that i would still need to come up with some sort of protocol to know what to query. Can you please give me ur 2 cents, i know that i haven't explained myself very clearly and I am sorry about that. Please ask if there is something unclear. Thank you. From tjreedy at udel.edu Wed Jul 29 15:01:57 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Jul 2015 15:01:57 -0400 Subject: Usage of P(C)ython Logo for Coffee Mug In-Reply-To: <201507291555.t6TFtaCs022990@fido.openend.se> References: <201507291555.t6TFtaCs022990@fido.openend.se> Message-ID: On 7/29/2015 11:55 AM, Laura Creighton wrote: > In a message of Mon, 27 Jul 2015 23:16:26 +0200, deus ex writes: >> Dear sirs or madam, >> >> I would like to let produce a p(c)ython coffee mug for myself for >> non-commerical use. Am I allowed to use your designed logo like: >> >> https://www.python.org/static/community_logos/python-logo-generic.svg >> https://upload.wikimedia.org/wikipedia/de/thumb/c/ce/Cython-logo.svg/640px-Cython-logo.svg.png >> >> or other versions? >> >> If you possibly be so kind to provide me a SVG Version please, that I am >> allowed to modify and use? >> >> Thanks in advance. >> >> Greetings, >> >> dex > > You will have to talk to the Cython developers for use of their image -- > but I doubt there will be any problem. The image belongs to PSF, not the developers. I believe the artist who donated it was not a developer. > We have SVG versions here: > https://www.python.org/community/logos/ See Guidelines for Use near the bottom, which as an *ask first* link if in doubt. Given that your coffee cup would be suitable for use while programming Python, I would expect no difficultly. -- Terry Jan Reedy From tjreedy at udel.edu Wed Jul 29 15:08:25 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Jul 2015 15:08:25 -0400 Subject: How to Calculate NPV? In-Reply-To: <757d1a56-fc27-4996-acff-8bb7e07204d6@googlegroups.com> References: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> <757d1a56-fc27-4996-acff-8bb7e07204d6@googlegroups.com> Message-ID: On 7/29/2015 10:21 AM, ryguy7272 wrote: > On Wednesday, July 29, 2015 at 9:59:10 AM UTC-4, ryguy7272 wrote: >> I am using Spyder Python 2.7. I'm running this sample code. >> >> import scipy as sp >> cashflows=[50,40,20,10,50] >> npv=sp.npv(0.1,cashflows) >> round(npv,2) >> >> >> Now, I'm trying to get the NPV, and I don't see any obvious way to get it. >> The author of the book that I'm reading gets 144.56. I think that's wrong, but I don't know for sure, as Python won't do any calculation at all. It's easy to enter code and run it, but I can't tell how to get Python to actually DO the calculation. >> >> Any idea what I'm doing wrong? > > PERFECT!! SO SIMPLE!! > I don't know why the author didn't do that in the book. The book show you how to calculate things. It is up to you to display, output to a file, or use in further calculation. I do admit, though, that snippets that show how to use an existing function, rather than define a new function, might benefit from adding print(xxxx). -- Terry Jan Reedy From alister.nospam.ware at ntlworld.com Wed Jul 29 15:12:58 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Wed, 29 Jul 2015 19:12:58 +0000 (UTC) Subject: how to References: Message-ID: On Wed, 29 Jul 2015 11:27:48 -0700, Martin Spasov wrote: > Hello, > > i have been learning python for the past year and i did a few projects. > Now i want to step up my game a bit and i want to build a real estate > app . Its not going to be commercially released, its just for learning. > My idea is the following, the app can have 2 types of users - brokers > that would be able to add, remove and edit properties and clients that > would be able to search and view different properties and send messages > that the broker would be able to answer through the app. Its not said > that i would do all of that in one go, its just the plan. Until now all > my projects used shelve as my database, so everything was in memory and > there was no need to share the data between users. > > For example > User A has his own notes , User B has his own notes and so > on. > > Now i want there to be global database and when a broker updates a > property i want to update the database so when a user requests the said > property it would be updated. > > What i think i could do is write a socketserver and keep the data in the > socket server object. then define a protocol and send the data when it > is requested. > > Or i could use a database like MySQL with ORM like SQLAlchemy and then > query the database from the server object. If i do that i would still > need to come up with some sort of protocol to know what to query. > > Can you please give me ur 2 cents, i know that i haven't explained > myself very clearly and I am sorry about that. Please ask if there is > something unclear. > > Thank you. Personally i would suggest this would be best served a a web app, then the DB can reside on the server & no transfer protocol would be req. the app could still be written in python using the WSGI interface. -- Saint: A dead sinner revised and edited. -- Ambrose Bierce From zachary.ware+pylist at gmail.com Wed Jul 29 15:36:12 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Wed, 29 Jul 2015 14:36:12 -0500 Subject: Usage of P(C)ython Logo for Coffee Mug In-Reply-To: References: <201507291555.t6TFtaCs022990@fido.openend.se> Message-ID: On Wed, Jul 29, 2015 at 2:01 PM, Terry Reedy wrote: > On 7/29/2015 11:55 AM, Laura Creighton wrote: >> We have SVG versions here: >> https://www.python.org/community/logos/ > > See Guidelines for Use near the bottom, which as an *ask first* link if in > doubt. Given that your coffee cup would be suitable for use while > programming Python, I would expect no difficultly. See also http://www.cafepress.com/pydotorg (linked from the logo page linked above), which includes coffee mugs for both logo styles. -- Zach From breamoreboy at yahoo.co.uk Wed Jul 29 16:06:47 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 29 Jul 2015 21:06:47 +0100 Subject: My code won't work if I double click the saved file In-Reply-To: <04881038-a14e-4469-be33-7fcd77496f67@googlegroups.com> References: <04881038-a14e-4469-be33-7fcd77496f67@googlegroups.com> Message-ID: On 29/07/2015 08:20, john wrote: > I have windows 8 running on my computer and I think I downloaded python 2 and 3 simultaneously or I think my computer has built in python 2 and I downloaded python 3. And now when I ran my code in IDLE, the code works fine but when I save my program and double click the save file, it will run but it doesn't worked like it used to work in IDLE. > > Can someone explain the possible problem I'm currently facing? > > I just want my program to run perfectly in both IDLE and when I double click the saved file. > > I posted my question in stackoverflow but I didn't find an answer. > > http://stackoverflow.com/questions/31692156/i-think-my-computer-has-built-in-python-2-and-i-installed-python-3 > Please run your code from a command prompt. Tell us exactly what you expected to happen and what actually happened. If you get a traceback please cut and paste the entire traceback here. Show us your code, just the bit that causes the problem, as cutting the code back to the bare minimum often helps you find the problem. There is advice on how to do this here http://sscce.org/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From irmen.NOSPAM at xs4all.nl Wed Jul 29 16:12:29 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Wed, 29 Jul 2015 22:12:29 +0200 Subject: Fwd: Request for Information XML-RPC (Python) In-Reply-To: References: Message-ID: <55b933af$0$2835$e4fe514c@news.xs4all.nl> On 29-7-2015 14:52, Davide D'Arenzo wrote: > I want to send a DOM instance through xmlrpc protocol. I know that the istance are > impossible to manage by xmlrpclib library in Python but this is what I need. I'm trying > to understand why is not possible to marshal the class Nodelist and I recognize that the > target function is dumps(self, values) in class Marshaller because she couldn't find > this type of Python Object. One serialized form of a DOM is.... an XML document. So why not just send the XML document itself? Just ask the dom for its string/xml form and send that as a string across your xml-rpc call. Irmen From jstrickler at gmail.com Wed Jul 29 16:46:12 2015 From: jstrickler at gmail.com (John Strick) Date: Wed, 29 Jul 2015 13:46:12 -0700 (PDT) Subject: String Attribute In-Reply-To: References: <55b81292.aaf5420a.ff2b1.4bb8@mx.google.com> Message-ID: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" for line in fname: line = line.strip() if not line.startwith('From '): continue line = line.split() count = count + 1 You need to actually open the file. (Look up how to do that) The first 'for' loop is looping through the file NAME, not the file OBJECT. Also, line.startwith() should be line.startswith(). --john From cs at zip.com.au Wed Jul 29 20:43:28 2015 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 30 Jul 2015 10:43:28 +1000 Subject: Gmail eats Python In-Reply-To: <1438181473.3233902.336329649.4B869E37@webmail.messagingengine.com> References: <1438181473.3233902.336329649.4B869E37@webmail.messagingengine.com> Message-ID: <20150730004328.GA78418@cskk.homeip.net> On 29Jul2015 10:51, random832 at fastmail.us wrote: >On Sun, Jul 26, 2015, at 07:48, Marko Rauhamaa wrote: >> At first, there was only the machine language. Assembly languages >> introduced "mnemonics" for the weaklings who couldn't remember the >> opcodes by heart. > >To be fair, x86 is also a particularly terrible example of a machine >language, from the perspective of someone imagining being expected to >memorize it. Compare it with PDP-11, which had eight registers and eight >addressing modes and a whole lot less to memorize (since each of these >appears in every instruction as a single octal digit). 16 registers - you forget the alternate register set. Since the UNIX V7 kernel code never made use of them we used to use them as a crude messaging system from user space, as what you put there sayed there, globally accessible by other users. Cheers, Cameron Simpson TeX: When you pronounce it correctly to your computer, the terminal may become slightly moist. - D. E. Knuth. From cs at zip.com.au Wed Jul 29 20:45:14 2015 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 30 Jul 2015 10:45:14 +1000 Subject: Gmail eats Python In-Reply-To: <201507291632.t6TGWkvn031297@fido.openend.se> References: <201507291632.t6TGWkvn031297@fido.openend.se> Message-ID: <20150730004514.GA85522@cskk.homeip.net> On 29Jul2015 18:32, Laura Creighton wrote: >In a message of Tue, 28 Jul 2015 20:35:15 -0700, Rustom Mody writes: >>- I should not have to customize emacs so that CTRL/A, CTRL/E, CTRL/N, and >>CTRL/P continue to work the way they've done since the mid-1970s. >> >>etc etc >>-------------------------------- >>? emacs 18 dates from around 1992 (!!) > >No, the original one was written in 1976. > >These control characters are the very basic move characters in emacs. >People have always been free to remap them if they want them to do >something else, but waking up in the morning and discovering that you >cannot move to the front of your current line, to the end ot it, one line >up and one line down because somebody has changed this ***for everybody*** >would get me quite upset, too. Yeah, I'd be annoyed too. I'm a vi user, but use the emacs mode for shell command line editing as it is modeless. ^A, ^E, ^P and ^N are really quite critical. >Laura (happy emacs user since 1979) Cheers, Cameron Simpson (happy vi user since 1985) English is a living language, but simple illiteracy is no basis for linguistic evolution. - Dwight MacDonald From cs at zip.com.au Wed Jul 29 22:06:33 2015 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 30 Jul 2015 12:06:33 +1000 Subject: My code won't work if I double click the saved file In-Reply-To: <04881038-a14e-4469-be33-7fcd77496f67@googlegroups.com> References: <04881038-a14e-4469-be33-7fcd77496f67@googlegroups.com> Message-ID: <20150730020633.GA13546@cskk.homeip.net> On 29Jul2015 00:20, john wrote: >I have windows 8 running on my computer and I think I downloaded python 2 and 3 simultaneously or I think my computer has built in python 2 and I downloaded python 3. And now when I ran my code in IDLE, the code works fine but when I save my program and double click the save file, it will run but it doesn't worked like it used to work in IDLE. > >Can someone explain the possible problem I'm currently facing? > >I just want my program to run perfectly in both IDLE and when I double click the saved file. > >I posted my question in stackoverflow but I didn't find an answer. > >http://stackoverflow.com/questions/31692156/i-think-my-computer-has-built-in-python-2-and-i-installed-python-3 This sounds like what is known as a "file association" issue. Your computer's desktop is perhaps associating .py files with the python2 executable. I do not use Windows, but I believe you can adjust these associations. However, the first question (to verify that this is the issue) is: if you deliberately invoke python2 and execute your code with it, does it behave the same way as when you currently double click on the file? Cheers, Cameron Simpson The mere existence of a problem is no proof of the existence of a solution. - Yiddish Proverb From rustompmody at gmail.com Wed Jul 29 22:21:49 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 29 Jul 2015 19:21:49 -0700 (PDT) Subject: Gmail eats Python In-Reply-To: References: <201507291632.t6TGWkvn031297@fido.openend.se> Message-ID: <38834c7a-8c2a-4fb8-ad2f-d31ea6d4813e@googlegroups.com> On Thursday, July 30, 2015 at 6:15:56 AM UTC+5:30, Cameron Simpson wrote: > On 29Jul2015 18:32, Laura Creighton wrote: > >These control characters are the very basic move characters in emacs. > >People have always been free to remap them if they want them to do > >something else, but waking up in the morning and discovering that you > >cannot move to the front of your current line, to the end ot it, one line > >up and one line down because somebody has changed this ***for everybody*** > >would get me quite upset, too. > > Yeah, I'd be annoyed too. I'm a vi user, but use the emacs mode for shell > command line editing as it is modeless. ^A, ^E, ^P and ^N are really quite > critical. > > >Laura (happy emacs user since 1979) > > Cheers, > Cameron Simpson (happy vi user since 1985) > > English is a living language, but simple illiteracy is no basis for > linguistic evolution. - Dwight MacDonald That footer says it best: Some stability is expected, also some change. Finding a sweetspot midway is hard and very necessary BTW I think python does a better job -- 2?3 transition than most other long-lived projects. Emacs is too much on the conservative side. Haskell is too much on the 'progress-is-heaven' side. From p_s_d_a_s_i_l_v_a_ns at netcabo.pt Thu Jul 30 01:16:38 2015 From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva) Date: Thu, 30 Jul 2015 06:16:38 +0100 Subject: Which GUI? References: Message-ID: On 24-07-2015 19:31, Paulo da Silva wrote: I'll begin with pyqtgraph. Seems to be simple to start with. Thanks Chistopher. Later I'll give a try to bokeh. I'll need to look better at web applications first. I still don't know if dynamically changing is possible without the bokeh server. Thanks Laura. Thank you all who responded. Paulo From dieter at handshake.de Thu Jul 30 02:10:43 2015 From: dieter at handshake.de (dieter) Date: Thu, 30 Jul 2015 08:10:43 +0200 Subject: Fwd: Request for Information XML-RPC (Python) References: Message-ID: <87wpxigopo.fsf@handshake.de> "Davide D'Arenzo" writes: > I'm Davide D'Arenzo and I'm working with Python using the standard > xmlrpclib library communicating between a JavaServer (that host xmlrpc > server) and my python client. I have a problem and I hope that you should > solve my issue. > > I want to send a DOM instance through xmlrpc protocol. I know that the > istance are impossible to manage by xmlrpclib library in Python but this is > what I need. XML-RPC supports only a very small set of elementary types - and "DOM instance" does not belong to this set. Thus, you must ask your server administrator as what type the server expects to get the XML (this may either by "string" or "binary"; I suppose, it will be "binary"). You then convert your DOM instance into an XML document, potentially using an appropriate encoding (likely "utf-8"), and potentially wrap it into "xmlrpclib"'s "binary" wrapper (in case, the server expects a binary string). From dieter at handshake.de Thu Jul 30 02:23:38 2015 From: dieter at handshake.de (dieter) Date: Thu, 30 Jul 2015 08:23:38 +0200 Subject: how to References: Message-ID: <87si86go45.fsf@handshake.de> Martin Spasov writes: > ... > i want to build a real estate app . > ... > Now i want there to be global database and when a broker updates a property i want to update the database so when a user requests the said property it would be updated. > > What i think i could do is write a socketserver and keep the data in the socket server object. then define a protocol and send the data when it is requested. > > Or i could use a database like MySQL with ORM like SQLAlchemy and then query the database from the server object. If i do that i would still need to come up with some sort of protocol to know what to query. I would go the second way. You mentioned to have a "global" database. This suggests there is also something "local". While is is possible to let distributed applications access a "global" database, this usually is a great security risk (you database communication endpoints are open to anybody - among others hackers that may try to steal or corrupt your data). Therefore, you usually use a client server architecture where the database is hidden behind a server interface. The clients do not directly connect to the database but to the server interface which in turn access the database. Part of the server interface is authentication (who wants my services) and authorization (which access should I provide to the authenticated user). Someone else already suggested to implement a web application for your project. Web application frameworks (such as e.g. "Django") come with components to easily (and rather safely) implement the common tasks of authentication and authorization. From elchino at cnn.cn Thu Jul 30 03:03:14 2015 From: elchino at cnn.cn (ElChino) Date: Thu, 30 Jul 2015 09:03:14 +0200 Subject: Python launcher problem Message-ID: If I in a cmd-shell (actually it is 4NT), do: c:>py -3 -V & python3 -V I get: Requested Python version (3) not installed << ! from py -3 -V Python 3.5.0b2 << ! from the 2nd cmd. What nonsense is this? I DO HAVE Python3 in my %PATH. A Registry setting gone haywire? From PointedEars at web.de Thu Jul 30 03:39:28 2015 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Thu, 30 Jul 2015 09:39:28 +0200 Subject: Python launcher problem References: Message-ID: <19199478.pdSVmecxvU@PointedEars.de> ElChino wrote: > If I in a cmd-shell (actually it is 4NT), do: > c:>py -3 -V & python3 -V > > I get: > Requested Python version (3) not installed << ! from py -3 -V > Python 3.5.0b2 << ! from the 2nd cmd. > > What nonsense is this? I DO HAVE Python3 in my %PATH. > A Registry setting gone haywire? RTFM. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. From breamoreboy at yahoo.co.uk Thu Jul 30 04:49:05 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 30 Jul 2015 09:49:05 +0100 Subject: My code won't work if I double click the saved file In-Reply-To: <20150730020633.GA13546@cskk.homeip.net> References: <04881038-a14e-4469-be33-7fcd77496f67@googlegroups.com> <20150730020633.GA13546@cskk.homeip.net> Message-ID: On 30/07/2015 03:06, Cameron Simpson wrote: > On 29Jul2015 00:20, john wrote: >> I have windows 8 running on my computer and I think I downloaded >> python 2 and 3 simultaneously or I think my computer has built in >> python 2 and I downloaded python 3. And now when I ran my code in >> IDLE, the code works fine but when I save my program and double click >> the save file, it will run but it doesn't worked like it used to work >> in IDLE. >> >> Can someone explain the possible problem I'm currently facing? >> >> I just want my program to run perfectly in both IDLE and when I double >> click the saved file. >> >> I posted my question in stackoverflow but I didn't find an answer. >> >> http://stackoverflow.com/questions/31692156/i-think-my-computer-has-built-in-python-2-and-i-installed-python-3 >> > > This sounds like what is known as a "file association" issue. Your > computer's desktop is perhaps associating .py files with the python2 > executable. I do not use Windows, but I believe you can adjust these > associations. > With the advent of the Python Launcher for Windows things have changed. Here's my setup. C:\Users\Mark\Documents\MyPython>assoc .py .py=Python.File C:\Users\Mark\Documents\MyPython>ftype Python.File Python.File="C:\Windows\py.exe" "%L" %* -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From breamoreboy at yahoo.co.uk Thu Jul 30 05:01:09 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 30 Jul 2015 10:01:09 +0100 Subject: Python launcher problem In-Reply-To: References: Message-ID: On 30/07/2015 08:03, ElChino wrote: > If I in a cmd-shell (actually it is 4NT), do: > c:>py -3 -V & python3 -V > > I get: > Requested Python version (3) not installed << ! from py -3 -V > Python 3.5.0b2 << ! from the 2nd cmd. > > What nonsense is this? I DO HAVE Python3 in my %PATH. > A Registry setting gone haywire? I get:- C:\Users\Mark\Documents\MyPython>py -3 -V & python3 -V Python 3.5.0b4 'python3' is not recognized as an internal or external command, operable program or batch file. I've never had a Windows system with a 'python3' on it, so that is presumably something you've set up. Hence it could be a screwed registry setting, but you're the only person in a position to find out :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From tjreedy at udel.edu Thu Jul 30 05:41:06 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 30 Jul 2015 05:41:06 -0400 Subject: Python launcher problem In-Reply-To: References: Message-ID: On 7/30/2015 3:03 AM, ElChino wrote: > If I in a cmd-shell (actually it is 4NT), do: > c:>py -3 -V & python3 -V > > I get: > Requested Python version (3) not installed << ! from py -3 -V > Python 3.5.0b2 << ! from the 2nd cmd. > > What nonsense is this? I DO HAVE Python3 in my %PATH. > A Registry setting gone haywire? Start with something that works. C:\Users\Terry>py -3 Python 3.5.0b2 (v3.5.0b2:7a088af5615b, May 31 2015, 06:22:19) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> exit() -- Terry Jan Reedy From info at egenix.com Thu Jul 30 06:54:27 2015 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Thu, 30 Jul 2015 12:54:27 +0200 Subject: ANN: eGenix pyOpenSSL Distribution 0.13.11 Message-ID: <55BA0263.4030405@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com pyOpenSSL Distribution Version 0.13.11 An easy-to-install and easy-to-use distribution of the pyOpenSSL Python interface for OpenSSL - available for Windows, Mac OS X and Unix platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.11.html ________________________________________________________________________ INTRODUCTION The eGenix.com pyOpenSSL Distribution includes everything you need to get started with SSL in Python. It comes with an easy-to-use installer that includes the most recent OpenSSL library versions in pre-compiled form, making your application independent of OS provided OpenSSL libraries: http://www.egenix.com/products/python/pyOpenSSL/ pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS- aware network applications as well as certificate management tools: https://launchpad.net/pyopenssl/ OpenSSL is an open-source implementation of the SSL/TLS protocol: http://www.openssl.org/ ________________________________________________________________________ NEWS This new release of the eGenix.com pyOpenSSL Distribution includes the following updates: New in OpenSSL -------------- * Updated included OpenSSL libraries from OpenSSL 1.0.1o to 1.0.1p. See https://www.openssl.org/news/secadv_20150709.txt ?for a complete list of changes. The following fixes are relevant for pyOpenSSL applications: - CVE-2015-1793: An error in the implementation of the alternative certificate chain logic could allow an attacker to use a regular server leaf certificate as CA certificate. Please see the product changelog for the full set of changes. http://www.egenix.com/products/python/pyOpenSSL/changelog.html pyOpenSSL / OpenSSL Binaries Included ------------------------------------- In addition to providing sources, we make binaries available that include both pyOpenSSL and the necessary OpenSSL libraries for all supported platforms: Windows, Linux, Mac OS X and FreeBSD, for x86 and x64. To simplify installation, we have uploaded a web installer to PyPI which will automatically choose the right binary for your platform, so a simple pip install egenix-pyopenssl will get you the package with OpenSSL libraries installed. Please see our installation instructions for details: http://www.egenix.com/products/python/pyOpenSSL/#Installation We have also added .egg-file distribution versions of our eGenix.com pyOpenSSL Distribution for Windows, Linux and Mac OS X to the available download options. These make setups using e.g. zc.buildout and other egg-file based installers a lot easier. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/pyOpenSSL/ ________________________________________________________________________ UPGRADING Before installing this version of pyOpenSSL, please make sure that you uninstall any previously installed pyOpenSSL version. Otherwise, you could end up not using the included OpenSSL libs. _______________________________________________________________________ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. ________________________________________________________________________ MORE INFORMATION For more information about the eGenix pyOpenSSL Distribution, licensing and download instructions, please visit our web-site or write to sales at egenix.com. About eGenix (http://www.egenix.com/): eGenix is a software project, consulting and product company focusing on expert project services and professional quality products for companies, Python users and developers. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 30 2015) >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::::: Try our mxODBC.Connect Python Database Interface for free ! :::::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From regoricardo at gmail.com Thu Jul 30 07:33:42 2015 From: regoricardo at gmail.com (regoricardo at gmail.com) Date: Thu, 30 Jul 2015 04:33:42 -0700 (PDT) Subject: Looking for Python developers with S&OP Simulation experience Message-ID: <5bc14a66-93e1-4773-8098-d564e54289a4@googlegroups.com> Hi all, We're starting a new Python project where any extra help will be warmly welcomed. Please, contact us at: ricardo att r2software dott com dott br Cheers, Ricardo From subhabrata.banerji at gmail.com Thu Jul 30 09:28:10 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Thu, 30 Jul 2015 06:28:10 -0700 (PDT) Subject: Logical Query in Python Message-ID: <90d0e539-d9ab-4c9a-ad79-7607fcd05531@googlegroups.com> Dear Group, I am trying to query JSON with Logical operators. I tried to experiment lot with it, but could not do much. I came many times pretty close but missed it almost. I tried to experiment with json, jsonquery, jsonschema, jsonpipe, objectpath, requests. I got a good example from http://www-01.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/com.ibm.db2z11.doc.json/src/tpc/db2z_jsonlogicaloperators.dita But I was looking for one or two worked out examples to start with. I am using Python2.7+ on Windows 7 with IDLE as GUI. I am trying and if anybody of the esteemed members may kindly help me with. Regards, Subhabrata Banerjee. From subhabrata.banerji at gmail.com Thu Jul 30 09:32:01 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Thu, 30 Jul 2015 06:32:01 -0700 (PDT) Subject: Logical Query JSON Message-ID: Dear Group, I am trying to query JSON with Logical operators. I tried to experiment lot with it, but could not do much. I came many times pretty close but missed it almost. I tried to experiment with json, jsonquery, jsonschema, jsonpipe, objectpath, requests. I got a good example from http://www-01.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/com.ibm.db2z11.doc.json/src/tpc/db2z_jsonlogicaloperators.dita But I was looking for one or two worked out examples to start with. I am using Python2.7+ on Windows 7 with IDLE as GUI. I am trying and if anybody of the esteemed members may kindly help me with. Regards, Subhabrata Banerjee. From zachary.ware+pylist at gmail.com Thu Jul 30 09:38:16 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Thu, 30 Jul 2015 08:38:16 -0500 Subject: Python launcher problem In-Reply-To: References: Message-ID: On Jul 30, 2015 2:05 AM, "ElChino" wrote: > > If I in a cmd-shell (actually it is 4NT), do: > c:>py -3 -V & python3 -V > > I get: > Requested Python version (3) not installed << ! from py -3 -V > Python 3.5.0b2 << ! from the 2nd cmd. > > What nonsense is this? I DO HAVE Python3 in my %PATH. > A Registry setting gone haywire? Did you perchance rename the installed 'python.exe' to 'python3.exe'? That would be enough to break the launcher. If you want a 'python3' command, you can copy 'python.exe' to 'python3.exe', but 'python.exe' needs to remain where it was. -- Zach (On a phone) -------------- next part -------------- An HTML attachment was scrubbed... URL: From df at see.replyto.invalid Thu Jul 30 10:18:27 2015 From: df at see.replyto.invalid (Dave Farrance) Date: Thu, 30 Jul 2015 15:18:27 +0100 Subject: How to Calculate NPV? References: <249a5b7e-0364-4b74-94f4-c8bbfbba2479@googlegroups.com> <757d1a56-fc27-4996-acff-8bb7e07204d6@googlegroups.com> Message-ID: <2hbkrat6h80cafs23roj46ojh9tbi4t12j@4ax.com> ryguy7272 wrote: >PERFECT!! SO SIMPLE!! >I don't know why the author didn't do that in the book. The book is evidently giving you code snippets to enter into Python's own interactive interpreter, i.e., you enter "python" at the command line, then you manually type each command which immediately displays any returned value. I assume that the book shows each command with three chevrons ">>>" in front of them. If you're using Spyder then you need to enter the commands into its interactive interpreter (which I think is bottom right). It sounds, instead, as though you're using Spyder's text editor to create a file containing the commands, and then using the "run" icon to run the file -- which is maybe skipping ahead because the book hasn't told you how to do that yet (?). If you do skip ahead, the book probably has a forthcoming chapter called "writing programs with a text editor" or something. I'd guess from the code snippets that you've shown us that the book is finance oriented, and the author seems to be more interested in introducing the features useful for finance than teaching the basics of Python. Maybe you should search out a simple Python primer on the web, work through that, and only then return to your book. From steve at pearwood.info Thu Jul 30 11:04:48 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 31 Jul 2015 01:04:48 +1000 Subject: Logical Query in Python References: <90d0e539-d9ab-4c9a-ad79-7607fcd05531@googlegroups.com> Message-ID: <55ba3d10$0$1643$c3e8da3$5496439d@news.astraweb.com> On Thu, 30 Jul 2015 11:28 pm, subhabrata.banerji at gmail.com wrote: > Dear Group, > > I am trying to query JSON with Logical operators. What does that mean? > I tried to experiment lot with it, but could not do much. > I came many times pretty close but missed it almost. Please: - show an example of what you tried; - give the results you expected; - show the results you actually got. COPY and PASTE the code and results, do not re-type them, or summarise them. -- Steven From michel.casabianca at gmail.com Thu Jul 30 11:29:51 2015 From: michel.casabianca at gmail.com (casa) Date: Thu, 30 Jul 2015 08:29:51 -0700 (PDT) Subject: [Ann] Package Repository Project Message-ID: Hi all, I have started a package repository project at http://github.com/c4s4/cheeseshop. This is useful if you want to share Python packages that you can't make public on pypi.python.org. It is aimed to be easy to install and efficient. Any comment welcome Enjoy! From mal at europython.eu Thu Jul 30 11:43:40 2015 From: mal at europython.eu (M.-A. Lemburg) Date: Thu, 30 Jul 2015 17:43:40 +0200 Subject: EuroPython 2015: Thank you to all volunteers Message-ID: <55BA462C.1000101@europython.eu> EuroPython is now over and was a great success thanks to everyone who helped make it happen. Unfortunately, we did not properly acknowledge all the volunteers who were working on the event during the closing session and we would like to apologize for this, so here?s the full list of all volunteers from the EuroPython 2015 Workgroups and the on-site volunteers: *** https://ep2015.europython.eu/en/volunteers/ *** On-site Team WG --------------- * Oier Echaniz Beneitez (Chair) * Borja Ayerdi Vilches * Alexandre Savio * Darya Chyzhyk * Jos? David Nu?ez * Luis Javier Salvatierra * Ion Marqu?s Conference Administration WG ---------------------------- * Marc-Andre Lemburg (Chair) * Vicky Lee * Rezuk Turgut * Stavros Anastasiadis * St?phane Wirtel * Borja Ayerdi Vilches * Oier Beneitez Finance WG ---------- * Borja Ayerdi Vilches (Chair) * Fabio Pliger * Marc-Andre Lemburg * Vicky Lee * Rezuk Turgut * Jacob Hall?n (EPS Treasurer) * Darya Chyzhyk Sponsors WG ----------- * Fabio Pilger (Chair) * Alexandre Savio * Borja Ayerdi Vilches * Marc-Andre Lemburg * Vicky Twomey-Lee * Hansel Dunlop * Ra?l Cumplido * Jos? David Mu?ez * Oier Echaniz Beneitez * Miren Urteaga Aldalur Communications WG ------------------ * Marc-Andre Lemburg (Chair) * Oier Beneitez * Kerstin Kollmann * Fabio Pliger * Vicky Lee * Dougal Matthews * Chris Ward * Kristian Rother * St?phane Wirtel * Miren Aldalur Support WG ---------- * Ra?l Cumplido * Anthon van der Neut * Alexandre Savio * Ion Marqu?s * Christian Barra * Eyad Toma * Stavros Anastasiadis Financial Aid WG ---------------- * Darya Chyzhyk * Vicky Twomey-Lee * Ion Marqu?s * St?phane Wirtel Marketing/Design WG ------------------- * Darya Chyzhyk * Marc-Andre Lemburg * Borja Ayerdi Vilches * Alexandre Savio * Miren Aldalur * St?phane Wirtel * Zachari Saltmer Program WG ---------- * Alexandre Savio (Chair) * Alexander Hendorf (Co-chair) * Vicky Twomey-Lee * Kristian Rother * Dougal Matthews * Sarah Mount * Ra?l Cumplido * Adam Byrtek * Christian Barra * Moshe Goldstein * Scott Reeve * Chris Ward * Claudiu Popa * Stavros Anastasiadis * Harry Percival * Daniel Pyrathon Web WG ------ * Christian Barra (Chair) * Oier Beneitez * Marc-Andre Lemburg * Adam Byrtek * Dougal Matthews * Ra?l Cumplido * Fabio Pliger * Eyad Toma * St?phane Wirtel Media WG -------- * Anthon van der Neut * Jos? David Mu?ez * Luis Javier Salvatierra * Francisco Fern?ndez Casta?o * Fabio Pliger On-Site Volunteers ------------------ In addition to several of the EuroPython Workgroup members, in particular, the on-site team WG, the following attendees helped as session manager, room manager, on the registration desk, bag stuffing and during set up and tear down of the conference. In alphabetical order: * Abraham Martin * Agust?n Herranz * Aisha Bello * Alberto Rasillo * Ana Balica * Andrew McCarthy * Anna Bednarska * Anna T?gl?ssy * Austur * Brianna Laugher * Cesar Desales * Christian Barra * Christin Sch?rfer * Corinne Welsh * Dorottya Czapari * Dougal Matthews * ?l?onore Mayola * Eugene Tataurov * Felipe Ximenez * Floris Bruynooghe * Gautier Hayoun * Gregorio Vivo * Harry Percival * Inigo Aldazabal * I?igo Ugarte P?rez * Ion Marques * Iraia Etxeberria * Iris Yuping Ren * Izarra Domingo * Jos? David Nu?ez * Julian Coyne * Julian Estevez * Jyrki Pulliainen * Kasia Kaminska * Kerstin Kollmann * Leire Ozaeta * Luis Javier Salavatierra * Matt McGraw * Maura Pilia * Mikey Ariel * Mircea Zetea * Miren Urteaga * Miroslav Sedivy * Pablo * Patrick Arminio * Paul Cochrane * Peter Deba * Petr Viktorin * Pierre Reinbold * Piotr Dyba * Raul Cumplido * Stefano Fontana * Stefano Mazzucco * Sven Wontroba * Szilvia Kadar * Tomasz Nowak * Victor Munoz Some attendees also helped without being registered as volunteer, e.g. during tear down at the conference venue. We?d like to thank you and acknowledge you as well. If you have helped and are not on the above list, please write to info at europython.eu. For next year, we will seek to use a better system for volunteer management and also invest more time into improving the conference opening and closing sessions. Enjoy, -- EuroPython 2015 Team http://ep2015.europython.eu/ http://www.europython-society.org/ From denismfmcmahon at gmail.com Thu Jul 30 11:48:48 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 30 Jul 2015 15:48:48 +0000 (UTC) Subject: Logical Query JSON References: Message-ID: On Thu, 30 Jul 2015 06:32:01 -0700, subhabrata.banerji wrote: > I am trying to query JSON with Logical operators. Your post was an excellent example of asking for help without explaining what your problem was at all. Please: - show an example of what you tried; - give the results you expected; - show the results you actually got. COPY and PASTE the code and results, do not re-type them, or summarise them. I found the examples quite easy to follow to create json queries, although as I don't have a db2 etc setup here iI'm unale to try feeding the resulting json query into a database to see what comes out. -- Denis McMahon, denismfmcmahon at gmail.com From seanmavley at gmail.com Thu Jul 30 11:57:39 2015 From: seanmavley at gmail.com (Nkansah Rexford) Date: Thu, 30 Jul 2015 08:57:39 -0700 (PDT) Subject: using sched Message-ID: <420b4f03-0eb5-4f22-ae51-0018ebd613a7@googlegroups.com> Using sched, how can I run a function, at for instance, exactly 00:00 GMT, and only that time. If sched wouldn't be the best to do so a job, please can you recommend something? From subhabrata.banerji at gmail.com Thu Jul 30 12:25:42 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Thu, 30 Jul 2015 09:25:42 -0700 (PDT) Subject: Logical Query JSON In-Reply-To: References: Message-ID: <36c251da-3dc0-47ee-8831-c6ae5d092aa1@googlegroups.com> On Thursday, July 30, 2015 at 9:20:35 PM UTC+5:30, Denis McMahon wrote: > On Thu, 30 Jul 2015 06:32:01 -0700, subhabrata.banerji wrote: > > > I am trying to query JSON with Logical operators. > > Your post was an excellent example of asking for help without explaining > what your problem was at all. > > Please: > > - show an example of what you tried; > > - give the results you expected; > > - show the results you actually got. > > COPY and PASTE the code and results, do not re-type them, or summarise > them. > > I found the examples quite easy to follow to create json queries, > although as I don't have a db2 etc setup here iI'm unale to try feeding > the resulting json query into a database to see what comes out. > > -- > Denis McMahon Dear Sir, I am trying to quote some of my exercises below, and my objective. (1) Exercise with objectpath: >>> from objectpath import * >>> tree=Tree({"a":1}) >>> tree.execute("$.a") 1 >>> $ { "a":1, "b":{ "c":[1,2,3] } } SyntaxError: invalid syntax >>> x1={"a":1,"b":{"c":[1,2,3]}} >>> x1.b Traceback (most recent call last): File "", line 1, in x1.b AttributeError: 'dict' object has no attribute 'b' >>> x1."b" SyntaxError: invalid syntax (2) Exercise from IBM Example: >>> x1={"or":[{"age":4},{"name":"Joe"}]} >>> x2=x1 >>> print x2 {'or': [{'age': 4}, {'name': 'Joe'}]} >>> x1['age'] Traceback (most recent call last): File "", line 1, in x1['age'] KeyError: 'age' >>> x1['or'] [{'age': 4}, {'name': 'Joe'}] >>> x1['or']['age'] Traceback (most recent call last): File "", line 1, in x1['or']['age'] TypeError: list indices must be integers, not str >>> x1['or'][0] {'age': 4} >>> x1['or'][1] {'name': 'Joe'} My expectation is: If I do AND, NOT, OR with two or more JSON values like {"age":4}, {"name":"Joe"}, ...etc. then I should get recirprocal results. Considering each one as Python variable and applying logical Python operation helps, but I am looking a smarter solution. Apology for indentation error. Regards, Subhabrata Banerjee. From subhabrata.banerji at gmail.com Thu Jul 30 12:29:28 2015 From: subhabrata.banerji at gmail.com (subhabrata.banerji at gmail.com) Date: Thu, 30 Jul 2015 09:29:28 -0700 (PDT) Subject: Logical Query in Python In-Reply-To: <55ba3d10$0$1643$c3e8da3$5496439d@news.astraweb.com> References: <90d0e539-d9ab-4c9a-ad79-7607fcd05531@googlegroups.com> <55ba3d10$0$1643$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4010db96-eb1e-44e3-91b1-99331543667b@googlegroups.com> On Thursday, July 30, 2015 at 8:35:08 PM UTC+5:30, Steven D'Aprano wrote: > On Thu, 30 Jul 2015 11:28 pm, wrote: > > > Dear Group, > > > > I am trying to query JSON with Logical operators. > > What does that mean? > > > I tried to experiment lot with it, but could not do much. > > I came many times pretty close but missed it almost. > > Please: > > - show an example of what you tried; > > - give the results you expected; > > - show the results you actually got. > > COPY and PASTE the code and results, do not re-type them, or summarise them. > > > > > -- > Steven Dear Sir, I redrafted it and reposted the question. This post I tried to drop but some how came. Please ignore this post. My reposting is with JSON. Regards, Subhabrata Banerjee. From gary719_list1 at verizon.net Thu Jul 30 13:56:51 2015 From: gary719_list1 at verizon.net (Gary Roach) Date: Thu, 30 Jul 2015 10:56:51 -0700 Subject: Improper Django Project error Message-ID: <55BA6563.8050603@verizon.net> Hi all Being new to Django and Python, I have two projects setup side by side, each in it's own virtualenv wrapper. The twr_project is running Django 1.7, python 2.7 and is set up to duplicate the 'Tango With Rango' tutorial. The archivedb project is running Django 1.8, python 2.7 and is my actual project. I am using Ninja-IDE as my IDE. I like it a lot. At this point both projects are essentially identical with the exception of name changes. The twr project work down to the first template inclusion ( index.html ). The archivedb project refuses to find the home.html template file. The system layout is exactly the same. I wiped the home.html file and attempted to re-install it but my IDE gave the following error window: > Sorry, either settings file or virtualenv are missingthese are > required for Django Plugin to work in thepresent version, we are > working on fixing this. > I have virtualenv installed and active and the settings file is present. In any case, the IDE won't let me save the home.html file without some fiddling. Even if I get the file saved the web server can't find it. (file not found error). The only difference between index.html (Django 1.7) and home.html (Django 1.8) is the name changes. I have inserted print statements in the url tree to try debugging this but all the path information returned seems reasonable. Is this a bug in Ninja-IDE, Django 1.8 or is it something else. If you need more information, please let me know Gary R. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sutanu.das at gmail.com Thu Jul 30 14:31:40 2015 From: sutanu.das at gmail.com (sutanu.das at gmail.com) Date: Thu, 30 Jul 2015 11:31:40 -0700 (PDT) Subject: How to re-write this bash script in Python? Message-ID: #!/bin/bash _maillist='pager at email.com' _hname=`hostname` _logdir=/hadoop/logs _dirlog=${_logdir}/directory_check.log _year=$(date -d "-5 hour" +%Y) _month=$(date -d "-5 hour" +%m) _day=$(date -d "-5 hour" +%d) _hour=$(date -d "-5 hour" +%H) _hdfsdir=`hdfs dfs -ls -d /hadoop/flume_ingest_*/$_year/$_month | awk '{print $8}'` echo "Checking for HDFS directories:" > ${_dirlog} echo >> ${_dirlog} for _currdir in $_hdfsdir do hdfs dfs -ls -d $_currdir/$_day/$_hour &>> ${_dirlog} done if [[ `grep -i "No such file or directory" ${_dirlog}` ]]; then echo "Verify Flume is working for all servers" | mailx -s "HDFS Hadoop Failure on Flume: ${_hname}" -a ${_dirlog} ${_maillist} fi From ltc.hotspot at gmail.com Thu Jul 30 15:00:52 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Thu, 30 Jul 2015 19:00:52 +0000 Subject: =?utf-8?Q?Re:_[Tutor]_Mailbox?= In-Reply-To: <20150730020105.GA96916@cskk.homeip.net> References: <55b94c40.e201460a.c7eec.3d3a@mx.google.com>, <20150730020105.GA96916@cskk.homeip.net> Message-ID: <55ba7488.882c460a.ed373.ffff8098@mx.google.com> Hi Cameron, New revision code: count = 0 fn = raw_input("Enter file name: ") if len(fn) < 1 : fname = "mbox-short.txt" for line in fn: if 'From' in line.split()[0]: count += 1 print "There are %d lines starting with From" % count print len(line) fn = open(fname) print "There were", count, "lines in the file with From as the first word" Syntax message produced by iPython interperter: NameError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assinment_8_5_v_2.py in () 6 print "There are %d lines starting with From" % count 7 print len(line) ----> 8 fn = open(fname) 9 print "There were", count, "lines in the file with From as the first wor d" NameError: name 'fname' is not defined In [16]: Question: Why is fname = "mbox-short.txt" not loading the sample data? Sample data file is located at http://www.pythonlearn.com/code/mbox-short.txt Regards, Hal Sent from Surface From: Cameron Simpson Sent: ?Wednesday?, ?July? ?29?, ?2015 ?7?:?01? ?PM To: Tutor at python.org On 29Jul2015 21:55, ltc.hotspot at gmail.com wrote: >I have a second and unrelated question: > >I tried to work backward to see if there is a logic error associated with a variable is being skipped over: > >#top of code, initialize variable >output_list = ["default"] Curious: why not just make this an empty list: [] [...snip...] >count = 0 >fname = raw_input("Enter file name: ") >if len(fname) < 1 : fname = "mbox-short.txt" >for line in fname: > line = line.strip() > if not line.startswith('From '): continue > line = line.split() >count = count + 1 >print len(line) >fh = open(fname) >print "There were", count, "lines in the file with From as the first word" [...snip...] My first observation would be that "count = count + 1" is not inside the loop. That means that it fires just once, _after_ the loop. So it will always be 1. Also, what is the purpose of this line: line = line.split() Cheers, Cameron Simpson _______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Thu Jul 30 15:36:06 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 30 Jul 2015 20:36:06 +0100 Subject: How to re-write this bash script in Python? In-Reply-To: References: Message-ID: On 30/07/2015 19:31, sutanu.das at gmail.com wrote: > #!/bin/bash > > _maillist='pager at email.com' > _hname=`hostname` > _logdir=/hadoop/logs > _dirlog=${_logdir}/directory_check.log > > _year=$(date -d "-5 hour" +%Y) > _month=$(date -d "-5 hour" +%m) > _day=$(date -d "-5 hour" +%d) > _hour=$(date -d "-5 hour" +%H) > > _hdfsdir=`hdfs dfs -ls -d /hadoop/flume_ingest_*/$_year/$_month | awk '{print $8}'` > > echo "Checking for HDFS directories:" > ${_dirlog} > echo >> ${_dirlog} > > for _currdir in $_hdfsdir > do > hdfs dfs -ls -d $_currdir/$_day/$_hour &>> ${_dirlog} > done > > if [[ `grep -i "No such file or directory" ${_dirlog}` ]]; > then > echo "Verify Flume is working for all servers" | mailx -s "HDFS Hadoop Failure on Flume: ${_hname}" -a ${_dirlog} ${_maillist} > fi > Read the documentation here https://docs.python.org/3/ and then run up your favourite editor and start typing. When and if you hit problems come back with a snippet of code that shows the problem, what you expected to happen, what actually happened, and the full traceback if there is one. Please use cut and paste to ensure that you get the data correct. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From irmen.NOSPAM at xs4all.nl Thu Jul 30 15:45:00 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Thu, 30 Jul 2015 21:45:00 +0200 Subject: using sched In-Reply-To: <420b4f03-0eb5-4f22-ae51-0018ebd613a7@googlegroups.com> References: <420b4f03-0eb5-4f22-ae51-0018ebd613a7@googlegroups.com> Message-ID: <55ba7ebd$0$2857$e4fe514c@news.xs4all.nl> On 30-7-2015 17:57, Nkansah Rexford wrote: > Using sched, how can I run a function, at for instance, exactly 00:00 GMT, and only that time. > > If sched wouldn't be the best to do so a job, please can you recommend something? > The sched module is by itself not really a task scheduler. It can be used to build one though, for example https://pypi.python.org/pypi/TGScheduler My recommendation would be however to utilize your operating system's native task scheduler (cron, or when you're on windows, the windows task scheduler). Irmen From baruchel at gmail.com Thu Jul 30 16:09:21 2015 From: baruchel at gmail.com (baruchel at gmail.com) Date: Thu, 30 Jul 2015 13:09:21 -0700 (PDT) Subject: New module (written in C) for using the high-precision QD library Message-ID: <3015c193-3a3f-468a-b998-94f77066febe@googlegroups.com> Hi, I wrote a module for wrapping the well-known high-precision QD library written by D.H. Bailey. You can find it here: https://github.com/baruchel/qd It is written in pure C with the CPython C-API in order to get the highest possible speed. The QD library provides floating number types for ~32 and ~64 decimals digits of precision and should be quicker for such precisions than other arbitrary-precision libraries. My ultimate goal is to implement these two types as new dtype for Numpy arrays, but I release here a first version which already gives a complete interface to the QD library. Regards, -- Thomas Baruchel From random832 at fastmail.us Thu Jul 30 16:17:14 2015 From: random832 at fastmail.us (random832 at fastmail.us) Date: Thu, 30 Jul 2015 16:17:14 -0400 Subject: How to re-write this bash script in Python? In-Reply-To: References: Message-ID: <1438287434.335840.337608409.5A5ECD73@webmail.messagingengine.com> On Thu, Jul 30, 2015, at 14:31, sutanu.das at gmail.com wrote: > _year=$(date -d "-5 hour" +%Y) > _month=$(date -d "-5 hour" +%m) > _day=$(date -d "-5 hour" +%d) > _hour=$(date -d "-5 hour" +%H) What is the purpose of the -5 hour offset? Is it an attempt to compensate for timezones? From martin.schoon at gmail.com Thu Jul 30 16:31:44 2015 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 30 Jul 2015 20:31:44 GMT Subject: How to rearrange array using Python? Message-ID: Here is a problem I think I should be able to solve using Python but after having searched the internet for the better part of this evening my head spins and I would apreciate some guidance. Disclaimer My formal programming training happened 35+ years ago and initially involved F77 and later Pascal. Python is something I have picked up lately and for fun. I don't master Python by any stretch of imagination. I know some linear algebra and numerical methods but don't practice any of this on a daily basis... Problem background I am just back from visiting my sisters and the younger of them was busy planning a youth orchestra summer camp. For some reason the kids are allowed to wish with whom they want to share rooms and my sister spent several evenings placing kids in rooms according to these wishes. It struck me that at least some of this work could be done by silicon running code. My thinking so far I have played around a little with something called DSM https://en.wikipedia.org/wiki/Design_structure_matrix at work and think entering all wishes into a 2D array for further processing and overview should be a good idea. An added piece of information is the number of and sizes of rooms. I want to overlay this on the array and re-shuffle until as many of the wishes as possible are fulfilled. Here is a picture that may help understanding what I am after: https://picasaweb.google.com/103341501341482571816/Miscellaneous#6177389865951753330 In this example I have 25 individuals (each allowed two wishes), one 5-bed room, two 4-bed rooms and four 3-bed rooms. Wishes are marked by "1" so a wants to sleep in the same room as i and n etc. The rooms are shown as light grey squares along the diagonal. Scores to the right show how many wishes are fulfilled in each room and at the bottom right corner I have the total score. The goal is to re-shuffle the array to maximize this score. How do I go about doing that? Note: This example is worse than the real life problem as most kids go to this camp with friends and wishes are highly coordinated. I used a random number generator to create wishes... The real problem involves some 80 kids. There are some more differences but let us leave them out for now. TIA /Martin From cs at zip.com.au Thu Jul 30 17:53:35 2015 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 31 Jul 2015 07:53:35 +1000 Subject: [Tutor] Mailbox In-Reply-To: <55ba7488.882c460a.ed373.ffff8098@mx.google.com> References: <55ba7488.882c460a.ed373.ffff8098@mx.google.com> Message-ID: <20150730215335.GA81150@cskk.homeip.net> On 30Jul2015 19:00, ltc.hotspot at gmail.com wrote: >New revision code: > >count = 0 >fn = raw_input("Enter file name: ") >if len(fn) < 1 : fname = "mbox-short.txt" >for line in fn: > if 'From' in line.split()[0]: count += 1 >print "There are %d lines starting with From" % count >print len(line) >fn = open(fname) >print "There were", count, "lines in the file with From as the first word" > > >Syntax message produced by iPython interperter: > >NameError Traceback (most recent call last) >C:\Users\vm\Desktop\apps\docs\Python\assinment_8_5_v_2.py in () > 6 print "There are %d lines starting with From" % count > 7 print len(line) >----> 8 fn = open(fname) > 9 print "There were", count, "lines in the file with From as the first wor >d" > >NameError: name 'fname' is not defined I have reposted this to the python-list. Please always reply to the list. The message above is not a syntax error. It is a NameError, which happens at runtime. It is complaining that the name "fname" is not defined. This is because you have the names "fn" and "fname" confused in your code. Based on your code, "fname" is supposed to be the filename (a string) and "fn" is meant to be the open file object (a file), since you have this line: fn = open(fname) However, you set "fn" from raw_input when you should set "fname". You also have the open() call _after_ your loop, but the loop needs to read from the open file, so these things are out of order. Cheers, Cameron Simpson From breamoreboy at yahoo.co.uk Thu Jul 30 18:21:03 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 30 Jul 2015 23:21:03 +0100 Subject: How to rearrange array using Python? In-Reply-To: References: Message-ID: On 30/07/2015 21:31, Martin Sch??n wrote: > Here is a problem I think I should be able to solve using Python but > after having searched the internet for the better part of this > evening my head spins and I would apreciate some guidance. > > Disclaimer > > My formal programming training happened 35+ years ago and > initially involved F77 and later Pascal. Python is something > I have picked up lately and for fun. I don't master Python by any > stretch of imagination. I know some linear algebra and numerical > methods but don't practice any of this on a daily basis... > > Problem background > > I am just back from visiting my sisters and the younger of them > was busy planning a youth orchestra summer camp. For some reason > the kids are allowed to wish with whom they want to share rooms > and my sister spent several evenings placing kids in rooms > according to these wishes. It struck me that at least some of this > work could be done by silicon running code. > > My thinking so far > > I have played around a little with something called DSM > https://en.wikipedia.org/wiki/Design_structure_matrix > at work and think entering all wishes into a 2D array > for further processing and overview should be a good idea. > > An added piece of information is the number of and sizes > of rooms. I want to overlay this on the array and re-shuffle > until as many of the wishes as possible are fulfilled. > > Here is a picture that may help understanding what I am after: > https://picasaweb.google.com/103341501341482571816/Miscellaneous#6177389865951753330 > In this example I have 25 individuals (each allowed two wishes), > one 5-bed room, two 4-bed rooms and four 3-bed rooms. > Wishes are marked by "1" so a wants to sleep in the same room > as i and n etc. The rooms are shown as light grey squares > along the diagonal. Scores to the right show how many wishes > are fulfilled in each room and at the bottom right corner I > have the total score. The goal is to re-shuffle the array > to maximize this score. > > How do I go about doing that? > > Note: This example is worse than the real life problem as > most kids go to this camp with friends and wishes are > highly coordinated. I used a random number generator to > create wishes... The real problem involves some 80 kids. > There are some more differences but let us leave them out > for now. > > TIA > > /Martin > I'm not absolutely certain but I think you're into what's known as a constraint satisfaction problem, in which case this https://pypi.python.org/pypi/python-constraint/1.2 is as good a starting point as any. If I'm wrong we'll soon get told :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From ltc.hotspot at gmail.com Thu Jul 30 18:31:00 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Thu, 30 Jul 2015 22:31:00 +0000 Subject: =?utf-8?Q?Re:_How_to_rearrange_array_using_Python=3F?= In-Reply-To: References: , Message-ID: <55baa637.6937460a.80ee.ffffa5dd@mx.google.com> Hi Mark, I?m still confused because line 4 reads: fh=open(fname,'r') # Open a new file handle, not fn = open(fname) Can you write down line by line from error to correction? Hal Sent from Surface From: Mark Lawrence Sent: ?Thursday?, ?July? ?30?, ?2015 ?3?:?21? ?PM To: python-list at python.org On 30/07/2015 21:31, Martin Sch??n wrote: > Here is a problem I think I should be able to solve using Python but > after having searched the internet for the better part of this > evening my head spins and I would apreciate some guidance. > > Disclaimer > > My formal programming training happened 35+ years ago and > initially involved F77 and later Pascal. Python is something > I have picked up lately and for fun. I don't master Python by any > stretch of imagination. I know some linear algebra and numerical > methods but don't practice any of this on a daily basis... > > Problem background > > I am just back from visiting my sisters and the younger of them > was busy planning a youth orchestra summer camp. For some reason > the kids are allowed to wish with whom they want to share rooms > and my sister spent several evenings placing kids in rooms > according to these wishes. It struck me that at least some of this > work could be done by silicon running code. > > My thinking so far > > I have played around a little with something called DSM > https://en.wikipedia.org/wiki/Design_structure_matrix > at work and think entering all wishes into a 2D array > for further processing and overview should be a good idea. > > An added piece of information is the number of and sizes > of rooms. I want to overlay this on the array and re-shuffle > until as many of the wishes as possible are fulfilled. > > Here is a picture that may help understanding what I am after: > https://picasaweb.google.com/103341501341482571816/Miscellaneous#6177389865951753330 > In this example I have 25 individuals (each allowed two wishes), > one 5-bed room, two 4-bed rooms and four 3-bed rooms. > Wishes are marked by "1" so a wants to sleep in the same room > as i and n etc. The rooms are shown as light grey squares > along the diagonal. Scores to the right show how many wishes > are fulfilled in each room and at the bottom right corner I > have the total score. The goal is to re-shuffle the array > to maximize this score. > > How do I go about doing that? > > Note: This example is worse than the real life problem as > most kids go to this camp with friends and wishes are > highly coordinated. I used a random number generator to > create wishes... The real problem involves some 80 kids. > There are some more differences but let us leave them out > for now. > > TIA > > /Martin > I'm not absolutely certain but I think you're into what's known as a constraint satisfaction problem, in which case this https://pypi.python.org/pypi/python-constraint/1.2 is as good a starting point as any. If I'm wrong we'll soon get told :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Thu Jul 30 18:41:48 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 30 Jul 2015 23:41:48 +0100 Subject: How to rearrange array using Python? In-Reply-To: <55baa637.6937460a.80ee.ffffa5dd@mx.google.com> References: <55baa637.6937460a.80ee.ffffa5dd@mx.google.com> Message-ID: On 30/07/2015 23:31, ltc.hotspot at gmail.com wrote: > Hi Mark, > > I?m still confused because line 4 reads: fh=open(fname,'r') # Open a new > file handle, not fn = open(fname) > > Can you write down line by line from error to correction? > I'd think about it if you could find the correct thread :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From ltc.hotspot at gmail.com Thu Jul 30 20:00:22 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Fri, 31 Jul 2015 00:00:22 +0000 Subject: =?utf-8?Q?'open'_is_not_defined?= Message-ID: <55babad0.c25e460a.2b9e.ffffb3cd@mx.google.com> Hi Everyone: Why is open not defined in the following code:NameError: name 'open' is not defined Code reads as follows: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 for line in fh: if not line.startswith('From'): continue line2 = line.strip() line3 = line2.split() line4 = line3[1] print line4 count = count + 1 print "There were", count, "lines in the file with From as the first word" Regards, Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From robin.koch at t-online.de Thu Jul 30 21:18:20 2015 From: robin.koch at t-online.de (Robin Koch) Date: Fri, 31 Jul 2015 03:18:20 +0200 Subject: How to rearrange array using Python? In-Reply-To: References: Message-ID: Am 30.07.2015 um 22:31 schrieb Martin Sch??n: > Scores to the right show how many wishes are fulfilled in each room Is it possible the is a mistake in the sum column on the third row? Should the be a 1? > The goal is to re-shuffle the array to maximize this score. > > How do I go about doing that? Depending on how you store those wishes I'd think you can use random.shuffle()!? But do you think simply maximising the score is the optimal solution to the problem? That way some kids will get their both wishes fulfilled (s, e and p in your example), while other kids not even one (r, z, j, v, c, y, g, m, d). Shouldn't be the goal to maximise the number of kinds which get at least one wished kid in the same room? (I hesitate writing "friend", since you maybe wouldn't want to be picked by someone... Friend would be pairs of kids picking each other. Another thing one might want to takeinto account. :-)) -- Robin Koch From Dwight at GoldWinde.com Thu Jul 30 21:22:33 2015 From: Dwight at GoldWinde.com (Dwight GoldWinde) Date: Fri, 31 Jul 2015 09:22:33 +0800 Subject: I'm a newbie and I'm stumped... Message-ID: Please help. I am running Python 3.4 on my Mac mini, OS X 10.10.2, using Coderunner 2 as my editor. Here?s the code: #!/usr/bin/env python3 word = (input('Enter a word ?)) When running this inside of Coderunner, I get the follow error, after entering the word ?serendipity?: Enter a word serendipity Traceback (most recent call last): File "test short.py", line 2, in word = (input('Enter a word ')) File "", line 1, in NameError: name 'serendipity' is not defined -------------- next part -------------- An HTML attachment was scrubbed... URL: From seanmavley at gmail.com Thu Jul 30 21:49:12 2015 From: seanmavley at gmail.com (Nkansah Rexford) Date: Thu, 30 Jul 2015 18:49:12 -0700 (PDT) Subject: using sched In-Reply-To: <55ba7ebd$0$2857$e4fe514c@news.xs4all.nl> References: <420b4f03-0eb5-4f22-ae51-0018ebd613a7@googlegroups.com> <55ba7ebd$0$2857$e4fe514c@news.xs4all.nl> Message-ID: Great. Thanks From PointedEars at web.de Thu Jul 30 22:29:47 2015 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Fri, 31 Jul 2015 04:29:47 +0200 Subject: How to rearrange array using Python? References: Message-ID: <1468455.P0rGZF1LBf@PointedEars.de> Mark Lawrence wrote: > On 30/07/2015 21:31, Martin Sch??n wrote: >> I am just back from visiting my sisters and the younger of them >> was busy planning a youth orchestra summer camp. For some reason >> the kids are allowed to wish with whom they want to share rooms >> and my sister spent several evenings placing kids in rooms >> according to these wishes. It struck me that at least some of this >> work could be done by silicon running code. >> [?] >> An added piece of information is the number of and sizes >> of rooms. I want to overlay this on the array and re-shuffle >> until as many of the wishes as possible are fulfilled. >> [?] >> How do I go about doing that? >> >> Note: This example is worse than the real life problem as >> most kids go to this camp with friends and wishes are >> highly coordinated. I used a random number generator to >> create wishes... The real problem involves some 80 kids. >> There are some more differences but let us leave them out >> for now. > > I'm not absolutely certain but I think you're into what's known as a > constraint satisfaction problem, in which case this > https://pypi.python.org/pypi/python-constraint/1.2 is as good a starting > point as any. If I'm wrong we'll soon get told :) It is a CSP indeed, and as I was reading the OP I was thinking of SWI- Prolog, not Python, for the solution. Using a PRNG and simple reshuffling cannot be the correct approach because you cannot be sure that you do not get the same number twice, the same solution twice, and that you can solve the problem in finite time. The correct approach, *a* correct approach at least, is as you would do without computers: keeping track of the solutions, backtracking, and discarding the solutions that were worse than the so-far- best one. However, fascinating to learn that Python has something to offer for CSPs, too. Please trim your quotes to the relevant minimum. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. From dieter at handshake.de Fri Jul 31 02:07:23 2015 From: dieter at handshake.de (dieter) Date: Fri, 31 Jul 2015 08:07:23 +0200 Subject: Logical Query JSON References: <36c251da-3dc0-47ee-8831-c6ae5d092aa1@googlegroups.com> Message-ID: <871tfoj1wk.fsf@handshake.de> subhabrata.banerji at gmail.com writes: > ... > I am trying to quote some of my exercises below, and my objective. A general remark. Python errror messages are quite good (unlike e.g. many Microsoft or Oracle error messages). You can almost always trust them. Thus, if you get a "SyntaxError", something with your Python syntax is wrong (Python is *very* sensitive to leading spaces, take case to get the correct indentation). An "AttributeError" means that you used the attribute access syntax ("obj.attr") for something which was not an attribute. Etc... > (1) Exercise with objectpath: >>>> from objectpath import * >>>> tree=Tree({"a":1}) >>>> tree.execute("$.a") > 1 >>>> $ > { > "a":1, > "b":{ > "c":[1,2,3] > } > } > SyntaxError: invalid syntax This looks a bit strange: "$" is not a Python name - thus, it could give a "SyntaxError" - but then, you should not see the dict like representation between the "$" and the "SyntaxError". Anyway, the dict like representation looks out of place - where does it come from? >>>> x1={"a":1,"b":{"c":[1,2,3]}} >>>> x1.b > > Traceback (most recent call last): > File "", line 1, in > x1.b > AttributeError: 'dict' object has no attribute 'b' "x1" is a dict and access to its keys is via subscription syntax ("mapping[key]"), not the attribute access syntax ("obj.attr"). >>>> x1."b" > SyntaxError: invalid syntax The "attr" in the attribute access syntax "obj.attr" must be a Python name, not an expression (such as the string '"b"'). The correct access to "b" would be 'x["b"]'. > (2) Exercise from IBM Example: > >>>> x1={"or":[{"age":4},{"name":"Joe"}]} >>>> x2=x1 >>>> print x2 > {'or': [{'age': 4}, {'name': 'Joe'}]} >>>> x1['age'] > > Traceback (most recent call last): > File "", line 1, in > x1['age'] > KeyError: 'age' "x1" is a dict with a single key "or". The value for "or" is a list with two dicts. The get the dict for "age", you would use 'x1["or"][0]'; to get the age value 'x1["or"][0]["age"]'. >>>> x1['or'] > [{'age': 4}, {'name': 'Joe'}] >>>> x1['or']['age'] > > Traceback (most recent call last): > File "", line 1, in > x1['or']['age'] > TypeError: list indices must be integers, not str 'x1["or"]' is a list, not a dict. >>>> x1['or'][0] > {'age': 4} >>>> x1['or'][1] > {'name': 'Joe'} You are making progress.... > > My expectation is: > > If I do AND, NOT, OR with two or more JSON values like > {"age":4}, {"name":"Joe"}, ...etc. then I should get recirprocal > results. > Considering each one as Python variable and applying logical Python > operation helps, but I am looking a smarter solution. You might need to read through the Python tutorial - in order to get a thorough understanding of * attribute versus subscription access, * Python's simple data types (such as "dict"s, "list"s, etc.) and how they are represented when printed * what the various error messages (such as "SyntaxError", "AttributeError", "KeyError", "TypeError", ...) mean. Keep in mind that Python is a (more or less) "general purpose" language which does not know about "jsonquery". It has "and", "or" and "not" operators (defined in the language reference) *BUT* these are not the operators you are looking for. You will need a special "jsonquery" extension (search "http://pypi.python.org" to find out whether there is something like this) which would provide appropriate support. From dieter at handshake.de Fri Jul 31 02:15:47 2015 From: dieter at handshake.de (dieter) Date: Fri, 31 Jul 2015 08:15:47 +0200 Subject: Improper Django Project error References: <55BA6563.8050603@verizon.net> Message-ID: <87wpxghmy4.fsf@handshake.de> Gary Roach writes: > Being new to Django and Python, I have two projects setup side by > side, each in it's own virtualenv wrapper. > The twr_project is running Django 1.7, python 2.7 and is set up to > duplicate the 'Tango With Rango' tutorial. > The archivedb project is running Django 1.8, python 2.7 and is my > actual project. As this is more a "Django" (than a general "Python") question, you might get better help in a "Django" mailing list/support forum. Your "subject" indicates that you likely see (somewhere) the "Django" error message "Improper Django Project error". Likely, you have corrupted you "Django" project setup. Read about how "Django" projects must look like and fix your setup. > I am using Ninja-IDE as my IDE. I like it a lot. > > At this point both projects are essentially identical with the > exception of name changes. The twr project work down to the first > template inclusion ( index.html ). The archivedb project refuses to > find the home.html template file. The system layout is exactly the > same. > > I wiped the home.html file and attempted to re-install it but my IDE > gave the following error window: > >> Sorry, either settings file or virtualenv are missingthese are >> required for Django Plugin to work in thepresent version, we are >> working on fixing this. >> > I have virtualenv installed and active and the settings file is > present. You should ask this question on a "Ninja-IDE" mailing list/support forum. From dieter at handshake.de Fri Jul 31 02:22:46 2015 From: dieter at handshake.de (dieter) Date: Fri, 31 Jul 2015 08:22:46 +0200 Subject: 'open' is not defined References: <55babad0.c25e460a.2b9e.ffffb3cd@mx.google.com> Message-ID: <87si84hmmh.fsf@handshake.de> writes: > ... > Why is open not defined in the following code:NameError: name 'open' is not defined > > Code reads as follows: > > fname = raw_input("Enter file name: ") > if len(fname) < 1 : fname = "mbox-short.txt" > fh = open(fname) > count = 0 > for line in fh: > if not line.startswith('From'): continue > line2 = line.strip() > line3 = line2.split() > line4 = line3[1] > print line4 > count = count + 1 > print "There were", count, "lines in the file with From as the first word" You might execute the code above in a "restricted execution environment" (one where "__builtins__" is not the typical "__builtin__" module -- that's how "open" (and other builtins) is found). From no.email at nospam.invalid Fri Jul 31 02:33:24 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 30 Jul 2015 23:33:24 -0700 Subject: GvR Europython keynote described on lwn.net Message-ID: <87r3noltu3.fsf@jester.gateway.sonic.net> https://lwn.net/Articles/651967/ Excerpts: He then moved on to Python 3.5, which is due in September. He would have trouble choosing a favorite feature from the release because there are "way too many cool things" in it.... Perhaps his favorite 3.5 feature should be type hints, since it is a PEP he worked on himself. It took a lot of work for the PEP to get accepted, which is a little bizarre since he is the benevolent dictator for life (BDFL) and could accept his own PEP. But he wanted to have independent review and acceptance of the PEP, which Mark Shannon was graciously willing to provide as the BDFL delegate, he said. ... If you caught him unaware, though, he probably would name the new async and await keywords for coroutines as his favorite. It was the last PEP accepted for 3.5 and it provides a more natural way of specifying coroutines. ... [regarding age of bugs in Python bug tracker] If you pick any bug at random, including closed bugs, you would likely get a closed bug. Many bugs are closed quickly and bugs that are easy to fix tend to get fixed quickly. But the average lifetime of an open bug grows linearly with the age of the project, he said. [On designing a new language, and the GIL] If you were to design a new language today, he said, you would make it without mutable (changeable) objects, or with limited mutability. From the audience, though, came: "That would not be Python." Van Rossum agreed: "You took the words out of my mouth." There are various ongoing efforts to get around the GIL, including the PyPy software transactional memory (STM) work and PyParallel. Other developers are also "banging their head against that wall until it breaks". If anyone has ideas on how to remove the GIL but still keep the language as Python, he (and others) would love to hear about it. [PyPy, and how GvR and Dropbox use Python] He was asked about PyPy, whether he used it and whether it might someday become the default interpreter. He does not use PyPy, but he does download it once in a while, plays with it for a few minutes, and likes what he sees. He uses Python in two modes, either writing a short little script to get something done, for which he just uses one of the interpreters he already has built on his system, or as a Dropbox engineer deploying Python code to its cluster. The Dropbox cluster runs a modified Python 2.7, he said, which elicited audience laughter. "I said it, it is no secret", he said. [Favorites] Five short questions about his favorites was up next. Favorite web framework? He said he only writes one web app in any framework and that the last he tried was Flask. Favorite testing library? He mostly just uses unittest and mock from the standard library. Editor? He uses Emacs, but started out with vi (both of which were greeted with applause, presumably by different sets of audience members). He still uses vi (or Vim) occasionally, but if he does that for five minutes, it takes him fifteen minutes to get used to Emacs again. [Anti-favorites] The final question was about what he hates in Python. "Anything to do with package distribution", he answered immediately. There are problems with version skew and dependencies that just make for an "endless mess". He dreads it when a colleague comes to him with a "simple Python question". Half the time it is some kind of import path problem and there is no easy solution to offer. From ltc.hotspot at gmail.com Fri Jul 31 02:34:34 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Fri, 31 Jul 2015 06:34:34 +0000 Subject: =?utf-8?Q?Re:_'open'_is_not_defined?= In-Reply-To: <87si84hmmh.fsf@handshake.de> References: <55babad0.c25e460a.2b9e.ffffb3cd@mx.google.com>, <87si84hmmh.fsf@handshake.de> Message-ID: <55bb181c.6567460a.a006c.fffff5f1@mx.google.com> Dieter, Thanks. What about using the append function to remove duplicate outputs entered on or thereafter line no. 9, i.e., LIST_APPEND(i) Calls list.append(TOS[-i], TOS). Used to implement list comprehensions. While the appended value is popped off, the list object remains on the stack so that it is available for further iterations of the loop. URL link available at https://docs.python.org/2.7/library/dis.html?highlight=append%20list#opcode-LIST_APPEND What is the command line for such an append function? Hal Sent from Surface Sent from Surface From: dieter Sent: ?Thursday?, ?July? ?30?, ?2015 ?11?:?22? ?PM To: python-list at python.org writes: > ... > Why is open not defined in the following code:NameError: name 'open' is not defined > > Code reads as follows: > > fname = raw_input("Enter file name: ") > if len(fname) < 1 : fname = "mbox-short.txt" > fh = open(fname) > count = 0 > for line in fh: > if not line.startswith('From'): continue > line2 = line.strip() > line3 = line2.split() > line4 = line3[1] > print line4 > count = count + 1 > print "There were", count, "lines in the file with From as the first word" You might execute the code above in a "restricted execution environment" (one where "__builtins__" is not the typical "__builtin__" module -- that's how "open" (and other builtins) is found). -- https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Fri Jul 31 03:16:32 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Fri, 31 Jul 2015 00:16:32 -0700 (PDT) Subject: GvR Europython keynote described on lwn.net In-Reply-To: <87r3noltu3.fsf@jester.gateway.sonic.net> References: <87r3noltu3.fsf@jester.gateway.sonic.net> Message-ID: <3a20bb75-c07b-4eea-ab72-1a31f9decf50@googlegroups.com> On Friday, July 31, 2015 at 12:03:36 PM UTC+5:30, Paul Rubin wrote: > The final question was about what he hates in Python. "Anything to do > with package distribution", he answered immediately. There are problems > with version skew and dependencies that just make for an "endless > mess". He dreads it when a colleague comes to him with a "simple Python > question". Half the time it is some kind of import path problem and > there is no easy solution to offer. Heh! I'm in good company! From stefan_ml at behnel.de Fri Jul 31 03:26:41 2015 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 31 Jul 2015 09:26:41 +0200 Subject: New module (written in C) for using the high-precision QD library In-Reply-To: <3015c193-3a3f-468a-b998-94f77066febe@googlegroups.com> References: <3015c193-3a3f-468a-b998-94f77066febe@googlegroups.com> Message-ID: baruchel at gmail.com schrieb am 30.07.2015 um 22:09: > It is written in pure C with the CPython C-API in order to get the highest possible speed. This is a common fallacy. Cython should still be able to squeeze another bit of performance out of your wrapper for you. It tends to know the C-API better than you would think, and it does things for you that you would never do in C. It also helps in keeping your code safer and easier to maintain. Your C code seems to be only about 1500 lines, not too late to translate it. That should save you a couple of hundred lines and at the same time make it work with Python 3 (which it currently doesn't, from what I see). Stefan From rosuav at gmail.com Fri Jul 31 03:37:20 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 31 Jul 2015 17:37:20 +1000 Subject: New module (written in C) for using the high-precision QD library In-Reply-To: References: <3015c193-3a3f-468a-b998-94f77066febe@googlegroups.com> Message-ID: On Fri, Jul 31, 2015 at 5:26 PM, Stefan Behnel wrote: > Your C code seems to be only about 1500 lines, not too late to translate > it. That should save you a couple of hundred lines and at the same time > make it work with Python 3 (which it currently doesn't, from what I see). I was just looking over the README (literally two minutes ago, your message came in as I was wording up a reply), and Python 3 support does seem to be a bit of a hole in the support. To what extent does Cython make this easier? The biggest barrier I would expect to see is the bytes/text distinction, where a default quoted string has different meaning in the two versions - but like with performance guessing, this is much more likely to be wrong than right. Another, but much smaller, hole in the support would be installation via pip. I'd recommend getting the package listed on PyPI and then testing some pip installations on different platforms - chances are that's going to be the best way to do the builds. All the best! ChrisA From rosuav at gmail.com Fri Jul 31 03:47:13 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 31 Jul 2015 17:47:13 +1000 Subject: How to re-write this bash script in Python? In-Reply-To: References: Message-ID: On Fri, Jul 31, 2015 at 4:31 AM, wrote: > #!/bin/bash > > _maillist='pager at email.com' > _hname=`hostname` > _logdir=/hadoop/logs > _dirlog=${_logdir}/directory_check.log > > _year=$(date -d "-5 hour" +%Y) > _month=$(date -d "-5 hour" +%m) > _day=$(date -d "-5 hour" +%d) > _hour=$(date -d "-5 hour" +%H) > > _hdfsdir=`hdfs dfs -ls -d /hadoop/flume_ingest_*/$_year/$_month | awk '{print $8}'` > > echo "Checking for HDFS directories:" > ${_dirlog} > echo >> ${_dirlog} > > for _currdir in $_hdfsdir > do > hdfs dfs -ls -d $_currdir/$_day/$_hour &>> ${_dirlog} > done > > if [[ `grep -i "No such file or directory" ${_dirlog}` ]]; > then > echo "Verify Flume is working for all servers" | mailx -s "HDFS Hadoop Failure on Flume: ${_hname}" -a ${_dirlog} ${_maillist} > fi > -- > https://mail.python.org/mailman/listinfo/python-list There are two basic approaches to this kind of job. 1) Go through every line of bash code and translate it into equivalent Python code. You should then have a Python script which blindly and naively accomplishes the same goal by the same method. 2) Start by describing what you want to accomplish, and then implement that in Python, using algorithmic notes from the bash code. The second option seems like a lot more work, but long-term it often isn't, because you end up with better code. For example, bash lacks decent timezone support, so I can well believe random832's guess that your five-hour offset is a simulation of that; but Python can do much better work with timezones, so you can get that actually correct. Also, file handling, searching, and text manipulation and so on can usually be done more efficiently and readably in Python directly than by piping things through grep and awk. ChrisA From cs at zip.com.au Fri Jul 31 04:15:03 2015 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 31 Jul 2015 18:15:03 +1000 Subject: How to re-write this bash script in Python? In-Reply-To: References: Message-ID: <20150731081503.GA12474@cskk.homeip.net> On 31Jul2015 17:47, Chris Angelico wrote: >On Fri, Jul 31, 2015 at 4:31 AM, wrote: >> #!/bin/bash [...] >> _year=$(date -d "-5 hour" +%Y) >> _month=$(date -d "-5 hour" +%m) [...] >For example, bash lacks >decent timezone support, so I can well believe random832's guess that >your five-hour offset is a simulation of that; but Python can do much >better work with timezones, so you can get that actually correct. Actually, bash has no timezone support but the date command _does_, and probably neither better nor worse than Python. All one has to do is set the TZ environment variable, eg (untested): _year_gmt=$( TZ=GMT date +%Y ) >Also, file handling, searching, and text manipulation and so on can >usually be done more efficiently and readably in Python directly than >by piping things through grep and awk. Again, depends a bit on the data. But in the general case probably true. Cheers, Cameron Simpson From rosuav at gmail.com Fri Jul 31 04:26:38 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 31 Jul 2015 18:26:38 +1000 Subject: How to re-write this bash script in Python? In-Reply-To: <20150731081503.GA12474@cskk.homeip.net> References: <20150731081503.GA12474@cskk.homeip.net> Message-ID: On Fri, Jul 31, 2015 at 6:15 PM, Cameron Simpson wrote: >> For example, bash lacks >> decent timezone support, so I can well believe random832's guess that >> your five-hour offset is a simulation of that; but Python can do much >> better work with timezones, so you can get that actually correct. > > > Actually, bash has no timezone support but the date command _does_, and > probably neither better nor worse than Python. All one has to do is set the > TZ environment variable, eg (untested): > > _year_gmt=$( TZ=GMT date +%Y ) That's assuming that it's converting against the current system timezone. I don't know how you'd use `date` to convert between two arbitrary timezones. But anyway, still justification to rewrite from original spec rather than reimplementing the five-hour hack. ChrisA From stefan_ml at behnel.de Fri Jul 31 04:40:14 2015 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 31 Jul 2015 10:40:14 +0200 Subject: New module (written in C) for using the high-precision QD library In-Reply-To: References: <3015c193-3a3f-468a-b998-94f77066febe@googlegroups.com> Message-ID: Chris Angelico schrieb am 31.07.2015 um 09:37: > On Fri, Jul 31, 2015 at 5:26 PM, Stefan Behnel wrote: >> Your C code seems to be only about 1500 lines, not too late to translate >> it. That should save you a couple of hundred lines and at the same time >> make it work with Python 3 (which it currently doesn't, from what I see). > > To what extent does Cython make this easier? The biggest barrier I > would expect to see is the bytes/text distinction Yes, that tends to be a barrier. Cython is mostly just Python, so you can write if isinstance(s, unicode): s = ( s).encode('utf8') and be happy with it ("" is a cast in Cython). Such simple code looks uglier when spelled out using the C-API and wouldn't be any CPU cycle faster. But there's also the PyInt/PyLong unification, which can easily get in the way for a number processing library. In Cython, you can write if isinstance(x, (int, long)): try: c_long = x except OverflowError: ... # do slow conversion of large integer here else: ... # do fast conversion from c_long here or something like that and it'll work in Py2.6 through Py3.5 because Cython does the necessary adaptations internally for you. This code snippet already has a substantially faster fast-path than what the OP's code does and it will still be much easier to tune later, in case you notice that the slow path is too slow after all. And then there are various helpful little features in the language like, say, C arrays assigning by value, or freelists for extension types using a decorator. The OP's code would clearly benefit from those, if only for readability. Python is much easier to write and maintain than C. Cython inherits that property and expands it across C data types. And it generates C code for you that automatically adapts to the different Python versions in various ways, both in terms of compatibility and performance. Stefan From antoon.pardon at rece.vub.ac.be Fri Jul 31 04:47:13 2015 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 31 Jul 2015 10:47:13 +0200 Subject: Interactive entered code, inserts spurious numbers. Message-ID: <55BB3611.5080304@rece.vub.ac.be> I'm using python 3.4.2 on debian 8. This is the code: ==== 8< ===== import sys write = sys.stdout.write from math import pi frac = 3 for a in range(2 * frac): write("%2d: %6.4f\n" % (a, a * pi / frac)) ===== 8< ==== Now when this code is written in a file and executed I get the expected result: 0: 0.0000 1: 1.0472 2: 2.0944 3: 3.1416 4: 4.1888 5: 5.2360 But when I enter this code interactively in the interpreter I get the following result: 0: 0.0000 11 1: 1.0472 11 2: 2.0944 11 3: 3.1416 11 4: 4.1888 11 5: 5.2360 11 That is different behaviour from python2, which gives me the expected result. My guess is that the write returns 11, being the number of characters written en that the interpreter, shows that each time through the loop. But is this the expected behaviour in python3? I find it annoying. From rosuav at gmail.com Fri Jul 31 05:02:36 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 31 Jul 2015 19:02:36 +1000 Subject: Interactive entered code, inserts spurious numbers. In-Reply-To: <55BB3611.5080304@rece.vub.ac.be> References: <55BB3611.5080304@rece.vub.ac.be> Message-ID: On Fri, Jul 31, 2015 at 6:47 PM, Antoon Pardon wrote: > That is different behaviour from python2, which gives me > the expected result. My guess is that the write returns > 11, being the number of characters written en that the > interpreter, shows that each time through the loop. > > But is this the expected behaviour in python3? I find > it annoying. It is; it's the behaviour of the interactive interpreter. If you want to disable that, change sys.displayhook to not print stuff out, or assign to a dummy variable. ChrisA From steve at pearwood.info Fri Jul 31 05:30:21 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 31 Jul 2015 19:30:21 +1000 Subject: Interactive entered code, inserts spurious numbers. References: Message-ID: <55bb402d$0$1657$c3e8da3$5496439d@news.astraweb.com> On Fri, 31 Jul 2015 06:47 pm, Antoon Pardon wrote: > That is different behaviour from python2, which gives me > the expected result. My guess is that the write returns > 11, being the number of characters written en that the > interpreter, shows that each time through the loop. In Python 3, write returns the number of characters written (or bytes written, when in binary mode). At the interactive interpreter, results returned but not assigned to anything are printed. > But is this the expected behaviour in python3? I find > it annoying. Yes, expected. dontcare = write("%2d: %6.4f\n" % (a, a * pi / frac)) -- Steven From PointedEars at web.de Fri Jul 31 06:35:29 2015 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Fri, 31 Jul 2015 12:35:29 +0200 Subject: Convert between timezones (was: How to re-write this bash script in Python?) References: <20150731081503.GA12474@cskk.homeip.net> Message-ID: <2716432.pTP2q8pAs5@PointedEars.de> [X-Post & F'up2 comp.unix.shell] Chris Angelico wrote: > On Fri, Jul 31, 2015 at 6:15 PM, Cameron Simpson wrote: >> Actually, bash has no timezone support but the date command _does_, and >> probably neither better nor worse than Python. All one has to do is set >> the TZ environment variable, eg (untested): >> >> _year_gmt=$( TZ=GMT date +%Y ) > > That's assuming that it's converting against the current system > timezone. I don't know how you'd use `date` to convert between two > arbitrary timezones. [?] With POSIX date(1), ISTM all you could do is set the system time and for an additional invocation the TZ variable accordingly for output. With GNU date(1): $ (tz_source="Asia/Dubai"; time_source="$(LC_TIME=C TZ=$tz_source date -d "today 00:00 UTC+4" -Im)"; tz_target="America/Chicago"; echo "When it was $time_source in $tz_source, it was $(LC_TIME=C TZ=$tz_target date -d "$time_source") in $tz_target.") When it was 2015-07-31T00:00+0400 in Asia/Dubai, it was Thu Jul 30 15:00:00 CDT 2015 in America/Chicago. $ date --version date (GNU coreutils) 8.23 [?] :) -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. From denismfmcmahon at gmail.com Fri Jul 31 08:36:52 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Fri, 31 Jul 2015 12:36:52 +0000 (UTC) Subject: Logical Query JSON References: <36c251da-3dc0-47ee-8831-c6ae5d092aa1@googlegroups.com> Message-ID: On Fri, 31 Jul 2015 08:07:23 +0200, dieter wrote: > Keep in mind that Python is a (more or less) "general purpose" language > which does not know about "jsonquery". It has "and", "or" and "not" > operators (defined in the language reference) *BUT* these are not the > operators you are looking for. > You will need a special "jsonquery" extension (search > "http://pypi.python.org" to find out whether there is something like > this) > which would provide appropriate support. Actually it's not too hard. You can construct the json query syntax fairly easily from python once you understand it: >>> import json >>> query = json.dumps( { "$and":[ { "$gt": {"age": 5} }, { "$not": {"name": "curly"} } ] } ) >>> query '{"$and": [{"$gt": {"age": 5}}, {"$not": {"name": "curly"}}]}' -- Denis McMahon, denismfmcmahon at gmail.com From invalid at invalid.invalid Fri Jul 31 10:26:28 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 31 Jul 2015 14:26:28 +0000 (UTC) Subject: How to re-write this bash script in Python? References: Message-ID: On 2015-07-31, Chris Angelico wrote: > There are two basic approaches to this kind of job. > > 1) Go through every line of bash code and translate it into > equivalent Python code. You should then have a Python script which > blindly and naively accomplishes the same goal by the same method. In my experience, that works OK for C (with a little post-translation tweaking and re-factoring). But, it's a pretty lousy method for bash scripts. There are a lot of things that are trivial in Python and complex/hard in bash (and a few vice versa), so a direct translation usually turns out to be a mess. You end up with a lot of Python code where only a couple lines are really needed. You also end up doing things in a bizarre manner in Python because the simple, easy, right way wasn't supported by bash. > 2) Start by describing what you want to accomplish, and then > implement that in Python, using algorithmic notes from the bash code. > > The second option seems like a lot more work, but long-term it often > isn't, because you end up with better code. And the code works. :) For bash, I really recommend 2) -- Grant Edwards grant.b.edwards Yow! GOOD-NIGHT, everybody at ... Now I have to go gmail.com administer FIRST-AID to my pet LEISURE SUIT!! From rosuav at gmail.com Fri Jul 31 10:53:00 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 1 Aug 2015 00:53:00 +1000 Subject: How to re-write this bash script in Python? In-Reply-To: References: Message-ID: On Sat, Aug 1, 2015 at 12:26 AM, Grant Edwards wrote: > On 2015-07-31, Chris Angelico wrote: > >> There are two basic approaches to this kind of job. >> >> 1) Go through every line of bash code and translate it into >> equivalent Python code. You should then have a Python script which >> blindly and naively accomplishes the same goal by the same method. > > In my experience, that works OK for C (with a little post-translation > tweaking and re-factoring). But, it's a pretty lousy method for bash > scripts. There are a lot of things that are trivial in Python and > complex/hard in bash (and a few vice versa), so a direct translation > usually turns out to be a mess. You end up with a lot of Python code > where only a couple lines are really needed. You also end up doing > things in a bizarre manner in Python because the simple, easy, right > way wasn't supported by bash. Right. The two techniques I suggested can be generalized to any language pair, but some work better this way than others do. Shell scripts are something of a special case, because they're massively optimized toward running other programs and piping output into input, which applications languages like Python are not as good at; so the naive transformation leads to code that goes to ridiculous lengths to invoke five subprocesses and move data between them, where a more intelligent approach might invoke one process, and then do the rest in Python code. The trouble is, you really need to know what your code is doing, because the non-naive transformation generally has a different set of assumptions. For instance, the OP's shell script calls on the 'mailx' command. What's it do? Presumably it sends an email... well, Python can do that. But what if the mailx command on this host has been carefully configured to pass mail along via a specific relay host, and that direct access on port 25 has been blocked? How would you know? So it's not just a matter of translating the script, you have to know its execution environment as well. >> 2) Start by describing what you want to accomplish, and then >> implement that in Python, using algorithmic notes from the bash code. >> >> The second option seems like a lot more work, but long-term it often >> isn't, because you end up with better code. > > And the code works. :) > > For bash, I really recommend 2) Yeah. You remove the ability for environmental changes to unexpectedly affect the script, which is often a feature and not a bug. ChrisA From cannedham284 at hotmail.com Fri Jul 31 12:15:00 2015 From: cannedham284 at hotmail.com (Ben Iannitelli) Date: Fri, 31 Jul 2015 12:15:00 -0400 Subject: My code won't work if I double click the saved file In-Reply-To: References: <04881038-a14e-4469-be33-7fcd77496f67@googlegroups.com>, <20150730020633.GA13546@cskk.homeip.net>, Message-ID: > > On 29Jul2015 00:20, john wrote: > >> I have windows 8 running on my computer and I think I downloaded > >> python 2 and 3 simultaneously or I think my computer has built in > >> python 2 and I downloaded python 3. John, Sorry to back-track this conversation, but would you mind telling us some more about how you installed Python on your computer in the first place? For example, I run Windows 8.1 on my computer, and at the time that I installed Python I used the installer provided on the official Python site. When the wizard was done, I had a file called 'Python33' at the top level of C: (I haven't gotten around to Python 3.4 yet), so I know that I installed version 3.3 at root level. Everyone else: sorry if I messed up with this post somehow, it's my first time writing back to anyone on the newsletter. -Ben I. -------------- next part -------------- An HTML attachment was scrubbed... URL: From elchino at cnn.cn Fri Jul 31 12:30:52 2015 From: elchino at cnn.cn (ElChino) Date: Fri, 31 Jul 2015 18:30:52 +0200 Subject: Python launcher problem In-Reply-To: References: Message-ID: Zachary Ware wrote: > On Jul 30, 2015 2:05 AM, "ElChino" > wrote: > > > > If I in a cmd-shell (actually it is 4NT), do: > > c:>py -3 -V & python3 -V > > > > I get: > > Requested Python version (3) not installed << ! from py -3 -V > > Python 3.5.0b2 << ! from the 2nd cmd. > > > > What nonsense is this? I DO HAVE Python3 in my %PATH. > > A Registry setting gone haywire? > > Did you perchance rename the installed 'python.exe' to 'python3.exe'? > That would be enough to break the launcher. If you want a 'python3' > command, you can copy 'python.exe' to 'python3.exe', but 'python.exe' > needs to remain where it was. That's what I did: ls -l f:/ProgramFiler/Python35/python*.exe -rwxr-xr-x 1 XX Administratorer 37664 May 31 04:18 f:/ProgramFiler/Python35/python.exe -rwxr-xr-x 1 XX Administratorer 37664 May 31 04:18 f:/ProgramFiler/Python35/python3.exe -rwxr-xr-x 1 XX Administratorer 37664 May 31 04:18 f:/ProgramFiler/Python35/pythonw.exe They all depends on: f:\ProgramFiler\Python35\python35.dll The one and only python35.dll on this box. And also on PATH. I took Ben Finney's advice to heart. From: http://code.activestate.com/lists/python-list/684547/ Calling ?python? is now ambiguous, and with Python 2 slipping inexorably into the past, increasingly the ?python? command is the wrong choice for code that we want to survive in the future. I am seeing a growing call, with which I agree, to recommend explicitly calling ?python2? or ?python3? as commands. That's why I made that copy; even if some of you find that strange on Windows. I'll investigate is there's an issue with the Registry later. From percy.k1234 at gmail.com Fri Jul 31 14:07:41 2015 From: percy.k1234 at gmail.com (Prasad Katti) Date: Fri, 31 Jul 2015 11:07:41 -0700 (PDT) Subject: Authenticate users using command line tool against AD in python In-Reply-To: References: Message-ID: <8de582e2-9dfd-4350-9342-b379059cfff6@googlegroups.com> On Tuesday, July 28, 2015 at 12:56:29 AM UTC-7, Michael Str?der wrote: > Prasad Katti wrote: > > I am writing a command line tool in python to generate one time > > passwords/tokens. The command line tool will have certain sub-commands like > > --generate-token and --list-all-tokens for example. I want to restrict > > access to certain sub-commands. In this case, when user tries to generate a > > new token, I want him/her to authenticate against AD server first. > > This does not sound secure: > The user can easily use a modified copy of your script. > > > I have looked at python-ldap and I am even able to bind to the AD server. > > In my application I have a function > > > > def authenticate_user(username, password): pass > > > > which gets username and plain-text password. How do I use the LDAPObject instance to validate these credentials? > > You probably want to use > > http://www.python-ldap.org/doc/html/ldap.html#ldap.LDAPObject.simple_bind_s > > Check whether password is non-zero before because most LDAP servers consider > an empty password as anon simple bind even if the bind-DN is set. > > Ciao, Michael. Hi Michael, Thank you for the reply. I ended up using simple_bind_s to authenticate users. But apparently it transmits plain-text password over the wire which can be easily sniffed using a packed sniffer. So I am looking at the start_tls_s method right now. About your other comment; How could I make it more secure? I looked for ways to obfuscate the file, but I read that it is easy to reverse engineer. How is python code usually distributed? This seems like a fairly common requirement. Am I using the wrong tool (Python)? This is my first attempt at doing such a thing. Appreciate your help! - Prasad From michael at stroeder.com Fri Jul 31 16:08:24 2015 From: michael at stroeder.com (=?UTF-8?Q?Michael_Str=c3=b6der?=) Date: Fri, 31 Jul 2015 22:08:24 +0200 Subject: Authenticate users using command line tool against AD in python In-Reply-To: <8de582e2-9dfd-4350-9342-b379059cfff6@googlegroups.com> References: <8de582e2-9dfd-4350-9342-b379059cfff6@googlegroups.com> Message-ID: Prasad Katti wrote: > On Tuesday, July 28, 2015 at 12:56:29 AM UTC-7, Michael Str?der wrote: >> Prasad Katti wrote: >>> I am writing a command line tool in python to generate one time >>> passwords/tokens. The command line tool will have certain sub-commands like >>> --generate-token and --list-all-tokens for example. I want to restrict >>> access to certain sub-commands. In this case, when user tries to generate a >>> new token, I want him/her to authenticate against AD server first. >> >> This does not sound secure: >> The user can easily use a modified copy of your script. >> >>> I have looked at python-ldap and I am even able to bind to the AD server. >>> In my application I have a function >>> >>> def authenticate_user(username, password): pass >>> >>> which gets username and plain-text password. How do I use the LDAPObject instance to validate these credentials? >> >> You probably want to use >> >> http://www.python-ldap.org/doc/html/ldap.html#ldap.LDAPObject.simple_bind_s >> >> Check whether password is non-zero before because most LDAP servers consider >> an empty password as anon simple bind even if the bind-DN is set. > > Thank you for the reply. I ended up using simple_bind_s to authenticate > users. But apparently it transmits plain-text password over the wire which > can be easily sniffed using a packed sniffer. So I am looking at the > start_tls_s method right now. Yes, use TLS if the server supports it. Make sure to the option for CA certificate. See Demo/initialize.py in the source distribution tar.gz. > About your other comment; How could I make it more secure? If you want something to be inaccessible for a user you have to spread the functionality across separate components which communicate with each other. In this communication you can implement authorization based on sufficiently secure authentication. Ciao, Michael. From martin.schoon at gmail.com Fri Jul 31 16:40:42 2015 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 31 Jul 2015 20:40:42 GMT Subject: How to rearrange array using Python? References: <1468455.P0rGZF1LBf@PointedEars.de> Message-ID: Den 2015-07-31 skrev Thomas 'PointedEars' Lahn : > Mark Lawrence wrote: >> >> I'm not absolutely certain but I think you're into what's known as a >> constraint satisfaction problem, in which case this >> https://pypi.python.org/pypi/python-constraint/1.2 is as good a starting >> point as any. If I'm wrong we'll soon get told :) > > It is a CSP indeed, and as I was reading the OP I was thinking of SWI- > Thanks guys, I will follow up on the CSP lead. It is not something I have prior experience of so it will be interesting. > Please trim your quotes to the relevant minimum. > Indeed. /Martin From martin.schoon at gmail.com Fri Jul 31 16:53:45 2015 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 31 Jul 2015 20:53:45 GMT Subject: How to rearrange array using Python? References: Message-ID: Den 2015-07-31 skrev Robin Koch : > Am 30.07.2015 um 22:31 schrieb Martin Sch??n: > >> Scores to the right show how many wishes are fulfilled in each room > > Is it possible the is a mistake in the sum column on the third row? > Should the be a 1? Indeed. > >> The goal is to re-shuffle the array to maximize this score. >> >> How do I go about doing that? > > Depending on how you store those wishes I'd think you can use > random.shuffle()!? When cruising the net yesterday I came across this and it looked to me it does re-shuffle arrays but not in a way that helps me. Maybe I am wrong. > > But do you think simply maximising the score is the optimal solution to > the problem? It is a start. The result will no doubt need some human post-processing. I am merely hoping to eliminate the grunt-work. (There will be pre-processing too, correcting misspelled names etc...) > That way some kids will get their both wishes fulfilled (s, e and p in > kids picking each other. Another thing one might want to takeinto > account. :-)) > I did hint at differences between my example and the real problem... /Martin From 4kir4.1i at gmail.com Fri Jul 31 20:39:13 2015 From: 4kir4.1i at gmail.com (Akira Li) Date: Sat, 01 Aug 2015 03:39:13 +0300 Subject: Convert between timezones References: <20150731081503.GA12474@cskk.homeip.net> <2716432.pTP2q8pAs5@PointedEars.de> Message-ID: <87io8zrgem.fsf@gmail.com> Thomas 'PointedEars' Lahn writes: > [X-Post & F'up2 comp.unix.shell] > > Chris Angelico wrote: > >> On Fri, Jul 31, 2015 at 6:15 PM, Cameron Simpson wrote: >>> Actually, bash has no timezone support but the date command _does_, and >>> probably neither better nor worse than Python. All one has to do is set >>> the TZ environment variable, eg (untested): >>> >>> _year_gmt=$( TZ=GMT date +%Y ) >> >> That's assuming that it's converting against the current system >> timezone. I don't know how you'd use `date` to convert between two >> arbitrary timezones. [?] > > With POSIX date(1), ISTM all you could do is set the system time and for an > additional invocation the TZ variable accordingly for output. > > > > With GNU date(1): > > $ (tz_source="Asia/Dubai"; time_source="$(LC_TIME=C TZ=$tz_source date -d > "today 00:00 UTC+4" -Im)"; tz_target="America/Chicago"; echo "When it was > $time_source in $tz_source, it was $(LC_TIME=C TZ=$tz_target date -d > "$time_source") in $tz_target.") > When it was 2015-07-31T00:00+0400 in Asia/Dubai, it was Thu Jul 30 15:00:00 > CDT 2015 in America/Chicago. > > $ date --version > date (GNU coreutils) 8.23 > [?] > Here's a corresponding Python code. I haven't seen the beginning of the discussion. I apologize if it has been already posted: #!/usr/bin/env python from datetime import datetime import pytz # $ pip install pytz source_tz, target_tz = map(pytz.timezone, ['Asia/Dubai', 'America/Chicago']) d = datetime.now(source_tz) # the current time in source_tz timezone midnight = source_tz.localize(datetime(d.year, d.month, d.day), is_dst=None) fmt = "%Y-%m-%dT%H:%M:%S%z" print("When it was {:{fmt}} in {}, it was {:{fmt}} in {}".format( midnight, source_tz.zone, target_tz.normalize(midnight), target_tz.zone, fmt=fmt)) Output: When it was 2015-08-01T00:00:00+0400 in Asia/Dubai, it was 2015-07-31T15:00:00-0500 in America/Chicago From steveburrus28 at gmail.com Fri Jul 31 21:21:25 2015 From: steveburrus28 at gmail.com (Steve Burrus) Date: Fri, 31 Jul 2015 18:21:25 -0700 (PDT) Subject: How Do I ............? Message-ID: <3b283e8a-91b2-461f-ab89-95677542f6b2@googlegroups.com> How Do I access tkinter in Python 3.4 anyway? I've tried and tried but cannot do it. From jason.swails at gmail.com Fri Jul 31 22:22:36 2015 From: jason.swails at gmail.com (Jason Swails) Date: Fri, 31 Jul 2015 22:22:36 -0400 Subject: How Do I ............? In-Reply-To: <3b283e8a-91b2-461f-ab89-95677542f6b2@googlegroups.com> References: <3b283e8a-91b2-461f-ab89-95677542f6b2@googlegroups.com> Message-ID: On Fri, Jul 31, 2015 at 9:21 PM, Steve Burrus wrote: > How Do I access tkinter in Python 3.4 anyway? I've tried and tried but > cannot do it. > ?You import it. If I play mind-reader for a second, I suspect you're trying to do in Python 3 what you did in Python 2. That won't work -- the Tkinter module layout has completely changed between Python 2 and Python 3. For starters, instead of doing: import Tkinter like you did in Python 2, you need to do import tkinter in Python 3. There are several other changes, like standalone modules that are not subpackages in tkinter (e.g., tkMessageBox is now tkinter.messagebox). To get a more complete list of name changes, you can Google something like "tkinter python 2 to python 3", which will give you a page like this: http://docs.pythonsprints.com/python3_porting/py-porting.html. Personally, I don't bother with that. I have my working Tkinter code from Python 2 and simply look at what the "2to3" module spits out during its conversion. That's often a good way to figure out "how the heck do I do something in Python 3" when you have a script written for Python 2 that works. If that doesn't answer your question, then chances are your Python wasn't built with Tkinter support (like the system Pythons in many Linux distributions). In that case you need to install the appropriate package (depends on your distro). ?Or if that *still* doesn't answer your question, then provide enough information so that someone can actually figure out what went wrong ;).? HTH, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From garyroach at verizon.net Fri Jul 31 22:32:33 2015 From: garyroach at verizon.net (Gary Roach) Date: Fri, 31 Jul 2015 19:32:33 -0700 Subject: Improper Django Project error (solved) In-Reply-To: <87wpxghmy4.fsf@handshake.de> References: <55BA6563.8050603@verizon.net> <87wpxghmy4.fsf@handshake.de> Message-ID: <55BC2FC1.1050509@verizon.net> On 07/30/2015 11:15 PM, dieter wrote: > Gary Roach writes: >> Being new to Django and Python, I have two projects setup side by >> side, each in it's own virtualenv wrapper. >> The twr_project is running Django 1.7, python 2.7 and is set up to >> duplicate the 'Tango With Rango' tutorial. >> The archivedb project is running Django 1.8, python 2.7 and is my >> actual project. > As this is more a "Django" (than a general "Python") question, > you might get better help in a "Django" mailing list/support forum. Actually you are dead correct on that. > > > Your "subject" indicates that you likely see (somewhere) > the "Django" error message "Improper Django Project error". > Likely, you have corrupted you "Django" project setup. > Read about how "Django" projects must look like and fix your setup. The real problem was that the settings.py files for Django 1.7 and 1.8 have some very significant differences with the format of the TEMPLATES = [] tuple. So the problem's solved --- sort of . >> I am using Ninja-IDE as my IDE. I like it a lot. >> >> At this point both projects are essentially identical with the >> exception of name changes. The twr project work down to the first >> template inclusion ( index.html ). The archivedb project refuses to >> find the home.html template file. The system layout is exactly the >> same. >> >> I wiped the home.html file and attempted to re-install it but my IDE >> gave the following error window: >> >>> Sorry, either settings file or virtualenv are missingthese are >>> required for Django Plugin to work in thepresent version, we are >>> working on fixing this. >>> >> I have virtualenv installed and active and the settings file is >> present. > You should ask this question on a "Ninja-IDE" mailing list/support forum. Ninja_IDE is just reporting an apparent problem. The real problem is that the browser can't find the file. A Django problem. > From gary719_list1 at verizon.net Fri Jul 31 22:33:39 2015 From: gary719_list1 at verizon.net (Gary Roach) Date: Fri, 31 Jul 2015 19:33:39 -0700 Subject: Improper Django Project error (solved) In-Reply-To: <87wpxghmy4.fsf@handshake.de> References: <55BA6563.8050603@verizon.net> <87wpxghmy4.fsf@handshake.de> Message-ID: <55BC3003.8040002@verizon.net> On 07/30/2015 11:15 PM, dieter wrote: > Gary Roach writes: >> Being new to Django and Python, I have two projects setup side by >> side, each in it's own virtualenv wrapper. >> The twr_project is running Django 1.7, python 2.7 and is set up to >> duplicate the 'Tango With Rango' tutorial. >> The archivedb project is running Django 1.8, python 2.7 and is my >> actual project. > As this is more a "Django" (than a general "Python") question, > you might get better help in a "Django" mailing list/support forum. Actually you are dead correct on that. > > > Your "subject" indicates that you likely see (somewhere) > the "Django" error message "Improper Django Project error". > Likely, you have corrupted you "Django" project setup. > Read about how "Django" projects must look like and fix your setup. The real problem was that the settings.py files for Django 1.7 and 1.8 have some very significant differences with the format of the TEMPLATES = [] tuple. So the problem's solved --- sort of . >> I am using Ninja-IDE as my IDE. I like it a lot. >> >> At this point both projects are essentially identical with the >> exception of name changes. The twr project work down to the first >> template inclusion ( index.html ). The archivedb project refuses to >> find the home.html template file. The system layout is exactly the >> same. >> >> I wiped the home.html file and attempted to re-install it but my IDE >> gave the following error window: >> >>> Sorry, either settings file or virtualenv are missingthese are >>> required for Django Plugin to work in thepresent version, we are >>> working on fixing this. >>> >> I have virtualenv installed and active and the settings file is >> present. > You should ask this question on a "Ninja-IDE" mailing list/support forum. Ninja_IDE is just reporting an apparent problem. The real problem is that the browser can't find the file. A Django problem. > From rantingrickjohnson at gmail.com Fri Jul 31 23:08:58 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 31 Jul 2015 20:08:58 -0700 (PDT) Subject: GvR Europython keynote described on lwn.net In-Reply-To: <87r3noltu3.fsf@jester.gateway.sonic.net> References: <87r3noltu3.fsf@jester.gateway.sonic.net> Message-ID: <106305a9-3ccd-4de4-a918-c27cec2d0b8c@googlegroups.com> On Friday, July 31, 2015 at 1:33:36 AM UTC-5, Paul Rubin wrote: > The Dropbox cluster runs a modified Python 2.7, he said, which > elicited audience laughter. "I said it, it is no secret", he said. Yep, even the BDFL is actively developing in 2.7! He's no fool. From cs at zip.com.au Fri Jul 31 23:31:16 2015 From: cs at zip.com.au (Cameron Simpson) Date: Sat, 1 Aug 2015 13:31:16 +1000 Subject: How to re-write this bash script in Python? In-Reply-To: References: Message-ID: <20150801033116.GA26772@cskk.homeip.net> On 31Jul2015 18:26, Chris Angelico wrote: >On Fri, Jul 31, 2015 at 6:15 PM, Cameron Simpson wrote: >>> For example, bash lacks >>> decent timezone support, so I can well believe random832's guess that >>> your five-hour offset is a simulation of that; but Python can do much >>> better work with timezones, so you can get that actually correct. >> >> >> Actually, bash has no timezone support but the date command _does_, and >> probably neither better nor worse than Python. All one has to do is set the >> TZ environment variable, eg (untested): >> >> _year_gmt=$( TZ=GMT date +%Y ) > >That's assuming that it's converting against the current system >timezone. I don't know how you'd use `date` to convert between two >arbitrary timezones. If date supports it I'd think one could use its -d option: utc=$( TZ=src_zone date -d source-time-spec -u +%Y%m%dT%H%M%SZ ) then: tz2=$( TZ=dst_zone date -d "$utc" ) Untested, but seems tractable. >But anyway, still justification to rewrite from >original spec rather than reimplementing the five-hour hack. Yes indeed. Cheers, Cameron Simpson