From harirammanohar159 at gmail.com Thu Oct 1 03:04:16 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Thu, 1 Oct 2015 00:04:16 -0700 (PDT) Subject: reg multiple login python Message-ID: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Hi All, Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. Thanks in advance. From harirammanohar159 at gmail.com Thu Oct 1 03:10:01 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Thu, 1 Oct 2015 00:10:01 -0700 (PDT) Subject: execute commands as su on remote server In-Reply-To: References: Message-ID: <71746612-9695-4003-8a69-fcbdb1a52789@googlegroups.com> On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm... at gmail.com wrote: > execute commands as su on remote server > > Postby hariram ? Mon Aug 17, 2015 4:02 am > Needed: > I need to execute commands after doing su to other user on remote server(not sudo which doesn't require password) how i can achieve this using python? > I googled and came to know that its not possible, so just for confirmation asking again, is it possible ? > > Already Tried: > Tried paramiko that's too not working. Thanks laura, i am able to acheive it using pxssh... From lac at openend.se Thu Oct 1 03:17:58 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 09:17:58 +0200 Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <201510010717.t917HwRj010067@fido.openend.se> In a message of Thu, 01 Oct 2015 00:04:16 -0700, harirammanohar159 at gmail.com wr ites: >Hi All, > >Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > >Thanks in advance. >-- >https://mail.python.org/mailman/listinfo/python-list I am not sure that what you said 'do at once' is what you meant. Actually making sure that 2 things happen at the same time on different machines is a rather hard problem. But you probably don't care. 'Do this thing all these places, asap' and 'Do this thing, sometime just after 03:00' is what we most of the time want, and the best you are going to get with your for loop. How much 'at once' do you need? Note, if your real problem is 'I have a lot of machines to admininster, and I need to push changes to all of them, and sometimes some of them are down, and keeping track of which ones still need the update vs which ones already have it is a real pain', you may find that admin tools such as fabric http://www.fabfile.org/ make your life easier. Laura From lac at openend.se Thu Oct 1 03:40:58 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 09:40:58 +0200 Subject: Check if a given value is out of certain range In-Reply-To: References: <87si5v3hpx.fsf@elektro.pacujo.net> Message-ID: <201510010740.t917ewnd011715@fido.openend.se> In a message of Wed, 30 Sep 2015 14:46:48 -0600, Ian Kelly writes: >Thought mirrors language. In English, we typically would say "x is not >between 0 and 10", not "x is either less than 0 or greater than 10". I wonder if that is regional. I think you may have stacked things with the 'either' and the 'greater than'. 'Either' doesn't get used much unless you are heading for 'either x or y but not both'. And everybody says 'more' even when 'greater than' is arguably more precise. Around here, I would expect "x is less than 0 or more than 10" more often than either of your proposed forms. But yesterday I hit up the students with the 'what do you find more readable' question. There was broad consensus that: if 0 < x < 10 : do_something() else: do_something_else() was plenty more readable than anything using 'not' so that the class favourite for readability was: if 0 < x < 10: pass else: complain_out_of_range() though refactoring the whole lot so that you could have an out_of_range Exception instead of an if had a large number of supporters. Laura From lac at openend.se Thu Oct 1 03:58:38 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 09:58:38 +0200 Subject: Check if a given value is out of certain range In-Reply-To: <201510010740.t917ewnd011715@fido.openend.se> References: <87si5v3hpx.fsf@elektro.pacujo.net> <201510010740.t917ewnd011715@fido.openend.se> Message-ID: <201510010758.t917wcoN013007@fido.openend.se> In a message of Thu, 01 Oct 2015 09:40:58 +0200, Laura Creighton writes: >'Either' doesn't get used much unless you are heading for >'either x or y but not both'. I don't think I was clear in expressing things this way. What I meant was, around here at any rate, 'either' is more often used for emphasis that you can have x or y (but not both). If there is no particular emphasis, the 'either' usually gets dropped. But it would not surprise me to find out that this is regional. Laura From harirammanohar159 at gmail.com Thu Oct 1 04:25:47 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Thu, 1 Oct 2015 01:25:47 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <6cf1b75d-86db-4770-866b-66f5b226ffb5@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. Hi Laura, I have checked fabric tutorial and examples, it didn't sound that using fab we can do/push the thing at same time in all servers. Are you saying that using fab we can login to all servers at same time and do the activity and come out... if so, can you just give me some example.. meanwhile i will try getting fab with py3.3 to machine... From alister.nospam.ware at ntlworld.com Thu Oct 1 04:33:16 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Thu, 1 Oct 2015 08:33:16 +0000 (UTC) Subject: Check if a given value is out of certain range References: <87si5v3hpx.fsf@elektro.pacujo.net> Message-ID: On Wed, 30 Sep 2015 14:46:48 -0600, Ian Kelly wrote: > On Wed, Sep 30, 2015 at 2:19 PM, alister > wrote: >> On Wed, 30 Sep 2015 21:06:02 +0300, Marko Rauhamaa wrote: >> >>> Grant Edwards : >>> >>>> not (0 <= x <= 10) (I) >>>> [...] >>>> (x < 0) or (x > 10) (II) >>>> [...] >>>> IMO, (I) is _more_ readable than (II) >>> >>> IMO, they're equally readable (except that you should drop the >>> redundant parentheses from (II)). >>> >>> >>> Marko >> >> both are correct the problem with 1 is the human brain is not >> particularity good with negatives*. >> to do not (some function) you first of all have to work out some >> function & then invert it, a computer does this without difficulty the >> human brain gets confused which is why I personally consider ii is >> more readable (YMMV especially if you are working with Boolean maths >> regularly) this example is relatively simple as things get more complex >> they become more error prone error. > > To me, the negative of one condition (is x in this range) is more easily > processable than the disjunction of two conditions that together compose > the real, more easily understood condition (is x outside this range). I > find it preferable to avoid nested conditions, not negated conditions, > and (II) has more nesting than (I). > > Thought mirrors language. In English, we typically would say "x is not > between 0 and 10", not "x is either less than 0 or greater than 10". > >> *as an example you brain cannot correctly process the following. >> >> Not (think of your left toe) >> >> you are now thinking about it aren't you? > > No, it made me think about thinking. I barely even registered the phrase > "left toe", much less thought about that. clearly it did, & you are now consciously aware of you left toe even if you try to deny it. > > In any case, that's more an issue of being unable to control what you're > thinking about. If I instruct you, "don't raise your right hand", do you > then automatically raise your right hand? Why is it that the Phrase "Don't Panic" is strongly discouraged in emergency situations? answer because the brain parses the statement as follows and focuses on Panic instead of calm. Don't : I must not do somthing what must i not do Panic: what is there to panic about? Holly shit the buildings onfire, Raise Panic The recommended phase is Stay calm Stay: ok dont change anything, whats next Calm ok I am calm that's alright then I may not have raised my right hand but I though about it (& decided no thanks) getting closer to topic, i work on PBX systems where the VM is capable of combining multiple conditions into one super condition using Boolean Operators. Invariably this does not happen & engineers are encoraged to check each condition separately because: 1) They are less likely to make a mistake 2) It is more obvious to subsequent engineers exactly what is happening 3) it is a lot easier to amend if req. on the other hand if i was designing an electronic circuit using discreet electronics I would use all available techniques to manipulate the equation to make best use of components available the may be reducing the total gate count, it may actually increase the component count so that I could use only Nand gates, or it may get strangely complex so that I could make use of spare gates on existing ic's Although I would have no difficulty reading the final equation it may not be obvious at 1st glance . -- Blue paint today. [Funny to Jack Slingwine, Guy Harris and Hal Pierson. Ed.] From rosuav at gmail.com Thu Oct 1 04:37:50 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 1 Oct 2015 18:37:50 +1000 Subject: Check if a given value is out of certain range In-Reply-To: References: <87si5v3hpx.fsf@elektro.pacujo.net> Message-ID: On Thu, Oct 1, 2015 at 6:33 PM, alister wrote: > The recommended phase is Stay calm > > Stay: ok dont change anything, whats next > Calm > ok I am calm that's alright then Yes, because that always works. Okay. Alright. I'm calm. *throws snowball* See? Now you made him mad! :) ChrisA From gal.kauffman at gmail.com Thu Oct 1 04:48:03 2015 From: gal.kauffman at gmail.com (gal kauffman) Date: Thu, 1 Oct 2015 01:48:03 -0700 Subject: Question about regular expression In-Reply-To: References: <811788b6-9955-4dcc-bf49-9647891d17ec@googlegroups.com> <20150930142015.4045c931@bigbox.christie.dr> Message-ID: items = s.replace(' (', '(').replace(', ',',').split() items_dict = dict() for item in items: if '(' not in item: item += '(0,0)' if ',' not in item: item = item.replace(')', ',0)') name, raw_data = item.split('(') data_tuple = tuple((int(v) for v in raw_data.replace(')','').split(','))) items_dict[name] = data_tuple 2015-09-30 20:58 GMT-07:00 Emile van Sebille : > On 9/30/2015 12:20 PM, Tim Chase wrote: > >> On 2015-09-30 11:34, massi_srb at msn.com wrote: >> > > >> I guess this problem can be tackled with regular expressions, b >>> >> ... However, if you *want* to do it with >> >> regular expressions, you can. It's ugly and might be fragile, but >> >> ############################################################# >> import re >> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..." >> r = re.compile(r""" >> \b # start at a word boundary >> (\w+) # capture the word >> \s* # optional whitespace >> (?: # start an optional grouping for things in the parens >> \( # a literal open-paren >> \s* # optional whitespace >> (\d+) # capture the number in those parens >> (?: # start a second optional grouping for the stuff after a >> comma >> \s* # optional whitespace >> , # a literal comma >> \s* # optional whitespace >> (\d+) # the second number >> )? # make the command and following number optional >> \) # a literal close-paren >> )? # make that stuff in parens optional >> """, re.X) >> d = {} >> for m in r.finditer(s): >> a, b, c = m.groups() >> d[a] = (int(b or 0), int(c or 0)) >> >> from pprint import pprint >> pprint(d) >> ############################################################# >> > > :) > > >> I'd stick with the commented version of the regexp if you were to use >> this anywhere so that others can follow what you're doing. >> > > ... and this is why I use python. That looks too much like a hex sector > disk dump rot /x20. :) > > No-really-that's-sick-ly yr's, > > Emile > > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alister.nospam.ware at ntlworld.com Thu Oct 1 04:48:43 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Thu, 1 Oct 2015 08:48:43 +0000 (UTC) Subject: Check if a given value is out of certain range References: <87si5v3hpx.fsf@elektro.pacujo.net> Message-ID: On Thu, 01 Oct 2015 18:37:50 +1000, Chris Angelico wrote: > On Thu, Oct 1, 2015 at 6:33 PM, alister > wrote: >> The recommended phase is Stay calm >> >> Stay: ok dont change anything, whats next >> Calm ok I am calm that's alright then > > Yes, because that always works. > > Okay. Alright. I'm calm. > *throws snowball* > See? Now you made him mad! > > :) > > ChrisA No it doesn't always work, but it does have a higher success rate than doing a "Corporal Jones" Apologies to no UK residents who might not get the "Dads Army" reference. -- One small step for man, one giant stumble for mankind. From lac at openend.se Thu Oct 1 05:10:19 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 11:10:19 +0200 Subject: reg multiple login python In-Reply-To: <6cf1b75d-86db-4770-866b-66f5b226ffb5@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> <6cf1b75d-86db-4770-866b-66f5b226ffb5@googlegroups.com> Message-ID: <201510010910.t919AJ6k018248@fido.openend.se> In a message of Thu, 01 Oct 2015 01:25:47 -0700, harirammanohar159 at gmail.com wr ites: >On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: >> Hi All, >> >> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. >> >> Thanks in advance. > >Hi Laura, > >I have checked fabric tutorial and examples, it didn't sound that using fab we can do/push the thing at same time in all servers. >Are you saying that using fab we can login to all servers at same time and do the activity and come out... if so, can you just give me some example.. > >meanwhile i will try getting fab with py3.3 to machine... >-- >https://mail.python.org/mailman/listinfo/python-list I still don't know what you mean by 'at the same time'. But see: http://www.pythonforbeginners.com/systems-programming/how-to-use-fabric-in-a-development-environment/ change env.hosts to be a list of all the places that you want the things you put in your fabfile.py to run. I don't know if this is going to help you, or be any better than just using a loop. It depends on what your problem is. Fabric is designed to solve a certain set of problems, but I don't know if they are the sort you have. Laura From michael at stroeder.com Thu Oct 1 05:17:13 2015 From: michael at stroeder.com (=?UTF-8?Q?Michael_Str=c3=b6der?=) Date: Thu, 1 Oct 2015 11:17:13 +0200 Subject: reg multiple login python In-Reply-To: <6cf1b75d-86db-4770-866b-66f5b226ffb5@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> <6cf1b75d-86db-4770-866b-66f5b226ffb5@googlegroups.com> Message-ID: harirammanohar159 at gmail.com wrote: > I have checked fabric tutorial and examples, it didn't sound that using fab > we can do/push the thing at same time in all servers. What does that mean? Since the posting's subject contains "login" are you trying to minimize the number of authentications needed? I had this discussion in project using OTP. Ciao, Michael. From harirammanohar159 at gmail.com Thu Oct 1 06:07:14 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Thu, 1 Oct 2015 03:07:14 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. Hi Laura, at the same time means... i have an activity say on two servers serverA and serverB, my aim is to do the activity using script by logging in to both servers serverA and serverB at the same time and not one by one. hope this time i am able to convey :) in earlier post the way you suggested will work only as one by one.. Thanks. From harirammanohar159 at gmail.com Thu Oct 1 06:09:01 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Thu, 1 Oct 2015 03:09:01 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <2ff0c2aa-910f-40a5-8f98-525f27905cf8@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. Hi Michael, please see earlier post to know the exact requirement :) and suggest if you have any solutions... :) Thanks. From lac at openend.se Thu Oct 1 08:26:38 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 14:26:38 +0200 Subject: reg multiple login python In-Reply-To: References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <201510011226.t91CQcRv032315@fido.openend.se> In a message of Thu, 01 Oct 2015 03:07:14 -0700, harirammanohar159 at gmail.com wr ites: >On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: >> Hi All, >> >> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. >> >> Thanks in advance. > >Hi Laura, > >at the same time means... >i have an activity say on two servers serverA and serverB, my aim is to do the activity using script by logging in to both servers serverA and serverB at the same time and not one by one. hope this time i am able to convey :) > >in earlier post the way you suggested will work only as one by one.. > >Thanks. I am still not understanding. Is your problem that you don't want to wait for the script to be done on machine A before you go to machine B? fork a separate process for each machine. You could even do this in, for instance, a bash shell. Given a script called myscript.py that takes a machine name as an argument. for machine in `cat list_of_machines` do python --machine $machine myscript.py & done if you need to do this inside python see os.fork https://docs.python.org/3.4/library/os.html and make sure you read about the problems with ssl if you care. https://docs.python.org/3.4/library/ssl.html#module-ssl Most people don't need any more 'at the same time' than this. Do you? Laura From python.list at tim.thechases.com Thu Oct 1 08:39:57 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 1 Oct 2015 07:39:57 -0500 Subject: Question about regular expression In-Reply-To: References: <811788b6-9955-4dcc-bf49-9647891d17ec@googlegroups.com> <20150930142015.4045c931@bigbox.christie.dr> Message-ID: <20151001073957.266d8656@bigbox.christie.dr> On 2015-10-01 01:48, gal kauffman wrote: > items = s.replace(' (', '(').replace(', ',',').split() s = "name1 (1)" Your suggestion doesn't catch cases where more than one space can occur before the paren. -tkc From gal.kauffman at gmail.com Thu Oct 1 09:04:15 2015 From: gal.kauffman at gmail.com (gal kauffman) Date: Thu, 1 Oct 2015 06:04:15 -0700 Subject: Question about regular expression In-Reply-To: <20151001073957.266d8656@bigbox.christie.dr> References: <811788b6-9955-4dcc-bf49-9647891d17ec@googlegroups.com> <20150930142015.4045c931@bigbox.christie.dr> <20151001073957.266d8656@bigbox.christie.dr> Message-ID: My example will give false positive if there is a space before a comma. Or anything else by the conventions in the original string. I tried to keep it as simple as I could. If you want to catch a wider range of values you can use *simple* regular expression to catch as much spaces as you want. On Oct 1, 2015 3:48 PM, "Tim Chase" wrote: > On 2015-10-01 01:48, gal kauffman wrote: > > items = s.replace(' (', '(').replace(', ',',').split() > > s = "name1 (1)" > > Your suggestion doesn't catch cases where more than one space can > occur before the paren. > > -tkc > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From info at egenix.com Thu Oct 1 09:08:38 2015 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Thu, 01 Oct 2015 15:08:38 +0200 Subject: ANN: eGenix PyRun - One file Python Runtime 2.1.1 Message-ID: <560D3056.5050003@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix PyRun - One file Python Runtime Version 2.1.1 An easy-to-use single file relocatable Python run-time - available for Linux, Mac OS X and Unix platforms, with support for Python 2.6, 2.7 and **now also for Python 3.4**. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-PyRun-2.1.1-GA.html ________________________________________________________________________ INTRODUCTION eGenix PyRun is our open source, one file, no installation version of Python, making the distribution of a Python interpreter to run based scripts and applications to Unix based systems as simple as copying a single file. eGenix PyRun's executable only needs 11MB for Python 2 and 13MB for Python 3, but still supports most Python application and scripts - and it can be compressed to just 3-4MB using upx, if needed. Compared to a regular Python installation of typically 100MB on disk, eGenix PyRun is ideal for applications and scripts that need to be distributed to several target machines, client installations or customers. It makes "installing" Python on a Unix based system as simple as copying a single file. eGenix has been using eGenix PyRun internally in the mxODBC Connect Server product since 2008 with great success and decided to make it available as a stand-alone open-source product. We provide both the source archive to build your own eGenix PyRun, as well as pre-compiled binaries for Linux, FreeBSD and Mac OS X, as 32- and 64-bit versions. The binaries can be downloaded manually, or you can let our automatic install script install-pyrun take care of the installation: ./install-pyrun dir and you're done. Please see the product page for more details: http://www.egenix.com/products/python/PyRun/ ________________________________________________________________________ NEWS This patch level release of eGenix PyRun 2.1 comes with the following enhancements: Enhancements / Changes ---------------------- * Upgraded eGenix PyRun to work with and use Python 2.7.10 per default. * eGenix PyRun will now adjust sys.base_prefix and sys.base_exec_prefix in the same way it does for sys.prefix and sys.exec_prefix. This is needed for Python 3.4 in order to have distutils find the Python.h include file when compiling C extensions. * PyRun for Python 3.4 will now show the correct file name of scripts in tracebacks when running them directly, instead of just ''. * The new internal _sysconfigdata module used by the sysconfig module is now patched with the eGenix PyRun config data as well, to make sure that PyRun doesn't ship with two sets of build config variables. install-pyrun Quick Install Enhancements --------------------------------------------- eGenix PyRun includes a shell script called install-pyrun, which greatly simplifies installation of PyRun. It works much like the virtualenv shell script used for creating new virtual environments (except that there's nothing virtual about PyRun environments). https://downloads.egenix.com/python/install-pyrun With the script, an eGenix PyRun installation is as simple as running: ./install-pyrun targetdir This will automatically detect the platform, download and install the right pyrun version into targetdir. We have updated this script since the last release: * Updated install-pyrun to default to eGenix PyRun 2.1.1 and its feature set. For a complete list of changes, please see the eGenix PyRun Changelog: http://www.egenix.com/products/python/PyRun/changelog.html ________________________________________________________________________ LICENSE eGenix PyRun is distributed under the eGenix.com Public License 1.1.0 which is an Open Source license similar to the Python license. You can use eGenix PyRun in both commercial and non-commercial settings without fee or charge. Please see our license page for more details: http://www.egenix.com/products/python/PyRun/license.html The package comes with full source code. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing eGenix PyRun can be found at: http://www.egenix.com/products/python/PyRun/ As always, we are providing pre-built binaries for all common platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac OS X 32/64-bit. Source code archives are available for installation on other platforms, such as Solaris, AIX, HP-UX, etc. _______________________________________________________________________ SUPPORT Commercial support for this product 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 eGenix PyRun, licensing and download instructions, please visit our web-site: http://www.egenix.com/products/python/PyRun/ About eGenix (http://www.egenix.com/): eGenix is a Python software project, consulting and product company delivering expert services and professional quality products for companies, Python users and developers. We specialize in database driven applications, large scale software designs and integration. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, Oct 01 2015) >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> Python Database Interfaces ... http://products.egenix.com/ >>> Plone/Zope Database Interfaces ... http://zope.egenix.com/ ________________________________________________________________________ 2015-09-25: Started a Python blog ... ... http://malemburg.com/ 2015-10-21: Python Meeting Duesseldorf ... 20 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 paul.hermeneutic at gmail.com Thu Oct 1 09:37:05 2015 From: paul.hermeneutic at gmail.com (paul.hermeneutic at gmail.com) Date: Thu, 1 Oct 2015 07:37:05 -0600 Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: On Oct 1, 2015 1:06 AM, wrote: > > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > If you want to start them all at the same time, look into subprocess and popen. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hemla21 at gmail.com Thu Oct 1 09:44:25 2015 From: hemla21 at gmail.com (Hedieh Ebrahimi) Date: Thu, 1 Oct 2015 06:44:25 -0700 (PDT) Subject: PySide window does not resize to fit screen Message-ID: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> Dear all, I am using Pyside to create a user interface for my app. The app works fine on my computer with big screen, but when I take it to my laptop with smaller screen size, it does not resize to match the screen size. How can I make my main widget get some information about the screen size and resize automatically? Thanks in Advance for your answers. From ian.g.kelly at gmail.com Thu Oct 1 10:14:14 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 1 Oct 2015 08:14:14 -0600 Subject: Check if a given value is out of certain range In-Reply-To: References: <87si5v3hpx.fsf@elektro.pacujo.net> Message-ID: On Thu, Oct 1, 2015 at 2:33 AM, alister wrote: > Why is it that the Phrase "Don't Panic" is strongly discouraged in > emergency situations? > > answer because the brain parses the statement as follows and focuses on > Panic instead of calm. > > Don't : I must not do somthing what must i not do > Panic: what is there to panic about? > Holly shit the buildings onfire, Raise Panic > > > The recommended phase is Stay calm > > Stay: ok dont change anything, whats next > Calm > ok I am calm that's alright then > > > I may not have raised my right hand but I though about it (& decided no > thanks) Again though this is not due to any failure in processing the "not", but because the phrase "don't panic" suggests that there may be reason to panic, which leads to panic (assuming for the sake of argument that this phenomenon is real and not just anecdotal). From ahlusar.ahluwalia at gmail.com Thu Oct 1 11:03:30 2015 From: ahlusar.ahluwalia at gmail.com (kbtyo) Date: Thu, 1 Oct 2015 08:03:30 -0700 (PDT) Subject: Pandas Left Merge with xlsx with CSV producing null value columns in output Message-ID: <858efe8b-ccc1-4c7a-acaf-f3e9de8cfbf3@googlegroups.com> I would appreciate any feedback on the following question that I have raised here: http://stackoverflow.com/questions/32889129/pandas-left-merge-with-xlsx-with-csv-producing-null-value-columns-in-output Thank you for your feedback and support. From kwpolska at gmail.com Thu Oct 1 11:07:09 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Thu, 1 Oct 2015 17:07:09 +0200 Subject: PySide window does not resize to fit screen In-Reply-To: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> Message-ID: On 1 October 2015 at 15:44, Hedieh Ebrahimi wrote: > Dear all, > > I am using Pyside to create a user interface for my app. > The app works fine on my computer with big screen, but when I take it to my laptop with smaller screen size, it does not resize to match the screen size. > > How can I make my main widget get some information about the screen size and resize automatically? > > Thanks in Advance for your answers. > -- > https://mail.python.org/mailman/listinfo/python-list The correct way to do this is to lay your application out using a layout. The available layouts are: * QHBoxLayout * QVBoxLayout * QGridLayout * QFormLayout The exact layout to use depends on your needs. What are you using to create your Qt code? Are you using Qt Designer or are you writing the code by hand? If you are using Qt Designer, use the ?Lay Out?? buttons in the Form menu or on the tool bar. If you are writing Qt code by hand, it looks roughly like this (for a VBox; Grid and Form are more complicated as they involve positioning): lay = QtGui.QVBoxLayout(self) # your central widget, dialog, main window ? whichever one exists btn = QtGui.QButton("Hello", lay) lay.addWidget(btn) Please check with Qt documentation for more details -- Chris Warrick PGP: 5EAAEA16 From rgaddi at technologyhighland.invalid Thu Oct 1 11:53:38 2015 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Thu, 1 Oct 2015 15:53:38 +0000 (UTC) Subject: Question about regular expression References: <811788b6-9955-4dcc-bf49-9647891d17ec@googlegroups.com> Message-ID: On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote: > Hi everyone, > > firstly the description of my problem. I have a string in the following > form: > > s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..." > > that is a string made up of groups in the form 'name' (letters only) > plus possibly a tuple containing 1 or 2 integer values. Blanks can be > placed between names and tuples or not, but they surely are placed > beween two groups. I would like to process this string in order to get a > dictionary like this: > > d = { > "name1":(0, 0), > "name2":(1, 0), > "name3":(0, 0), > "name4":(1, 4), > "name5":(2, 0), > } > > I guess this problem can be tackled with regular expressions, but I have > no idea bout how to use them in this case (I'm not a regexp guy). Can > anyone give me a hint? any possible different approach is absolutely > welcome. > > Thanks in advance! There's a quote for this. 'Some people, when confronted with a problem, think ?I know, I'll use regular expressions.? Now they have two problems.' That one's not always true, but any time you're debating a regex solution it should at least come to mind. Lots of people have posted lots of pure Python solutions. I will simply comment that using any of them will make you fundamentally happier as time goes on than trying to shoehorn a regex in. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From lac at openend.se Thu Oct 1 12:19:12 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 18:19:12 +0200 Subject: PySide window does not resize to fit screen In-Reply-To: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> Message-ID: <201510011619.t91GJC8H016991@fido.openend.se> In a message of Thu, 01 Oct 2015 06:44:25 -0700, Hedieh Ebrahimi writes: >Dear all, > >I am using Pyside to create a user interface for my app. >The app works fine on my computer with big screen, but when I take it to my laptop with smaller screen size, it does not resize to match the screen size. > >How can I make my main widget get some information about the screen size and resize automatically? > >Thanks in Advance for your answers. screenGeometry = QApplication.instance().desktop().screenGeometry() to find out your desktop size in pixels. availGeometry = QApplication.instance().desktop().availableGeometry() is the same thing minus the space for the task bar, so maybe more useful. width, height = availGeometry.width(), availGeometry.height() Finding out what pyside thinks the size is can be useful for debugging problems, but this stuff should already be happening automatically. There is something not quite right with your layout, and brutally resizing things by hand is treating the symptom, not the cause. Laura From kwpolska at gmail.com Thu Oct 1 12:26:40 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Thu, 1 Oct 2015 18:26:40 +0200 Subject: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results) Message-ID: The Nikola developers decided to deprecate Python 2.7 support. Starting with v7.7.2, Nikola will display a warning if Python 2.7 is used (but it will still be fully supported). In early 2016, Nikola v8.0.0 will come out, and that release will not support Python 2.7 officially. The decision was made on the basis of a user survey, with 138 participants. The vast majority of them claimed that they either use Python 3 already, or can switch really easily. The main reason for the switch was the fact that supporting both requires a lot of extra effort, especially because Python 2.7?s Unicode support is abysmal. Full results: https://getnikola.com/blog/env-survey-results-and-the-future-of-python-27.html What is Nikola? =============== Nikola is a static site and blog generator, written in Python. It can use Mako and Jinja2 templates, and input in many popular markup formats, such as reStructuredText and Markdown ? and can even turn Jupyter (IPython) Notebooks into blog posts! It also supports image galleries, and is multilingual. Nikola is flexible, and page builds are extremely fast, courtesy of doit (which is rebuilding only what has been changed). Find out more at the website: https://getnikola.com/ -- Chris Warrick PGP: 5EAAEA16 From df at see.replyto.invalid Thu Oct 1 12:36:50 2015 From: df at see.replyto.invalid (Dave Farrance) Date: Thu, 01 Oct 2015 17:36:50 +0100 Subject: matplotlib timer Message-ID: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> I'm trying to set up the basics of a timer-scheduled function in matplotlib and I can't figure out how to stop the timer. Maybe the stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the syntax wrong. If anybody's got matplotlib installed, can you try this code and tell me if it stops after one tick as it should -- or does it continue printing every second without stopping as mine does? #!/usr/bin/env python import matplotlib.pyplot as P def fn(): timer.stop() print("tick") fig, ax = P.subplots() timer = fig.canvas.new_timer(interval=1000) timer.add_callback(fn) timer.start() P.show() From paul.hermeneutic at gmail.com Thu Oct 1 12:43:58 2015 From: paul.hermeneutic at gmail.com (paul.hermeneutic at gmail.com) Date: Thu, 1 Oct 2015 10:43:58 -0600 Subject: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results) In-Reply-To: References: Message-ID: Python 3 has venv in the kit. Is there a reason users should get the virtualenv add-on? On Oct 1, 2015 10:28 AM, "Chris Warrick" wrote: > The Nikola developers decided to deprecate Python 2.7 support. > Starting with v7.7.2, Nikola will display a warning if Python 2.7 is > used (but it will still be fully supported). In early 2016, Nikola > v8.0.0 will come out, and that release will not support Python 2.7 > officially. > > The decision was made on the basis of a user survey, with 138 > participants. The vast majority of them claimed that they either use > Python 3 already, or can switch really easily. The main reason for the > switch was the fact that supporting both requires a lot of extra > effort, especially because Python 2.7?s Unicode support is abysmal. > > Full results: > https://getnikola.com/blog/env-survey-results-and-the-future-of-python-27.html > > What is Nikola? > =============== > > Nikola is a static site and blog generator, written in Python. > It can use Mako and Jinja2 templates, and input in many popular markup > formats, such as reStructuredText and Markdown ? and can even turn > Jupyter (IPython) Notebooks into blog posts! It also supports image > galleries, and is multilingual. Nikola is flexible, and page builds > are extremely fast, courtesy of doit (which is rebuilding only what > has been changed). > > Find out more at the website: https://getnikola.com/ > > -- > Chris Warrick > PGP: 5EAAEA16 > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Thu Oct 1 13:02:22 2015 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 1 Oct 2015 19:02:22 +0200 Subject: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results) In-Reply-To: References: Message-ID: Chris Warrick schrieb am 01.10.2015 um 18:26: > The Nikola developers decided to deprecate Python 2.7 support. I wonder why it took the Nikola project so long to take that decision. Python 3.3 came out almost exactly three(!) years ago and seems to have all major features that they would require. Nikola's PyPI page claims support of Python 3.3 for just about as long, since version 5.4 or so, which means that all of their dependencies were already available back then. It's a different thing for *libraries* that Python 2.x users still depend on, but for an *application* that has all its (necessary) dependencies available in Python 3.x, I can't see a general reason to keep supporting both language versions. Stefan From kwpolska at gmail.com Thu Oct 1 13:16:44 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Thu, 1 Oct 2015 19:16:44 +0200 Subject: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results) In-Reply-To: References: Message-ID: On 1 October 2015 at 18:43, wrote: > Python 3 has venv in the kit. Is there a reason users should get the > virtualenv add-on? Both can be used; I wrote about virtualenv because it?s the tried-and-true solution (and is it guaranteed in all Linux distros anyway?) On 1 October 2015 at 19:02, Stefan Behnel wrote: > Chris Warrick schrieb am 01.10.2015 um 18:26: >> The Nikola developers decided to deprecate Python 2.7 support. > > I wonder why it took the Nikola project so long to take that decision. > Python 3.3 came out almost exactly three(!) years ago and seems to have all > major features that they would require. Nikola's PyPI page claims support > of Python 3.3 for just about as long, since version 5.4 or so, which means > that all of their dependencies were already available back then. > > It's a different thing for *libraries* that Python 2.x users still depend > on, but for an *application* that has all its (necessary) dependencies > available in Python 3.x, I can't see a general reason to keep supporting > both language versions. > > Stefan We did it now because it all started with frustration with 2.7 [0]. Also, doing it back in 2012/2013 would be problematic, because back then not all Linux distros had an easily installable Python 3 stack (and RHEL 7 still doesn?t have one in the default repos) [0]: http://ralsina.me/weblog/posts/floss-decision-making-in-action.html -- Chris Warrick PGP: 5EAAEA16 From lac at openend.se Thu Oct 1 13:28:35 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 19:28:35 +0200 Subject: matplotlib timer In-Reply-To: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> References: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> Message-ID: <201510011728.t91HSZdX021999@fido.openend.se> In a message of Thu, 01 Oct 2015 17:36:50 +0100, Dave Farrance writes: >I'm trying to set up the basics of a timer-scheduled function in >matplotlib and I can't figure out how to stop the timer. Maybe the >stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the >syntax wrong. > >If anybody's got matplotlib installed, can you try this code and tell me >if it stops after one tick as it should -- or does it continue printing >every second without stopping as mine does? > >#!/usr/bin/env python >import matplotlib.pyplot as P >def fn(): > timer.stop() > print("tick") >fig, ax = P.subplots() >timer = fig.canvas.new_timer(interval=1000) >timer.add_callback(fn) >timer.start() >P.show() > debian unstable Python 3.4.3+ (default, Jul 28 2015, 13:17:50) mine ticks forever, too. Laura From lac at openend.se Thu Oct 1 13:41:54 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 19:41:54 +0200 Subject: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results) In-Reply-To: References: Message-ID: <201510011741.t91HfsMF023010@fido.openend.se> In a message of Thu, 01 Oct 2015 10:43:58 -0600, paul.hermeneutic at gmail.com wri tes: >Python 3 has venv in the kit. Is there a reason users should get the >virtualenv add-on? Yes. It is known to work. Debian packager doko (Matthias Klose) thinks that venv is not debian compatible. Thus when you try to use it, on a debian system, it doesn't work unless you have installed Barry Warsaw's package fix, because you don't have an ensure-pip. This should only affect debian and their downstream, though not ubuntu as Barry fixed things. See my bug report, here, after a frustrating morning trying to see why venv didn't work -- 'debian broke my python' was not the first tree I climbed in trying to understand this. https://bugs.python.org/issue25151 Actually, search there for venv and pyenv and read all about it. ... pyenv is going away, use python -m instead ... So unless you want to help your debian users get a working venv, I would stick with telling everybody to use virtualenv for now. Laura From df at see.replyto.invalid Thu Oct 1 13:45:06 2015 From: df at see.replyto.invalid (Dave Farrance) Date: Thu, 01 Oct 2015 18:45:06 +0100 Subject: matplotlib timer References: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> Message-ID: Laura Creighton wrote: >In a message of Thu, 01 Oct 2015 17:36:50 +0100, Dave Farrance writes: >>I'm trying to set up the basics of a timer-scheduled function in >>matplotlib and I can't figure out how to stop the timer. Maybe the >>stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the >>syntax wrong. >> >>If anybody's got matplotlib installed, can you try this code and tell me >>if it stops after one tick as it should -- or does it continue printing >>every second without stopping as mine does? >> >>#!/usr/bin/env python >>import matplotlib.pyplot as P >>def fn(): >> timer.stop() >> print("tick") >>fig, ax = P.subplots() >>timer = fig.canvas.new_timer(interval=1000) >>timer.add_callback(fn) >>timer.start() >>P.show() >> > >debian unstable >Python 3.4.3+ (default, Jul 28 2015, 13:17:50) > >mine ticks forever, too. Thanks. I've just figured out how to stop the timer. replace "timer.stop()" with timer.single_shot = True Yet the documentation says that it's mandatory for the GUI backend base to implement stop() but that single_shot is optional. Ho hum. http://matplotlib.org/api/backend_bases_api.html#matplotlib.backend_bases.TimerBase From lac at openend.se Thu Oct 1 14:09:17 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 20:09:17 +0200 Subject: matplotlib timer In-Reply-To: References: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> Message-ID: <201510011809.t91I9HlN025088@fido.openend.se> In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes: >Yet the documentation says that it's mandatory for the GUI backend base >to implement stop() but that single_shot is optional. Ho hum. report as a bug. its a doc bug at least, but I think its a real bug, and your code should have worked. https://github.com/matplotlib/matplotlib/issues Laura From steve at pearwood.info Thu Oct 1 14:18:08 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 02 Oct 2015 04:18:08 +1000 Subject: Check if a given value is out of certain range References: Message-ID: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> On Thu, 1 Oct 2015 08:31 am, Mark Lawrence wrote: >> What is so "yuck" about that? What would you do instead? It seems like >> the best solution to me. Easy to read, fast to execute. >> > > I have to parse those damn brackets and then figure out the inverted > logic. Give me x < 0 or x > 10 any day of the week. When you're an old, > senile git like me, readability counts :-) With the greatest of respect Mark, I don't believe that for a second. Your sig line, which you have used without fail for more years than I can remember includes the phrase "ask not what our language can do for you". If you can understand that, I don't believe that you cannot figure out how to go from this: # x is within the range a to b a <= x < = b to this: # x is NOT within the range a to b not a <= x < = b You're certainly a senile old git if you think we're falling for that one :-) P.S. in case you missed it, you don't actually need the params, since the precedence of not is lower than the other operators. Did-I-include-sufficient-smileys-ly y'rs, -- Steven From gordon at panix.com Thu Oct 1 14:20:25 2015 From: gordon at panix.com (John Gordon) Date: Thu, 1 Oct 2015 18:20:25 +0000 (UTC) Subject: Check if a given value is out of certain range References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> Message-ID: In <560d78e2$0$1618$c3e8da3$5496439d at news.astraweb.com> Steven D'Aprano writes: > > I have to parse those damn brackets and then figure out the inverted > > logic. Give me x < 0 or x > 10 any day of the week. When you're an old, > > senile git like me, readability counts :-) > With the greatest of respect Mark, I don't believe that for a second. Your > sig line, which you have used without fail for more years than I can > remember includes the phrase "ask not what our language can do for you". If > you can understand that, I don't believe that you cannot figure out how to Certainly we can understand it. But it takes ever-so-slightly more effort to do so. -- 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 steve at pearwood.info Thu Oct 1 14:59:37 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 02 Oct 2015 04:59:37 +1000 Subject: Check if a given value is out of certain range References: <87si5v3hpx.fsf@elektro.pacujo.net> Message-ID: <560d829c$0$1595$c3e8da3$5496439d@news.astraweb.com> On Thu, 1 Oct 2015 06:46 am, Ian Kelly wrote: > On Wed, Sep 30, 2015 at 2:19 PM, alister > wrote: [...] >> the problem with 1 is the human brain is not particularity good with >> negatives*. >> to do not (some function) you first of all have to work out some function >> & then invert it, a computer does this without difficulty the human brain >> gets confused which is why I personally consider ii is more readable >> (YMMV especially if you are working with Boolean maths regularly) this >> example is relatively simple as things get more complex they become more >> error prone error. In other words, "more complex things are more error prone". Well, sure. That doesn't tell us much about simple things though. You are right that there are certain constructs which, when written in terms of negatives, are harder for people to parse and understand than if written in more straight-forward positive forms. But others are simpler when written in the negative: "No entry to under 18s" versus "Entry to over 18s only" Ian: > To me, the negative of one condition (is x in this range) is more > easily processable than the disjunction of two conditions that > together compose the real, more easily understood condition (is x > outside this range). I find it preferable to avoid nested conditions, > not negated conditions, and (II) has more nesting than (I). > > Thought mirrors language. In English, we typically would say "x is not > between 0 and 10", not "x is either less than 0 or greater than 10". I agree with Ian here. >> *as an example you brain cannot correctly process the following. >> >> Not (think of your left toe) >> >> you are now thinking about it aren't you? Actually I'm not, I'm too busy trying to think of a witty reply :-) > No, it made me think about thinking. I barely even registered the > phrase "left toe", much less thought about that. It's a nice trick, but that's all it is -- it's a trick. The problem isn't that we can't parse and understand the "not", but that few people have either the mental discipline or the short attention span to not think about about something once the thought is planted in the mind. The classic formulation of this idea is the instruction: Don't think of an elephant! Sometimes people will use rhinoceros instead. The more you try to think about *not* thinking of an elephant, the more the idea of one comes to your consciousness. It takes great discipline, or a level of flightiness and empty-headedness that is rare even in the post-MTV and Twitter generation, to consciously think about something else without going back to the elephant. Of course, there is a loop-hole. There is always a loop-hole.[1] In one of Terry Pratchett's Discworld novels, a young witch mentions the phrase "Don't think of a rhinoceros", and states that it is impossible to not think of a rhinoceros. The elderly and curmudgeonly, but extremely powerful, witch Granny Weatherwax confidently dismisses this, and says that it doesn't work on her, she's not thinking of a rhinoceros. Such is Granny's reputation for strength of will, and a self-confidence that you could bend horseshoes on, that her claim is accepted without question. It's not until quite late in the book that her secret is revealed. Being an rural witch who has never really travelled much and doesn't hold with book learning, she has no idea what a rhinoceros is. > In any case, that's more an issue of being unable to control what > you're thinking about. If I instruct you, "don't raise your right > hand", do you then automatically raise your right hand? I could be wrong, but I seem to recall reading that this is *exactly* what happens -- the muscles used to raise the right arm trigger ever-so-slightly. You don't even notice it, but sensitive electrodes can detect the change in electrical potential in the muscles. [1] Except when there isn't. -- Steven From df at see.replyto.invalid Thu Oct 1 15:03:26 2015 From: df at see.replyto.invalid (Dave Farrance) Date: Thu, 01 Oct 2015 20:03:26 +0100 Subject: matplotlib timer References: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> Message-ID: Laura Creighton wrote: >In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes: >>Yet the documentation says that it's mandatory for the GUI backend base >>to implement stop() but that single_shot is optional. Ho hum. > >report as a bug. its a doc bug at least, but I think its a real bug, >and your code should have worked. > >https://github.com/matplotlib/matplotlib/issues OK, done. https://github.com/matplotlib/matplotlib/issues/5163 From steve at pearwood.info Thu Oct 1 15:12:57 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 02 Oct 2015 05:12:57 +1000 Subject: Create a .lua fle from Python References: Message-ID: <560d85ba$0$1591$c3e8da3$5496439d@news.astraweb.com> On Wed, 30 Sep 2015 07:21 pm, jmp wrote: >> Is Ariel's xml file user-supplied? If so, how does your suggestion >> prevent the resulting lua script from executing arbitrary code? > > It does not. Like it doesn't fulfill the millions of possible > requirements the OP could have written but did not. What if the OP want > a thread safe, super fast, multi core solution distributed on multiple > remote hosts ? Then he should have said so. We are not *required* to guess every last requirement that somebody might have but didn't mention. But we do have a professional[1] duty of care to warn an *obvious beginner* that he may be introducing a serious security vulnerability into his code. [1] In the sense of a job well done, not in the sense of "I got paid money to write this shit". Think master craftsman, not interchangeable code monkey. -- Steven From steve at pearwood.info Thu Oct 1 15:19:01 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 02 Oct 2015 05:19:01 +1000 Subject: Check if a given value is out of certain range References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> Message-ID: <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> On Fri, 2 Oct 2015 04:20 am, John Gordon wrote: > In <560d78e2$0$1618$c3e8da3$5496439d at news.astraweb.com> Steven D'Aprano > writes: > >> > I have to parse those damn brackets and then figure out the inverted >> > logic. Give me x < 0 or x > 10 any day of the week. When you're an >> > old, senile git like me, readability counts :-) > >> With the greatest of respect Mark, I don't believe that for a second. >> Your sig line, which you have used without fail for more years than I can >> remember includes the phrase "ask not what our language can do for you". >> If you can understand that, I don't believe that you cannot figure out >> how to > > Certainly we can understand it. Unless every single one of you (the "we" you refer to) are called Mark, I don't believe I was talking to you :-P > But it takes ever-so-slightly more effort > to do so. Slightly more effort than what alternative? How would you communicate the idea of *not* asking for X without using the concept of "not"? -- Steven From lac at openend.se Thu Oct 1 15:19:25 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 21:19:25 +0200 Subject: matplotlib timer In-Reply-To: References: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> Message-ID: <201510011919.t91JJPHt029859@fido.openend.se> In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes: >Laura Creighton wrote: > >>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes: >>>Yet the documentation says that it's mandatory for the GUI backend base >>>to implement stop() but that single_shot is optional. Ho hum. >> >>report as a bug. its a doc bug at least, but I think its a real bug, >>and your code should have worked. >> >>https://github.com/matplotlib/matplotlib/issues > >OK, done. > Thank you. Can you add how you got it to work, and the doc you read that seems wrong? Laura From gordon at panix.com Thu Oct 1 15:41:27 2015 From: gordon at panix.com (John Gordon) Date: Thu, 1 Oct 2015 19:41:27 +0000 (UTC) Subject: Check if a given value is out of certain range References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> Message-ID: In <560d8726$0$1602$c3e8da3$5496439d at news.astraweb.com> Steven D'Aprano writes: > > But it takes ever-so-slightly more effort to do so. > Slightly more effort than what alternative? How would you communicate the > idea of *not* asking for X without using the concept of "not"? I wasn't commenting directly to the "ask not..." quote; I was referring upthread to the choice between not 0 <= x <= 10 and x < 0 or x > 10 Both are of course understandable, but in my opinion, the latter one takes slightly less effort to grok. -- 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 df at see.replyto.invalid Thu Oct 1 15:47:10 2015 From: df at see.replyto.invalid (Dave Farrance) Date: Thu, 01 Oct 2015 20:47:10 +0100 Subject: matplotlib timer References: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> Message-ID: <4d3r0bdalmomjk4jq4f62lbgr1hu3kgsfr@4ax.com> Laura Creighton wrote: >In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes: >>Laura Creighton wrote: >> >>>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes: >>>>Yet the documentation says that it's mandatory for the GUI backend base >>>>to implement stop() but that single_shot is optional. Ho hum. >>> >>>report as a bug. its a doc bug at least, but I think its a real bug, >>>and your code should have worked. >>> >>>https://github.com/matplotlib/matplotlib/issues >> >>OK, done. >> > >Thank you. > >Can you add how you got it to work, and the doc you read >that seems wrong? OK. From marko at pacujo.net Thu Oct 1 15:59:20 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 01 Oct 2015 22:59:20 +0300 Subject: Check if a given value is out of certain range References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87r3le1ht3.fsf@elektro.pacujo.net> John Gordon : > I wasn't commenting directly to the "ask not..." quote; I was > referring upthread to the choice between > > not 0 <= x <= 10 > > and > > x < 0 or x > 10 > > Both are of course understandable, but in my opinion, the latter one > takes slightly less effort to grok. Wouldn't x < 0 or 10 < x be even more visual? Marko From lac at openend.se Thu Oct 1 16:01:03 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 01 Oct 2015 22:01:03 +0200 Subject: matplotlib timer In-Reply-To: <4d3r0bdalmomjk4jq4f62lbgr1hu3kgsfr@4ax.com> References: <3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com> <4d3r0bdalmomjk4jq4f62lbgr1hu3kgsfr@4ax.com> Message-ID: <201510012001.t91K13Uu000383@fido.openend.se> In a message of Thu, 01 Oct 2015 20:47:10 +0100, Dave Farrance writes: >Laura Creighton wrote: > >>In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes: >>>Laura Creighton wrote: >>> >>>>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes: >>>>>Yet the documentation says that it's mandatory for the GUI backend base >>>>>to implement stop() but that single_shot is optional. Ho hum. >>>> >>>>report as a bug. its a doc bug at least, but I think its a real bug, >>>>and your code should have worked. >>>> >>>>https://github.com/matplotlib/matplotlib/issues >>> >>>OK, done. >>> >> >>Thank you. >> >>Can you add how you got it to work, and the doc you read >>that seems wrong? > >OK. You, sir, are a champion. Thank you again. Laura From emile at fenx.com Thu Oct 1 16:15:21 2015 From: emile at fenx.com (Emile van Sebille) Date: Thu, 1 Oct 2015 13:15:21 -0700 Subject: Check if a given value is out of certain range In-Reply-To: <87r3le1ht3.fsf@elektro.pacujo.net> References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> <87r3le1ht3.fsf@elektro.pacujo.net> Message-ID: On 10/1/2015 12:59 PM, Marko Rauhamaa wrote: > John Gordon : > >> I wasn't commenting directly to the "ask not..." quote; I was >> referring upthread to the choice between >> >> not 0 <= x <= 10 >> >> and >> >> x < 0 or x > 10 >> >> Both are of course understandable, but in my opinion, the latter one >> takes slightly less effort to grok. > > Wouldn't > > x < 0 or 10 < x > > be even more visual? Well, I had to parse that one twice to grok it. Emile From p_s_d_a_s_i_l_v_a_ns at netcabo.pt Thu Oct 1 16:45:40 2015 From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva) Date: Thu, 1 Oct 2015 21:45:40 +0100 Subject: Generating a vector from successive multiplications of another vector from an initial value Message-ID: Hi all. What is the fastest way to do the following: I have an initial value V and a vector vec of (financial) indexes. I want to generate a new vector nvec as V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ... A numpy vectorized solution would be better. Thanks From ian.g.kelly at gmail.com Thu Oct 1 17:10:50 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 1 Oct 2015 15:10:50 -0600 Subject: Generating a vector from successive multiplications of another vector from an initial value In-Reply-To: References: Message-ID: On Thu, Oct 1, 2015 at 2:45 PM, Paulo da Silva wrote: > Hi all. > > What is the fastest way to do the following: > > I have an initial value V and a vector vec of (financial) indexes. > I want to generate a new vector nvec as > > V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ... > > A numpy vectorized solution would be better. That looks hard to vectorize since each calculation depends on the previous. You might be stuck with something like: result = [V] for x in vec: result.append(result[-1] * x) From denismfmcmahon at gmail.com Thu Oct 1 17:31:58 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 1 Oct 2015 21:31:58 +0000 (UTC) Subject: Question about regular expression References: <811788b6-9955-4dcc-bf49-9647891d17ec@googlegroups.com> <20150930142015.4045c931@bigbox.christie.dr> Message-ID: On Thu, 01 Oct 2015 01:48:03 -0700, gal kauffman wrote: > items = s.replace(' (', '(').replace(', ',',').split() > > items_dict = dict() > for item in items: > if '(' not in item: > item += '(0,0)' > if ',' not in item: > item = item.replace(')', ',0)') > > name, raw_data = item.split('(') data_tuple = tuple((int(v) for v in > raw_data.replace(')','').split(','))) > > items_dict[name] = data_tuple Please don't top post. What happens if there's more whitespace than you allow for preceding a '(' or following a ',', or if there's whitespace following '('? -- Denis McMahon, denismfmcmahon at gmail.com From denismfmcmahon at gmail.com Thu Oct 1 17:41:05 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 1 Oct 2015 21:41:05 +0000 (UTC) Subject: Question about regular expression References: <811788b6-9955-4dcc-bf49-9647891d17ec@googlegroups.com> Message-ID: On Thu, 01 Oct 2015 15:53:38 +0000, Rob Gaddi wrote: > There's a quote for this. 'Some people, when confronted with a problem, > think ?I know, I'll use regular expressions.? Now they have two > problems.' I actually used 2 regexes: wordpatt = re.compile('[a-zA-Z]+') numpatt = re.compile('[0-9]+') replace all '(', ',' and ')' in the string with spaces split the string on space create an empty dict d process each thing in the split list setting d[word]=[0,0] for each word element (wordpatt.match(thing)) (a list because I want to be able to modify it) setting d[word][n] = int(num) for each num element (numpatt.match(thing)) with n depending on whether it was the first or second num following the previous word then: d = {x:tuple(d[x]) for x in d} to convert the lists in the new dic to tuples -- Denis McMahon, denismfmcmahon at gmail.com From gordon at panix.com Thu Oct 1 17:45:46 2015 From: gordon at panix.com (John Gordon) Date: Thu, 1 Oct 2015 21:45:46 +0000 (UTC) Subject: Check if a given value is out of certain range References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> <87r3le1ht3.fsf@elektro.pacujo.net> Message-ID: In <87r3le1ht3.fsf at elektro.pacujo.net> Marko Rauhamaa writes: > > I wasn't commenting directly to the "ask not..." quote; I was > > referring upthread to the choice between > > > > not 0 <= x <= 10 > > > > and > > > > x < 0 or x > 10 > > > > Both are of course understandable, but in my opinion, the latter one > > takes slightly less effort to grok. > Wouldn't > x < 0 or 10 < x > be even more visual? I don't know what you mean by "more visual". In my opinion, when comparing a variable to a constant, it's more natural to have the variable on the left and the constant on the right, so that's one strike against this code. Another strike is that the code isn't consistent with itself; it puts the variable on the left in the first comparison, then swaps to the right for the second comparison. -- 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 gal.kauffman at gmail.com Thu Oct 1 17:50:43 2015 From: gal.kauffman at gmail.com (gal kauffman) Date: Thu, 1 Oct 2015 14:50:43 -0700 Subject: Question about regular expression In-Reply-To: References: <811788b6-9955-4dcc-bf49-9647891d17ec@googlegroups.com> <20150930142015.4045c931@bigbox.christie.dr> Message-ID: On Oct 2, 2015 12:35 AM, "Denis McMahon" wrote: > > On Thu, 01 Oct 2015 01:48:03 -0700, gal kauffman wrote: > > > items = s.replace(' (', '(').replace(', ',',').split() > > > > items_dict = dict() > > for item in items: > > if '(' not in item: > > item += '(0,0)' > > if ',' not in item: > > item = item.replace(')', ',0)') > > > > name, raw_data = item.split('(') data_tuple = tuple((int(v) for v in > > raw_data.replace(')','').split(','))) > > > > items_dict[name] = data_tuple > > Please don't top post. Sorry :( > > What happens if there's more whitespace than you allow for preceding a > '(' or following a ',', or if there's whitespace following '('? My code won't work. Even worse then that, it will return a dict as if everything is OK, but the dict will have weird keys and values. But I didn't try to make it work for every possible input. It works for the conventions defined. If I wanted to accept a wider range of values, I would write another program that applies the conventions on the input, and chain it with the current code. > > -- > Denis McMahon, denismfmcmahon at gmail.com > -- > https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From Cecil at decebal.nl Thu Oct 1 17:58:49 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Thu, 01 Oct 2015 23:58:49 +0200 Subject: Only getting the first 6 lines Message-ID: <87y4fmp7xi.fsf@Equus.decebal.nl> I want to get the first 6 lines of ps output. For this I use: ======================================================================== from subprocess import check_output ps_command = ('ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort') message = '\n'.join(check_output(ps_command + ('-%cpu',)).decode("utf-8").splitlines()[0:6]) ======================================================================== It works, but does not look very efficient. Is there a better way to do this? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From ian.g.kelly at gmail.com Thu Oct 1 18:01:17 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 1 Oct 2015 16:01:17 -0600 Subject: Check if a given value is out of certain range In-Reply-To: References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> <87r3le1ht3.fsf@elektro.pacujo.net> Message-ID: On Thu, Oct 1, 2015 at 3:45 PM, John Gordon wrote: > In <87r3le1ht3.fsf at elektro.pacujo.net> Marko Rauhamaa writes: > >> > I wasn't commenting directly to the "ask not..." quote; I was >> > referring upthread to the choice between >> > >> > not 0 <= x <= 10 >> > >> > and >> > >> > x < 0 or x > 10 >> > >> > Both are of course understandable, but in my opinion, the latter one >> > takes slightly less effort to grok. > >> Wouldn't > >> x < 0 or 10 < x > >> be even more visual? > > I don't know what you mean by "more visual". Visually, it places the x outside the range suggested by 0 and 10, similarly to how 0 <= x <= 10 places the x inside. From ian.g.kelly at gmail.com Thu Oct 1 18:03:28 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 1 Oct 2015 16:03:28 -0600 Subject: Check if a given value is out of certain range In-Reply-To: References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> <87r3le1ht3.fsf@elektro.pacujo.net> Message-ID: On Thu, Oct 1, 2015 at 3:45 PM, John Gordon wrote: > In <87r3le1ht3.fsf at elektro.pacujo.net> Marko Rauhamaa writes: >> Wouldn't > >> x < 0 or 10 < x > >> be even more visual? > > [SNIP] > > Another strike is that the code isn't consistent with itself; it puts the > variable on the left in the first comparison, then swaps to the right for > the second comparison. And on the other hand, it consistently uses the < operator rather than swapping to > for the second comparison. From oscar.j.benjamin at gmail.com Thu Oct 1 18:36:50 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 01 Oct 2015 22:36:50 +0000 Subject: Generating a vector from successive multiplications of another vector from an initial value In-Reply-To: References: Message-ID: On Thu, 1 Oct 2015 21:51 Paulo da Silva wrote: Hi all. What is the fastest way to do the following: I have an initial value V and a vector vec of (financial) indexes. I want to generate a new vector nvec as V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ... A numpy vectorized solution would be better. V * np.cumprod(vec) -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckaynor at zindagigames.com Thu Oct 1 18:48:35 2015 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 1 Oct 2015 15:48:35 -0700 Subject: Check if a given value is out of certain range In-Reply-To: References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> <87r3le1ht3.fsf@elektro.pacujo.net> Message-ID: On Thu, Oct 1, 2015 at 3:03 PM, Ian Kelly wrote: > On Thu, Oct 1, 2015 at 3:45 PM, John Gordon wrote: > > In <87r3le1ht3.fsf at elektro.pacujo.net> Marko Rauhamaa writes: > >> Wouldn't > > > >> x < 0 or 10 < x > > > >> be even more visual? > > > > [SNIP] > > > > Another strike is that the code isn't consistent with itself; it puts the > > variable on the left in the first comparison, then swaps to the right for > > the second comparison. > > And on the other hand, it consistently uses the < operator rather > than swapping to > for the second comparison. I would argue that the former consistency is more important than the second, mostly because my mode of thought is along the lines of: - Do I have more than 10 apples? (x > 10) or - Do I have fewer than 10 apples? (x < 10) rather than - Is 10 fewer apples than I have? (10 < x) or - Is 10 more apples than I have? (10 > x) Because the former set is how I think, the former set is the easier to understand. By no means does it mean I cannot understand the later set, but it takes more thought to parse the meaning. If a bunch of code consistently used the second, my mind would adapt to more easily parse it, but it would take a while to transition between the sets, especially compared to transitioning within a set. Chris From cs at zip.com.au Thu Oct 1 18:50:32 2015 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 2 Oct 2015 08:50:32 +1000 Subject: Only getting the first 6 lines In-Reply-To: <87y4fmp7xi.fsf@Equus.decebal.nl> References: <87y4fmp7xi.fsf@Equus.decebal.nl> Message-ID: <20151001225032.GA5474@cskk.homeip.net> On 01Oct2015 23:58, Cecil Westerhof wrote: >I want to get the first 6 lines of ps output. For this I use: >======================================================================== >from subprocess import check_output > >ps_command = ('ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort') >message = '\n'.join(check_output(ps_command + ('-%cpu',)).decode("utf-8").splitlines()[0:6]) >======================================================================== > >It works, but does not look very efficient. Is there a better way to >do this? It depends what you mean by inefficient. I'm presuming you mean that this: - sucks in all the output of ps instead of just the first 6 lines - sucks all the output into memory instead of just some of it - does more in-memory work in splitlines() - needs ps to run to completion instead of just long enough to print 6 lines You could just read six lines of output from ps. Something like this (untested): lines = [] for lineno, line in \ enumerate(Popen(ps_command + ('-%cpu',), stdin=NULL, stdout=PIPE).stdout, 1): lines.append(line.decode("utf-8")) if lineno >= 6: break This works because in a miracle of foresight you can split binary data streams (the stdout) on line breaks, so you can fetch "binary" lines and decode them individually. This approach is important if the output of your command is large or slow, as it does not need to suck the whole thing into memory or to wait for it to finish a long procedure. With "ps" these issues are pretty minor; with some other programs it can be significant, especially if the other program _doesn't_ terminate (consider "tail -f" of an active log file). Cheers, Cameron Simpson From cs at zip.com.au Thu Oct 1 18:52:36 2015 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 2 Oct 2015 08:52:36 +1000 Subject: ConnectionError handling problem In-Reply-To: <201509302156.t8ULu2rE000710@fido.openend.se> References: <201509302156.t8ULu2rE000710@fido.openend.se> Message-ID: <20151001225236.GA52174@cskk.homeip.net> On 30Sep2015 23:56, Laura Creighton wrote: >In a message of Thu, 01 Oct 2015 07:30:59 +1000, Cameron Simpson writes: >>Most likely the Ctrl-C interrupts whatever system call is hanging, causing it >>to return (failed, probably with errno EINTR). And the python program resumes >>because the OS system call has returned. > >Shiva Upreti needs to post the current code, but last time I read it >the problem was that control-C is a KeyboardInterrupt, which the >program was catching, and then continuing the loop. Indeed. Cheers, Cameron Simpson C makes it easy for you to shoot yourself in the foot. C++ makes that harder, but when you do, it blows away your whole leg. - Bjarne Stroustrup From ian.g.kelly at gmail.com Thu Oct 1 18:58:02 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 1 Oct 2015 16:58:02 -0600 Subject: Only getting the first 6 lines In-Reply-To: <87y4fmp7xi.fsf@Equus.decebal.nl> References: <87y4fmp7xi.fsf@Equus.decebal.nl> Message-ID: On Thu, Oct 1, 2015 at 3:58 PM, Cecil Westerhof wrote: > I want to get the first 6 lines of ps output. For this I use: > ======================================================================== > from subprocess import check_output > > ps_command = ('ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort') > message = '\n'.join(check_output(ps_command + ('-%cpu',)).decode("utf-8").splitlines()[0:6]) > ======================================================================== > > It works, but does not look very efficient. Is there a better way to > do this? Instead of using check_output which reads the entire output, you could create a Popen with stdin=None, stdout=PIPE, stderr=None, and then read just the first six lines. Don't forget to clean up the subprocess afterward. From breamoreboy at yahoo.co.uk Thu Oct 1 19:34:47 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 2 Oct 2015 00:34:47 +0100 Subject: Check if a given value is out of certain range In-Reply-To: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 01/10/2015 19:18, Steven D'Aprano wrote: > On Thu, 1 Oct 2015 08:31 am, Mark Lawrence wrote: > >>> What is so "yuck" about that? What would you do instead? It seems like >>> the best solution to me. Easy to read, fast to execute. >>> >> >> I have to parse those damn brackets and then figure out the inverted >> logic. Give me x < 0 or x > 10 any day of the week. When you're an old, >> senile git like me, readability counts :-) > > With the greatest of respect Mark, I don't believe that for a second. Your > sig line, which you have used without fail for more years than I can > remember includes the phrase "ask not what our language can do for you". If > you can understand that, I don't believe that you cannot figure out how to > go from this: > > # x is within the range a to b > a <= x < = b > > to this: > > # x is NOT within the range a to b > not a <= x < = b > > You're certainly a senile old git if you think we're falling for that > one :-) Why do you think I never gamble at anything, it's a mug's game. > > P.S. in case you missed it, you don't actually need the params, since the > precedence of not is lower than the other operators. I confess that I did not bother to check. > > Did-I-include-sufficient-smileys-ly y'rs, > Not bad. However after the big match coming up on Saturday evening UK time one of us will possibly be putting up ginormous quantities of smileys, matched by the ginormous quantity of grimaces from the other :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From buzzard at invalid.invalid Thu Oct 1 19:44:19 2015 From: buzzard at invalid.invalid (duncan smith) Date: Fri, 2 Oct 2015 00:44:19 +0100 Subject: Generating a vector from successive multiplications of another vector from an initial value In-Reply-To: References: Message-ID: <560dc554$0$3212$862e30e2@ngroups.net> On 01/10/15 21:45, Paulo da Silva wrote: > Hi all. > > What is the fastest way to do the following: > > I have an initial value V and a vector vec of (financial) indexes. > I want to generate a new vector nvec as > > V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ... > > A numpy vectorized solution would be better. > > Thanks > Maybe, http://docs.scipy.org/doc/numpy/reference/generated/numpy.cumprod.html Duncan From breamoreboy at yahoo.co.uk Thu Oct 1 19:46:12 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 2 Oct 2015 00:46:12 +0100 Subject: Pandas Left Merge with xlsx with CSV producing null value columns in output In-Reply-To: <858efe8b-ccc1-4c7a-acaf-f3e9de8cfbf3@googlegroups.com> References: <858efe8b-ccc1-4c7a-acaf-f3e9de8cfbf3@googlegroups.com> Message-ID: On 01/10/2015 16:03, kbtyo wrote: > I would appreciate any feedback on the following question that I have raised here: > > http://stackoverflow.com/questions/32889129/pandas-left-merge-with-xlsx-with-csv-producing-null-value-columns-in-output > > Thank you for your feedback and support. > I was going to suggest that you ask on the pandas mailing list/google group, but as you've all ready done so, is there anywhere that you haven't asked? Is there a subreddit for pandas you could also try just in case? -- 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 Oct 1 19:59:04 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 1 Oct 2015 19:59:04 -0400 Subject: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results) In-Reply-To: References: Message-ID: On 10/1/2015 12:26 PM, Chris Warrick wrote: > The Nikola developers decided to deprecate Python 2.7 support. > Starting with v7.7.2, Nikola will display a warning if Python 2.7 is > used (but it will still be fully supported). In early 2016, Nikola > v8.0.0 will come out, and that release will not support Python 2.7 > officially. How sane ;-) > The decision was made on the basis of a user survey, with 138 > participants. The vast majority of them claimed that they either use > Python 3 already, or can switch really easily. From the survey and description below, 'using Python 3' means having Python 3 installed, not writing Python 3 code. Correct? I must admit that I am surprised that even 7% of those who bothered to answer would claim that they would refuse to even install Py 3. > The main reason for the > switch was the fact that supporting both requires a lot of extra > effort, especially because Python 2.7?s Unicode support is abysmal. 2.7 unicode bug-fixing pretty much ended a couple of years ago or so. Remaining bugs either have or eventually will be closed as fixed in 3.x. > Full results: https://getnikola.com/blog/env-survey-results-and-the-future-of-python-27.html > > What is Nikola? > =============== > > Nikola is a static site and blog generator, written in Python. > It can use Mako and Jinja2 templates, and input in many popular markup > formats, such as reStructuredText and Markdown ? and can even turn > Jupyter (IPython) Notebooks into blog posts! It also supports image > galleries, and is multilingual. Nikola is flexible, and page builds > are extremely fast, courtesy of doit (which is rebuilding only what > has been changed). > > Find out more at the website: https://getnikola.com/ -- Terry Jan Reedy From p_s_d_a_s_i_l_v_a_ns at netcabo.pt Thu Oct 1 21:01:57 2015 From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva) Date: Fri, 2 Oct 2015 02:01:57 +0100 Subject: Generating a vector from successive multiplications of another vector from an initial value References: Message-ID: ?s 23:36 de 01-10-2015, Oscar Benjamin escreveu: > > On Thu, 1 Oct 2015 21:51 Paulo da Silva > wrote: ... > > V * np.cumprod(vec) > Thank you very much Oscar and Duncan. I googled a lot for such a function. Unfortunately the word "cumulative" didn't come to my mind! Paulo From hadassah.harland at gmail.com Thu Oct 1 22:32:14 2015 From: hadassah.harland at gmail.com (Hadassah Harland) Date: Fri, 2 Oct 2015 12:32:14 +1000 Subject: Python 3.5.0 (32-bit) Setup error Message-ID: The python for windows setup program is constantly opening on my computer, every couple seconds. Nothing I can do will make it stop. Please, make it stop. Regards, Hadassah -------------- next part -------------- An HTML attachment was scrubbed... URL: From gtec.oses at gmail.com Fri Oct 2 02:15:54 2015 From: gtec.oses at gmail.com (Rolston Jeremiah) Date: Thu, 1 Oct 2015 23:15:54 -0700 (PDT) Subject: compiling matplotlib in virtual env Message-ID: Hello everyone, I been trying to compile matplotlib in a python3.4 virtual env using pip version 1.7 on Fedora 22. I am in about 3 weeks learning python and Django so I am not clear on the error response to: commmand ========= pip3 install matplotlib error message ============= Traceback (most recent call last): File "", line 20, in File "/tmp/pip-build-b_yuukm4/matplotlib/setup.py", line 155, in result = package.check() File "/tmp/pip-build-b_yuukm4/matplotlib/setupext.py", line 961, in check min_version='2.3', version=version) File "/tmp/pip-build-b_yuukm4/matplotlib/setupext.py", line 445, in _check_for_pkg_config if (not is_min_version(version, min_version)): File "/tmp/pip-build-b_yuukm4/matplotlib/setupext.py", line 173, in is_min_version return found_version >= expected_version File "/usr/lib64/python3.4/distutils/version.py", line 76, in __ge__ c = self._cmp(other) File "/usr/lib64/python3.4/distutils/version.py", line 343, in _cmp if self.version < other.version: TypeError: unorderable types: str() < int() ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-b_yuukm4/matplotlib Appreciate your help thanks rjae From miki.tebeka at gmail.com Fri Oct 2 02:43:35 2015 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Thu, 1 Oct 2015 23:43:35 -0700 (PDT) Subject: compiling matplotlib in virtual env In-Reply-To: References: Message-ID: > I been trying to compile matplotlib in a python3.4 virtual env using > pip version 1.7 on Fedora 22. I am in about 3 weeks learning python > and Django so I am not clear on the error response to: > ... > File "/usr/lib64/python3.4/distutils/version.py", line 343, in _cmp > if self.version < other.version: > TypeError: unorderable types: str() < int() Looks like a bug in distuils (which is a package used by pip). Maybe you can upgrade to a newer version of distutils? (pip3 install -U distutils) and try again? As a side note, I find using conda to install scipy related packages a much easier way. From __peter__ at web.de Fri Oct 2 03:37:54 2015 From: __peter__ at web.de (Peter Otten) Date: Fri, 02 Oct 2015 09:37:54 +0200 Subject: Only getting the first 6 lines References: <87y4fmp7xi.fsf@Equus.decebal.nl> Message-ID: Cecil Westerhof wrote: > I want to get the first 6 lines of ps output. For this I use: > ======================================================================== > from subprocess import check_output > > ps_command = ('ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd', > '--sort') message = '\n'.join(check_output(ps_command + > ('-%cpu',)).decode("utf-8").splitlines()[0:6]) > ======================================================================== > > It works, but does not look very efficient. Is there a better way to > do this? Efficiency be damned, readability counts ;) With that in mind here's a little code cleanup: import subprocess def text_head(text, n): return "\n".join(text.split("\n", n)[:n]) def ps(sort=None): cmd = ['ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd'] if sort is not None: cmd += ["--sort", sort] return subprocess.check_output(cmd, universal_newlines=True) if __name__ == "__main__": print(text_head(ps("-%cpu"), 6)) For long strings and small n text.split(\n", n)[:n] is a bit faster than text.splitlines()[n] $ wc -l fodder.txt 969 fodder.txt $ python3 -m timeit -s 'text = open("fodder.txt").read()' 'text.split("\n", 6)[:6]' 100000 loops, best of 3: 7.54 usec per loop $ python3 -m timeit -s 'text = open("fodder.txt").read()' 'text.splitlines() [:6]' 1000 loops, best of 3: 215 usec per loop but the effect on the total time to run the code should be negligable. From lac at openend.se Fri Oct 2 04:42:21 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 02 Oct 2015 10:42:21 +0200 Subject: compiling matplotlib in virtual env In-Reply-To: References: Message-ID: <201510020842.t928gLOl023981@fido.openend.se> Lots of egg problems can be fixed if you pip install this package first. https://pypi.python.org/pypi/ez_setup However, you are trying to install matplotlib. Your distro should have it already as a package (python-matplotlib perhaps? python3-matplotlib perhaps?) and you may want to get it from there. If you don't want to get it from there, you may want to use conda instead of pip/easy_install and so on. http://conda.pydata.org/docs/intro.html If the scientific python stack, and not just matplotlib is in your future, just use conda. It is so much easier. Laura From jeanmichel at sequans.com Fri Oct 2 05:03:11 2015 From: jeanmichel at sequans.com (jmp) Date: Fri, 02 Oct 2015 11:03:11 +0200 Subject: Create a .lua fle from Python In-Reply-To: <560d85ba$0$1591$c3e8da3$5496439d@news.astraweb.com> References: <560d85ba$0$1591$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 10/01/2015 09:12 PM, Steven D'Aprano wrote: > On Wed, 30 Sep 2015 07:21 pm, jmp wrote: > >>> Is Ariel's xml file user-supplied? If so, how does your suggestion >>> prevent the resulting lua script from executing arbitrary code? >> >> It does not. Like it doesn't fulfill the millions of possible >> requirements the OP could have written but did not. What if the OP want >> a thread safe, super fast, multi core solution distributed on multiple >> remote hosts ? > > Then he should have said so. > > We are not *required* to guess every last requirement that somebody might > have but didn't mention. But we do have a professional[1] duty of care to > warn an *obvious beginner* that he may be introducing a serious security > vulnerability into his code. I agree with you and to some extend to Peter's answer, my solution is not safe but note that I didn't mean it to be nor did I claimed it was safe. What I disagree with, is the suggestion that I should provide a safe version of my solution, just in case the OP forgot to mention that he was going public with his application while a simple "beware this solution is not safe" would have sufficed. Safety is like speed optimization, you care about it only when it can be a problem. And the vast majority (there's a recent trolling thread about the equivalent percentage of vast majority if you want to have fun) of python code may run on trusted networks. Meaning it's probable you are wrong when assuming security of a python snippet is a concern. JM Note : becoming public on the internet is not even enough for security to be a concern. Consider the OP's request, someone around the world would need to be willing to hack into the OP's server, guess/find out that the xml is able to execute lua and then attack the server for a reason yet to be known. If the OP's name is google, yeah someone will want to do that. If you're a complete anonymous... From wabayang at gmail.com Fri Oct 2 06:49:53 2015 From: wabayang at gmail.com (bayang) Date: Fri, 2 Oct 2015 12:49:53 +0200 Subject: compiling matplotlib in virtual env In-Reply-To: <201510020842.t928gLOl023981@fido.openend.se> References: <201510020842.t928gLOl023981@fido.openend.se> Message-ID: I ran into the same issue. Check here http://stackoverflow.com/questions/27024731/matplotlib-compilation-error-typeerror-unorderable-types-str-int It worked for me on python 3 with virtualenv in ubuntu . Libfreetype was missing. Le 2 oct. 2015 10:43, "Laura Creighton" a ?crit : > Lots of egg problems can be fixed if you pip install this > package first. > > https://pypi.python.org/pypi/ez_setup > > However, you are trying to install matplotlib. > Your distro should have it already as a package (python-matplotlib > perhaps? python3-matplotlib perhaps?) and you may want to get > it from there. If you don't want to get it from there, you may > want to use conda instead of pip/easy_install and so on. > http://conda.pydata.org/docs/intro.html > > If the scientific python stack, and not just matplotlib is in > your future, just use conda. It is so much easier. > > Laura > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hadassah.harland at gmail.com Fri Oct 2 06:59:58 2015 From: hadassah.harland at gmail.com (Hadassah Harland) Date: Fri, 2 Oct 2015 20:59:58 +1000 Subject: Python 3.5.0 (32-bit) Setup error In-Reply-To: References: Message-ID: [image: Inline image 1] For further clarification, this pop-up keeps appearing every time i use pycharm, it will restart every couple of seconds. If I choose repair, it will start a repair and while the repair is going it will open again, and without another response, after about a second will close itself and reopen, centre page every time. The program has rendered my computer unusable while pycharm is open. Regards, Hadassah On Fri, Oct 2, 2015 at 12:32 PM, Hadassah Harland < hadassah.harland at gmail.com> wrote: > The python for windows setup program is constantly opening on my computer, > every couple seconds. Nothing I can do will make it stop. Please, make it > stop. > > Regards, Hadassah > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 297037 bytes Desc: not available URL: From Cecil at decebal.nl Fri Oct 2 07:08:37 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 02 Oct 2015 13:08:37 +0200 Subject: Only getting the first 6 lines References: <87y4fmp7xi.fsf@Equus.decebal.nl> Message-ID: <87twq9plxm.fsf@Equus.decebal.nl> On Friday 2 Oct 2015 00:50 CEST, Cameron Simpson wrote: > On 01Oct2015 23:58, Cecil Westerhof wrote: >> I want to get the first 6 lines of ps output. For this I use: >> ======================================================================== >> from subprocess import check_output >> >> ps_command = ('ps', '-eo', >> 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort') message = >> '\n'.join(check_output(ps_command + >> ('-%cpu',)).decode("utf-8").splitlines()[0:6]) >> ======================================================================== >> >> It works, but does not look very efficient. Is there a better way >> to do this? > > It depends what you mean by inefficient. I'm presuming you mean that > this: > > - sucks in all the output of ps instead of just the first 6 lines > > - sucks all the output into memory instead of just some of it > > - does more in-memory work in splitlines() Yes. > - needs ps to run to completion instead of just long enough to print > 6 lines No, because of the sort, ps has to generate all lines. > > You could just read six lines of output from ps. Something like this > (untested): > > > lines = [] > for lineno, line in \ > enumerate(Popen(ps_command + ('-%cpu',), > stdin=NULL, stdout=PIPE).stdout, > 1): > lines.append(line.decode("utf-8")) > if lineno >= 6: > break I wrote the following general function for it: ======================================================================== def log_resource_usage(command, resource_type, nr_of_lines): lines = [] process = Popen(command, stdin = None, stdout = PIPE, stderr = None) for lineno, line in enumerate(process.stdout, 1): lines.append(line.decode('utf-8').strip()) if lineno >= nr_of_lines: break message = '\n'.join(lines) cursor.execute(insert_message, (resource_type, message)) process.wait() ======================================================================== > This approach is important if the output of your command is large or > slow, as it does not need to suck the whole thing into memory or to > wait for it to finish a long procedure. With "ps" these issues are > pretty minor; with some other programs it can be significant, > especially if the other program _doesn't_ terminate (consider "tail > -f" of an active log file). Well ps generates more as 400 lines. Not a real problem, but I like to solve problems before they become a problem. ;-) -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From Cecil at decebal.nl Fri Oct 2 07:11:46 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 02 Oct 2015 13:11:46 +0200 Subject: Only getting the first 6 lines References: <87y4fmp7xi.fsf@Equus.decebal.nl> Message-ID: <87pp0xplsd.fsf@Equus.decebal.nl> On Friday 2 Oct 2015 09:37 CEST, Peter Otten wrote: > Cecil Westerhof wrote: > >> I want to get the first 6 lines of ps output. For this I use: >> ======================================================================== >> from subprocess import check_output >> >> ps_command = ('ps', '-eo', >> 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort') message = >> '\n'.join(check_output(ps_command + >> ('-%cpu',)).decode("utf-8").splitlines()[0:6]) >> ======================================================================== >> >> It works, but does not look very efficient. Is there a better way >> to do this? > > Efficiency be damned, readability counts ;) The second is more important as the first, but if you can have both ? :-) I already made a function for it. See my other response. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From stefan_ml at behnel.de Fri Oct 2 07:49:05 2015 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 2 Oct 2015 13:49:05 +0200 Subject: Create a .lua fle from Python In-Reply-To: References: <560d85ba$0$1591$c3e8da3$5496439d@news.astraweb.com> Message-ID: jmp schrieb am 02.10.2015 um 11:03: > Safety is like speed optimization, you care about it only when it can be a > problem. And the vast majority (there's a recent trolling thread about the > equivalent percentage of vast majority if you want to have fun) of python > code may run on trusted networks. Meaning it's probable you are wrong when > assuming security of a python snippet is a concern. Writing code "for internal use only" is ok, but there is never a guarantee that some of that code won't be reused elsewhere, in an entirely different context. Or that someone comes up with the idea of adding a REST API frontend, now that there is a command line interface [1]. If that happens, I assure you that at least in some cases (be it the "vast majority" or not) there will be no thorough security audit up-front. Because, you know - it's code that works and is production proven already. Possibly for years and years, and through generations of employees, all experienced and trusted. What can possibly be wrong with such code? So, it's acceptable to write such code under certain conditions, but at least someone should leave a visible comment somewhere (as Peter rightfully did in this case) that the input is not safely validated, so that future generations of programmers can see immediately that a) security hasn't been a concern when writing it and b) the author was in fact not a complete moron, not knowing a bit about the basics of input validation. It really helps in trust building to find such comments from time to time. Stefan [1] mainframes on the Internet, anyone? From lac at openend.se Fri Oct 2 08:06:41 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 02 Oct 2015 14:06:41 +0200 Subject: Python 3.5.0 (32-bit) Setup error In-Reply-To: References: Message-ID: <201510021206.t92C6fWR008011@fido.openend.se> In a message of Fri, 02 Oct 2015 20:59:58 +1000, Hadassah Harland writes: >[image: Inline image 1] >For further clarification, this pop-up keeps appearing every time i use >pycharm, it will restart every couple of seconds. If I choose repair, it >will start a repair and while the repair is going it will open again, and >without another response, after about a second will close itself and >reopen, centre page every time. The program has rendered my computer >unusable while pycharm is open. > >Regards, Hadassah PyCharm is made by JetBrains, an independent company. You will have to talk to them about your problem. https://intellij-support.jetbrains.com/hc/en-us Laura From kwpolska at gmail.com Fri Oct 2 08:13:54 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Fri, 2 Oct 2015 14:13:54 +0200 Subject: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results) In-Reply-To: References: Message-ID: On 2 October 2015 at 01:59, Terry Reedy wrote: > On 10/1/2015 12:26 PM, Chris Warrick wrote: >> >> The Nikola developers decided to deprecate Python 2.7 support. >> Starting with v7.7.2, Nikola will display a warning if Python 2.7 is >> used (but it will still be fully supported). In early 2016, Nikola >> v8.0.0 will come out, and that release will not support Python 2.7 >> officially. > > > How sane ;-) > >> The decision was made on the basis of a user survey, with 138 >> participants. The vast majority of them claimed that they either use >> Python 3 already, or can switch really easily. > > > From the survey and description below, 'using Python 3' means having Python > 3 installed, not writing Python 3 code. Correct? Correct. We asked about Nikola users, who don?t really have to write any Python code. This is, however, an useful information for OSS developers, who want to know if they can/should target Python 3 instead of Python 2. -- Chris Warrick PGP: 5EAAEA16 From hemla21 at gmail.com Fri Oct 2 09:10:56 2015 From: hemla21 at gmail.com (Hedieh Ebrahimi) Date: Fri, 2 Oct 2015 06:10:56 -0700 (PDT) Subject: PySide window does not resize to fit screen In-Reply-To: References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> Message-ID: <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> Thanks Laura, In my user interface I have many group boxes that are located inside the main widget. All the group boxes and their child widgets have fixed sizes. How can I use the width and height I get from availableGeometry or ScreenGeometry to multiply screenGeometry = QApplication.instance().desktop().screenGeometry() availGeometry = QApplication.instance().desktop().availableGeometry() width, height = availGeometry.width(), availGeometry.height() to resize my geometry by a ratio? Is this a good approach? From kwpolska at gmail.com Fri Oct 2 09:25:44 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Fri, 2 Oct 2015 15:25:44 +0200 Subject: PySide window does not resize to fit screen In-Reply-To: <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> Message-ID: On 2 October 2015 at 15:10, Hedieh Ebrahimi wrote: > Thanks Laura, > > In my user interface I have many group boxes that are located inside the main widget. All the group boxes and their child widgets have fixed sizes. > > How can I use the width and height I get from availableGeometry or ScreenGeometry to multiply > > screenGeometry = QApplication.instance().desktop().screenGeometry() > availGeometry = QApplication.instance().desktop().availableGeometry() > width, height = availGeometry.width(), availGeometry.height() > > to resize my geometry by a ratio? Is this a good approach? > -- > https://mail.python.org/mailman/listinfo/python-list This is NOT a good approach. A good approach involves using a layout. See my previous e-mail for details. Geometry is not going to help you here, especially since you would need a ton of code to resize everything on **any** window size change event. And you especially do not need the screen size, because it would still hinder changing window sizes. -- Chris Warrick PGP: 5EAAEA16 From gilcanmachado at gmail.com Fri Oct 2 10:14:59 2015 From: gilcanmachado at gmail.com (Gilcan Machado) Date: Fri, 2 Oct 2015 11:14:59 -0300 Subject: I'm using Sphinx, but is there a UML auto generator Message-ID: Hi, I'm using Sphinx as a doc tool. Amazing. But I need a way to describe, for example, that, inside a Person class, there's a method called changePassword which depends of the execution of the method checkPermissions, and checkPermissions depends on the execution of two other methods. I'm using a graphic tool like OpenDraw to do the job, but I guess there's a better way of doing this. Is there any UML auto generator for python that do that? If not, any suggestion? By the way, I don't know UML (only the very basic stuff), I'm only trying to find a good way to describe the methods relations inside my class. [] Gil -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Fri Oct 2 11:14:19 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 02 Oct 2015 17:14:19 +0200 Subject: I'm using Sphinx, but is there a UML auto generator In-Reply-To: References: Message-ID: <201510021514.t92FEJKG022718@fido.openend.se> In a message of Fri, 02 Oct 2015 11:14:59 -0300, Gilcan Machado writes: >Hi, > >I'm using Sphinx as a doc tool. > >Amazing. > >But I need a way to describe, for example, that, inside a Person class, >there's a method called changePassword which depends of the execution of >the method checkPermissions, and checkPermissions depends on the execution >of two other methods. > >I'm using a graphic tool like OpenDraw to do the job, but I guess there's a >better way of doing this. > >Is there any UML auto generator for python that do that? > >If not, any suggestion? > >By the way, I don't know UML (only the very basic stuff), I'm only trying >to find a good way to describe the methods relations inside my class. > >[] >Gil > >-- >https://mail.python.org/mailman/listinfo/python-list You can use Graphvix and Plant UML from inside Sphinx. http://build-me-the-docs-please.readthedocs.org/en/latest/Using_Sphinx/UsingGraphicsAndDiagramsInSphinx.html Laura From ahlusar.ahluwalia at gmail.com Fri Oct 2 11:15:03 2015 From: ahlusar.ahluwalia at gmail.com (kbtyo) Date: Fri, 2 Oct 2015 08:15:03 -0700 (PDT) Subject: Pandas Left Merge with xlsx with CSV producing null value columns in output In-Reply-To: References: <858efe8b-ccc1-4c7a-acaf-f3e9de8cfbf3@googlegroups.com> Message-ID: On Thursday, October 1, 2015 at 7:47:18 PM UTC-4, Mark Lawrence wrote: > On 01/10/2015 16:03, kbtyo wrote: > > I would appreciate any feedback on the following question that I have raised here: > > > > http://stackoverflow.com/questions/32889129/pandas-left-merge-with-xlsx-with-csv-producing-null-value-columns-in-output > > > > Thank you for your feedback and support. > > > > I was going to suggest that you ask on the pandas mailing list/google > group, but as you've all ready done so, is there anywhere that you > haven't asked? Is there a subreddit for pandas you could also try just > in case? I appreciate the suggestion. I was able to solve the issue. Thank you again. > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence From tyler at tysdomain.com Fri Oct 2 11:19:56 2015 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Fri, 2 Oct 2015 11:19:56 -0400 Subject: I'm using Sphinx, but is there a UML auto generator In-Reply-To: <201510021514.t92FEJKG022718@fido.openend.se> References: <201510021514.t92FEJKG022718@fido.openend.se> Message-ID: <560EA09C.6080808@tysdomain.com> > You can use Graphvix and Plant UML from inside Sphinx. > http://build-me-the-docs-please.readthedocs.org/en/latest/Using_Sphinx/UsingGraphicsAndDiagramsInSphinx.html > > Laura > Keep this in mind: However you write your docs, they should be accessible for everyone to use. That is to say, screen readers should be able to use them as well--perhaps try explaining this dependency in a format across all the docs in text as well? HTH, -- Take care, Ty twitter: @sorressean web:http://tysdomain.com pubkey: http://tysdomain.com/files/pubkey.asc From kennfletch at gmail.com Fri Oct 2 12:41:16 2015 From: kennfletch at gmail.com (Kenneth L) Date: Fri, 2 Oct 2015 09:41:16 -0700 (PDT) Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) Message-ID: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> I'm a graphic designer. I'm new to Python. I know html, css, alittle actioscript and little javascript. I actually build an iOS using Flash. I understand programming concepts I believe. I'd like to build a Illustrator/Photoshop like program. Why, there are some features that I'd like to personally have. Example, randomizing the rotation, line height and sizing of text. You have to do this manually. It would be cool have a little program that is dedicated building logos. Not trying to reinvent the wheel. Just basic featuring of vector graphics program plus my enhancements. Maybe this program could be base and it can export vector and bring into Photoshop to add finishing touches. I heard Python is easy to learn. So my question is Python able to do this or connect with libraries? Plus where do I start? I watched python tutorials but they don't really show you how to build an application. How does one build a graphics program? LOL where do you start? How do you draw graphics on the screen? I'm just confused. From rosuav at gmail.com Fri Oct 2 12:57:44 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 3 Oct 2015 02:57:44 +1000 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On Sat, Oct 3, 2015 at 2:41 AM, Kenneth L wrote: > I'm a graphic designer. I'm new to Python. I know html, css, alittle actioscript and little javascript. I actually build an iOS using Flash. I understand programming concepts I believe. > > I'd like to build a Illustrator/Photoshop like program. Why, there are some features that I'd like to personally have. Example, randomizing the rotation, line height and sizing of text. You have to do this manually. It would be cool have a little program that is dedicated building logos. Not trying to reinvent the wheel. Just basic featuring of vector graphics program plus my enhancements. > Maybe this program could be base and it can export vector and bring into Photoshop to add finishing touches. > > I heard Python is easy to learn. So my question is Python able to do this or connect with libraries? Plus where do I start? I watched python tutorials but they don't really show you how to build an application. How does one build a graphics program? LOL where do you start? How do you draw graphics on the screen? > > I'm just confused. You basically have three options here. 1) Completely write a Photoshop-like program from scratch. There are libraries that can do the heavy lifting for you (Pillow comes to mind), but you'd be writing a big and complex UI. This is a huge job. I recommend not doing this. 2) Find an existing open-source program that does what you want, and hack on it; or find an existing program that has a plugin/extension system, and write a plugin. This is a great option if one exists, but bear in mind that you might have your choices restricted somewhat (eg you might have to use a specific programming language, or you might have to fit everything into a single menu item, etc). 3) Build a preprocessor or postprocessor for your images. You'd do most of your work in a well-known program, and then when you get to the very last step, you run your output file through a post-processor (or you run your input files through a preprocessor prior to importing them). This can work really well in some situations, but it isn't so great for interactive work. But it's fairly straight-forward; you can define your program purely in terms of its inputs and outputs, and you can write it in any language you like. Have a look into those options, and see what kind of job you're taking on. (Hint: Options 2 and 3 are *much* smaller jobs than option 1 will be.) Then decide whether it's within your time budget (don't forget that you might have to learn some new technologies), and whether it'll be worth the effort (and it's always more effort than you first think it will be). And maybe, even if it's not really worth the effort, it'll be enough fun that you barge ahead and do it anyway :) ChrisA From lac at openend.se Fri Oct 2 13:01:27 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 02 Oct 2015 19:01:27 +0200 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: <201510021701.t92H1REH030727@fido.openend.se> In a message of Fri, 02 Oct 2015 09:41:16 -0700, Kenneth L writes: >I'd like to build a Illustrator/Photoshop like program. Why, there are some features that I'd like to personally have. Example, randomizing the rotation, line height and sizing of text. You have to do this manually. It would be cool have a little program that is dedicated building logos. Not trying to reinvent the wheel. Just basic featuring of vector graphics program plus my enhancements. Do you know about GIMP? http://www.gimp.org/ You can script it with Python. http://www.gimp.org/docs/python/ Note: Play with GIMP first. A whole lot. Then learn Python -- a bit with a tutorial here: https://wiki.python.org/moin/BeginnersGuide/Programmers or maybe here: https://wiki.python.org/moin/BeginnersGuide/NonProgrammers or -- well, these days there are plenty more that aren't on either of those lists. Then try to script gimp using python. It's not the ideal place to learn how to program in Python, as the Python in the examples there is fairly atypical for normal Python programs, but it works ... Welcome, welcome! Laura From invalid at invalid.invalid Fri Oct 2 13:39:11 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 2 Oct 2015 17:39:11 +0000 (UTC) Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On 2015-10-02, Kenneth L wrote: > I'm a graphic designer. I'm new to Python. I know html, css, alittle > actioscript and little javascript. I actually build an iOS using > Flash. I understand programming concepts I believe. > I'd like to build a Illustrator/Photoshop like program. Holy Cow. I'd like to build something just like the Brooklyn Bridge, only with more lanes. I've got a shovel. And some bricks and wire. I know how to stack the two bricks one on top of another. What do I do next? I'm just confused. -- Grant Edwards grant.b.edwards Yow! PUNK ROCK!! DISCO at DUCK!! BIRTH CONTROL!! gmail.com From blake.garretson at gmail.com Fri Oct 2 14:01:56 2015 From: blake.garretson at gmail.com (Blake Garretson) Date: Fri, 2 Oct 2015 14:01:56 -0400 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: Creating a standalone, special-purpose program that does one thing really well seems doable for a beginner. What you are describing sounds much more involved than that though. Frankly, it is overwhelming. I would HIGHLY suggest looking into creating an extension/plugin for an existing open-source program to do what you want. You mentioned vector graphics and logos, so I would recommend looking into Inkscape (http://inkscape.org) as a candidate for your project. Inkscape has add-ons that can be internal C++ extensions or external scripts in Python (or whatever). Look here: https://inkscape.org/en/develop/extensions/ The advantage of this approach is the heavy lifting has already been done for you, and you can focus on implementing whatever feature you need. This is much more plausible for a beginner to tackle. We also have the added bonus of expanding Inkscape's capabilities, which helps out everyone else. -------------------------- Blake T. Garretson On Fri, Oct 2, 2015 at 12:41 PM, Kenneth L wrote: > I'm a graphic designer. I'm new to Python. I know html, css, alittle > actioscript and little javascript. I actually build an iOS using Flash. I > understand programming concepts I believe. > > I'd like to build a Illustrator/Photoshop like program. Why, there are > some features that I'd like to personally have. Example, randomizing the > rotation, line height and sizing of text. You have to do this manually. It > would be cool have a little program that is dedicated building logos. Not > trying to reinvent the wheel. Just basic featuring of vector graphics > program plus my enhancements. > Maybe this program could be base and it can export vector and bring into > Photoshop to add finishing touches. > > I heard Python is easy to learn. So my question is Python able to do this > or connect with libraries? Plus where do I start? I watched python > tutorials but they don't really show you how to build an application. How > does one build a graphics program? LOL where do you start? How do you draw > graphics on the screen? > > I'm just confused. > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From denismfmcmahon at gmail.com Fri Oct 2 14:25:34 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Fri, 2 Oct 2015 18:25:34 +0000 (UTC) Subject: Question about regular expression References: <811788b6-9955-4dcc-bf49-9647891d17ec@googlegroups.com> Message-ID: On Wed, 30 Sep 2015 23:30:47 +0000, Denis McMahon wrote: > On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote: > >> firstly the description of my problem. I have a string in the following >> form: ..... > > The way I solved this was to: > > 1) replace all the punctuation in the string with spaces > > 2) split the string on space > > 3) process each thing in the list to test if it was a number or word > > 4a) add words to the dictionary as keys with value of a default list, or > 4b) add numbers to the dictionary in the list at the appropriate > position > > 5) convert the list values of the dictionary to tuples > > It seems to work on my test case: > > s = "fred jim(1) alice tom (1, 4) peter (2) andrew(3,4) janet( 7,6 ) > james ( 7 ) mike ( 9 )" > > d = {'mike': (9, 0), 'janet': (7, 6), 'james': (7, 0), 'jim': (1, 0), > 'andrew': (3, 4), 'alice': (0, 0), 'tom': (1, 4), 'peter': (2, 0), > 'fred': > (0, 0)} Oh yeah, the code: #!/usr/bin/python import re s = 'fred jim(1) alice tom (1, 4) peter (2) andrew(3,4) janet( 7,6 ) james ( 7 ) mike ( 9 ) jon ( 6 , 3 ) charles(0,12)' bits = s.replace('(', ' ').replace(',', ' ').replace(')', ' ').split(' ') d = {} namep = re.compile('^[A-Za-z]+$') numbp = re.compile('^[0-9]+$') for bit in bits: if namep.match(bit): d[bit] = [0,0] w = bit nums = 0 if numbp.match(bit): n = int(bit) d[w][nums] = n nums += 1 d = {x:tuple(d[x]) for x in d} print s print d It uses regex to determine if the list element being processed is a name or a number, which makes for 2 very simple patterns. -- Denis McMahon, denismfmcmahon at gmail.com From kennfletch at gmail.com Fri Oct 2 14:25:41 2015 From: kennfletch at gmail.com (Kenneth L) Date: Fri, 2 Oct 2015 11:25:41 -0700 (PDT) Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: Well 15 years ago when I was 15 I wanted to model cars in 3D. It took me 100 hours and 5-10 years but I can modeling a realistic vehicle and other objects in 3d. It was time consuming and challenging but it was worth it. And honestly I've used my 3d modeling skills to build displays and products. It has helped me land jobs and keep jobs. It was a hobby. I'm not afraid of the hard work. I just didn't know were to begin. If this takes me a few years that's fine, lol. I have 20-40 years on earth, hopefully. I'm not sure about the plugin route. I'm not looking to build a plug, lol. Just a finger to point me where to go/start. 1&2 sound good to me. From kennfletch at gmail.com Fri Oct 2 14:27:51 2015 From: kennfletch at gmail.com (Kenneth L) Date: Fri, 2 Oct 2015 11:27:51 -0700 (PDT) Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: I tried to use gimp but as a photoshop user it was horrible. I was trying to like it. That is a great idea tearing down gimp. that is how I learn html and css. Breakin down websites. From sjeik_appie at hotmail.com Fri Oct 2 14:54:23 2015 From: sjeik_appie at hotmail.com (Albert-Jan Roskam) Date: Fri, 2 Oct 2015 18:54:23 +0000 Subject: I'm using Sphinx, but is there a UML auto generator In-Reply-To: References: Message-ID: (Sorry for top-posting, mobile hotmail sie sucks). This is cool, although it's not a Sphinx directive. You use insert the resulting graph in the .rst of course: http://furius.ca/snakefood/ Date: Fri, 2 Oct 2015 11:14:59 -0300 Subject: I'm using Sphinx, but is there a UML auto generator From: gilcanmachado at gmail.com To: python-list at python.org Hi, I'm using Sphinx as a doc tool. Amazing. But I need a way to describe, for example, that, inside a Person class, there's a method called changePassword which depends of the execution of the method checkPermissions, and checkPermissions depends on the execution of two other methods. I'm using a graphic tool like OpenDraw to do the job, but I guess there's a better way of doing this. Is there any UML auto generator for python that do that? If not, any suggestion? By the way, I don't know UML (only the very basic stuff), I'm only trying to find a good way to describe the methods relations inside my class. [] Gil -- https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From random832 at fastmail.com Fri Oct 2 14:57:59 2015 From: random832 at fastmail.com (Random832) Date: Fri, 02 Oct 2015 14:57:59 -0400 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: <1443812279.804884.399866385.35CB4C8C@webmail.messagingengine.com> On Fri, Oct 2, 2015, at 14:27, Kenneth L wrote: > I tried to use gimp but as a photoshop user it was horrible. This is off-topic, but have you tried Gimpshop? From random832 at fastmail.com Fri Oct 2 15:01:55 2015 From: random832 at fastmail.com (Random832) Date: Fri, 02 Oct 2015 15:01:55 -0400 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: <1443812279.804884.399866385.35CB4C8C@webmail.messagingengine.com> References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> <1443812279.804884.399866385.35CB4C8C@webmail.messagingengine.com> Message-ID: <1443812515.805761.399869601.1606E27F@webmail.messagingengine.com> And right after I posted this I found all the stuff mentioning someone had hijacked the name and added spyware... sorry... On Fri, Oct 2, 2015, at 14:57, Random832 wrote: > On Fri, Oct 2, 2015, at 14:27, Kenneth L wrote: > > I tried to use gimp but as a photoshop user it was horrible. > > This is off-topic, but have you tried Gimpshop? > -- > https://mail.python.org/mailman/listinfo/python-list From gadgetsteve at live.co.uk Fri Oct 2 15:32:29 2015 From: gadgetsteve at live.co.uk (Steve (Gadget) Barnes) Date: Fri, 2 Oct 2015 20:32:29 +0100 Subject: Kansha 1.0.5 released In-Reply-To: <1443713188.20700.33.camel@net-ng.com> References: <1443713188.20700.33.camel@net-ng.com> Message-ID: On 01/10/2015 16:26, Romuald Texier-Marcad? wrote: > Hello everybody! > > On behalf of the *Kansha team*, I am excited to announce the release of > version *1.0.5* of *Kansha*, an open source web application to manage > and share collaborative scrum boards with enhanced todo lists and > Trello-like boards (http://www.kansha.org/). > > This version is the first public release. You can install it from pypi > or run it as a docker container. See > http://kansha.readthedocs.org/en/stable/install.html. > > The package is BSD licensed and you can get the sources from github: > https://github.com/Net-ng/kansha. > > General and developer documentation is available at > http://kansha.readthedocs.org/en/stable/. > > Questions can be directed to the *Kansha* mailing list: > http://groups.google.com/group/kansha-users > > > Cheers, > > Romuald Texier-Marcad? > *Software developer* > Just tried the link to the home page, clicked on "Try It" and got connection refused in Chrome, MS Edge & Firefox - this doesn't give a great first impression. -- Steve (Gadget) Barnes Any opinions in this message are my personal opinions and do not reflect those of my employer. From garyr at fidalgo.net Fri Oct 2 15:35:10 2015 From: garyr at fidalgo.net (garyr) Date: Fri, 2 Oct 2015 12:35:10 -0700 Subject: DistutilsPlatformError Message-ID: I'm trying to build an extension for Python 3. I'm using the example code in the book "Python Essential Reference", 4ed. I have it working for Python 2. But when I try to build it for Python 3 I get the following error: distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 10.0 is required ( Unable to find vcvarsall.bat). How can this be fixed? I'm using Python 3.4.3, obtained from Anaconda, on Win XP Thanks in advance garyr --------------------------------- # setup.py from setuptools import setup, Extension setup(name="example", version = "1.0", ext_modules = [ Extension("_example", ["pyexample.c", "example.c"]) ] ) From bc at freeuk.com Fri Oct 2 15:40:40 2015 From: bc at freeuk.com (Bartc) Date: Fri, 2 Oct 2015 20:40:40 +0100 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On 02/10/2015 17:41, Kenneth L wrote: > I actually build an iOS using Flash. What does that mean? That you built an Apple-like operating system using Flash? > I'd like to build a Illustrator/Photoshop like program. You've probably got the message by now that that is not trivial. > Maybe this program could be base and it can export vector and bring into Photoshop to add finishing touches. Yes, I did something like that (but many years ago with not so many libraries). Users took my 3D vector output and used 3D Studio to render it. Still, even an application that does the basic stuff will be a long, hard slog to do, and most of it is going to be concerned with a million uninteresting details, probably GUI-related. > I heard Python is easy to learn. So my question is Python able to do this or connect with libraries? Plus where do I start? I watched python tutorials but they don't really show you how to build an application. How does one build a graphics program? LOL where do you start? How do you draw graphics on the screen? In that case you're probably being over-ambitious. One problem with Python is that it can be quite slow when it needs to do detailed things itself, and it has to rely on libraries written in other, faster languages. If what you want to do can't be directly done by calling a series of such library functions, then you would really need to code in another language. > I'm just confused. Try something much simpler first. -- Bartc From kennfletch at gmail.com Fri Oct 2 16:23:55 2015 From: kennfletch at gmail.com (Kenneth L) Date: Fri, 2 Oct 2015 13:23:55 -0700 (PDT) Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: No don't tell me what to do. I joined the military 3 years ago. You wouldn't believe the stuff I wasn't able to do before but now I am. You can keep your advice to yourself. I wasn't asking for something simple. I was asking for a starting point. The 3d was to show you I've learned hard stuff and it didn't scare me. I was building web pages when I was in grade school late 90s. I had no idea how to build an iPhone app but I created one, lol. I want to build a graphics program or even a prototype. Maybe I can pass it over to a expert and hire then to build it. I have a dozen degree and certificates on my wall. And I didn't get that by going basic. Keep your advice Bartc. From denismfmcmahon at gmail.com Fri Oct 2 16:41:59 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Fri, 2 Oct 2015 20:41:59 +0000 (UTC) Subject: Python 3.5.0 (32-bit) Setup error References: Message-ID: On Fri, 02 Oct 2015 12:32:14 +1000, Hadassah Harland wrote: > The python for windows setup program is constantly opening on my > computer, > every couple seconds. Nothing I can do will make it stop. Please, make > it stop. Based on the comprehensive and thorough information that you have given, I have waved my magic wand. If this didn't work, the information you supplied was insufficient. -- Denis McMahon, denismfmcmahon at gmail.com From bc at freeuk.com Fri Oct 2 16:51:41 2015 From: bc at freeuk.com (Bartc) Date: Fri, 2 Oct 2015 21:51:41 +0100 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On 02/10/2015 21:23, Kenneth L wrote: > And I didn't get that by going basic. Keep your advice Bartc. OK, I will. Although I'm now curious as to what advice you /do/ want. -- Bartc From ian.g.kelly at gmail.com Fri Oct 2 16:56:37 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 2 Oct 2015 14:56:37 -0600 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On Fri, Oct 2, 2015 at 12:27 PM, Kenneth L wrote: > I tried to use gimp but as a photoshop user it was horrible. I was trying to like it. That is a great idea tearing down gimp. that is how I learn html and css. Breakin down websites. What about Inkscape? It's a lot friendlier than GIMP, and it sounds like you're only really interested in vector graphics anyway. Inkscape is also open source and also extensible with Python. From breamoreboy at yahoo.co.uk Fri Oct 2 17:25:24 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 2 Oct 2015 22:25:24 +0100 Subject: DistutilsPlatformError In-Reply-To: References: Message-ID: On 02/10/2015 20:35, garyr wrote: > I'm trying to build an extension for Python 3. I'm using the example code in > the > book "Python Essential Reference", 4ed. I have it working for Python 2. But > when > I try to build it for Python 3 I get the following error: > > distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 10.0 is > required ( > Unable to find vcvarsall.bat). > > How can this be fixed? > > I'm using Python 3.4.3, obtained from Anaconda, on Win XP > > Thanks in advance > garyr > https://docs.python.org/devguide/setup.html#windows -- 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 Oct 2 17:29:03 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 2 Oct 2015 22:29:03 +0100 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On 02/10/2015 18:39, Grant Edwards wrote: > On 2015-10-02, Kenneth L wrote: > >> I'm a graphic designer. I'm new to Python. I know html, css, alittle >> actioscript and little javascript. I actually build an iOS using >> Flash. I understand programming concepts I believe. > >> I'd like to build a Illustrator/Photoshop like program. > > Holy Cow. > > I'd like to build something just like the Brooklyn Bridge, only with > more lanes. > > I've got a shovel. > > And some bricks and wire. > > I know how to stack the two bricks one on top of another. > > What do I do next? > > I'm just confused. > Make allowance for the number of guys who will die of the bends? -- 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 Oct 2 17:40:26 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 2 Oct 2015 22:40:26 +0100 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On 02/10/2015 19:25, Kenneth L wrote: > Well 15 years ago when I was 15 I wanted to model cars in 3D. It took me 100 hours and 5-10 years but I can modeling a realistic vehicle and other objects in 3d. It was time consuming and challenging but it was worth it. And honestly I've used my 3d modeling skills to build displays and products. It has helped me land jobs and keep jobs. It was a hobby. > > I'm not afraid of the hard work. I just didn't know were to begin. If this takes me a few years that's fine, lol. I have 20-40 years on earth, hopefully. > > I'm not sure about the plugin route. I'm not looking to build a plug, lol. Just a finger to point me where to go/start. > > 1&2 sound good to me. > Please quote some context, you'll get a lot more help here if you do. Following threads can get tricky when there are sometimes hundreds of replies. That said with existing programming skills I'd recommend starting out with Python 3, with this http://www.diveintopython3.net/ as good a place as any. If that doesn't suit you feel free to come back, stating why and we'll find you an alternative. -- 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 Fri Oct 2 18:31:56 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 2 Oct 2015 18:31:56 -0400 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On 10/2/2015 12:41 PM, Kenneth L wrote: > I'm a graphic designer. I'm new to Python. I know html, css, alittle > actioscript and little javascript. I actually build an iOS using > Flash. I understand programming concepts I believe. > > I'd like to build a Illustrator/Photoshop like program. Why, there > are some features that I'd like to personally have. Example, > randomizing the rotation, line height and sizing of text. You have to > do this manually. It would be cool have a little program that is > dedicated building logos. Not trying to reinvent the wheel. Just > basic featuring of vector graphics program plus my enhancements. > Maybe this program could be base and it can export vector and bring > into Photoshop to add finishing touches. > > I heard Python is easy to learn. So my question is Python able to do > this or connect with libraries? Plus where do I start? I watched > python tutorials but they don't really show you how to build an > application. How does one build a graphics program? LOL where do you > start? How do you draw graphics on the screen? Python comes with the tkinter package, which interfaces to the tcl/tk GUI framework. Tk has a canvas widget that is, I believe, at least partly vector-based. In any case, it can output .ps or .eps postscript files* and with an extension# .svg scalable vector graphics files. * They may or may not be readable by any other particular app. # I do not know how to install this, but have read that it exists. To get an intro to using tkinter, I would start with the beginning example in the tkinter doc or http://www.tkdocs.com/ or http://effbot.org/tkinterbook/ There are other GUI packages you can download and install. And the other suggestions people have given. -- Terry Jan Reedy From rgaddi at technologyhighland.invalid Fri Oct 2 18:36:23 2015 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Fri, 2 Oct 2015 22:36:23 +0000 (UTC) Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic Message-ID: So, this is odd. I'm running Ubuntu 14.04, and my system did a kernel upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic. And pyserial (2.7, installed through pip) stopped working. Specifically, when I make read() calls on a Serial object, I get the error serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?) This comes from the PosixSerial.read() method in serialposix.py, and seems to be a result of the select.select call screwing up. I reboot under 3.13.0-63-generic. My code works. I reboot under 3.13.0-65-generic. My code doesn't. Implication would seem to be that somehow between these kernel versions, the select() logic in the serial driver changed. This happens regardless of whether the serial port is real, FTDI USB-UART, or Prolific USB-UART. Can anyone else confirm? Also, who do I try to report this one to? Thanks, Rob -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From paul.hermeneutic at gmail.com Fri Oct 2 18:40:33 2015 From: paul.hermeneutic at gmail.com (paul.hermeneutic at gmail.com) Date: Fri, 2 Oct 2015 16:40:33 -0600 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: On Oct 2, 2015 12:31 PM, "Kenneth L" wrote: > I'm not sure about the plugin route. I'm not looking to build a plug, lol. Just a finger to point me where to go/start. Writing a plug-in for an existing open source project would be a good starting point to see how others have approached graphics applications. You probably have something good to contribute to the community. You might start by searching pypi.python.org for "graphics" to see if something there catches your interest. -------------- next part -------------- An HTML attachment was scrubbed... URL: From invalid at invalid.invalid Fri Oct 2 19:36:08 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 2 Oct 2015 23:36:08 +0000 (UTC) Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic References: Message-ID: On 2015-10-02, Rob Gaddi wrote: > Also, who do I try to report this one to? I'd try here: https://github.com/pyserial/pyserial/issues From tjreedy at udel.edu Fri Oct 2 23:57:58 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 2 Oct 2015 23:57:58 -0400 Subject: IDLE = 'Integrated Development and Learning Environment' Message-ID: Today, we agreed on the idle-dev list (Guido included) that 'IDLE' should be interpreted as 'Integrated Development and Learning Environment' rather than as 'Integrated DeveLopment Environment' (note the 'L' in 'DeveLopment'). The new long form better reflects the current practice and goal of IDLE development. For instance, a menu entry to run turtledemo was added a year ago to help learning, rather than development. Of course, 'IDLE' remains an intentional reference to Eric Idle of Monty Python. -- Terry Jan Reedy From rosuav at gmail.com Sat Oct 3 00:02:42 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 3 Oct 2015 14:02:42 +1000 Subject: IDLE = 'Integrated Development and Learning Environment' In-Reply-To: References: Message-ID: On Sat, Oct 3, 2015 at 1:57 PM, Terry Reedy wrote: > Today, we agreed on the idle-dev list (Guido included) that 'IDLE' should be > interpreted as 'Integrated Development and Learning Environment' rather than > as 'Integrated DeveLopment Environment' (note the 'L' in 'DeveLopment'). > The new long form better reflects the current practice and goal of IDLE > development. For instance, a menu entry to run turtledemo was added a year > ago to help learning, rather than development. Of course, 'IDLE' remains an > intentional reference to Eric Idle of Monty Python. Oh, I thought it was already called that. Definitely prefer the four-word expansion to the middle-of-word version. ChrisA From neubyr at gmail.com Sat Oct 3 02:35:28 2015 From: neubyr at gmail.com (neubyr) Date: Fri, 2 Oct 2015 23:35:28 -0700 Subject: Instance method for converting int to str - str() and __str__() Message-ID: I was wondering if there is any resource that explains why certain methods like str() and type() were implemented the way they are, rather than .to_string() or .type() instance/object methods. I find instance/object methods more intuitive for this cases, but I am wondering why it wasn't implemented it like that. I know there are equivalents like __str__() and __class__ , but passing object to str() or type() seems more popular. Any resources for reading or some background information would be helpful. - CS -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Sat Oct 3 04:31:21 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 03 Oct 2015 10:31:21 +0200 Subject: Instance method for converting int to str - str() and __str__() In-Reply-To: References: Message-ID: <201510030831.t938VLTd032128@fido.openend.se> In a message of Fri, 02 Oct 2015 23:35:28 -0700, neubyr writes: >I was wondering if there is any resource that explains why certain methods >like str() and type() were implemented the way they are, rather than >.to_string() or .type() instance/object methods. > >I find instance/object methods more intuitive for this cases, but I am >wondering why it wasn't implemented it like that. > >I know there are equivalents like __str__() and __class__ , but passing >object to str() or type() seems more popular. > >Any resources for reading or some background information would be helpful. > >- CS > >-- >https://mail.python.org/mailman/listinfo/python-list > start reading here: https://www.python.org/download/releases/2.2/descrintro/ and keep searching and reading about type-class unification in Python. The answer is, because types and classes used to be very different things, and you _couldn't_. Laura From lac at openend.se Sat Oct 3 05:07:04 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 03 Oct 2015 11:07:04 +0200 Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic In-Reply-To: References: Message-ID: <201510030907.t93974tU002535@fido.openend.se> In a message of Fri, 02 Oct 2015 22:36:23 -0000, Rob Gaddi writes: >So, this is odd. I'm running Ubuntu 14.04, and my system did a kernel >upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic. >And pyserial (2.7, installed through pip) stopped working. > >Specifically, when I make read() calls on a Serial object, I get the error > >serial.serialutil.SerialException: device reports readiness to read but >returned no data (device disconnected?) > >This comes from the PosixSerial.read() method in serialposix.py, and >seems to be a result of the select.select call screwing up. > >I reboot under 3.13.0-63-generic. My code works. I reboot under >3.13.0-65-generic. My code doesn't. Implication would seem to be that >somehow between these kernel versions, the select() logic in the serial >driver changed. This happens regardless of whether the serial port is >real, FTDI USB-UART, or Prolific USB-UART. > >Can anyone else confirm? Also, who do I try to report this one to? > >Thanks, >Rob > >-- >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 I think you have this bug https://bugs.launchpad.net/ubuntu/+source/linux/+bug/460857 or rather, you like the behaviour that ubuntu thinks is buggy, which never got fixed, and don't like that it changed to be what ubuntu thinks is correct in .65. I'd talk to the pyserial issue tracker as the people there ought to be well aware of this problem, and then see if talking to ubuntu is the right thing to do. Laura From lac at openend.se Sat Oct 3 05:12:28 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 03 Oct 2015 11:12:28 +0200 Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic In-Reply-To: <201510030907.t93974tU002535@fido.openend.se> References: <201510030907.t93974tU002535@fido.openend.se> Message-ID: <201510030912.t939CSQj003123@fido.openend.se> In a message of Sat, 03 Oct 2015 11:07:04 +0200, Laura Creighton writes: >In a message of Fri, 02 Oct 2015 22:36:23 -0000, Rob Gaddi writes: >>So, this is odd. I'm running Ubuntu 14.04, and my system did a kernel >>upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic. >>And pyserial (2.7, installed through pip) stopped working. >> >>Specifically, when I make read() calls on a Serial object, I get the error >> >>serial.serialutil.SerialException: device reports readiness to read but >>returned no data (device disconnected?) >> >>This comes from the PosixSerial.read() method in serialposix.py, and >>seems to be a result of the select.select call screwing up. >> >>I reboot under 3.13.0-63-generic. My code works. I reboot under >>3.13.0-65-generic. My code doesn't. Implication would seem to be that >>somehow between these kernel versions, the select() logic in the serial >>driver changed. This happens regardless of whether the serial port is >>real, FTDI USB-UART, or Prolific USB-UART. >> >>Can anyone else confirm? Also, who do I try to report this one to? >> >>Thanks, >>Rob >> >>-- >>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 > >I think you have this bug >https://bugs.launchpad.net/ubuntu/+source/linux/+bug/460857 > >or rather, you like the behaviour that ubuntu thinks is buggy, >which never got fixed, and don't like that it changed to be >what ubuntu thinks is correct in .65. > >I'd talk to the pyserial issue tracker as the people there ought >to be well aware of this problem, and then see if talking to >ubuntu is the right thing to do. > >Laura >-- >https://mail.python.org/mailman/listinfo/python-list I think I said that poorly. What I think happened is that ubuntu made some changes to fix this problem, and along the way they managed to break things for you, and maybe all pyserial users. But I would talk to the pyserial people about that. Laura From lac at openend.se Sat Oct 3 05:19:39 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 03 Oct 2015 11:19:39 +0200 Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic In-Reply-To: <201510030907.t93974tU002535@fido.openend.se> References: <201510030907.t93974tU002535@fido.openend.se> Message-ID: <201510030919.t939Jdq6003741@fido.openend.se> With better searching, I find this bug. https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345 Looks like that's the real one. Laura From tjreedy at udel.edu Sat Oct 3 06:09:25 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 3 Oct 2015 06:09:25 -0400 Subject: Instance method for converting int to str - str() and __str__() In-Reply-To: References: Message-ID: On 10/3/2015 2:35 AM, neubyr wrote: > > I was wondering if there is any resource that explains why certain > methods like str() and type() These are classes. Calling a class calls the class construction and initialization functions. These return an instance of the class. While reading the tutorial, read the library reference, chapter 2. Chapter 4 is also extremely important to read. -- Terry Jan Reedy From steve at pearwood.info Sat Oct 3 06:29:05 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sat, 03 Oct 2015 20:29:05 +1000 Subject: Check if a given value is out of certain range References: <87r3le1ht3.fsf@elektro.pacujo.net> Message-ID: <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> On Fri, 2 Oct 2015 07:45 am, John Gordon wrote: > In <87r3le1ht3.fsf at elektro.pacujo.net> Marko Rauhamaa > writes: [...] >> Wouldn't > >> x < 0 or 10 < x > >> be even more visual? > > I don't know what you mean by "more visual". > > In my opinion, when comparing a variable to a constant, it's more natural > to have the variable on the left and the constant on the right, so that's > one strike against this code. > > Another strike is that the code isn't consistent with itself; it puts the > variable on the left in the first comparison, then swaps to the right for > the second comparison. The alternative is equally inconsistent: for one comparison it uses less than, for the other it uses greater than. I find this discussion about the relative readability of not 0 <= x <= 10 #1 versus 0 < x or x > 10 #2 0 < x or 10 < x to be a good example of people's propensity to invent so-called "rational" justifications for irrational preferences. Honestly, all these people claiming that reading #1 takes them "slightly more effort" than reading #2, or vice versa. Really? You've done an objective test of this? I don't think so. We know from UI testing in other fields that people's *self-reported* efficiency and their *actual* efficiency are almost completely uncorrelated. Back in the DOS versus Macintosh days, when mice were new, DOS users consistently reported that using a mouse was too slow and inefficient compared to the keyboard, but actual objective measurements of the time that they took to do tasks showed the opposite. E.g. subjects were asked to do some task, using the keyboard and then again using the mouse, and (let's say) it actually took them 3 minutes to do it via keyboard and 2 minutes via mouse, they reported that using the keyboard commands was much more efficient, fast and easy. Whether you have #1 or either variation of #2, the time it takes to read and comprehend the expression is likely to be of the order of a few dozen milliseconds, plus or minus a few dozen milliseconds. I expect the variation will be nearly as great as the average time. (But of course, I haven't done objective studies either.) Anyone who has done high-school level maths should be familiar with the notation `0 <= x <= 10`, read as "x between 0 and 10". (Anyone who is not can hardly claim to be fluent in Python -- that's like claiming to be fluent in English while not knowing where and how to use an exclamation mark.) If you want to check for the opposite, x not between 0 and 10, the natural way to do so is with `not`: `not 0 <= x <= 10`. If you prefer `x < 0 or x > 10` for whatever reason, that's fine too. Some people prefer pizza, some prefer kebabs... inventing (spurious) arguments of (imaginary) efficiency ("It takes me half a second less time to chew each mouthful of burger compared to kebab") is unnecessary. But we do love the argument from efficiency. Frankly, as a profession, we programmers are lousy at prioritising. We write pages and pages of convoluted, inconsistent, hard to understand code that can sometimes take hours or even days to comprehend well enough to make even a minor change, while spending dozens of person-hours arguing about which expression saves them a microsecond or two of reading time. Yay us! -- Steven From bc at freeuk.com Sat Oct 3 06:48:17 2015 From: bc at freeuk.com (Bartc) Date: Sat, 3 Oct 2015 11:48:17 +0100 Subject: Check if a given value is out of certain range In-Reply-To: <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> References: <87r3le1ht3.fsf@elektro.pacujo.net> <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 03/10/2015 11:29, Steven D'Aprano wrote: > On Fri, 2 Oct 2015 07:45 am, John Gordon wrote: > I find this discussion about the relative readability of > > not 0 <= x <= 10 #1 > > versus > > 0 < x or x > 10 #2 > 0 < x or 10 < x > > to be a good example of people's propensity to invent so-called "rational" > justifications for irrational preferences. Honestly, all these people > claiming that reading #1 takes them "slightly more effort" than reading #2, > or vice versa. Really? I find #1 straightforward (although I'm bothered by the lack of parentheses as I would parse that as (not 0). Presumably, this does actually mean not (0<=x<=10).) But I spent a minute looking at #2, and I'm still not sure that it expresses the same thing. I would have written #2 as: x<0 or x>10 -- Bartc From steve at pearwood.info Sat Oct 3 07:29:38 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sat, 03 Oct 2015 21:29:38 +1000 Subject: Instance method for converting int to str - str() and __str__() References: Message-ID: <560fbc24$0$1583$c3e8da3$5496439d@news.astraweb.com> On Sat, 3 Oct 2015 04:35 pm, neubyr wrote: > I was wondering if there is any resource that explains why certain methods > like str() and type() were implemented the way they are, rather than > .to_string() or .type() instance/object methods. There is a FAQ that might help with this question: https://docs.python.org/2/faq/design.html In early Python, some objects (like ints, floats, tuples, None) had no methods at all, so you couldn't have None.to_string() and expect it to work. There was no base class for the entire object hierarchy, so no method they could inherit: every class would have to re-implement their own to_string method. But even today, when all objects have methods and all inherit from object, having functions instead of methods for some tasks makes good sense. It allows us to write functions that operate by a protocol, rather than purely by inheritance, and it helps guarantee consistent naming. For example, let's look at conversion to bool. Should that method be called .bool, .boolean, .to_bool, .truthify, ... ? Different classes that don't inherit from each other may make different choices. By having a built-in function (technically, a class, but the difference doesn't matter here) called bool, that ensures one standard way to convert to bool. How does bool() work? As a built-in function, it can (in theory) include optimizations that aren't available to a method, for example it could look like this pseudocode: def bool(obj): if obj is None: return False if obj is a number: return obj != 0 ... which may be faster than calling obj.bool() since it doesn't have to search the inheritance chain (remember that method resolution in Python happens at runtime, not compile-time). Of course, the built-in bool needs to know how to deal with custom classes that aren't built-in. For that, we have a *protocol* that tells the built-in functions how to deal with new, unknown classes. The most basic protocol is to call a specified "dunder" method. Dunder stands for: Double leading and trailing UNDERscores and refers to those methods __str__, __add__, __radd__, etc. that you so often see. All dunder names are reserved for use by Python, so you should never use them yourself, and especially never invent your own. bool() is a good example of a protocol because it is more complex than just a single method call. It looks something like this: # Python 3 version def bool(x): # possible optimizations for built-ins here... # now deal with everything else T = type(x) if hasattr(T, '__bool__'): flag = T.__bool__() if flag in (True, False): return flag else: raise TypeError elif hasattr(T, '__len__'): return T.__len__() != 0 else: return True bool(x) ignores methods defined on the instance x itself, and goes straight to the class object (saving a runtime lookup). If the dunder method does not return an actual boolean, it raises an error. And if the object doesn't define a __bool__ method, it falls back on __len__, and if it doesn't define __len__ either, it could in principle have other fallbacks, but in practice just returns a default value. (Of course, the actual built-in bool may be written in C, not Python, but that's besides the point.) So you should never call dunder methods such as __str__ yourself, always call the wrapper. Chances are very good that the function form will contain optimizations that are unavailable to you, will perform pre-processing or post-processing, catch exceptions, or error-check the result. -- Steven From steve at pearwood.info Sat Oct 3 07:39:26 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sat, 03 Oct 2015 21:39:26 +1000 Subject: Footnotes in ReST Message-ID: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> I have a document written in Restructured Text format, and I use lots of footnotes: blah blah blah [1]_ and blah blah blah [2]_. blah blah [3]_ blah ... blah blah blah blah [999]_. .. [1] fe .. [2] fi .. [3] fo ... .. [999] fum I need to add a footnote between [2] and [3], but I don't want to have to renumber the following 997 footnotes by hand. Is there something I can do, within the syntax of ReST itself, to help? -- Steven From rosuav at gmail.com Sat Oct 3 07:57:55 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 3 Oct 2015 21:57:55 +1000 Subject: Footnotes in ReST In-Reply-To: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> References: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Oct 3, 2015 at 9:39 PM, Steven D'Aprano wrote: > I need to add a footnote between [2] and [3], but I don't want to have to > renumber the following 997 footnotes by hand. Is there something I can do, > within the syntax of ReST itself, to help? Now that they're all numbered manually? Not sure. But if you know in advance you're going to have that kind of thing, there are other ways to do footnotes: https://hg.python.org/peps/file/tip/pep-0498.txt https://www.python.org/dev/peps/pep-0498/ Otherwise, I'd look at scripting the 997-footnote changes. It shouldn't be too hard to script - will probably take only twice as long as doing it manually would have... ChrisA From lac at openend.se Sat Oct 3 08:12:20 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 03 Oct 2015 14:12:20 +0200 Subject: Check if a given value is out of certain range In-Reply-To: <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> References: <87r3le1ht3.fsf@elektro.pacujo.net> <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201510031212.t93CCKnd016417@fido.openend.se> Actually, the fact that adults have more difficulty processing negations is one of the earliest things proven experimentally in experimental psychology. Clark, H., & Chase, W. (1972). On the process of comparing sentences against pictures. Cognitive Psychology, 3, 472?517. is one of the most heavily cited experiments in the field. The question is _why_? The early assumption was that the negation is conceptually more difficult. People think logically, and a negation is a harder sentence to construct. Recently, this idea has come to be questioned: see http://www.google.se/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CB0QFjAAahUKEwisvv_6lKbIAhXo8XIKHX32BKE&url=http%3A%2F%2Flangcog.stanford.edu%2Fpapers_new%2Fnordmeyer-2015-underrev.pdf&usg=AFQjCNEaPmluLtZs6aeAHgnyCCLEDazJdg which I shortened to: http://bit.ly/1OOfK46 It seems that people tend to hear what they expect to hear, and that effect overwhelms any 'this is harder to constuct logically' effect. Also, the 'mouse is quicker' experiment was rather more nuanced than you reported. It seems when measuring 'what is faster' the cognitive load is important. Time seems to go faster when you are thinking harder about something, than when you are not. (i.e. how did my coffee get cold? I just started hacking on this thing?) It seems that mouse editing was less of a cognitive load than typing, for the people studied, thus they reported that keyboard was faster, when it wasn't for them. But the experiment was replicated among secretaries who had superior typing skills (and used emacs a lot). For a lot of them, moving text by mouse was not faster than using keyboard macros. But the limiting factor seemed to be 'how hard did I have to think about it' -- if you move things by keyboard macro without thinking, then you won't report that it takes you time, and you won't accurately report how long it takes to do the task. Thus for this experiment, the conclusion was that people were a whole lot better at telling 'how hard did this make me think' than 'how long did it take me to do the job'. Also, when you changed the requirements to 'reformat text all day long' a huge number of people could get a lot more work done using emacs than using the mouse editor. We ran both of these experiemnts in the coputer graphics lab at the University of Toronto as a joint csc/psych exp in the mid 1980s, and our conclusion at the time was that, for 'all day long' sorts of tasks what was most important was boredom. Once the subject got bored with the task, it took longer. For me the experiment was wonderful for another reason. The University of Toronto has long believed that their secretaries weren't intelligent enough to use emacs, and had gone to particular effort to design an easier editor for them to use. But the secretaries of the Political Science department, who used to come down to the department of Zoology (where I worked) to use our pdp-11/44 for text formating, and me (the undergraduate they hired to help Zoologists format their graduate theses prior to having them phototypeset) for advice, once saw me fix a problem by writing an emacs macro, and hauling their document into emacs and using it. They were entranced. And wondered if I could teach them how to do it. I thought, fine enough, and so taught classes in how to use emacs to about 6 of them for 3 nights a week one summer. And it turned out that everybody, including one sweet lady whose powers of reasoning was seriously sub par, learned how to use emacs. She learned mostly by rote, but she could do it. And the first two weeks of learning how to write macros was very hard. I learned a lot about how not to teach things in that class. :) So a good bit of the problem was lack of skill in the teacher. But once we started on writing them for real life tasks they had, and not useless contrived examples I came up with, it went a lot better. And soon they were quite proficient, and Political Science had its own set of common emacs macros. I got a real understanding of how much 'retype it by hand, it is faster' you do, if your normal rate of typing is 165 wpm or more. Especially if you grew up with paper, not computers, where retyping it was considered very normal ... At any rate when I heard about this experiment I got the secretaries to compete, for fun. The secretaries with their own emacs macros beat the heck out of everybody else at 'copying and moving text around', which was, after all, something they did all of the time. The researchers thought that this wasn't a fair test, as the playing field was so far from level. The secretaries thought they could better their score if they had been given the task the night before -- as they would have designed an even better emacs macro. And, of course, if they had a lot of that particular task to do, they would have 'had Caroline write one and teach it to us', as was usual. Which got people down to the heart of the matter. People wanted to measure keyboard vs mouse efficiency, but as far as the secretaries were concerned any test done 'for fun' didn't measure up to their real lives, where getting more throughput meant 'we don't have to work overtime' and 'only one secretary works in the office Friday after 3:30 in case a professor needs something typed up in a hurry, the rest of us go home early'. They were fairly hostile to the idea of inflicting the mouse editor on the university support staff, unless it came with emacs lisp built in. And there was considerable 'when you pry my emacs away from my cold dead fingers' sentiment. These days, I suspect, the Political Science professors at U of T do their own typing. The profession of typist seems to be nearly extinct. And voice-to-text is the next big thing. But we already know that many people find talking for a long time itself unpleasant and exhausting. I like my email. I hate listening to voice messages. But, should we all live long enough, will listening to people become the only option? Laura From lac at openend.se Sat Oct 3 08:21:25 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 03 Oct 2015 14:21:25 +0200 Subject: Footnotes in ReST In-Reply-To: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> References: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201510031221.t93CLPqB017099@fido.openend.se> In a message of Sat, 03 Oct 2015 21:39:26 +1000, "Steven D'Aprano" writes: >I have a document written in Restructured Text format, and I use lots of >footnotes: > > blah blah blah [1]_ and blah blah blah [2]_. > blah blah [3]_ blah ... blah blah > blah blah [999]_. > > .. [1] fe > .. [2] fi > .. [3] fo > ... > .. [999] fum > > >I need to add a footnote between [2] and [3], but I don't want to have to >renumber the following 997 footnotes by hand. Is there something I can do, >within the syntax of ReST itself, to help? > > >-- >Steven You shouldn't have numbered them manually in the first place. Use '#' instead to get automatic numbered footnotes. http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#footnote-references Laura From steve at pearwood.info Sat Oct 3 09:51:11 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sat, 03 Oct 2015 23:51:11 +1000 Subject: Check if a given value is out of certain range References: <87r3le1ht3.fsf@elektro.pacujo.net> <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> Message-ID: <560fdd50$0$1586$c3e8da3$5496439d@news.astraweb.com> On Sat, 3 Oct 2015 10:12 pm, Laura Creighton wrote: > People think logically LOL :-) -- Steven From blake.garretson at gmail.com Sat Oct 3 10:14:42 2015 From: blake.garretson at gmail.com (Blake Garretson) Date: Sat, 3 Oct 2015 10:14:42 -0400 Subject: Footnotes in ReST In-Reply-To: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> References: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Oct 3, 2015 7:40 AM, "Steven D'Aprano" wrote: > I need to add a footnote between [2] and [3], but I don't want to have to > renumber the following 997 footnotes by hand. Is there something I can do, > within the syntax of ReST itself, to help? I would use a regular expression to find and replace all the numbers with the auto-numbering feature. So something like "\[\d+\]_" should be replaced with "\[#\]_". ### Blake T. Garretson -------------- next part -------------- An HTML attachment was scrubbed... URL: From wxjmfauth at gmail.com Sat Oct 3 10:19:30 2015 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Sat, 3 Oct 2015 07:19:30 -0700 (PDT) Subject: Check if a given value is out of certain range In-Reply-To: <560fdd50$0$1586$c3e8da3$5496439d@news.astraweb.com> References: <87r3le1ht3.fsf@elektro.pacujo.net> <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> <560fdd50$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: <619f9a84-d684-49c5-b55f-0fccc8618463@googlegroups.com> > On Sat, 3 Oct 2015 10:12 pm, Laura Creighton wrote: > > > People think logically > > When I see, Python and its Unicode implementation, I doubt. Except that in that case, it is *really* logically buggy. jmf From steve at pearwood.info Sat Oct 3 10:22:19 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 04 Oct 2015 00:22:19 +1000 Subject: Footnotes in ReST References: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: <560fe49c$0$1587$c3e8da3$5496439d@news.astraweb.com> On Sat, 3 Oct 2015 10:21 pm, Laura Creighton wrote: > In a message of Sat, 03 Oct 2015 21:39:26 +1000, "Steven D'Aprano" writes: >>I have a document written in Restructured Text format, and I use lots of >>footnotes: [...] > You shouldn't have numbered them manually in the first place. > Use '#' instead to get automatic numbered footnotes. > http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#footnote-references Thanks. Especially useful is the ability to label footnotes so that they can be auto-numbered while still being able to refer to them from multiple places: If [#note]_ is the first footnote reference, it will show up as "[1]". We can refer to it again as [#note]_ and again see "[1]". We can also refer to it as note_ (an ordinary internal hyperlink reference). .. [#note] This is the footnote labeled "note". That's the problem I was trying to solve by manual numbering. -- Steven From torriem at gmail.com Sat Oct 3 10:38:53 2015 From: torriem at gmail.com (Michael Torrie) Date: Sat, 03 Oct 2015 08:38:53 -0600 Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic In-Reply-To: <201510030919.t939Jdq6003741@fido.openend.se> References: <201510030907.t93974tU002535@fido.openend.se> <201510030919.t939Jdq6003741@fido.openend.se> Message-ID: <560FE87D.2050706@gmail.com> On 10/03/2015 03:19 AM, Laura Creighton wrote: > With better searching, I find this bug. > https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345 > > Looks like that's the real one. This ubuntu bug and the other bug you mention seem to be about FTDI devices. Rob said in his original post that the problem occurs with a real UART serial port as well, and also the prolific USB chipset. From voxner.dev at gmail.com Sat Oct 3 11:07:01 2015 From: voxner.dev at gmail.com (voxner.dev at gmail.com) Date: Sat, 3 Oct 2015 08:07:01 -0700 (PDT) Subject: python and ARM memory types Message-ID: <62e78153-8a84-4b78-8881-8a891df0d496@googlegroups.com> I am running python in the ARM architecture (arm64 to be exact). The CPU Arch I use has clusters (2 big cores in a cluster and 2 small cores in another cluster think : A57, A53). It's going to be run in Ubuntu 14.04 I am trying to run traffic that stresses the interconnects of the clusters. One example is dekker's algorithm : pin first process to 1 cluster and another process to another cluster and check the algo (using multiprocessing library). Also I am also trying to run "streaming" traffic - the kind of traffic that you don't want in the cache because it is non-temporal. But how do I specify (streaming,write-combining,write-back) memory types in python ? Is there a library that I can use ? I am thinking of programming some fixed memory space (say 0x1000_000 - 0x2000_000) as "WC or WT or streaming" using the OS and then try to use the mmap facility in python. What set of libraries can I use ? Where should I start ? Fixed memories are discouraged so what kind of alternatives I can use ? Thanks, Vox From torriem at gmail.com Sat Oct 3 11:40:55 2015 From: torriem at gmail.com (Michael Torrie) Date: Sat, 03 Oct 2015 09:40:55 -0600 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) In-Reply-To: References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: <560FF707.1010000@gmail.com> On 10/02/2015 02:23 PM, Kenneth L wrote: > No don't tell me what to do. I joined the military 3 years ago. You > wouldn't believe the stuff I wasn't able to do before but now I am. > You can keep your advice to yourself. I wasn't asking for something > simple. I was asking for a starting point. The 3d was to show you > I've learned hard stuff and it didn't scare me. I was building web > pages when I was in grade school late 90s. I had no idea how to build > an iPhone app but I created one, lol. > > I want to build a graphics program or even a prototype. Maybe I can > pass it over to a expert and hire then to build it. I have a dozen > degree and certificates on my wall. And I didn't get that by going > basic. Keep your advice Bartc. No one is insulting your intelligence, so there's no need to get snippy. It's easy to take offense in an environment like this as things sound much harsher in our own heads than they were likely intended. The reason that you're not getting the responses you want is because what you are asking for involves so many different things it's hard to know how to respond. I have no doubt you may be able to do much of what you want, but it will take a lot of time and a lot of googling of various things. Sounds like you need to search for information concerning: - Python programming in general (tutorials, mini courses, etc) - GUI programming in Python. There are many options here including tkinter, PyQt (or PySide), PyGObject (GTK+ 3.x), and also Kivy. - Vector drawing libraries (PyQt has support, Cairo is another library, maybe a python-based svg library) - bitmap graphics engine of some kind, probably GEGL, which has Python bindings - linear algebra I'm sure you can learn all this, but you aren't going to be able to come here and simply ask about how to put everything together: there's no turn-key solution we can point you to. Fire up your browser and start learning about each of these things. Take heart, though. One man created this all by himself using the C# language: http://www.getpaint.net/index.html Tearing down the GIMP is an excellent idea, though that will also be very daunting. GIMP is a huge program, written in C. On the subject of GIMP, I find it interesting you dismissed it out of hand. GIMP is certainly deficient in many areas, but to say you can't use it because it's so different from Photoshop strikes me as, well, a cop out. Photoshop is intuitive because you learned it. As you are fond of talking about how much you enjoy learning, so learn how to use the GIMP, and as Laura said, hack on it using Python to make add-ons. From lac at openend.se Sat Oct 3 12:23:14 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 03 Oct 2015 18:23:14 +0200 Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic In-Reply-To: <560FE87D.2050706@gmail.com> References: <201510030907.t93974tU002535@fido.openend.se> <201510030919.t939Jdq6003741@fido.openend.se> <560FE87D.2050706@gmail.com> Message-ID: <201510031623.t93GNEcH002438@fido.openend.se> In a message of Sat, 03 Oct 2015 08:38:53 -0600, Michael Torrie writes: >On 10/03/2015 03:19 AM, Laura Creighton wrote: >> With better searching, I find this bug. >> https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345 >> >> Looks like that's the real one. > >This ubuntu bug and the other bug you mention seem to be about FTDI >devices. Rob said in his original post that the problem occurs with a >real UART serial port as well, and also the prolific USB chipset. > >-- >https://mail.python.org/mailman/listinfo/python-list https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345 seems to be about a whole lot of serial ports to me, not just FTDI Laura From ronjc.2001 at gmail.com Sat Oct 3 13:40:57 2015 From: ronjc.2001 at gmail.com (Ronald Cosentino) Date: Sat, 3 Oct 2015 10:40:57 -0700 (PDT) Subject: function code snippet that has function calls I have never seen before. How does it work. Message-ID: def funA(x,y,z): return (x+y) * z def funB(x,y): return(x-y) print(funA(4,funB(2,3), funB(3,2))) the answer is 3. I don't know how it works. From joel.goldstick at gmail.com Sat Oct 3 14:01:21 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Sat, 3 Oct 2015 14:01:21 -0400 Subject: function code snippet that has function calls I have never seen before. How does it work. In-Reply-To: References: Message-ID: On Sat, Oct 3, 2015 at 1:40 PM, Ronald Cosentino wrote: > def funA(x,y,z): > return (x+y) * z > The above takes 3 values and returns a value > def funB(x,y): > return(x-y) > The above takes 2 values and returns a value > print(funA(4,funB(2,3), funB(3,2))) > you are printing the result of funA, to which you are passing 4, the value returned by funB(2,3) and the value returned by funB(3,2) So, print(funA(4, -1, 1)) Which is 4 + -1 * 1 Which is 3 * 1 > > the answer is 3. I don't know how it works. > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From joseph.lee22590 at gmail.com Sat Oct 3 14:03:07 2015 From: joseph.lee22590 at gmail.com (Joseph Lee) Date: Sat, 3 Oct 2015 11:03:07 -0700 Subject: function code snippet that has function calls I have never seen before. How does it work. In-Reply-To: References: Message-ID: <000b01d0fe05$c25eaae0$471c00a0$@gmail.com> Hi Ronald, Answers inline. -----Original Message----- From: Python-list [mailto:python-list-bounces+joseph.lee22590=gmail.com at python.org] On Behalf Of Ronald Cosentino Sent: Saturday, October 3, 2015 10:41 AM To: python-list at python.org Subject: function code snippet that has function calls I have never seen before. How does it work. def funA(x,y,z): return (x+y) * z def funB(x,y): return(x-y) print(funA(4,funB(2,3), funB(3,2))) the answer is 3. I don't know how it works. JL: Okay, let's step through the print routine. 1. Before print does its job, the function result will be gathered. 2. The argument to print is result of funA, which itself takes result of two calls to FunB. 3. First, results of funB calls will be gathered (subtracting 3 from 2 and 2 from 3, respectively). So it becomes: print(funA(4, (2-3), (3-2))) 4. Then funA will continue to perform its job, returning the result for output. Thus the final expression that print will print is: print((4+-1) * 1) When looking at a function that takes result of another function, it is important to look at what the inner callee does (in this case, look at what funB does first). Cheers, Joseph -- https://mail.python.org/mailman/listinfo/python-list From airween at gmail.com Sat Oct 3 14:09:43 2015 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Sat, 3 Oct 2015 20:09:43 +0200 Subject: function code snippet that has function calls I have never seen before. How does it work. In-Reply-To: References: Message-ID: <20151003180943.GA11459@arxnet.hu> hi, On Sat, Oct 03, 2015 at 10:40:57AM -0700, Ronald Cosentino wrote: > def funA(x,y,z): > return (x+y) * z > def funB(x,y): > return(x-y) > print(funA(4,funB(2,3), funB(3,2))) > > the answer is 3. I don't know how it works. it's simple: - there is a "composition of functions", generally f(g()) (function in argument list of another function) - first, Python evaulates the arguments first, from left to right - in this point, you'll get -1 for 2nd arg, and 1 for 3rd arg - then your funcA() will be called with these arguents: 4, -1, 1 - funcA() calculates this: (x+y)*z, in this case (4+(-1))*1 which is 3... a. -- I ? UTF-8 From denismfmcmahon at gmail.com Sat Oct 3 15:59:07 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Sat, 3 Oct 2015 19:59:07 +0000 (UTC) Subject: function code snippet that has function calls I have never seen before. How does it work. References: Message-ID: On Sat, 03 Oct 2015 10:40:57 -0700, Ronald Cosentino wrote: > def funA(x,y,z): > return (x+y) * z > def funB(x,y): > return(x-y) > print(funA(4,funB(2,3), funB(3,2))) > > the answer is 3. I don't know how it works. def funA(x, y, z): return (x+y) * z def funB(x, y): return (x-y) # this line # print(funA(4,funB(2,3), funB(3,2))) # can be written as the following 4 lines: a = funB(2, 3) # 2 - 3 -> -1 b = funB(3, 2) # 3 - 2 -> 1 c = funA(4, a, b) # (4 + -1) * 1 -> 3 print(c) # 3 -- Denis McMahon, denismfmcmahon at gmail.com From __peter__ at web.de Sun Oct 4 05:50:24 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 04 Oct 2015 11:50:24 +0200 Subject: Footnotes in ReST References: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: Blake Garretson wrote: > On Oct 3, 2015 7:40 AM, "Steven D'Aprano" wrote: >> I need to add a footnote between [2] and [3], but I don't want to have to >> renumber the following 997 footnotes by hand. Is there something I can >> do, within the syntax of ReST itself, to help? > > I would use a regular expression to find and replace all the numbers with > the auto-numbering feature. So something like "\[\d+\]_" should be > replaced with "\[#\]_". With labeled autonumbers: >>> text = """\ ... blah blah blah [1]_ and blah blah blah [2]_. ... blah blah [3]_ blah ... blah blah ... blah blah [999]_. ... ... .. [1] fe ... .. [2] fi ... .. [3] fo ... ... ... .. [999] fum ... """ >>> print(re.compile(r"\[(\d+)\]").sub(r"[#n\1]", text)) blah blah blah [#n1]_ and blah blah blah [#n2]_. blah blah [#n3]_ blah ... blah blah blah blah [#n999]_. .. [#n1] fe .. [#n2] fi .. [#n3] fo ... .. [#n999] fum Changing numbers to make room for a new footnote is not much harder (but less convenient as you have to repeat it for every new footnote): >>> def replace(match, n=2): ... index = int(match.group(1)) ... if index >= n: ... index += 1 ... return "[{}]".format(index) ... >>> print(re.compile(r"\[(\d+)\]").sub(replace, text)) blah blah blah [1]_ and blah blah blah [3]_. blah blah [4]_ blah ... blah blah blah blah [1000]_. .. [1] fe .. [3] fi .. [4] fo ... .. [1000] fum From __peter__ at web.de Sun Oct 4 06:14:16 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 04 Oct 2015 12:14:16 +0200 Subject: Footnotes in ReST References: <560fbe70$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: Peter Otten wrote: > Changing numbers to make room for a new footnote is not much harder (but > less convenient as you have to repeat it for every new footnote): > >>>> def replace(match, n=2): > ... index = int(match.group(1)) > ... if index >= n: > ... index += 1 > ... return "[{}]".format(index) > ... >>>> print(re.compile(r"\[(\d+)\]").sub(replace, text)) > blah blah blah [1]_ and blah blah blah [3]_. > blah blah [4]_ blah ... blah blah > blah blah [1000]_. > > .. [1] fe > .. [3] fi > .. [4] fo > ... > .. [1000] fum Those who remember the old basic dialects might [1]_ like $ cat insert_footnote_basic.py #!/usr/bin/env python3 import re import sys def step(start, delta): n = start while True: yield n n += delta def insert_footnote(text): lookup = {} steps = step(10, 10) def replace(match): index = int(match.group(1)) try: new_index = lookup[index] except KeyError: new_index = lookup[index] = next(steps) return "[{}]".format(new_index) return re.compile(r"\[(\d+)\]").sub(replace, text) if __name__ == "__main__": sys.stdout.write( insert_footnote(sys.stdin.read()) ) $ cat sample.rst blah blah blah [10]_ and blah blah blah [20]_. [21] this is new blah blah [30]_ blah ... blah blah blah blah [9990]_. .. [10] fe .. [20] fi .. [21] yes it is .. [30] fo ... .. [9990] fum $ ./insert_footnote_basic.py < sample.rst blah blah blah [10]_ and blah blah blah [20]_. [30] this is new blah blah [40]_ blah ... blah blah blah blah [50]_. .. [10] fe .. [20] fi .. [30] yes it is .. [40] fo ... .. [50] fum $ .. [1] or run away screaming ;) From marko at pacujo.net Sun Oct 4 07:40:33 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 04 Oct 2015 14:40:33 +0300 Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> Message-ID: <87d1wuzwsu.fsf@elektro.pacujo.net> Grant Edwards : > Holy Cow. > > I'd like to build something just like the Brooklyn Bridge, only with > more lanes. Failed grandiose attempts make you into a better software developer. Successful grandiose attempts even more so! Always playing it safe condemns you to mediocrity. Not that mediocrity is all that bad a place to be. Marko From steve at pearwood.info Sun Oct 4 09:42:31 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 05 Oct 2015 00:42:31 +1100 Subject: function code snippet that has function calls I have never seen before. How does it work. References: Message-ID: <56112cc8$0$1597$c3e8da3$5496439d@news.astraweb.com> On Sun, 4 Oct 2015 04:40 am, Ronald Cosentino wrote: > def funA(x,y,z): > return (x+y) * z > def funB(x,y): > return(x-y) > print(funA(4,funB(2,3), funB(3,2))) > > the answer is 3. I don't know how it works. Break it up and consider it a little at a time, starting with the three values given to funA: * calculate 4 (too easy, it's already done) * calculate funB(2, 3) => funB(2, 3) returns 2-3, which gives -1 * calculate funB(3,2) => funB(3, 2) returns 3-2, which gives 1 Then pass those three values to the funA function: * calculate funA(4, -1, 1) => which returns (4 + -1)*1, which gives 3 and finally pass that value to print: * print(3) which prints 3. -- Steven From steve at pearwood.info Sun Oct 4 09:47:57 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 05 Oct 2015 00:47:57 +1100 Subject: Check if a given value is out of certain range References: <87r3le1ht3.fsf@elektro.pacujo.net> <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> Message-ID: <56112e0e$0$1604$c3e8da3$5496439d@news.astraweb.com> On Sat, 3 Oct 2015 10:12 pm, Laura Creighton wrote: > Actually, the fact that adults have more difficulty processing > negations is one of the earliest things proven experimentally > in experimental psychology. I don't think I've questioned that under some circumstances some negations can be hard to understand. I've certainly written my share of code involving negatives that I've had to refactor to understand. A typical example: def function(arg, dontpreprocess=False): """Perform function on arg. If dontpreprocess is not true, arg is preprocessed.""" if not dontpreprocess: arg = preprocess(arg) ... And of course there are the legendary chains of negations: don't not cancel the preprocessor suppressor Does the preprocess run or not? :-) But I don't think we can jump from a general observation about negations to the conclusion that a logical disjunction of two different comparisons is necessarily easier to understand than a negated chained comparison. Some negations are easy to understand: Don't touch that! and some negations may technically be harder to understand, but in a practical sense the difference may be negligible: if x == 1: ... if x != 1: ... I refuse to believe that the second is *significantly* harder to reason about than the first. [...] > It seems that people tend to hear what they expect to hear, and that > effect overwhelms any 'this is harder to constuct logically' effect. I can certainly believe that. It explains a class of errors: "I'll have the cheese and salad sandwich, no butter, no salt or pepper." "Okay." [proceeds to make sandwich with butter, salt and pepper] I've had that happen to me more times than I can remember. People only listen with half an ear, especially if they're tired, distracted, emotional, bored, busy, or breathing. > Also, the 'mouse is quicker' experiment was rather more nuanced than > you reported. It seems when measuring 'what is faster' the cognitive > load is important. Time seems to go faster when you are thinking > harder about something, than when you are not. (i.e. how did my > coffee get cold? I just started hacking on this thing?) It seems > that mouse editing was less of a cognitive load than typing, for > the people studied, thus they reported that keyboard was faster, > when it wasn't for them. Thanks for the anecdote, it was fascinating. My point was not so much about the advantage (if any) of mouse over keyboard, which I'm sure will depend on a multitude of factors, but of people's ability to judge their own efficiency, which I maintain is often not very good. -- Steven From invalid at invalid.invalid Sun Oct 4 10:15:35 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 4 Oct 2015 14:15:35 +0000 (UTC) Subject: Newbie: Designer Looking to Build Graphics Editor (PS/AI) References: <54286f19-7859-4e30-a9de-ef1b85c23670@googlegroups.com> <87d1wuzwsu.fsf@elektro.pacujo.net> Message-ID: On 2015-10-04, Marko Rauhamaa wrote: > Grant Edwards : > >> Holy Cow. >> >> I'd like to build something just like the Brooklyn Bridge, only with >> more lanes. > > Failed grandiose attempts make you into a better software developer. > > Successful grandiose attempts even more so! > > Always playing it safe condemns you to mediocrity. Not that > mediocrity is all that bad a place to be. Just pointing out that it _is_ a grandiose attempt... If the OP still wants to undertake such a huge task, then I applaud him. It just struck me as amusing they he asked "how do I do it" about such a huge project... -- Grant From c.buhtz at posteo.jp Sun Oct 4 10:36:21 2015 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Sun, 4 Oct 2015 16:36:21 +0200 Subject: doc-generation tool Message-ID: <3nTSLL1kfbz5vNF@dovecot03.posteo.de> I am confused about to much possible tools and conventions for doc-strings and the doc-generating tools using it. My code isn't about a package interface. It is just a simple application I want I readable documentation for. I have the following needs - in-code doc-string should be readable for humans (e.g. reStructuredText, markup) - type of a methode-argument or class-attribute can be specified - no seperation between class-doc-string and class-attribute-doc-strings. the attribute should be described in the class-doc-string itself I read a lot about Doxygen and Sphinx but not sure which one of it I should concentrate on. And maybe there are other/better/easier solutions for Python code? -- -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1 mQENBFQIluABCACfPwAhRAwFD3NXgv5CtVUGSiqdfJGVViVBqaKd+14E0pASA0MU G0Ewj7O7cGy/ZIoiZ0+lIEZmzJKHfuGwYhXjR/PhnUDrQIHLBvh9WuD6JQuULXfH kXtVm/i9wm76QAcvr2pwYgNzhcJntUHl2GcgnInYbZDeVmg+p9yIPJjuq73/lRS3 0/McgNoFOBhKK/S6STQuFyjr9OyJyYd1shoM3hmy+kg0HYm6OgQBJNg92WV9jwGe GzlipvEp2jpLwVsTxYir2oOPhfd9D1fC9F/l/3gXbfjd5GIIVrZFq2haZmoVeJ33 LJxo3RA5Tf9LoUeels1b4s9kFz6h7+AHERUpABEBAAG0IUNocmlzdGlhbiBCdWh0 eiA8YnVodHpAcG9zdGVvLmRlPokBPgQTAQIAKAUCVAiW4AIbAwUJAeEzgAYLCQgH AwIGFQgCCQoLBBYCAwECHgECF4AACgkQZLsXsAdRqOxNUAf/V/hDA5zGDpySuCEj DhjiVRK74J9Wd8gfH0WAf1Co5HZ24wZH8rgOIVIgXw8rWkOw/VA6xfdfT+64xjTY Fhkpbrk199nDzp72F7Jc4NC+x8xac2e3rK5ifSWhZx7L5A32pGYE+d16m3EEqImK D4gcZl38x9zdUnD4hHyXkIPz1uCfuMuGgWEnaUk4Wbj41CBZr3O0ABue6regV15U jaes8r+B8iCcY+0yP2kse+3iaCaMqNv5FgQZ9+b2Cql8pFkZJVtBVUw4GW3DWZJi du0O/YrC9TgS+xY9ht/MD2qSHwjcK1sdImjqBO7xP8TIOwKeYyDvGKnSO3EJ/sSA UPGEPrkBDQRUCJbgAQgA0k/Qg67CCUJE2/zuxBEoK4wLJpDRJzh8CQPZpjWx8VP0 KL892jwfxymXn8KNhuy1SgCBFSeV9jg4VZNWDlUGJc2lo82ajr9PzIsrQwu4lf0B zrUWV5hWepKu/kb8uSjx58YYfx0SFz4+9akX3Wwu9TUHntzL5Gk3Q26nnsr1xEJ+ VEumvCH9AE0Tk0K7dQpJ2/JcLuO+uhrpd/lHFDYVN5NsG3P015uFOkDI6N/xNFCj v95XNR93QlfKpK3qWlFGescfG+o/7Ub6s67/i/JoNbw0XgPEHmQfXpD7IHO4cu+p +ETb11cz+1mmi96cy98ID+uTiToJ8G//yD9rmtyxoQARAQABiQElBBgBAgAPBQJU CJbgAhsMBQkB4TOAAAoJEGS7F7AHUajs6sQH/iKs6sPc0vkRJLfbwrijZeecwCWF blo/jzIQ8jPykAj9SLjV20Xwqg3XcJyko8ZU6/zuRJq9xjlv9pZr/oVudQAt6v+h 2Cf4rKEjmau483wjMV2xjTXQhZi9+ttDbia4fgdmGtKsOicn5ae2fFXcXNPu3RiW sZKifWdokA6xqMW6iIG9YjjI5ShxngHWp2xfPscBFMDRtFOMags/Yx+YvwoyEZ4A dURYMFHFqpwILEc8hIzhRg1gq40AHbOaEdczS1Rr3T7/gS6eBs4u6HuY5g2Bierm lLjpspFPjMXwJAa/XLOBjMF2vsHPrZNcouNKkumQ36yq/Pm6DFXAseQDxOk= =PGP9 -----END PGP PUBLIC KEY BLOCK----- From ned at nedbatchelder.com Sun Oct 4 11:39:41 2015 From: ned at nedbatchelder.com (Ned Batchelder) Date: Sun, 4 Oct 2015 08:39:41 -0700 (PDT) Subject: Neil Gaiman mentions Python Message-ID: <9e2ad02e-1c4c-4c04-bacd-8fbe0898ce7e@googlegroups.com> The Moth is a podcast of people telling stories. Many of them are really good. In a recent story, Neil Gaiman talks about his relationship with his dad, and along the way, Python makes a (very brief) appearance: http://themoth.org/posts/stories/a-fathers-pride --Ned. From rustompmody at gmail.com Sun Oct 4 22:28:15 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 4 Oct 2015 19:28:15 -0700 (PDT) Subject: Check if a given value is out of certain range In-Reply-To: <56112e0e$0$1604$c3e8da3$5496439d@news.astraweb.com> References: <87r3le1ht3.fsf@elektro.pacujo.net> <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> <56112e0e$0$1604$c3e8da3$5496439d@news.astraweb.com> Message-ID: <83b66c5c-25fe-48dd-b71c-5091803a1500@googlegroups.com> On Sunday, October 4, 2015 at 7:18:11 PM UTC+5:30, Steven D'Aprano wrote: > On Sat, 3 Oct 2015 10:12 pm, Laura Creighton wrote: > > > Actually, the fact that adults have more difficulty processing > > negations is one of the earliest things proven experimentally > > in experimental psychology. > > I don't think I've questioned that under some circumstances some negations > can be hard to understand. I've certainly written my share of code > involving negatives that I've had to refactor to understand. A typical > example: > > def function(arg, dontpreprocess=False): > """Perform function on arg. If dontpreprocess is not true, > arg is preprocessed.""" > if not dontpreprocess: > arg = preprocess(arg) > ... > > And of course there are the legendary chains of negations: > > don't not cancel the preprocessor suppressor > > Does the preprocess run or not? :-) > > But I don't think we can jump from a general observation about negations to > the conclusion that a logical disjunction of two different comparisons is > necessarily easier to understand than a negated chained comparison. Some > negations are easy to understand: > > Don't touch that! > > and some negations may technically be harder to understand, but in a > practical sense the difference may be negligible: > > if x == 1: ... > > if x != 1: ... > > > I refuse to believe that the second is *significantly* harder to reason > about than the first. [With hermeneutic/semantic hat firmly on] one could make a case that "!=" ? "not =" ? "?" [Back with python hat] My preference: not 1 <= x <= 10 From rustompmody at gmail.com Sun Oct 4 22:32:55 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 4 Oct 2015 19:32:55 -0700 (PDT) Subject: Check if a given value is out of certain range In-Reply-To: <83b66c5c-25fe-48dd-b71c-5091803a1500@googlegroups.com> References: <87r3le1ht3.fsf@elektro.pacujo.net> <560fadf3$0$1610$c3e8da3$5496439d@news.astraweb.com> <56112e0e$0$1604$c3e8da3$5496439d@news.astraweb.com> <83b66c5c-25fe-48dd-b71c-5091803a1500@googlegroups.com> Message-ID: On Monday, October 5, 2015 at 7:58:34 AM UTC+5:30, Rustom Mody wrote: > On Sunday, October 4, 2015 at 7:18:11 PM UTC+5:30, Steven D'Aprano wrote: > > and some negations may technically be harder to understand, but in a > > practical sense the difference may be negligible: > > > > if x == 1: ... > > > > if x != 1: ... > > > > > > I refuse to believe that the second is *significantly* harder to reason > > about than the first. > > [With hermeneutic/semantic hat firmly on] > one could make a case that > "!=" ? "not =" ? "?" > [Back with python hat] > My preference: > not 1 <= x <= 10 I take that back: Unarys binding looser than binaries is "yuck" (in my book) SO it would have to be not (1 <= x <= 10) From harirammanohar159 at gmail.com Mon Oct 5 00:01:28 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Sun, 4 Oct 2015 21:01:28 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <3a9b7eee-f02e-4dd5-a1ec-074c0fd913f7@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. Hi Paul, subprocess is used to spawn a new process with in the machine.. my requirement is completely different... From harirammanohar159 at gmail.com Mon Oct 5 00:06:29 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Sun, 4 Oct 2015 21:06:29 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <27c50868-37f7-44f9-b81e-ecf85bcdd5b6@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. Hi Laura, yes this is what i require and i don't need more than this. how can i fork a pxssh session ? can i do like this ? os.fork(pxssh.pxssh()), but how can i capture the session variable ?? whereas fork returns child id and pid.. Thanks... From dieter at handshake.de Mon Oct 5 03:01:50 2015 From: dieter at handshake.de (dieter) Date: Mon, 05 Oct 2015 09:01:50 +0200 Subject: python and ARM memory types References: <62e78153-8a84-4b78-8881-8a891df0d496@googlegroups.com> Message-ID: <87r3l9u7c1.fsf@handshake.de> voxner.dev at gmail.com writes: > ... > But how do I specify (streaming,write-combining,write-back) memory types in python ? Is there a library that I can use ? I am thinking of programming some fixed memory space (say 0x1000_000 - 0x2000_000) as "WC or WT or streaming" using the OS and then try to use the mmap facility in python. Python is quite a high level programming language - i.e. lots of things are out of direct control of the programmer - among others memory management. I suppose you will need an approach that gives you more control over memory use - maybe, write your algorithms partially in the "C" programming language. You might find "cython" helpful to easily combine Python parts and "C" parts. "cython" is a compiler that compiles a source (which can use a subset of Python and a subset of "C") into a "C" source file which is then processed like a typical "C" source. It takes care of a lot of the difficulties at the Python-C interface and, thus, greatly facilitates combining Python and "C" parts. > What set of libraries can I use ? Where should I start ? Fixed memories are discouraged so what kind of alternatives I can use ? Note that modern operating systems virtualize memory. You will need a lot of tricks to be able to use a specific range of physical memory in "user level" processes -- but hopefully, you do not need to control thing of the "physical memory level". From motoom at xs4all.nl Mon Oct 5 04:18:29 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Mon, 5 Oct 2015 10:18:29 +0200 Subject: Check if a given value is out of certain range In-Reply-To: References: Message-ID: Why not use a function? if outside(x, 0, 10): print("x has wrong value") else: print("x has good value") where 'outside' is defined as: def outside(value, lowerbound, upperbound): return value < lowerbound or value > upperbound Greetings, From hemla21 at gmail.com Mon Oct 5 04:18:33 2015 From: hemla21 at gmail.com (Hedieh Ebrahimi) Date: Mon, 5 Oct 2015 01:18:33 -0700 (PDT) Subject: PySide window does not resize to fit screen In-Reply-To: References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> Message-ID: Hi Chris, Thanks for your answer. I get your point now. Unfortunately there are not layouts in my user interface. Smaller widget have been grouped using group boxes and then all these group boxes are put on the central widget. I would like to recreate my user interface using one of the designer software that exist. Could you recommend any free designer software that I can create my user interface with? Thank you From breamoreboy at yahoo.co.uk Mon Oct 5 05:19:56 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 5 Oct 2015 10:19:56 +0100 Subject: Check if a given value is out of certain range In-Reply-To: References: Message-ID: On 05/10/2015 09:18, Michiel Overtoom wrote: > > Why not use a function? > > > if outside(x, 0, 10): > print("x has wrong value") > else: > print("x has good value") > > > where 'outside' is defined as: > > def outside(value, lowerbound, upperbound): > return value < lowerbound or value > upperbound > > Greetings, > Please wash your mouth out with soap, burn precious clock cycles just to make code readable, never I say :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From harvesting at makes.email.invalid Mon Oct 5 06:08:33 2015 From: harvesting at makes.email.invalid (Jussi Piitulainen) Date: Mon, 05 Oct 2015 13:08:33 +0300 Subject: Check if a given value is out of certain range References: Message-ID: Michiel Overtoom writes: > Why not use a function? > > > if outside(x, 0, 10): > print("x has wrong value") > else: > print("x has good value") > > > where 'outside' is defined as: > > def outside(value, lowerbound, upperbound): > return value < lowerbound or value > upperbound Wouldn't that be more readable as:? def outside(value, lowerbound, upperbound): return not (lowerbound <= value <= upperbound) Just wondering ... From harirammanohar159 at gmail.com Mon Oct 5 06:13:52 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Mon, 5 Oct 2015 03:13:52 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. Hi All, I am able to achieve it using multiprocessing package... Thanks. From lac at openend.se Mon Oct 5 06:51:12 2015 From: lac at openend.se (Laura Creighton) Date: Mon, 05 Oct 2015 12:51:12 +0200 Subject: PySide window does not resize to fit screen In-Reply-To: References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> Message-ID: <201510051051.t95ApCEB028374@fido.openend.se> In a message of Mon, 05 Oct 2015 01:18:33 -0700, Hedieh Ebrahimi writes: >Could you recommend any free designer software that I can create my user interface with? > >Thank you Qt Designer works with PySide. http://doc.qt.io/qt-5/designer-quick-start.html Laura From hemla21 at gmail.com Mon Oct 5 07:20:22 2015 From: hemla21 at gmail.com (Hedieh Ebrahimi) Date: Mon, 5 Oct 2015 04:20:22 -0700 (PDT) Subject: PySide window does not resize to fit screen In-Reply-To: References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> Message-ID: is this free to use for commercial use? From marko at pacujo.net Mon Oct 5 07:42:41 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 05 Oct 2015 14:42:41 +0300 Subject: Check if a given value is out of certain range References: Message-ID: <87si5pv8we.fsf@elektro.pacujo.net> Jussi Piitulainen : > Michiel Overtoom writes: > >> Why not use a function? >> >> >> if outside(x, 0, 10): >> print("x has wrong value") >> else: >> print("x has good value") >> >> >> where 'outside' is defined as: >> >> def outside(value, lowerbound, upperbound): >> return value < lowerbound or value > upperbound > > Wouldn't that be more readable as:? > > def outside(value, lowerbound, upperbound): > return not (lowerbound <= value <= upperbound) Why not use a fricking class framework: class Endpoint: def __init__(self, value): self.value = value class IncludedEndpoint(Endpoint): def above(self, x): return x > self.value def below(self, x): return x < self.value class ExcludedEndpoint(Endpoint): def above(self, x): return x >= self.value def below(self, x): return x <= self.value class Range: def __init__(self, lower_bound, upper_bound): self.lower_bound = lower_bound self.upper_bound = upper_bound def outside(self, x): return self.lower_bound.below(x) or self.upper_bound.above(x) def inside(self, x): return not self.outside(x) Then, we could simply have: if Range(IncludedEndpoint(0), IncludedEndpoint(10)).outside(x): print("x has wrong value") else: print("x has good value") Just for the sake of readability, I mean... Marko From rosuav at gmail.com Mon Oct 5 09:10:00 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 6 Oct 2015 00:10:00 +1100 Subject: Check if a given value is out of certain range In-Reply-To: <87si5pv8we.fsf@elektro.pacujo.net> References: <87si5pv8we.fsf@elektro.pacujo.net> Message-ID: On Mon, Oct 5, 2015 at 10:42 PM, Marko Rauhamaa wrote: > Why not use a fricking class framework: > > Then, we could simply have: > > if Range(IncludedEndpoint(0), IncludedEndpoint(10)).outside(x): > print("x has wrong value") > else: > print("x has good value") > > Just for the sake of readability, I mean... Hold on a moment! You can't seriously be contemplating instantiating those classes directly, can you?!? You need to go through the ThreadedRangeFactory, passing it a couple of EndpointFactory subclasses to suggest which kinds of endpoints to employ, and finally use operator overloading to wait for the factory thread to finish its work. *THEN* you can use this Range object. ChrisA has just been reading http://thedailywtf.com/articles/eins-zwei-zuffa From marko at pacujo.net Mon Oct 5 09:25:35 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 05 Oct 2015 16:25:35 +0300 Subject: Check if a given value is out of certain range References: <87si5pv8we.fsf@elektro.pacujo.net> Message-ID: <87oagdv44w.fsf@elektro.pacujo.net> Chris Angelico : > On Mon, Oct 5, 2015 at 10:42 PM, Marko Rauhamaa wrote: >> Why not use a fricking class framework: >> >> Then, we could simply have: >> >> if Range(IncludedEndpoint(0), IncludedEndpoint(10)).outside(x): >> print("x has wrong value") >> else: >> print("x has good value") >> >> Just for the sake of readability, I mean... > > Hold on a moment! You can't seriously be contemplating instantiating > those classes directly, can you?!? You need to go through the > ThreadedRangeFactory, passing it a couple of EndpointFactory > subclasses to suggest which kinds of endpoints to employ, and finally > use operator overloading to wait for the factory thread to finish its > work. *THEN* you can use this Range object. > > ChrisA > has just been reading http://thedailywtf.com/articles/eins-zwei-zuffa Pointing out flaws in my code is totally unprofessional. Marko From chalao.adda at gmail.com Mon Oct 5 09:29:03 2015 From: chalao.adda at gmail.com (Jaydip Chakrabarty) Date: Mon, 5 Oct 2015 13:29:03 +0000 (UTC) Subject: Finding Blank Columns in CSV Message-ID: Hello, I have a csv file like this. Name,Surname,Age,Sex abc,def,,M ,ghi,,F jkl,mno,, pqr,,,F I want to find out the blank columns, that is, fields where all the values are blank. Here is my python code. fn = "tmp1.csv" fin = open(fn, 'rb') rdr = csv.DictReader(fin, delimiter=',') data = list(rdr) flds = rdr.fieldnames fin.close() mt = [] flag = 0 for i in range(len(flds)): for row in data: if len(row[flds[i]]): flag = 0 break else: flag = 1 if flag: mt.append(flds[i]) flag = 0 print mt I need to know if there is better way to code this. Thanks. From kwpolska at gmail.com Mon Oct 5 09:32:33 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Mon, 5 Oct 2015 15:32:33 +0200 Subject: PySide window does not resize to fit screen In-Reply-To: References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> Message-ID: On 5 October 2015 at 13:20, Hedieh Ebrahimi wrote: > is this free to use for commercial use? > -- > https://mail.python.org/mailman/listinfo/python-list Yeah, you can use Qt Designer to create a nice layout and the pyside-uic tool to generate code (that you will need to clean up later). -- Chris Warrick PGP: 5EAAEA16 From rosuav at gmail.com Mon Oct 5 09:48:51 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 6 Oct 2015 00:48:51 +1100 Subject: Finding Blank Columns in CSV In-Reply-To: References: Message-ID: On Tue, Oct 6, 2015 at 12:29 AM, Jaydip Chakrabarty wrote: > I want to find out the blank columns, that is, fields where all the > values are blank. Here is my python code. > > fn = "tmp1.csv" > fin = open(fn, 'rb') > rdr = csv.DictReader(fin, delimiter=',') > data = list(rdr) > flds = rdr.fieldnames > fin.close() > mt = [] > flag = 0 > for i in range(len(flds)): > for row in data: > if len(row[flds[i]]): > flag = 0 > break > else: > flag = 1 > if flag: > mt.append(flds[i]) > flag = 0 > print mt > > I need to know if there is better way to code this. > You could do it with a single iteration, something like this: fn = "tmp1.csv" fin = open(fn, 'rb') rdr = csv.DictReader(fin, delimiter=',') # all the same down to here blanks = set(rdr.fieldnames) for row in data: blanks = {col for col in blanks if not row[col]} mt = [col for col in rdr.fieldnames if col not in blanks] print mt From rosuav at gmail.com Mon Oct 5 09:51:51 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 6 Oct 2015 00:51:51 +1100 Subject: Finding Blank Columns in CSV In-Reply-To: References: Message-ID: On Tue, Oct 6, 2015 at 12:48 AM, Chris Angelico wrote: > fn = "tmp1.csv" > fin = open(fn, 'rb') > rdr = csv.DictReader(fin, delimiter=',') > # all the same down to here > blanks = set(rdr.fieldnames) > for row in data: > blanks = {col for col in blanks if not row[col]} > mt = [col for col in rdr.fieldnames if col not in blanks] > print mt Oops, premature send - hadn't proofread it yet. fn = "tmp1.csv" fin = open(fn, 'rb') rdr = csv.DictReader(fin, delimiter=',') # all the same down to here blanks = set(rdr.fieldnames) for row in rdr: blanks = {col for col in blanks if not row[col]} mt = [col for col in rdr.fieldnames if col not in blanks] print mt Though I still haven't tested it, so there may be other bugs. Broadly speaking, though, what it does is quite simple: start by assuming that every column is nothing but blanks, and then any time you find a non-blank cell, remove it from the set of blanks. At the end, all field names not present in the set of blanks are non-blanks. ChrisA From random832 at fastmail.com Mon Oct 5 10:00:34 2015 From: random832 at fastmail.com (Random832) Date: Mon, 05 Oct 2015 10:00:34 -0400 Subject: Finding Blank Columns in CSV In-Reply-To: References: Message-ID: <1444053634.1646396.401625385.6F8DC34C@webmail.messagingengine.com> On Mon, Oct 5, 2015, at 09:29, Jaydip Chakrabarty wrote: > Hello, > > I have a csv file like this. > > Name,Surname,Age,Sex > abc,def,,M > ,ghi,,F > jkl,mno,, > pqr,,,F > > I want to find out the blank columns, that is, fields where all the > values are blank. Here is my python code. > > fn = "tmp1.csv" > fin = open(fn, 'rb') > rdr = csv.DictReader(fin, delimiter=',') > data = list(rdr) > flds = rdr.fieldnames > fin.close() > mt = [] > flag = 0 > for i in range(len(flds)): > for row in data: > if len(row[flds[i]]): > flag = 0 > break > else: > flag = 1 > if flag: > mt.append(flds[i]) > flag = 0 > print mt > > I need to know if there is better way to code this. Well, for one thing, you should just be using something like "for fld in flds" rather than range(len(...)). There's also an opportunity to use list/generator comprehensions instead of explicit loops - your whole loop could be written as: mt = [fld for fld in flds if not any(row[fld] for row in data)] It might be more efficient to iterate over rows first than columns, depending on your data (if you have a large number of rows, consider that you're reading them all into memory at the start) This would be more complex code, though, and more difficult to write as a comprehension, so if your data isn't ideal for it it might not be worth doing. From python.list at tim.thechases.com Mon Oct 5 10:06:52 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 5 Oct 2015 09:06:52 -0500 Subject: Finding Blank Columns in CSV In-Reply-To: References: Message-ID: <20151005090652.1c9faed7@bigbox.christie.dr> On 2015-10-06 00:51, Chris Angelico wrote: > fn = "tmp1.csv" > fin = open(fn, 'rb') > rdr = csv.DictReader(fin, delimiter=',') > # all the same down to here > blanks = set(rdr.fieldnames) > for row in rdr: > blanks = {col for col in blanks if not row[col]} > mt = [col for col in rdr.fieldnames if col not in blanks] > print mt My only other modification would be to add a check that, if you no longer have any blank columns, bail early from the loop: from cStringIO import StringIO import csv s = StringIO("""Name,Surname,Age,Sex abc,def,,M ,ghi,,F jkl,mno,, pqr,,,F """) dr = csv.DictReader(s) header_set = set(dr.fieldnames) for row in dr: header_set = set(h for h in header_set if not row[h]) if not header_set: # we no longer have any headers, bail early break ordered_headers = [h for h in dr.fieldnames if h in header_set] print(header_set) print(ordered_headers) That way, if you determine by line 3 that your million-row CSV file has no blank columns, you can get away with not processing all million rows. -tkc From skip.montanaro at gmail.com Mon Oct 5 10:14:00 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Mon, 5 Oct 2015 09:14:00 -0500 Subject: Parsing HTML with xml.etree in Python 2.7? Message-ID: Back before Fredrik Lundh's elementtree module was sucked into the Python stdlib as xml.etree, I used to use his elementtidy extension module to clean up HTML source so it could be parsed into an ElementTree object. Elementtidy hasn't be updated in about ten years, and still assumes there is a module named "elementtree" which it can import. I wouldn't be surprised if there were some small API changes other than the name change caused by the move into the xml package. Before I dive into a rabbit hole and start to modify elementtidy, is there some other stdlib-only way to parse HTML code into an xml.etree.ElementTree? Thx, Skip -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Oct 5 10:34:17 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 6 Oct 2015 01:34:17 +1100 Subject: Finding Blank Columns in CSV In-Reply-To: <20151005090652.1c9faed7@bigbox.christie.dr> References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase wrote: > That way, if you determine by line 3 that your million-row CSV file > has no blank columns, you can get away with not processing all > million rows. Sure, although that effectively means the entire job is moot. I kinda assume that the OP knows that there are some blank columns (maybe lots of them). The extra check is unnecessary unless it's actually plausible that there'll be no blanks whatsoever. Incidentally, you have an ordered_headers list which is the blank columns in order; I think the OP was looking for a list of the _non_blank columns. But that's a trivial difference, easy to tweak. ChrisA From skip.montanaro at gmail.com Mon Oct 5 11:15:04 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Mon, 5 Oct 2015 10:15:04 -0500 Subject: Parsing HTML with xml.etree in Python 2.7? In-Reply-To: References: Message-ID: On Mon, Oct 5, 2015 at 9:14 AM, Skip Montanaro wrote: > I wouldn't be surprised if there were some small API changes other than the > name change caused by the move into the xml package. Before I dive into a > rabbit hole and start to modify elementtidy, is there some other stdlib-only > way to parse HTML code into an xml.etree.ElementTree? Never mind. The only change necessary turned out to be the import. /F writes robust code. :-) Skip From josef.pktd at gmail.com Mon Oct 5 11:55:07 2015 From: josef.pktd at gmail.com (Josef Pktd) Date: Mon, 5 Oct 2015 08:55:07 -0700 (PDT) Subject: Pyarmor, guard your python scripts In-Reply-To: References: <42f12eba-2504-4a97-a5bc-e7b9bfe2f1f9@googlegroups.com> <22dc806f-f3f4-4e5d-a939-5ecc5e4bf946@googlegroups.com> <74f43ca8-fc25-4622-8f18-784b71f781af@googlegroups.com> <63bd6da4-50ad-4b0c-bff7-5b5d26d161b3@googlegroups.com> Message-ID: <95a3b4d2-82b7-406a-99dd-4d130b0a3ccd@googlegroups.com> related https://youtu.be/wsczq6j3_bA?t=20m9s Josef From torriem at gmail.com Mon Oct 5 12:28:36 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 05 Oct 2015 10:28:36 -0600 Subject: PySide window does not resize to fit screen In-Reply-To: References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> Message-ID: <5612A534.8020907@gmail.com> On 10/05/2015 05:20 AM, Hedieh Ebrahimi wrote: > is this free to use for commercial use? Yes of course. There's also the newer Qt Creator program if you want to use Qt 5. The license of the Designer and Creator programs does not apply to the output of these programs (the .ui XML files). You'll want to read up on the documentation. Here's a couple of links for starters: http://doc.qt.io/qt-4.8/designer-layouts.html https://wiki.qt.io/QtCreator_and_PySide (works with .ui files from Designer also) Even if you don't use a GUI designer, you should construct your GUI with layout managers so that your interfaces can adjust and look good on a variety of screen sizes and DPI. It's pretty simple once you wrap your brain around the idea. Another method of working with .ui files it to load them at runtime: https://srinikom.github.io/pyside-docs/PySide/QtUiTools/QUiLoader.html From rgaddi at technologyhighland.invalid Mon Oct 5 12:34:29 2015 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Mon, 5 Oct 2015 16:34:29 +0000 (UTC) Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic References: <201510030907.t93974tU002535@fido.openend.se> Message-ID: On Sat, 03 Oct 2015 11:12:28 +0200, Laura Creighton wrote: > In a message of Sat, 03 Oct 2015 11:07:04 +0200, Laura Creighton writes: >>In a message of Fri, 02 Oct 2015 22:36:23 -0000, Rob Gaddi writes: >>>So, this is odd. I'm running Ubuntu 14.04, and my system did a kernel >>>upgrade from the repository from 3.13.0-63-generic to >>>3.13.0-65-generic. And pyserial (2.7, installed through pip) stopped >>>working. >>> >>>Specifically, when I make read() calls on a Serial object, I get the >>>error >>> >>>serial.serialutil.SerialException: device reports readiness to read but >>>returned no data (device disconnected?) >>> >>>This comes from the PosixSerial.read() method in serialposix.py, and >>>seems to be a result of the select.select call screwing up. >>> >>>I reboot under 3.13.0-63-generic. My code works. I reboot under >>>3.13.0-65-generic. My code doesn't. Implication would seem to be that >>>somehow between these kernel versions, the select() logic in the serial >>>driver changed. This happens regardless of whether the serial port is >>>real, FTDI USB-UART, or Prolific USB-UART. >>> >>>Can anyone else confirm? Also, who do I try to report this one to? >>> >>>Thanks, >>>Rob >>> >>>-- >>>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 >> >>I think you have this bug >>https://bugs.launchpad.net/ubuntu/+source/linux/+bug/460857 >> >>or rather, you like the behaviour that ubuntu thinks is buggy, which >>never got fixed, and don't like that it changed to be what ubuntu thinks >>is correct in .65. >> >>I'd talk to the pyserial issue tracker as the people there ought to be >>well aware of this problem, and then see if talking to ubuntu is the >>right thing to do. >> >>Laura -- >>https://mail.python.org/mailman/listinfo/python-list > > I think I said that poorly. > > What I think happened is that ubuntu made some changes to fix this > problem, and along the way they managed to break things for you, > and maybe all pyserial users. But I would talk to the pyserial people > about that. > > Laura I'm not sure poorly as much as "could have offended someone who hasn't been caught by these sorts of issues before". I took it as meant, that one person's bug is another's fix, rather than as "Your bug report is stupid and you should feel bad and never Python again." And thanks for the find on https://bugs.launchpad.net/ubuntu/+source/ linux-lts-trusty/+bug/1501345. That is PRECISELY what I should have been able to find. I'll make only the excuse that it was late Friday with me having to run for the airport and I wanted to at least flag it as an issue before I hit the door. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From cameronbell45 at gmail.com Mon Oct 5 14:06:04 2015 From: cameronbell45 at gmail.com (=?utf-8?Q?Cameroni123_=E2=84=A2?=) Date: Mon, 5 Oct 2015 19:06:04 +0100 Subject: Trouble running Message-ID: <5612bc0d.2772c20a.271c4.24a5@mx.google.com> Hi I have recently installed python on windows 10 and I?m trying to save in order to run the module and I cant I don?t know why, could you please help? Cameron Sent from Mail for Windows 10 -------------- next part -------------- An HTML attachment was scrubbed... URL: From wxjmfauth at gmail.com Mon Oct 5 14:28:12 2015 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Mon, 5 Oct 2015 11:28:12 -0700 (PDT) Subject: PySide window does not resize to fit screen In-Reply-To: References: <24851466-7de1-408f-a0a0-548d42d21ab4@googlegroups.com> <0536254e-4101-4b7c-a848-61a5c3e1a064@googlegroups.com> Message-ID: <2a082305-37a7-4801-96cb-288696060896@googlegroups.com> Le lundi 5 octobre 2015 12:51:31 UTC+2, Laura Creighton a ?crit?: > In a message of Mon, 05 Oct 2015 01:18:33 -0700, Hedieh Ebrahimi writes: > >Could you recommend any free designer software that I can create my user interface with? > > > >Thank you > > Qt Designer works with PySide. > http://doc.qt.io/qt-5/designer-quick-start.html > > Laura And PySide does not work properly with Python 3.3+. From jtim.arnold at gmail.com Mon Oct 5 15:43:38 2015 From: jtim.arnold at gmail.com (Tim) Date: Mon, 5 Oct 2015 12:43:38 -0700 (PDT) Subject: packaging code with compiled libraries Message-ID: <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com> I have a package I want to share but have a question about packaging. Mostly the package is pure python code, but it also requires some binary libraries (*.so, *.dll, *.dylib). I want to bundle these libs so users don't have to compile. The package will run on *nix/windows/mac platforms. Currently I handle this in setup.py. In the 'build' phase, I copy the platform-specific libs to a subdirectory called 'libs'. class MyBuilder(build_py): def run(self): conditional logic for copying appropriate library files to 'libs' etc etc. build_py.run() And that seems to work, but after reading more from the Python Packaging Authority, I wonder if that is the right way. Should I be using wheels instead? I think my brain fried a little bit while going through the doc. thanks, --Tim From sohcahtoa82 at gmail.com Mon Oct 5 15:44:07 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Mon, 5 Oct 2015 12:44:07 -0700 (PDT) Subject: Pyarmor, guard your python scripts In-Reply-To: <6f60b49d-4621-4ea7-a50a-a07fe1b1dc58@googlegroups.com> References: <42f12eba-2504-4a97-a5bc-e7b9bfe2f1f9@googlegroups.com> <6978ab18-6154-4f62-9e97-0cd5c921015e@googlegroups.com> <6f60b49d-4621-4ea7-a50a-a07fe1b1dc58@googlegroups.com> Message-ID: <3e4cd5ae-4387-40f7-a70f-c2e0c1c5ad3d@googlegroups.com> On Thursday, September 17, 2015 at 10:55:19 PM UTC-7, Jondy Zhao wrote: > On Friday, September 18, 2015 at 11:06:25 AM UTC+8, Ben Finney wrote: > > Jondy Zhao writes: > > > > > For example, I develop a game by python. What I want to do is that the > > > player or the agent could not simply copy the game to others. For the > > > player or the agent, they needn't research the game. > > > > Deciding for the customer what they may not do, on their own computer, > > is quite hostile. Please don't enable such restrictions. > > > > This is only one possible way to distribute encrypted scripts. As I thought the user of Pyarmor would be the producer of commercial software, so they could bind their license file to netcard, harddisk, cpu, etc. > > > -- > > \ "We must find our way to a time when faith, without evidence, | > > `\ disgraces anyone who would claim it." --Sam Harris, _The End of | > > _o__) Faith_, 2004 | > > Ben Finney DRM does not prevent piracy. End of story. The only thing DRM does is piss off your legitimate users by forcing them to jump through hoops if they happen to upgrade or replace their computer. From anthra.norell at bluewin.ch Mon Oct 5 16:08:33 2015 From: anthra.norell at bluewin.ch (Friedrich Rentsch) Date: Mon, 5 Oct 2015 22:08:33 +0200 Subject: Finding Blank Columns in CSV In-Reply-To: References: Message-ID: <5612D8C1.6030302@bluewin.ch> On 10/05/2015 03:29 PM, Jaydip Chakrabarty wrote: > Hello, > > I have a csv file like this. > > Name,Surname,Age,Sex > abc,def,,M > ,ghi,,F > jkl,mno,, > pqr,,,F > > I want to find out the blank columns, that is, fields where all the > values are blank. Here is my python code. > > fn = "tmp1.csv" > fin = open(fn, 'rb') > rdr = csv.DictReader(fin, delimiter=',') > data = list(rdr) > flds = rdr.fieldnames > fin.close() > mt = [] > flag = 0 > for i in range(len(flds)): > for row in data: > if len(row[flds[i]]): > flag = 0 > break > else: > flag = 1 > if flag: > mt.append(flds[i]) > flag = 0 > print mt > > I need to know if there is better way to code this. > > Thanks. > Operations on columns are often simpler, if a table is rotated beforehand. Columns become lists. def find_empty_columns (table): number_of_records = len (table) rotated_table = zip (*table) indices_of_empty_columns = [] for i in range (len (rotated_table)): # Column indices if rotated_table[i].count ('') == number_of_records: indices_of_empty_columns.append (i) return indices_of_empty_columns Frederic From denismfmcmahon at gmail.com Mon Oct 5 16:56:52 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Mon, 5 Oct 2015 20:56:52 +0000 (UTC) Subject: Finding Blank Columns in CSV References: Message-ID: On Mon, 05 Oct 2015 13:29:03 +0000, Jaydip Chakrabarty wrote: > Hello, > > I have a csv file like this. > > Name,Surname,Age,Sex abc,def,,M ,ghi,,F jkl,mno,, > pqr,,,F > > I want to find out the blank columns, that is, fields where all the > values are blank. Here is my python code. > > fn = "tmp1.csv" > fin = open(fn, 'rb') > rdr = csv.DictReader(fin, delimiter=',') > data = list(rdr) > flds = rdr.fieldnames fin.close() > mt = [] > flag = 0 for i in range(len(flds)): > for row in data: > if len(row[flds[i]]): > flag = 0 break > else: > flag = 1 > if flag: > mt.append(flds[i]) flag = 0 > print mt > > I need to know if there is better way to code this. > > Thanks. Assuming all the records have the same number of fields: I'd create a list of flags of length numfields, all set to 0 then for each record, I*d set flag[n] = 1 if field[n] has content then I'd check if I still have any 0 flags, and if I do, process the next record As soon as I have no 0 flags, I can stop processing records, as this means I have no empty columns. It might be more efficient if, when checking a record, I only tested the fields for which flag was still 0. Example (untested) flags = [False for x in rdr.fieldnames] for row in data: blanks = False for i in range(len(flags)): if not flags[i]: if len(row[i]) == 0: flags[i] = True else: blanks = True if not blanks: break -- Denis McMahon, denismfmcmahon at gmail.com From larry.martell at gmail.com Mon Oct 5 18:11:33 2015 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 5 Oct 2015 18:11:33 -0400 Subject: threading bug in strptime Message-ID: We have been trying to figure out an intermittent problem where a thread would fail with this: AttributeError: 'module' object has no attribute '_strptime' Even though we were importing datetime. After much banging our heads against the wall, we found this: http://code-trick.com/python-bug-attribute-error-_strptime/ The workaround suggested there, to call strptime before starting your threads, seems to have fixed the issue. I thought I'd mention it here in case anyone else is facing this. From ben+python at benfinney.id.au Mon Oct 5 18:25:25 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 06 Oct 2015 09:25:25 +1100 Subject: Pyarmor, guard your python scripts References: <42f12eba-2504-4a97-a5bc-e7b9bfe2f1f9@googlegroups.com> <22dc806f-f3f4-4e5d-a939-5ecc5e4bf946@googlegroups.com> <74f43ca8-fc25-4622-8f18-784b71f781af@googlegroups.com> <63bd6da4-50ad-4b0c-bff7-5b5d26d161b3@googlegroups.com> <95a3b4d2-82b7-406a-99dd-4d130b0a3ccd@googlegroups.com> Message-ID: <85si5p0x7u.fsf@benfinney.id.au> Josef Pktd writes: > related Care to give us a summary of what that is, and describe what you think is the relevant point? -- \ ?The best way to get information on Usenet is not to ask a | `\ question, but to post the wrong information.? ?Aahz | _o__) | Ben Finney From rustompmody at gmail.com Mon Oct 5 22:42:31 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Mon, 5 Oct 2015 19:42:31 -0700 (PDT) Subject: packaging code with compiled libraries In-Reply-To: <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com> References: <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com> Message-ID: On Tuesday, October 6, 2015 at 1:14:05 AM UTC+5:30, Tim wrote: > And that seems to work, but after reading more from the Python Packaging > Authority, I wonder if that is the right way. Should I be using wheels instead? > I think my brain fried a little bit while going through the doc. You are not alone https://mail.python.org/pipermail/python-list/2015-July/694818.html [last para] From harirammanohar159 at gmail.com Mon Oct 5 23:22:57 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Mon, 5 Oct 2015 20:22:57 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <25fb0dc7-8c94-451e-ba3b-dce17bfde6b3@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. Hi, issue in implementing multiprocessing with pxssh, its working fine with normal operations but with pxssh its throwing error as below: ========= multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 44, in mapstar return list(map(*args)) File "./rmcomments.py", line 12, in xcute s = pxssh.pxssh() File "/usr/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/pxssh.py", line 91, in __init__ spawn.__init__(self, None, timeout=timeout, maxread=maxread, searchwindowsize=searchwindowsize, logfile=logfile, cwd=cwd, env=env) File "/usr/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py", line 493, in __init__ fd = sys.__stdin__.fileno() ValueError: I/O operation on closed file """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./rmcomments.py", line 23, in output = p.map(xcute, [(srvrs) for srvrs in serverslist]) File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 260, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 599, in get raise self._value ValueError: I/O operation on closed file ====== Below is the code: ------------------------ serverslist = ['server1','server2'] username = 'user1' password = 'password1' def xcute(srvrs): s = pxssh.pxssh() s.login (srvrs, username, password) ---do stuff--- s.sendline('logout') np = len(serverslist) p = multiprocessing.Pool(np) output = p.map(xcute, [(srvrs) for srvrs in serverslist]) can any one help me out!!!!! Thanks From ian.g.kelly at gmail.com Mon Oct 5 23:27:37 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 5 Oct 2015 21:27:37 -0600 Subject: Pyarmor, guard your python scripts In-Reply-To: <85si5p0x7u.fsf@benfinney.id.au> References: <42f12eba-2504-4a97-a5bc-e7b9bfe2f1f9@googlegroups.com> <22dc806f-f3f4-4e5d-a939-5ecc5e4bf946@googlegroups.com> <74f43ca8-fc25-4622-8f18-784b71f781af@googlegroups.com> <63bd6da4-50ad-4b0c-bff7-5b5d26d161b3@googlegroups.com> <95a3b4d2-82b7-406a-99dd-4d130b0a3ccd@googlegroups.com> <85si5p0x7u.fsf@benfinney.id.au> Message-ID: On Oct 5, 2015 4:27 PM, "Ben Finney" wrote: > > Josef Pktd writes: > > > related > > Care to give us a summary of what that is, and describe what you think > is the relevant point? Following the link reveals it to be the video of a talk on Python exe compilation from PyCon 2014. If you're worried about the safety of the link, know that youtu.be is the official URL shortener for YouTube and only leads to YouTube videos. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Oct 6 03:16:56 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 6 Oct 2015 08:16:56 +0100 Subject: packaging code with compiled libraries In-Reply-To: <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com> References: <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com> Message-ID: <56137568.90900@timgolden.me.uk> On 05/10/2015 20:43, Tim wrote: > I have a package I want to share but have a question about packaging. > > Mostly the package is pure python code, but it also requires some binary libraries (*.so, *.dll, *.dylib). I want to bundle these libs so users don't have to compile. The package will run on *nix/windows/mac platforms. > > Currently I handle this in setup.py. In the 'build' phase, I copy the platform-specific libs to a subdirectory called 'libs'. > > class MyBuilder(build_py): > def run(self): > conditional logic for copying > appropriate library files to 'libs' > etc etc. > build_py.run() > > And that seems to work, but after reading more from the Python Packaging Authority, I wonder if that is the right way. Should I be using wheels instead? > I think my brain fried a little bit while going through the doc. I suggest you ask on distutils-sig which is where the PPA guys tend to hang out. https://mail.python.org/mailman/listinfo/distutils-sig TJG From ben+python at benfinney.id.au Tue Oct 6 03:21:36 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 06 Oct 2015 18:21:36 +1100 Subject: doc-generation tool References: <3nTSLL1kfbz5vNF@dovecot03.posteo.de> Message-ID: <85k2r01myn.fsf@benfinney.id.au> writes: > I am confused about to much possible tools and conventions for > doc-strings and the doc-generating tools using it. Thank you for taking seriously the job of documenting your software! > My code isn't about a package interface. It is just a simple > application I want I readable documentation for. I am confused; maybe you can help me. You say that you *don't* want documentation for ?a package interface?, by which I think you mean the interface a programmer needs to use your code . So I think for ?a simple application I want readable documentation for?, I think you are explicitly asking for documentation to be read primarily by the (non-programmer) *users* of the application. > I have the following needs > - in-code doc-string should be readable for humans (e.g. > reStructuredText, markup) > - type of a methode-argument or class-attribute can be specified > - no seperation between class-doc-string and > class-attribute-doc-strings. the attribute should be described in > the class-doc-string itself That is all related to the documentation of very fine-grained parts of your code; exactly the kind of documentation that is useful for a programmer needing API documentation. Your list, above, is *not* what I would expect for an application's (non-programmer) end-user documentation. Which is it? Do you want to produce API documentation, or end-user documentation? -- \ ?I still have my Christmas Tree. I looked at it today. Sure | `\ enough, I couldn't see any forests.? ?Steven Wright | _o__) | Ben Finney From kenneth.gomez at gmail.com Tue Oct 6 03:29:09 2015 From: kenneth.gomez at gmail.com (kennethg) Date: Tue, 6 Oct 2015 00:29:09 -0700 (PDT) Subject: Trouble running In-Reply-To: References: Message-ID: <18363e9a-f5f4-439c-96b6-56d86f528d50@googlegroups.com> On Tuesday, 6 October 2015 15:09:54 UTC+8, Cameroni123 (tm) wrote: > Hi I have recently installed python on windows 10 and I'm trying to save in order to run the module and I cant I don't know why, could you please help? > Cameron > > Sent from Mail for Windows 10 I presume you wrote your code in a text editor? Or in IDLE? If in IDLE, you will need to click on File-new File and then write you code in the window that pops up. Hit on File-Save to save the file. The click on the Run-Run Module or press F5. This would execute your code within IDLE. Hope this helps. Regards, Kenneth. From tom at limepepper.co.uk Tue Oct 6 03:37:28 2015 From: tom at limepepper.co.uk (Tom Hodder) Date: Tue, 6 Oct 2015 08:37:28 +0100 Subject: Downloading Python In-Reply-To: <522AFBF4-F03B-4D20-B6EF-24AB9CD5C7E0@gmail.com> References: <522AFBF4-F03B-4D20-B6EF-24AB9CD5C7E0@gmail.com> Message-ID: Hi Sharon, > Sharon MOrine wrote: > I am new to programming and the website is confusing and my eyesight isn't that great. Welcome to Python! Announcement mailing lists, like this one, are typically used by python package maintainers to publicize the availability of new versions of their software. You could consider it much like a Tannoy system, it is loud, everyone can hear it, but it is not used very often. If you are a total beginner, then I would recommend starting with; Python For Beginners , really there is no substitute for ploughing through the introductory documentation. > Can you please tell me how to download python 3.4.2 (or .3)? There is a guide to downloading python in the wiki, Downloading Python -------------- next part -------------- An HTML attachment was scrubbed... URL: From moagstar at gmail.com Tue Oct 6 04:15:09 2015 From: moagstar at gmail.com (Daniel Bradburn) Date: Tue, 6 Oct 2015 10:15:09 +0200 Subject: Downloading Python In-Reply-To: <522AFBF4-F03B-4D20-B6EF-24AB9CD5C7E0@gmail.com> References: <522AFBF4-F03B-4D20-B6EF-24AB9CD5C7E0@gmail.com> Message-ID: Hi Sharon, Here are the links for the Python 3.4.2 downloads: https://www.python.org/downloads/release/python-342/#download Regards 2015-10-06 6:49 GMT+02:00 Sharon MOrine : > Hello: > Can you please tell me how to download python 3.4.2 (or .3)? I am new to > programming and the website is confusing and my eyesight isn't that great. > Thanks! > -- > https://mail.python.org/mailman/listinfo/python-announce-list > > Support the Python Software Foundation: > http://www.python.org/psf/donations/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From harirammanohar159 at gmail.com Tue Oct 6 05:09:51 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Tue, 6 Oct 2015 02:09:51 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <2e9d10ba-57cf-4c10-bd02-91ca010c3941@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. Hi, Anyone suggest... From grahn+nntp at snipabacken.se Tue Oct 6 05:11:53 2015 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 6 Oct 2015 09:11:53 GMT Subject: python and ARM memory types References: <62e78153-8a84-4b78-8881-8a891df0d496@googlegroups.com> Message-ID: On Mon, 2015-10-05, dieter wrote: > voxner.dev at gmail.com writes: >> ... >> But how do I specify (streaming,write-combining,write-back) memory >> types in python ? Is there a library that I can use ? I am thinking of >> programming some fixed memory space [...] > > Python is quite a high level programming language - i.e. lots of things > are out of direct control of the programmer - among others memory management. > > I suppose you will need an approach that gives you more control over > memory use - maybe, write your algorithms partially in the "C" programming > language. C or C++ would work. He may want to check the assembly code that's generated too. > You might find "cython" helpful to easily combine Python parts > and "C" parts. In this case I doubt that involving Python will be helpful at all ... There won't be a lot for it to do: all the interesting stuff will happen at the level close to the hardware. There's tweaking the parameters for the benchmark, but that could be just command-line options. He may also want to instrument his programs using valgrind, time(1), oprofile and perf(1), and I guess the Python interpreter would introduce some noise there. /Jorgen -- // Jorgen Grahn O o . From lac at openend.se Tue Oct 6 05:38:20 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 06 Oct 2015 11:38:20 +0200 Subject: python and ARM memory types In-Reply-To: References: <62e78153-8a84-4b78-8881-8a891df0d496@googlegroups.com> Message-ID: <201510060938.t969cKri030566@fido.openend.se> It is not clear to me if any of the tools that come with volutility are going to be of any use, but I figure it is worth a look, at any rate. https://github.com/volatilityfoundation/volatility I seem to have replied directly, at any rate I mentioned this yesterday but don't see it in the mailing list archives. Laura From oscar.j.benjamin at gmail.com Tue Oct 6 05:50:39 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Tue, 6 Oct 2015 10:50:39 +0100 Subject: packaging code with compiled libraries In-Reply-To: <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com> References: <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com> Message-ID: On 5 October 2015 at 20:43, Tim wrote: > > I have a package I want to share but have a question about packaging. > > Mostly the package is pure python code, but it also requires some binary libraries (*.so, *.dll, *.dylib). I want to bundle these libs so users don't have to compile. The package will run on *nix/windows/mac platforms. > > Currently I handle this in setup.py. In the 'build' phase, I copy the platform-specific libs to a subdirectory called 'libs'. > > class MyBuilder(build_py): > def run(self): > conditional logic for copying > appropriate library files to 'libs' > etc etc. > build_py.run() > > And that seems to work, but after reading more from the Python Packaging Authority, I wonder if that is the right way. Should I be using wheels instead? > I think my brain fried a little bit while going through the doc. The idea of a wheel is that you want to distribute your code fully precompiled to end users who will be able to install it without needing any C compilers etc. Of course this requires you to supply wheels for each platform of interest. If this is what you want to do then yes absolutely use wheels. Note that if you have installed setuptools and wheel and you use setuptools in your setup.py then building a wheel is as simple as running "python setup.py bdist_wheel" (once your setup.py is complete). If the binary libraries in question are extension modules then you should just declare them as such in your setup.py and distutils/setuptools/wheel will take care of bundling them into the wheel. If the binary libraries are not extension modules and you are building them separately (not using distutils) then you can declare them as "datafiles" [1] so that they will be bundled into your wheel and installed alongside your python code. [1] https://packaging.python.org/en/latest/distributing/#package-data -- Oscar From ben+python at benfinney.id.au Tue Oct 6 05:51:51 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 06 Oct 2015 20:51:51 +1100 Subject: Python 2 =?utf-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode Message-ID: <851td81g08.fsf@benfinney.id.au> Howdy all, In Python 2.7, I am seeing this behaviour for ?print?:: Python 2.7.10 (default, Sep 13 2015, 20:30:50) [GCC 5.2.1 20150911] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from __future__ import unicode_literals >>> from __future__ import print_function >>> import io >>> print(None) None >>> print(None, file=io.StringIO()) Traceback (most recent call last): File "", line 1, in TypeError: unicode argument expected, got 'str' So, although my string literals are now Unicode objects, apparently ?print? still coerces objects using the bytes type ?str?. Binding the ?str? name to the Unicode type doesn't help:: >>> str = unicode >>> print(None, file=io.StringIO()) Traceback (most recent call last): File "", line 1, in TypeError: unicode argument expected, got 'str' The reason I need to do this is that I'm replacing the standard streams (?sys.stderr?, etc.) with ?io.StringIO? instances in a test suite. That works great for everything but ?print?. Since this is a test suite for existing code, I don't have the option to change all the existing statements; I need them to work as-is. How can I convince ?print?, everywhere throughout a module, that it should coerce its arguments using ?unicode?? -- \ ?Not using Microsoft products is like being a non-smoker 40 or | `\ 50 years ago: You can choose not to smoke, yourself, but it's | _o__) hard to avoid second-hand smoke.? ?Michael Tiemann | Ben Finney From ben+python at benfinney.id.au Tue Oct 6 06:45:03 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 06 Oct 2015 21:45:03 +1100 Subject: Python 2 =?utf-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode References: <851td81g08.fsf@benfinney.id.au> Message-ID: <85wpv0z368.fsf@benfinney.id.au> Ben Finney writes: > In Python 2.7, I am seeing this behaviour for ?print?:: > > Python 2.7.10 (default, Sep 13 2015, 20:30:50) > [GCC 5.2.1 20150911] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> from __future__ import unicode_literals > >>> from __future__ import print_function > >>> import io > >>> print(None) > None > >>> print(None, file=io.StringIO()) > Traceback (most recent call last): > File "", line 1, in > TypeError: unicode argument expected, got 'str' > > So, although my string literals are now Unicode objects, apparently > ?print? still coerces objects using the bytes type ?str?. To eliminate ?from __future__ import print_function? as a possible factor, here is another demonstration without that:: Python 2.7.10 (default, Sep 13 2015, 20:30:50) [GCC 5.2.1 20150911] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from __future__ import unicode_literals >>> import sys >>> import io >>> print "foo" foo >>> print None None >>> sys.stdout = io.StringIO() >>> print "foo" Traceback (most recent call last): File "", line 1, in TypeError: unicode argument expected, got 'str' >>> print None Traceback (most recent call last): File "", line 1, in TypeError: unicode argument expected, got 'str' So it appears that even a string literal, which is explicitly Unicode by the above ?from __future__ import unicode_literals?, is still being coerced to a bytes ?str? object by ?print?. How can I convince ?print?, everywhere throughout a module, that it should coerce its arguments using ?unicode?? -- \ ?Pity the meek, for they shall inherit the earth.? ?Donald | `\ Robert Perry Marquis | _o__) | Ben Finney From chalao.adda at gmail.com Tue Oct 6 07:24:33 2015 From: chalao.adda at gmail.com (Jaydip Chakrabarty) Date: Tue, 6 Oct 2015 11:24:33 +0000 (UTC) Subject: Finding Blank Columns in CSV References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote: > On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase > wrote: >> That way, if you determine by line 3 that your million-row CSV file has >> no blank columns, you can get away with not processing all million >> rows. > > Sure, although that effectively means the entire job is moot. I kinda > assume that the OP knows that there are some blank columns (maybe lots > of them). The extra check is unnecessary unless it's actually plausible > that there'll be no blanks whatsoever. > > Incidentally, you have an ordered_headers list which is the blank > columns in order; I think the OP was looking for a list of the > _non_blank columns. But that's a trivial difference, easy to tweak. > > ChrisA Thanks to you all. I got it this far. But while writing back to another csv file, I got this error - "ValueError: dict contains fields not in fieldnames: None". Here is my code. rdr = csv.DictReader(fin, delimiter=',') header_set = set(rdr.fieldnames) for r in rdr: header_set = set(h for h in header_set if not r[h]) if not header_set: break for r in rdr: data = list(r[i] for i in header_set) dw = csv.DictWriter(fout, header_set) dw.writeheader() dw.writerows(data) Also, there is difference between len(header_set) and len(data[0].keys). Why is so? Thanks again for all your help. Thanks. From fabiofz at gmail.com Tue Oct 6 07:59:37 2015 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Tue, 6 Oct 2015 08:59:37 -0300 Subject: PyDev 4.4.0 Released Message-ID: Release Highlights: ------------------------------- * Improved PyDev Package Explorer to give more information when all elements are filtered. * Code completion improvements: when a parameter is typed in the docstring, assigning it to an instance gives proper code-completion results when accessing the instance. * Fixed issues dealing with ansi colors in the interactive console. * When autopep8 is applied as the code formatting engine, the region selected is used to specify the lines for formatting. * Minor improvements in the debugger. 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 __peter__ at web.de Tue Oct 6 08:33:51 2015 From: __peter__ at web.de (Peter Otten) Date: Tue, 06 Oct 2015 14:33:51 +0200 Subject: Finding Blank Columns in CSV References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: Jaydip Chakrabarty wrote: > On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote: > >> On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase >> wrote: >>> That way, if you determine by line 3 that your million-row CSV file has >>> no blank columns, you can get away with not processing all million >>> rows. >> >> Sure, although that effectively means the entire job is moot. I kinda >> assume that the OP knows that there are some blank columns (maybe lots >> of them). The extra check is unnecessary unless it's actually plausible >> that there'll be no blanks whatsoever. >> >> Incidentally, you have an ordered_headers list which is the blank >> columns in order; I think the OP was looking for a list of the >> _non_blank columns. But that's a trivial difference, easy to tweak. >> >> ChrisA > > Thanks to you all. I got it this far. But while writing back to another > csv file, I got this error - "ValueError: dict contains fields not in > fieldnames: None". Here is my code. > > rdr = csv.DictReader(fin, delimiter=',') > header_set = set(rdr.fieldnames) > for r in rdr: > header_set = set(h for h in header_set if not r[h]) > if not header_set: > break > > for r in rdr: > data = list(r[i] for i in header_set) > > dw = csv.DictWriter(fout, header_set) > dw.writeheader() > dw.writerows(data) Sorry, this is not the code you ran. I could guess what the missing parts might be, but it is easier for both sides if you provide a small script that actually can be executed and a small dataset that shows the behaviour you describe. Then post the session and especially the traceback. Example: $ cat my_data.csv 0 $ cat my_code.py print 1/int(open("my_data.csv").read()) $ python my_code.py Traceback (most recent call last): File "my_code.py", line 1, in print 1/int(open("my_data.csv").read()) ZeroDivisionError: integer division or modulo by zero Don't retype, use cut and paste. Thank you. From lac at openend.se Tue Oct 6 08:42:47 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 06 Oct 2015 14:42:47 +0200 Subject: Python 2 =?utf-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode In-Reply-To: <85wpv0z368.fsf@benfinney.id.au> References: <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> Message-ID: <201510061242.t96Cglw3011324@fido.openend.se> I think the thing you want to converse is your stringIO not your print. I think you do this using six.stringIO https://pythonhosted.org/six/ But I have only read the doc, not done this in practice. Laura From lac at openend.se Tue Oct 6 08:48:12 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 06 Oct 2015 14:48:12 +0200 Subject: Python 2 =?utf-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode In-Reply-To: <85wpv0z368.fsf@benfinney.id.au> References: <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> Message-ID: <201510061248.t96CmCWP011700@fido.openend.se> Hmm, now that I read the six document again @six.python_2_unicode_compatible seems exactly what you are asking for ... https://pythonhosted.org/six/ Laura From voxner.dev at gmail.com Tue Oct 6 08:58:09 2015 From: voxner.dev at gmail.com (voxner) Date: Tue, 6 Oct 2015 18:28:09 +0530 Subject: python and ARM memory types In-Reply-To: <201510060938.t969cKri030566@fido.openend.se> References: <62e78153-8a84-4b78-8881-8a891df0d496@googlegroups.com> <201510060938.t969cKri030566@fido.openend.se> Message-ID: The main intent to use python was because it was easier to code the algorithms. Also I was hoping to reuse the parallel algorithms specifically iterative ones where we have some sort of control thread that distributes data between the threads. Now I am planning to have 2 different set of kernel with malloc that returns WB and WT memory respectively. Then run the parallel python program on top of that. On 6 October 2015 at 15:08, Laura Creighton wrote: > It is not clear to me if any of the tools that come with volutility are > going to be of any use, but I figure it is worth a look, at any rate. > > https://github.com/volatilityfoundation/volatility > > I seem to have replied directly, at any rate I mentioned this yesterday > but don't see it in the mailing list archives. > > Laura > > -- > https://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Tue Oct 6 10:30:31 2015 From: __peter__ at web.de (Peter Otten) Date: Tue, 06 Oct 2015 16:30:31 +0200 Subject: Python 2 =?UTF-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode References: <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: > Ben Finney writes: > >> In Python 2.7, I am seeing this behaviour for ?print?:: >> >> Python 2.7.10 (default, Sep 13 2015, 20:30:50) >> [GCC 5.2.1 20150911] on linux2 >> Type "help", "copyright", "credits" or "license" for more >> information. >> >>> from __future__ import unicode_literals >> >>> from __future__ import print_function >> >>> import io >> >>> print(None) >> None >> >>> print(None, file=io.StringIO()) >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: unicode argument expected, got 'str' >> >> So, although my string literals are now Unicode objects, apparently >> ?print? still coerces objects using the bytes type ?str?. > > To eliminate ?from __future__ import print_function? as a possible > factor, here is another demonstration without that:: > > Python 2.7.10 (default, Sep 13 2015, 20:30:50) > [GCC 5.2.1 20150911] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> from __future__ import unicode_literals > >>> import sys > >>> import io > >>> print "foo" > foo > >>> print None > None > >>> sys.stdout = io.StringIO() > >>> print "foo" > Traceback (most recent call last): > File "", line 1, in > TypeError: unicode argument expected, got 'str' > >>> print None > Traceback (most recent call last): > File "", line 1, in > TypeError: unicode argument expected, got 'str' > > So it appears that even a string literal, which is explicitly Unicode by > the above ?from __future__ import unicode_literals?, is still being > coerced to a bytes ?str? object by ?print?. > > How can I convince ?print?, everywhere throughout a module, that it > should coerce its arguments using ?unicode?? I don't think this is possible with the print statement, but the print() function can be replaced with anything you like: $ 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 __future__ import unicode_literals >>> from __future__ import print_function >>> import io >>> _print = print >>> def print(*args, **kw): ... return _print(*map(unicode, args), **kw) ... >>> print(None, file=io.StringIO()) >>> outstream = io.StringIO() >>> print(None, file=outstream) >>> outstream.getvalue() u'None\n' >>> print(None) None From josef.pktd at gmail.com Tue Oct 6 10:35:37 2015 From: josef.pktd at gmail.com (Josef Pktd) Date: Tue, 6 Oct 2015 07:35:37 -0700 (PDT) Subject: Pyarmor, guard your python scripts In-Reply-To: References: <42f12eba-2504-4a97-a5bc-e7b9bfe2f1f9@googlegroups.com> <22dc806f-f3f4-4e5d-a939-5ecc5e4bf946@googlegroups.com> <74f43ca8-fc25-4622-8f18-784b71f781af@googlegroups.com> <63bd6da4-50ad-4b0c-bff7-5b5d26d161b3@googlegroups.com> <95a3b4d2-82b7-406a-99dd-4d130b0a3ccd@googlegroups.com> <85si5p0x7u.fsf@benfinney.id.au> Message-ID: <7a3a861d-1ae9-4063-80b4-a6d02c802fcf@googlegroups.com> On Monday, October 5, 2015 at 11:27:58 PM UTC-4, Ian wrote: > On Oct 5, 2015 4:27 PM, "Ben Finney" wrote: > > > > > > Josef Pktd writes: > > > > > > > related > > > > > > Care to give us a summary of what that is, and describe what you think > > > is the relevant point? > > Following the link reveals it to be the video of a talk on Python exe compilation from PyCon 2014. > > If you're worried about the safety of the link, know that youtu.be is the official URL shortener for YouTube and only leads to YouTube videos. The talk is by Brandon Rhodes that I found quite refreshing the first time I attended Pycon https://us.pycon.org/2014/schedule/presentation/201/ The approach is building an exe file, but the motivation is the same as here. About the keys: Consider it as price discrimination between "cheap" hackers and plain users. When I was a student I wasn't very reluctant to install cracked versions, but as far as I remember, I haven't installed a cracked version of a program in 15 years or so. All the application and music on the ipads in my family are legitimate versions, either free minimal functionality versions or purchased on apps store or through itunes. The python community in general seems to be a lot in favor of SaaS but not much in favor of selling (small) software products. When we got our first ipad, (I'm traditionally a Windows user) I was surprised how large the market for small and larger programs is and the opportunities that it provides for single developers or small groups of developers. In contrast, SaaS requires a much larger setup cost and larger scale. I pretty much share Jondy Zhao's view. That doesn't mean it's always a good idea. I have been working for many years on BSD licensed open source software. Josef From rajthanug at gmail.com Tue Oct 6 10:43:11 2015 From: rajthanug at gmail.com (rajesh thanu) Date: Tue, 6 Oct 2015 20:13:11 +0530 Subject: pls help me install 3.5 and 2.7.10 Message-ID: [14C0:1718][2015-10-06T20:09:57]i001: Burn v3.10.0.1823, Windows v6.1 (Build 7601: Service Pack 1), path: C:\Users\raj\Downloads\python-3.5.0-webinstall.exe [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'ActionLikeInstalling' to value 'Installing' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'ActionLikeInstallation' to value 'Setup' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'ShortVersion' to value '3.5' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'ShortVersionNoDot' to value '35' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'InstallAllUsers' to value '0' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'InstallLauncherAllUsers' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'TargetDir' to value '' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'DefaultAllUsersTargetDir' to value '[ProgramFilesFolder]Python [ShortVersion]' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'TargetPlatform' to value 'x86' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'DefaultJustForMeTargetDir' to value '[LocalAppDataFolder]Programs\Python\Python[ShortVersionNoDot]-32' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'OptionalFeaturesRegistryKey' to value 'Software\Python\PythonCore\[ShortVersion]-32\InstalledFeatures' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'TargetDirRegistryKey' to value 'Software\Python\PythonCore\[ShortVersion]-32\InstallPath' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'DefaultCustomTargetDir' to value '' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'InstallAllUsersState' to value 'enabled' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'InstallLauncherAllUsersState' to value 'enabled' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'CustomInstallLauncherAllUsersState' to value '[InstallLauncherAllUsersState]' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'TargetDirState' to value 'enabled' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'CustomBrowseButtonState' to value 'enabled' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_core' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_exe' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_dev' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_lib' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_test' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_doc' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_tools' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_tcltk' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_pip' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_launcher' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_symbols' to value '0' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Include_debug' to value '0' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'LauncherOnly' to value '0' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'AssociateFiles' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'Shortcuts' to value '1' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'PrependPath' to value '0' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'CompileAll' to value '0' [14C0:1718][2015-10-06T20:09:57]i000: Initializing numeric variable 'SimpleInstall' to value '0' [14C0:1718][2015-10-06T20:09:57]i000: Initializing string variable 'SimpleInstallDescription' to value '' [14C0:1718][2015-10-06T20:09:57]i009: Command Line: '-burn.unelevated BurnPipe.{B3FE2E0A-C963-4F43-9B16-7706F1471DA1} {AD66A7E6-551E-4F74-871C-78CDC3FABCA9} 4796' [14C0:1718][2015-10-06T20:09:57]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957.log' [14C0:1718][2015-10-06T20:09:57]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\raj\Downloads\python-3.5.0-webinstall.exe' [14C0:1718][2015-10-06T20:09:57]i000: Setting string variable 'WixBundleOriginalSourceFolder' to value 'C:\Users\raj\Downloads\' [14C0:1718][2015-10-06T20:09:57]i000: Setting string variable 'WixBundleName' to value 'Python 3.5.0 (32-bit)' [14C0:1718][2015-10-06T20:09:57]i000: Setting string variable 'WixBundleManufacturer' to value 'Python Software Foundation' [14C0:1718][2015-10-06T20:09:57]i000: Setting numeric variable 'CRTInstalled' to value 0 [14C0:0D40][2015-10-06T20:09:57]i000: Did not find C:\Users\raj\Downloads\unattend.xml [14C0:0D40][2015-10-06T20:09:57]i000: Setting string variable 'ActionLikeInstalling' to value 'Installing' [14C0:0D40][2015-10-06T20:09:57]i000: Setting string variable 'ActionLikeInstallation' to value 'Setup' [14C0:0D40][2015-10-06T20:09:57]i000: Setting version variable 'WixBundleFileVersion' to value '3.5.150.0' [14C0:1718][2015-10-06T20:09:57]i100: Detect begin, 54 packages [14C0:1718][2015-10-06T20:09:57]w120: Detected partially cached package: crt_14.0_v6.1_x64, invalid payload: crt_14.0_v6.1_x64, reason: 0x80070002 [14C0:1718][2015-10-06T20:09:57]i101: Detected package: crt_14.0_v6.0_x86, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: crt_14.0_v6.0_x64, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: crt_14.0_v6.1_x86, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: crt_14.0_v6.1_x64, state: Absent, cached: Partial [14C0:1718][2015-10-06T20:09:57]i101: Detected package: crt_14.0_v6.2_x86, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: crt_14.0_v6.2_x64, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: crt_14.0_v6.3_x86, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: crt_14.0_v6.3_x64, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: core_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: core_AllUsers_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: core_AllUsers_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: core_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: core_JustForMe_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: core_JustForMe_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: dev_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: dev_AllUsers_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: dev_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: dev_JustForMe_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: exe_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: exe_AllUsers, feature: DefaultFeature, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: exe_AllUsers, feature: Shortcuts, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: exe_AllUsers_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: exe_AllUsers_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: exe_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: exe_JustForMe, feature: DefaultFeature, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: exe_JustForMe, feature: Shortcuts, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: exe_JustForMe_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: exe_JustForMe_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: lib_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: lib_AllUsers_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: lib_AllUsers_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: lib_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: lib_JustForMe_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: lib_JustForMe_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: test_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: test_AllUsers_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: test_AllUsers_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: test_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: test_JustForMe_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: test_JustForMe_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: doc_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: doc_AllUsers, feature: DefaultFeature, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: doc_AllUsers, feature: Shortcuts, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: doc_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: doc_JustForMe, feature: DefaultFeature, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: doc_JustForMe, feature: Shortcuts, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: tools_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: tools_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: tcltk_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_AllUsers, feature: DefaultFeature, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_AllUsers, feature: AssociateFiles, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_AllUsers, feature: Shortcuts, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: tcltk_AllUsers_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_AllUsers_pdb, feature: Symbols, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: tcltk_AllUsers_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_AllUsers_d, feature: DebugBinaries, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: tcltk_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_JustForMe, feature: DefaultFeature, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_JustForMe, feature: AssociateFiles, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_JustForMe, feature: Shortcuts, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: tcltk_JustForMe_pdb, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_JustForMe_pdb, feature: Symbols, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: tcltk_JustForMe_d, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: tcltk_JustForMe_d, feature: DebugBinaries, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: launcher_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: launcher_AllUsers, feature: DefaultFeature, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: launcher_AllUsers, feature: AssociateFiles, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: launcher_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i104: Detected package: launcher_JustForMe, feature: DefaultFeature, state: Absent [14C0:1718][2015-10-06T20:09:57]i104: Detected package: launcher_JustForMe, feature: AssociateFiles, state: Absent [14C0:1718][2015-10-06T20:09:57]i101: Detected package: pip_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: pip_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: path_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: path_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: compileall_AllUsers, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i101: Detected package: compileall_JustForMe, state: Absent, cached: None [14C0:1718][2015-10-06T20:09:57]i000: Setting string variable 'TargetDir' to value 'C:\Users\raj\AppData\Local\Programs\Python\Python35-32' [14C0:1718][2015-10-06T20:09:57]i199: Detect complete, result: 0x0 [14C0:0D40][2015-10-06T20:09:57]i052: Condition 'not WixBundleElevated and (InstallAllUsers or (InstallLauncherAllUsers and Include_launcher))' evaluates to false. [14C0:0D40][2015-10-06T20:10:02]i000: Setting numeric variable 'PrependPath' to value 1 [14C0:0D40][2015-10-06T20:10:02]i000: Setting numeric variable 'InstallLauncherAllUsers' to value 1 [14C0:0D40][2015-10-06T20:10:12]i000: Setting numeric variable 'Include_doc' to value 1 [14C0:0D40][2015-10-06T20:10:12]i000: Setting numeric variable 'Include_pip' to value 1 [14C0:0D40][2015-10-06T20:10:12]i000: Setting numeric variable 'Include_tcltk' to value 1 [14C0:0D40][2015-10-06T20:10:12]i000: Setting numeric variable 'Include_test' to value 1 [14C0:0D40][2015-10-06T20:10:12]i000: Setting numeric variable 'Include_launcher' to value 1 [14C0:0D40][2015-10-06T20:10:12]i000: Setting numeric variable 'CustomInstallLauncherAllUsers' to value 1 [14C0:0D40][2015-10-06T20:10:12]i052: Condition 'not WixBundleElevated and (InstallAllUsers or (InstallLauncherAllUsers and Include_launcher))' evaluates to false. [14C0:0D40][2015-10-06T20:10:14]i000: Setting numeric variable 'InstallAllUsers' to value 1 [14C0:0D40][2015-10-06T20:10:14]i052: Condition 'not WixBundleElevated and (InstallAllUsers or (InstallLauncherAllUsers and Include_launcher))' evaluates to false. [14C0:0D40][2015-10-06T20:10:14]i000: Setting numeric variable 'CompileAll' to value 1 [14C0:0D40][2015-10-06T20:10:16]i000: Setting numeric variable 'InstallAllUsers' to value 0 [14C0:0D40][2015-10-06T20:10:16]i052: Condition 'not WixBundleElevated and (InstallAllUsers or (InstallLauncherAllUsers and Include_launcher))' evaluates to false. [14C0:0D40][2015-10-06T20:10:19]i000: Setting numeric variable 'InstallAllUsers' to value 1 [14C0:0D40][2015-10-06T20:10:19]i052: Condition 'not WixBundleElevated and (InstallAllUsers or (InstallLauncherAllUsers and Include_launcher))' evaluates to false. [14C0:0D40][2015-10-06T20:10:19]i000: Setting numeric variable 'CompileAll' to value 1 [14C0:0D40][2015-10-06T20:10:20]i000: Setting numeric variable 'InstallAllUsers' to value 0 [14C0:0D40][2015-10-06T20:10:20]i052: Condition 'not WixBundleElevated and (InstallAllUsers or (InstallLauncherAllUsers and Include_launcher))' evaluates to false. [14C0:0D40][2015-10-06T20:10:27]i000: Setting numeric variable 'InstallAllUsers' to value 0 [14C0:0D40][2015-10-06T20:10:27]i000: Setting numeric variable 'AssociateFiles' to value 1 [14C0:0D40][2015-10-06T20:10:27]i000: Setting numeric variable 'Shortcuts' to value 1 [14C0:0D40][2015-10-06T20:10:27]i000: Setting numeric variable 'PrependPath' to value 1 [14C0:0D40][2015-10-06T20:10:27]i000: Setting numeric variable 'CompileAll' to value 1 [14C0:0D40][2015-10-06T20:10:27]i000: Setting numeric variable 'Include_symbols' to value 0 [14C0:0D40][2015-10-06T20:10:27]i000: Setting numeric variable 'Include_debug' to value 0 [14C0:0D40][2015-10-06T20:10:27]i000: Setting string variable 'TargetDir' to value 'C:\Users\raj\AppData\Local\Programs\Python\Python35-32' [14C0:0D40][2015-10-06T20:10:27]i052: Condition 'not WixBundleElevated and (InstallAllUsers or (InstallLauncherAllUsers and Include_launcher))' evaluates to false. [14C0:0D40][2015-10-06T20:10:27]i000: Setting string variable 'ActionLikeInstalling' to value 'Installing' [14C0:0D40][2015-10-06T20:10:27]i000: Setting string variable 'ActionLikeInstallation' to value 'Setup' [14C0:1718][2015-10-06T20:10:27]i200: Plan begin, 54 packages, action: Install [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT = v6.0 and not VersionNT64 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT = v6.0 and not VersionNT64 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: crt_14.0_v6.0_x86 [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT64 = v6.0 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT64 = v6.0 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: crt_14.0_v6.0_x64 [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT = v6.1 and not VersionNT64 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT = v6.1 and not VersionNT64 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: crt_14.0_v6.1_x86 [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT64 = v6.1 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT64 = v6.1 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: crt_14.0_v6.1_x64 [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT = v6.2 and not VersionNT64 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT = v6.2 and not VersionNT64 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: crt_14.0_v6.2_x86 [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT64 = v6.2 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT64 = v6.2 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: crt_14.0_v6.2_x64 [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT = v6.3 and not VersionNT64 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT = v6.3 and not VersionNT64 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: crt_14.0_v6.3_x86 [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT64 = v6.3 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not CRTInstalled and VersionNT64 = v6.3 and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: crt_14.0_v6.3_x64 [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: core_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: core_AllUsers_pdb, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: core_AllUsers_d, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_core_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_001_core_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_core_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_001_core_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_core or Include_exe or Include_launcher or Include_pip) and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_dev and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_dev and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: dev_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_dev and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_dev and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: dev_AllUsers_d, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_dev and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_dev and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_dev_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_002_dev_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_dev_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_002_dev_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_dev and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_dev and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i204: Plan 2 msi features for package: exe_AllUsers [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DefaultFeature, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: Shortcuts, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: exe_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: exe_AllUsers_pdb, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: exe_AllUsers_d, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i204: Plan 2 msi features for package: exe_JustForMe [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DefaultFeature, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: Shortcuts, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_exe_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_003_exe_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_exe_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_003_exe_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and (Include_exe or Include_launcher or Include_pip) and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_lib and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_lib and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: lib_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_lib and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_lib and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: lib_AllUsers_pdb, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_lib and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_lib and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: lib_AllUsers_d, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_lib and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_lib and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_lib_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_004_lib_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_lib_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_004_lib_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_lib and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_lib and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_lib and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_lib and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_test and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_test and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: test_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_test and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_test and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: test_AllUsers_pdb, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_test and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_test and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: test_AllUsers_d, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_test and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_test and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_test_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_005_test_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_test_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_005_test_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_test and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_test and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_test and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_test and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_doc and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_doc and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i204: Plan 2 msi features for package: doc_AllUsers [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DefaultFeature, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: Shortcuts, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: doc_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_doc and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_doc and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i204: Plan 2 msi features for package: doc_JustForMe [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DefaultFeature, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: Shortcuts, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_doc_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_006_doc_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_doc_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_006_doc_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_tools and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_tools and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: tools_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_tools and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_tools and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_tools_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_007_tools_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_tools_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_007_tools_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_tcltk and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_tcltk and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i204: Plan 3 msi features for package: tcltk_AllUsers [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DefaultFeature, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: AssociateFiles, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: Shortcuts, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: tcltk_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_tcltk and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_tcltk and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i204: Plan 1 msi features for package: tcltk_AllUsers_pdb [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: Symbols, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: tcltk_AllUsers_pdb, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_tcltk and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_tcltk and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i204: Plan 1 msi features for package: tcltk_AllUsers_d [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DebugBinaries, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: tcltk_AllUsers_d, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_tcltk and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_tcltk and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i204: Plan 3 msi features for package: tcltk_JustForMe [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DefaultFeature, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: AssociateFiles, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: Shortcuts, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_tcltk_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_008_tcltk_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_tcltk_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_008_tcltk_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_tcltk and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_tcltk and Include_symbols and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i204: Plan 1 msi features for package: tcltk_JustForMe_pdb [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: Symbols, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_tcltk and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_tcltk and Include_debug and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i204: Plan 1 msi features for package: tcltk_JustForMe_d [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DebugBinaries, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i052: Condition '(InstallAllUsers or InstallLauncherAllUsers) and Include_launcher' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition '(InstallAllUsers or InstallLauncherAllUsers) and Include_launcher' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i204: Plan 2 msi features for package: launcher_AllUsers [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DefaultFeature, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: AssociateFiles, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: launcher_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_launcher_AllUsers' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_009_launcher_AllUsers_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_launcher_AllUsers' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_009_launcher_AllUsers.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not (InstallAllUsers or InstallLauncherAllUsers) and Include_launcher' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not (InstallAllUsers or InstallLauncherAllUsers) and Include_launcher' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i204: Plan 2 msi features for package: launcher_JustForMe [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: DefaultFeature, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i203: Planned feature: AssociateFiles, state: Absent, default requested: Unknown, ba requested: Local, execute action: AddLocal, rollback action: Remove [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_pip and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and Include_pip and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: pip_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_pip and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and Include_pip and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_pip_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_010_pip_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_pip_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_010_pip_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and PrependPath and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and PrependPath and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w322: Skipping cross-scope dependency registration on package: path_AllUsers, bundle scope: PerUser, package scope: PerMachine [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and PrependPath and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and PrependPath and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleRollbackLog_path_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_011_path_JustForMe_rollback.log' [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_path_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_011_path_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and CompileAll and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'InstallAllUsers and CompileAll and not LauncherOnly' evaluates to false. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: compileall_AllUsers [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and CompileAll and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]i052: Condition 'not InstallAllUsers and CompileAll and not LauncherOnly' evaluates to true. [14C0:1718][2015-10-06T20:10:27]w321: Skipping dependency registration on package with no dependency providers: compileall_JustForMe [14C0:1718][2015-10-06T20:10:27]i000: Setting string variable 'WixBundleLog_compileall_JustForMe' to value 'C:\Users\raj\AppData\Local\Temp\Python 3.5.0 (32-bit)_20151006200957_012_compileall_JustForMe.log' [14C0:1718][2015-10-06T20:10:27]i201: Planned package: crt_14.0_v6.0_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: crt_14.0_v6.0_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: crt_14.0_v6.1_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: crt_14.0_v6.1_x64, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: crt_14.0_v6.2_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: crt_14.0_v6.2_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: crt_14.0_v6.3_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: crt_14.0_v6.3_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: core_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: core_AllUsers_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: core_AllUsers_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: core_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: core_JustForMe_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: core_JustForMe_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: dev_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: dev_AllUsers_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: dev_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: dev_JustForMe_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: exe_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: exe_AllUsers_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: exe_AllUsers_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: exe_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: exe_JustForMe_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: exe_JustForMe_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: lib_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: lib_AllUsers_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: lib_AllUsers_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: lib_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: lib_JustForMe_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: lib_JustForMe_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: test_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: test_AllUsers_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: test_AllUsers_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: test_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: test_JustForMe_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: test_JustForMe_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: doc_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: doc_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: tools_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: tools_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: tcltk_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: tcltk_AllUsers_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: tcltk_AllUsers_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: tcltk_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: tcltk_JustForMe_pdb, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: tcltk_JustForMe_d, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: launcher_AllUsers, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: launcher_JustForMe, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: pip_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: pip_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: path_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: path_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register [14C0:1718][2015-10-06T20:10:27]i201: Planned package: compileall_AllUsers, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i201: Planned package: compileall_JustForMe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: None, cache: Yes, uncache: No, dependency: None [14C0:1718][2015-10-06T20:10:27]i299: Plan complete, result: 0x0 [14C0:1718][2015-10-06T20:10:27]i300: Apply begin [12BC:04E8][2015-10-06T20:10:27]i358: Pausing automatic updates. [12BC:04E8][2015-10-06T20:10:27]i359: Paused automatic updates. [12BC:04E8][2015-10-06T20:10:27]i360: Creating a system restore point. [12BC:04E8][2015-10-06T20:10:32]i361: Created a system restore point. [14C0:1718][2015-10-06T20:10:32]i370: Session begin, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}, options: 0x7, disable resume: No [14C0:1718][2015-10-06T20:10:32]i000: Caching bundle from: 'C:\Users\raj\AppData\Local\Temp\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}\.be\python-3.5.0-webinstall.exe' to: 'C:\Users\raj\AppData\Local\Package Cache\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}\python-3.5.0-webinstall.exe' [14C0:1718][2015-10-06T20:10:32]i320: Registering bundle dependency provider: {4d5c3f26-744d-4e1e-8362-cdbe364e1a73}, version: 3.5.150.0 [14C0:1718][2015-10-06T20:10:32]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}, resume: Active, restart initiated: No, disable resume: No [14C0:1778][2015-10-06T20:10:32]i338: Acquiring package: crt_14.0_v6.1_x64, payload: crt_14.0_v6.1_x64, copy from: C:\Users\raj\Downloads\Windows6.1-KB2999226-x64.msu [14C0:1778][2015-10-06T20:10:32]i000: Setting string variable 'WixBundleLastUsedSource' to value 'C:\Users\raj\Downloads\' [12BC:0384][2015-10-06T20:10:32]e000: Error 0x80091007: Hash mismatch for path: C:\ProgramData\Package Cache\.unverified\crt_14.0_v6.1_x64, expected: 42D5BEC7DDFBD49E76467529CBC2868987BF8460, actual: 54050A5F8AE7F0C56E553F0090146C17A1D2BF8D [12BC:0384][2015-10-06T20:10:32]e000: Error 0x80091007: Failed to verify hash of payload: crt_14.0_v6.1_x64 [12BC:0384][2015-10-06T20:10:32]e310: Failed to verify payload: crt_14.0_v6.1_x64 at path: C:\ProgramData\Package Cache\.unverified\crt_14.0_v6.1_x64, error: 0x80091007. Deleting file. [12BC:0384][2015-10-06T20:10:32]e000: Error 0x80091007: Failed to cache payload: crt_14.0_v6.1_x64 [14C0:1778][2015-10-06T20:10:32]e314: Failed to cache payload: crt_14.0_v6.1_x64 from working path: C:\Users\raj\AppData\Local\Temp\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}\crt_14.0_v6.1_x64, error: 0x80091007. [14C0:1778][2015-10-06T20:10:32]e349: Application requested retry of payload: crt_14.0_v6.1_x64, encountered error: 0x80091007. Retrying... [14C0:1778][2015-10-06T20:10:35]i338: Acquiring package: crt_14.0_v6.1_x64, payload: crt_14.0_v6.1_x64, copy from: C:\Users\raj\Downloads\Windows6.1-KB2999226-x64.msu [12BC:0384][2015-10-06T20:10:35]e000: Error 0x80091007: Hash mismatch for path: C:\ProgramData\Package Cache\.unverified\crt_14.0_v6.1_x64, expected: 42D5BEC7DDFBD49E76467529CBC2868987BF8460, actual: 54050A5F8AE7F0C56E553F0090146C17A1D2BF8D [12BC:0384][2015-10-06T20:10:35]e000: Error 0x80091007: Failed to verify hash of payload: crt_14.0_v6.1_x64 [12BC:0384][2015-10-06T20:10:35]e310: Failed to verify payload: crt_14.0_v6.1_x64 at path: C:\ProgramData\Package Cache\.unverified\crt_14.0_v6.1_x64, error: 0x80091007. Deleting file. [12BC:0384][2015-10-06T20:10:35]e000: Error 0x80091007: Failed to cache payload: crt_14.0_v6.1_x64 [14C0:1778][2015-10-06T20:10:35]e314: Failed to cache payload: crt_14.0_v6.1_x64 from working path: C:\Users\raj\AppData\Local\Temp\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}\crt_14.0_v6.1_x64, error: 0x80091007. [14C0:1778][2015-10-06T20:10:35]e349: Application requested retry of payload: crt_14.0_v6.1_x64, encountered error: 0x80091007. Retrying... [14C0:1778][2015-10-06T20:10:38]i338: Acquiring package: crt_14.0_v6.1_x64, payload: crt_14.0_v6.1_x64, copy from: C:\Users\raj\Downloads\Windows6.1-KB2999226-x64.msu [12BC:0384][2015-10-06T20:10:38]e000: Error 0x80091007: Hash mismatch for path: C:\ProgramData\Package Cache\.unverified\crt_14.0_v6.1_x64, expected: 42D5BEC7DDFBD49E76467529CBC2868987BF8460, actual: 54050A5F8AE7F0C56E553F0090146C17A1D2BF8D [12BC:0384][2015-10-06T20:10:38]e000: Error 0x80091007: Failed to verify hash of payload: crt_14.0_v6.1_x64 [12BC:0384][2015-10-06T20:10:38]e310: Failed to verify payload: crt_14.0_v6.1_x64 at path: C:\ProgramData\Package Cache\.unverified\crt_14.0_v6.1_x64, error: 0x80091007. Deleting file. [12BC:0384][2015-10-06T20:10:38]e000: Error 0x80091007: Failed to cache payload: crt_14.0_v6.1_x64 [14C0:1778][2015-10-06T20:10:38]e314: Failed to cache payload: crt_14.0_v6.1_x64 from working path: C:\Users\raj\AppData\Local\Temp\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}\crt_14.0_v6.1_x64, error: 0x80091007. [14C0:1718][2015-10-06T20:10:38]e000: Error 0x80091007: Cache thread exited unexpectedly. [14C0:1718][2015-10-06T20:10:38]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}, resume: ARP, restart: None, disable resume: No [14C0:1718][2015-10-06T20:10:38]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4d5c3f26-744d-4e1e-8362-cdbe364e1a73}, resume: ARP, restart initiated: No, disable resume: No [14C0:1718][2015-10-06T20:10:38]i399: Apply complete, result: 0x80091007, restart: None, ba requested restart: No -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Tue Oct 6 10:44:00 2015 From: emile at fenx.com (Emile van Sebille) Date: Tue, 6 Oct 2015 07:44:00 -0700 Subject: Trouble running In-Reply-To: <5612bc0d.2772c20a.271c4.24a5@mx.google.com> References: <5612bc0d.2772c20a.271c4.24a5@mx.google.com> Message-ID: On 10/5/2015 11:06 AM, Cameroni123 ? wrote: > Hi I have recently installed python on windows 10 and I?m trying to save > in order to run the module and I cant I don?t know why, could you please > help? you might find the following helpful: http://www.cs.utexas.edu/~mitra/bytes/start.html emile From gordon at panix.com Tue Oct 6 10:56:28 2015 From: gordon at panix.com (John Gordon) Date: Tue, 6 Oct 2015 14:56:28 +0000 (UTC) Subject: Trouble running References: Message-ID: In =?utf-8?Q?Cameroni123_=E2=84=A2?= writes: > Hi I have recently installed python on windows 10 and I'm trying to > save in order to run the module and I cant I don't know why, could > you please help? > Cameron We need more details to help you. What program are you using to try to save? Is it a text editor? What happens when you try to save? How do you know it didn't work? Do you get an error message? -- 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 python at mrabarnett.plus.com Tue Oct 6 11:03:56 2015 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 6 Oct 2015 16:03:56 +0100 Subject: Finding Blank Columns in CSV In-Reply-To: References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: <5613E2DC.2020604@mrabarnett.plus.com> On 2015-10-06 12:24, Jaydip Chakrabarty wrote: > On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote: > >> On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase >> wrote: >>> That way, if you determine by line 3 that your million-row CSV file has >>> no blank columns, you can get away with not processing all million >>> rows. >> >> Sure, although that effectively means the entire job is moot. I kinda >> assume that the OP knows that there are some blank columns (maybe lots >> of them). The extra check is unnecessary unless it's actually plausible >> that there'll be no blanks whatsoever. >> >> Incidentally, you have an ordered_headers list which is the blank >> columns in order; I think the OP was looking for a list of the >> _non_blank columns. But that's a trivial difference, easy to tweak. >> >> ChrisA > > Thanks to you all. I got it this far. But while writing back to another > csv file, I got this error - "ValueError: dict contains fields not in > fieldnames: None". Here is my code. > > rdr = csv.DictReader(fin, delimiter=',') > header_set = set(rdr.fieldnames) Initially, header_set contains all of the field names. > for r in rdr: > header_set = set(h for h in header_set if not r[h]) Keeping the field name if the field is empty. > if not header_set: > break > At this point, header_set will contain the field names where none of its values are empty. Wasn't the original question about excluding columns where all of the values are empty? You're excluding columns where _any_ of the values are empty. > for r in rdr: > data = list(r[i] for i in header_set) data will contain each processed row in turn. Because of the indentation, only the final data (row) will be would be written out. > > dw = csv.DictWriter(fout, header_set) > dw.writeheader() > dw.writerows(data) > > Also, there is difference between len(header_set) and len(data[0].keys). > Why is so? > Thanks again for all your help. > > Thanks. > From robin at reportlab.com Tue Oct 6 11:14:38 2015 From: robin at reportlab.com (Robin Becker) Date: Tue, 6 Oct 2015 16:14:38 +0100 Subject: python3.5 + reportlab + windows again Message-ID: <5613E55E.9000203@chamonix.reportlab.co.uk> I can run all of the reportlab tests OK under ubuntu 14.04 amd65 with the latest python 3.5 (built using configure make dance). However, when I try to do the same with windows 7 x64 & VS2015 as the compiler I am getting strange issues. Basically at some point in the run python pops up a dialogue that says python has stopped working and MS is searching for a solution :( MS doesn't find a solution and then my only options are debug & stop. Debugging reveals that the error appeared to happen somewhere in 'external code' called from python, but I don't have any idea which of the possible extensions is at fault. So far as I know I'm only using two extensions from inside reportlab and pillow. When tested separately, the two RL extensions appear to work OK, but I don't know where pillow came from. I just used c:\python35\scripts\pip install pillow and it automagically got downloaded as a wheel. I can at least import _imaging etc etc so I assume the pillow 3.0.0 is working. I guess I have to think about creating a debug build of python 3.5 and or one or more extensions. Does anyone know which flags I should be setting in the PCBUILD? I vaguely remember /Od /Zi, but this is a new version of VS so perhaps I'm out of date. -- Robin Becker From robin at reportlab.com Tue Oct 6 11:31:30 2015 From: robin at reportlab.com (Robin Becker) Date: Tue, 6 Oct 2015 16:31:30 +0100 Subject: python3.5 + reportlab + windows again In-Reply-To: <5613E55E.9000203@chamonix.reportlab.co.uk> References: <5613E55E.9000203@chamonix.reportlab.co.uk> Message-ID: <5613E952.2090503@chamonix.reportlab.co.uk> On 06/10/2015 16:14, Robin Becker wrote: > I can run all of the reportlab tests OK under ubuntu 14.04 amd65 with the latest > python 3.5 (built using configure make dance). ............ > > I guess I have to think about creating a debug build of python 3.5 and or one or > more extensions. > > Does anyone know which flags I should be setting in the PCBUILD? I vaguely > remember /Od /Zi, but this is a new version of VS so perhaps I'm out of date. well it seems someone can build these extensions properly. I used Christoph Gohlke's reportlab build and although there are 3 failures in the latest tests I don't see any crashes etc etc and all the failures are explainable. Last thing I saw from him in respect of pyRXPU was to use extra_compile_args=['/Od']. I will try that in the reportlab extension builds and see if the problems go away. -- Robin Becker From ltwede at ep.com Tue Oct 6 11:39:48 2015 From: ltwede at ep.com (Lisa Twede) Date: Tue, 6 Oct 2015 15:39:48 +0000 Subject: Just installed python and it says python34.dll is missing Message-ID: I tried re-downloading python and it gave me an option to repair, so I tried that. But it still throws the same error. I downloaded Python 3.5.0 for Windows. Lisa Twede Staff Software Developer Products ltwede at ep.com PHONE (818) 955-4311 FAX [Entertainment Partners: an employee owned company] Disclaimer - October 6, 2015 This email and any attachments are confidential and intended solely for python-list at python.org. If you are not a named addressee you are prohibited from reviewing, printing, disseminating, distributing, copying or altering this email or any part of it. If you have received this communication in error, please notify the sender of the error immediately, do not read or use the communication in any manner, destroy all copies, and delete it from your system if the communication was sent via email. Warning: Although Entertainment Partners has taken reasonable precautions to ensure no viruses are present in this email, the recipient is responsible for checking for and deleting viruses. Entertainment Partners does not accept responsibility for any loss or damage arising from the use of this email or attachments. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: eptagline.gif Type: image/gif Size: 3009 bytes Desc: eptagline.gif URL: From jtim.arnold at gmail.com Tue Oct 6 11:40:23 2015 From: jtim.arnold at gmail.com (Tim) Date: Tue, 6 Oct 2015 08:40:23 -0700 (PDT) Subject: packaging code with compiled libraries In-Reply-To: References: <67eacdc3-e493-44fe-859c-51b016995a3a@googlegroups.com> Message-ID: <174a6561-01dd-4823-bcd0-47369d30e8cc@googlegroups.com> On Tuesday, October 6, 2015 at 5:51:48 AM UTC-4, Oscar Benjamin wrote: > On 5 October 2015 at 20:43, Tim wrote: > > > > I have a package I want to share but have a question about packaging. > > > > Mostly the package is pure python code, but it also requires some binary libraries (*.so, *.dll, *.dylib). I want to bundle these libs so users don't have to compile. The package will run on *nix/windows/mac platforms. > The idea of a wheel is that you want to distribute your code fully > precompiled to end users who will be able to install it without > needing any C compilers etc. Of course this requires you to supply > wheels for each platform of interest. If this is what you want to do > then yes absolutely use wheels. Note that if you have installed > setuptools and wheel and you use setuptools in your setup.py then > building a wheel is as simple as running "python setup.py bdist_wheel" > (once your setup.py is complete). > > If the binary libraries in question are extension modules then you > should just declare them as such in your setup.py and > distutils/setuptools/wheel will take care of bundling them into the > wheel. > > If the binary libraries are not extension modules and you are building > them separately (not using distutils) then you can declare them as > "datafiles" [1] so that they will be bundled into your wheel and > installed alongside your python code. > > [1] https://packaging.python.org/en/latest/distributing/#package-data > > -- > Oscar Thanks for that description. I read through the recent archives on distutils-sig and it's pretty much over my head. These libs are built separately (not extension modules) so I will use wheels with the 'datafiles' approach. --Tim From chalao.adda at gmail.com Tue Oct 6 13:23:31 2015 From: chalao.adda at gmail.com (Jaydip Chakrabarty) Date: Tue, 6 Oct 2015 17:23:31 +0000 (UTC) Subject: Finding Blank Columns in CSV References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote: > Jaydip Chakrabarty wrote: > >> On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote: >> >>> On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase >>> wrote: >>>> That way, if you determine by line 3 that your million-row CSV file >>>> has no blank columns, you can get away with not processing all >>>> million rows. >>> >>> Sure, although that effectively means the entire job is moot. I kinda >>> assume that the OP knows that there are some blank columns (maybe lots >>> of them). The extra check is unnecessary unless it's actually >>> plausible that there'll be no blanks whatsoever. >>> >>> Incidentally, you have an ordered_headers list which is the blank >>> columns in order; I think the OP was looking for a list of the >>> _non_blank columns. But that's a trivial difference, easy to tweak. >>> >>> ChrisA >> >> Thanks to you all. I got it this far. But while writing back to another >> csv file, I got this error - "ValueError: dict contains fields not in >> fieldnames: None". Here is my code. >> >> rdr = csv.DictReader(fin, delimiter=',') >> header_set = set(rdr.fieldnames) >> for r in rdr: >> header_set = set(h for h in header_set if not r[h]) >> if not header_set: >> break >> >> for r in rdr: >> data = list(r[i] for i in header_set) >> >> dw = csv.DictWriter(fout, header_set) >> dw.writeheader() >> dw.writerows(data) > > Sorry, this is not the code you ran. I could guess what the missing > parts might be, but it is easier for both sides if you provide a small > script that actually can be executed and a small dataset that shows the > behaviour you describe. Then post the session and especially the > traceback. Example: > > $ cat my_data.csv 0 > $ cat my_code.py print 1/int(open("my_data.csv").read()) > $ python my_code.py Traceback (most recent call last): > File "my_code.py", line 1, in > print 1/int(open("my_data.csv").read()) > ZeroDivisionError: integer division or modulo by zero > > Don't retype, use cut and paste. Thank you. I downloaded gmail contacts in google csv format. There are so many columns. So I was trying to create another csv with the required columns. Now when I tried to open the gmail csv file with csv DictReader, it said the file contained NULL characters. So first I did - data = open(fn, 'rb').read() fout = open(ofn, 'wb') fout.write(data.replace('\x00', '')) fout.close() shutil.move(ofn, fn) Then I found, there were some special characters in the file. So, once again I opened the file and did - data = open(fn, 'rb').read() fout = open(ofn, 'wb') fout.write(data.replace('\xff\xfe', '')) fout.close() shutil.move(ofn, fn) Now it seemed right. So I started to remove empty columns. fin = open(fn, 'rb') fout = open(ofn, 'wb') rdr = csv.DictReader(fin, delimiter=',') flds = rdr.fieldnames header_set = set(rdr.fieldnames) for r in rdr: header_set = set(h for h in header_set if not r[h]) if not header_set: break for r in rdr: data = list(r[i] for i in header_set) dw = csv.DictWriter(fout, data[0].keys()) dw.writeheader() dw.writerows(data) fin.close() fout.close() But, I am getting error at dw.writerows(data). I put the whole code here. Please help. Thanks. From __peter__ at web.de Tue Oct 6 14:20:40 2015 From: __peter__ at web.de (Peter Otten) Date: Tue, 06 Oct 2015 20:20:40 +0200 Subject: Finding Blank Columns in CSV References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: Jaydip Chakrabarty wrote: > On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote: > >> Jaydip Chakrabarty wrote: >> >>> On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote: >>> >>>> On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase >>>> wrote: >>>>> That way, if you determine by line 3 that your million-row CSV file >>>>> has no blank columns, you can get away with not processing all >>>>> million rows. >>>> >>>> Sure, although that effectively means the entire job is moot. I kinda >>>> assume that the OP knows that there are some blank columns (maybe lots >>>> of them). The extra check is unnecessary unless it's actually >>>> plausible that there'll be no blanks whatsoever. >>>> >>>> Incidentally, you have an ordered_headers list which is the blank >>>> columns in order; I think the OP was looking for a list of the >>>> _non_blank columns. But that's a trivial difference, easy to tweak. >>>> >>>> ChrisA >>> >>> Thanks to you all. I got it this far. But while writing back to another >>> csv file, I got this error - "ValueError: dict contains fields not in >>> fieldnames: None". Here is my code. >>> >>> rdr = csv.DictReader(fin, delimiter=',') >>> header_set = set(rdr.fieldnames) >>> for r in rdr: >>> header_set = set(h for h in header_set if not r[h]) >>> if not header_set: >>> break >>> >>> for r in rdr: >>> data = list(r[i] for i in header_set) >>> >>> dw = csv.DictWriter(fout, header_set) >>> dw.writeheader() >>> dw.writerows(data) >> >> Sorry, this is not the code you ran. I could guess what the missing >> parts might be, but it is easier for both sides if you provide a small >> script that actually can be executed and a small dataset that shows the >> behaviour you describe. Then post the session and especially the >> traceback. Example: >> >> $ cat my_data.csv 0 >> $ cat my_code.py print 1/int(open("my_data.csv").read()) >> $ python my_code.py Traceback (most recent call last): >> File "my_code.py", line 1, in >> print 1/int(open("my_data.csv").read()) >> ZeroDivisionError: integer division or modulo by zero >> >> Don't retype, use cut and paste. Thank you. > > I downloaded gmail contacts in google csv format. There are so many > columns. So I was trying to create another csv with the required columns. > Now when I tried to open the gmail csv file with csv DictReader, it said > the file contained NULL characters. > So first I did - > > data = open(fn, 'rb').read() > fout = open(ofn, 'wb') > fout.write(data.replace('\x00', '')) > fout.close() > shutil.move(ofn, fn) > > Then I found, there were some special characters in the file. So, once > again I opened the file and did - > > data = open(fn, 'rb').read() > fout = open(ofn, 'wb') > fout.write(data.replace('\xff\xfe', '')) > fout.close() > shutil.move(ofn, fn) Uh this looks like the file is in UTF-16. Use import codecs fn = ... ofn = ... with codecs.open(fn, encoding="utf-16") as f: with codecs.open(ofn, "w", encoding="utf-8") as g: g.writelines(f) ... to convert it to UTF-8 which is compatible with the csv module of Python 2. > Now it seemed right. Only if all characters are encodable as iso-8859-1. > So I started to remove empty columns. > > fin = open(fn, 'rb') > fout = open(ofn, 'wb') > > rdr = csv.DictReader(fin, delimiter=',') > flds = rdr.fieldnames > header_set = set(rdr.fieldnames) > for r in rdr: > header_set = set(h for h in header_set if not r[h]) > if not header_set: > break > for r in rdr: > data = list(r[i] for i in header_set) > > dw = csv.DictWriter(fout, data[0].keys()) > dw.writeheader() > dw.writerows(data) > > fin.close() > fout.close() > > But, I am getting error at dw.writerows(data). I put the whole code here. > Please help. I really meant it when I asked you to post the code you actually ran, and the traceback it produces. When I fill in the blanks by guessing $ cat in.csv one,two,three foo,, bar,,baz $ cat remove_empty_colums.py import csv fn = "in.csv" ofn = "out.csv" fin = open(fn, 'rb') fout = open(ofn, 'wb') rdr = csv.DictReader(fin, delimiter=',') flds = rdr.fieldnames header_set = set(rdr.fieldnames) for r in rdr: header_set = set(h for h in header_set if not r[h]) if not header_set: break for r in rdr: data = list(r[i] for i in header_set) dw = csv.DictWriter(fout, data[0].keys()) dw.writeheader() dw.writerows(data) fin.close() fout.close() and then run the resulting script I get $ python remove_empty_colums.py Traceback (most recent call last): File "remove_empty_colums.py", line 18, in dw = csv.DictWriter(fout, data[0].keys()) NameError: name 'data' is not defined So this is my traceback, and while the NameError is trivial to fix (reopen the file or do a seek) but not sufficient to make the script do what you want it doesn't seem to be the problem you ran into. So you have a different script. I'd really like to see it, and the traceback it produces. From python at mrabarnett.plus.com Tue Oct 6 14:25:12 2015 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 6 Oct 2015 19:25:12 +0100 Subject: Finding Blank Columns in CSV In-Reply-To: References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: <56141208.1070903@mrabarnett.plus.com> On 2015-10-06 18:23, Jaydip Chakrabarty wrote: > On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote: > [snip] > > I downloaded gmail contacts in google csv format. There are so many > columns. So I was trying to create another csv with the required columns. > Now when I tried to open the gmail csv file with csv DictReader, it said > the file contained NULL characters. Why would there be nulls in a CSV file? > So first I did - > > data = open(fn, 'rb').read() > fout = open(ofn, 'wb') > fout.write(data.replace('\x00', '')) > fout.close() > shutil.move(ofn, fn) > > Then I found, there were some special characters in the file. So, once > again I opened the file and did - > > data = open(fn, 'rb').read() > fout = open(ofn, 'wb') > fout.write(data.replace('\xff\xfe', '')) > fout.close() > shutil.move(ofn, fn) > b'\xff\xfe' looks like a BOM. If it's at the start of the file, it indicates that the file is encoded in 'UTF16-LE'. So, apparently, the original file was CSV encoded in 'UTF16-LE'. You _do_ still have the original file, don't you? [snip] From ben+python at benfinney.id.au Tue Oct 6 17:23:17 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 07 Oct 2015 08:23:17 +1100 Subject: Python 2 =?utf-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode References: <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> <201510061248.t96CmCWP011700@fido.openend.se> Message-ID: <85si5nzo6y.fsf@benfinney.id.au> Laura Creighton writes: > Hmm, now that I read the six document again > @six.python_2_unicode_compatible Peter Otten <__peter__ at web.de> writes: > I don't think this is possible with the print statement, but the > print() function can be replaced with anything you like: Hmm. I am more looking for something that doesn't involve replacing ?print?, but rather to hook into whatever it uses to coerce the type of its arguments. -- \ ?The problem with television is that the people must sit and | `\ keep their eyes glued on a screen: the average American family | _o__) hasn't time for it.? ?_The New York Times_, 1939 | Ben Finney From invalid at invalid.invalid Tue Oct 6 17:31:02 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 6 Oct 2015 21:31:02 +0000 (UTC) Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic References: <201510030907.t93974tU002535@fido.openend.se> <201510030919.t939Jdq6003741@fido.openend.se> <560FE87D.2050706@gmail.com> Message-ID: On 2015-10-03, Laura Creighton wrote: > https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345 > seems to be about a whole lot of serial ports to me, not just FTDI We just ran into the OP's problem where I work: Ununtu kernel updated and all serial ports stopped working (it isn't just an FTDI problem). Booting with the previous kernel makes the serial ports work again. What I'm trying to figure out: is this something _Ubuntu_ did so that only affects Ubuntu kernels? [I haven't seen it mentioned on the linux-serial mailing list, and nobody other than Ubuntu users seem to have the problem, so I think the answer to my question is "yes".] -- Grant Edwards grant.b.edwards Yow! Am I SHOPLIFTING? at gmail.com From rgaddi at technologyhighland.invalid Tue Oct 6 17:46:55 2015 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Tue, 6 Oct 2015 21:46:55 +0000 (UTC) Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic References: <201510030907.t93974tU002535@fido.openend.se> <201510030919.t939Jdq6003741@fido.openend.se> <560FE87D.2050706@gmail.com> Message-ID: On Tue, 06 Oct 2015 21:31:02 +0000, Grant Edwards wrote: > On 2015-10-03, Laura Creighton wrote: > >> https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/ +bug/1501345 >> seems to be about a whole lot of serial ports to me, not just FTDI > > We just ran into the OP's problem where I work: Ununtu kernel updated > and all serial ports stopped working (it isn't just an FTDI problem). > > Booting with the previous kernel makes the serial ports work again. > > What I'm trying to figure out: is this something _Ubuntu_ did so that > only affects Ubuntu kernels? [I haven't seen it mentioned on the > linux-serial mailing list, and nobody other than Ubuntu users seem to > have the problem, so I think the answer to my question is "yes".] Glad I was able to get you some heads-up on it; I wound up burning 4 hours before I figured out what the problem was. I'm not sure if these are Ubuntu specific problems, but I slung some C to test and confirmed that they're not Python specific problems. Pyserial uses select(), and on Linux all of select(), poll(), and epoll() are handled at the driver level by the same entry point. Anything in the genre is hosed until they get it back under control. Personally, I'm so upset that I'm going to call Linux and demand my money back. But until then I'm regressed to -63. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From lac at openend.se Tue Oct 6 17:51:38 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 06 Oct 2015 23:51:38 +0200 Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic In-Reply-To: References: <201510030907.t93974tU002535@fido.openend.se> <201510030919.t939Jdq6003741@fido.openend.se> <560FE87D.2050706@gmail.com> Message-ID: <201510062151.t96LpcmM019218@fido.openend.se> In a message of Tue, 06 Oct 2015 21:31:02 -0000, Grant Edwards writes: >On 2015-10-03, Laura Creighton wrote: > >> https://bugs.launchpad.net/ubuntu/+source/linux-lts-trusty/+bug/1501345 >> seems to be about a whole lot of serial ports to me, not just FTDI > >We just ran into the OP's problem where I work: Ununtu kernel updated >and all serial ports stopped working (it isn't just an FTDI problem). > >Booting with the previous kernel makes the serial ports work again. > >What I'm trying to figure out: is this something _Ubuntu_ did so that >only affects Ubuntu kernels? [I haven't seen it mentioned on the >linux-serial mailing list, and nobody other than Ubuntu users seem to >have the problem, so I think the answer to my question is "yes".] > >-- >Grant Edwards grant.b.edwards Yow! Am I SHOPLIFTING? > at > gmail.com Upstream from ubuntu is debian. I am running debian unstable. I did a kernel update, all my serial ports work fine, but since I don't have a simple script to test if I have the problem, I cannot swear for certain ubuntu did it ... Laura From kilgore661 at gmail.com Tue Oct 6 18:39:19 2015 From: kilgore661 at gmail.com (Ben Thompson) Date: Tue, 6 Oct 2015 23:39:19 +0100 Subject: Windows 32-bit Python 3.5 Install Failure Message-ID: <56144D97.8080209@gmail.com> Hi, I just tried using the 32-bit Python 3.5 installer for Windows from python.org. The program seemed to run OK, I ticked the path box but there seems to be no working python 3.5 on my (32-bit, XP) computer. The screenshot shows that python 2.7 is still installed, path contains Python 3 (albeit it a weird place) but if I give the full path to what I assume is the Python 3.5 binary, I get a window telling me that the program is not a valid application. My guess is that what is advertised as a 32-binary installer actually installed a 64-bit version (because the error message described above is what I get if I try and run a 64-bit binary). To check that I had not accidentally downloaded the wrong installer I checked: I downloaded and ran python-3.5.0.exe not python-3.5.0-amd64.exe. -------------- next part -------------- A non-text attachment was scrubbed... Name: pos.png Type: image/png Size: 279114 bytes Desc: not available URL: From __peter__ at web.de Tue Oct 6 18:55:03 2015 From: __peter__ at web.de (Peter Otten) Date: Wed, 07 Oct 2015 00:55:03 +0200 Subject: Python 2 =?UTF-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode References: <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> <201510061248.t96CmCWP011700@fido.openend.se> <85si5nzo6y.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: >> I don't think this is possible with the print statement, but the >> print() function can be replaced with anything you like: > > > Hmm. I am more looking for something that doesn't involve replacing > ?print?, but rather to hook into whatever it uses to coerce the type of > its arguments. Have a look at PyFile_WriteObject in Objects/fileobject.c. As I understand the code it basically does if isinstance(obj) and stream.encoding is not None: s = obj.encode(stream.encoding)) else: s = str(obj) stream.write(s) There's no way to get the original object. From tjreedy at udel.edu Tue Oct 6 19:07:24 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 6 Oct 2015 19:07:24 -0400 Subject: =?UTF-8?Q?Re:_Python_2_=e2=80=98print=e2=80=99=2c_coercing_argument?= =?UTF-8?Q?s_to_Unicode?= In-Reply-To: <85wpv0z368.fsf@benfinney.id.au> References: <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> Message-ID: On 10/6/2015 6:45 AM, Ben Finney wrote: > Ben Finney writes: > How can I convince ?print?, everywhere throughout a module, that it > should coerce its arguments using ?unicode?? Use Python 3. I am only half joking. Switching to unicode instead of bytes as the default text type fixed numerous bugs all at once. -- Terry Jan Reedy From tjreedy at udel.edu Tue Oct 6 19:11:42 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 6 Oct 2015 19:11:42 -0400 Subject: Trouble running In-Reply-To: References: Message-ID: On 10/6/2015 10:56 AM, John Gordon wrote: > In =?utf-8?Q?Cameroni123_=E2=84=A2?= writes: > >> Hi I have recently installed python on windows 10 and I'm trying to >> save in order to run the module and I cant I don't know why, could >> you please help? >> Cameron Which version of Python. How installed. > We need more details to help you. > > What program are you using to try to save? Is it a text editor? > > What happens when you try to save? How do you know it didn't work? > Do you get an error message? If you are using IDLE, to see errors messages, run it from Command Prompt window with 'python -m idlelib' or perhaps 'py -3.y -m idlelib' (replacing 'y' with the appropriate number) or 'py -2.7 -m idlelib.idle'. -- Terry Jan Reedy From ben+python at benfinney.id.au Tue Oct 6 19:23:16 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 07 Oct 2015 10:23:16 +1100 Subject: Python 2 =?utf-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode References: <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> <201510061248.t96CmCWP011700@fido.openend.se> <85si5nzo6y.fsf@benfinney.id.au> Message-ID: <8537xnzimz.fsf@benfinney.id.au> Peter Otten <__peter__ at web.de> writes: > Have a look at PyFile_WriteObject in Objects/fileobject.c. > As I understand the code it basically does > > if isinstance(obj) and stream.encoding is not None: > s = obj.encode(stream.encoding)) > else: > s = str(obj) > stream.write(s) So as I understand it I'm looking for the hypothetical from __future__ import print_coerce_args_to_unicode and without that, I'm stuck with the hard-coded ?str? coercion. Thanks, at least now I can stop flailing to try to get it working. -- \ ?Fear him, which after he hath killed hath power to cast into | `\ hell; yea, I say unto you, Fear him.? ?Jesus, as quoted in Luke | _o__) 12:5 | Ben Finney From ben+python at benfinney.id.au Tue Oct 6 19:24:23 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 07 Oct 2015 10:24:23 +1100 Subject: Python 2 =?utf-8?B?4oCYcHJpbnTigJks?= coercing arguments to Unicode References: <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> Message-ID: <85y4ffy40o.fsf@benfinney.id.au> Terry Reedy writes: > On 10/6/2015 6:45 AM, Ben Finney wrote: > > Ben Finney writes: > > > How can I convince ?print?, everywhere throughout a module, that it > > should coerce its arguments using ?unicode?? > > Use Python 3. I am only half joking. Switching to unicode instead > of bytes as the default text type fixed numerous bugs all at once. This is all part of a transition to Python 3, so I am fully on board with that. It doesn't help address the problem to tell me I want to do what I'm already in pursuit of doing :-) -- \ ?Intellectual property is to the 21st century what the slave | `\ trade was to the 16th.? ?David Mertz | _o__) | Ben Finney From vaporbleep at gmail.com Tue Oct 6 21:03:47 2015 From: vaporbleep at gmail.com (vaporbleep at gmail.com) Date: Tue, 6 Oct 2015 18:03:47 -0700 (PDT) Subject: building Demo/embed on Mac OS 10.10 from source: configure args? Message-ID: <84de50e1-b641-4558-a53b-1436b50b91d6@googlegroups.com> I'm trying to build the embedding demo (Demo/embed in the source directory) After configuring with $ ./configure --enable-framework MACOSX_DEPLOYMENT_TARGET=10.10 And calling "make" in the root source directory to build python.exe I then change directory to Demo/embed and edit LIBS and LDFLAGS in Demo/embed (per instructions in Makefile) Now I can make the "demo" $ make demo gcc -g -I../../Include -I../.. -c -o demo.o demo.c demo.c:7:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] main(int argc, char **argv) ^ 1 warning generated. gcc demo.o ../../libpython2.7.a -ldl -framework CoreFoundation -lm -o demo But when I try to run it, $ ./demo Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] ImportError: No module named site Mac OS X Version 10.10.5 MacBook Pro Not sure what is going on here / what the problem is My goal is to change the Python commands in demo.c to a simple script to put up the pyglet Hello, World: http://pyglet-current.readthedocs.org/en/latest/programming_guide/quickstart.html When I run the file Python source distribution 2.7.10 Is anyone else finding it impossible to get Demo/embed to run on a Mac? From chalao.adda at gmail.com Tue Oct 6 23:02:07 2015 From: chalao.adda at gmail.com (Jaydip Chakrabarty) Date: Wed, 7 Oct 2015 03:02:07 +0000 (UTC) Subject: Finding Blank Columns in CSV References: <20151005090652.1c9faed7@bigbox.christie.dr> <56141208.1070903@mrabarnett.plus.com> Message-ID: On Tue, 06 Oct 2015 19:25:12 +0100, MRAB wrote: > On 2015-10-06 18:23, Jaydip Chakrabarty wrote: >> On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote: >> > [snip] >> >> I downloaded gmail contacts in google csv format. There are so many >> columns. So I was trying to create another csv with the required >> columns. >> Now when I tried to open the gmail csv file with csv DictReader, it >> said the file contained NULL characters. > > Why would there be nulls in a CSV file? > >> So first I did - >> >> data = open(fn, 'rb').read() >> fout = open(ofn, 'wb') >> fout.write(data.replace('\x00', '')) >> fout.close() >> shutil.move(ofn, fn) >> >> Then I found, there were some special characters in the file. So, once >> again I opened the file and did - >> >> data = open(fn, 'rb').read() >> fout = open(ofn, 'wb') >> fout.write(data.replace('\xff\xfe', '')) >> fout.close() >> shutil.move(ofn, fn) >> > b'\xff\xfe' looks like a BOM. > > If it's at the start of the file, it indicates that the file is encoded > in 'UTF16-LE'. > > So, apparently, the original file was CSV encoded in 'UTF16-LE'. > > You _do_ still have the original file, don't you? > > [snip] Yes, I am having it. Thanks. From harirammanohar159 at gmail.com Tue Oct 6 23:47:58 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Tue, 6 Oct 2015 20:47:58 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. please respond...actually i am in need of this multiprocessing.. From 4kir4.1i at gmail.com Wed Oct 7 02:47:12 2015 From: 4kir4.1i at gmail.com (Akira Li) Date: Wed, 07 Oct 2015 09:47:12 +0300 Subject: threading bug in strptime References: Message-ID: <87zizvyy33.fsf@gmail.com> Larry Martell writes: > We have been trying to figure out an intermittent problem where a > thread would fail with this: > > AttributeError: 'module' object has no attribute '_strptime' > > Even though we were importing datetime. After much banging our heads > against the wall, we found this: > > http://code-trick.com/python-bug-attribute-error-_strptime/ > > The workaround suggested there, to call strptime before starting your > threads, seems to have fixed the issue. > > I thought I'd mention it here in case anyone else is facing this. I can reproduce it in Python 2 (but not in Python 3) even with *threading* module: #!/usr/bin/env python import threading import time for _ in range(10): threading.Thread(target=time.strptime, args=("2013-06-02", "%Y-%m-%d")).start() Don't use *thread* directly (it is even renamed to *_thread* in Python 3, to discourage an unintended usage), use *threading* module instead. In Python 3.3+, PyImport_ImportModuleNoBlock() is deprecated https://bugs.python.org/issue9260 From rosuav at gmail.com Wed Oct 7 03:32:29 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 7 Oct 2015 18:32:29 +1100 Subject: Windows 32-bit Python 3.5 Install Failure In-Reply-To: <56144D97.8080209@gmail.com> References: <56144D97.8080209@gmail.com> Message-ID: On Wed, Oct 7, 2015 at 9:39 AM, Ben Thompson wrote: > My guess is that what is advertised as a 32-binary installer actually > installed a 64-bit version (because the error message described above is > what I get if I try and run a 64-bit binary). To check that I had not > accidentally downloaded the wrong installer I checked: I downloaded and ran > python-3.5.0.exe not python-3.5.0-amd64.exe. Actually, the problem is that Windows XP can't handle Python 3.5. You should be able to use 3.4, or alternatively, upgrade to Windows 7/8/10 (or Xubuntu or anything else...). There's an open tracker issue to make the message a bit clearer: http://bugs.python.org/issue25143 but ultimately, this isn't going to be supported, ever. ChrisA From rosuav at gmail.com Wed Oct 7 03:33:50 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 7 Oct 2015 18:33:50 +1100 Subject: Just installed python and it says python34.dll is missing In-Reply-To: References: Message-ID: On Wed, Oct 7, 2015 at 2:39 AM, Lisa Twede wrote: > > I tried re-downloading python and it gave me an option to repair, so I tried that. But it still throws the same error. > > > > I downloaded Python 3.5.0 for Windows. Exactly what did you install, on what system, and what's throwing the error? From the sound of things, something's looking for Python 3.4, but you have 3.5 installed. ChrisA From __peter__ at web.de Wed Oct 7 03:49:39 2015 From: __peter__ at web.de (Peter Otten) Date: Wed, 07 Oct 2015 09:49:39 +0200 Subject: Finding Blank Columns in CSV References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: Peter Otten wrote: > I really meant it when I asked you to post the code you actually ran, and > the traceback it produces. Anyway, here's a complete script that should work. It uses indices instead names, but the underlying logic is the same. #!/usr/bin/env python import csv import sys from contextlib import contextmanager if sys.version_info.major == 3: READ_MODE = "r" WRITE_MODE = "w" else: READ_MODE = "rb" WRITE_MODE = "wb" @contextmanager def ext_open(file, mode): """Open a file if passed a string, pass on everything else unchanged. "-", b"-", and None indicate stdin or stdout depending on `mode`. >>> with ext_open(None, "w") as f: ... print("foo", file=f) foo >>> with ext_open(["one\\n", "two\\n"], "r") as f: ... for line in f: print(line, end="") one two """ if file is None or file == "-" or file == b"-": yield sys.stdout if "w" in mode else sys.stdin elif isinstance(file, (str, bytes)): with open(file, mode) as stream: yield stream else: yield file def non_empty_columns(infile): """Find indices of columns that contain data. Doesn't check the first row assumed to contain the fieldnames. """ with ext_open(infile, READ_MODE) as instream: reader = csv.reader(instream) colcount = len(next(reader)) empty_columns = set(range(colcount)) for row in reader: assert len(row) == colcount empty_columns = {i for i in empty_columns if not row[i]} if not empty_columns: break return [i for i in range(colcount) if i not in empty_columns] def copy_csv(infile, outfile, columns): """Copy the specified columns from infile to outfile. """ with ext_open(infile, READ_MODE) as instream: with ext_open(outfile, WRITE_MODE) as outstream: reader = csv.reader(instream) writer = csv.writer(outstream) for row in reader: writer.writerow([row[i] for i in columns]) def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument("infile", nargs="?", default=sys.stdin) parser.add_argument("outfile", nargs="?", default=sys.stdout) args = parser.parse_args() if args.infile is sys.stdin or args.infile == "-": args.infile = list(sys.stdin) copy_csv( args.infile, args.outfile, columns=non_empty_columns(args.infile)) if __name__ == "__main__": main() From df at see.replyto.invalid Wed Oct 7 04:29:42 2015 From: df at see.replyto.invalid (Dave Farrance) Date: Wed, 07 Oct 2015 09:29:42 +0100 Subject: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic References: Message-ID: Rob Gaddi wrote: >So, this is odd. I'm running Ubuntu 14.04, and my system did a kernel >upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic. >And pyserial (2.7, installed through pip) stopped working. When KDE's "Plasma 5" appeared with Kubuntu 15.04, I found it to be too new and have too many dysfunctions, so I reverted to Kubuntu 14.04 LTS. Now this problem. Looking at the Ubuntu 14.04 repository, I found that it contained a backported version of the kernel used in 15.04. So... Remove "meta" packages that have latest 3.13 kernel as dependencies: sudo apt-get purge linux-generic linux-signed-generic Install meta packages that pull in the latest 3.19 kernel: sudo apt-get install linux-generic-lts-vivid linux-signed-generic-lts-vivid Serial now works fine. The later kernel introduces no functional changes in (K)ubuntu 14.04 that I can discern. I presume that since it is a "backported" version of the 3.19 kernel, that its video drivers have been matched to Ubuntu 14.04's version of X.Org, and so on. Anyway, that's what works for me. I could've put a "hold" on the 3.13.0-63 kernel, but this seems a better fix. From harirammanohar159 at gmail.com Wed Oct 7 05:24:35 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Wed, 7 Oct 2015 02:24:35 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <202cb5a5-0915-4170-a938-bded0c4a7b4a@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. how to handle this ? any one pls help... From cl at isbd.net Wed Oct 7 05:38:37 2015 From: cl at isbd.net (cl at isbd.net) Date: Wed, 7 Oct 2015 10:38:37 +0100 Subject: Hiding code from intruders, a different slant on an old question Message-ID: I know questions similar to this are often asked but my reasons for wanting to do this (and thus ways it can be done) are slightly different. I have a number of little utility scripts (python and others) which I use to automate the process of decrypting and displaying things like files containing passwords. The encryption I use is reasonably secure anyway but I'd like to hide the programs/methods I use so that:- 1 - The encrypted files are not identifiable as encrypted data (the file command just returns 'data' so they can't be identified by that). If there's a script in my ~/bin directory that relates directly to the files it's obvious they're encrypted. 2 - The method used for encryption isn't obvious, again an obvious script will show the program I have used. I *could* write a C program which just exec()'s the required programs, if they're done separately this would be fairly well hidden but I was wondering if there's anything more obvious I can do that enables me to do things easily in Python. This is for protecting against any possible intruder who has gained access to my system by breaking an ssh password or stealing my laptop for example. It's *not* for hiding code that I'm giving to others, I'd be quite happy to give the code in question to people who might want to use it. -- Chris Green ? From lac at openend.se Wed Oct 7 05:48:44 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 07 Oct 2015 11:48:44 +0200 Subject: Windows 32-bit Python 3.5 Install Failure In-Reply-To: <56144D97.8080209@gmail.com> References: <56144D97.8080209@gmail.com> Message-ID: <201510070948.t979milG008737@fido.openend.se> In a message of Tue, 06 Oct 2015 23:39:19 +0100, Ben Thompson writes: >Hi, > >I just tried using the 32-bit Python 3.5 installer for Windows from >python.org. The program seemed to run OK, I ticked the path box but >there seems to be no working python 3.5 on my (32-bit, XP) computer. The >screenshot shows that python 2.7 is still installed, path contains >Python 3 (albeit it a weird place) but if I give the full path to what I >assume is the Python 3.5 binary, I get a window telling me that the >program is not a valid application. > >My guess is that what is advertised as a 32-binary installer actually >installed a 64-bit version (because the error message described above is >what I get if I try and run a 64-bit binary). To check that I had not >accidentally downloaded the wrong installer I checked: I downloaded and >ran python-3.5.0.exe not python-3.5.0-amd64.exe. Your problem is that 3.5 does not run on XP at all. There is a bug fix going in to tell XP users this when they try to install 3.5 and later. python.org has given up support of XP for 3.5 and later releases. Laura From gandalf at shopzeus.com Wed Oct 7 06:39:29 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Wed, 7 Oct 2015 12:39:29 +0200 Subject: certifi or tornadoweb broken? What is happening here? Message-ID: <5614F661.6000306@shopzeus.com> Here is an MWE: import certifi import tornado.ioloop import tornado.httpclient io_loop = tornado.ioloop.IOLoop.current() def test(): global io_loop url = "https://www.saaspass.com/sd/rest/applications/xxxxxxxxxxxxxxxxx/tokens?password=xxxxxxxxxxxxxxxxx" # Just a test application! http_client = tornado.httpclient.HTTPClient() request = tornado.httpclient.HTTPRequest(url = url, method = "GET", ca_certs=certifi.where()) response = http_client.fetch(request) print(response.body) print("Certifi version:",certifi.__version__) io_loop.add_callback(test) io_loop.start() # forgive me, will never stop, but this is just a test Here is what happens on Windows 7: c:\Temp\aaa>py -3 test.py Certifi version: 2015.09.06.2 ERROR:tornado.application:Exception in callback functools.partial(.null_wrapper at 0x00000000033AC598>) Traceback (most recent call last): File "C:\Python35\lib\site-packages\tornado\ioloop.py", line 592, in _run_call back ret = callback() File "C:\Python35\lib\site-packages\tornado\stack_context.py", line 275, in nu ll_wrapper return fn(*args, **kwargs) File "test.py", line 12, in test response = http_client.fetch(request) File "C:\Python35\lib\site-packages\tornado\httpclient.py", line 102, in fetch self._async_client.fetch, request, **kwargs)) File "C:\Python35\lib\site-packages\tornado\ioloop.py", line 445, in run_sync return future_cell[0].result() File "C:\Python35\lib\site-packages\tornado\concurrent.py", line 215, in resul t raise_exc_info(self._exc_info) File "", line 3, in raise_exc_info tornado.httpclient.HTTPError: HTTP 400: Bad Request And here is what happens on Ubuntu: test at vps014:~$ python3 test.py Certifi version: 2015.09.06.2 WARNING:tornado.general:SSL Error on 9 ('104.154.49.147', 443): [Errno 1] _ssl.c:392: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed ERROR:tornado.application:Exception in callback functools.partial() Traceback (most recent call last): File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/ioloop.py", line 592, in _run_callback ret = callback() File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/stack_context.py", line 275, in null_wrapper return fn(*args, **kwargs) File "test.py", line 12, in test response = http_client.fetch(request) File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/httpclient.py", line 102, in fetch self._async_client.fetch, request, **kwargs)) File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/ioloop.py", line 445, in run_sync return future_cell[0].result() File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/concurrent.py", line 215, in result raise_exc_info(self._exc_info) File "", line 3, in raise_exc_info File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/stack_context.py", line 314, in wrapped ret = fn(*args, **kwargs) File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/gen.py", line 212, in future, lambda future: callback(future.result())) File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/concurrent.py", line 215, in result raise_exc_info(self._exc_info) File "", line 3, in raise_exc_info File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/gen.py", line 876, in run yielded = self.gen.throw(*exc_info) File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/tcpclient.py", line 174, in connect server_hostname=host) File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/gen.py", line 870, in run value = future.result() File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/concurrent.py", line 215, in result raise_exc_info(self._exc_info) File "", line 3, in raise_exc_info File "/usr/local/lib/python3.2/dist-packages/tornado-4.2.1-py3.2-linux-x86_64.egg/tornado/iostream.py", line 1243, in _do_ssl_handshake self.socket.do_handshake() File "/usr/lib/python3.2/ssl.py", line 458, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [Errno 1] _ssl.c:392: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed The certifi package has the very same version on both systems. I have compared the cacert.pem file provided by certifi on both systems and they are identical. The URL is also identical. What is happening here? How it is possible that the Ubuntu system gives an SSL handshake error, but the Windows system does the SSL handshake - using the same CA cert list? Thanks Laszlo From chalao.adda at gmail.com Wed Oct 7 07:56:18 2015 From: chalao.adda at gmail.com (Jaydip Chakrabarty) Date: Wed, 7 Oct 2015 11:56:18 +0000 (UTC) Subject: Finding Blank Columns in CSV References: <20151005090652.1c9faed7@bigbox.christie.dr> Message-ID: On Tue, 06 Oct 2015 20:20:40 +0200, Peter Otten wrote: > Jaydip Chakrabarty wrote: > >> On Tue, 06 Oct 2015 14:33:51 +0200, Peter Otten wrote: >> >>> Jaydip Chakrabarty wrote: >>> >>>> On Tue, 06 Oct 2015 01:34:17 +1100, Chris Angelico wrote: >>>> >>>>> On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase >>>>> wrote: >>>>>> That way, if you determine by line 3 that your million-row CSV file >>>>>> has no blank columns, you can get away with not processing all >>>>>> million rows. >>>>> >>>>> Sure, although that effectively means the entire job is moot. I >>>>> kinda assume that the OP knows that there are some blank columns >>>>> (maybe lots of them). The extra check is unnecessary unless it's >>>>> actually plausible that there'll be no blanks whatsoever. >>>>> >>>>> Incidentally, you have an ordered_headers list which is the blank >>>>> columns in order; I think the OP was looking for a list of the >>>>> _non_blank columns. But that's a trivial difference, easy to tweak. >>>>> >>>>> ChrisA >>>> >>>> Thanks to you all. I got it this far. But while writing back to >>>> another csv file, I got this error - "ValueError: dict contains >>>> fields not in fieldnames: None". Here is my code. >>>> >>>> rdr = csv.DictReader(fin, delimiter=',') >>>> header_set = set(rdr.fieldnames) >>>> for r in rdr: >>>> header_set = set(h for h in header_set if not r[h]) >>>> if not header_set: >>>> break >>>> >>>> for r in rdr: >>>> data = list(r[i] for i in header_set) >>>> >>>> dw = csv.DictWriter(fout, header_set) >>>> dw.writeheader() >>>> dw.writerows(data) >>> >>> Sorry, this is not the code you ran. I could guess what the missing >>> parts might be, but it is easier for both sides if you provide a small >>> script that actually can be executed and a small dataset that shows >>> the behaviour you describe. Then post the session and especially the >>> traceback. Example: >>> >>> $ cat my_data.csv 0 $ cat my_code.py print >>> 1/int(open("my_data.csv").read()) >>> $ python my_code.py Traceback (most recent call last): >>> File "my_code.py", line 1, in >>> print 1/int(open("my_data.csv").read()) >>> ZeroDivisionError: integer division or modulo by zero >>> >>> Don't retype, use cut and paste. Thank you. >> >> I downloaded gmail contacts in google csv format. There are so many >> columns. So I was trying to create another csv with the required >> columns. >> Now when I tried to open the gmail csv file with csv DictReader, it >> said the file contained NULL characters. >> So first I did - >> >> data = open(fn, 'rb').read() >> fout = open(ofn, 'wb') >> fout.write(data.replace('\x00', '')) >> fout.close() >> shutil.move(ofn, fn) >> >> Then I found, there were some special characters in the file. So, once >> again I opened the file and did - >> >> data = open(fn, 'rb').read() >> fout = open(ofn, 'wb') >> fout.write(data.replace('\xff\xfe', '')) >> fout.close() >> shutil.move(ofn, fn) > > Uh this looks like the file is in UTF-16. Use > > import codecs fn = ... > ofn = ... > with codecs.open(fn, encoding="utf-16") as f: > with codecs.open(ofn, "w", encoding="utf-8") as g: > g.writelines(f) > ... > > to convert it to UTF-8 which is compatible with the csv module of Python > 2. > >> Now it seemed right. > > Only if all characters are encodable as iso-8859-1. > >> So I started to remove empty columns. >> >> fin = open(fn, 'rb') >> fout = open(ofn, 'wb') >> >> rdr = csv.DictReader(fin, delimiter=',') >> flds = rdr.fieldnames header_set = set(rdr.fieldnames) >> for r in rdr: >> header_set = set(h for h in header_set if not r[h]) >> if not header_set: >> break >> for r in rdr: >> data = list(r[i] for i in header_set) >> >> dw = csv.DictWriter(fout, data[0].keys()) >> dw.writeheader() >> dw.writerows(data) >> >> fin.close() >> fout.close() >> >> But, I am getting error at dw.writerows(data). I put the whole code >> here. >> Please help. > > I really meant it when I asked you to post the code you actually ran, > and the traceback it produces. > > When I fill in the blanks by guessing > > $ cat in.csv one,two,three foo,, > bar,,baz $ cat remove_empty_colums.py import csv fn = "in.csv" > ofn = "out.csv" > > fin = open(fn, 'rb') > fout = open(ofn, 'wb') > > rdr = csv.DictReader(fin, delimiter=',') > flds = rdr.fieldnames header_set = set(rdr.fieldnames) > for r in rdr: > header_set = set(h for h in header_set if not r[h]) > if not header_set: > break > for r in rdr: > data = list(r[i] for i in header_set) > > dw = csv.DictWriter(fout, data[0].keys()) > dw.writeheader() > dw.writerows(data) > > fin.close() > fout.close() > > and then run the resulting script I get > > $ python remove_empty_colums.py Traceback (most recent call last): > File "remove_empty_colums.py", line 18, in > dw = csv.DictWriter(fout, data[0].keys()) > NameError: name 'data' is not defined > > So this is my traceback, and while the NameError is trivial to fix > (reopen the file or do a seek) but not sufficient to make the script do > what you want it doesn't seem to be the problem you ran into. > So you have a different script. I'd really like to see it, and the > traceback it produces. Yes, that is so. Thank you all for the help. Thanks. From tyler at tysdomain.com Wed Oct 7 08:00:26 2015 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 07 Oct 2015 08:00:26 -0400 Subject: Hiding code from intruders, a different slant on an old question In-Reply-To: References: Message-ID: <5615095A.1050006@tysdomain.com> On 10/7/2015 5:38 AM, cl at isbd.net wrote: > I know questions similar to this are often asked but my reasons for > wanting to do this (and thus ways it can be done) are slightly different. > > I have a number of little utility scripts (python and others) which I > use to automate the process of decrypting and displaying things like > files containing passwords. > > The encryption I use is reasonably secure anyway but I'd like to hide > the programs/methods I use so that:- > > 1 - The encrypted files are not identifiable as encrypted data (the file > command just returns 'data' so they can't be identified by that). If > there's a script in my ~/bin directory that relates directly to the > files it's obvious they're encrypted. > > 2 - The method used for encryption isn't obvious, again an obvious > script will show the program I have used. > You have two options here: 1) Use a strong encryption like aes256 etc and don't bother trying to "hide" the code because it's just a blob of data and they'll not crack it. 2) Encrypt the whole drive if you use something like *nix/*bsd. The only thing hiding the code will do is make them guess at the method. But if you use a good method in the firstplace, you shouldn't have any issues because it's not going to be cracked. > I *could* write a C program which just exec()'s the required programs, > if they're done separately this would be fairly well hidden but I was > wondering if there's anything more obvious I can do that enables me to > do things easily in Python. > > > This is for protecting against any possible intruder who has gained > access to my system by breaking an ssh password or stealing my laptop > for example. It's *not* for hiding code that I'm giving to others, > I'd be quite happy to give the code in question to people who might > want to use it. > -- Take care, Ty http://tds-solutions.net He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave. From alister.nospam.ware at ntlworld.com Wed Oct 7 09:05:07 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Wed, 7 Oct 2015 13:05:07 +0000 (UTC) Subject: Hiding code from intruders, a different slant on an old question References: Message-ID: On Wed, 07 Oct 2015 10:38:37 +0100, cl wrote: > I know questions similar to this are often asked but my reasons for > wanting to do this (and thus ways it can be done) are slightly > different. > > I have a number of little utility scripts (python and others) which I > use to automate the process of decrypting and displaying things like > files containing passwords. > > The encryption I use is reasonably secure anyway but I'd like to hide > the programs/methods I use so that:- > > 1 - The encrypted files are not identifiable as encrypted data (the file > command just returns 'data' so they can't be identified by that). If > there's a script in my ~/bin directory that relates directly to the > files it's obvious they're encrypted. > > 2 - The method used for encryption isn't obvious, again an obvious > script will show the program I have used. > > > I *could* write a C program which just exec()'s the required programs, > if they're done separately this would be fairly well hidden but I was > wondering if there's anything more obvious I can do that enables me to > do things easily in Python. > > > This is for protecting against any possible intruder who has gained > access to my system by breaking an ssh password or stealing my laptop > for example. It's *not* for hiding code that I'm giving to others, > I'd be quite happy to give the code in question to people who might want > to use it. The general rule with all forms of encryption is that the method is not secret. it is the key that needs to be kept secret. in the same way that the mechanical principles of the lock on your front door are public knowledge, the profile of the key itself (which is needed to unlock the door) is unknown. Example: With a simple Cesar the method is "shift the alphabet by 'X' characters and X is the key if the key is unknown then the attacker still has to brute force the method (admittedly with only 25 options this is not difficult) -- Down with categorical imperative! From gall.pavgal.gall at gmail.com Wed Oct 7 10:13:11 2015 From: gall.pavgal.gall at gmail.com (gall.pavgal.gall at gmail.com) Date: Wed, 7 Oct 2015 07:13:11 -0700 (PDT) Subject: change data in large excel file(more than 240 000 rows on sheet) Message-ID: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> Hi Guys, I need to change data in large excel file(more than 240 000 rows on sheet), it's possible through win32com.client, but i need use Linux OS ... Please, could you advise some-thing suitable! best regards, Pavel. From breamoreboy at yahoo.co.uk Wed Oct 7 10:18:33 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 7 Oct 2015 15:18:33 +0100 Subject: change data in large excel file(more than 240 000 rows on sheet) In-Reply-To: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> References: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> Message-ID: On 07/10/2015 15:13, gall.pavgal.gall at gmail.com wrote: > Hi Guys, > I need to change data in large excel file(more than 240 000 rows on sheet), it's possible through win32com.client, but i need use Linux OS ... > Please, could you advise some-thing suitable! > > best regards, Pavel. > http://www.python-excel.org/ -- 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 Wed Oct 7 12:05:08 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Wed, 7 Oct 2015 16:05:08 +0000 (UTC) Subject: Trouble running References: Message-ID: On Mon, 05 Oct 2015 19:06:04 +0100, Cameroni123 ? wrote: > Hi I have recently installed python on windows 10 and I?m trying to save > in order to run the module and I cant I don?t know why, could you please > help? Based on the comprehensive problem description I have waved my magic wand. It should work now. If it still doesn't work, please provide more details about the problem. -- Denis McMahon, denismfmcmahon at gmail.com From emile at fenx.com Wed Oct 7 12:58:45 2015 From: emile at fenx.com (Emile van Sebille) Date: Wed, 7 Oct 2015 09:58:45 -0700 Subject: reg multiple login python In-Reply-To: <202cb5a5-0915-4170-a938-bded0c4a7b4a@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> <202cb5a5-0915-4170-a938-bded0c4a7b4a@googlegroups.com> Message-ID: On 10/7/2015 2:24 AM, harirammanohar159 at gmail.com wrote: > On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: >> Hi All, >> >> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. >> >> Thanks in advance. > > how to handle this ? any one pls help... > the best you're likely to do to get them running near simultaneously is to launch a detached process for each request. you could adapt your current for loop to do so. emile From lac at openend.se Wed Oct 7 16:06:47 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 07 Oct 2015 22:06:47 +0200 Subject: certifi or tornadoweb broken? What is happening here? In-Reply-To: <5614F661.6000306@shopzeus.com> References: <5614F661.6000306@shopzeus.com> Message-ID: <201510072006.t97K6lZK022387@fido.openend.se> There is discussion here about problems with ubuntu certificate handling. https://bugs.python.org/issue23476, with links to ubuntu bugs that you should read. No promises that this is your bug, but seems possible. Laura From joel.goldstick at gmail.com Wed Oct 7 17:04:10 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Wed, 7 Oct 2015 17:04:10 -0400 Subject: change data in large excel file(more than 240 000 rows on sheet) In-Reply-To: References: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> Message-ID: On Wed, Oct 7, 2015 at 10:18 AM, Mark Lawrence wrote: > On 07/10/2015 15:13, gall.pavgal.gall at gmail.com wrote: > >> Hi Guys, >> I need to change data in large excel file(more than 240 000 rows on >> sheet), it's possible through win32com.client, but i need use Linux OS ... >> Please, could you advise some-thing suitable! >> >> best regards, Pavel. >> >> > http://www.python-excel.org/ > > -- > 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 > I agree with Mark's link. Is there any reason why you can't get these files as csv? That would also simplify things -- Joel Goldstick http://joelgoldstick.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From gheskett at wdtv.com Wed Oct 7 17:28:40 2015 From: gheskett at wdtv.com (Gene Heskett) Date: Wed, 7 Oct 2015 17:28:40 -0400 Subject: Trouble running In-Reply-To: References: Message-ID: <201510071728.40128.gheskett@wdtv.com> On Wednesday 07 October 2015 12:05:08 Denis McMahon wrote: > On Mon, 05 Oct 2015 19:06:04 +0100, Cameroni123 ? wrote: > > Hi I have recently installed python on windows 10 and I?m trying to > > save in order to run the module and I cant I don?t know why, could > > you please help? > > Based on the comprehensive problem description I have waved my magic > wand. It should work now. If it still doesn't work, please provide > more details about the problem. > > -- > Denis McMahon, denismfmcmahon at gmail.com You are a piece of work Dennis, love it. ;-) 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 halim.rz99 at gmail.com Wed Oct 7 22:32:52 2015 From: halim.rz99 at gmail.com (halim hamadi) Date: Wed, 7 Oct 2015 19:32:52 -0700 (PDT) Subject: error installation GR python Message-ID: <385cc7c3-a51f-4bb7-b349-130e4d874c52@googlegroups.com> I want to install GR plot in python using pip, but I receive an error when installing GR. Collecting gr Using cached gr-0.16.0.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 20, in File "C:\Users\HALIMH~1\AppData\Local\Temp\pip-build-vhpiefs2\gr\setup.py", line 200, in class check_ext(Command, build_static): TypeError: Cannot create a consistent method resolution order (MRO) for bases build_static, Command Can anyone help please? Thank you. From breamoreboy at yahoo.co.uk Thu Oct 8 00:54:39 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 8 Oct 2015 05:54:39 +0100 Subject: error installation GR python In-Reply-To: <385cc7c3-a51f-4bb7-b349-130e4d874c52@googlegroups.com> References: <385cc7c3-a51f-4bb7-b349-130e4d874c52@googlegroups.com> Message-ID: On 08/10/2015 03:32, halim hamadi wrote: > > I want to install GR plot in python using pip, but I receive an error when installing GR. > > Collecting gr > Using cached gr-0.16.0.tar.gz > Complete output from command python setup.py egg_info: > Traceback (most recent call last): > File "", line 20, in > File "C:\Users\HALIMH~1\AppData\Local\Temp\pip-build-vhpiefs2\gr\setup.py", line 200, in > class check_ext(Command, build_static): > TypeError: Cannot create a consistent method resolution > order (MRO) for bases build_static, Command > > Can anyone help please? > > Thank you. > I can reproduce the above with 3.3, 3.4 and 3.5 whereas 2.7 gives the infamous "Unable to find vcvarsall.bat". That plus taking a look at pypi leads to the conclusion is that it's Python 2 only. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From anthony at cajuntechie.org Thu Oct 8 01:15:26 2015 From: anthony at cajuntechie.org (Anthony Papillion) Date: Thu, 08 Oct 2015 00:15:26 -0500 Subject: Is there a Windows Python SIG? Message-ID: <4e05bb75-f6a5-4eeb-9161-e5ab3a49461f@email.android.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Over the next few months, I'll be working on a project using Python on Microsoft Windows. While I'm doing this project, I'd also like to contribute in any way I can to making Python in Windows better. Does anyone know if there is a Windows SIG? I went to the Python website where I thought I'd seen one but it doesn't seem to be there now. Any thoughts? Anthony - -- Phone: +1.845.666.3312 Skype: CajunTechie SIP/VoIP: 17772471988 at in.callcentric.com PGP Key: 0x53B04B15 Fingerprint: C5CE E687 DDC2 D12B 9063 56EA 028A DF74 53B0 4B15 -----BEGIN PGP SIGNATURE----- Version: APG v1.1.1 iQJJBAEBCgAzBQJWFfvuLBxBbnRob255IFBhcGlsbGlvbiA8YW50aG9ueUBjYWp1 bnRlY2hpZS5vcmc+AAoJEAKK33RTsEsVWbQP+wQesUBBum1FvswZqav3HnSDxKJ0 tkytRhaXCEtAwK5OShYyK9ktxUb7P3gCKCZix30UegtW9RcXqvqSCq/aWqKCtV0Q yqV8Jcr0cuinIMWLLIEWNZolERStMr2U2HVL0tAXvVwYqvAqfEbWm+akSFbAy+s4 J2ta3gnynD5jIkh0BlLFOBxqg06EbSY0pO8o0K1rEtSGBY2IjXElFwQnJ/IwvxHq x2a0SUGaGrlFCWoJ7agHIS0kZOZonn930U4QHdf1fLNWtQq8t9xy5qIV2PCn87m9 YxnZuWY+XuFO47Z5lS++lZFkwE9pu6PKjzusyZQ/BQlkh5QjtuJhjUSMA8ZaTPIO L3P3aun+cKNTEROMN95b4ygiVWljY6QVwGVxdcxbyudisIdnNaaG6+gtNJ7HKbgG BHH+3w/BQ2MdX5dhQrDBbBFLNcUBP2/HT470bf4UY8cXssB0ZfkOtMCxsKA5XP8U 8sZ2KHEMV7doD7SvHNgeg5PUwl+p98ymHgoSZqfq8W4A24Ltk8RvIQZjIOioEY1G kAzUyx06JjbcOlxGtP0Wk0+4v8NGzu2agWWQQgSHSaYpb4aOdoQ28ryYi7srd8gP vRYRpBYQhoAIClwcfaoO0pQnfnSf0V6lpnBJ3/gNCgW1F+RquvN285aD4BlPj3N+ MkwZBgzxIx4ybh17 =xqD0 -----END PGP SIGNATURE----- From rosuav at gmail.com Thu Oct 8 01:49:14 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 8 Oct 2015 16:49:14 +1100 Subject: Is there a Windows Python SIG? In-Reply-To: <4e05bb75-f6a5-4eeb-9161-e5ab3a49461f@email.android.com> References: <4e05bb75-f6a5-4eeb-9161-e5ab3a49461f@email.android.com> Message-ID: On Thu, Oct 8, 2015 at 4:15 PM, Anthony Papillion wrote: > Over the next few months, I'll be working on a project using Python on Microsoft Windows. While I'm doing this project, I'd also like to contribute in any way I can to making Python in Windows better. > > Does anyone know if there is a Windows SIG? I went to the Python website where I thought I'd seen one but it doesn't seem to be there now. Any thoughts? > Awesome! Contributors are always welcome. There's the python-win32 mailing list: https://mail.python.org/mailman/listinfo/python-win32 Also, search bugs.python.org for anything that interests you - often, an issue will languish because it can't be replicated, or because there aren't enough details to move forward with it. I use Linux everywhere, so for me to fire up a Windows VM and test something is extra effort (plus there's the question of whether the bug can even be replicated in that environment). You could help out enormously without any knowledge of Python's internals, or of C, or anything! ChrisA From davanand.bahall at gmail.com Thu Oct 8 02:24:35 2015 From: davanand.bahall at gmail.com (DBS) Date: Wed, 7 Oct 2015 23:24:35 -0700 (PDT) Subject: Access a class in another python script Message-ID: <58842c9a-cc17-4929-9fc6-16fff3a2ac5c@googlegroups.com> Hello, I'm using Python 3.5 and have two python scripts where one needs access to a class in the other script for authentication purposes. The scripts runs through GitHub to poll for all pull requests and pull requests that meet a certain condition. The call from the second script to the class and variables in the first script are working, but I'm getting prompted for credentials several times. I wrapped the credentials in a class and created an object in the second script to access the class so that I would not be prompted for credentials in the second script. I've include both scripts below. I'm still new to python, but I think it's how I'm calling the class or the import in the second script??? Thanks in advance for your time. main_en_pr script: #! /usr/bin/python import os import github3 from github3 import login, GitHub, authorize from getpass import getuser, getpass import requests import csv import configparser import sys import datetime import codecs sys.__stdout__ = codecs.getwriter('utf8')(sys.stdout) # Class to authenticate to GitHub class GitAuth: gh = None def authentication(self): try: user = input('GitHub username: ') except KeyboardInterrupt: user = getuser() password = getpass('GitHub token for {0}: '.format(user)) self.gh = login(user, password) return user # Assign the class to an object myobjectx = GitAuth() # Assign the variable user to the function inside the class user = myobjectx.authentication() # Read the contents of the config file to pull in the repo name config = configparser.ConfigParser() config.read('repo.ini') repo = config.get('repos', 'repo1') result = myobjectx.gh.repository(user, repo).pull_requests('open') # Define function to list all pull requests def list_all_prs(): # open csv file and create header rows with open('c:\\pull.csv', 'w+', newline='') as f: csv_writer = csv.writer(f) csv_writer.writerow(['Id', 'Login', 'Title', 'Commits', 'Changed Files']) # iterate through repo for pull requests based on criteria and output to csv file for pr in result: data = pr.as_dict() changes = (myobjectx.gh.repository(user, repo).pull_request(data['number'])).as_dict() # keep print to console statement for testing purposes # print(changes['id'], changes['user']['login'], changes['title'], changes['commits'], changes['changed_files']) with open('c:\\pull.csv','a+',newline='') as f: csv_writer = csv.writer(f) csv_writer.writerow([changes['id'], changes['user']['login'], changes['title'], changes['commits'], changes['changed_files']]) list_all_prs() # Call the validation script exec(open("one_commit_one_file_change.py").read()) +++++++++++++++++++++++++++++++++++++++ one_commit_one_file_change script: #! /usr/bin/python import os import github3 from github3 import login, GitHub, authorize from getpass import getuser, getpass import requests import csv import configparser import sys import main_en_pr from main_en_pr import GitAuth import codecs sys.__stdout__ = codecs.getwriter('utf8')(sys.stdout) myobjecty = GitAuth() user = myobjecty.authentication() def one_commit_one_file_change_pr(): #open csv file and create header rows with open('c:\\commit_filechange.csv', 'w+') as f: csv_writer = csv.writer(f) csv_writer.writerow(['Login', 'Title', 'Commits', 'Changed Files','Deletions', 'Additions']) #iterate through repo for pull requests based on criteria and output to csv file for pr in main_en_pr.result: data = pr.as_dict() changes = (myobjecty.gh.repository(user, main_en_pr.repo).pull_request(data['number'])).as_dict() if changes['commits'] == 1 and changes['changed_files'] == 1: #keep print to console statement for testing purposes #print changes['user']['login'] with open('c:\\commit_filechange.csv', 'a+') as f: csv_writer = csv.writer(f) csv_writer.writerow([changes['user']['login'], changes['title'], changes['commits'], changes['changed_files']]) one_commit_one_file_change_pr() From tjreedy at udel.edu Thu Oct 8 02:44:39 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 8 Oct 2015 02:44:39 -0400 Subject: Access a class in another python script In-Reply-To: <58842c9a-cc17-4929-9fc6-16fff3a2ac5c@googlegroups.com> References: <58842c9a-cc17-4929-9fc6-16fff3a2ac5c@googlegroups.com> Message-ID: On 10/8/2015 2:24 AM, DBS wrote: > I'm using Python 3.5 and have two python scripts where one needs > access to a class in the other script for authentication purposes. Any python .py file can be either run as a main program or module (ie, script) or imported as a module by another module. If a file is meant for both, it should end with if __name__ == '__main__: The latter is ofter to call a function main() defined previously. If you have a problem with this, write a **minimal** example with at most 10 lines per file and post. -- Terry Jan Reedy From lac at openend.se Thu Oct 8 03:30:20 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 08 Oct 2015 09:30:20 +0200 Subject: Is there a Windows Python SIG? In-Reply-To: <4e05bb75-f6a5-4eeb-9161-e5ab3a49461f@email.android.com> References: <4e05bb75-f6a5-4eeb-9161-e5ab3a49461f@email.android.com> Message-ID: <201510080730.t987UKpA007206@fido.openend.se> In a message of Thu, 08 Oct 2015 00:15:26 -0500, Anthony Papillion writes: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA512 > >Over the next few months, I'll be working on a project using Python on Microsoft Windows. While I'm doing this project, I'd also like to contribute in any way I can to making Python in Windows better. > >Does anyone know if there is a Windows SIG? I went to the Python website where I thought I'd seen one but it doesn't seem to be there now. Any thoughts? > >Anthony https://mail.python.org/mailman/listinfo/python-win32 Speaking as (a) webmaster, a page that tells windows users how to have more than one Python version on your machine; how to use virtualenv after you have multiple Python versions, and how to find out which versions of Python you already have would have significant value. Laura From robin at reportlab.com Thu Oct 8 05:26:44 2015 From: robin at reportlab.com (Robin Becker) Date: Thu, 8 Oct 2015 10:26:44 +0100 Subject: python3.5 + reportlab + windows again In-Reply-To: <5613E952.2090503@chamonix.reportlab.co.uk> References: <5613E55E.9000203@chamonix.reportlab.co.uk> <5613E952.2090503@chamonix.reportlab.co.uk> Message-ID: <561636D4.4080001@chamonix.reportlab.co.uk> On 06/10/2015 16:31, Robin Becker wrote: ......... > > well it seems someone can build these extensions properly. I used Christoph > Gohlke's reportlab build and although there are 3 failures in the latest tests I > don't see any crashes etc etc and all the failures are explainable. Last thing I > saw from him in respect of pyRXPU was to use extra_compile_args=['/Od']. I will > try that in the reportlab extension builds and see if the problems go away. I figured out the problem I was having with windows vs python3.5. It seems that something has changed in the way extensions are loaded when using imp to override the normal import mechanism. The following code works OK for python 2.7, 3.3 & 3.4, but fails fairly catastrophically when used in a complex way (ie running reportlab's tests). Simple usage appears to work ie when I run one test. My extension loading code looks like this ###################################### def __hack__(): import sys, os, importlib, imp if sys.modules['reportlab'].__path__[0].lower()!=r'c:\code\reportlab': return from distutils.util import get_platform archname = get_platform() _p0=r'c:\repos\reportlab\build\lib.%s-%d.%d' % (archname,sys.version_info[0],sys.version_info[1]) _p1=r'c:\repos\pyRXP\build\lib.%s-%d.%d' % (archname,sys.version_info[0],sys.version_info[1]) _overrides={ 'reportlab.lib._rl_accel':os.path.join(_p0,r'reportlab\lib'), 'reportlab.graphics._renderPM':os.path.join(_p0,r'reportlab\graphics'), 'pyRXPU':_p1, } def find_override(name): if name in _overrides and os.path.isdir(_overrides[name]): fpd = imp.find_module(name.split('.')[-1],[_overrides[name]]) try: try: return imp.load_module(name,fpd[0],fpd[1],fpd[2]) except: pass finally: if fpd[0]: fpd[0].close() class RLImporter(object): def __init__(self): self.module = None def find_module(self, name, path=None): m = find_override(name) if m: m.__loader__ = self self.module = m return self def load_module(self, name): if not self.module: raise ImportError("Unable to load module %s" % name) sys.modules[name] = m = self.module self.module = None return m sys.meta_path.insert(0, RLImporter()) __hack__() del __hack__ ###################################### My guess is that it's not cool any more to use imp.load_module repeatedly or that the hack of passing the found module about using a temporary attribute is not a good idea. The intent of the above code is to allow me to build extensions for multiple pythons in a single area under c:\repos\reportlab\build and allow loading of those with different python versions. I don't want to pollute my repository with different extensions so prefer to keep them in the build area (and they change very slowly compared to the python code). Is there some simple sample code that can be used as a model for this. I've tried looking at the importlib docs and my brain is bursting. I also looked at http://chimera.labs.oreilly.com/books/1230000000393/ch10.html, but that seems all about normal python models/packages. I think importlib has split the loading of extensions into a different method, and there seem to be assertions about re-using an existing loader. -- Robin Becker From chenchao at inhand.com.cn Thu Oct 8 05:32:56 2015 From: chenchao at inhand.com.cn (chenchao at inhand.com.cn) Date: Thu, 8 Oct 2015 17:32:56 +0800 Subject: libevent-python Message-ID: <56163848.2040402@inhand.com.cn> hi: I use libevent-python package currently. I read the file eventmodule.c, but I can not understand the function: static EventObject *EventBase_CreateEvent(EventBaseObject *self, PyObject *args, PyObject *kwargs) { EventObject *newEvent = NULL; newEvent = (EventObject *)Event_New(&Event_Type,NULL,NULL); if (Event_Init(newEvent, args, kwargs) < 0){ return NULL; } if (PyObject_CallMethod((PyObject *)newEvent, "setEventBase", "O", self) == NULL){ return NULL; } return newEvent; } So, I can not know the param "EventBaseObject *self" is what? And I read the examples/echo_server.py file, I read the follow source: class BaseConnection(object): bufferSize = 2**16 def __init__(self, sock, addr, server): self.sock = sock self.addr = addr self.server = server self.sock.setblocking(False) self.buf = [] self.readEvent = libevent.createEvent( self.sock,libevent.EV_READ|libevent.EV_PERSIST, self._doRead) self.writeEvent = libevent.createEvent( self.sock,libevent.EV_WRITE, self._doWrite) self.startReading() So, I can not see pass the self parameter. Is anybody know this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From gall.pavgal.gall at gmail.com Thu Oct 8 05:58:41 2015 From: gall.pavgal.gall at gmail.com (gall.pavgal.gall at gmail.com) Date: Thu, 8 Oct 2015 02:58:41 -0700 (PDT) Subject: change data in large excel file(more than 240 000 rows on sheet) In-Reply-To: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> References: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> Message-ID: thanks Guys! xlrd it's cool, but i need change existing file, which contains some sheets with large data...) So, if i use xlwt(i.e. create new excel document), i will lose data from other sheets. I tried use openpyxl, but got error : Traceback (most recent call last): File "D:/WebPython/oneMoreTest.py", line 15, in wb = load_workbook(filename='D:\WebPython\COX.DSG.Offering Product Catalog VANE.xlsx') File "C:\Python27\lib\site-packages\openpyxl\reader\excel.py", line 149, in load_workbook _load_workbook(wb, archive, filename, read_only, keep_vba) File "C:\Python27\lib\site-packages\openpyxl\reader\excel.py", line 236, in _load_workbook color_index=wb._colors) File "C:\Python27\lib\site-packages\openpyxl\reader\worksheet.py", line 327, in read_worksheet fast_parse(ws, xml_source, shared_strings, style_table, color_index) File "C:\Python27\lib\site-packages\openpyxl\reader\worksheet.py", line 315, in fast_parse parser.parse() File "C:\Python27\lib\site-packages\openpyxl\reader\worksheet.py", line 88, in parse stream = _get_xml_iter(self.source) File "C:\Python27\lib\site-packages\openpyxl\reader\worksheet.py", line 36, in _get_xml_iter xml_source = xml_source.encode("utf-8") MemoryError From harirammanohar159 at gmail.com Thu Oct 8 06:03:17 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Thu, 8 Oct 2015 03:03:17 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <9cd3423a-75c3-4b94-9bc8-cd48e2da4140@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. if its a command i can launch a detached process for each request, its a session.. From lac at openend.se Thu Oct 8 06:27:39 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 08 Oct 2015 12:27:39 +0200 Subject: change data in large excel file(more than 240 000 rows on sheet) In-Reply-To: References: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> Message-ID: <201510081027.t98ARdsF020037@fido.openend.se> You need to use the optimised reader. https://openpyxl.readthedocs.org/en/latest/optimized.html Laura From cl at isbd.net Thu Oct 8 06:28:19 2015 From: cl at isbd.net (cl at isbd.net) Date: Thu, 8 Oct 2015 11:28:19 +0100 Subject: Hiding code from intruders, a different slant on an old question References: Message-ID: <33thec-mat.ln1@esprimo.zbmc.eu> Dennis Lee Bieber wrote: > On Wed, 7 Oct 2015 13:05:07 +0000 (UTC), alister > declaimed the following: > > > >With a simple Cesar the method is "shift the alphabet by 'X' characters > >and X is the key > > > >if the key is unknown then the attacker still has to brute force the > >method (admittedly with only 25 options this is not difficult) > > But who'd consider that with just one-case and alphabet only... > > At the least include upper, lower, numbers, and basic punctuation -- > that will add a few more cycles of computation time to break > > > But the other point, yes... The most used encryption systems have > publicly known/reviewed algorithms and rely on the secrecy of the key(s). Which makes a nonsense of using a super-secure algorithm in many cases. If you are doing in-place symmetric file encryption then it's the security of the key hashing algorithm that matters much more than the actual encryption used on the file. Using ccrypt, enc, etc. for file encryption means the password that encodes the encryption key is saved with the file so brute-force attacks to get the key are quite straightforward. -- Chris Green ? From w4wyi at comcast.net Thu Oct 8 09:25:41 2015 From: w4wyi at comcast.net (MICHAEL) Date: Thu, 8 Oct 2015 13:25:41 +0000 (UTC) Subject: Installation problem In-Reply-To: <1817880421.3694051.1444310262425.JavaMail.zimbra@comcast.net> Message-ID: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> Hello, Please forgive a new user's ignorance. I am trying to install Python 3.5.0 on my laptop (Windows 10). The default installation directory is shown as c:\Users\(my user name)\AppData\Local\Programs\Python\Python35-32. However, if I select Custom Install then the default installation directory is c:\Program Files(x86)\Python3.5. In either case, after the installation is complete I cannot find a Python3.5 directory under Program Files(x86) or the Users\... directory. The python.exe file can be located under c:\OpenOffice. Other python files are found scattered all over my hard drive in locations such as c:\ HamRadio\WSJT, or c:\Program Files(x86)\Cyberlink, or c:\CHIRP, or a variety of other directories, but never in the designated installation directory. Scattered files include: python.exe (in Open Office) python27.dll (in CHIRP) pythoncom27.dll (in CHIRP) python33.dll (in HamRadio\WSJT) python25.dll (in "Koan c:\Program Files(x86)\Cyberlink) I assume these various .dll files are used in the various other programs I have installed but I cannot understand, at the moment, why the main python program does not appear in the designated installation directory. Any ideas or suggestion you may have are most welcome and appreciated. Thanks very much, Mike Wolcott -------------- next part -------------- An HTML attachment was scrubbed... URL: From beliavsky at aol.com Thu Oct 8 09:39:44 2015 From: beliavsky at aol.com (beliavsky at aol.com) Date: Thu, 8 Oct 2015 06:39:44 -0700 (PDT) Subject: Planet Scipy blog Message-ID: <6bf1c241-ca95-4f13-9230-5d57f5f02500@googlegroups.com> There used to be a blog about SciPy at https://planet.scipy.org/ , discussing the applications of Python to scientific computing. Now there is a static page about "MPI for Python". What happened? From mail at timgolden.me.uk Thu Oct 8 09:47:34 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 8 Oct 2015 14:47:34 +0100 Subject: Installation problem In-Reply-To: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> Message-ID: <561673F6.2050502@timgolden.me.uk> On 08/10/2015 14:25, MICHAEL wrote: > Hello, > > Please forgive a new user's ignorance. > > I am trying to install Python 3.5.0 on my laptop (Windows 10). The > default installation directory is shown as c:\Users\(my user > name)\AppData\Local\Programs\Python\Python35-32. However, if I select > Custom Install then the default installation directory is c:\Program > Files(x86)\Python3.5. > > In either case, after the installation is complete I cannot find a > Python3.5 directory under Program Files(x86) or the Users\... directory. Mike, What happens if you do [Windows] + R (ie Start > Run), enter "python" and click OK? If it comes up with a Python window, what happens if you type this: import sys print(sys.executable) You can do all this in one step if you're feeling adventurous: Start > Run > python -i -c "import sys; print(sys.executable)" TJG From info at wingware.com Thu Oct 8 09:53:21 2015 From: info at wingware.com (Wingware) Date: Thu, 08 Oct 2015 10:53:21 -0300 Subject: ANN: Wing IDE 5.1.8 released Message-ID: <56167551.9090706@wingware.com> Hi, Wingware has released version 5.1.8 of Wing IDE, our cross-platform integrated development environment for the Python programming language. Wing IDE features a professional code editor with vi, emacs, visual studio, and other key bindings, auto-completion, call tips, context-sensitive auto-editing, goto-definition, find uses, refactoring, a powerful debugger, version control, unit testing, search, project management, and many other features. This release includes the following improvements: Support for Python 3.5 final release New option to specify how to run test files in package directories Improved performance of Open from Project for large projects Several improvements in the pytest integration Fix displaying multiple plots with the Mac OS X backend for matplotlib Fix auto-spacing around - and + in exponents Don't jump back to last stop position when restarting debugging Don't expand folds on edited lines unless the fold point is removed About 30 other improvements For details see http://wingware.com/news/2015-10-05 and http://wingware.com/pub/wingide/5.1.8/CHANGELOG.txt What's New in Wing 5.1: Wing IDE 5.1 adds multi-process and child process debugging, syntax highlighting in the shells, support for pytest, Find Symbol in Project, persistent time-stamped unit test results, auto-conversion of indents on paste, an XCode keyboard personality, support for Flask, Django 1.7 and 1.8, Python 3.5 and recent Google App Engine versions, improved auto-completion for PyQt, recursive snippet invocation, and many other minor features and improvements. Free trial: http://wingware.com/wingide/trial Downloads: http://wingware.com/downloads Feature list: http://wingware.com/wingide/features Sales: http://wingware.com/store/purchase Upgrades: https://wingware.com/store/upgrade Questions? Don't hesitate to email us at support at wingware.com. Thanks, -- Stephan Deibel Wingware | Python IDE The Intelligent Development Environment for Python Programmers wingware.com From gandalf at shopzeus.com Thu Oct 8 09:55:48 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Thu, 8 Oct 2015 15:55:48 +0200 Subject: When tornado 4.3 will be available at pypi? Message-ID: <561675E4.4050700@shopzeus.com> I would like to use async/await. The tornado latest documentation says it is possible with tornado 4.3 and later: http://tornadokevinlee.readthedocs.org/en/latest/guide/coroutines.html However, it is not available yet. c:\Python\Projects>pip3 install tornado -U Requirement already up-to-date: tornado in c:\python35\lib\site-packages c:\Python\Projects>py -3 Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tornado >>> print(tornado.version) 4.2.1 Thanks, Laszlo From breamoreboy at yahoo.co.uk Thu Oct 8 10:10:21 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 8 Oct 2015 15:10:21 +0100 Subject: Planet Scipy blog In-Reply-To: <6bf1c241-ca95-4f13-9230-5d57f5f02500@googlegroups.com> References: <6bf1c241-ca95-4f13-9230-5d57f5f02500@googlegroups.com> Message-ID: On 08/10/2015 14:39, beliavsky--- via Python-list wrote: > There used to be a blog about SciPy at https://planet.scipy.org/ , discussing the applications of Python to scientific computing. Now there is a static page about "MPI for Python". What happened? > Presumably http://www.scipy.org/ -- 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 Oct 8 10:27:31 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 08 Oct 2015 16:27:31 +0200 Subject: Planet Scipy blog In-Reply-To: References: <6bf1c241-ca95-4f13-9230-5d57f5f02500@googlegroups.com> Message-ID: <201510081427.t98ERVPN004759@fido.openend.se> In a message of Thu, 08 Oct 2015 15:10:21 +0100, Mark Lawrence writes: >On 08/10/2015 14:39, beliavsky--- via Python-list wrote: >> There used to be a blog about SciPy at https://planet.scipy.org/ , discussing the applications of Python to scientific computing. Now there is a static page about "MPI for Python". What happened? >> > >Presumably http://www.scipy.org/ > >-- >My fellow Pythonistas, ask not what our language can do for you, ask >what you can do for our language. > >Mark Lawrence No, all the blog links there go to the MPI for Python link, too. Laura From paul.hermeneutic at gmail.com Thu Oct 8 10:30:47 2015 From: paul.hermeneutic at gmail.com (paul.hermeneutic at gmail.com) Date: Thu, 8 Oct 2015 08:30:47 -0600 Subject: Installation problem In-Reply-To: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> References: <1817880421.3694051.1444310262425.JavaMail.zimbra@comcast.net> <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> Message-ID: On Oct 8, 2015 7:31 AM, "MICHAEL" wrote: > > Hello, > > Please forgive a new user's ignorance. > > I am trying to install Python 3.5.0 on my laptop (Windows 10). The default installation directory is shown as c:\Users\(my user name)\AppData\Local\Programs\Python\Python35-32. However, if I select Custom Install then the default installation directory is c:\Program Files(x86)\Python3.5. > I would like to see Python in use as much as anyone. However, I am not sure we are doing users or ourselves much of a favor encouraging pieces of the language be distributed in so many kits. I do not know, but it does not seem that Java has much of this problem. Everyone seems to know that Java should be installed on the system. There is a clear way to have multiple versions of Java on one system. There would be benefits in having a well structured way to do it. I am not suggesting that other ways should be prohibited. This approach would fit well with the Python maxim to pick one really good way to do it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Oct 8 10:44:43 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 8 Oct 2015 08:44:43 -0600 Subject: Hiding code from intruders, a different slant on an old question In-Reply-To: References: Message-ID: On Wed, Oct 7, 2015 at 6:01 PM, Dennis Lee Bieber wrote: > On Wed, 7 Oct 2015 13:05:07 +0000 (UTC), alister > declaimed the following: > > >>With a simple Cesar the method is "shift the alphabet by 'X' characters >>and X is the key >> >>if the key is unknown then the attacker still has to brute force the >>method (admittedly with only 25 options this is not difficult) > > But who'd consider that with just one-case and alphabet only... > > At the least include upper, lower, numbers, and basic punctuation -- > that will add a few more cycles of computation time to break It doesn't really matter how much you add; any Caesar cipher is going to fall easily to just a little bit of frequency analysis. Consider an extreme case, where the range of X is the size of the entire Unicode character set. If the message is written in a Latin-based character set, chances are good that the majority of the characters will fall within a range of <96, giving the attacker a great starting point to brute-force from. From mail at timgolden.me.uk Thu Oct 8 10:49:56 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 8 Oct 2015 15:49:56 +0100 Subject: Installation problem In-Reply-To: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> Message-ID: <56168294.6090702@timgolden.me.uk> On 08/10/2015 14:25, MICHAEL wrote: > Hello, > > Please forgive a new user's ignorance. > > I am trying to install Python 3.5.0 on my laptop (Windows 10). The > default installation directory is shown as c:\Users\(my user > name)\AppData\Local\Programs\Python\Python35-32. However, if I select > Custom Install then the default installation directory is c:\Program > Files(x86)\Python3.5. > > In either case, after the installation is complete I cannot find a > Python3.5 directory under Program Files(x86) or the Users\... directory. OP reports off-list that the installation now appears to have been successful. (I'm not clear whether as the result of a re-install or simply finding the .exe) TJG From rosuav at gmail.com Thu Oct 8 10:51:31 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 9 Oct 2015 01:51:31 +1100 Subject: Installation problem In-Reply-To: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> References: <1817880421.3694051.1444310262425.JavaMail.zimbra@comcast.net> <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> Message-ID: On Fri, Oct 9, 2015 at 12:25 AM, MICHAEL wrote: > Scattered files include: > python.exe (in Open Office) > python27.dll (in CHIRP) > pythoncom27.dll (in CHIRP) > python33.dll (in HamRadio\WSJT) > python25.dll (in "Koan c:\Program Files(x86)\Cyberlink) > > I assume these various .dll files are used in the various other programs I > have installed but I cannot understand, at the moment, why the main python > program does not appear in the designated installation directory. Those would all be different programs that have packaged up (part of) Python with them - and in some cases, a very old version. You can ignore those. Did the installation give any complaints? It's possible that you'd need to elevate privileges for the global installation, though you should be able to install to your own user directory without elevation. ChrisA From lac at openend.se Thu Oct 8 11:27:18 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 08 Oct 2015 17:27:18 +0200 Subject: Installation problem In-Reply-To: <56168294.6090702@timgolden.me.uk> References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> <56168294.6090702@timgolden.me.uk> Message-ID: <201510081527.t98FRImi009103@fido.openend.se> In a message of Thu, 08 Oct 2015 15:49:56 +0100, Tim Golden writes: >On 08/10/2015 14:25, MICHAEL wrote: >> Hello, >> >> Please forgive a new user's ignorance. >> >> I am trying to install Python 3.5.0 on my laptop (Windows 10). The >> default installation directory is shown as c:\Users\(my user >> name)\AppData\Local\Programs\Python\Python35-32. However, if I select >> Custom Install then the default installation directory is c:\Program >> Files(x86)\Python3.5. >> >> In either case, after the installation is complete I cannot find a >> Python3.5 directory under Program Files(x86) or the Users\... directory. > >OP reports off-list that the installation now appears to have been >successful. (I'm not clear whether as the result of a re-install or >simply finding the .exe) > >TJG Well, his Python shouldn't have been scattered all over his filesystem in any case. Did it all show up in one place like it was supposed to? Laura From mail at timgolden.me.uk Thu Oct 8 11:34:15 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 8 Oct 2015 16:34:15 +0100 Subject: Installation problem In-Reply-To: <201510081527.t98FRImi009103@fido.openend.se> References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> <56168294.6090702@timgolden.me.uk> <201510081527.t98FRImi009103@fido.openend.se> Message-ID: <56168CF7.8090205@timgolden.me.uk> On 08/10/2015 16:27, Laura Creighton wrote: > In a message of Thu, 08 Oct 2015 15:49:56 +0100, Tim Golden writes: >> On 08/10/2015 14:25, MICHAEL wrote: >>> Hello, >>> >>> Please forgive a new user's ignorance. >>> >>> I am trying to install Python 3.5.0 on my laptop (Windows 10). The >>> default installation directory is shown as c:\Users\(my user >>> name)\AppData\Local\Programs\Python\Python35-32. However, if I select >>> Custom Install then the default installation directory is c:\Program >>> Files(x86)\Python3.5. >>> >>> In either case, after the installation is complete I cannot find a >>> Python3.5 directory under Program Files(x86) or the Users\... directory. >> >> OP reports off-list that the installation now appears to have been >> successful. (I'm not clear whether as the result of a re-install or >> simply finding the .exe) >> >> TJG > > Well, his Python shouldn't have been scattered all over his filesystem > in any case. Did it all show up in one place like it was supposed to? (Not entirely sure if you're serious...) Those were elements of the other programs he mentioned which ship Python as, eg, a scripting or even because they're partly or wholly implemented in Python. Apart from the file locations, none of the DLL versions are 35: python27.dll, python33.dll etc. TJG From alister.nospam.ware at ntlworld.com Thu Oct 8 11:46:32 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Thu, 8 Oct 2015 15:46:32 +0000 (UTC) Subject: Hiding code from intruders, a different slant on an old question References: Message-ID: On Thu, 08 Oct 2015 08:44:43 -0600, Ian Kelly wrote: > On Wed, Oct 7, 2015 at 6:01 PM, Dennis Lee Bieber > wrote: >> On Wed, 7 Oct 2015 13:05:07 +0000 (UTC), alister >> declaimed the following: >> >> >>>With a simple Cesar the method is "shift the alphabet by 'X' characters >>>and X is the key >>> >>>if the key is unknown then the attacker still has to brute force the >>>method (admittedly with only 25 options this is not difficult) >> >> But who'd consider that with just one-case and alphabet only... >> >> At the least include upper, lower, numbers, and basic >> punctuation -- >> that will add a few more cycles of computation time to break > > It doesn't really matter how much you add; any Caesar cipher is going to > fall easily to just a little bit of frequency analysis. Consider an > extreme case, where the range of X is the size of the entire Unicode > character set. If the message is written in a Latin-based character set, > chances are good that the majority of the characters will fall within a > range of <96, giving the attacker a great starting point to brute-force > from. Oh please the Caesar cypher was mentioned as a simplification for the purpose of demonstration. it was not intended to be even a remotely serious suggestion which I am sure at least Denis understood when he posted his tongue in cheek reply. -- Economists can certainly disappoint you. One said that the economy would turn up by the last quarter. Well, I'm down to mine and it hasn't. -- Robert Orben From lac at openend.se Thu Oct 8 12:17:50 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 08 Oct 2015 18:17:50 +0200 Subject: Installation problem In-Reply-To: <56168CF7.8090205@timgolden.me.uk> References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> <56168294.6090702@timgolden.me.uk> <201510081527.t98FRImi009103@fido.openend.se> <56168CF7.8090205@timgolden.me.uk> Message-ID: <201510081617.t98GHoiQ012519@fido.openend.se> In a message of Thu, 08 Oct 2015 16:34:15 +0100, Tim Golden writes: >On 08/10/2015 16:27, Laura Creighton wrote: >> In a message of Thu, 08 Oct 2015 15:49:56 +0100, Tim Golden writes: >>> On 08/10/2015 14:25, MICHAEL wrote: >>>> Hello, >>>> >>>> Please forgive a new user's ignorance. >>>> >>>> I am trying to install Python 3.5.0 on my laptop (Windows 10). The >>>> default installation directory is shown as c:\Users\(my user >>>> name)\AppData\Local\Programs\Python\Python35-32. However, if I select >>>> Custom Install then the default installation directory is c:\Program >>>> Files(x86)\Python3.5. >>>> >>>> In either case, after the installation is complete I cannot find a >>>> Python3.5 directory under Program Files(x86) or the Users\... directory. >>> >>> OP reports off-list that the installation now appears to have been >>> successful. (I'm not clear whether as the result of a re-install or >>> simply finding the .exe) >>> >>> TJG >> >> Well, his Python shouldn't have been scattered all over his filesystem >> in any case. Did it all show up in one place like it was supposed to? > >(Not entirely sure if you're serious...) > >Those were elements of the other programs he mentioned which ship Python >as, eg, a scripting or even because they're partly or wholly implemented >in Python. Apart from the file locations, none of the DLL versions are >35: python27.dll, python33.dll etc. > >TJG I am serious, in that it wasn't clear to me what those things were. What I don't know about Windows is very huge ... Laura From ian.g.kelly at gmail.com Thu Oct 8 12:33:37 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 8 Oct 2015 10:33:37 -0600 Subject: Hiding code from intruders, a different slant on an old question In-Reply-To: References: Message-ID: On Thu, Oct 8, 2015 at 9:46 AM, alister wrote: > Oh please > the Caesar cypher was mentioned as a simplification for the purpose of > demonstration. > it was not intended to be even a remotely serious suggestion > > which I am sure at least Denis understood when he posted his tongue in > cheek reply. I understood that also. I don't see why that means I can't elaborate on it. From jcb2g at virginia.edu Thu Oct 8 13:01:24 2015 From: jcb2g at virginia.edu (Jay Brown) Date: Thu, 8 Oct 2015 13:01:24 -0400 Subject: can't install Python 3.5 on windows Message-ID: <000001d101ea$f6ee9160$e4cbb420$@virginia.edu> Dear Python: I have been trying to install Python on my Windows computer. I tried both Python 2.7 and 3.5. No luck with either one. If I try to run Python I get a message asking me if I want to repair Python. The program never runs. Can you help? -Jay Brown Jay C. Brown Department of Microbiology, Immunology and Cancer Biology University of Virginia Health System Charlottesville, VA 22908 Email: jcb2g at virginia.edu Phone: 434-924-1814 -------------- next part -------------- An HTML attachment was scrubbed... URL: From davanand.bahall at gmail.com Thu Oct 8 13:40:48 2015 From: davanand.bahall at gmail.com (DBS) Date: Thu, 8 Oct 2015 10:40:48 -0700 (PDT) Subject: Access a class in another python script In-Reply-To: References: <58842c9a-cc17-4929-9fc6-16fff3a2ac5c@googlegroups.com> Message-ID: On Wednesday, October 7, 2015 at 11:46:05 PM UTC-7, Terry Reedy wrote: > On 10/8/2015 2:24 AM, DBS wrote: > > I'm using Python 3.5 and have two python scripts where one needs > > access to a class in the other script for authentication purposes. > > Any python .py file can be either run as a main program or module (ie, > script) or imported as a module by another module. If a file is meant > for both, it should end with > > if __name__ == '__main__: > > > The latter is ofter to call a function main() defined previously. If > you have a problem with this, write a **minimal** example with at most > 10 lines per file and post. > > > -- > Terry Jan Reedy Hello Terry, Thanks. Will do and get back with what come up with. To clarify your repsonse, I need to change the file name to reflect __filename__.py and then import the needed components (classes and variables) accordingly? From oscar.j.benjamin at gmail.com Thu Oct 8 15:11:46 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 08 Oct 2015 19:11:46 +0000 Subject: Planet Scipy blog In-Reply-To: <201510081427.t98ERVPN004759@fido.openend.se> References: <6bf1c241-ca95-4f13-9230-5d57f5f02500@googlegroups.com> <201510081427.t98ERVPN004759@fido.openend.se> Message-ID: On Thu, 8 Oct 2015 15:29 Laura Creighton wrote: In a message of Thu, 08 Oct 2015 15:10:21 +0100, Mark Lawrence writes: >On 08/10/2015 14:39, beliavsky--- via Python-list wrote: >> There used to be a blog about SciPy at https :// planet.scipy.org/ , discussing the applications of Python to scientific computing. Now there is a static page about "MPI for Python". What happened? >> > >Presumably http:// www.scipy.org/ > >-- >My fellow Pythonistas, ask not what our language can do for you, ask >what you can do for our language. > >Mark Lawrence No, all the blog links there go to the MPI for Python link, too. Numpy etc have been having some hosting problems recently. This might be a temporary glitch. -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Thu Oct 8 17:10:34 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 8 Oct 2015 22:10:34 +0100 Subject: Installation problem In-Reply-To: <201510081527.t98FRImi009103@fido.openend.se> References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> <56168294.6090702@timgolden.me.uk> <201510081527.t98FRImi009103@fido.openend.se> Message-ID: On 08/10/2015 16:27, Laura Creighton wrote: > In a message of Thu, 08 Oct 2015 15:49:56 +0100, Tim Golden writes: >> On 08/10/2015 14:25, MICHAEL wrote: >>> Hello, >>> >>> Please forgive a new user's ignorance. >>> >>> I am trying to install Python 3.5.0 on my laptop (Windows 10). The >>> default installation directory is shown as c:\Users\(my user >>> name)\AppData\Local\Programs\Python\Python35-32. However, if I select >>> Custom Install then the default installation directory is c:\Program >>> Files(x86)\Python3.5. >>> >>> In either case, after the installation is complete I cannot find a >>> Python3.5 directory under Program Files(x86) or the Users\... directory. >> >> OP reports off-list that the installation now appears to have been >> successful. (I'm not clear whether as the result of a re-install or >> simply finding the .exe) >> >> TJG > > Well, his Python shouldn't have been scattered all over his filesystem > in any case. Did it all show up in one place like it was supposed to? > > Laura > I have a very strong feeling that Steve Dower has *NOT* incorporated some kind of random number generator into the Python 3.5 installer such that weird versions of everything get scattered over a hard drive like confetti at a wedding. If he had of done so I might well have had a word. The old lags know what I'm like, but for the benefit of the new lags, when I'm having a bad hair day, having got out of bed on the wrong side, it most certainly would *NOT* have been quiet. Please also be aware that my bark is roughly one trillion times worse than my bite. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From eryksun at gmail.com Thu Oct 8 17:28:36 2015 From: eryksun at gmail.com (eryksun) Date: Thu, 8 Oct 2015 16:28:36 -0500 Subject: Installation problem In-Reply-To: <561673F6.2050502@timgolden.me.uk> References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> <561673F6.2050502@timgolden.me.uk> Message-ID: On 10/8/15, Tim Golden wrote: > > What happens if you do [Windows] + R (ie Start > Run), enter "python" > and click OK? The new installer for 3.5 doesn't create an "App Paths" key for "python.exe" like the old installer used to do (see the old Tools/msi/msi.py). Without that, unless python.exe is in the search PATH, "Win+R -> python" and running "start python" in the command prompt won't work. You can of course add the key manually as the default value for "[HKLM|HKCU]\Software\Microsoft\Windows\CurrentVersion\App Paths\python.exe". IMO, this makes it the 'system' Python. From oscar.j.benjamin at gmail.com Thu Oct 8 17:34:02 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 08 Oct 2015 21:34:02 +0000 Subject: Installation problem In-Reply-To: References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> <561673F6.2050502@timgolden.me.uk> Message-ID: On Thu, 8 Oct 2015 22:30 eryksun wrote: On 10/8/15, Tim Golden wrote: > > What happens if you do [Windows] + R (ie Start > Run), enter "python" > and click OK? The new installer for 3.5 doesn't create an "App Paths" key for "python.exe" like the old installer used to do (see the old Tools/msi/msi.py). Without that, unless python.exe is in the search PATH, "Win+R -> python" and running "start python" in the command prompt won't work. You can of course add the key manually as the default value for "[HKLM|HKCU]\Software\Microsoft\Windows\CurrentVersion\App Paths\python.exe". IMO, this makes it the 'system' Python. That's interesting. Any idea why it changed? -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From eryksun at gmail.com Thu Oct 8 17:41:09 2015 From: eryksun at gmail.com (eryksun) Date: Thu, 8 Oct 2015 16:41:09 -0500 Subject: Installation problem In-Reply-To: References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> <561673F6.2050502@timgolden.me.uk> Message-ID: On 10/8/15, Oscar Benjamin wrote: > On Thu, 8 Oct 2015 22:30 eryksun wrote: > > The new installer for 3.5 doesn't create an "App Paths" key for > "python.exe" like the old installer used to do (see the old > Tools/msi/msi.py). Without that, unless python.exe is in the search > PATH, "Win+R -> python" and running "start python" in the command > prompt won't work. You can of course add the key manually as the > default value for > "[HKLM|HKCU]\Software\Microsoft\Windows\CurrentVersion\App > Paths\python.exe". IMO, this makes it the 'system' Python. > > That's interesting. Any idea why it changed? Probably it's just an oversight. I doubt Steve Dower would have purposefully decided to not set the "App Paths" key. From Cecil at decebal.nl Thu Oct 8 18:03:36 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 09 Oct 2015 00:03:36 +0200 Subject: Using pipe in a system call Message-ID: <87oag9nhl3.fsf@Equus.decebal.nl> I want to do the following Bash command in Python: sqlite3 spreekwoorden.sqlite "SELECT spreekwoord FROM spreekwoorden;" | sort > spreekwoorden2.txt The following does this in Python: sqlite_pipe = Popen( ( 'sqlite3', 'spreekwoorden.sqlite', 'SELECT spreekwoord FROM spreekwoorden;' ), stdout = PIPE ) Popen( ( 'sort', '--output=spreekwoorden2.txt', ), stdin = sqlite_pipe.stdout ) Is this the correct way, or is there a better way? By the way: I want this because I just filled the table spreekwoorden in my Python script and want to save it immediately. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From oscar.j.benjamin at gmail.com Thu Oct 8 18:07:52 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 08 Oct 2015 22:07:52 +0000 Subject: Installation problem In-Reply-To: References: <1484754132.3702647.1444310741669.JavaMail.zimbra@comcast.net> <561673F6.2050502@timgolden.me.uk> Message-ID: On Thu, 8 Oct 2015 22:41 eryksun wrote: > On 10/8/15, Oscar Benjamin wrote: > > On Thu, 8 Oct 2015 22:30 eryksun wrote: > > > > The new installer for 3.5 doesn't create an "App Paths" key for > > "python.exe" like the old installer used to do (see the old > > Tools/msi/msi.py). Without that, unless python.exe is in the search > > PATH, "Win+R -> python" and running "start python" in the command > > prompt won't work. You can of course add the key manually as the > > default value for > > "[HKLM|HKCU]\Software\Microsoft\Windows\CurrentVersion\App > > Paths\python.exe". IMO, this makes it the 'system' Python. > > > > That's interesting. Any idea why it changed? > > Probably it's just an oversight. I doubt Steve Dower would have > purposefully decided to not set the "App Paths" key. > I guess it deserves a bug report then. (Not on a proper computer right now but maybe tomorrow) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Oct 8 18:26:35 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 8 Oct 2015 16:26:35 -0600 Subject: Using pipe in a system call In-Reply-To: <87oag9nhl3.fsf@Equus.decebal.nl> References: <87oag9nhl3.fsf@Equus.decebal.nl> Message-ID: On Thu, Oct 8, 2015 at 4:03 PM, Cecil Westerhof wrote: > I want to do the following Bash command in Python: > sqlite3 spreekwoorden.sqlite "SELECT spreekwoord FROM spreekwoorden;" | sort > spreekwoorden2.txt > > The following does this in Python: > sqlite_pipe = Popen( > ( > 'sqlite3', > 'spreekwoorden.sqlite', > 'SELECT spreekwoord FROM spreekwoorden;' > ), > stdout = PIPE > ) > Popen( > ( > 'sort', > '--output=spreekwoorden2.txt', > ), > stdin = sqlite_pipe.stdout > ) > > Is this the correct way, or is there a better way? That seems fine to me. Alternatively you could pass shell=True to Popen and then the original command should work verbatim (but see the warnings about using shell=True). From christopher_reimer at icloud.com Thu Oct 8 22:41:57 2015 From: christopher_reimer at icloud.com (Christopher Reimer) Date: Thu, 08 Oct 2015 19:41:57 -0700 Subject: Is there a Windows Python SIG? In-Reply-To: References: <4e05bb75-f6a5-4eeb-9161-e5ab3a49461f@email.android.com> Message-ID: <56172975.50000@icloud.com> On 10/7/2015 10:49 PM, Chris Angelico wrote: > Awesome! Contributors are always welcome. On a YouTube video from PyCon 2015, I think someone mentioned the need for more people to look at Python on Windows. Does this mean that Python on Linux and/or Mac get more love than Python on Windows? I went looking at the bug database. A lot of the reports are way over my head, but some of the comments made for fascinating reading. I found one report of an installer error on Windows 10 Educational version. I wasn't aware that there was an educational version of Windows 10. My first thought of the bug was a bad download, which was the first comment someone posted in response. Being so vague in details, no one else will probably look at it again. This one looks doable. How many bugs do I have to poke and prod to put Python contributor on my resume? Chris R. From Cecil at decebal.nl Fri Oct 9 02:56:18 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 09 Oct 2015 08:56:18 +0200 Subject: Using pipe in a system call References: <87oag9nhl3.fsf@Equus.decebal.nl> Message-ID: <87k2qwo7hp.fsf@Equus.decebal.nl> On Friday 9 Oct 2015 02:11 CEST, Dennis Lee Bieber wrote: > On Fri, 09 Oct 2015 00:03:36 +0200, Cecil Westerhof > declaimed the following: > >> I want to do the following Bash command in Python: sqlite3 >> spreekwoorden.sqlite "SELECT spreekwoord FROM spreekwoorden;" | >> sort > spreekwoorden2.txt >> >> The following does this in Python: >> sqlite_pipe = Popen( >> ( >> 'sqlite3', >> 'spreekwoorden.sqlite', >> 'SELECT spreekwoord FROM spreekwoorden;' >> ), >> stdout = PIPE >> ) >> Popen( >> ( >> 'sort', >> '--output=spreekwoorden2.txt', >> ), >> stdin = sqlite_pipe.stdout >> ) >> >> Is this the correct way, or is there a better way? >> > > Use the standard db-api interface for SQLite3 provided with > Python and avoid creating external processes? > > Heck, why rely on an external sort command when you can add > "ORDER BY spreekwoord" to the SQL statement. My bad, I intended to mention that ORDER BY gives the wrong order (? comes after z and with sort it comes after e), so that is why I use the external sort command. > Test data (out of habit, I always create an autonumber primary > key) (this is shown as CSV): I am using that also, but when I add things to the database I just want to have a sorted file with all the proverbs (that is the meaning of spreekwoord) so I can use it to import everything again if need to be. The create statement: CREATE TABLE spreekwoorden ( spreekwoordID INTEGER PRIMARY KEY AUTOINCREMENT, spreekwoord TEXT UNIQUE NOT NULL, gebruikt TEXT DEFAULT CURRENT_DATE NOT NULL ) > fout = open("wordlist.txt", "w") Fout means wrong in Dutch. ;-) -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From Cecil at decebal.nl Fri Oct 9 02:57:46 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 09 Oct 2015 08:57:46 +0200 Subject: Using pipe in a system call References: <87oag9nhl3.fsf@Equus.decebal.nl> Message-ID: <87fv1ko7f9.fsf@Equus.decebal.nl> On Friday 9 Oct 2015 00:26 CEST, Ian Kelly wrote: > On Thu, Oct 8, 2015 at 4:03 PM, Cecil Westerhof wrote: >> I want to do the following Bash command in Python: sqlite3 >> spreekwoorden.sqlite "SELECT spreekwoord FROM spreekwoorden;" | >> sort > spreekwoorden2.txt >> >> The following does this in Python: >> sqlite_pipe = Popen( >> ( >> 'sqlite3', >> 'spreekwoorden.sqlite', >> 'SELECT spreekwoord FROM spreekwoorden;' >> ), >> stdout = PIPE >> ) >> Popen( >> ( >> 'sort', >> '--output=spreekwoorden2.txt', >> ), >> stdin = sqlite_pipe.stdout >> ) >> >> Is this the correct way, or is there a better way? > > That seems fine to me. Alternatively you could pass shell=True to > Popen and then the original command should work verbatim (but see > the warnings about using shell=True). I know about that, but because of the warnings I decided to never use it. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From rosuav at gmail.com Fri Oct 9 03:21:25 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 9 Oct 2015 18:21:25 +1100 Subject: Using pipe in a system call In-Reply-To: <87k2qwo7hp.fsf@Equus.decebal.nl> References: <87oag9nhl3.fsf@Equus.decebal.nl> <87k2qwo7hp.fsf@Equus.decebal.nl> Message-ID: On Fri, Oct 9, 2015 at 5:56 PM, Cecil Westerhof wrote: > My bad, I intended to mention that ORDER BY gives the wrong order (? > comes after z and with sort it comes after e), so that is why I use > the external sort command. Can you configure SQLite's locale? That ought to resolve that. Failing that, I'd be inclined to take the data into Python as Unicode strings, and do a locale-based sort of those strings (or tuples of strings). ChrisA From alister.nospam.ware at ntlworld.com Fri Oct 9 03:50:48 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Fri, 9 Oct 2015 07:50:48 +0000 (UTC) Subject: can't install Python 3.5 on windows References: Message-ID: On Thu, 08 Oct 2015 13:01:24 -0400, Jay Brown wrote: > Dear Python: > > I have been trying to install Python on my Windows computer. I tried > both Python 2.7 and 3.5. No luck with either one. If I try to run Python > I get a message asking me if I want to repair Python. The program never > runs. Can you help? > > -Jay Brown > > > > Jay C. Brown > > Department of Microbiology, Immunology and Cancer Biology > > University of Virginia Health System > > Charlottesville, VA 22908 > > Install python correctly. That is as good an answer as anyone can give based on the quality of the question which considering the source cited in you signature is seriously worrying. From mail at timgolden.me.uk Fri Oct 9 04:08:52 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 9 Oct 2015 09:08:52 +0100 Subject: Is there a Windows Python SIG? In-Reply-To: <56172975.50000@icloud.com> References: <4e05bb75-f6a5-4eeb-9161-e5ab3a49461f@email.android.com> <56172975.50000@icloud.com> Message-ID: <56177614.4070506@timgolden.me.uk> On 09/10/2015 03:41, Christopher Reimer wrote: > On 10/7/2015 10:49 PM, Chris Angelico wrote: >> Awesome! Contributors are always welcome. > > On a YouTube video from PyCon 2015, I think someone mentioned the need > for more people to look at Python on Windows. Does this mean that Python > on Linux and/or Mac get more love than Python on Windows? It absolutely does. > > I went looking at the bug database. A lot of the reports are way over my > head, but some of the comments made for fascinating reading. I found one > report of an installer error on Windows 10 Educational version. I wasn't > aware that there was an educational version of Windows 10. My first > thought of the bug was a bad download, which was the first comment > someone posted in response. Being so vague in details, no one else will > probably look at it again. This one looks doable. > > How many bugs do I have to poke and prod to put Python contributor on my > resume? Can I suggest a read through this article, written more than 5 years ago (!) but still fairly relevant. The situation's changed a little -- in particular, Steve Dower of Microsoft has taken a very active part in the 3.5 release, bringing our build & install process up to the very latest. But we're still very short of Windows-based people. http://ramblings.timgolden.me.uk/2010/08/16/im-a-windows-person-how-can-i-contribute-to-python-part-i/ A lot of what we're seeing right at the moment is down to the new installer and its interaction with the different flavours of Windows out there. Windows 10 is very new: I'm not running it on any machine and I don't know if any Windows dev is. I don't know if we have any buildbots running it either. But people out there *are* using it, so we're seeing bug reports which might well be specific to that. Please dive in and help: even if it's just lending a hand explaining or diagnosing without ever writing code, that's helpful. If you can also contribute *and review* patches, better still. TJG From oscar.j.benjamin at gmail.com Fri Oct 9 04:08:55 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Fri, 09 Oct 2015 08:08:55 +0000 Subject: can't install Python 3.5 on windows In-Reply-To: <000001d101ea$f6ee9160$e4cbb420$@virginia.edu> References: <000001d101ea$f6ee9160$e4cbb420$@virginia.edu> Message-ID: On Fri, 9 Oct 2015 08:48 Jay Brown wrote: Dear Python: I have been trying to install Python on my Windows computer. I tried both Python 2.7 and 3.5. No luck with either one. If I try to run Python I get a message asking me if I want to repair Python. The program never runs. Can you help? Hi Jay, You need to provide more information than that! What version of Windows are you using? Is your computer 32 bit or 64 bit? Which Python installer did you use (please give a link to where you downloaded it and say what the exact filename is)? Did the install complete without errors? How are you trying to run Python? -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Fri Oct 9 04:09:50 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 9 Oct 2015 19:09:50 +1100 Subject: Is there a Windows Python SIG? In-Reply-To: <56172975.50000@icloud.com> References: <4e05bb75-f6a5-4eeb-9161-e5ab3a49461f@email.android.com> <56172975.50000@icloud.com> Message-ID: On Fri, Oct 9, 2015 at 1:41 PM, Christopher Reimer wrote: > On 10/7/2015 10:49 PM, Chris Angelico wrote: >> >> Awesome! Contributors are always welcome. > > > On a YouTube video from PyCon 2015, I think someone mentioned the need for > more people to look at Python on Windows. Does this mean that Python on > Linux and/or Mac get more love than Python on Windows? The ease of compiling CPython on Linux compared to Windows means the bar for contributions involving C code is a lot higher on Windows. So I suspect that, yes, Linux would see a lot more people dabbling in development, testing patches, etc. With Python-only patches, it shouldn't be too hard to fiddle around on Windows, but I suspect that tinkerers generally prefer Linux anyway, so there'll still be less patch testing on Windows. So if you're willing to grab patches and test them out, yes, it's well worth doing. > I went looking at the bug database. A lot of the reports are way over my > head, but some of the comments made for fascinating reading. I found one > report of an installer error on Windows 10 Educational version. I wasn't > aware that there was an educational version of Windows 10. My first thought > of the bug was a bad download, which was the first comment someone posted in > response. Being so vague in details, no one else will probably look at it > again. This one looks doable. > > How many bugs do I have to poke and prod to put Python contributor on my > resume? One :) Any work on the bug tracker is a contribution. If you sign the copyright agreement, submit a patch, and get it committed, then you'll be a "contributor" in a fuller sense, but a simple post of "Confirmed on Windows 7" is a contribution too (and doesn't require any sort of compiler or anything). ChrisA From gall.pavgal.gall at gmail.com Fri Oct 9 04:21:37 2015 From: gall.pavgal.gall at gmail.com (gall.pavgal.gall at gmail.com) Date: Fri, 9 Oct 2015 01:21:37 -0700 (PDT) Subject: change data in large excel file(more than 240 000 rows on sheet) In-Reply-To: References: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> Message-ID: <3d355596-b1cb-4a1e-b234-21bf1e637f63@googlegroups.com> Thanks Laura! But i need to change existing excel file and if i use the optimised reader, i can read data only, but i can't change data. From harirammanohar159 at gmail.com Fri Oct 9 05:07:07 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Fri, 9 Oct 2015 02:07:07 -0700 (PDT) Subject: reg multiple login python In-Reply-To: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> References: <2fe53246-4212-4cfd-896b-acf8e8e88b09@googlegroups.com> Message-ID: <51649ddc-6803-4498-a4d6-a096f30ee902@googlegroups.com> On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com wrote: > Hi All, > > Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop.. > > Thanks in advance. any way is there ??? From joshua.stokes at icloud.com Fri Oct 9 06:08:22 2015 From: joshua.stokes at icloud.com (Joshua Stokes) Date: Fri, 09 Oct 2015 21:08:22 +1100 Subject: Script To Remove Files Made Either By Python Or Git Message-ID: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> Hi Is there an available script to remove file created by either using the Python module or by using git? Thanks From Joshua P Stokes From lac at openend.se Fri Oct 9 07:07:44 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 09 Oct 2015 13:07:44 +0200 Subject: change data in large excel file(more than 240 000 rows on sheet) In-Reply-To: <3d355596-b1cb-4a1e-b234-21bf1e637f63@googlegroups.com> References: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> <3d355596-b1cb-4a1e-b234-21bf1e637f63@googlegroups.com> Message-ID: <201510091107.t99B7i4k028473@fido.openend.se> In a message of Fri, 09 Oct 2015 01:21:37 -0700, gall.pavgal.gall at gmail.com wri tes: >Thanks Laura! >But i need to change existing excel file and if i use the optimised reader, i can read data only, but i can't change data. Hmmm. When I have this problem I have other problems as well, and they can pretty well all be sumarised as 'I never wanted an excel file anyway'. So first I convert the xlsx to a CVS. import openpyxl import csv workbook = openpyxl.load_workbook('my_big_file.xlsx', read_only=True) sheet = workbook['big_data'] with open('my_big_file.csv', 'wb') as f: c = csv.writer(f) for r in sh.rows: c.writerow([cell.value for cell in r]) This may be enough for you, and you may be able to use the Python csv module to make the changes you want. https://docs.python.org/3.5/library/csv.html This may be all you need, if you can process your problem one line at a time. Reading it all into memory will give you the same problem. But I have never actually done this. Instead I convert the cvs to a postgresql database, and then make my changes there, and then export it again as a csv, and then reverse the process to get an xlsx again (if I need one). I don't know any way to get postgresql to take the xlsx directly, which is why I have the two step process with the csv in the middle. If you are more comfortable with MySQL or SQLite or some other database, by all means use that. They might even have a way to import xlsx directly. I only do this because it is what I am used to. The other thing to consider is pandas. https://pypi.python.org/pypi/pandas It uses openpyxl under the hood, but is set up for big data. It accepts xlxs files and also connects to databases. It may be exactly what you are looking for -- but I haven't tried this myself for such large datasets, so I don't know for sure. Laura From harirammanohar159 at gmail.com Fri Oct 9 07:19:16 2015 From: harirammanohar159 at gmail.com (harirammanohar159 at gmail.com) Date: Fri, 9 Oct 2015 04:19:16 -0700 (PDT) Subject: change data in large excel file(more than 240 000 rows on sheet) In-Reply-To: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> References: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> Message-ID: On Wednesday, 7 October 2015 19:44:12 UTC+5:30, gall.pav... at gmail.com wrote: > Hi Guys, > I need to change data in large excel file(more than 240 000 rows on sheet), it's possible through win32com.client, but i need use Linux OS ... > Please, could you advise some-thing suitable! > > best regards, Pavel. Hi Pavel, is there is no possibility to write a definition or macro in excel itself to change the rows which makes bit easier than the script.. :) From alister.nospam.ware at ntlworld.com Fri Oct 9 07:33:23 2015 From: alister.nospam.ware at ntlworld.com (alister) Date: Fri, 9 Oct 2015 11:33:23 +0000 (UTC) Subject: change data in large excel file(more than 240 000 rows on sheet) References: <9c23c9d1-4257-475b-a7f6-811e85fe83f3@googlegroups.com> <3d355596-b1cb-4a1e-b234-21bf1e637f63@googlegroups.com> Message-ID: On Fri, 09 Oct 2015 01:21:37 -0700, gall.pavgal.gall wrote: > Thanks Laura! > But i need to change existing excel file and if i use the optimised > reader, i can read data only, but i can't change data. I know it does not help but if you have this amount of data being stored in a spreadsheet you are probably using the wrong technology. This sounds like a typical example of miss-using a spreadsheet as a database. once your current issue is resolved you may want to investigate moving the data to a more sensible format. -- _________________________________________ / We Klingons believe as you do -- the \ | sick should die. Only the strong should | | live. | | | | -- Kras, "Friday's Child", stardate | \ 3497.2 / ----------------------------------------- \ \ .--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/ From __peter__ at web.de Fri Oct 9 09:12:43 2015 From: __peter__ at web.de (Peter Otten) Date: Fri, 09 Oct 2015 15:12:43 +0200 Subject: Using pipe in a system call References: <87oag9nhl3.fsf@Equus.decebal.nl> <87k2qwo7hp.fsf@Equus.decebal.nl> Message-ID: Dennis Lee Bieber wrote: > On Fri, 09 Oct 2015 08:56:18 +0200, Cecil Westerhof > declaimed the following: > >>My bad, I intended to mention that ORDER BY gives the wrong order (? >>comes after z and with sort it comes after e), so that is why I use >>the external sort command. >> > My books show how to define collation functions for SQLite3 -- from C; > don't show if Python can interface to that side (custom aggregation > functions are shown, however). > > Even if you have to use the external sort, you can still avoid one > process level by not spawning the external SQLite3 process. Collect the > data from the Python level and sort the output (possibly, as mentioned > elsewhere, if the data fits in memory, you can sort using Python itself > and avoid all external processes). > > AH! the help file (still Python 2.7 -- though a quick glance at the P3 has > the same text) shows: > > -=-=-=-=- > create_collation(name, callable) > > Creates a collation with the specified name and callable. The callable > will be passed two string arguments. It should return -1 if the first is > ordered lower than the second, 0 if they are ordered equal and 1 if the > first is ordered higher than the second. Note that this controls sorting > (ORDER BY in SQL) so your comparisons don?t affect other SQL operations. > > Note that the callable will get its parameters as Python bytestrings, > which will normally be encoded in UTF-8. > > The following example shows a custom collation that sorts ?the wrong > way?: > ... > -=-=-=-=- > > So if one can write a short comparison function that gives the desired > order, one can extend the SQL query with > > ... order by collate Turns out such a function already exists; it's called locale.strcoll() Modified example from the docs: $ cat sqlite3_collation.py import sqlite3 import locale print("Using locale", locale.setlocale(locale.LC_ALL, "")) con = sqlite3.connect(":memory:") con.create_collation("localized", locale.strcoll) cur = con.cursor() cur.execute("create table test(x)") cur.executemany( "insert into test(x) values (?)", "a?bA?B") cur.execute("select x from test order by x collate localized") for row in cur: print(row) con.close() $ python3 sqlite3_collation.py Using locale de_DE.UTF-8 ('a',) ('A',) ('?',) ('?',) ('b',) ('B',) $ PYTHONIOENCODING=UTF-8 LANG=C python3 sqlite3_collation.py Using locale C ('A',) ('B',) ('a',) ('b',) ('?',) ('?',) From rosuav at gmail.com Fri Oct 9 09:37:06 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 10 Oct 2015 00:37:06 +1100 Subject: Script To Remove Files Made Either By Python Or Git In-Reply-To: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> References: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> Message-ID: On Fri, Oct 9, 2015 at 9:08 PM, Joshua Stokes wrote: > Hi > > Is there an available script to remove file created by either using the Python module or by using git? > > Thanks I asked my advice device, and it said: Ask again later. Unsatisfied, I reworded the question, and asked again. It responded: Most likely. If you need better information than that, a magic eight-ball is probably not the tool for you, and you might want to consider offering us more details in your question. ChrisA From kwpolska at gmail.com Fri Oct 9 09:45:08 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Fri, 9 Oct 2015 15:45:08 +0200 Subject: Script To Remove Files Made Either By Python Or Git In-Reply-To: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> References: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> Message-ID: On 9 October 2015 at 12:08, Joshua Stokes wrote: > Hi > > Is there an available script to remove file created by either using the Python module or by using git? There?s no such script, but we could help you write one. Now, what ?Python module? do you mean? Unless it?s a git module, it?s impossible. And I really hope that ?by using git? really means ?that are part of the git repo?. -- Chris Warrick PGP: 5EAAEA16 From invalid at invalid.invalid Fri Oct 9 10:01:51 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 9 Oct 2015 14:01:51 +0000 (UTC) Subject: Script To Remove Files Made Either By Python Or Git References: Message-ID: On 2015-10-09, Joshua Stokes wrote: > Is there an available script to remove file created by either using > the Python module or by using git? Yes. Execute the following at the bash prompt: $ rm $(find . ) -- Grant Edwards grant.b.edwards Yow! Four thousand at different MAGNATES, MOGULS gmail.com & NABOBS are romping in my gothic solarium!! From rosuav at gmail.com Fri Oct 9 10:08:59 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 10 Oct 2015 01:08:59 +1100 Subject: Script To Remove Files Made Either By Python Or Git In-Reply-To: References: Message-ID: On Sat, Oct 10, 2015 at 1:01 AM, Grant Edwards wrote: > Yes. Execute the following at the bash prompt: > > $ rm $(find . ) Or if you're using GNU find: $ find -delete ChrisA From python.list at tim.thechases.com Fri Oct 9 10:16:46 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Fri, 9 Oct 2015 09:16:46 -0500 Subject: Script To Remove Files Made Either By Python Or Git In-Reply-To: References: Message-ID: <20151009091646.2b2545c2@bigbox.christie.dr> On 2015-10-09 14:01, Grant Edwards wrote: > > Is there an available script to remove file created by either > > using the Python module or by using git? > > Yes. Execute the following at the bash prompt: > > $ rm $(find . ) If you've got GNU find, you can just $ find . -type f {find-options-go-here} -delete (The find(1) on the OpenBSD box I have at hand doesn't include a -delete option) -tkc From marko at pacujo.net Fri Oct 9 11:05:55 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 09 Oct 2015 18:05:55 +0300 Subject: Script To Remove Files Made Either By Python Or Git References: Message-ID: <87wpuwrsj0.fsf@elektro.pacujo.net> Chris Angelico : > On Sat, Oct 10, 2015 at 1:01 AM, Grant Edwards > wrote: >> $ rm $(find . ) This is not safe since find might return pathnames with spaces in them. Also, the command fails if find should produce no matches. > Or if you're using GNU find: > > $ find -delete This is safe. Marko From Cecil at decebal.nl Fri Oct 9 11:09:59 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Fri, 09 Oct 2015 17:09:59 +0200 Subject: Using pipe in a system call References: <87oag9nhl3.fsf@Equus.decebal.nl> <87k2qwo7hp.fsf@Equus.decebal.nl> Message-ID: <87a8rsnkmw.fsf@Equus.decebal.nl> On Friday 9 Oct 2015 15:12 CEST, Peter Otten wrote: > Dennis Lee Bieber wrote: > >> On Fri, 09 Oct 2015 08:56:18 +0200, Cecil Westerhof >> declaimed the following: >> >>> My bad, I intended to mention that ORDER BY gives the wrong order >>> (? comes after z and with sort it comes after e), so that is why I >>> use the external sort command. >>> >> My books show how to define collation functions for SQLite3 -- from >> C; don't show if Python can interface to that side (custom >> aggregation functions are shown, however). >> >> Even if you have to use the external sort, you can still avoid one >> process level by not spawning the external SQLite3 process. Collect >> the data from the Python level and sort the output (possibly, as >> mentioned elsewhere, if the data fits in memory, you can sort using >> Python itself and avoid all external processes). >> >> AH! the help file (still Python 2.7 -- though a quick glance at the >> P3 has the same text) shows: >> >> -=-=-=-=- >> create_collation(name, callable) >> >> Creates a collation with the specified name and callable. The >> callable will be passed two string arguments. It should return -1 >> if the first is ordered lower than the second, 0 if they are >> ordered equal and 1 if the first is ordered higher than the second. >> Note that this controls sorting (ORDER BY in SQL) so your >> comparisons don?t affect other SQL operations. >> >> Note that the callable will get its parameters as Python >> bytestrings, which will normally be encoded in UTF-8. >> >> The following example shows a custom collation that sorts ?the >> wrong way?: ... -=-=-=-=- >> >> So if one can write a short comparison function that gives the >> desired order, one can extend the SQL query with >> >> ... order by collate > > Turns out such a function already exists; it's called > > locale.strcoll() > > Modified example from the docs: > > $ cat sqlite3_collation.py > import sqlite3 > import locale > > print("Using locale", locale.setlocale(locale.LC_ALL, "")) > > con = sqlite3.connect(":memory:") > con.create_collation("localized", locale.strcoll) > > cur = con.cursor() > cur.execute("create table test(x)") > cur.executemany( > "insert into test(x) values (?)", > "a?bA?B") > cur.execute("select x from test order by x collate localized") > > for row in cur: > print(row) > con.close() > $ python3 sqlite3_collation.py > Using locale de_DE.UTF-8 > ('a',) > ('A',) > ('?',) > ('?',) > ('b',) > ('B',) > $ PYTHONIOENCODING=UTF-8 LANG=C python3 sqlite3_collation.py > Using locale C > ('A',) > ('B',) > ('a',) > ('b',) > ('?',) > ('?',) Thanks very much. I now have in my initialisation: conn.create_collation("localized", locale.strcoll) cursor = conn.cursor() locale.setlocale(locale.LC_ALL, 'en_GB.UTF-8') I use: with open('spreekwoorden2.txt', 'w') as spreekwoorden: cursor.execute(export_spreekwoorden) for spreekwoord in cursor: spreekwoorden.write('%s\n' % spreekwoord) and export_spreekwoorden is defined as: export_spreekwoorden = ''' SELECT spreekwoord FROM spreekwoorden ORDER BY spreekwoord COLLATE LOCALIZED ''' -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From remirampin at gmail.com Fri Oct 9 11:21:13 2015 From: remirampin at gmail.com (=?UTF-8?B?UsOpbWkgUmFtcGlu?=) Date: Fri, 9 Oct 2015 11:21:13 -0400 Subject: IPython Notebooks to Learn Python In-Reply-To: References: Message-ID: 2015-10-08 13:49 EDT, Rajath Kumar : > I have written IPython Notebooks to learn Python interactively. I have > covered all the basic concepts and it is everything one needs to get > started with the language. > > Do check it out : https://github.com/rajathkumarmp/Python-Lectures > I only went over this very quickly, but it looks like this is completely Python 2-specific. Also, your code would benefit from following PEP8. Your classes are old-style which is really not recommended (especially in Python 2!). You also seem to like coming up with your own names for Python concepts instead of using the common, documented names (like "implicit argument" -- why?). As it stands, I don't see the value in this when compared to the official documentation . Why not work on improving that, or converting it to notebooks? -- R?mi -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason.swails at gmail.com Fri Oct 9 11:44:21 2015 From: jason.swails at gmail.com (Jason Swails) Date: Fri, 9 Oct 2015 11:44:21 -0400 Subject: Script To Remove Files Made Either By Python Or Git In-Reply-To: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> References: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> Message-ID: On Fri, Oct 9, 2015 at 6:08 AM, Joshua Stokes wrote: > Hi > > Is there an available script to remove file created by either using the > Python module or by using git? > ?There's always this nugget: git clean -fxd This will get rid of *all* untracked files in the current directory of a git repo (and recursively all subdirectories). You can optionally specify a directory at the end of that command. Careful with this sledgehammer, though, as it will also trash any untracked source code files as well (and you may never get them back). HTH, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From invalid at invalid.invalid Fri Oct 9 11:49:38 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 9 Oct 2015 15:49:38 +0000 (UTC) Subject: Script To Remove Files Made Either By Python Or Git References: <87wpuwrsj0.fsf@elektro.pacujo.net> Message-ID: On 2015-10-09, Marko Rauhamaa wrote: >>> $ rm $(find . ) > > This is not safe since find might return pathnames with spaces in > them. Good point. > Also, the command fails if find should produce no matches. I just tried, it with a pattern that produced no matches, and it removed no files. That's what one would expect it to do. I admit the message from rm is undesirable. :) >> Or if you're using GNU find: >> >> $ find -delete > > This is safe. Agreed, that is a better answer. I've known for years that gnu find has a -delete option, but I always forget to _use_ it. -- Grant Edwards grant.b.edwards Yow! I'm having a at tax-deductible experience! gmail.com I need an energy crunch!! From johnmichaelreedfas at gmail.com Fri Oct 9 12:03:33 2015 From: johnmichaelreedfas at gmail.com (John Michael Lafayette) Date: Fri, 9 Oct 2015 12:03:33 -0400 Subject: Strong typing implementation for Python Message-ID: I would like Python to have a strong typing feature that can co-exist with the current dynamic typing system. Currently Python is like this: var animal = Factory.make("dog") #okay var dog = Factory.make("dog") #okay -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Fri Oct 9 12:20:00 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 09 Oct 2015 18:20:00 +0200 Subject: Script To Remove Files Made Either By Python Or Git In-Reply-To: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> References: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> Message-ID: <201510091620.t99GK0lH019812@fido.openend.se> In a message of Fri, 09 Oct 2015 21:08:22 +1100, Joshua Stokes writes: >Hi > >Is there an available script to remove file created by either using the Python module or by using git? > >Thanks > >>From Joshua P Stokes No. A file is a file. It doesn't know which program created it. I can use python to create a file named anything_I_like and place it anywhere I have write permission in the filesystem. There is no way to get it to identify itself as 'made by python', so there is no way to write such a script. Now, python itself makes .pyc files whenever it runs, so if you want to clean those up, finding them and removing them is easy. But we need to know what OS you are running. If you want to delete a git repository, that is also fairly easy to do. If you want to do something else -- for instance, find out if you have any git repositories on this machine -- explain more about what you want to accomplish, and why. Laura From johnmichaelreedfas at gmail.com Fri Oct 9 12:26:17 2015 From: johnmichaelreedfas at gmail.com (John Michael Lafayette) Date: Fri, 9 Oct 2015 12:26:17 -0400 Subject: Strong typing implementation for Python Message-ID: I would like Python to have a strong typing feature that can co-exist with the current dynamic typing system. Currently Python is like this: var animal = Factory.make("dog") # okay. var dog = Factory.make("dog") # okay. var cat = Factory.make("dog") # are you sure? I would like Python to also be able to also do this: Animal a = Factory.make("dog") # okay. Dog is Animal. Dog d = Factory.make("dog") # okay. Dog is Dog. Cat c = Factory.make("cat") # Runtime error. Dog is not Cat. With a strong typing option that performs runtime type checking, the reader can be certain that the program is running the type they expect. Also, the IDE can be more helpful. Example: var dog = Factory.make("dog") # okay dog. (Ctr+Space) # Auto-complete lists only Animal methods. Dog d = Factory.make("dog") # okay. Dog is dog. d. (Ctr+Space) # Auto-complete lists methods for Dog and Animal. In C++, this could be implemented by using dynamic_cast or typeinfo / typeid. The interpreter look for an uppercase word followed by a lowercase word followed by "=" and then it check the type on the right side of the "=" at runtime and see if it is an instance of the (uppercase) type on the left side of the "=". If not, the interpreter throws a runtime error that says something like "Type Dog is not instance of type Cat. Line: 45". This feature can be completely optional and could be integrated without anyone noticing. If it is integrated, only the people who want this type safety would have to use it. If there is a performance penalty, it would mainly affect the people who use this feature. Given that a lot of people transition from C/C++/Java to Python, I think that this feature would be intuitive to many users and a good addition for people who like type safety. -------------- next part -------------- An HTML attachment was scrubbed... URL: From arsh840 at gmail.com Fri Oct 9 13:12:16 2015 From: arsh840 at gmail.com (Arshpreet Singh) Date: Fri, 9 Oct 2015 10:12:16 -0700 (PDT) Subject: Recover data over the network Message-ID: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> Hello Python and People! I want to write a small Python application which will be able to 1.recover data from server and 2.send it to another server. For the 2nd part I can use scp(secure copy), Please let me know if any data-recovery library is available in Python to do 1st task. From emile at fenx.com Fri Oct 9 13:20:14 2015 From: emile at fenx.com (Emile van Sebille) Date: Fri, 9 Oct 2015 10:20:14 -0700 Subject: Recover data over the network In-Reply-To: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> Message-ID: On 10/9/2015 10:12 AM, Arshpreet Singh wrote: > Hello Python and People! > > I want to write a small Python application which will be able to 1.recover data from server and 2.send it to another server. > > For the 2nd part I can use scp(secure copy), Please let me know if any data-recovery library is available in Python to do 1st task. > without extensive clues as to the nature of the data to be recovered you're not going to get much further with this. When I've had to recover data from disks or damaged files is generally been a one-off kind of recovery. But, I'd choose scp if it's an option. :) Emile From garyhski at gmail.com Fri Oct 9 13:24:34 2015 From: garyhski at gmail.com (Gary Hanyzewski) Date: Fri, 9 Oct 2015 10:24:34 -0700 (PDT) Subject: Errors installing xmiparser with Python 3.4 and windows - any help? Message-ID: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> I am trying to install xmiparser-1.5.dev-r124826 into python 3.4.0 on a windows machine. When I try and install (either with pip or setup.py install) I get a number of syntax errors in the code ( below) Has anyone managed to install and use the xmiparser module in python 3.4? If so what's the trick? if not any pointers on what I can do to get it to go. Are there any other xmi parsers or tools? Thanks Gary ---- Error output below ------ >python setup.py install running install running bdist_egg running egg_info writing entry points to xmiparser.egg-info\entry_points.txt writing namespace_packages to xmiparser.egg-info\namespace_packages.txt writing requirements to xmiparser.egg-info\requires.txt writing dependency_links to xmiparser.egg-info\dependency_links.txt writing xmiparser.egg-info\PKG-INFO writing top-level names to xmiparser.egg-info\top_level.txt reading manifest file 'xmiparser.egg-info\SOURCES.txt' writing manifest file 'xmiparser.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py creating build\bdist.win-amd64\egg creating build\bdist.win-amd64\egg\xmiparser creating build\bdist.win-amd64\egg\xmiparser\doc copying build\lib\xmiparser\doc\umlsample.zargo -> build\bdist.win-amd64\egg\xmi parser\doc copying build\lib\xmiparser\interfaces.py -> build\bdist.win-amd64\egg\xmiparser creating build\bdist.win-amd64\egg\xmiparser\tests copying build\lib\xmiparser\tests\test_doctest.py -> build\bdist.win-amd64\egg\x miparser\tests copying build\lib\xmiparser\tests\xmiparser.txt -> build\bdist.win-amd64\egg\xmi parser\tests copying build\lib\xmiparser\tests\__init__.py -> build\bdist.win-amd64\egg\xmipa rser\tests copying build\lib\xmiparser\utils.py -> build\bdist.win-amd64\egg\xmiparser copying build\lib\xmiparser\xmiparser.py -> build\bdist.win-amd64\egg\xmiparser copying build\lib\xmiparser\zargoparser.py -> build\bdist.win-amd64\egg\xmiparse r copying build\lib\xmiparser\__init__.py -> build\bdist.win-amd64\egg\xmiparser byte-compiling build\bdist.win-amd64\egg\xmiparser\interfaces.py to interfaces.c python-34.pyc byte-compiling build\bdist.win-amd64\egg\xmiparser\tests\test_doctest.py to test _doctest.cpython-34.pyc byte-compiling build\bdist.win-amd64\egg\xmiparser\tests\__init__.py to __init__ .cpython-34.pyc byte-compiling build\bdist.win-amd64\egg\xmiparser\utils.py to utils.cpython-34. pyc byte-compiling build\bdist.win-amd64\egg\xmiparser\xmiparser.py to xmiparser.cpy thon-34.pyc File "build\bdist.win-amd64\egg\xmiparser\xmiparser.py", line 400 raise TypeError, 'element %s has empty taggedValue' % self.getId(el) ^ SyntaxError: invalid syntax byte-compiling build\bdist.win-amd64\egg\xmiparser\zargoparser.py to zargoparser .cpython-34.pyc byte-compiling build\bdist.win-amd64\egg\xmiparser\__init__.py to __init__.cpyth on-34.pyc creating build\bdist.win-amd64\egg\EGG-INFO copying xmiparser.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO copying xmiparser.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO copying xmiparser.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG -INFO copying xmiparser.egg-info\entry_points.txt -> build\bdist.win-amd64\egg\EGG-INF O copying xmiparser.egg-info\namespace_packages.txt -> build\bdist.win-amd64\egg\E GG-INFO copying xmiparser.egg-info\not-zip-safe -> build\bdist.win-amd64\egg\EGG-INFO copying xmiparser.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO copying xmiparser.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO creating 'dist\xmiparser-1.5.dev_r124826-py3.4.egg' and adding 'build\bdist.win- amd64\egg' to it removing 'build\bdist.win-amd64\egg' (and everything under it) Processing xmiparser-1.5.dev_r124826-py3.4.egg removing 'c:\python34\lib\site-packages\xmiparser-1.5.dev_r124826-py3.4.egg' (an d everything under it) creating c:\python34\lib\site-packages\xmiparser-1.5.dev_r124826-py3.4.egg Extracting xmiparser-1.5.dev_r124826-py3.4.egg to c:\python34\lib\site-packages File "c:\python34\lib\site-packages\xmiparser-1.5.dev_r124826-py3.4.egg\xmipar ser\xmiparser.py", line 400 raise TypeError, 'element %s has empty taggedValue' % self.getId(el) ^ SyntaxError: invalid syntax xmiparser 1.5.dev-r124826 is already the active version in easy-install.pth Installed c:\python34\lib\site-packages\xmiparser-1.5.dev_r124826-py3.4.egg Processing dependencies for xmiparser==1.5.dev-r124826 Searching for zope.interface Reading https://pypi.python.org/simple/zope.interface/ Best match: zope.interface 4.1.3 Downloading https://pypi.python.org/packages/source/z/zope.interface/zope.interf ace-4.1.3.tar.gz#md5=9ae3d24c0c7415deb249dd1a132f0f79 Processing zope.interface-4.1.3.tar.gz Writing C:\Users\GHANYZ~1\AppData\Local\Temp\easy_install-hnq9571n\zope.interfac e-4.1.3\setup.cfg Running zope.interface-4.1.3\setup.py -q bdist_egg --dist-dir C:\Users\GHANYZ~1\ AppData\Local\Temp\easy_install-hnq9571n\zope.interface-4.1.3\egg-dist-tmp-j5z_0 _r8 warning: no previously-included files matching '*.dll' found anywhere in distrib ution warning: no previously-included files matching '*.pyc' found anywhere in distrib ution warning: no previously-included files matching '*.pyo' found anywhere in distrib ution warning: no previously-included files matching '*.so' found anywhere in distribu tion warning: no previously-included files matching 'coverage.xml' found anywhere in distribution no previously-included directories found matching 'docs\_build' Traceback (most recent call last): File "setup.py", line 45, in """, File "C:\Python34\lib\distutils\core.py", line 149, in setup dist.run_commands() File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands self.run_command(cmd) File "C:\Python34\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "C:\Python34\lib\site-packages\setuptools\command\install.py", line 74, i n run self.do_egg_install() File "C:\Python34\lib\site-packages\setuptools\command\install.py", line 97, i n do_egg_install cmd.run() File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 358, in run self.easy_install(spec, not self.no_deps) File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 574, in easy_install return self.install_item(None, spec, tmpdir, deps, True) File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 625, in install_item self.process_distribution(spec, dist, deps) File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 671, in process_distribution [requirement], self.local_index, self.easy_install File "C:\Python34\lib\site-packages\pkg_resources.py", line 564, in resolve dist = best[req.key] = env.best_match(req, self, installer) File "C:\Python34\lib\site-packages\pkg_resources.py", line 802, in best_match return self.obtain(req, installer) # try and download/install File "C:\Python34\lib\site-packages\pkg_resources.py", line 814, in obtain return installer(requirement) File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 593, in easy_install return self.install_item(spec, dist.location, tmpdir, deps) File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 623, in install_item dists = self.install_eggs(spec, download, tmpdir) File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 809, in install_eggs return self.build_and_install(setup_script, setup_base) File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 1015, in build_and_install self.run_setup(setup_script, setup_base, args) File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line 1000, in run_setup run_setup(setup_script, args) File "C:\Python34\lib\site-packages\setuptools\sandbox.py", line 50, in run_se tup lambda: execfile( File "C:\Python34\lib\site-packages\setuptools\sandbox.py", line 100, in run return func() File "C:\Python34\lib\site-packages\setuptools\sandbox.py", line 52, in {'__file__':setup_script, '__name__':'__main__'} File "C:\Python34\lib\site-packages\setuptools\compat.py", line 78, in execfil e exec(compile(source, fn, 'exec'), globs, locs) File "setup.py", line 147, in File "C:\Python34\lib\distutils\core.py", line 149, in setup dist.run_commands() File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands self.run_command(cmd) File "C:\Python34\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "C:\Python34\lib\site-packages\setuptools\command\bdist_egg.py", line 185 , in run cmd = self.call_command('install_lib', warn_dir=0) File "C:\Python34\lib\site-packages\setuptools\command\bdist_egg.py", line 171 , in call_command self.run_command(cmdname) File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\Python34\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "C:\Python34\lib\site-packages\setuptools\command\install_lib.py", line 2 0, in run self.build() File "C:\Python34\lib\distutils\command\install_lib.py", line 107, in build self.run_command('build_ext') File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\Python34\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "setup.py", line 41, in run 'ordereddict', File "C:\Python34\lib\site-packages\setuptools\command\build_ext.py", line 52, in run _build_ext.run(self) File "C:\Python34\lib\distutils\command\build_ext.py", line 348, in run self.build_extensions() File "C:\Python34\lib\distutils\command\build_ext.py", line 457, in build_exte nsions self.build_extension(ext) File "setup.py", line 47, in build_extension File "C:\Python34\lib\site-packages\setuptools\command\build_ext.py", line 186 , in build_extension _build_ext.build_extension(self,ext) File "C:\Python34\lib\distutils\command\build_ext.py", line 512, in build_exte nsion depends=ext.depends) File "C:\Python34\lib\distutils\msvc9compiler.py", line 460, in compile self.initialize() File "C:\Python34\lib\distutils\msvc9compiler.py", line 371, in initialize vc_env = query_vcvarsall(VERSION, plat_spec) File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsal l raise ValueError(str(list(result.keys()))) ValueError: ['path'] From lac at openend.se Fri Oct 9 13:47:50 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 09 Oct 2015 19:47:50 +0200 Subject: Errors installing xmiparser with Python 3.4 and windows - any help? In-Reply-To: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> References: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> Message-ID: <201510091747.t99Hlo2D025964@fido.openend.se> In a message of Fri, 09 Oct 2015 10:24:34 -0700, Gary Hanyzewski writes: >I am trying to install xmiparser-1.5.dev-r124826 into python 3.4.0 on a windows machine. >When I try and install (either with pip or setup.py install) I get a number of syntax errors in the code ( below) > >Has anyone managed to install and use the xmiparser module in python 3.4? If so what's the trick? if not any pointers on what I can do to get it to go. Are there any other xmi parsers or tools? > >Thanks > >Gary Any time I have problems with easy_install I first pip install this: https://pypi.python.org/pypi/ez_setup and see if the problems go away. No promises ... Laura From lac at openend.se Fri Oct 9 14:14:08 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 09 Oct 2015 20:14:08 +0200 Subject: Errors installing xmiparser with Python 3.4 and windows - any help? In-Reply-To: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> References: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> Message-ID: <201510091814.t99IE85t027860@fido.openend.se> In a message of Fri, 09 Oct 2015 10:24:34 -0700, Gary Hanyzewski writes: >I am trying to install xmiparser-1.5.dev-r124826 into python 3.4.0 on a windows machine. >When I try and install (either with pip or setup.py install) I get a number of syntax errors in the code ( below) > >Has anyone managed to install and use the xmiparser module in python 3.4? If so what's the trick? if not any pointers on what I can do to get it to go. Are there any other xmi parsers or tools? > >Thanks > >Gary If XMI is just XML according to a particular schema, then you can get the schema over here: http://www.omg.org/spec/XMI/2.5.1/ And then parse it with PyXB. https://pypi.python.org/pypi/PyXB But maybe I don't understand what XMI is well enough. Laura From zachary.ware+pylist at gmail.com Fri Oct 9 14:38:34 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Fri, 9 Oct 2015 13:38:34 -0500 Subject: Errors installing xmiparser with Python 3.4 and windows - any help? In-Reply-To: <201510091747.t99Hlo2D025964@fido.openend.se> References: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> <201510091747.t99Hlo2D025964@fido.openend.se> Message-ID: On Fri, Oct 9, 2015 at 12:47 PM, Laura Creighton wrote: > In a message of Fri, 09 Oct 2015 10:24:34 -0700, Gary Hanyzewski writes: >>I am trying to install xmiparser-1.5.dev-r124826 into python 3.4.0 on a windows machine. >>When I try and install (either with pip or setup.py install) I get a number of syntax errors in the code ( below) >> >>Has anyone managed to install and use the xmiparser module in python 3.4? If so what's the trick? if not any pointers on what I can do to get it to go. Are there any other xmi parsers or tools? >> >>Thanks >> >>Gary > > Any time I have problems with easy_install I first pip install this: > https://pypi.python.org/pypi/ez_setup and see if the problems go away. > No promises ... That won't help here; xmiparser appears to have not been updated since 2010, and has no hint of Python 3 support. -- Zach From gall.pavgal.gall at gmail.com Fri Oct 9 14:45:30 2015 From: gall.pavgal.gall at gmail.com (gall.pavgal.gall at gmail.com) Date: Fri, 9 Oct 2015 11:45:30 -0700 (PDT) Subject: win32com.client .Cells Message-ID: <097ed748-765c-4134-bcf2-5b2d538c4db7@googlegroups.com> Hi Guys, i wrote small function : Excel = win32com.client.Dispatch("Excel.Application") excel_book=Excel.Workbooks.Open('D:\WebPython\Config3.xlsx') s_config=excel_book.Worksheets('VA Prices') def writtenCell(row,col,value): try: global s_config print "row --> {0}".format(row) print "col --> {0}".format(col) print "value --> {0}".format(value) old_val = s_config.Cells(row+1,col).Value s_config.Cells(row+1,col).Value = value s_config.Cells(row+1,col).Interior.ColorIndex = 8 # change fon color of CELL except Exception as err: print err So, it's work :) But, when i try call this function from Class, i get error : row --> 36 col --> 18 value --> 34.99 .Cells row --> 36 col --> 19 value --> 39.99 .Cells 127.0.0.1 - - [09/Oct/2015 21:44:47] "POST /cscox-99988 HTTP/1.1" 500 - Traceback (most recent call last): File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__ return self.wsgi_app(environ, start_response) File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app response = self.make_response(self.handle_exception(e)) File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception reraise(exc_type, exc_value, tb) File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "D:\WebPython\new\main.py", line 36, in cust_dir return define_ID(cscoxId=cscoxId,upload_folder=app.config['UPLOAD_FOLDER'], request=request) File "D:\WebPython\new\utils.py", line 51, in define_ID return upload_file(session['customer_dir'][0],request) File "D:\WebPython\new\utils.py", line 61, in upload_file run_exel( config_file=session['config_file'],customer_dir=session['customer_dir'][0],customer_file=os.path.join(upload_folder, filename),log_name=session['cox_id']) File "D:\WebPython\new\utils.py", line 84, in run_exel customer.merge_to_config() File "D:\WebPython\new\main.py", line 119, in merge_to_config excel_book.Save() File "", line 2, in Save com_error: (-2147221008, 'CoInitialize has not been called.', None, None) Please, help me! :) From breamoreboy at yahoo.co.uk Fri Oct 9 19:05:39 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 10 Oct 2015 00:05:39 +0100 Subject: Errors installing xmiparser with Python 3.4 and windows - any help? In-Reply-To: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> References: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> Message-ID: On 09/10/2015 18:24, Gary Hanyzewski wrote: > I am trying to install xmiparser-1.5.dev-r124826 into python 3.4.0 on a windows machine. > When I try and install (either with pip or setup.py install) I get a number of syntax errors in the code ( below) > > Has anyone managed to install and use the xmiparser module in python 3.4? If so what's the trick? if not any pointers on what I can do to get it to go. Are there any other xmi parsers or tools? > > Thanks > > Gary > [mega snip] Try running the code through 2to3, then have the usual fun and games getting anything to compile on Windows, although I'd have thought it was blatantly obvious what the following meant. File "C:\Python34\lib\distutils\msvc9compiler.py", line 460, in compile self.initialize() File "C:\Python34\lib\distutils\msvc9compiler.py", line 371, in initialize vc_env = query_vcvarsall(VERSION, plat_spec) File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsal l raise ValueError(str(list(result.keys()))) ValueError: ['path'] **NOT** -- 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 Fri Oct 9 19:10:04 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sat, 10 Oct 2015 10:10:04 +1100 Subject: Recover data over the network References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> Message-ID: <5618494f$0$1584$c3e8da3$5496439d@news.astraweb.com> On Sat, 10 Oct 2015 04:12 am, Arshpreet Singh wrote: > Hello Python and People! > > I want to write a small Python application which will be able to 1.recover > data from server and 2.send it to another server. What do you mean, "recover data from a server"? What has happened to the server? Can it boot or is it in an unbootable state? Are the hard drives physically damaged? What sort of hard drives? (Solid state, or magnetic media?) What makes you think this will be a "small" Python application? Do you have limits on the maximum size? (Does the application have to fit on a floppy disk?) Are you expecting a GUI? What OS do you want the application to run on? (Windows, Linux, Mac OS, Android, embedded systems, something else?) > For the 2nd part I can use scp(secure copy), Please let me know if any > data-recovery library is available in Python to do 1st task. Depends on what you mean by data recovery. -- Steven From breamoreboy at yahoo.co.uk Fri Oct 9 19:12:19 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 10 Oct 2015 00:12:19 +0100 Subject: Script To Remove Files Made Either By Python Or Git In-Reply-To: References: <36FE4C1F-2B11-4606-8A8C-7FFE999F8364@icloud.com> Message-ID: On 09/10/2015 16:44, Jason Swails wrote: > > > On Fri, Oct 9, 2015 at 6:08 AM, Joshua Stokes > wrote: > > Hi > > Is there an available script to remove file created by either using > the Python module or by using git? > > > ?There's always this nugget: > > git clean -fxd > > This will get rid of *all* untracked files in the current directory of a > git repo (and recursively all subdirectories). You can optionally > specify a directory at the end of that command. > > Careful with this sledgehammer, though, as it will also trash any > untracked source code files as well (and you may never get them back). > > HTH, > Jason > Well as this thread appears to be pretty useless I'll simply point out that you are known to me as "The Outlaw" Jason Swails, there's either "Tell Laura, I love her," Creighton OR Laura "Red Dwarf" Creighton, Dr Brett "Loose" Cannon but even I have to feel sorry for poor old Donald Stufft. -- 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 Fri Oct 9 19:54:23 2015 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Sat, 10 Oct 2015 01:54:23 +0200 Subject: win32com.client .Cells In-Reply-To: <097ed748-765c-4134-bcf2-5b2d538c4db7@googlegroups.com> References: <097ed748-765c-4134-bcf2-5b2d538c4db7@googlegroups.com> Message-ID: <561853ae$0$23734$e4fe514c@news.xs4all.nl> On 9-10-2015 20:45, gall.pavgal.gall at gmail.com wrote: > Hi Guys, > > i wrote small function : > > Excel = win32com.client.Dispatch("Excel.Application") [...] > com_error: (-2147221008, 'CoInitialize has not been called.', None, None) > > Please, help me! :) > First hit on google when searching for "CoInitialize has not been called python": http://stackoverflow.com/questions/26745617/win32com-client-dispatch-cherrypy-coinitialize-has-not-been-called I.e. do what the error says, call CoInitialize from your threads. Irmen From arsh840 at gmail.com Fri Oct 9 22:44:12 2015 From: arsh840 at gmail.com (Arshpreet Singh) Date: Fri, 9 Oct 2015 19:44:12 -0700 (PDT) Subject: Recover data over the network In-Reply-To: <5618494f$0$1584$c3e8da3$5496439d@news.astraweb.com> References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> <5618494f$0$1584$c3e8da3$5496439d@news.astraweb.com> Message-ID: <30a9ad8c-1417-4004-8d2d-19a13c95afa1@googlegroups.com> On Saturday, 10 October 2015 04:40:27 UTC+5:30, Steven D'Aprano wrote: > What do you mean, "recover data from a server"? What has happened to the > server? Can it boot or is it in an unbootable state? Are the hard drives > physically damaged? What sort of hard drives? (Solid state, or magnetic > media?) Server is booting up. We are using SSD. Disk is not physically Damaged. I can't reach to server Physically. > What makes you think this will be a "small" Python application? Do you have > limits on the maximum size? (Does the application have to fit on a floppy > disk?) Are you expecting a GUI? What OS do you want the application to run > on? (Windows, Linux, Mac OS, Android, embedded systems, something else?) >From the small I was meaning a simple Python command Line application. That I will be able to execute from shell. Server is on Ubuntu Linux. > > For the 2nd part I can use scp(secure copy), Please let me know if any > > data-recovery library is available in Python to do 1st task. > > Depends on what you mean by data recovery. My main aim is to recover user accounts mostly data present in /home partition of the disk. From arsh840 at gmail.com Fri Oct 9 22:44:18 2015 From: arsh840 at gmail.com (Arshpreet Singh) Date: Fri, 9 Oct 2015 19:44:18 -0700 (PDT) Subject: Recover data over the network In-Reply-To: <5618494f$0$1584$c3e8da3$5496439d@news.astraweb.com> References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> <5618494f$0$1584$c3e8da3$5496439d@news.astraweb.com> Message-ID: <30f34702-573c-4816-bebb-6033358e8014@googlegroups.com> On Saturday, 10 October 2015 04:40:27 UTC+5:30, Steven D'Aprano wrote: > What do you mean, "recover data from a server"? What has happened to the > server? Can it boot or is it in an unbootable state? Are the hard drives > physically damaged? What sort of hard drives? (Solid state, or magnetic > media?) Server is booting up. We are using SSD. Disk is not physically Damaged. I can't reach to server Physically. > What makes you think this will be a "small" Python application? Do you have > limits on the maximum size? (Does the application have to fit on a floppy > disk?) Are you expecting a GUI? What OS do you want the application to run > on? (Windows, Linux, Mac OS, Android, embedded systems, something else?) >From the small I was meaning a simple Python command Line application. That I will be able to execute from shell. Server is on Ubuntu Linux. > > For the 2nd part I can use scp(secure copy), Please let me know if any > > data-recovery library is available in Python to do 1st task. > > Depends on what you mean by data recovery. My main aim is to recover user accounts mostly data present in /home partition of the disk. From arsh840 at gmail.com Fri Oct 9 22:47:12 2015 From: arsh840 at gmail.com (Arshpreet Singh) Date: Fri, 9 Oct 2015 19:47:12 -0700 (PDT) Subject: Recover data over the network In-Reply-To: References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> Message-ID: <8872d3ab-aa02-4d2d-ad8c-a13985b118cb@googlegroups.com> On Friday, 9 October 2015 22:51:16 UTC+5:30, Emile van Sebille wrote: > without extensive clues as to the nature of the data to be recovered > you're not going to get much further with this. It is mostly /home partition data on disk. Those are user Configuration files.(user accounts, settings etc) >When I've had to > recover data from disks or damaged files is generally been a one-off > kind of recovery. Please enlighten me about one-off kind of data recovery. From emile at fenx.com Fri Oct 9 23:06:23 2015 From: emile at fenx.com (Emile van Sebille) Date: Fri, 9 Oct 2015 20:06:23 -0700 Subject: Recover data over the network In-Reply-To: <8872d3ab-aa02-4d2d-ad8c-a13985b118cb@googlegroups.com> References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> <8872d3ab-aa02-4d2d-ad8c-a13985b118cb@googlegroups.com> Message-ID: On 10/9/2015 7:47 PM, Arshpreet Singh wrote: > On Friday, 9 October 2015 22:51:16 UTC+5:30, Emile van Sebille wrote: > >> without extensive clues as to the nature of the data to be recovered >> you're not going to get much further with this. > > It is mostly /home partition data on disk. Those are user Configuration files.(user accounts, settings etc) > >> When I've had to >> recover data from disks or damaged files is generally been a one-off >> kind of recovery. > > Please enlighten me about one-off kind of data recovery. This isn't really on-topic for this forum, but if you haven't already, dd the drive to a file and work on that rather than on the drive directly to avoid degrading the situation further. Then find a recovery utility that meets your needs and go forward from there. You're not likely to find a command line python utility that'll do it for you. Emile From wrw at mac.com Fri Oct 9 23:44:26 2015 From: wrw at mac.com (William Ray Wing) Date: Fri, 09 Oct 2015 23:44:26 -0400 Subject: Recover data over the network In-Reply-To: <30f34702-573c-4816-bebb-6033358e8014@googlegroups.com> References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> <5618494f$0$1584$c3e8da3$5496439d@news.astraweb.com> <30f34702-573c-4816-bebb-6033358e8014@googlegroups.com> Message-ID: > On Oct 9, 2015, at 10:44 PM, Arshpreet Singh wrote: > >> On Saturday, 10 October 2015 04:40:27 UTC+5:30, Steven D'Aprano wrote: >> >> What do you mean, "recover data from a server"? What has happened to the >> server? Can it boot or is it in an unbootable state? Are the hard drives >> physically damaged? What sort of hard drives? (Solid state, or magnetic >> media?) > > Server is booting up. We are using SSD. Disk is not physically Damaged. I can't reach to server Physically. > > >> What makes you think this will be a "small" Python application? Do you have >> limits on the maximum size? (Does the application have to fit on a floppy >> disk?) Are you expecting a GUI? What OS do you want the application to run >> on? (Windows, Linux, Mac OS, Android, embedded systems, something else?) > > From the small I was meaning a simple Python command Line application. That I will be able to execute from shell. Server is on Ubuntu Linux. > >>> For the 2nd part I can use scp(secure copy), Please let me know if any >>> data-recovery library is available in Python to do 1st task. >> >> Depends on what you mean by data recovery. > > My main aim is to recover user accounts mostly data present in /home partition of the disk. > -- > https://mail.python.org/mailman/listinfo/python-list I hesitate to mention this, but there _may_ be a communication problem here. When American-English speakers refer to data recovery, they usually are discussing reading data from a disk that has suffered some catastrophic event, say a head crash or an inadvertent wholesale data deletion. In either case physical access to the hardware is assumed (and required). Based on what you've said so far, you don't have physical access, the disk (SSD) is operating normally, and you simply want remote read access to the /home directory tree. Is this correct? If the answer is yes, then the discussion will head off in an entirely different direction. Bill From torriem at gmail.com Sat Oct 10 00:07:10 2015 From: torriem at gmail.com (Michael Torrie) Date: Fri, 09 Oct 2015 22:07:10 -0600 Subject: Recover data over the network In-Reply-To: <8872d3ab-aa02-4d2d-ad8c-a13985b118cb@googlegroups.com> References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> <8872d3ab-aa02-4d2d-ad8c-a13985b118cb@googlegroups.com> Message-ID: <56188EEE.8060200@gmail.com> On 10/09/2015 08:47 PM, Arshpreet Singh wrote: > On Friday, 9 October 2015 22:51:16 UTC+5:30, Emile van Sebille wrote: > >> without extensive clues as to the nature of the data to be recovered >> you're not going to get much further with this. > > It is mostly /home partition data on disk. Those are user Configuration files.(user accounts, settings etc) > >> When I've had to >> recover data from disks or damaged files is generally been a one-off >> kind of recovery. > > Please enlighten me about one-off kind of data recovery. So you're not trying to "recover" data as in the server failed and the file system won't mount, but rather just copy off files. Correct? If so, then what you're really trying to do is just copy data off. This is what rsync was invented for. Sure you could hack a script with Python to run this kind of thing, but really either a one-liner from the command prompt with rsync, or a simple bash script is all you need. If you need to recover data from unmountable disks, you'll have to look into file recovery software. Good luck. As Emile says, this isn't really a Python thing. From torriem at gmail.com Sat Oct 10 01:08:22 2015 From: torriem at gmail.com (Michael Torrie) Date: Fri, 09 Oct 2015 23:08:22 -0600 Subject: Recover data over the network In-Reply-To: References: <000c472b-74c4-45b0-a1ec-6cb165cb64ca@googlegroups.com> <5618494f$0$1584$c3e8da3$5496439d@news.astraweb.com> <30f34702-573c-4816-bebb-6033358e8014@googlegroups.com> Message-ID: <56189D46.9090605@gmail.com> On 10/09/2015 09:44 PM, William Ray Wing wrote: > I hesitate to mention this, but there _may_ be a communication > problem here. When American-English speakers refer to data recovery, > they usually are discussing reading data from a disk that has > suffered some catastrophic event, say a head crash or an inadvertent > wholesale data deletion. In either case physical access to the > hardware is assumed (and required). Based on what you've said so far, > you don't have physical access, the disk (SSD) is operating normally, > and you simply want remote read access to the /home directory tree. > Is this correct? If the answer is yes, then the discussion will head > off in an entirely different direction. Good point. rsync over ssh is his answer. That's what it was designed for. And maybe a bit of bash scripting. I don't see Python as a good fit for this task. From sanpo at sspipe.net Sat Oct 10 01:39:36 2015 From: sanpo at sspipe.net (Shreenivas Potnis) Date: Sat, 10 Oct 2015 11:09:36 +0530 Subject: Error Message-ID: <240A2D8E7B334AF9B8DE0CE9497CAD8A@SystemSetters> I have 32 bit machine with XP service pack 3. 1. I installed x86 version of python. While running I get the following error: 2. Also while installing the no buttons are displayed. I had to gusess where to click: Regards Shreenivas Potnis -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 11290 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 44136 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image003.jpg Type: image/jpeg Size: 17128 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: oledata.mso Type: application/octet-stream Size: 52728 bytes Desc: not available URL: From pinsonneaultsebastien at gmail.com Sat Oct 10 02:15:02 2015 From: pinsonneaultsebastien at gmail.com (=?UTF-8?Q?S=C3=A9bastien_Pinsonneault?=) Date: Sat, 10 Oct 2015 02:15:02 -0400 Subject: Python problem Message-ID: Hi, I've downloaded Python 3.5.0 64 bits, but I can't open it. It ask me each time if I want to modify, repair or uninstall, but doesn't open. I have Windows 10 64 bits. Thx -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Sat Oct 10 02:33:44 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 10 Oct 2015 17:33:44 +1100 Subject: Error In-Reply-To: <240A2D8E7B334AF9B8DE0CE9497CAD8A@SystemSetters> References: <240A2D8E7B334AF9B8DE0CE9497CAD8A@SystemSetters> Message-ID: On Sat, Oct 10, 2015 at 4:39 PM, Shreenivas Potnis wrote: > > I have 32 bit machine with XP service pack 3. > > I installed x86 version of python. > While running I get the following error: > > Python 3.5 does not run on XP. Instead, either use Python 3.4, or upgrade to a better operating system (Windows 7/8/10, or Linux or *BSD) to use Python 3.5. ChrisA From rosuav at gmail.com Sat Oct 10 02:34:55 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 10 Oct 2015 17:34:55 +1100 Subject: Python problem In-Reply-To: References: Message-ID: On Sat, Oct 10, 2015 at 5:15 PM, S?bastien Pinsonneault wrote: > I've downloaded Python 3.5.0 64 bits, but I can't open it. It ask me each > time if I want to modify, repair or uninstall, but doesn't open. > > I have Windows 10 64 bits. "doesn't open"? Do you mean that it's refusing to install, or that it's installed but you now can't find Python? ChrisA From ben+python at benfinney.id.au Sat Oct 10 03:40:43 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 10 Oct 2015 18:40:43 +1100 Subject: Static typing implementation for Python (was: Strong typing implementation for Python) References: Message-ID: <85d1wnw4qs.fsf@benfinney.id.au> John Michael Lafayette writes: > I would like Python to have a strong typing feature that can co-exist > with the current dynamic typing system. You have incorrectly conflated two separate matters. The opposite of string typing is weak typing. Python has strong typing: its objects will only behave according to the type they're defined as, and won't pretend to be what they're not. The opposite of dynamic typing is static typing. Python has dynamic typing: references are not at all restricted in what type of object they reference. > I would like Python to also be able to also do this: > > Animal a = Factory.make("dog") # okay. Dog is Animal. > Dog d = Factory.make("dog") # okay. Dog is Dog. > Cat c = Factory.make("cat") # Runtime error. Dog is not Cat. By that example, you appear to want static typing: references are restricted to a particular type and cannot refer to other types. The two ends of that spectrum are pretty much incompatible: to gain static typing, you must lose dynamic typing. That does not strike me as an improvement for Python. There are plenty of statically-typed languages; why would you want Python to lose its dynamic typing? > With a strong typing option that performs runtime type checking, the > reader can be certain that the program is running the type they > expect. Also, the IDE can be more helpful. Type annotations and type hints are both in Python already. They are entirely optional: code which does not use them can ignore them completely. However, they appear to provide the benefits you describe, without losing any of the power of dynamic typing. -- \ ?When cryptography is outlawed, bayl bhgynjf jvyy unir | `\ cevinpl.? ?Anonymous | _o__) | Ben Finney From frank at chagford.com Sat Oct 10 03:45:25 2015 From: frank at chagford.com (Frank Millman) Date: Sat, 10 Oct 2015 09:45:25 +0200 Subject: Using pipe in a system call In-Reply-To: <87a8rsnkmw.fsf@Equus.decebal.nl> References: <87oag9nhl3.fsf@Equus.decebal.nl> <87k2qwo7hp.fsf@Equus.decebal.nl> <87a8rsnkmw.fsf@Equus.decebal.nl> Message-ID: "Cecil Westerhof" wrote in message news:87a8rsnkmw.fsf at Equus.decebal.nl... This has got nothing to do with your question (which I found interesting) but I thought I would mention it. > export_spreekwoorden is defined as: > export_spreekwoorden = ''' > SELECT spreekwoord > FROM spreekwoorden > ORDER BY spreekwoord COLLATE LOCALIZED > ''' This works fine, but if anyone examines the resulting sql, it is full of extra spaces and newlines. To avoid this, I have adopted this habit - export_spreekwoorden = ( "SELECT spreekwoord " "FROM spreekwoorden " "ORDER BY spreekwoord COLLATE LOCALIZED" ) To my eye, the result is nicer, at virtually no extra effort. Just don't forget the trailing space on all but the last line. Frank Millman From Cecil at decebal.nl Sat Oct 10 07:42:15 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sat, 10 Oct 2015 13:42:15 +0200 Subject: Using pipe in a system call References: <87oag9nhl3.fsf@Equus.decebal.nl> <87k2qwo7hp.fsf@Equus.decebal.nl> <87a8rsnkmw.fsf@Equus.decebal.nl> Message-ID: <874mhzne5k.fsf@Equus.decebal.nl> On Saturday 10 Oct 2015 09:45 CEST, Frank Millman wrote: > "Cecil Westerhof" wrote in message > news:87a8rsnkmw.fsf at Equus.decebal.nl... > > This has got nothing to do with your question (which I found > interesting) but I thought I would mention it. > >> export_spreekwoorden is defined as: >> export_spreekwoorden = ''' >> SELECT spreekwoord >> FROM spreekwoorden >> ORDER BY spreekwoord COLLATE LOCALIZED >> ''' > > This works fine, but if anyone examines the resulting sql, it is > full of extra spaces and newlines. > > To avoid this, I have adopted this habit - > > export_spreekwoorden = ( > "SELECT spreekwoord " > "FROM spreekwoorden " > "ORDER BY spreekwoord COLLATE LOCALIZED" > ) > > To my eye, the result is nicer, at virtually no extra effort. Just > don't forget the trailing space on all but the last line. Good idea, I will adopt it. With one modification: I also put a trailing space on the last line. That makes it easier when you extend the query. ;-) -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From Cecil at decebal.nl Sat Oct 10 08:17:41 2015 From: Cecil at decebal.nl (Cecil Westerhof) Date: Sat, 10 Oct 2015 14:17:41 +0200 Subject: Using pipe in a system call References: <87oag9nhl3.fsf@Equus.decebal.nl> <87k2qwo7hp.fsf@Equus.decebal.nl> <87a8rsnkmw.fsf@Equus.decebal.nl> <874mhzne5k.fsf@Equus.decebal.nl> Message-ID: <87wpuuncii.fsf@Equus.decebal.nl> On Saturday 10 Oct 2015 13:42 CEST, Cecil Westerhof wrote: > On Saturday 10 Oct 2015 09:45 CEST, Frank Millman wrote: > >> "Cecil Westerhof" wrote in message >> news:87a8rsnkmw.fsf at Equus.decebal.nl... >> >> This has got nothing to do with your question (which I found >> interesting) but I thought I would mention it. >> >>> export_spreekwoorden is defined as: >>> export_spreekwoorden = ''' >>> SELECT spreekwoord >>> FROM spreekwoorden >>> ORDER BY spreekwoord COLLATE LOCALIZED >>> ''' >> >> This works fine, but if anyone examines the resulting sql, it is >> full of extra spaces and newlines. >> >> To avoid this, I have adopted this habit - >> >> export_spreekwoorden = ( >> "SELECT spreekwoord " >> "FROM spreekwoorden " >> "ORDER BY spreekwoord COLLATE LOCALIZED" >> ) >> >> To my eye, the result is nicer, at virtually no extra effort. Just >> don't forget the trailing space on all but the last line. > > Good idea, I will adopt it. With one modification: I also put a > trailing space on the last line. That makes it easier when you > extend the query. ;-) I tried it, but it does not make things much better. I used something like this (with another statement): create_links_table = ( 'CREATE TABLE links (\n' ' ID integer PRIMARY KEY AUTOINCREMENT,\n' ' year integer NOT NULL,\n' ' month integer NOT NULL,\n' ' description text NOT NULL,\n' ' URL text NOT NULL UNIQUE\n' ')\n' ) This because I want to be able to print it and get something easy to understand. I prefer: CREATE TABLE links ( ID integer PRIMARY KEY AUTOINCREMENT, year integer NOT NULL, month integer NOT NULL, description text NOT NULL, URL text NOT NULL UNIQUE ) above: CREATE TABLE links ( ID integer PRIMARY KEY AUTOINCREMENT, year integer NOT NULL, month integer NOT NULL, description text NOT NULL, URL text NOT NULL UNIQUE\n) It gets rid of the spaces before, but for the rest it does not make much difference. Using create_links_table looks bad, while using print(create_links_table) looks good. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof From dfnsonfsduifb at gmx.de Sat Oct 10 10:24:55 2015 From: dfnsonfsduifb at gmx.de (Johannes Bauer) Date: Sat, 10 Oct 2015 16:24:55 +0200 Subject: Understanding WSGI together with Apache Message-ID: Hi there, I'm running an Apache 2.4 webserver using mod_wsgi 4.3.0. There are two different applications running in there running on two completely separate vhosts. I'm seeing some weird crosstalk between them which I do not understand. In particular, crosstalk concerning the locales of the two. One application needs to output, e.g., date information using a German locale. It uses locale.setlocale to set its LC_ALL to de_DE.UTF-8. Now the second application doesn't need nor want to be German. It wants to see the C locale everywhere, in particular because at some point it uses datetime.datetime.strptime() to parse a datetime. Here's where things get weird: Sometimes, my "C" locale process throws exceptions, because it's unable to parse a date. When looking why this fails, the string looks like de_DE's "Sa, 10 Okt 2015" instead of C's "Sat, 10 Oct 2015". This seems to happen depending on which worker thread is currently serving the request, i.e. nondeterministically. So all in all, this is very weird and I must admit that I don't seem to fully understand how WSGI applications are run and served within a mod_wsgi framework altogether. In the past it all "just worked" and I didn't need to understand it all in-depth. But I think to be able to debug such a weird issue, in-depth knowledge of what happens under the hood would be helpful. So if someone could shed some light on how it works in general or what could cause the described issue in particular, I'd really be grateful. Thanks, 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 emile at fenx.com Sat Oct 10 10:44:15 2015 From: emile at fenx.com (Emile van Sebille) Date: Sat, 10 Oct 2015 07:44:15 -0700 Subject: Using pipe in a system call In-Reply-To: <874mhzne5k.fsf@Equus.decebal.nl> References: <87oag9nhl3.fsf@Equus.decebal.nl> <87k2qwo7hp.fsf@Equus.decebal.nl> <87a8rsnkmw.fsf@Equus.decebal.nl> <874mhzne5k.fsf@Equus.decebal.nl> Message-ID: On 10/10/2015 4:42 AM, Cecil Westerhof wrote: >> >To avoid this, I have adopted this habit - >> > >> >export_spreekwoorden = ( >> >"SELECT spreekwoord " >> >"FROM spreekwoorden " >> >"ORDER BY spreekwoord COLLATE LOCALIZED" >> >) >> > >> >To my eye, the result is nicer, at virtually no extra effort. Just >> >don't forget the trailing space on all but the last line. > Good idea, I will adopt it. With one modification: I also put a > trailing space on the last line. That makes it easier when you extend > the query.;-) I've done the same, but find that leading spaces work better for me -- they line up nicely on the left rather than the trailing ragged edge. Emile From garyhski at gmail.com Sat Oct 10 12:13:52 2015 From: garyhski at gmail.com (Gary Hanyzewski) Date: Sat, 10 Oct 2015 09:13:52 -0700 (PDT) Subject: Errors installing xmiparser with Python 3.4 and windows - any help? In-Reply-To: References: <1185e11b-e9da-4972-94f3-802c05c0aa72@googlegroups.com> Message-ID: Laura, Thanks for the pointer to PyXB, I think this will work for my purposes and it appears to be Python 3.4 / Windows compatible. Thank you to all who helped. On Friday, October 9, 2015 at 1:14:32 PM UTC-5, Laura Creighton wrote: > In a message of Fri, 09 Oct 2015 10:24:34 -0700, Gary Hanyzewski writes: > >I am trying to install xmiparser-1.5.dev-r124826 into python 3.4.0 on a windows machine. > >When I try and install (either with pip or setup.py install) I get a number of syntax errors in the code ( below) > > > >Has anyone managed to install and use the xmiparser module in python 3.4? If so what's the trick? if not any pointers on what I can do to get it to go. Are there any other xmi parsers or tools? > > > >Thanks > > > >Gary > > If XMI is just XML according to a particular schema, then you can get the > schema over here: http://www.omg.org/spec/XMI/2.5.1/ > > And then parse it with PyXB. > https://pypi.python.org/pypi/PyXB > > But maybe I don't understand what XMI is well enough. > > Laura From speeze.pearson at gmail.com Sat Oct 10 13:02:24 2015 From: speeze.pearson at gmail.com (speeze.pearson at gmail.com) Date: Sat, 10 Oct 2015 10:02:24 -0700 (PDT) Subject: How do I extend a class that I never instantiate myself? Message-ID: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> (This is a long post, but the question is simple. Most of this is just me enumerating what I've already tried.) Someone wrote a library that creates and manipulates `Node`s. I would like to write another layer on top of this, to make trees that behave just like the library's trees, but whose nodes have some extra methods. "Subclass!" is the classic OO answer, and my first instinct. Problem: I never instantiate `Node` myself. `Node`s are created somewhere deep inside the library, and there's no way to tell it "don't use `Node`, use this class instead." Does anyone know a programming pattern that solves this problem? (That's it! That's the question. Everything after this is descriptions of solutions I'm not happy enough with.) "Write a wrapper!" is my next instinct. Basically, class MyNode(object): ... def foo(self, *args, **kwargs): return self.node.foo(*args, **kwargs) def bar(self, *args, **kwargs): return self.node.bar(*args, **kwargs) ... This would be tedious, but acceptable, if I knew how to make `MyNode.parent` and `MyNode.children` return `MyNode`s instead of `Node`s. Every way I've thought of makes me cringe: - Make `MyNode` maintain its own parent/child info, and keep it in lock-step with the underlying `Node`'s parent/child info. Objection: this is a lot of work, and just begging to get out of sync. - Give every wrapped `Node` a `_wrapper` attribute, specifying the wrapping `MyNode` instance. Then `MyNode.children` would return `[child._wrapper for child in self._node.children]`. Objection: it just feels weird adding custom attributes to objects. - Have a global registry mapping `Node`s to their corresponding `MyNode` wrappers. Then `MyNode.children` would return `[MyNode.wrappers[child] for child in self.node.children]`. Objection: I've been trained not to like global state. My last idea is that my approach is *entirely* wrong: I shouldn't be trying to make the tree's nodes instances of my own class -- I should just use the existing library's `Node` class, and write my library in a functional style. Don't define `MyNode.foo()`, instead define `mylibrary.foo(my_node)`. I've got nothing against functional programming, but mixing it so closely with OO would, I think, result in a confusing, schizophrenic interface. Last possibly relevant fact: the library I want to extend is `xml.dom.minidom`. By `Node` I mean `Element`, and the specific methods I want to add will modify attributes used for CSS/JavaScript. Thank you very much! -Spencer From ian.g.kelly at gmail.com Sat Oct 10 13:39:01 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 10 Oct 2015 11:39:01 -0600 Subject: How do I extend a class that I never instantiate myself? In-Reply-To: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> Message-ID: On Sat, Oct 10, 2015 at 11:02 AM, wrote: > (This is a long post, but the question is simple. Most of this is > just me enumerating what I've already tried.) > > Someone wrote a library that creates and manipulates `Node`s. > I would like to write another layer on top of this, to make > trees that behave just like the library's trees, but whose nodes > have some extra methods. > > "Subclass!" is the classic OO answer, and my first instinct. > Problem: I never instantiate `Node` myself. `Node`s are created > somewhere deep inside the library, and there's no way to tell it > "don't use `Node`, use this class instead." > > Does anyone know a programming pattern that solves this problem? The factory method pattern would be the usual solution, but it depends on the library being written to support it. Alternatively you could monkey-patch the Node class in the library (with all the usual caveats about why you probably shouldn't). > (That's it! That's the question. Everything after this is > descriptions of solutions I'm not happy enough with.) > > "Write a wrapper!" is my next instinct. Basically, > > class MyNode(object): > ... > def foo(self, *args, **kwargs): > return self.node.foo(*args, **kwargs) > def bar(self, *args, **kwargs): > return self.node.bar(*args, **kwargs) > ... > > This would be tedious, but acceptable, if I knew how to make > `MyNode.parent` and `MyNode.children` return `MyNode`s > instead of `Node`s. Every way I've thought of makes me cringe: > - Make `MyNode` maintain its own parent/child info, and keep it > in lock-step with the underlying `Node`'s parent/child info. > Objection: this is a lot of work, and just begging to get out of sync. > - Give every wrapped `Node` a `_wrapper` attribute, specifying > the wrapping `MyNode` instance. Then `MyNode.children` would > return `[child._wrapper for child in self._node.children]`. > Objection: it just feels weird adding custom attributes to objects. If you do this, I would suggest calling the attribute __wrapper (with two underscores) to invoke name mangling in order to ensure that the attribute doesn't conflict with any added by the library itself. > - Have a global registry mapping `Node`s to their corresponding > `MyNode` wrappers. Then `MyNode.children` would return > `[MyNode.wrappers[child] for child in self.node.children]`. > Objection: I've been trained not to like global state. Implement MyNode.parent and MyNode.children as properties that wrap the underlying Node's parent/children on demand. This means you lose consistency of object identity for the wrappers, but maybe that's not important to you. If you want to maintain that, then cache the wrappers, perhaps using the __wrapper attribute scheme above. > My last idea is that my approach is *entirely* wrong: I shouldn't > be trying to make the tree's nodes instances of my own class -- > I should just use the existing library's `Node` class, and write > my library in a functional style. Don't define `MyNode.foo()`, > instead define `mylibrary.foo(my_node)`. > I've got nothing against functional programming, but mixing it > so closely with OO would, I think, result in a confusing, > schizophrenic interface. There's nothing wrong with this IMO. In fact, Python does this in the standard library, e.g. len(objects) rather than objects.len(). From lac at openend.se Sat Oct 10 15:09:51 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 10 Oct 2015 21:09:51 +0200 Subject: How do I extend a class that I never instantiate myself? In-Reply-To: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> Message-ID: <201510101909.t9AJ9pd5004018@fido.openend.se> In a message of Sat, 10 Oct 2015 10:02:24 -0700, speeze.pearson at gmail.com write s: >I should just use the existing library's `Node` class, and write >my library in a functional style. Don't define `MyNode.foo()`, >instead define `mylibrary.foo(my_node)`. >I've got nothing against functional programming, but mixing it >so closely with OO would, I think, result in a confusing, >schizophrenic interface. This is one useful place to do some thinking. Object-oriented programming is best used when you have a fixed set of operations on things, and as you write more code, you mostly add new things. Do this by adding new classes which implement existing methods, and leave the existing classes alone. Functional programming is best used when you have a fixed set of things, and as you write more code, you mostly add new operations on existing things. Do this by adding new functions that use the existing data types, and leave the existing functions alone. So do you have a horrible mismatch between the style of coding you are doing and the job you expect to do? If so, one possible way out not discussed is to use multiple inheritance, and write a mixin class. What you say you want to do -- glue some extra methods onto an existing class, or better yet a few extra classes -- is the classic use case for 'time to write a mixin'. OO purists dislike mixin classes. There is namespace pollution to worry about -- which is a real problem if you just multiply inherit two independent classes both of which have authors who are writing code like crazy, but isn't so much if you are writing the mixin, and worry about such things as they happen. Poor old Michele Simionato used Zope/Plone a lot and got bit a whole lot by mixins, and wrote this: http://www.artima.com/weblogs/viewpost.jsp?thread=246341 which I include mostly for the very nice 'detect conflicts' decorator which I use. (Thank you Michele). But while he thinks (or at least thought when he wrote that) that Mixins are harmful, I think that the sort of hell he found can be easily surpassed by misuse of decorators, and the real rule is -- "People who write bad code make messes." which is hardly original (or comforting). A related problem is that lots of people cannot do the thought you already did on this issue -- but everybody can use multiple inheritance. So lots of people who are new enough at this business to have done practically no thought at all use multiple inheritance, badly. All I am really saying -- I should condense this whole post but dinner is about to arrive on the table -- is don't fear mixins and multiple inheritance unduly. They are a practical solution for a lot of problems. You might have one of them. Laura From breamoreboy at yahoo.co.uk Sat Oct 10 15:39:29 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 10 Oct 2015 20:39:29 +0100 Subject: Python problem In-Reply-To: References: Message-ID: On 10/10/2015 07:15, S?bastien Pinsonneault wrote: > Hi, > > I've downloaded Python 3.5.0 64 bits, but I can't open it. It ask me > each time if I want to modify, repair or uninstall, but doesn't open. > > I have Windows 10 64 bits. > > Thx > Check out the issue tracker as there are known problems. If you're on XP that's just tough luck as it's no longer supported. -- 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 Oct 10 15:41:28 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 10 Oct 2015 20:41:28 +0100 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: On 09/10/2015 17:03, John Michael Lafayette wrote: > I would like Python to have a strong typing feature that can co-exist > with the current dynamic typing system. Currently Python is like this: > > var animal = Factory.make("dog") #okay > var dog = Factory.make("dog") #okay > As Ben Finney has all ready pointed out elsewhere Python is strongly typed. -- 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 Sat Oct 10 16:16:40 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 10 Oct 2015 16:16:40 -0400 Subject: Error In-Reply-To: References: <240A2D8E7B334AF9B8DE0CE9497CAD8A@SystemSetters> Message-ID: On 10/10/2015 2:33 AM, Chris Angelico wrote: > On Sat, Oct 10, 2015 at 4:39 PM, Shreenivas Potnis wrote: >> >> I have 32 bit machine with XP service pack 3. >> >> I installed x86 version of python. >> While running I get the following error: >> >> > > Python 3.5 does not run on XP. One of the goals for the 3.5.1 Windows installer is to detect whether the machine has an allowed version with the needed service packs. Apparently, this is not as trivial as one might hope. -- Terry Jan Reedy From lac at openend.se Sat Oct 10 16:52:39 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 10 Oct 2015 22:52:39 +0200 Subject: Python problem In-Reply-To: References: Message-ID: <201510102052.t9AKqdOK011337@fido.openend.se> In a message of Sat, 10 Oct 2015 20:39:29 +0100, Mark Lawrence writes: >On 10/10/2015 07:15, S?bastien Pinsonneault wrote: >> Hi, >> >> I've downloaded Python 3.5.0 64 bits, but I can't open it. It ask me >> each time if I want to modify, repair or uninstall, but doesn't open. >> >> I have Windows 10 64 bits. >> >> Thx >> > >Check out the issue tracker as there are known problems. If you're on >XP that's just tough luck as it's no longer supported. Windows 10 is new enough that the new 3.5.0 installer never was well tested with it. Can you open a bug report over here: bugs.python.org, and mention windows 10. If you got a log for what you were doing, please include that. Sorry for the hassle, Laura Creighton From bc at freeuk.com Sat Oct 10 17:51:33 2015 From: bc at freeuk.com (Bartc) Date: Sat, 10 Oct 2015 22:51:33 +0100 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: On 09/10/2015 17:26, John Michael Lafayette wrote: > I would like Python to have a strong typing feature that can co-exist > with the current dynamic typing system. Currently Python is like this: > > var animal = Factory.make("dog") # okay. > var dog = Factory.make("dog") # okay. > var cat = Factory.make("dog") # are you sure? AFAIK (I'm not an expert) that isn't Python. And you wouldn't expect Python to know about the names of animals and their relationships to each other so that it can give that sort of warning. > I would like Python to also be able to also do this: > > Animal a = Factory.make("dog") # okay. Dog is Animal. > Dog d = Factory.make("dog") # okay. Dog is Dog. > Cat c = Factory.make("cat") # Runtime error. Dog is not Cat. It seems you're looking for a radically different language (statically typed amongst other things). But I think you can define Animal, Dog and Cat such that you can write this: a = Factory.make(Animal,"dog") d = Factory.make(Dog,"dog") c = Factory.make(Cat,"cat") and program it so that it behaves the way you want. That doesn't need any language changes. > With a strong typing option that performs runtime type checking, the > reader can be certain that the program is running the type they expect. > Also, the IDE can be more helpful. Example: > > var dog = Factory.make("dog") # okay > dog. (Ctr+Space) # Auto-complete lists only > Animal methods. Even as a non-expert, I know that is not possible unless it is completely transformed (or you are running it interactively). Neither the IDE nor the Python bytecode compile can know what Factory or make are going to be until runtime, and even then, not until it's about to execute that line (and perhaps not even by that point sometimes, if the evaluation of the line can change the meaning of Factory). > This feature can be completely optional and could be integrated without > anyone noticing. If it is integrated, only the people who want this type > safety would have to use it. If there is a performance penalty, it would > mainly affect the people who use this feature. Given that a lot of > people transition from C/C++/Java to Python, I think that this feature > would be intuitive to many users and a good addition for people who like > type safety. Remember that Python allows this: if randombit(): # 1 or 0 import A else: import B A defines Factory as that complex class or whatever you had in mind. While B defines Factory as: Factory = 42 -- bartc From steve at pearwood.info Sat Oct 10 18:54:29 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sun, 11 Oct 2015 09:54:29 +1100 Subject: How do I extend a class that I never instantiate myself? References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> Message-ID: <56199727$0$1604$c3e8da3$5496439d@news.astraweb.com> On Sun, 11 Oct 2015 04:02 am, speeze.pearson at gmail.com wrote: > (This is a long post, but the question is simple. Most of this is > just me enumerating what I've already tried.) > > Someone wrote a library that creates and manipulates `Node`s. > I would like to write another layer on top of this, to make > trees that behave just like the library's trees, but whose nodes > have some extra methods. > > "Subclass!" is the classic OO answer, and my first instinct. > Problem: I never instantiate `Node` myself. `Node`s are created > somewhere deep inside the library, and there's no way to tell it > "don't use `Node`, use this class instead." But you have trees of nodes returned? Here are a few solutions: # Solution 1: inject a new method into each and every instance in the tree. # Does not work for __dunder__ methods, but should work for any class that # includes a per-instance __dict__ (that's most classes apart from # built-ins). from types import MethodType def foo(self): return self.spam or self.eggs for node in the_tree: node.foo = MethodType(foo, node) # Later... for node in the_tree: print node.foo() # Solution 2: hack the node type of each instance. # Should work fine for adding new methods, even __dunder__ methods. # Depending on the original class, may or may not work for overriding # existing methods. class MyNode(Node): def foo(self): return self.spam or self.eggs for node in the_tree: node.__class__ = MyNode # Later... for node in the_tree: print node.foo() Solution #2 is especially good to test your team's internal procedures and code review practices. Any code review which doesn't flag it as a "What the hell are you doing??? Is this even legal???" change is clearly deficient. Yes, it is legal, in fact it is not just legal but a deliberately supported feature of Python. But it is a bit tricky to get the details right. As written above, it should work, but for me to really be comfortable with using this in production, I would want to have written the original class specifically with this in mind. While both of the above have their uses, really the *right* way to do this is to stop being such an OOP purist. This isn't Java, we have functions for a reason. # Solution 3: just use a damn function. Works for any class, whether pure # Python or an extension class. Doesn't require any special support in the # original class, and guaranteed not to give your code reviewers a # conniption fit. def foo(node): return node.spam or node.eggs # Later... for node in the_tree: print foo(node) > Does anyone know a programming pattern that solves this problem? > > (That's it! That's the question. Everything after this is > descriptions of solutions I'm not happy enough with.) > > "Write a wrapper!" is my next instinct. Basically, > > class MyNode(object): > ... > def foo(self, *args, **kwargs): > return self.node.foo(*args, **kwargs) > def bar(self, *args, **kwargs): > return self.node.bar(*args, **kwargs) > ... > > This would be tedious, but acceptable, if I knew how to make > `MyNode.parent` and `MyNode.children` return `MyNode`s > instead of `Node`s. class MyNode(Node): @property def parent(self): parent = super(MyNode, self).parent if parent is not None: parent = MyNode(parent) return parent # etc. Still a lot of work, and you really need to understand the original Node class very well. This is the problem with subclassing: it requires you to be intimately familiar with the *implementation details* of the class you subclass. > My last idea is that my approach is *entirely* wrong: I shouldn't > be trying to make the tree's nodes instances of my own class -- > I should just use the existing library's `Node` class, and write > my library in a functional style. Don't define `MyNode.foo()`, > instead define `mylibrary.foo(my_node)`. > I've got nothing against functional programming, but mixing it > so closely with OO would, I think, result in a confusing, > schizophrenic interface. Do you find len(alist) to be confusing and schizophrenic? > Last possibly relevant fact: the library I want to extend is > `xml.dom.minidom`. By `Node` I mean `Element`, and the specific > methods I want to add will modify attributes used for CSS/JavaScript. It may be relevant. Try it and see. -- Steven From ben.schiek at gmail.com Sat Oct 10 19:16:14 2015 From: ben.schiek at gmail.com (Ben S) Date: Sat, 10 Oct 2015 16:16:14 -0700 Subject: Problem encountered using v3.5 Message-ID: Working on a Windows 7 64 bit machine, I installed 64 bit python v3.5. Was able to pip install a number of basic packages like numpy, pyamml, and nltk (off the Christoph Gohlke page). Did not test numpy or the other packages too much, but did explore nltk and encountered major flaw: Much of the functionality is available (eg. tokenize functions work fine), and I am able to import corpora; however when I try to examine the contents of the corpora using for eg. "brown.words()" I got an AttributeError. I posted the issue at SO and see there that a few other people are having similar problems. A link to my SO post is below, or just google "Stack Overflow Python AttributeError when calling nltk Brown corpus." http://stackoverflow.com/questions/33041621/python-attributeerror-when-calling-nltk-brown-corpus I am going to install the 32 bit python v3.5 to see if that works. Thanks, Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.ewing at canterbury.ac.nz Sat Oct 10 20:03:41 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 11 Oct 2015 13:03:41 +1300 Subject: How do I extend a class that I never instantiate myself? In-Reply-To: References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> Message-ID: Laura Creighton wrote: > don't fear mixins and multiple > inheritance unduly. They are a practical solution for a lot of > problems. You might have one of them. I don't think mixins are a solution here, because they still require controlling the instantiation of the classes so that you can substitute a class that incorporates the mixin. This seems like a case of "adding new operations to existing things", for which the functional style is appropriate. If dispatching on the classes of the objects is needed, perhaps some implementation of generic functions may be of help, such as functools.singledispatch in Python 3.4, or PEAK-Rules. -- Greg From torriem at gmail.com Sat Oct 10 20:38:32 2015 From: torriem at gmail.com (Michael Torrie) Date: Sat, 10 Oct 2015 18:38:32 -0600 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: <5619AF88.9030908@gmail.com> On 10/09/2015 10:26 AM, John Michael Lafayette wrote: > I would like Python to have a strong typing feature that can co-exist with > the current dynamic typing system. Currently Python is like this: > > var animal = Factory.make("dog") # okay. > var dog = Factory.make("dog") # okay. > var cat = Factory.make("dog") # are you sure? No actually it's not like that at all. Python's variables are not like C where they are little boxes you can write values to. Python's variables are names that are attached to various objects. Once a name is assigned to an object, unless that object permits mutation to itself, the actual value can never change, until the name is reused by rebinding it. On other words, Python's variables are very strongly typed. Python does have type annotations, but those really only are meaningful for function calls where the function can recommend some types of variables to pass to it. And type annotations certainly have their place Also, the nicest and most powerful feature of python is that as long as my object supports a particular interface, I can pass it to a function that knows nothing about my particular type and it works. Called duck typing. Looks to me like you want Python to be Java. Instead I suggest you learn more idiomatic ways of doing things and let Python work for you instead of against you. But it sounds like you don't want Python anyway. If you want a static language, use a static language. There are many compiled languages available these days with vaguely python-like syntaxes. One is Nim. There's the D language too for bringing some of the expressiveness of Python to a language that's more similar to C in syntax. There's certainly room in the world for using a variety of programming languages to suit your purpose. For mine right now Python fits the bill rather wonderfully. From rustompmody at gmail.com Sun Oct 11 01:11:00 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 10 Oct 2015 22:11:00 -0700 (PDT) Subject: python 2.2 or 3.5 Message-ID: At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance it says In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. So is it 3.5 or 2.2? For some reason google takes me to the 3.3 docs Replacing the 3.3 by 3.5 seems to keep the same entry From rustompmody at gmail.com Sun Oct 11 01:11:27 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 10 Oct 2015 22:11:27 -0700 (PDT) Subject: Python 2.2 or 3.5 Message-ID: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance it says In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. So is it 3.5 or 2.2? For some reason google takes me to the 3.3 docs Replacing the 3.3 by 3.5 seems to keep the same entry From ian.g.kelly at gmail.com Sun Oct 11 01:18:22 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 10 Oct 2015 23:18:22 -0600 Subject: Python 2.2 or 3.5 In-Reply-To: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> References: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> Message-ID: On Sat, Oct 10, 2015 at 11:11 PM, Rustom Mody wrote: > At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance > > it says > In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. > > So is it 3.5 or 2.2? 2.2 or greater. From breamoreboy at yahoo.co.uk Sun Oct 11 01:37:59 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 11 Oct 2015 06:37:59 +0100 Subject: Python 2.2 or 3.5 In-Reply-To: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> References: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> Message-ID: On 11/10/2015 06:11, Rustom Mody wrote: > At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance > > it says > In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. > > So is it 3.5 or 2.2? > > For some reason google takes me to the 3.3 docs > Replacing the 3.3 by 3.5 seems to keep the same entry > If just use "3" instead of "3.3" or "3.5" you'll always get the latest stable version of the docs. You can select any version you like from the drop down list up in the top left hand corner of the display. -- 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 Sun Oct 11 01:46:22 2015 From: dieter at handshake.de (dieter) Date: Sun, 11 Oct 2015 07:46:22 +0200 Subject: Understanding WSGI together with Apache References: Message-ID: <87zizqufdd.fsf@handshake.de> Johannes Bauer writes: > I'm running an Apache 2.4 webserver using mod_wsgi 4.3.0. There are two > different applications running in there running on two completely > separate vhosts. > > I'm seeing some weird crosstalk between them which I do not understand. > In particular, crosstalk concerning the locales of the two. One > application needs to output, e.g., date information using a German > locale. It uses locale.setlocale to set its LC_ALL to de_DE.UTF-8. > > Now the second application doesn't need nor want to be German. It wants > to see the C locale everywhere, in particular because at some point it > uses datetime.datetime.strptime() to parse a datetime. > > Here's where things get weird: Sometimes, my "C" locale process throws > exceptions, because it's unable to parse a date. When looking why this > fails, the string looks like de_DE's "Sa, 10 Okt 2015" instead of C's > "Sat, 10 Oct 2015". This seems to happen depending on which worker > thread is currently serving the request, i.e. nondeterministically. This is more an Apache than a Python question. The "locale" implementation does not expect different "locale"s in the same process (this is true not only on the Python but also on the "C" level). Thus, if in a single process, two concurrent activities (i.e. threads) need different "locale"s, you are in trouble. Your problem discription indicates that something like this is happening in your WSGI setup. I suppose that a single Python process is not used to process several requests at the same time (but I may be wrong). In this case, you have a chance to set the correct locale for the current request processing at request start. If, however, a single Python process is used for all requests and concurrent requests are handled by separate tasks, then there is no safe way to get the "locale" right. At your place, I would search the Apache documentation related to "mod_wsgi" to find out how it uses processes and tasks for request processing. From dieter at handshake.de Sun Oct 11 01:53:35 2015 From: dieter at handshake.de (dieter) Date: Sun, 11 Oct 2015 07:53:35 +0200 Subject: How do I extend a class that I never instantiate myself? References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> Message-ID: <87vbaeuf1c.fsf@handshake.de> speeze.pearson at gmail.com writes: > ... > Someone wrote a library that creates and manipulates `Node`s. > I would like to write another layer on top of this, to make > trees that behave just like the library's trees, but whose nodes > have some extra methods. If you are happy, the library supports extensions of this type (as e.g. "lxml" and "PyXB" do). Otherwise, you can likely use a technique called "monkey patching". This is dynamically changing code at startup time. In your case, it could look like: from ... import Node def new_method(self, ...): ... Node.new_method = new_method >From that moment on, the "Node" class has a new method "new_method". From rustompmody at gmail.com Sun Oct 11 01:57:05 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 10 Oct 2015 22:57:05 -0700 (PDT) Subject: Python 2.2 or 3.5 In-Reply-To: References: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> Message-ID: <456e038a-bd44-4fcc-9fe9-530f17b7bbdd@googlegroups.com> On Sunday, October 11, 2015 at 11:09:17 AM UTC+5:30, Mark Lawrence wrote: > On 11/10/2015 06:11, Rustom Mody wrote: > > At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance > > > > it says > > In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. > > > > So is it 3.5 or 2.2? > > > > For some reason google takes me to the 3.3 docs > > Replacing the 3.3 by 3.5 seems to keep the same entry > > > > If just use "3" instead of "3.3" or "3.5" you'll always get the latest > stable version of the docs. You can select any version you like from > the drop down list up in the top left hand corner of the display. Leave aside the decimal point I did not even specify 2 or 3 Just gave "embedding python alternative to swig" to google and I get that 3.3 page From rosuav at gmail.com Sun Oct 11 02:15:22 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 11 Oct 2015 17:15:22 +1100 Subject: Python 2.2 or 3.5 In-Reply-To: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> References: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> Message-ID: On Sun, Oct 11, 2015 at 4:11 PM, Rustom Mody wrote: > At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance > > it says > In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. > > So is it 3.5 or 2.2? More accurate would be "Since Python 2.2, you can etc etc". Every 3.x version permits this, as do all 2.x back as far as 2.2. Seems to warrant a docs patch. http://bugs.python.org/issue25375 ChrisA From ben+python at benfinney.id.au Sun Oct 11 02:19:09 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 11 Oct 2015 17:19:09 +1100 Subject: Python 2.2 or 3.5 References: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> <456e038a-bd44-4fcc-9fe9-530f17b7bbdd@googlegroups.com> Message-ID: <85k2quuduq.fsf@benfinney.id.au> Rustom Mody writes: > On Sunday, October 11, 2015 at 11:09:17 AM UTC+5:30, Mark Lawrence wrote: > > On 11/10/2015 06:11, Rustom Mody wrote: > > > At https://docs.python.org/3.5/faq/[?] > > > > > > it says > > > In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. > > > > > > So is it 3.5 or 2.2? [?] > > Leave aside the decimal point I did not even specify 2 or 3 > > Just gave "embedding python alternative to swig" to google and I get > that 3.3 page Fascinating, I'm sure. How is this relevant to your question about the *content of the Python docs*? If you want to complain about Google's search results, you know where to find Google. If you want to discuss the content of the Python docs, citing ?what Google showed me? is irrelevant. -- \ ?The idea that He would take his attention away from the | `\ universe in order to give me a bicycle with three speeds is | _o__) just so unlikely that I can't go along with it.? ?Quentin Crisp | Ben Finney From rosuav at gmail.com Sun Oct 11 02:32:09 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 11 Oct 2015 17:32:09 +1100 Subject: How do I extend a class that I never instantiate myself? In-Reply-To: <87vbaeuf1c.fsf@handshake.de> References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> <87vbaeuf1c.fsf@handshake.de> Message-ID: On Sun, Oct 11, 2015 at 4:53 PM, dieter wrote: > Otherwise, you can likely use a technique called "monkey patching". > This is dynamically changing code at startup time. > In your case, it could look like: > > from ... import Node > > def new_method(self, ...): > ... > > Node.new_method = new_method > > From that moment on, the "Node" class has a new method "new_method". And if you're going to do this for a good number of methods, I'd recommend something like this: def monkeypatch(cls): def deco(func): setattr(cls, func.__name__, func) return func return deco @monkeypatch(Node) def new_method(self, ...): ... @monkeypatch(Node) def another_new_method(self, ...): ... @monkeypatch(Node) def yet_another(self, ...): ... @monkeypatch(Node) def and_another(self, ...): ... If you REALLY want to look like Ruby, you could actually do something rather sneaky. When a decorator is called, the name has yet to be bound; conceptually, it's like defining the function/class and then using "x = deco(x)" at the end, but you can actually access the previous use of that name. So check this out: # -- cut -- class Foo: def old_method(self): print("Old method.") print("Before we begin patching, Foo is %x." % id(Foo)) def monkeypatch(cls): # NOTE: Needs to be able to find its own globals, so you # can't use this inside a function or import it from another # module. Play with sys._getframe if you want to. old = globals()[cls.__name__] print("Inside monkeypatch, old is %x, and cls is %x." % (id(old), id(cls))) for attr in dir(cls): # Don't override dunders. TODO: Figure out if they were # set here, and if so, *do* override. if attr.startswith("__") and attr.endswith("__"): continue setattr(old, attr, getattr(cls, attr)) return old @monkeypatch class Foo: def new_method(self): print("New method!") print("After patching, Foo is %x." % id(Foo)) f = Foo() f.old_method() f.new_method() # -- cut -- However, don't blame me if other programmers chase you down with torches and pitchforks. ChrisA From rosuav at gmail.com Sun Oct 11 02:34:03 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 11 Oct 2015 17:34:03 +1100 Subject: Python 2.2 or 3.5 In-Reply-To: References: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> Message-ID: On Sun, Oct 11, 2015 at 5:15 PM, Chris Angelico wrote: > On Sun, Oct 11, 2015 at 4:11 PM, Rustom Mody wrote: >> At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance >> >> it says >> In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. >> >> So is it 3.5 or 2.2? > > More accurate would be "Since Python 2.2, you can etc etc". Every 3.x > version permits this, as do all 2.x back as far as 2.2. Seems to > warrant a docs patch. > > http://bugs.python.org/issue25375 ... which has just been applied. I'm not sure how long it'll be before you see the change on the web site, but it won't be long. Thanks for the report! ChrisA From rustompmody at gmail.com Sun Oct 11 02:48:00 2015 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 10 Oct 2015 23:48:00 -0700 (PDT) Subject: Python 2.2 or 3.5 In-Reply-To: References: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> Message-ID: On Sunday, October 11, 2015 at 12:04:18 PM UTC+5:30, Chris Angelico wrote: > On Sun, Oct 11, 2015 at 5:15 PM, Chris Angelico wrote: > > On Sun, Oct 11, 2015 at 4:11 PM, Rustom Mody wrote: > >> At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance > >> > >> it says > >> In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. > >> > >> So is it 3.5 or 2.2? > > > > More accurate would be "Since Python 2.2, you can etc etc". Every 3.x > > version permits this, as do all 2.x back as far as 2.2. Seems to > > warrant a docs patch. > > > > http://bugs.python.org/issue25375 Thanks -- More useful than the other responses From breamoreboy at yahoo.co.uk Sun Oct 11 02:48:27 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 11 Oct 2015 07:48:27 +0100 Subject: Python 2.2 or 3.5 In-Reply-To: <456e038a-bd44-4fcc-9fe9-530f17b7bbdd@googlegroups.com> References: <88aa7a1b-f4c8-4afb-b382-19a30c924dfa@googlegroups.com> <456e038a-bd44-4fcc-9fe9-530f17b7bbdd@googlegroups.com> Message-ID: On 11/10/2015 06:57, Rustom Mody wrote: > On Sunday, October 11, 2015 at 11:09:17 AM UTC+5:30, Mark Lawrence wrote: >> On 11/10/2015 06:11, Rustom Mody wrote: >>> At https://docs.python.org/3.5/faq/extending.html#can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance >>> >>> it says >>> In Python 2.2, you can inherit from built-in classes such as int, list, dict, etc. >>> >>> So is it 3.5 or 2.2? >>> >>> For some reason google takes me to the 3.3 docs >>> Replacing the 3.3 by 3.5 seems to keep the same entry >>> >> >> If just use "3" instead of "3.3" or "3.5" you'll always get the latest >> stable version of the docs. You can select any version you like from >> the drop down list up in the top left hand corner of the display. > > Leave aside the decimal point I did not even specify 2 or 3 > > Just gave "embedding python alternative to swig" to google and I get that 3.3 > page > Specify other searches and you'll often get Python 2.x references instead of Python 3. What about it? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From __peter__ at web.de Sun Oct 11 04:24:36 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 11 Oct 2015 10:24:36 +0200 Subject: Understanding WSGI together with Apache References: Message-ID: Johannes Bauer wrote: > I'm seeing some weird crosstalk between them which I do not understand. > In particular, crosstalk concerning the locales of the two. One > application needs to output, e.g., date information using a German > locale. It uses locale.setlocale to set its LC_ALL to de_DE.UTF-8. > > Now the second application doesn't need nor want to be German. It wants > to see the C locale everywhere, in particular because at some point it > uses datetime.datetime.strptime() to parse a datetime. There is a library that might interest you. Babel allows multiple locales in the same process. See http://babel.pocoo.org/ From zrinko.budimir at gmail.com Sun Oct 11 10:13:19 2015 From: zrinko.budimir at gmail.com (Zrinko Budimir) Date: Sun, 11 Oct 2015 16:13:19 +0200 Subject: installation Python Message-ID: Hi, What is the difference between Python 3.5.0 and 3.5.0rc4? What is rc4? -- Zrinko Budimir -------------- next part -------------- An HTML attachment was scrubbed... URL: From eetix.letix at gmail.com Sun Oct 11 13:12:29 2015 From: eetix.letix at gmail.com (eetix letix) Date: Sun, 11 Oct 2015 19:12:29 +0200 Subject: Problem with Python 3.5.0 Message-ID: Hi, I'm sorry but the last version of Python (3.5.0) had a problem. I start and I meet this problem : >>>a=5 >>>if a>0: . . . print("a is a positive.") . . . if a<0: ^ SyntaxError: invalid syntax >>> Normally this should work but problem comes to the fact that Python considers "a" is a positive number and refuses to do the command >>>if a<0: And the command \n is doesn't working : >>> a="test\nto\nsee\nif\nit\nis\nworking" >>> a 'test\nto\nsee\nif\nit\nis\nworking' >>> Normally, \n should make that the text returns to the line but doesn't make it. And if y do : >>> a="""test . . . to . . . see . . . if . . . it . . . is . . . working""" >>>a 'test\nto\nsee\nif\nit\nis\nworking' >>> Thanks to fix this problems and good luck ;) PS : I'm sorry for this really bad english but I'm french and I'm 14 -------------- next part -------------- An HTML attachment was scrubbed... URL: From joel.goldstick at gmail.com Sun Oct 11 14:49:09 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Sun, 11 Oct 2015 14:49:09 -0400 Subject: installation Python In-Reply-To: References: Message-ID: On Sun, Oct 11, 2015 at 10:13 AM, Zrinko Budimir wrote: > Hi, > > What is the difference between Python 3.5.0 and 3.5.0rc4? > What is rc4? > > -- > Zrinko Budimir > > -- > https://mail.python.org/mailman/listinfo/python-list > > rc = release candidate. If the final version is available, use that -- Joel Goldstick http://joelgoldstick.com/stats/birthdays -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Sun Oct 11 14:58:49 2015 From: lac at openend.se (Laura Creighton) Date: Sun, 11 Oct 2015 20:58:49 +0200 Subject: Problem encountered using v3.5 In-Reply-To: References: Message-ID: <201510111858.t9BIwnWi007577@fido.openend.se> In a message of Sat, 10 Oct 2015 16:16:14 -0700, Ben S writes: >http://stackoverflow.com/questions/33041621/python-attributeerror-when-calling-nltk-brown-corpus > >I am going to install the 32 bit python v3.5 to see if that works. > >Thanks, >Ben This looks like this nltk bug. https://github.com/nltk/nltk/issues/1106 Talk to them about what you should do, and then tell everybody on Stack Overflow, please. Laura From joel.goldstick at gmail.com Sun Oct 11 15:05:10 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Sun, 11 Oct 2015 15:05:10 -0400 Subject: Problem with Python 3.5.0 In-Reply-To: References: Message-ID: On Sun, Oct 11, 2015 at 1:12 PM, eetix letix wrote: > Hi, > > I'm sorry but the last version of Python (3.5.0) had a problem. I start > and I meet this problem : > > >>>a=5 > >>>if a>0: > . . . print("a is a positive.") > . . . if a<0: > ^ > SyntaxError: invalid syntax > >>> > Not sure what is going on above > > Normally this should work but problem > comes to the > fact that Python considers "a" is a positive number and refuses to do the > command >>>if a<0: > > And the command \n is doesn't working : > > >>> a="test\nto\nsee\nif\nit\nis\nworking" > >>> a > 'test\nto\nsee\nif\nit\nis\nworking' > >>> > > In the interactive python shell, typing a name will give the > representation of the variable. So you will see the \n. If you type > print(a), you will get what you expected > > Normally, \n should make > that the text > returns to the line but doesn't make it. And if y do : > > >>> a="""test > . . . to > . . . see > . . . if > . . . it > . . . is > . . . working""" > >>>a > 'test\nto\nsee\nif\nit\nis\nworking' > >>> > > > Thanks to fix this problems and good luck ;) > > > PS : I'm sorry for this really bad english but I'm french and I'm 14 > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -- Joel Goldstick http://joelgoldstick.com/stats/birthdays -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent.vande.vyvre at telenet.be Sun Oct 11 15:09:55 2015 From: vincent.vande.vyvre at telenet.be (Vincent Vande Vyvre) Date: Sun, 11 Oct 2015 21:09:55 +0200 Subject: Problem with Python 3.5.0 In-Reply-To: References: Message-ID: <561AB403.7000207@telenet.be> Le 11/10/2015 19:12, eetix letix a ?crit : > Hi, > > I'm sorry but the last version of Python (3.5.0) had a problem. I > start and I meet this problem : > > >>>a=5 > >>>if a>0: > . . . print("a is a positive.") > . . . if a<0: > ^ > SyntaxError: invalid syntax > >>> > > Normally this should work but problem comes to the fact that Python > considers "a" is a positive number and refuses to do the command >>>if > a<0: > > And the command |\n is doesn't working : > > | > |>>> a="test||\nto||\nsee||\nif||\nit||\nis||\nworking" > | > |>>> a > | > |'||test||\nto||\nsee||\nif||\nit||\nis||\nworking' > >>> > > > | > Normally, \n should make that the text returns to the line but doesn't > make it. And if y do : > > >>> a="""test > . . . to > . . . see > . . . if > . . . it > . . . is > . . . working""" > >>>a > |'||test||\nto||\nsee||\nif||\nit||\nis||\nworking' > >>> > > > | > |Thanks to fix this problems and good luck ;) > > > | > |PS : I'm sorry for this really bad english but I'm french and I'm 14 > | > > Hi, see: >>> a = 5 >>> if a > 0: ... print('a is a positive') ... # here, type a Enter a is a positive >>> elif a .... >>> a = "test\nto\nsee\nif\nit\nis\nworking" >>> a 'test\nto\nsee\nif\nit\nis\nworking' >>> print(a) test to see if it is working >>> Clear ? Vincent From m at funkyhat.org Sun Oct 11 15:12:51 2015 From: m at funkyhat.org (Matt Wheeler) Date: Sun, 11 Oct 2015 20:12:51 +0100 Subject: Problem with Python 3.5.0 In-Reply-To: References: Message-ID: On 11 October 2015 at 18:12, eetix letix wrote: > Hi, > > I'm sorry but the last version of Python (3.5.0) had a problem. I start and > I meet this problem : > >>>>a=5 >>>>if a>0: > . . . print("a is a positive.") > . . . if a<0: > ^ > SyntaxError: invalid syntax >>>> > > Normally this should work but problem comes to the fact that Python > considers "a" is a positive number and refuses to do the command >>>if a<0: You're almost there, but your guess as to the reason for the error isn't quite right. It seems that the syntax in the Python shell is subtly different to code in a module. Because the second 'if' is a distinct statement from the first, the python shell seems to require a second return. However consider that perhaps using an 'else' or 'elif' instead of a completely separate 'if' And also consider that most people regard 0 to be positive, so you probably meant (a>=0). That means you can simplify to if a>=0: print("a is a positive") else: print("no need to evaluate a a second time") > And the command \n is doesn't working : > >>>> a="test\nto\nsee\nif\nit\nis\nworking" >>>> a > 'test\nto\nsee\nif\nit\nis\nworking' >>>> > > > Normally, \n should make that the text returns to the line but doesn't make > it. And if y do : > >>>> a="""test > . . . to > . . . see > . . . if > . . . it > . . . is > . . . working""" >>>>a > 'test\nto\nsee\nif\nit\nis\nworking' >>>> \n is an escape sequence rather than a command Have a look at what happens if you try print(a) > Thanks to fix this problems and good luck ;) > > > PS : I'm sorry for this really bad english but I'm french and I'm 14 Don't worry, it's certainly better than my French! -- Matt Wheeler http://funkyh.at From m at funkyhat.org Sun Oct 11 15:45:37 2015 From: m at funkyhat.org (Matt Wheeler) Date: Sun, 11 Oct 2015 20:45:37 +0100 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: On 9 October 2015 at 17:26, John Michael Lafayette wrote: > I would like Python to have a strong typing feature that can co-exist with > the current dynamic typing system. Currently Python is like this: > > var animal = Factory.make("dog") # okay. > var dog = Factory.make("dog") # okay. > var cat = Factory.make("dog") # are you sure? > > I would like Python to also be able to also do this: > > Animal a = Factory.make("dog") # okay. Dog is Animal. > Dog d = Factory.make("dog") # okay. Dog is Dog. > Cat c = Factory.make("cat") # Runtime error. Dog is not Cat. Though it's intended for performance optimisation rather than simply static typing for static typing's sake, you could probably use Cython to achieve what you want... ...but then you might start to see the benefits of dynamic typing :) -- Matt Wheeler http://funkyh.at From gal.kauffman at gmail.com Sun Oct 11 15:46:47 2015 From: gal.kauffman at gmail.com (gal kauffman) Date: Sun, 11 Oct 2015 12:46:47 -0700 Subject: Strong typing implementation for Python In-Reply-To: <5619AF88.9030908@gmail.com> References: <5619AF88.9030908@gmail.com> Message-ID: > You can run your code inside a class definition, abuse metaclassing to replace the namespace with yourown dict and override the __setitem__ function. Then you can implement a var function so it inspect into it's caller namespace, and inserts the given key into it. This hack doesn't apply on any sub scope, is not scaleable, and is generaly bad. import inspect # Implement how you see right class VarError(NameError): pass class MissingVarError(VarError): pass class ExisitngVarError(VarError): pass def namespacemeta(namespace): class _(type): @classmethod def __prepare__(metacls, name, bases): return namespace() return _ class staticnamespace(dict): PRE_USER_SETTED_ITENS = 2 def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.items_setted = 0 def var_setitem(self, key, typ): # Use descriptor object for better control # Implement type-checking yourself return super().__setitem__(key, typ) def __setitem__(self, key, value): if self.items_setted >= staticnamespace.PRE_USER_SETTED_ITENS: # Ugly hack, probably won't work IRL if key not in self: raise MissingVarError(key) self.items_setted += 1 return super().__setitem__(key, value) def var(key, typ): calling_namespace = inspect.currentframe().f_back.f_locals if key in calling_namespace: raise ExisitngVarError(key) calling_namespace.var_setitem(key, typ) class _(object, metaclass=namespacemeta(staticnamespace)): if __name__ == '__main__': try: a = 13 except MissingVarError: print("Couldn't set 'a'") var('a', int) a = 37 print(a) try: var('a', str) except ExisitngVarError: print ("Can't call var twice with the same variable name") -------------- next part -------------- An HTML attachment was scrubbed... URL: From random832 at fastmail.com Sun Oct 11 17:33:06 2015 From: random832 at fastmail.com (Random832) Date: Sun, 11 Oct 2015 17:33:06 -0400 Subject: Static typing implementation for Python References: <85d1wnw4qs.fsf@benfinney.id.au> Message-ID: <87a8rp6qgd.fsf@fastmail.com> Ben Finney writes: > The opposite of string typing is weak typing. Well, I would say *string* typing [as used in, for example, sh and tcl] is actually a form of weak typing. But anyway, the other issue is that strong typing is meaningless. In general it seems like weak typing means "the existence of implicit operations (either type conversions or any other operation between objects of different types) that I don't like". "Duck typing" of the sort that Python has, for example, could be and sometimes is regarded as a form of weak typing. From rosuav at gmail.com Sun Oct 11 17:40:55 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 12 Oct 2015 08:40:55 +1100 Subject: Static typing implementation for Python In-Reply-To: <87a8rp6qgd.fsf@fastmail.com> References: <85d1wnw4qs.fsf@benfinney.id.au> <87a8rp6qgd.fsf@fastmail.com> Message-ID: On Mon, Oct 12, 2015 at 8:33 AM, Random832 wrote: > Ben Finney writes: >> The opposite of string typing is weak typing. > > Well, I would say *string* typing [as used in, for example, sh and tcl] > is actually a form of weak typing. But anyway, the other issue is that > strong typing is meaningless. In general it seems like weak typing means > "the existence of implicit operations (either type conversions or any > other operation between objects of different types) that I don't like". > > "Duck typing" of the sort that Python has, for example, could be and > sometimes is regarded as a form of weak typing. "Strong typing" is anything the current speaker likes. "Weak typing" is anything the current speaker dislikes. I'm fairly sure most arguments about "readable" or "unreadable" code follow the same definitions. ChrisA From ben+python at benfinney.id.au Sun Oct 11 17:57:25 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 12 Oct 2015 08:57:25 +1100 Subject: Static typing implementation for Python References: <85d1wnw4qs.fsf@benfinney.id.au> <87a8rp6qgd.fsf@fastmail.com> Message-ID: <85fv1hukze.fsf@benfinney.id.au> Random832 writes: > Ben Finney writes: > > The opposite of string typing is weak typing. > > Well, I would say *string* typing [as used in, for example, sh and tcl] > is actually a form of weak typing. I infer a smile as you write that, but to clarify for others: I made a typo, and meant to contrast weak typing with strong typing. -- \ ?Like the creators of sitcoms or junk food or package tours, | `\ Java's designers were consciously designing a product for | _o__) people not as smart as them.? ?Paul Graham | Ben Finney From speeze.pearson at gmail.com Sun Oct 11 18:26:00 2015 From: speeze.pearson at gmail.com (speeze.pearson at gmail.com) Date: Sun, 11 Oct 2015 15:26:00 -0700 (PDT) Subject: How do I extend a class that I never instantiate myself? In-Reply-To: References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> Message-ID: <8860bad3-cba1-4c34-844e-70b0f16aaae1@googlegroups.com> On Saturday, October 10, 2015 at 10:40:15 AM UTC-7, Ian wrote: > name mangling Awesome! I didn't know this was a feature. > There's nothing wrong with [functional programming] IMO. In fact, Python > does this in the standard library, e.g. len(objects) rather than > objects.len(). ...good point. I'll look at that option again with fresh eyes. Thanks! From speeze.pearson at gmail.com Sun Oct 11 18:35:45 2015 From: speeze.pearson at gmail.com (speeze.pearson at gmail.com) Date: Sun, 11 Oct 2015 15:35:45 -0700 (PDT) Subject: How do I extend a class that I never instantiate myself? In-Reply-To: <56199727$0$1604$c3e8da3$5496439d@news.astraweb.com> References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> <56199727$0$1604$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3cfd3651-5e89-48a3-9bbc-7d07ba442910@googlegroups.com> On Saturday, October 10, 2015 at 3:55:17 PM UTC-7, Steven D'Aprano wrote: > # Solution 1: inject a new method into each and every instance in the tree. > > node.foo = MethodType(foo, node) Ooh, interesting. I'll meditate on that for a while. > # Solution 2: hack the node type of each instance. > > node.__class__ = MyNode That is undoubtedly the coolest feature that I will absolutely never ever use. > While both of the above have their uses, really the *right* way to do this > is to stop being such an OOP purist. This isn't Java, we have functions for > a reason. > > Do you find len(alist) to be confusing and schizophrenic? Um-- no, because I'm used to it. ;) I'll definitely give the functional approach another think-over. If I do go down the functional road, and I decide that I need to associate my own data with each node (e.g. for callback functions), would there be a better way to do that than just adding my own attribute onto each node? > class MyNode(Node): > @property > def parent(self): > parent = super(MyNode, self).parent > if parent is not None: > parent = MyNode(parent) > return parent > # etc. > > Still a lot of work, and you really need to understand the original Node > class very well. This is the problem with subclassing: it requires you to > be intimately familiar with the *implementation details* of the class you > subclass. Hrm. Relying on implementation details of somebody else's library seems dangerous... I think I'll shy away. Thanks a lot! -Spencer From greg.ewing at canterbury.ac.nz Sun Oct 11 18:43:02 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Mon, 12 Oct 2015 11:43:02 +1300 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: > On 9 October 2015 at 17:26, John Michael Lafayette > wrote: > >>I would like Python to also be able to also do this: >> >> Animal a = Factory.make("dog") # okay. Dog is Animal. >> Dog d = Factory.make("dog") # okay. Dog is Dog. >> Cat c = Factory.make("cat") # Runtime error. Dog is not Cat. You might like to investigate Boo, which is a .NET-based language with a Python-like syntax: -- Greg From speeze.pearson at gmail.com Sun Oct 11 19:09:23 2015 From: speeze.pearson at gmail.com (speeze.pearson at gmail.com) Date: Sun, 11 Oct 2015 16:09:23 -0700 (PDT) Subject: How do I extend a class that I never instantiate myself? In-Reply-To: References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> <87vbaeuf1c.fsf@handshake.de> Message-ID: On Saturday, October 10, 2015 at 11:32:24 PM UTC-7, Chris Angelico wrote: > If you REALLY want to look like Ruby, Ha! This thread has provided so many interesting monkey-patching techniques, but this might be the most perverse. Very cute. From kmisoft at gmail.com Sun Oct 11 19:24:51 2015 From: kmisoft at gmail.com (Vladimir Ignatov) Date: Sun, 11 Oct 2015 19:24:51 -0400 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: Hi, > You might like to investigate Boo, which is a .NET-based > language with a Python-like syntax: AFAIK Unity just dropped Boo support from version 5.0 because virtually nobody used it. Those little known niche languages are destined to extinct. Interesting language is Apple's Swift. While it's statically typed language, type specification is optional as far as compiler can figure out type. That gives an interesting feeling because you don't need to type types all over but in the same time you have all type checking we normally expect from statically typed language. The syntax is not pythonic but overall it looks like language got some influence from Python. Vladimir http://itunes.apple.com/us/app/python-code-samples/id1025613117 From rosuav at gmail.com Sun Oct 11 19:53:52 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 12 Oct 2015 10:53:52 +1100 Subject: How do I extend a class that I never instantiate myself? In-Reply-To: References: <7f1f37db-a917-4f11-864c-b79b45c0ad68@googlegroups.com> <87vbaeuf1c.fsf@handshake.de> Message-ID: On Mon, Oct 12, 2015 at 10:09 AM, wrote: > On Saturday, October 10, 2015 at 11:32:24 PM UTC-7, Chris Angelico wrote: >> If you REALLY want to look like Ruby, > > Ha! This thread has provided so many interesting monkey-patching techniques, > but this might be the most perverse. Very cute. Thank you for taking it in its proper light. To be quite frank, I don't know that this is even supported. Can anyone confirm or deny? Simple test: def deco(f): print(globals()[f.__name__]) foo = bar = "old" @deco def foo(x): pass @deco class bar(object): pass If it prints 'old' twice, the trick works. I tested it on PyPy 2.4, Jython 2.5, and CPython 2.7 and 3.6. More importantly, though, the docs always describe decorators as being equivalent to defining a function and then reassigning: https://www.python.org/dev/peps/pep-0318/#motivation https://docs.python.org/2/glossary.html#term-decorator https://docs.python.org/2/reference/compound_stmts.html#function https://docs.python.org/3/glossary.html#term-decorator https://docs.python.org/3/reference/compound_stmts.html#function So I think this is about on par with tinkering with sys._getframe to make stuff work :) ChrisA From steve at pearwood.info Sun Oct 11 20:34:43 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 12 Oct 2015 11:34:43 +1100 Subject: Strong typing implementation for Python References: Message-ID: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> On Mon, 12 Oct 2015 10:24 am, Vladimir Ignatov wrote: > Hi, > >> You might like to investigate Boo, which is a .NET-based >> language with a Python-like syntax: > > AFAIK Unity just dropped Boo support from version 5.0 because > virtually nobody used it. What's Unity? I've never heard of it. Why should Boo users care about it? > Those little known niche languages are > destined to extinct. Yes, you are correct, and sadly while rubbish languages like PHP, Java, Javascript and C continue in popularity for decades, amazingly good, powerful, safe, rich languages like D, Eiffel and others languish in obscurity as niche languages for just as long, and innovative languages like Boo are almost certain to die off. Network effects have a dark side, and the IT community as a whole is not just conservative, but *stupidly* conservative to the point of pain. And becoming *more* conservative and scared of change, not less. > Interesting language is Apple's Swift. While it's statically typed > language, type specification is optional as far as compiler can figure > out type. That's called type inference, and there's nothing innovative about Swift to include that as a feature. Type inference is *old*. The theory behind type inference goes back to 1958, and languages such as ML and OCaml have included it for decades, and yet here we are in 2015 and people think that it's something cool and new :-( -- Steven From victorhooi at gmail.com Sun Oct 11 20:56:33 2015 From: victorhooi at gmail.com (Victor Hooi) Date: Sun, 11 Oct 2015 17:56:33 -0700 (PDT) Subject: Relaxed, or best-efforts JSON parser for Python? Message-ID: <52c15e23-c897-4c80-88ff-b18314a91d80@googlegroups.com> Hi, I'm attempting to parse MongoDB loglines. The formatting of these loglines could best be described as JSON-like... For example - arrays Anyhow, say I had the following logline snippet: { Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 1 } }, oplog: { acquireCount: { w: 1 } } } This won't parse with json.loads() - the main issues is the missing quotation marks (") around the strings. My question, is there a more lenient, or relaxed JSON parser available for Python, that will try to do a best-efforts parsing of non-spec JSON? Cheers, Victor From python at mrabarnett.plus.com Sun Oct 11 22:43:57 2015 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 12 Oct 2015 03:43:57 +0100 Subject: Relaxed, or best-efforts JSON parser for Python? In-Reply-To: <52c15e23-c897-4c80-88ff-b18314a91d80@googlegroups.com> References: <52c15e23-c897-4c80-88ff-b18314a91d80@googlegroups.com> Message-ID: <561B1E6D.1050704@mrabarnett.plus.com> On 2015-10-12 01:56, Victor Hooi wrote: > Hi, > > I'm attempting to parse MongoDB loglines. > > The formatting of these loglines could best be described as JSON-like... > > For example - arrays > > Anyhow, say I had the following logline snippet: > > { Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 1 } }, oplog: { acquireCount: { w: 1 } } } > > This won't parse with json.loads() - the main issues is the missing quotation marks (") around the strings. > > My question, is there a more lenient, or relaxed JSON parser available for Python, that will try to do a best-efforts parsing of non-spec JSON? > Have you tried first adding the quotes using the re module? >>> import json, re >>> line = '{ Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 1 } }, oplog: { acquireCount: { w: 1 } } }' >>> json.loads(re.sub(r'(\w+)', r'"\1"', line)) From torriem at gmail.com Sun Oct 11 22:45:33 2015 From: torriem at gmail.com (Michael Torrie) Date: Sun, 11 Oct 2015 20:45:33 -0600 Subject: Strong typing implementation for Python In-Reply-To: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> Message-ID: <561B1ECD.3000705@gmail.com> On 10/11/2015 06:34 PM, Steven D'Aprano wrote: > That's called type inference, and there's nothing innovative about Swift to > include that as a feature. Type inference is *old*. The theory behind type > inference goes back to 1958, and languages such as ML and OCaml have > included it for decades, and yet here we are in 2015 and people think that > it's something cool and new :-( C++ introduced it a while ago (C++11), and D has had it from the beginning. Even lowly FreeBasic has it. It's certainly nice and it can be a time saver. Though it's only useful in certain places, such as when declaring a variable and an initializer. While it can be used for the return type of a function, in practice I've found it to not be that useful when you are making a function that is going to be called by someone else. You can't just stick an automatic reference in a .h file, for example. Anyway, I guess our OP is another example of a drive-by poster who took a brief look at Python then came here to try make a point of some kind, and then disappeared, perhaps realizing that he probably should have gained a bit more understanding of Python before trying to make said point. From random832 at fastmail.com Sun Oct 11 22:57:03 2015 From: random832 at fastmail.com (Random832) Date: Sun, 11 Oct 2015 22:57:03 -0400 Subject: Relaxed, or best-efforts JSON parser for Python? References: <52c15e23-c897-4c80-88ff-b18314a91d80@googlegroups.com> Message-ID: <87lhb84ww0.fsf@fastmail.com> Victor Hooi writes: > My question, is there a more lenient, or relaxed JSON parser available > for Python, that will try to do a best-efforts parsing of non-spec > JSON? In an answer to a similar question on StackExchange, using YAML was suggested. http://stackoverflow.com/questions/9104930 Is it possible that this format is in fact YAML? It does have the spaces after each colon as mentioned in a comment, and it seems more likely to me than that a major package like MongoDB aimed for JSON and missed. From anthony at cajuntechie.org Mon Oct 12 03:17:34 2015 From: anthony at cajuntechie.org (Anthony Papillion) Date: Mon, 12 Oct 2015 02:17:34 -0500 Subject: How to handle attachments passed via Postfix Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 I'm writing a script that will have email with attachments passed to it via Postfix. Postfix is properly passing the email to the script but I'm not quite sure how to get at the attachment. What I need to do is save the attachment out to the filesystem. Can anyone point me in the right direction? Thanks! Anthony - -- Phone: +1.845.666.3312 Skype: CajunTechie SIP/VoIP: 17772471988 at in.callcentric.com PGP Key: 0x53B04B15 Fingerprint: C5CE E687 DDC2 D12B 9063 56EA 028A DF74 53B0 4B15 -----BEGIN PGP SIGNATURE----- Version: APG v1.1.1 iQJJBAEBCgAzBQJWG16OLBxBbnRob255IFBhcGlsbGlvbiA8YW50aG9ueUBjYWp1 bnRlY2hpZS5vcmc+AAoJEAKK33RTsEsVfr8QAJDmU9lroSDdVkvLNoniwq4j/UM+ 2KOozruO8NKciYFLuKpip006Tza+XQxmqXjIi/KxXuXaqu+bQaigem9/eo2AKQ4n hSzs4sjQdu8Z2KBOxRaItSzCypdCEKFHQkHjne7d+vH1QA0XpL1LbBhliUjRZWNV LrjsLmJwggD7ClRPfQKfqK9Jr0l772EGZZlEbH9gLRvwoHTcZb9qm6iQObfXnEjt HGnTQpnRet4GOrx/GjFKzcnUxEhR5HtyqIMYp06miGEk6zTEWmtDRizCKCaF/GPC KdK7RZJvugQnNC4lohyD9Wa686t157lRQNZHkfNBhbqcSTko7QwRG7A+rca628ON L4rpcz68ruVyV7XQBtcaQcKcn/yZHcaTGpBUVIgIOGtnyxuDhJnTZiiXjUXMc8tj 700sgTHlrsiiJkjed9FEfoAOt66WNcaVsAR/jirSSyyMwSTqxxbOHzM/zOK0Whq3 8SD4kMAvjlAqU96ymy0rUuf4hvoyJ+aiit27ISxtofW+Lxn8vDMSYja5X/vBActZ ZqP27NK+xSwfUXtdZ/CLkYqIBs+Bi2nQamHqN6qZSe1oS0WSG6zHf7FO2Br8bBJ/ FJlqWV/OTSrU85SRIJ3OeSKWD8oCizEpsfS5P/8dCPYJGfY6Yk9POOebH1H+SP4D nhO3G81QosenmGhZ =n767 -----END PGP SIGNATURE----- From mdione at grulic.org.ar Mon Oct 12 03:27:38 2015 From: mdione at grulic.org.ar (Marcos Dione) Date: Mon, 12 Oct 2015 09:27:38 +0200 Subject: [mdione@grulic.org.ar: modifying locals] Message-ID: <20151012072738.GH2798@diablo.grulicueva.local> I repost this here, as somebody in python-help told it was probably out of their league. ----- Forwarded message from Marcos Dione ----- Date: Sun, 11 Oct 2015 15:30:05 +0200 From: Marcos Dione Subject: modifying locals To: help at python.org Message-ID: <20151011133005.GC2798 at diablo.grulicueva.local> Content-Type: text/plain; charset=us-ascii First of all, I'm not subscribed to the list, so please CC me. I'm writing a language[1] heavily based on Python. The way I'm implementing it is by having my own parser (based/stealed from pypy), obtaining an AST, modifying it and running the result with exec(). One of its particular features is that I intend to support semi-transparent remote execution using paramiko. For that, there is a construction that looks like this: [local code 1] with remote(...): [remote code] [local code 2] The idea is that [remote code] is effectively executed in a remote machine specified in remote()'s parameters. This is implemented[3] by remote() being a context manager. Part of the transparency is that globals and locals at the remote() point will be accesible to the remote code (so far only variables), and that modifications to locals will be visible back to [local code 2]. So far I managed to do the first part, but not the second. I managed to transfer the locals back from the remote. My problem is modifying the locals in remote()'s __exit__() method. As I'm running the code using exec(), it's not just a matter of modifying locals()[2]. What I tried was the following: * When I execute the code, I pass an empty dictionary to hold the locals. I save a reference to it, and I try to use it to modify the locals [local code 2] sees, but as locals are related to stack frame, it doesn't work. * This leads to the second attempt: use the stack to modify remote()'s caller's locals by[4]: inception_locals= sys._getframe().f_back.f_locals inception_locals.update (locals) Somehow this doesn't work either, and it's driving me crazy. I run out of ideas, so maybe you could throw some? Thanks in advance. -- [1] if you're interested, check https://github.com/StyXman/ayrton/ [2] isn't it? Just by writing that I got my doubts... [3] https://github.com/StyXman/ayrton/blob/develop/ayrton/functions.py#L112 [4] https://github.com/StyXman/ayrton/blob/develop/ayrton/functions.py#L254 -- (Not so) Random fortune: They called me mad, and I called them mad, and damn them, they outvoted me. -- Nathaniel Lee ----- End forwarded message ----- -- (Not so) Random fortune: Cruickshank's Law of Committees: If a committee is allowed to discuss a bad idea long enough, it will inevitably decide to implement the idea simply because so much work has already been done on it. From johnmichaelreedfas at gmail.com Mon Oct 12 04:25:26 2015 From: johnmichaelreedfas at gmail.com (John Michael Lafayette) Date: Mon, 12 Oct 2015 04:25:26 -0400 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: No. Python now has static type checking and IDE auto-complete support. All you have to do is put the type name in the function declaration. On Oct 11, 2015 3:45 PM, "Matt Wheeler" wrote: > On 9 October 2015 at 17:26, John Michael Lafayette > wrote: > > I would like Python to have a strong typing feature that can co-exist > with > > the current dynamic typing system. Currently Python is like this: > > > > var animal = Factory.make("dog") # okay. > > var dog = Factory.make("dog") # okay. > > var cat = Factory.make("dog") # are you sure? > > > > I would like Python to also be able to also do this: > > > > Animal a = Factory.make("dog") # okay. Dog is Animal. > > Dog d = Factory.make("dog") # okay. Dog is Dog. > > Cat c = Factory.make("cat") # Runtime error. Dog is not > Cat. > > Though it's intended for performance optimisation rather than simply > static typing for static typing's sake, you could probably use Cython > to achieve what you want... > > ...but then you might start to see the benefits of dynamic typing :) > > > -- > Matt Wheeler > http://funkyh.at > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Static_Typechecked_Python.png Type: image/png Size: 15240 bytes Desc: not available URL: From johnmichaelreedfas at gmail.com Mon Oct 12 04:47:35 2015 From: johnmichaelreedfas at gmail.com (John Michael Lafayette) Date: Mon, 12 Oct 2015 04:47:35 -0400 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: Now that Python has static type checking and support for IDE auto-complete (PEP 484?), I beg you to please use it. In your standard library, in your production code, in everywhere. I cannot type without auto-complete. I know that sounds ridiculous, but I have been coding on a daily basis for the last four years and I cannot recall the last time I actually typed out a variable or function name without auto-complete typing it for me. To me, java.net.DatagramSocket isn't "DatagramSocket". It is "Da" + Ctrl + Space + Enter (auto complete). I literally memorized the number of characters I have to type for auto-complete to guess the variable name and then I only type that many characters. For me, typing without auto-complete is like doing surgery with a kitchen knife. It's messy and error prone and I make lots of mistakes and have to try twice as hard to remember the actual names of variables instead of just whatever they start with. You don't understand because you actually know what all the function names are and you don't have to constantly hover over them in auto-complete and pull up their documentation to figure out how to use them. But I do. And for me, without auto-complete, the learning process goes from actively querying the IDE for one documentation after another to having to minimize the IDE and Google search for each and every function and module that I"m not familiar with. Auto-complete literally cuts the learning time by more than half. So please please please use PEP 484 to document all your standard library functions. Not for static compilation. Not even for catching mistakes caused by bad function input (although I like that). For Christ's sake, do it for the auto-complete. I gave up on JavaScript in favor of TypeScript for a reason god dammit. On Oct 11, 2015 3:45 PM, "Matt Wheeler" wrote: > On 9 October 2015 at 17:26, John Michael Lafayette > wrote: > > I would like Python to have a strong typing feature that can co-exist > with > > the current dynamic typing system. Currently Python is like this: > > > > var animal = Factory.make("dog") # okay. > > var dog = Factory.make("dog") # okay. > > var cat = Factory.make("dog") # are you sure? > > > > I would like Python to also be able to also do this: > > > > Animal a = Factory.make("dog") # okay. Dog is Animal. > > Dog d = Factory.make("dog") # okay. Dog is Dog. > > Cat c = Factory.make("cat") # Runtime error. Dog is not > Cat. > > Though it's intended for performance optimisation rather than simply > static typing for static typing's sake, you could probably use Cython > to achieve what you want... > > ...but then you might start to see the benefits of dynamic typing :) > > > -- > Matt Wheeler > http://funkyh.at > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Oct 12 04:50:40 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 12 Oct 2015 19:50:40 +1100 Subject: [mdione@grulic.org.ar: modifying locals] In-Reply-To: <20151012072738.GH2798@diablo.grulicueva.local> References: <20151012072738.GH2798@diablo.grulicueva.local> Message-ID: On Mon, Oct 12, 2015 at 6:27 PM, Marcos Dione wrote: > So far I managed to do the first part, but not the second. I managed > to transfer the locals back from the remote. My problem is modifying the > locals in remote()'s __exit__() method. As I'm running the code using > exec(), it's not just a matter of modifying locals()[2]. Short answer: You can't. Modifying locals is not something that's ever supported (except in the trivial case where locals() is globals(), as mutating globals() *is* supported). Personally, I'd be inclined to switch from a 'with' block to a function with a decorator - something like this: [local code 1] @remote(...) def operationname(): [remote code] [local code 2] The decorator could then do the actual remote call. I'm assuming here that it's a synchronous call, and that [local code 2] doesn't begin until [remote code] has finished. Then you simply use nonlocal and/or global to mark which names need to get rebound after the call. This might even be possible with existing CPython - I'm not sure. ChrisA From rosuav at gmail.com Mon Oct 12 04:58:37 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 12 Oct 2015 19:58:37 +1100 Subject: How to handle attachments passed via Postfix In-Reply-To: References: Message-ID: On Mon, Oct 12, 2015 at 6:17 PM, Anthony Papillion wrote: > I'm writing a script that will have email with attachments passed to it via Postfix. Postfix is properly passing the email to the script but I'm not quite sure how to get at the attachment. What I need to do is save the attachment out to the filesystem. > > Can anyone point me in the right direction? If I understand the situation correctly, you're getting a MIME-formatted email, and want to decode it into a usable attachment - right? Python includes a package for teasing apart RFC[2]822 format emails: https://docs.python.org/3/library/email.html Check out the email.parser module, or the convenience function email.message_from_string - you should be able to get at the different parts (including attachments) from there. ChrisA From robin at reportlab.com Mon Oct 12 05:41:29 2015 From: robin at reportlab.com (Robin Becker) Date: Mon, 12 Oct 2015 10:41:29 +0100 Subject: python3.5 + reportlab + windows again In-Reply-To: <561636D4.4080001@chamonix.reportlab.co.uk> References: <5613E55E.9000203@chamonix.reportlab.co.uk> <5613E952.2090503@chamonix.reportlab.co.uk> <561636D4.4080001@chamonix.reportlab.co.uk> Message-ID: <561B8049.1030904@chamonix.reportlab.co.uk> On 08/10/2015 10:26, Robin Becker wrote: > On 06/10/2015 16:31, Robin Becker wrote: > ......... >> >> well it seems someone can build these extensions properly. I used Christoph >> Gohlke's reportlab build and although there are 3 failures in the latest tests I >> don't see any crashes etc etc and all the failures are explainable. Last thing I >> saw from him in respect of pyRXPU was to use extra_compile_args=['/Od']. I will >> try that in the reportlab extension builds and see if the problems go away. > > I figured out the problem I was having with windows vs python3.5. It seems that > something has changed in the way extensions are loaded when using imp to > override the normal import mechanism. ....... I managed to fix up my c-extension loading code so it works for pythons 2.7, 3.3, 3.4 & 3.5. Horrid details can be found here https://code.activestate.com/recipes/579109-loading-c-extensions-from-a-repository-build-area/ -- Robin Becker From marko at pacujo.net Mon Oct 12 06:35:06 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 12 Oct 2015 13:35:06 +0300 Subject: Strong typing implementation for Python References: Message-ID: <87vbacs7c5.fsf@elektro.pacujo.net> John Michael Lafayette : > Now that Python has static type checking and support for IDE > auto-complete (PEP 484?), I beg you to please use it. In your standard > library, in your production code, in everywhere. I cannot type without > auto-complete. > > I know that sounds ridiculous, It sure does. Ducktyping is the essence of Python. You are asking Python to become Java. > You don't understand because you actually know what all the function > names are and you don't have to constantly hover over them in > auto-complete and pull up their documentation to figure out how to use > them. I barely remember any of them. That's why I keep Python Standard Library reference in a browser window whenever I program in Python. > But I do. And for me, without auto-complete, the learning process goes > from actively querying the IDE for one documentation after another to > having to minimize the IDE and Google search for each and every > function and module that I"m not familiar with. Auto-complete > literally cuts the learning time by more than half. Many modern windowing systems let you have more than one window on the screen at once. My Python editor window occupies 25% of the screen. The rest of the space goes to a browser, a couple of terminals etc. You don't need Google to see Python's documentation. Just bookmark https://docs.python.org/3/library/ > So please please please use PEP 484 to document all your standard > library functions. Not for static compilation. Not even for catching > mistakes caused by bad function input (although I like that). For > Christ's sake, do it for the auto-complete. I gave up on JavaScript in > favor of TypeScript for a reason god dammit. It would appear Python is too small a programming language for the two of us. Marko From lac at openend.se Mon Oct 12 07:01:25 2015 From: lac at openend.se (Laura Creighton) Date: Mon, 12 Oct 2015 13:01:25 +0200 Subject: Relaxed, or best-efforts JSON parser for Python? In-Reply-To: <52c15e23-c897-4c80-88ff-b18314a91d80@googlegroups.com> References: <52c15e23-c897-4c80-88ff-b18314a91d80@googlegroups.com> Message-ID: <201510121101.t9CB1PnI011608@fido.openend.se> In a message of Sun, 11 Oct 2015 17:56:33 -0700, Victor Hooi writes: >Hi, > >I'm attempting to parse MongoDB loglines. > >The formatting of these loglines could best be described as JSON-like... > >For example - arrays > >Anyhow, say I had the following logline snippet: > > { Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 1 } }, oplog: { acquireCount: { w: 1 } } } > >This won't parse with json.loads() - the main issues is the missing quotation marks (") around the strings. > >My question, is there a more lenient, or relaxed JSON parser available for Python, that will try to do a best-efforts parsing of non-spec JSON? > >Cheers, >Victor >-- >https://mail.python.org/mailman/listinfo/python-list Won't this http://blog.mongodb.org/post/85123256973/introducing-mtools https://github.com/rueckstiess/mtools https://pypi.python.org/pypi/mtools/1.1.3 be better? :) From steve at pearwood.info Mon Oct 12 07:39:02 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Mon, 12 Oct 2015 22:39:02 +1100 Subject: Strong typing implementation for Python References: Message-ID: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> On Mon, 12 Oct 2015 07:47 pm, John Michael Lafayette wrote: > Now that Python has static type checking It certainly does not. It appears you have misunderstood the purpose and meaning of PEP 484. PEP 484 provides a *standard meaning for function annotations* as type-hints, which may be useful for third-party type-checking, documentation generators, runtime inspection, editor auto-completion, and other tools. It doesn't add static type checking to Python. > and support for IDE auto-complete (PEP 484?), PEP 484 isn't needed for IDE auto-completion, although it can be used for that. Using IDLE and Pyton 2.7, I can type "l" (without the quotes) and TAB, and IDLE will pop up a menu with "len" highlighted. And IDLE is a pretty basic IDE: its auto-complete only works on built-in names, which makes it quite limited. More powerful IDEs have better auto-complete features. > I beg you to please use it. In your standard library, in your > production code, in everywhere. I cannot type without auto-complete. I'm sorry for your disability, but for most programmers, auto-complete is a convenience, not a necessity. > I know that sounds ridiculous, but I have been coding on a daily basis for > the last four years and I cannot recall the last time I actually typed out > a variable or function name without auto-complete typing it for me. To me, > java.net.DatagramSocket isn't "DatagramSocket". It is "Da" + Ctrl + Space > + Enter (auto complete). I literally memorized the number of characters I > have to type for auto-complete to guess the variable name and then I only > type that many characters. I cannot imagine filling my mind with such useless information as "the number of characters I have to type for auto-complete to guess the variable name". I *especially* cannot fathom why I would prefer to learn "two characters, starts with Da" by rote instead of something *meaningful* like "DatagramSocket". What does "Da" stand for? Daddy, dabbling, dandelion, dandruff, daguerreotype? > For me, typing without auto-complete is like > doing surgery with a kitchen knife. It's messy and error prone and I make > lots of mistakes and have to try twice as hard to remember the actual > names of variables instead of just whatever they start with. > > You don't understand because you actually know what all the function names > are and you don't have to constantly hover over them in auto-complete and > pull up their documentation to figure out how to use them. Hardly. > But I do. And > for me, without auto-complete, the learning process goes from actively > querying the IDE for one documentation after another to having to minimize > the IDE and Google search for each and every function and module that I"m > not familiar with. Auto-complete literally cuts the learning time by more > than half. No, it just eliminates learning. The end result is that you are reliant on the auto-complete because you haven't actually learned. > So please please please use PEP 484 to document all your standard library > functions. Not for static compilation. Not even for catching mistakes > caused by bad function input (although I like that). For Christ's sake, do > it for the auto-complete. I gave up on JavaScript in favor of TypeScript > for a reason god dammit. As I said, you don't need PEP 484 to implement auto-complete. Auto-complete is a fine and useful tool. But if you are crippled as a programmer without it, well, then you can hardly claim to understand the language or framework you are programming in if you cannot use it without an IDE doing half the work for you. -- Steven From as at sci.fi Mon Oct 12 08:53:14 2015 From: as at sci.fi (Anssi Saari) Date: Mon, 12 Oct 2015 15:53:14 +0300 Subject: Static typing implementation for Python References: <85d1wnw4qs.fsf@benfinney.id.au> <87a8rp6qgd.fsf@fastmail.com> Message-ID: Chris Angelico writes: > I'm fairly sure most arguments about "readable" or "unreadable" code > follow the same definitions. Does it ever. I never thought annotating names one added with one's initials or copy-pasting code instead of having a boolean expression in an if statement or keeping old code as comments improve readability. But that's what I was just told recently by someone. From bc at freeuk.com Mon Oct 12 09:30:52 2015 From: bc at freeuk.com (Bartc) Date: Mon, 12 Oct 2015 14:30:52 +0100 Subject: Strong typing implementation for Python In-Reply-To: References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12/10/2015 03:45, Michael Torrie wrote: > On 10/11/2015 06:34 PM, Steven D'Aprano wrote: >> That's called type inference, and there's nothing innovative about Swift to >> include that as a feature. Type inference is *old*. The theory behind type >> inference goes back to 1958, and languages such as ML and OCaml have >> included it for decades, and yet here we are in 2015 and people think that >> it's something cool and new :-( > > C++ introduced it a while ago (C++11), and D has had it from the > beginning. Even lowly FreeBasic has it. I've surprised Basic needs it. The last time I looked, $A was a string, %B an integer, and C a number. Type inference wasn't hard! (And trying Freebasic, it insists on variables being declared anyway. It's rather like C but with Basic syntax.) -- Bartc From nulla.epistola at web.de Mon Oct 12 09:40:55 2015 From: nulla.epistola at web.de (Sibylle Koczian) Date: Mon, 12 Oct 2015 15:40:55 +0200 Subject: Strong typing implementation for Python In-Reply-To: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> References: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: <561BB867.9010504@web.de> Am 12.10.2015 um 13:39 schrieb Steven D'Aprano: > Auto-complete is a fine and useful tool. But if you are crippled as a > programmer without it, well, then you can hardly claim to understand the > language or framework you are programming in if you cannot use it without > an IDE doing half the work for you. > Well ... you're certainly quite right as far as Python and its standard library is concerned. But I don't know who would really want to use .NET without auto-complete and for all I know Java may be just as awful. Sibylle From nulla.epistola at web.de Mon Oct 12 09:40:55 2015 From: nulla.epistola at web.de (Sibylle Koczian) Date: Mon, 12 Oct 2015 15:40:55 +0200 Subject: Strong typing implementation for Python In-Reply-To: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> References: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> Message-ID: <561BB867.9010504@web.de> Am 12.10.2015 um 13:39 schrieb Steven D'Aprano: > Auto-complete is a fine and useful tool. But if you are crippled as a > programmer without it, well, then you can hardly claim to understand the > language or framework you are programming in if you cannot use it without > an IDE doing half the work for you. > Well ... you're certainly quite right as far as Python and its standard library is concerned. But I don't know who would really want to use .NET without auto-complete and for all I know Java may be just as awful. Sibylle From gall.pavgal.gall at gmail.com Mon Oct 12 10:25:09 2015 From: gall.pavgal.gall at gmail.com (pupsik kc) Date: Mon, 12 Oct 2015 07:25:09 -0700 (PDT) Subject: win32com.client .Cells In-Reply-To: <561853ae$0$23734$e4fe514c@news.xs4all.nl> References: <097ed748-765c-4134-bcf2-5b2d538c4db7@googlegroups.com> <561853ae$0$23734$e4fe514c@news.xs4all.nl> Message-ID: Very Thanks Irmen! It's helped me. From gall.pavgal.gall at gmail.com Mon Oct 12 10:37:10 2015 From: gall.pavgal.gall at gmail.com (pupsik kc) Date: Mon, 12 Oct 2015 07:37:10 -0700 (PDT) Subject: [python] PYSVN [https] [callback_ssl_server_trust_prompt] Message-ID: Hi Guys, I need get update of files through SVN, that is called from python-script. could you show me example https connection ? :) i searched in google, but without success :( i had tried do next: import pysvn def get_login(username, save, password,retcode): return retcode, username, password, save def ssl_server_trust_prompt(trust_dict): return True, 0, True client = pysvn.Client() client.callback_ssl_server_trust_prompt = ssl_server_trust_prompt client.callback_get_login = get_login(username='USER',save=False,retcode=True,password='passwd') Traceback (most recent call last): File "D:/WebPython/SVN_test.py", line 13, in client.callback_get_login = get_login(username='USER',save=False,retcode=True,password='passwd') AttributeError: expecting None or a callable object From motoom at xs4all.nl Mon Oct 12 10:37:18 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Mon, 12 Oct 2015 16:37:18 +0200 Subject: win32com.client .Cells In-Reply-To: <097ed748-765c-4134-bcf2-5b2d538c4db7@googlegroups.com> References: <097ed748-765c-4134-bcf2-5b2d538c4db7@googlegroups.com> Message-ID: <7EF5FCD2-3E2B-4571-A0B1-5B6C588BE7F2@xs4all.nl> Hi, > excel_book=Excel.Workbooks.Open('D:\WebPython\Config3.xlsx') Shouldn't this be: excel_book=Excel.Workbooks.Open('D:\\WebPython\\Config3.xlsx') or excel_book=Excel.Workbooks.Open(r'D:\WebPython\Config3.xlsx') ? From rosuav at gmail.com Mon Oct 12 10:50:18 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 13 Oct 2015 01:50:18 +1100 Subject: win32com.client .Cells In-Reply-To: <7EF5FCD2-3E2B-4571-A0B1-5B6C588BE7F2@xs4all.nl> References: <097ed748-765c-4134-bcf2-5b2d538c4db7@googlegroups.com> <7EF5FCD2-3E2B-4571-A0B1-5B6C588BE7F2@xs4all.nl> Message-ID: On Tue, Oct 13, 2015 at 1:37 AM, Michiel Overtoom wrote: > Hi, > >> excel_book=Excel.Workbooks.Open('D:\WebPython\Config3.xlsx') > > Shouldn't this be: > > excel_book=Excel.Workbooks.Open('D:\\WebPython\\Config3.xlsx') > or > excel_book=Excel.Workbooks.Open(r'D:\WebPython\Config3.xlsx') > ? Ideally yes, but in this case it's the same. \W is an unrecognized escape sequence, so it represents REVERSE SOLIDUS followed by LATIN CAPITAL LETTER W. (IMO this is a misfeature in Python. I'd prefer unrecognized escapes to trigger SyntaxError, so people don't get confused when they change to "C:\Users\fred" and it changes in meaning.) ChrisA From torriem at gmail.com Mon Oct 12 11:47:23 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 12 Oct 2015 09:47:23 -0600 Subject: Strong typing implementation for Python In-Reply-To: References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> Message-ID: <561BD60B.4060608@gmail.com> On 10/12/2015 07:30 AM, Bartc wrote: > On 12/10/2015 03:45, Michael Torrie wrote: >> On 10/11/2015 06:34 PM, Steven D'Aprano wrote: >>> That's called type inference, and there's nothing innovative about Swift to >>> include that as a feature. Type inference is *old*. The theory behind type >>> inference goes back to 1958, and languages such as ML and OCaml have >>> included it for decades, and yet here we are in 2015 and people think that >>> it's something cool and new :-( >> >> C++ introduced it a while ago (C++11), and D has had it from the >> beginning. Even lowly FreeBasic has it. > > I've surprised Basic needs it. The last time I looked, $A was a string, > %B an integer, and C a number. Type inference wasn't hard! Back in the day this was certainly true. Most modern Basic dialects are more C-like in their declarations. > (And trying Freebasic, it insists on variables being declared anyway. > It's rather like C but with Basic syntax.) FB could be considered C-like with a Basic syntax, yes, but with dynamic strings and dynamic arrays. This idea of being c-like makes FB kind of interesting but uninteresting at the same time. Kind of hard to come up with a good reason to use it for something, especially when a dynamic language like Python, combined with C, is so flexible. From torriem at gmail.com Mon Oct 12 12:08:45 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 12 Oct 2015 10:08:45 -0600 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: <561BDB0D.5060903@gmail.com> On 10/12/2015 02:47 AM, John Michael Lafayette wrote: > Now that Python has static type checking and support for IDE auto-complete > (PEP 484?), I beg you to please use it. In your standard library, in your > production code, in everywhere. I cannot type without auto-complete. > > I know that sounds ridiculous, but I have been coding on a daily basis for > the last four years and I cannot recall the last time I actually typed out > a variable or function name without auto-complete typing it for me. To me, > java.net.DatagramSocket isn't "DatagramSocket". It is "Da" + Ctrl + Space + > Enter (auto complete). I literally memorized the number of characters I > have to type for auto-complete to guess the variable name and then I only > type that many characters. For me, typing without auto-complete is like > doing surgery with a kitchen knife. It's messy and error prone and I make > lots of mistakes and have to try twice as hard to remember the actual names > of variables instead of just whatever they start with. I haven't used Java in many years now, but it sounds like it's an awful experience to use if auto-complete is such a requirement to get anything done. > You don't understand because you actually know what all the function > names are and you don't have to constantly hover over them in > auto-complete and pull up their documentation to figure out how to > use them. But I do. And for me, without auto-complete, the learning > process goes from actively querying the IDE for one documentation > after another to having to minimize the IDE and Google search for > each and every function and module that I"m not familiar with. > Auto-complete literally cuts the learning time by more than half. Of course I don't know all the function names by heart. But in several years I haven't had to either. A few that I use regularly are easy to memorize. Not sure what you mean about having to minimize anything. If an IDE has to be kept full-screen all the time then I would find them to be a significant handicap. I have a windowing system for a reason! I can count on one hand the number of times I've maximized a window in the last few years. As others have said the standard library docs are quite good, and it's not hard to keep them up next to my programming window. Also Python can help document itself. A vital tool for any Python programmer is an interactive Python session. It's often easier to query the object I'm working with directly to find what methods it supports and the parameters it expects. Get familiar with the Python interactive mode and with basic calls like dir() and help(). Also many Python editing environments do support basic completion. However completion is actually very difficult to implement in a static manner because Python is so dynamic. I can import any standard library module and rename it as needed. Since some modules have longer names that I don't want to always type and since importing all of a module's symbols into the global namespace is really not a good idea, I might do something like import BeautifulSoup as bs Now I can refer to any BeautifulSoup symbols using the prefix bs. That isn't impossible for an IDE to track, but it is harder. If you can set aside your prejudices (static typing) and learn idiomatic python I think you'll have a great amount of fun and you'll find that even without the same level of auto completion that you'll be able to develop quite a bit faster than with Java. There's a good book called Fluent Python that can show you how idiomatic Python can really benefit you. Another good one is "Effective Python." From edmondo.giovannozzi at gmail.com Mon Oct 12 12:21:46 2015 From: edmondo.giovannozzi at gmail.com (edmondo.giovannozzi at gmail.com) Date: Mon, 12 Oct 2015 09:21:46 -0700 (PDT) Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: Il giorno luned? 12 ottobre 2015 10:51:50 UTC+2, John Michael Lafayette ha scritto: > Now that Python has static type checking and support for IDE auto-complete (PEP 484?), I beg you to please use it. In your standard library, in your production code, in everywhere. I cannot type without auto-complete. > > I know that sounds ridiculous, but I have been coding on a daily basis for the last four years and I cannot recall the last time I actually typed out a variable or function name without auto-complete typing it for me. To me, java.net.DatagramSocket isn't "DatagramSocket". It is "Da" + Ctrl + Space + Enter (auto complete). I literally memorized the number of characters I have to type for auto-complete to guess the variable name and then I only type that many characters. For me, typing without auto-complete is like doing surgery with a kitchen knife. It's messy and error prone and I make lots of mistakes and have to try twice as hard to remember the actual names of variables instead of just whatever they start with. > > You don't understand because you actually know what all the function names are and you don't have to constantly hover over them in auto-complete and pull up their documentation to figure out how to use them. But I do. And for me, without auto-complete, the learning process goes from actively querying the IDE for one documentation after another to having to minimize the IDE and Google search for each and every function and module that I"m not familiar with. Auto-complete literally cuts the learning time by more than half. > > So please please please use PEP 484 to document all your standard library functions. Not for static compilation. Not even for catching mistakes caused by bad function input (although I like that). For Christ's sake, do it for the auto-complete. I gave up on JavaScript in favor of TypeScript for a reason god dammit. > > On Oct 11, 2015 3:45 PM, "Matt Wheeler" wrote: > On 9 October 2015 at 17:26, John Michael Lafayette > > wrote: > > > I would like Python to have a strong typing feature that can co-exist with > > > the current dynamic typing system. Currently Python is like this: > > > > > >? ? ?var animal = Factory.make("dog")? # okay. > > >? ? ?var dog = Factory.make("dog")? ? ? ?# okay. > > >? ? ?var cat = Factory.make("dog")? ? ? ? # are you sure? > > > > > > I would like Python to also be able to also do this: > > > > > >? ? ?Animal a = Factory.make("dog")? ? # okay. Dog is Animal. > > >? ? ?Dog d = Factory.make("dog")? ? ? ? ?# okay. Dog is Dog. > > >? ? ?Cat c = Factory.make("cat")? ? ? ? ? ?# Runtime error. Dog is not Cat. > > > > Though it's intended for performance optimisation rather than simply > > static typing for static typing's sake, you could probably use Cython > > to achieve what you want... > > > > ...but then you might start to see the benefits of dynamic typing :) > > > > > > -- > > Matt Wheeler > > http://funkyh.at As far as I know the shell (if I can call it a shell) IPython has a sort of autocomplete. Given an object, after a dot if you type a tab it will give you the list of all the method that it can retrieve from the function dir(). geany, and spyder have also a sort of autocomplete. From carl at oddbird.net Mon Oct 12 12:26:04 2015 From: carl at oddbird.net (Carl Meyer) Date: Mon, 12 Oct 2015 10:26:04 -0600 Subject: Understanding WSGI together with Apache In-Reply-To: References: Message-ID: <561BDF1C.8000505@oddbird.net> Hi Johannes, On 10/10/2015 08:24 AM, Johannes Bauer wrote: > I'm running an Apache 2.4 webserver using mod_wsgi 4.3.0. There are two > different applications running in there running on two completely > separate vhosts. > > I'm seeing some weird crosstalk between them which I do not understand. > In particular, crosstalk concerning the locales of the two. One > application needs to output, e.g., date information using a German > locale. It uses locale.setlocale to set its LC_ALL to de_DE.UTF-8. > > Now the second application doesn't need nor want to be German. It wants > to see the C locale everywhere, in particular because at some point it > uses datetime.datetime.strptime() to parse a datetime. > > Here's where things get weird: Sometimes, my "C" locale process throws > exceptions, because it's unable to parse a date. When looking why this > fails, the string looks like de_DE's "Sa, 10 Okt 2015" instead of C's > "Sat, 10 Oct 2015". This seems to happen depending on which worker > thread is currently serving the request, i.e. nondeterministically. > > So all in all, this is very weird and I must admit that I don't seem to > fully understand how WSGI applications are run and served within a > mod_wsgi framework altogether. In the past it all "just worked" and I > didn't need to understand it all in-depth. But I think to be able to > debug such a weird issue, in-depth knowledge of what happens under the > hood would be helpful. > > So if someone could shed some light on how it works in general or what > could cause the described issue in particular, I'd really be grateful. It's been a number of years since I used mod-wsgi (I prefer gunicorn or uwsgi, in part because I find their process model so much easier to understand), but as best I understand (hopefully if I get anything wrong, someone who knows better can correct me) mod-wsgi uses a little-known CPython feature called "sub-interpreters", meaning that even multiple mod-wsgi sites on the same server can run in sub-interpreters of the same Python process, and certain global state (e.g. os.environ, apparently also the localization context) is shared between those sub-interpreters, which can cause "crosstalk" issues like you're seeing. I'm not sure, but I think _maybe_ using WSGIDaemonProcess [1] and putting your sites in different WSGIProcessGroup [2] might help? Carl [1] https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess [2] https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From ian.g.kelly at gmail.com Mon Oct 12 12:29:56 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 12 Oct 2015 10:29:56 -0600 Subject: Strong typing implementation for Python In-Reply-To: References: Message-ID: On Mon, Oct 12, 2015 at 2:47 AM, John Michael Lafayette wrote: > Now that Python has static type checking and support for IDE auto-complete > (PEP 484?), I beg you to please use it. In your standard library, in your > production code, in everywhere. I cannot type without auto-complete. *Decent* Python IDEs have had auto-complete for years -- at least for the past decade. You don't need PEP 484 for that. If the IDE that you're using doesn't support it well, then find another one that does. From bc at freeuk.com Mon Oct 12 13:10:47 2015 From: bc at freeuk.com (Bartc) Date: Mon, 12 Oct 2015 18:10:47 +0100 Subject: Strong typing implementation for Python In-Reply-To: References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12/10/2015 16:47, Michael Torrie wrote: > On 10/12/2015 07:30 AM, Bartc wrote: >> On 12/10/2015 03:45, Michael Torrie wrote: >>> C++ introduced it a while ago (C++11), and D has had it from the >>> beginning. Even lowly FreeBasic has it. >> >> [I'm] surprised Basic needs it. The last time I looked, $A was a string, >> %B an integer, and C a number. Type inference wasn't hard! > > Back in the day this was certainly true. Most modern Basic dialects are > more C-like in their declarations. > >> (And trying Freebasic, it insists on variables being declared anyway. >> It's rather like C but with Basic syntax.) > > FB could be considered C-like with a Basic syntax, yes, but with dynamic > strings and dynamic arrays. This idea of being c-like makes FB kind of > interesting but uninteresting at the same time. Kind of hard to come up > with a good reason to use it for something, especially when a dynamic > language like Python, combined with C, is so flexible. I suppose one reason is that it is easy to get up to speed with little effort, with something that is friendlier and a little higher level than C. Actually, I was pleasantly surprised at its capabilities. (Example, calling fib(40) on the example below took 90 seconds on Python 3.4, 11 seconds with PyPy, but only 1.8 seconds running the equivalent with FreeBasic: def fib(n): if n<2: return n else: return fib(n-2)+fib(n-1) There are doubtless all sorts of ways of getting that sort of speed in Python, but it's something extra to be researched and to do and could require using an auxiliary language. Maybe there are too many possible ways which is another problem.) -- Bartc From marko at pacujo.net Mon Oct 12 13:20:54 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 12 Oct 2015 20:20:54 +0300 Subject: Strong typing implementation for Python References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87wpusovex.fsf@elektro.pacujo.net> Bartc : > (Example, calling fib(40) on the example below took 90 seconds on > Python 3.4, 11 seconds with PyPy, but only 1.8 seconds running the > equivalent with FreeBasic: I don't know what you need fibonacci numbers for, but speed is not the essence of most programming tasks. Rather, the key issue is managing complexity. As for managing complexity, many people believe static typing is a crucial tool. I disagree. Static typing adds vast amounts of noise to the code. A dynamic programming language like Python allows you to express powerful abstractions concisely, understandably and likely correctly. Marko From bc at freeuk.com Mon Oct 12 13:50:54 2015 From: bc at freeuk.com (Bartc) Date: Mon, 12 Oct 2015 18:50:54 +0100 Subject: Strong typing implementation for Python In-Reply-To: <87wpusovex.fsf@elektro.pacujo.net> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> Message-ID: On 12/10/2015 18:20, Marko Rauhamaa wrote: > Bartc : > >> (Example, calling fib(40) on the example below took 90 seconds on >> Python 3.4, 11 seconds with PyPy, but only 1.8 seconds running the >> equivalent with FreeBasic: > > I don't know what you need fibonacci numbers for, It's a benchmark that gives you an idea of how efficient an implementation is at doing function calls. > but speed is not the > essence of most programming tasks. They've been wasting their time with PyPy then! Everyone likes a bit more speed. It can mean being able to have a solution all within the same language. > Rather, the key issue is managing > complexity. (Yes, I've seen gal kauffman's post in this thread. That will need some managing for sure!) > As for managing complexity, many people believe static typing is a > crucial tool. I disagree. Static typing adds vast amounts of noise to > the code. A dynamic programming language like Python allows you to > express powerful abstractions concisely, understandably and likely > correctly. Static typing gives advantages but it's also nice not to have to bother. That's why type inference can be useful. -- Bartc From jason.swails at gmail.com Mon Oct 12 16:08:43 2015 From: jason.swails at gmail.com (Jason Swails) Date: Mon, 12 Oct 2015 16:08:43 -0400 Subject: Strong typing implementation for Python In-Reply-To: References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> Message-ID: On Mon, Oct 12, 2015 at 1:50 PM, Bartc wrote: > On 12/10/2015 18:20, Marko Rauhamaa wrote: > >> Bartc : >> >> (Example, calling fib(40) on the example below took 90 seconds on >>> Python 3.4, 11 seconds with PyPy, but only 1.8 seconds running the >>> equivalent with FreeBasic: >>> >> >> I don't know what you need fibonacci numbers for, >> > > It's a benchmark that gives you an idea of how efficient an implementation > is at doing function calls. > > but speed is not the >> essence of most programming tasks. >> > > They've been wasting their time with PyPy then! Everyone likes a bit more > speed. It can mean being able to have a solution all within the same > language. ?Marko said most. Not all. And I would agree with that (I'm a computational scientist, where we put more emphasis on performance than almost anywhere else). A lot of our tools need to be hand-optimized using either assembler or compiler intrinsics to get the most performance possible out of the machine, but the *vast* majority of our daily programming does not require this. Only the most computationally intensive kernels do (which themselves are small portions of the main simulation engines!). Performance only matters when it allows you to do something that you otherwise couldn't. pypy makes some things possible that otherwise wasn't, but there's a reason why CPython is still used overwhelmingly more than pypy for scientific computing.? ?All the best, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Mon Oct 12 16:19:27 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 12 Oct 2015 16:19:27 -0400 Subject: Strong typing implementation for Python In-Reply-To: <561BDB0D.5060903@gmail.com> References: <561BDB0D.5060903@gmail.com> Message-ID: On 10/12/2015 12:08 PM, Michael Torrie wrote: > Also many Python editing environments do support basic completion. > However completion is actually very difficult to implement in a static > manner because Python is so dynamic. I can import any standard library > module and rename it as needed. Since some modules have longer names > that I don't want to always type and since importing all of a module's > symbols into the global namespace is really not a good idea, I might do > something like > > import BeautifulSoup as bs > > Now I can refer to any BeautifulSoup symbols using the prefix bs. That > isn't impossible for an IDE to track, but it is harder. That depends on whether autocompletion is name or object based. IDLE's is object based, so the following displays the contents of itertools the same as without the abbreviation. >>> import itertools as it >>> it. Object-based in turn means that autocompletion does not work as well in the editor until the code *is* executed. -- Terry Jan Reedy From anthony at cajuntechie.org Mon Oct 12 17:52:31 2015 From: anthony at cajuntechie.org (Anthony Papillion) Date: Mon, 12 Oct 2015 16:52:31 -0500 Subject: How to handle attachments passed via Postfix In-Reply-To: References: Message-ID: <561C2B9F.50309@cajuntechie.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 10/12/2015 3:58 AM, Chris Angelico wrote: > On Mon, Oct 12, 2015 at 6:17 PM, Anthony Papillion > wrote: >> I'm writing a script that will have email with attachments passed >> to it via Postfix. Postfix is properly passing the email to the >> script but I'm not quite sure how to get at the attachment. What >> I need to do is save the attachment out to the filesystem. >> >> Can anyone point me in the right direction? > > If I understand the situation correctly, you're getting a > MIME-formatted email, and want to decode it into a usable > attachment - right? > > Python includes a package for teasing apart RFC[2]822 format > emails: > > https://docs.python.org/3/library/email.html > > Check out the email.parser module, or the convenience function > email.message_from_string - you should be able to get at the > different parts (including attachments) from there. > Many thanks! Checking it out now. Sounds like exactly what I'm looking for. Anthony -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJWHCufAAoJEAKK33RTsEsVfeUP/3YWWDwVglwHXkHGrY3AkWol yyTeJyy+s8RQvza1gHcR3yv2gZs7PAI8azFjkMmlsicaB+dqdP1ffxd2eXK3TVlh GTOuCe7dHNgJ4EMpREr3RtJVbvQBX3ygmZaZY9jqPRCpG40TfOCaEOXjGABLukwi DP9j65tyIYRJsImmQ4RJ6L2AcrgGC3QTU1wCPPWaYD9AWLFyfR4be02vGGZODbYs QnKw1MrHrQBWMYaVKlhkvHVJIa68q/wIH4yPfE8tPejykRQ0OFUDfp8a9zveNU7U zIjeVU02jL3ijGXK1LxNz3mtt+aRletecOFbLtCMLY9TLwGTquXRyQzl28oOukh+ Uy/rYf9ZK8g2qrOEELyJXy4x0K6MpTdF+hN85oYkCl802uEsqlxUsU/EocUs6uIX GIXrevDSvdQDbujMUPg4TQKmkhNN5/fC40NQGFd/xcxljTqHZ/bl4MinDT9ZxYFk OLwEpCVZfTMJvYxGEfBS1GQvKxeRKzPgXeV70YgXh0GIl339Bq1znpObnlYNuVki cBRqos2RUAanzgkQ6jqoE0KknP/wPZL/nJA1MR67lV64j5zqMD/b+Pw44K/u9QNP YZnXzto8EUJ9Zs4i7LrZcFuRpE+WjFyP39XPGiMZN7+/S9++CVfgu0SLLT3VrHWc v7WzAa3wNEnR8O35bhvH =xwRy -----END PGP SIGNATURE----- From ben+python at benfinney.id.au Mon Oct 12 18:10:04 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 13 Oct 2015 09:10:04 +1100 Subject: Strong typing implementation for Python References: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> <561BB867.9010504@web.de> Message-ID: <85vbabu4ar.fsf@benfinney.id.au> Sibylle Koczian writes: > Am 12.10.2015 um 13:39 schrieb Steven D'Aprano: > > Auto-complete is a fine and useful tool. But if you are crippled as a > > programmer without it, well, then you can hardly claim to understand the > > language or framework you are programming in if you cannot use it without > > an IDE doing half the work for you. > > > > Well ... you're certainly quite right as far as Python and its > standard library is concerned. But I don't know who would really want > to use .NET without auto-complete and for all I know Java may be just > as awful. Yes, and that is quite compatible with Steven's assertion. The two assertions: * A programmer who feels crippled without auto-complete cannot claim to understand the language or framework they're programming in. (assertion made by Steven) * The overwhelming majority of .NET and Java programmers would feel crippled without auto-complete. (assertion made by Sibylle) can both be true. An obvious resolution is to conclude that the overwhelming majority of Java and .NET programmers cannot claim to understand those technologies. Python, on the other hand, has the huge advantage that programming in even a bare minimal editor is feasible, and editor features that make the programmer's life easier are conveniences, not essential to be competent in Python. -- \ ?Free thought is a necessary, but not a sufficient, condition | `\ for democracy.? ?Carl Sagan | _o__) | Ben Finney From glennmschultz at gmail.com Mon Oct 12 18:42:17 2015 From: glennmschultz at gmail.com (Glenn Schultz) Date: Mon, 12 Oct 2015 15:42:17 -0700 (PDT) Subject: Some Help getting started Message-ID: <3acd60ee-d0ac-4986-bc99-75692d3b4094@googlegroups.com> Hello All, I have an application written in R for the analysis of mortgage-backed and asset-backed securities. I am in the process of writing it in Python. I need some help getting started. Here is the repository https://github.com/glennmschultz/Bond_Lab I think I have the deployment setup properly but I can't seem to install the deployment. I tried pip install - e . but that did not work. I have been reading all day and have made very little progress. I expect its simple but so far I have not found the magic bullet. The R version was used to write a book which is coming out in Feb so the Python version will benefit from earlier mistakes. http://www.amazon.com/Investing-Mortgage-Backed-Securities-Website/dp/1118944003/ref=sr_1_1?ie=UTF8&qid=1444689641&sr=8-1&keywords=glenn+schultz I have two Python books I have been reading but at some point one just has to get to it. Any advise as to what I am doing wrong is greatly appreciated -Glenn From victor.hooi at 10gen.com Mon Oct 12 18:43:07 2015 From: victor.hooi at 10gen.com (victor.hooi at 10gen.com) Date: Mon, 12 Oct 2015 15:43:07 -0700 (PDT) Subject: Relaxed, or best-efforts JSON parser for Python? In-Reply-To: References: <52c15e23-c897-4c80-88ff-b18314a91d80@googlegroups.com> Message-ID: On Monday, October 12, 2015 at 10:02:13 PM UTC+11, Laura Creighton wrote: > In a message of Sun, 11 Oct 2015 17:56:33 -0700, Victor Hooi writes: > >Hi, > > > >I'm attempting to parse MongoDB loglines. > > > >The formatting of these loglines could best be described as JSON-like... > > > >For example - arrays > > > >Anyhow, say I had the following logline snippet: > > > > { Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 1 } }, oplog: { acquireCount: { w: 1 } } } > > > >This won't parse with json.loads() - the main issues is the missing quotation marks (") around the strings. > > > >My question, is there a more lenient, or relaxed JSON parser available for Python, that will try to do a best-efforts parsing of non-spec JSON? > > > >Cheers, > >Victor > >-- > >https://mail.python.org/mailman/listinfo/python-list > > Won't this > http://blog.mongodb.org/post/85123256973/introducing-mtools > https://github.com/rueckstiess/mtools > https://pypi.python.org/pypi/mtools/1.1.3 > > be better? :) Hi, @MRAB - Thanks for the tip. I did actually think of doing that as well - it's what we (MongoDB) do internally for a few of our tools, but was really hoping to avoid going down the regex route. However, this is what I'm doing for now: locks = re.sub(r"(\w+):", "\"\g<1>\":", locks) @Random832 - No, it's not YAML. The MongoDB log format is....sort of JSON, but not. IMHO ,it's a bit of an ugly mess. So things like string fields aren't quoted, you have random custom types, parentheses aren't necessarily balanced (e.g. if you have long loglines that get truncated at 10K characters etc.). I could go on. @Laura Creighton - Yup, mtools is actually written by a colleague of mine =). Awesome guy. He does a lot of stuff to work around the idiosyncrasies of the MongoDB log format. However, there's quite a bit of overhead to using the full module for this - for this use case, I just needed to parse a specific "locks" document from a logline, so I was hoping for a clean way to just take it and parse it - in this case, the only issue that could hit us (AFAIK) is the lack of quotes around string fields. If they ever introduced a field with spaces in it....I don't know what would happen, lol. From ian.g.kelly at gmail.com Mon Oct 12 18:58:40 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 12 Oct 2015 16:58:40 -0600 Subject: Some Help getting started In-Reply-To: <3acd60ee-d0ac-4986-bc99-75692d3b4094@googlegroups.com> References: <3acd60ee-d0ac-4986-bc99-75692d3b4094@googlegroups.com> Message-ID: On Mon, Oct 12, 2015 at 4:42 PM, Glenn Schultz wrote: > Hello All, > > I have an application written in R for the analysis of mortgage-backed and asset-backed securities. I am in the process of writing it in Python. I need some help getting started. Here is the repository > > https://github.com/glennmschultz/Bond_Lab > > I think I have the deployment setup properly but I can't seem to install the deployment. I tried > pip install - e . but that did not work. I have been reading all day and have made very little progress. I expect its simple but so far I have not found the magic bullet. Did you actually use pip install -e or pip install - e (which would be an error)? Just saying that it doesn't work doesn't help us help you. What precisely have you tried, and what was the error that you got when you tried it? From steve at pearwood.info Mon Oct 12 20:07:36 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Tue, 13 Oct 2015 11:07:36 +1100 Subject: Strong typing implementation for Python References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> Message-ID: <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> On Tue, 13 Oct 2015 04:20 am, Marko Rauhamaa wrote: > As for managing complexity, many people believe static typing is a > crucial tool. I disagree. Static typing adds vast amounts of noise to > the code. Only if you are stuck in the 1970s. And even then, it is not always noise, type declarations or annotations often make useful documentation. Consider the following piece of code: def addone(x): return x + 1 The human programmer reading that can trivially infer that x must be a number (or at least something which supports numeric addition). So can the compiler. In a strongly typed language with no numeric promotion, the compiler can infer that x must be an int. In a language with numeric promotion, it can infer that x must be an int or float. Where is the "vast amounts of noise" added to the code? -- Steven From bc at freeuk.com Mon Oct 12 20:43:24 2015 From: bc at freeuk.com (Bartc) Date: Tue, 13 Oct 2015 01:43:24 +0100 Subject: Strong typing implementation for Python In-Reply-To: <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 13/10/2015 01:07, Steven D'Aprano wrote: > On Tue, 13 Oct 2015 04:20 am, Marko Rauhamaa wrote: > >> As for managing complexity, many people believe static typing is a >> crucial tool. I disagree. Static typing adds vast amounts of noise to >> the code. > > Only if you are stuck in the 1970s. And even then, it is not always noise, > type declarations or annotations often make useful documentation. > > Consider the following piece of code: > > def addone(x): > return x + 1 > > > The human programmer reading that can trivially infer that x must be a > number (or at least something which supports numeric addition). So can the > compiler. In a strongly typed language with no numeric promotion, the > compiler can infer that x must be an int. In a language with numeric > promotion, it can infer that x must be an int or float. That's type inference. And is harder than it looks. In Python, x could be almost anything, and still be legal, if X has type T and "+" has been defined between T and integer. (It would need to analyse an entire program and it still can't always be sure.) > Where is the "vast amounts of noise" added to the code? It comes from writing this: def addone(int x)int: And not all types are as compact as 'int' (have a look at some C or C++ header files). -- Bartc From torriem at gmail.com Mon Oct 12 21:35:57 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 12 Oct 2015 19:35:57 -0600 Subject: Strong typing implementation for Python In-Reply-To: <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: <561C5FFD.1090006@gmail.com> On 10/12/2015 06:07 PM, Steven D'Aprano wrote: > Where is the "vast amounts of noise" added to the code? Well in Java code for one. No wonder they require auto-completion. Java class-based namespaces must be a nightmare to work with. That and all the over-use of design patterns that Java libraries love to do, though in fairness Java requires a certain amount of boilerplate to do things like singletons and factories, whereas Python can often just use a module. Also in C and C++ the static type declarations do sometimes make things look a lot more noisy. From burak.arslan at arskom.com.tr Tue Oct 13 03:04:09 2015 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Tue, 13 Oct 2015 10:04:09 +0300 Subject: How to handle attachments passed via Postfix In-Reply-To: <561C2B9F.50309@cajuntechie.org> References: <561C2B9F.50309@cajuntechie.org> Message-ID: <561CACE9.7010405@arskom.com.tr> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 10/13/15 00:52, Anthony Papillion wrote: >> Check out the email.parser module, or the convenience function >> > email.message_from_string - you should be able to get at the >> > different parts (including attachments) from there. >> > > Many thanks! Checking it out now. Sounds like exactly what I'm looking > for. Also have a look at flanker (https://github.com/mailgun/flanker) basically doing the same thing. Here's why it exists: https://github.com/mailgun/flanker/blob/master/docs/User%20Manual.md#rationale Best, Burak -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWHKzpAAoJEDzeDArrSnh8eKwQAJJ1odTXgJkVi4LgmxhN/CLR jWdGCGdpIds1WNJ2iwcagF1N57oU3Lfq1xuTmF7GtCbRyL5/O9Tsjmge+xw8jzDQ va/ge2keR2LTRlJd/XAYmQSx8ArGq/2K/hG/xNbzMjMhDo49ZQXenzGAZxCnMPcj x5i1Op/PeKBNz/lTyHvkMPNubtc5XWaKo2U9QxaA151A/jNCJPNQ0jpezkjKdHlo 2PEYNgoqU5ioF+wQ6bHwk/QCgIYINO3Spm0MqE+49qVnOhDl/LabnT5ckpGMOn4N mMPbSWIKNMOs+ulFScy2lV6yBFPi/eniZF4S7V1osxiPxu/N1X1fK92gljw31JQF tkumMBV+ql2nuv288zPPJG3O8YUvUug/v2OJewIvjPr5eBabcwDYZHdoW8oPBBuU DGVaJPynzUNvm1SaTE+/w7Baa19XIB+IqvYw42Ey4xoZQgr5T10h7ipwnpcNCWwy 7TQ5MdxhIeR1iiV9ofF2gxLWkE8bWJJ0eCBcOFvgXbUWbsdKsp+WqHHuXBjRedvI 1PGWJWBd411hpDnJc0vVVW5zqJqGr4MKkxEVh9K5T0RLcaUeXlQEMWWzl6n2/3KX Nv9jNQ5T7raiBRgXt8/DXBLTreq9FzCxpRR3HMUeoZo2If2bkQ983tK2U8IxCxoE hTQsYzrEFEiw37ypo9G2 =5gjA -----END PGP SIGNATURE----- From toddrjen at gmail.com Tue Oct 13 03:55:56 2015 From: toddrjen at gmail.com (Todd) Date: Tue, 13 Oct 2015 09:55:56 +0200 Subject: Strong typing implementation for Python In-Reply-To: <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Oct 13, 2015 2:11 AM, "Steven D'Aprano" wrote: > > On Tue, 13 Oct 2015 04:20 am, Marko Rauhamaa wrote: > > > As for managing complexity, many people believe static typing is a > > crucial tool. I disagree. Static typing adds vast amounts of noise to > > the code. > > Only if you are stuck in the 1970s. And even then, it is not always noise, > type declarations or annotations often make useful documentation. > > Consider the following piece of code: > > def addone(x): > return x + 1 > > > The human programmer reading that can trivially infer that x must be a > number (or at least something which supports numeric addition). So can the > compiler. In a strongly typed language with no numeric promotion, the > compiler can infer that x must be an int. In a language with numeric > promotion, it can infer that x must be an int or float. Or a decimal, complex number, numpy array, any one of a dozen or so pandas classes, any one of the dozen or so units classes, sympy variable, etc... -------------- next part -------------- An HTML attachment was scrubbed... URL: From mvoicem at gmail.com Tue Oct 13 04:03:29 2015 From: mvoicem at gmail.com (m) Date: Tue, 13 Oct 2015 10:03:29 +0200 Subject: Strong typing implementation for Python In-Reply-To: References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: <561cbac9$0$27520$65785112@news.neostrada.pl> W dniu 13.10.2015 o 03:35, Michael Torrie pisze: > On 10/12/2015 06:07 PM, Steven D'Aprano wrote: >> > Where is the "vast amounts of noise" added to the code? > Well in Java code for one. No wonder they require auto-completion. > Java class-based namespaces must be a nightmare to work with. IMHO mainly because their naming convention. They just love typing long names. If they used named like in python, that "vast amount of noise added to code" would be just "a bit noise added to code" r. m. From cllach at email.com Tue Oct 13 04:10:17 2015 From: cllach at email.com (Cinto Llach) Date: Tue, 13 Oct 2015 10:10:17 +0200 Subject: Python not working on my system Message-ID: <000001d1058e$9a56a6c0$cf03f440$@email.com> I'm sending you this email, as I'm having problems trying to install and use Python. I've been tryng to install Python on one System : HP Intel Core 2 Duo 4300, 1,8 GHz 2 Gb RAM Windows XP Professional SP 3 And I've got the following screens, with no visible Command Buttons. I've been able to proceed by blind testing in the forms ... Setup was successful ... It appears in Start Menu ... But when trying to launch pythonw.exe : Or python.exe : And when uninstalling, the form show no buttons ... But after finding the locations to click ... I will thank you if you can provide any help. Best wishes. Cinto Llach cllach at outlook.com cllach at email.com 034 622401038 Barcelona -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image003.png Type: image/png Size: 7047 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image008.jpg Type: image/jpeg Size: 17865 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image015.jpg Type: image/jpeg Size: 16703 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image016.jpg Type: image/jpeg Size: 14010 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image017.jpg Type: image/jpeg Size: 15203 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image018.jpg Type: image/jpeg Size: 13589 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image019.jpg Type: image/jpeg Size: 14278 bytes Desc: not available URL: From mtcarrick at alaska.edu Tue Oct 13 04:35:57 2015 From: mtcarrick at alaska.edu (Mathew Carrick) Date: Tue, 13 Oct 2015 00:35:57 -0800 Subject: Python not working on my system In-Reply-To: <000001d1058e$9a56a6c0$cf03f440$@email.com> References: <000001d1058e$9a56a6c0$cf03f440$@email.com> Message-ID: Hi Cinto, Python 3.5 does not work on Windows XP. Can you use Python 3.4 instead? Best, Mathew Carrick On Tue, Oct 13, 2015 at 12:10 AM, Cinto Llach wrote: > I?m sending you this email, as I?m having problems trying to install and > use Python. > > > > I?ve been tryng to install Python on one System : > > HP Intel Core 2 Duo 4300, 1,8 GHz > > 2 Gb RAM > > Windows XP Professional SP 3 > > > > And I?ve got the following screens, with no visible Command Buttons. I?ve > been able to proceed by blind testing in the forms ... > > > > > > Setup was successful ... > > > > > > It appears in Start Menu ... > > > > [image: cid:image003.png at 01D10513.21E3F4C0] > > > > But when trying to launch pythonw.exe : > > > > > > Or python.exe : > > > > > > And when uninstalling, the form show no buttons ... > > > > > > But after finding the locations to click ... > > > > > > I will thank you if you can provide any help. > > > > Best wishes. > > > > Cinto Llach > > cllach at outlook.com > > cllach at email.com > > > > 034 622401038 > > > > Barcelona > > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image003.png Type: image/png Size: 7047 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image008.jpg Type: image/jpeg Size: 17865 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image016.jpg Type: image/jpeg Size: 14010 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image015.jpg Type: image/jpeg Size: 16703 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image019.jpg Type: image/jpeg Size: 14278 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image017.jpg Type: image/jpeg Size: 15203 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image018.jpg Type: image/jpeg Size: 13589 bytes Desc: not available URL: From lac at openend.se Tue Oct 13 04:41:55 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 13 Oct 2015 10:41:55 +0200 Subject: Some Help getting started In-Reply-To: References: <3acd60ee-d0ac-4986-bc99-75692d3b4094@googlegroups.com> Message-ID: <201510130841.t9D8ftZl006364@fido.openend.se> In a message of Mon, 12 Oct 2015 16:58:40 -0600, Ian Kelly writes: >Just saying that it doesn't work doesn't help us help you. What >precisely have you tried, and what was the error that you got when you >tried it? What Ian said. Also what python version are you using and what OS? Laura From cllach at email.com Tue Oct 13 04:49:53 2015 From: cllach at email.com (Cinto Llach) Date: Tue, 13 Oct 2015 10:49:53 +0200 Subject: Python not working on my system In-Reply-To: References: <000001d1058e$9a56a6c0$cf03f440$@email.com> Message-ID: <004001d10594$22c77250$685656f0$@email.com> Ok, thanks a lot for your quick answer. I?ll try to upgrade the machine to W7 as I?ve been asked to use Python 3.5. Again my thanks and best wishes. Cinto Llach cllach at email.com 622401038 From: Mathew Carrick [mailto:mtcarrick at alaska.edu] Sent: Tuesday, October 13, 2015 10:36 AM To: Cinto Llach Cc: python-list at python.org Subject: Re: Python not working on my system Hi Cinto, Python 3.5 does not work on Windows XP. Can you use Python 3.4 instead? Best, Mathew Carrick On Tue, Oct 13, 2015 at 12:10 AM, Cinto Llach > wrote: I?m sending you this email, as I?m having problems trying to install and use Python. I?ve been tryng to install Python on one System : HP Intel Core 2 Duo 4300, 1,8 GHz 2 Gb RAM Windows XP Professional SP 3 And I?ve got the following screens, with no visible Command Buttons. I?ve been able to proceed by blind testing in the forms ... Setup was successful ... It appears in Start Menu ... But when trying to launch pythonw.exe : Or python.exe : And when uninstalling, the form show no buttons ... But after finding the locations to click ... I will thank you if you can provide any help. Best wishes. Cinto Llach cllach at outlook.com cllach at email.com 034 622401038 Barcelona -- https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 17865 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 16703 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image003.png Type: image/png Size: 7047 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image004.jpg Type: image/jpeg Size: 14010 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image005.jpg Type: image/jpeg Size: 15203 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image006.jpg Type: image/jpeg Size: 13589 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image007.jpg Type: image/jpeg Size: 14278 bytes Desc: not available URL: From lac at openend.se Tue Oct 13 05:05:38 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 13 Oct 2015 11:05:38 +0200 Subject: Strong typing implementation for Python In-Reply-To: <561C5FFD.1090006@gmail.com> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> <561C5FFD.1090006@gmail.com> Message-ID: <201510130905.t9D95crg008225@fido.openend.se> In a message of Mon, 12 Oct 2015 19:35:57 -0600, Michael Torrie writes: >On 10/12/2015 06:07 PM, Steven D'Aprano wrote: >> Where is the "vast amounts of noise" added to the code? > >Well in Java code for one. No wonder they require auto-completion. >Java class-based namespaces must be a nightmare to work with. That and >all the over-use of design patterns that Java libraries love to do, >though in fairness Java requires a certain amount of boilerplate to do >things like singletons and factories, whereas Python can often just use >a module. When Design Patterns were new, the 2 of the first books to come out were 'Design Patterns'[1995] which was C++ focused, and the 'Design Patterns Smalltalk Companion'[1998]. If you read the two of them, side by side (as DPSTC asks you to) you will be struct by how little of the C++ code is about 'here is the pattern I want to implement' and how much is 'here is what to do to bash the C++ type system into submission' -- to the point where a couple of DP are files, in the Smalltalk version as 'for Smalltalk this is only a few lines of code, not enough to really be a pattern (and I bet you do this all the time without thinking that you were using a Design pattern, don't you?)'. The Smalltalk versions are all so much sorter. And Smalltalk, like Python is a strongly and dynamically typed langauge. Thus it is no wonder that the DP get used more than they need to in the java world. No matter what you write you will have to write the 'and then get it past the type checking' part, and grabbing a well-tested one of those saves you from a lot of bugs, even if you have to take and overly-heavy and complicated DP to go along with it. Laura From anthony at cajuntechie.org Tue Oct 13 05:32:44 2015 From: anthony at cajuntechie.org (Anthony Papillion) Date: Tue, 13 Oct 2015 04:32:44 -0500 Subject: How to handle attachments passed via Postfix In-Reply-To: <561CACE9.7010405@arskom.com.tr> References: <561C2B9F.50309@cajuntechie.org> <561CACE9.7010405@arskom.com.tr> Message-ID: <332ac897-e188-4487-ad45-af6891743380@email.android.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On October 13, 2015 2:04:09 AM CDT, Burak Arslan wrote: > > >On 10/13/15 00:52, Anthony Papillion wrote: >>> Check out the email.parser module, or the convenience function >>> > email.message_from_string - you should be able to get at the >>> > different parts (including attachments) from there. >>> > >> Many thanks! Checking it out now. Sounds like exactly what I'm >looking >> for. > >Also have a look at flanker (https://github.com/mailgun/flanker) >basically doing the same thing. > >Here's why it exists: >https://github.com/mailgun/flanker/blob/master/docs/User%20Manual.md#rationale Thanks Burak!I've just had a look at it and it looks pretty amazing. I particularly like the speed incest and smaller memory footprint. Thanks for pointing me here! Anthony - -- Phone: +1.845.666.3312 Skype: CajunTechie SIP/VoIP: 17772471988 at in.callcentric.com PGP Key: 0x53B04B15 Fingerprint: C5CE E687 DDC2 D12B 9063 56EA 028A DF74 53B0 4B15 -----BEGIN PGP SIGNATURE----- Version: APG v1.1.1 iQJJBAEBCgAzBQJWHM+8LBxBbnRob255IFBhcGlsbGlvbiA8YW50aG9ueUBjYWp1 bnRlY2hpZS5vcmc+AAoJEAKK33RTsEsVmCQP/3KYdbTjyXW33BkCalagLosJC6os xGVggx1TB8aK0QFDAJoVRAKZ7nn9AV75VC/+Y9qIVJyMWS9GQICMhU29NeSJ7Uao DL6XqROpOy8hl9Mnu+e5c0TwL9SI2oKeOwRqxwJVVWq9kM/og99ryfKOaNIVBoV4 32gHHYqjEx/zXlmYTL0gTbYbK/LJyVlmfVYWXjdvb7QWsv8g+5NyRUpqKrx+Pvvs YPhtfQ/ltgo7NxSU2e3hNWp91F29J840d82jvHVqPEMpAHVikFBYAD8B1fkeLvBi z9x5mQfGdReLlnUngbCcJJ0/6Vwla5LeK2nvAJuMofjy2NKCS91arLmp5wIgWz7P CMSep1Lt1Nhd1PRKMF0uXFMZ1i7cC7BzalyY6WJHnFBryLh0uxrEMH2ma1ZR+d7W PgcMo4nmB9ECIbZAGQE5p46QJ08op8E5GnrtRfOlcCpJIYLT2CEIg4cSz14cPm8f 0mCP7iMz3B5CeASTnfJ425mTczHVgtd20FpiRNUh58JvoSlLL0nmRaL4yJfBlC+t u75UsNxknWPsy3tDCDs2U+gdo0vrla0Ld5iy2i38oiJ0a9KBeUiLrJd7AJi4fQft BPJHDdRbUBXnpkb7VyPLF7ftxEVvI/XxJr8NY99DU/hfexsOiY/49YFdj783GxDk FuzU9Vmd1HAeou0T =JVUd -----END PGP SIGNATURE----- From info at egenix.com Tue Oct 13 06:06:20 2015 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Tue, 13 Oct 2015 12:06:20 +0200 Subject: =?UTF-8?Q?ANN:_Python_Meeting_D=c3=bcsseldorf_-_21.10.2015?= Message-ID: <561CD79C.50100@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, 21.10.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-10-21 ________________________________________________________________________ NEUIGKEITEN * Bereits angemeldete Vortr?ge: Matthias Endler: "Writing a fuzzy receipt parser in Python using tesseract" Marc-Andre Lemburg: "Untwisting Mersenne Twister: Python's Zufallszahlengenerator" "Portierung von mxDateTime auf Python 3" 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 Experts (#1, Oct 13 2015) >>> Python Projects, Coaching and Consulting ... http://www.egenix.com/ >>> Python Database Interfaces ... http://products.egenix.com/ >>> Plone/Zope Database Interfaces ... http://zope.egenix.com/ ________________________________________________________________________ 2015-10-21: Python Meeting Duesseldorf ... 8 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 marticongost at gmail.com Tue Oct 13 06:17:41 2015 From: marticongost at gmail.com (=?UTF-8?Q?Mart=C3=AD_Congost?=) Date: Tue, 13 Oct 2015 12:17:41 +0200 Subject: User defined generic types and collections.abc Message-ID: I have a package that defines a variety of collections based on the ABCs provided by collections.abc (Mapping, Sequence, etc). I wanted to take advantage of the type hinting facilities introduced in Python 3.5, and I'm having doubts as to what would be the best way to go about it. Lets take one of these classes as an exemple; until now, I had something resembling this: from collections.abc import Mapping class MyMapping(Mapping): ... To turn this into a generic type, the documentation ( https://www.python.org/dev/peps/pep-0484/#arbitrary-generic-types-as-base-classes) would seem to suggest doing something like this: from typing import Generic, Hashable, TypeVar, Mapping K = TypeVar("K", bound=Hashable) V = TypeVar("V") class MyMapping(Mapping[K, V]): ... But this poses two problems: - The class looses all the mixin methods from collections.abc.Mapping. I could deal with this by implementing them myself, but that would defeat part of the purpose of using ABCs in the first place. - isinstance(MyMapping(), collections.abc.Mapping) returns False. Also, trying to call collections.abc.Mapping.register(MyMapping) to work around this raises a RuntimeError ("Refusing to create an inheritance cycle"). My first attempt to solve these problems was to go back to extending collections.abc.Mapping: from typing import Generic, Hashable, TypeVar from collections.abc import Mapping K = TypeVar("K", bound=Hashable) V = TypeVar("V") class MyMapping(Mapping[K, V]): ... But that doesn't work, as collections.abc.Mapping is not a generic type and does not support the subscription operator. So I tried this: from typing import Generic, Hashable, TypeVar, Mapping from collections.abc import Mapping as MappingABC K = TypeVar("K", bound=Hashable) V = TypeVar("V") class MyMapping(MappingABC, Mapping[K, V]): ... But this smells fishy. The imports and aliasing are cumbersome, the resulting class has a tortuous MRO, and the mix-in methods provided by the ABC won't have typing information... So what is the preferred way to declare a custom generic type based on a collection ABC? -------------- next part -------------- An HTML attachment was scrubbed... URL: From marko at pacujo.net Tue Oct 13 06:42:00 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 13 Oct 2015 13:42:00 +0300 Subject: Strong typing implementation for Python References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> <561C5FFD.1090006@gmail.com> Message-ID: <87h9lvrqx3.fsf@elektro.pacujo.net> Laura Creighton : > When Design Patterns were new, the 2 of the first books to come out > were 'Design Patterns'[1995] which was C++ focused, and the 'Design > Patterns Smalltalk Companion'[1998]. If you read the two of them, side > by side (as DPSTC asks you to) you will be struct by how little of the > C++ code is about 'here is the pattern I want to implement' and how > much is 'here is what to do to bash the C++ type system into > submission' -- to the point where a couple of DP are files, in the > Smalltalk version as 'for Smalltalk this is only a few lines of code, > not enough to really be a pattern (and I bet you do this all the time > without thinking that you were using a Design pattern, don't you?)'. > The Smalltalk versions are all so much sorter. And Smalltalk, like > Python is a strongly and dynamically typed langauge. > > Thus it is no wonder that the DP get used more than they need to in > the java world. No matter what you write you will have to write the > 'and then get it past the type checking' part, and grabbing a > well-tested one of those saves you from a lot of bugs, even if you > have to take and overly-heavy and complicated DP to go along with it. Great post! A few years back I programmed in Java. I literally had to write (or generate) 2,000 lines of code to satisfy the structural requirements (interfaces, method stubs, javadocs, ...) before the code actually did anything. Marko From Uday.Pethakamsetty at infor.com Tue Oct 13 06:45:01 2015 From: Uday.Pethakamsetty at infor.com (Uday Pethakamsetty) Date: Tue, 13 Oct 2015 10:45:01 +0000 Subject: request Message-ID: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> Hi I am working on python 2.x for long time. I thought of testing python 3.5 for possible usage. The problem is that when I installed python 3.5, all the pip installs are directing to python 3.5, instead of my native python 2.7. I heard of a feature called pylauancher; but I didn't find any satisfying documentation on it. Either pylauncer, or something else Solution-could you help reply the possible solution to work comfortably on either versions, without interfering, in my windows 64 bit machine. Thanks & regards Udhay Prakash -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Tue Oct 13 07:18:31 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 13 Oct 2015 13:18:31 +0200 Subject: sorry for all the typos In-Reply-To: <87h9lvrqx3.fsf@elektro.pacujo.net> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> <561C5FFD.1090006@gmail.com> <87h9lvrqx3.fsf@elektro.pacujo.net> Message-ID: <201510131118.t9DBIV65018196@fido.openend.se> re-reading what I wrote after Marko quoted it, I see an unacceptable level of typos and other sentence structure errors. I have eyedrops in my eyes today. I really cannot read what I type well enough. Amusing that my fingers find 'struct' a more reasonable thing to type than 'struck', (to me at any rate) ... Laura From abbasmo at centralfoundationboys.co.uk Tue Oct 13 07:33:12 2015 From: abbasmo at centralfoundationboys.co.uk (abbasmo at centralfoundationboys.co.uk) Date: Tue, 13 Oct 2015 04:33:12 -0700 (PDT) Subject: I have this programme (annotated) I want allow it to run more than once any tips or even better python code. :) Message-ID: <2bfe0376-d13b-4e62-ad25-2377b0ecd3a9@googlegroups.com> import time #this is so that i can set a timer print ("only print numbers as your answers (Round all numbers up): ") time.sleep(2) #this is to let the person know what format to write it in# answer = input ("enter the height of the room walls between 2 to 6 metres: ") #this is the first input to understand what the client wants# print (answer) #this is to let the client know what value they have put in to see if they have made a mistake# while answer == range(2,6): Q1 #this lets the programme know which figures are acceptable# Q1 = input("enter length of room walls between 1 to 25 metres: ") #this the second question that is chosen# print (Q1) #This is again to let the client know what number they have inserted in case they have made an error while Q1 == range(1,25): Q2 #this is to let the programme know the numbers that are acceptable# Q2 = input("choose the price of paint that you want. Luxury = 175 Standard cost 100 Economy = 45 ALL PRICES MULTIPLIED BY 100 : ") #this is the final question that is asked# print (Q2) #this the final indication of what the client has inserted into the equasion# y = (int(answer) * int(Q1)* int(Q2)) #This tells the programme to multiply the numbers together# print (y/100 + 0.5) #this is because the programme only accepts whole numbers and to get the real value i needed to devide by 100 time.sleep(25) #problem with this programme is that it allows any number to be placed in the system and also that it stops straight away hence the timer. if you have any advice I would love to hear# From abbasmo at centralfoundationboys.co.uk Tue Oct 13 07:35:16 2015 From: abbasmo at centralfoundationboys.co.uk (abbasmo at centralfoundationboys.co.uk) Date: Tue, 13 Oct 2015 04:35:16 -0700 (PDT) Subject: dont know if it sent sorry if it has Message-ID: <499f9f91-9bc2-484c-84c8-20ed574bded0@googlegroups.com> import time #this is so that i can set a timer print ("only print numbers as your answers (Round all numbers up): ") time.sleep(2) #this is to let the person know what format to write it in# answer = input ("enter the height of the room walls between 2 to 6 metres: ") #this is the first input to understand what the client wants# print (answer) #this is to let the client know what value they have put in to see if they have made a mistake# while answer == range(2,6): Q1 #this lets the programme know which figures are acceptable# Q1 = input("enter length of room walls between 1 to 25 metres: ") #this the second question that is chosen# print (Q1) #This is again to let the client know what number they have inserted in case they have made an error while Q1 == range(1,25): Q2 #this is to let the programme know the numbers that are acceptable# Q2 = input("choose the price of paint that you want. Luxury = 175 Standard cost 100 Economy = 45 ALL PRICES MULTIPLIED BY 100 : ") #this is the final question that is asked# print (Q2) #this the final indication of what the client has inserted into the equasion# y = (int(answer) * int(Q1)* int(Q2)) #This tells the programme to multiply the numbers together# print (y/100 + 0.5) #this is because the programme only accepts whole numbers and to get the real value i needed to devide by 100 time.sleep(25) #problem with this programme is that it allows any number to be placed in the From airween at gmail.com Tue Oct 13 07:36:19 2015 From: airween at gmail.com (=?UTF-8?Q?Ervin_Heged=C3=BCs?=) Date: Tue, 13 Oct 2015 13:36:19 +0200 Subject: Extended functions in embedded code Message-ID: Hello there, I'm interesting for the embeding of Python code - the examples and docs are very helpfully. The main code, which embeds the Python interpreter, had written in C. There are several functions, what I have to use in embedded (Python) code, so I must to write them as Python extension. That's no problem - I found a solution for that, I don't need to made (and I don't _want_) a separated .so file (a new Python module): the extension in same C source, where the embedded code exists, like this: #include #include /* python mymodule */ static PyObject* mymodule_usleep(PyObject *self, PyObject *args) { ... } ... static PyMethodDef mymodule_methods[] = { {"usleep", mymodule_usleep, METH_VARARGS, mymodule_usleep_doc}, {NULL, NULL} }; PyMODINIT_FUNC initmymodule(void) { (void) Py_InitModule("mymodule", mymodule_methods); } /* python mymodule */ /* python embedding */ void foo() { Py_Initialize(); initmymodule(); .... Py_Finalize(); } /* python embedding */ Then I have a Python file, which the code above calls: import mymodule def bar(d) do_something() mymodule.usleep(10000) return something Just my "2 cents" question: is there any way to make the extension without "import" keyword? Or is there a way to leave that? Thanks, a. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bc at freeuk.com Tue Oct 13 08:31:56 2015 From: bc at freeuk.com (Bartc) Date: Tue, 13 Oct 2015 13:31:56 +0100 Subject: Strong typing implementation for Python In-Reply-To: <87h9lvrqx3.fsf@elektro.pacujo.net> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> <561C5FFD.1090006@gmail.com> <87h9lvrqx3.fsf@elektro.pacujo.net> Message-ID: On 13/10/2015 11:42, Marko Rauhamaa wrote: > A few years back I programmed in Java. I literally had to write (or > generate) 2,000 lines of code to satisfy the structural requirements > (interfaces, method stubs, javadocs, ...) before the code actually did > anything. And this is the recommended language if you want to code apps for Android. (Actually I don't think it's that easy to use another language of your choice.) Who decides these things? -- Bartc From lac at openend.se Tue Oct 13 08:51:21 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 13 Oct 2015 14:51:21 +0200 Subject: Extended functions in embedded code In-Reply-To: References: Message-ID: <201510131251.t9DCpLhs024862@fido.openend.se> Are you looking for this:? https://docs.python.org/3.5/library/runpy.html or maybe this:? https://docs.python.org/3.5/library/importlib.html#importlib.import_module Or is your real problem 'I don't have a filesystem'? Laura From lac at openend.se Tue Oct 13 08:54:21 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 13 Oct 2015 14:54:21 +0200 Subject: Strong typing implementation for Python In-Reply-To: References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> <561C5FFD.1090006@gmail.com> <87h9lvrqx3.fsf@elektro.pacujo.net> Message-ID: <201510131254.t9DCsLae025093@fido.openend.se> In a message of Tue, 13 Oct 2015 13:31:56 +0100, Bartc writes: >On 13/10/2015 11:42, Marko Rauhamaa wrote: > >> A few years back I programmed in Java. I literally had to write (or >> generate) 2,000 lines of code to satisfy the structural requirements >> (interfaces, method stubs, javadocs, ...) before the code actually did >> anything. > >And this is the recommended language if you want to code apps for >Android. (Actually I don't think it's that easy to use another language >of your choice.) > >Who decides these things? >-- >Bartc Start using kivy and vote with your feet! http://kivy.org/#home Laura From steve at pearwood.info Tue Oct 13 09:40:21 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 14 Oct 2015 00:40:21 +1100 Subject: Strong typing implementation for Python References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: <561d09c6$0$1585$c3e8da3$5496439d@news.astraweb.com> On Tue, 13 Oct 2015 06:55 pm, Todd wrote: > On Oct 13, 2015 2:11 AM, "Steven D'Aprano" wrote: >> Consider the following piece of code: >> >> def addone(x): >> return x + 1 >> >> >> The human programmer reading that can trivially infer that x must be a >> number (or at least something which supports numeric addition). So can >> the compiler. In a strongly typed language with no numeric promotion, the >> compiler can infer that x must be an int. In a language with numeric >> promotion, it can infer that x must be an int or float. > > Or a decimal, complex number, numpy array, any one of a dozen or so pandas > classes, any one of the dozen or so units classes, sympy variable, etc... I knew my over-simplification would get me in trouble... Firstly, if we're talking about Python specifically, the compiler won't actually infer anything (see PEP 484, which "assumes the existence of a separate off-line type checker which users can run over their source code voluntarily"). It is up to the external type checker (or linter, IDE, documentation generator, refactoring tool, etc) to perform any type checks. Secondly, what the tool actually infers will depend on the tool. I would expect that a basic type checker (say, in a text editor) will infer that x is an int or float only. A more powerful checker might infer the Number ABC (Abstract Base Class). A specialist checker might even know about numpy, pandas, units and sympy, but I wouldn't expect a general-purpose type checker to infer them. If the programmer cares about such specialist types, then she can easily add type hints to supplement the checker's type inference, or the checker itself may be configurable. That's a *quality of implementation* detail. The beauty of *gradual typing* is that you don't have to care about every possible class in the entire universe of Python code, only about the classes you actually care about in the parts of your code you choose to type check. http://wphomes.soic.indiana.edu/jsiek/what-is-gradual-typing/ Because the Python interpreter itself doesn't care about the compile-time type checking, if the checker gets in your way, you can just *not run it*. I also expect that good checkers will include directives to skip sections of code, so you can include annotations as documentation while still silencing over-strict or incorrect compile-time type errors. (Runtime type errors will still occur as normal.) -- Steven From steve at pearwood.info Tue Oct 13 09:43:54 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 14 Oct 2015 00:43:54 +1100 Subject: Strict comparisons in Python 2 Message-ID: <561d0a9a$0$1585$c3e8da3$5496439d@news.astraweb.com> In Python 3, comparisons between arbitrary types raise TypeError: py> None < 2 Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: NoneType() < int() In Python 2, that same comparison will arbitrarily return True or False, according to some implementation-dependent rule. Is there some way to force the Python 3 rules into Python 2? Something like a __future__ import? -- Steven From ian.g.kelly at gmail.com Tue Oct 13 09:58:27 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 13 Oct 2015 07:58:27 -0600 Subject: Strict comparisons in Python 2 In-Reply-To: <561d0a9a$0$1585$c3e8da3$5496439d@news.astraweb.com> References: <561d0a9a$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Oct 13, 2015 7:48 AM, "Steven D'Aprano" wrote: > > In Python 3, comparisons between arbitrary types raise TypeError: > > py> None < 2 > Traceback (most recent call last): > File "", line 1, in > TypeError: unorderable types: NoneType() < int() > > > In Python 2, that same comparison will arbitrarily return True or False, > according to some implementation-dependent rule. > > Is there some way to force the Python 3 rules into Python 2? Something like > a __future__ import? You couldn't do this with a __future__ import because those must be confined to the importing module and are therefore generally limited to syntax changes. It may be a good candidate for the six library, but I don't see any existing support there for it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From airween at gmail.com Tue Oct 13 10:59:57 2015 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Tue, 13 Oct 2015 16:59:57 +0200 Subject: Extended functions in embedded code In-Reply-To: <201510131251.t9DCpLhs024862@fido.openend.se> References: <201510131251.t9DCpLhs024862@fido.openend.se> Message-ID: <20151013145957.GA26706@arxnet.hu> Hi, On Tue, Oct 13, 2015 at 02:51:21PM +0200, Laura Creighton wrote: > Are you looking for this:? > https://docs.python.org/3.5/library/runpy.html I think I'm not - I'm afraid, the runpy modul wasn't developed for me, for this reason. > or maybe this:? > https://docs.python.org/3.5/library/importlib.html#importlib.import_module I think this is just an "alias" of the standard import. > Or is your real problem 'I don't have a filesystem'? no, I have filesystem. I help to contribute a software, which had written in C. The configuration schema is very simple, there are several keywords, but not all required function could be configure with them. Python would be a good choice, but the users aren't programmers in most cases. I just don't want to start the documentation, that "Make a Python script like this: import mymodul ...." and nobody knows, why is it require, because there isn't any module with this name. As I wrote, that's just my 2-cents question, not a critical issue - it could be better to know, is it possible or not. That's all :) a. From rosuav at gmail.com Tue Oct 13 11:05:43 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 14 Oct 2015 02:05:43 +1100 Subject: Extended functions in embedded code In-Reply-To: <20151013145957.GA26706@arxnet.hu> References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> Message-ID: On Wed, Oct 14, 2015 at 1:59 AM, Ervin Heged?s wrote: > no, I have filesystem. I help to contribute a software, which had > written in C. The configuration schema is very simple, there are > several keywords, but not all required function could be > configure with them. Python would be a good choice, but the > users aren't programmers in most cases. I just don't want to > start the documentation, that > > "Make a Python script like this: > > import mymodul > > ...." > > and nobody knows, why is it require, because there isn't any > module with this name. Sounds to me like the easiest way would be to inject into the builtins. You should be able to import the builtins module from your C code, and then stuff some extra attributes into it; they'll be automatically available to the script, same as the "normal" built-in names like int, super, and ValueError. ChrisA From random832 at fastmail.com Tue Oct 13 11:24:08 2015 From: random832 at fastmail.com (Random832) Date: Tue, 13 Oct 2015 11:24:08 -0400 Subject: Strict comparisons in Python 2 References: <561d0a9a$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87bnc2vlk7.fsf@fastmail.com> Ian Kelly writes: > You couldn't do this with a __future__ import because those must be > confined to the importing module and are therefore generally limited > to syntax changes. In principle, it could be a syntax change to the < operator (etc) to cause it to try to call a different method first, same as division and the / operator. That'd be a bit heavyweight to do this late in the Python 2 cycle though. What might be nice would be a general way to pass in lexical context information to the methods called to implement operators. > It may be a good candidate for the six library, but > I don't see any existing support there for it. From airween at gmail.com Tue Oct 13 11:29:46 2015 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Tue, 13 Oct 2015 17:29:46 +0200 Subject: Extended functions in embedded code In-Reply-To: References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> Message-ID: <20151013152946.GA27067@arxnet.hu> Hi Chris, On Wed, Oct 14, 2015 at 02:05:43AM +1100, Chris Angelico wrote: > On Wed, Oct 14, 2015 at 1:59 AM, Ervin Heged?s wrote: > > no, I have filesystem. I help to contribute a software, which had > > written in C. The configuration schema is very simple, there are > > several keywords, but not all required function could be > > configure with them. Python would be a good choice, but the > > users aren't programmers in most cases. I just don't want to > > start the documentation, that > > > > "Make a Python script like this: > > > > import mymodul > > > > ...." > > > > and nobody knows, why is it require, because there isn't any > > module with this name. > > Sounds to me like the easiest way would be to inject into the > builtins. You should be able to import the builtins module from your C > code, and then stuff some extra attributes into it; they'll be > automatically available to the script, same as the "normal" built-in > names like int, super, and ValueError. well, sounds good - this solution would be right for me. Could you show me a good example and/or documentation about this? I've looked up, but "python extend built-in module" is may be too simple expression :). a. From rosuav at gmail.com Tue Oct 13 11:48:57 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 14 Oct 2015 02:48:57 +1100 Subject: Extended functions in embedded code In-Reply-To: <20151013152946.GA27067@arxnet.hu> References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> <20151013152946.GA27067@arxnet.hu> Message-ID: On Wed, Oct 14, 2015 at 2:29 AM, Ervin Heged?s wrote: >> >> Sounds to me like the easiest way would be to inject into the >> builtins. You should be able to import the builtins module from your C >> code, and then stuff some extra attributes into it; they'll be >> automatically available to the script, same as the "normal" built-in >> names like int, super, and ValueError. > > well, sounds good - this solution would be right for me. Could > you show me a good example and/or documentation about this? I've > looked up, but "python extend built-in module" is may be too > simple expression :). It'd look broadly like this: /* initialize the interpreter, yada yada */ PyObject *builtins = PyImport_ImportModule("builtins"); PyModule_AddFunctions(builtins, mymodule_methods); instead of the current module initialization. You import the name 'builtins', stuff some extra stuff into it, and then go on your merry way. It should be reasonably easy. ChrisA From ian.g.kelly at gmail.com Tue Oct 13 11:51:37 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 13 Oct 2015 09:51:37 -0600 Subject: Strict comparisons in Python 2 In-Reply-To: <87bnc2vlk7.fsf@fastmail.com> References: <561d0a9a$0$1585$c3e8da3$5496439d@news.astraweb.com> <87bnc2vlk7.fsf@fastmail.com> Message-ID: On Tue, Oct 13, 2015 at 9:24 AM, Random832 wrote: > Ian Kelly writes: >> You couldn't do this with a __future__ import because those must be >> confined to the importing module and are therefore generally limited >> to syntax changes. > > In principle, it could be a syntax change to the < operator (etc) to > cause it to try to call a different method first, same as division and > the / operator. That'd be a bit heavyweight to do this late in the > Python 2 cycle though. And it also wouldn't change the behavior of list.sort. From emile at fenx.com Tue Oct 13 11:55:42 2015 From: emile at fenx.com (Emile van Sebille) Date: Tue, 13 Oct 2015 08:55:42 -0700 Subject: Extended functions in embedded code In-Reply-To: <20151013152946.GA27067@arxnet.hu> References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> <20151013152946.GA27067@arxnet.hu> Message-ID: On 10/13/2015 8:29 AM, Ervin Heged?s wrote: > Hi Chris, > > On Wed, Oct 14, 2015 at 02:05:43AM +1100, Chris Angelico wrote: >> Sounds to me like the easiest way would be to inject into the >> builtins. You should be able to import the builtins module from your C >> code, and then stuff some extra attributes into it; they'll be >> automatically available to the script, same as the "normal" built-in >> names like int, super, and ValueError. > > well, sounds good - this solution would be right for me. Could > you show me a good example and/or documentation about this? I've > looked up, but "python extend built-in module" is may be too > simple expression :). Maybe the site module helps you. See https://docs.python.org/3/library/site.html Emile From ivanjankovic at live.ca Tue Oct 13 11:59:09 2015 From: ivanjankovic at live.ca (jogaserbia) Date: Tue, 13 Oct 2015 08:59:09 -0700 (PDT) Subject: Some Help getting started In-Reply-To: <3acd60ee-d0ac-4986-bc99-75692d3b4094@googlegroups.com> References: <3acd60ee-d0ac-4986-bc99-75692d3b4094@googlegroups.com> Message-ID: <1386ad0b-b105-47a6-aafd-c04273d0a997@googlegroups.com> Hi Glenn, Welcome to the community and thank you for creating this module. It's great you want to get this going in Python (3?). A couple of things: 1) I looked at the github repo. You do not have anything to be deployed there. Actually, that repo has nothing to do with python as of yet, aside from the init and setup files. 2) What are you trying to achieve with the pip install -e? http://stackoverflow.com/questions/18068077/format-error-when-using-pip-install-e-from-github-value-of-using-egg http://pip.readthedocs.org/en/stable/reference/pip_install/#editable-installs I have never used the -e, so someone else might be able to chime in. Also, .egg is in your .gitignore file. 3) unless you have a particular reason for adding the .idea folder to be tracked, I would add it to git ignore. 4) If you want to comply with pep8, https://www.python.org/dev/peps/pep-0008/#package-and-module-names your module should be called bondlab or bond_lab if really necessary. For #1) I would add the folder for the actual module in there as bondlab or bond_lab. I prefer the former (in keeping with numpy, scipy, pandas naming conventions, but that is personal preference.) #2) I assume you are just looking to start using version control for your project. use the git clone if that is the case. #3 add the .idea folder to the gitignore #4) see #1 resolution I'll send a pull request with these changes if you like them. Ivan From ivanjankovic at live.ca Tue Oct 13 12:04:25 2015 From: ivanjankovic at live.ca (jogaserbia) Date: Tue, 13 Oct 2015 09:04:25 -0700 (PDT) Subject: Some Help getting started In-Reply-To: <1386ad0b-b105-47a6-aafd-c04273d0a997@googlegroups.com> References: <3acd60ee-d0ac-4986-bc99-75692d3b4094@googlegroups.com> <1386ad0b-b105-47a6-aafd-c04273d0a997@googlegroups.com> Message-ID: Forgot to mention. you might want to take a look at numpy and pandas for their structures. https://github.com/numpy/numpy https://github.com/pydata/pandas I always find it easier to look at something concrete. Ivan From nulla.epistola at web.de Tue Oct 13 14:51:34 2015 From: nulla.epistola at web.de (Sibylle Koczian) Date: Tue, 13 Oct 2015 20:51:34 +0200 Subject: Strong typing implementation for Python In-Reply-To: <85vbabu4ar.fsf@benfinney.id.au> References: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> <561BB867.9010504@web.de> <85vbabu4ar.fsf@benfinney.id.au> Message-ID: <561D52B6.5070902@web.de> Am 13.10.2015 um 00:10 schrieb Ben Finney: > Sibylle Koczian writes: > >> Am 12.10.2015 um 13:39 schrieb Steven D'Aprano: >>> Auto-complete is a fine and useful tool. But if you are crippled as a >>> programmer without it, well, then you can hardly claim to understand the >>> language or framework you are programming in if you cannot use it without >>> an IDE doing half the work for you. >>> >> >> Well ... you're certainly quite right as far as Python and its >> standard library is concerned. But I don't know who would really want >> to use .NET without auto-complete and for all I know Java may be just >> as awful. > > Yes, and that is quite compatible with Steven's assertion. The two > assertions: > > * A programmer who feels crippled without auto-complete cannot claim to > understand the language or framework they're programming in. > (assertion made by Steven) > > * The overwhelming majority of .NET and Java programmers would feel > crippled without auto-complete. (assertion made by Sibylle) > Not really wanting to do without x isn't the same as feeling crippled without it. > can both be true. An obvious resolution is to conclude that the > overwhelming majority of Java and .NET programmers cannot claim to > understand those technologies. > I don't think you can measure understanding by the ability and willingness (!) to type those overlong and yet similar names again and again in full. > Python, on the other hand, has the huge advantage that programming in > even a bare minimal editor is feasible, and editor features that make > the programmer's life easier are conveniences, not essential to be > competent in Python. > Only one of its huge advantages. As long as no GUI is necessary ... but that's another story. Sibylle From nulla.epistola at web.de Tue Oct 13 14:51:34 2015 From: nulla.epistola at web.de (Sibylle Koczian) Date: Tue, 13 Oct 2015 20:51:34 +0200 Subject: Strong typing implementation for Python In-Reply-To: <85vbabu4ar.fsf@benfinney.id.au> References: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> <561BB867.9010504@web.de> <85vbabu4ar.fsf@benfinney.id.au> Message-ID: <561D52B6.5070902@web.de> Am 13.10.2015 um 00:10 schrieb Ben Finney: > Sibylle Koczian writes: > >> Am 12.10.2015 um 13:39 schrieb Steven D'Aprano: >>> Auto-complete is a fine and useful tool. But if you are crippled as a >>> programmer without it, well, then you can hardly claim to understand the >>> language or framework you are programming in if you cannot use it without >>> an IDE doing half the work for you. >>> >> >> Well ... you're certainly quite right as far as Python and its >> standard library is concerned. But I don't know who would really want >> to use .NET without auto-complete and for all I know Java may be just >> as awful. > > Yes, and that is quite compatible with Steven's assertion. The two > assertions: > > * A programmer who feels crippled without auto-complete cannot claim to > understand the language or framework they're programming in. > (assertion made by Steven) > > * The overwhelming majority of .NET and Java programmers would feel > crippled without auto-complete. (assertion made by Sibylle) > Not really wanting to do without x isn't the same as feeling crippled without it. > can both be true. An obvious resolution is to conclude that the > overwhelming majority of Java and .NET programmers cannot claim to > understand those technologies. > I don't think you can measure understanding by the ability and willingness (!) to type those overlong and yet similar names again and again in full. > Python, on the other hand, has the huge advantage that programming in > even a bare minimal editor is feasible, and editor features that make > the programmer's life easier are conveniences, not essential to be > competent in Python. > Only one of its huge advantages. As long as no GUI is necessary ... but that's another story. Sibylle From paul.hermeneutic at gmail.com Tue Oct 13 15:28:29 2015 From: paul.hermeneutic at gmail.com (paul.hermeneutic at gmail.com) Date: Tue, 13 Oct 2015 13:28:29 -0600 Subject: request In-Reply-To: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> References: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> Message-ID: On Oct 13, 2015 1:16 PM, "Uday Pethakamsetty" wrote: > The problem is that when I installed python 3.5, all the pip installs are directing to python 3.5, instead of my native python 2.7. > Probably, this is because the Python 3 directories appears first in the PATH variable. Python 3 has venv. I always use venv and never put Python in the PATH variable. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mtcarrick at alaska.edu Tue Oct 13 15:31:43 2015 From: mtcarrick at alaska.edu (Mathew Carrick) Date: Tue, 13 Oct 2015 11:31:43 -0800 Subject: request In-Reply-To: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> References: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> Message-ID: Hi Uday, Pip should support using the pip{version} command to install version-specific packages. Try using pip2.7 to install 2.7 packages. Best, Mathew Carrick On Tue, Oct 13, 2015 at 2:45 AM, Uday Pethakamsetty < Uday.Pethakamsetty at infor.com> wrote: > Hi > > > > I am working on python 2.x for long time. > > > > I thought of testing python 3.5 for possible usage. > > > > The problem is that when I installed python 3.5, all the pip installs are > directing to python 3.5, instead of my native python 2.7. > > > > I heard of a feature called pylauancher; but I didn?t find any satisfying > documentation on it. > > > > Either pylauncer, or something else Solution?could you help reply the > possible solution to work comfortably on either versions, without > interfering, in my windows 64 bit machine. > > > > > > Thanks & regards > > > > Udhay Prakash > > -- > https://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Tue Oct 13 16:18:21 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 13 Oct 2015 22:18:21 +0200 Subject: request In-Reply-To: References: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> Message-ID: <201510132018.t9DKIL4f024693@fido.openend.se> In a message of Tue, 13 Oct 2015 13:28:29 -0600, paul.hermeneutic at gmail.com wri tes: >On Oct 13, 2015 1:16 PM, "Uday Pethakamsetty" >wrote: > >> The problem is that when I installed python 3.5, all the pip installs are >directing to python 3.5, instead of my native python 2.7. >> > >Probably, this is because the Python 3 directories appears first in the >PATH variable. > >Python 3 has venv. I always use venv and never put Python in the PATH >variable. > >-- >https://mail.python.org/mailman/listinfo/python-list Then you must only be using different Python 3 versions, because venv won't make you a Python 2.7. virtualenv will, though. pip2.7 will get your pip installs to 2.7. Laura From airween at gmail.com Tue Oct 13 16:28:54 2015 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Tue, 13 Oct 2015 22:28:54 +0200 Subject: Extended functions in embedded code In-Reply-To: References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> <20151013152946.GA27067@arxnet.hu> Message-ID: <20151013202854.GA1526@arxnet.hu> Hi Chris, what I misses: currently I'm using Python 2.7. On Wed, Oct 14, 2015 at 02:48:57AM +1100, Chris Angelico wrote: > On Wed, Oct 14, 2015 at 2:29 AM, Ervin Heged?s wrote: > >> > >> Sounds to me like the easiest way would be to inject into the > >> builtins. You should be able to import the builtins module from your C > >> code, and then stuff some extra attributes into it; they'll be > >> automatically available to the script, same as the "normal" built-in > >> names like int, super, and ValueError. > > > > well, sounds good - this solution would be right for me. Could > > you show me a good example and/or documentation about this? I've > > looked up, but "python extend built-in module" is may be too > > simple expression :). > > It'd look broadly like this: > > /* initialize the interpreter, yada yada */ > PyObject *builtins = PyImport_ImportModule("builtins"); > PyModule_AddFunctions(builtins, mymodule_methods); PyModule_AddFunction was introduced in Python 3.5. Most of stable Linux distribution has Python 3.4 > instead of the current module initialization. You import the name > 'builtins', stuff some extra stuff into it, and then go on your merry > way. It should be reasonably easy. Is there any other solution to add functions to builtins? Thanks, a. -- I ? UTF-8 From airween at gmail.com Tue Oct 13 16:32:59 2015 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Tue, 13 Oct 2015 22:32:59 +0200 Subject: Extended functions in embedded code In-Reply-To: References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> <20151013152946.GA27067@arxnet.hu> Message-ID: <20151013203259.GB1526@arxnet.hu> Hi, On Tue, Oct 13, 2015 at 08:55:42AM -0700, Emile van Sebille wrote: > On 10/13/2015 8:29 AM, Ervin Heged?s wrote: > >Hi Chris, > > > >On Wed, Oct 14, 2015 at 02:05:43AM +1100, Chris Angelico wrote: > > >>Sounds to me like the easiest way would be to inject into the > >>builtins. You should be able to import the builtins module from your C > >>code, and then stuff some extra attributes into it; they'll be > >>automatically available to the script, same as the "normal" built-in > >>names like int, super, and ValueError. > > > >well, sounds good - this solution would be right for me. Could > >you show me a good example and/or documentation about this? I've > >looked up, but "python extend built-in module" is may be too > >simple expression :). > > Maybe the site module helps you. See > https://docs.python.org/3/library/site.html no, I think this module is totally different, what I need. thanks, a. -- I ? UTF-8 From emile at fenx.com Tue Oct 13 16:59:23 2015 From: emile at fenx.com (Emile van Sebille) Date: Tue, 13 Oct 2015 13:59:23 -0700 Subject: Extended functions in embedded code In-Reply-To: <20151013203259.GB1526@arxnet.hu> References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> <20151013152946.GA27067@arxnet.hu> <20151013203259.GB1526@arxnet.hu> Message-ID: On 10/13/2015 1:32 PM, Ervin Heged?s wrote: > Hi, > > On Tue, Oct 13, 2015 at 08:55:42AM -0700, Emile van Sebille wrote: >> On 10/13/2015 8:29 AM, Ervin Heged?s wrote: >>> Hi Chris, >>> >>> On Wed, Oct 14, 2015 at 02:05:43AM +1100, Chris Angelico wrote: >> >>>> Sounds to me like the easiest way would be to inject into the >>>> builtins. You should be able to import the builtins module from your C >>>> code, and then stuff some extra attributes into it; they'll be >>>> automatically available to the script, same as the "normal" built-in >>>> names like int, super, and ValueError. >>> >>> well, sounds good - this solution would be right for me. Could >>> you show me a good example and/or documentation about this? I've >>> looked up, but "python extend built-in module" is may be too >>> simple expression :). >> >> Maybe the site module helps you. See >> https://docs.python.org/3/library/site.html > > no, I think this module is totally different, what I need. > or perhaps http://stackoverflow.com/questions/8608587/finding-the-source-code-for-built-in-python-functions Emile From lac at openend.se Tue Oct 13 18:02:36 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 14 Oct 2015 00:02:36 +0200 Subject: Extended functions in embedded code In-Reply-To: <20151013202854.GA1526@arxnet.hu> References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> <20151013152946.GA27067@arxnet.hu> <20151013202854.GA1526@arxnet.hu> Message-ID: <201510132202.t9DM2a5M032292@fido.openend.se> In a message of Tue, 13 Oct 2015 22:28:54 +0200, Ervin Heged?s writes: >Hi Chris, > >what I misses: currently I'm using Python 2.7. > >On Wed, Oct 14, 2015 at 02:48:57AM +1100, Chris Angelico wrote: >> On Wed, Oct 14, 2015 at 2:29 AM, Ervin Heged?s wrote: >> >> >> >> Sounds to me like the easiest way would be to inject into the >> >> builtins. You should be able to import the builtins module from your C >> >> code, and then stuff some extra attributes into it; they'll be >> >> automatically available to the script, same as the "normal" built-in >> >> names like int, super, and ValueError. >> > >> > well, sounds good - this solution would be right for me. Could >> > you show me a good example and/or documentation about this? I've >> > looked up, but "python extend built-in module" is may be too >> > simple expression :). >> >> It'd look broadly like this: >> >> /* initialize the interpreter, yada yada */ >> PyObject *builtins = PyImport_ImportModule("builtins"); >> PyModule_AddFunctions(builtins, mymodule_methods); > >PyModule_AddFunction was introduced in Python 3.5. Most of stable >Linux distribution has Python 3.4 > >> instead of the current module initialization. You import the name >> 'builtins', stuff some extra stuff into it, and then go on your merry >> way. It should be reasonably easy. > >Is there any other solution to add functions to builtins? > > >Thanks, > >a. You can stuff things into the __dict__ of __builtin__ if you like. It's highly frowned upon. But see discussion attatched to: http://code.activestate.com/recipes/577888-see-what-the-builtins-are/ Laura From greg.ewing at canterbury.ac.nz Tue Oct 13 18:10:21 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 14 Oct 2015 11:10:21 +1300 Subject: Strong typing implementation for Python In-Reply-To: References: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> <561BB867.9010504@web.de> Message-ID: Ben Finney wrote: > * The overwhelming majority of .NET and Java programmers would feel > crippled without auto-complete. (assertion made by Sibylle) > > An obvious resolution is to conclude that the > overwhelming majority of Java and .NET programmers cannot claim to > understand those technologies. As a data point, I've been doing some fairly intensive Java programming recently, and doing it in a very plain text editor with no auto-completion at all. While I do make a lot of use of docs during the process, it's not so much to find out how a name is spelled, but for higher-level things like which methods a class has, or even which class I should be using in the first place, and how to go about using it. Also, once I've got the information needed for a particular session paged into my brain, it usually stays there at least for the rest of the session, so I'm not having to constantly consult the docs for every little thing. So at least for me, it *is* possible to be productive in Java without special editor support. In Python it's even easier, due to the general smallness and consistency of everything. -- Greg From greg.ewing at canterbury.ac.nz Tue Oct 13 18:16:32 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 14 Oct 2015 11:16:32 +1300 Subject: Strong typing implementation for Python In-Reply-To: References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> Message-ID: Bartc wrote: > I've surprised Basic needs it. The last time I looked, $A was a string, > %B an integer, and C a number. A$ and B%, actually. Although if you didn't like the type suffixes, you could say DEFINT I-N and pretend you were writing Fortran code. :-) -- Greg From greg.ewing at canterbury.ac.nz Tue Oct 13 18:27:02 2015 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 14 Oct 2015 11:27:02 +1300 Subject: Strong typing implementation for Python In-Reply-To: <561cbac9$0$27520$65785112@news.neostrada.pl> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> <561cbac9$0$27520$65785112@news.neostrada.pl> Message-ID: m wrote: > W dniu 13.10.2015 o 03:35, Michael Torrie pisze: > >>Well in Java code for one. No wonder they require auto-completion. >>Java class-based namespaces must be a nightmare to work with. > > IMHO mainly because their naming convention. They just love typing long > names. The biggest verbosity problems in Java stem from the inability to define short aliases for fully-qualified class names and complicated type expressions. Ever since generic types were added, omitting such a feature has been obviously insane, yet somehow nothing has been done about it. -- Greg From josef.pktd at gmail.com Tue Oct 13 19:25:31 2015 From: josef.pktd at gmail.com (Josef Pktd) Date: Tue, 13 Oct 2015 16:25:31 -0700 (PDT) Subject: Strong typing implementation for Python In-Reply-To: References: <561b9bd8$0$1586$c3e8da3$5496439d@news.astraweb.com> <561BB867.9010504@web.de> <85vbabu4ar.fsf@benfinney.id.au> Message-ID: <1238d7c3-d3a1-4d18-be5e-815fad762c32@googlegroups.com> On Tuesday, October 13, 2015 at 2:52:32 PM UTC-4, Sibylle Koczian wrote: > Am 13.10.2015 um 00:10 schrieb Ben Finney: > > Sibylle Koczian <> writes: > > > >> Am 12.10.2015 um 13:39 schrieb Steven D'Aprano: > >>> Auto-complete is a fine and useful tool. But if you are crippled as a > >>> programmer without it, well, then you can hardly claim to understand the > >>> language or framework you are programming in if you cannot use it without > >>> an IDE doing half the work for you. > >>> > >> > >> Well ... you're certainly quite right as far as Python and its > >> standard library is concerned. But I don't know who would really want > >> to use .NET without auto-complete and for all I know Java may be just > >> as awful. > > > > Yes, and that is quite compatible with Steven's assertion. The two > > assertions: > > > > * A programmer who feels crippled without auto-complete cannot claim to > > understand the language or framework they're programming in. > > (assertion made by Steven) > > > > * The overwhelming majority of .NET and Java programmers would feel > > crippled without auto-complete. (assertion made by Sibylle) > > > Not really wanting to do without x isn't the same as feeling crippled > without it. To support this I have been writing numpy/scipy based code in python for many years, and still I make a lot more mistakes without autocompletion and having pyflakes or similar run in the editor in the background. I know roughly where everything is in a large class hierarchy with more information hidden in attached classes (instances). But it's easy to figure out the details with code completion and standard inspection. It works pretty well maybe 90 % of the time (except in chained expressions). I also memorize only the main arguments in the signatures, and rely for the rest on the pop-up hints. > > > can both be true. An obvious resolution is to conclude that the > > overwhelming majority of Java and .NET programmers cannot claim to > > understand those technologies. > > > I don't think you can measure understanding by the ability and > willingness (!) to type those overlong and yet similar names again and > again in full. > > > Python, on the other hand, has the huge advantage that programming in > > even a bare minimal editor is feasible, and editor features that make > > the programmer's life easier are conveniences, not essential to be > > competent in Python. > > > Only one of its huge advantages. As long as no GUI is necessary ... but > that's another story. I don't know about GUI programming, but even though it's not part of the language there are packages for example for asserting and maintaining types and restriction on values like traits and traitlets. Josef > > Sibylle From rosuav at gmail.com Tue Oct 13 19:30:12 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 14 Oct 2015 10:30:12 +1100 Subject: Extended functions in embedded code In-Reply-To: <20151013202854.GA1526@arxnet.hu> References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> <20151013152946.GA27067@arxnet.hu> <20151013202854.GA1526@arxnet.hu> Message-ID: On Wed, Oct 14, 2015 at 7:28 AM, Ervin Heged?s wrote: > Hi Chris, > > what I misses: currently I'm using Python 2.7. Oh, sorry. In that case, you'll be importing "__builtin__" rather than "builtins", but the same technique works. > On Wed, Oct 14, 2015 at 02:48:57AM +1100, Chris Angelico wrote: >> It'd look broadly like this: >> >> /* initialize the interpreter, yada yada */ >> PyObject *builtins = PyImport_ImportModule("builtins"); >> PyModule_AddFunctions(builtins, mymodule_methods); > > PyModule_AddFunction was introduced in Python 3.5. Most of stable > Linux distribution has Python 3.4 It's been years since I actually did this, so I cheated and just flipped through the docs :) But there'll be a way to create a Python function from a C function, and then you can simply stuff that into the module's dictionary. ChrisA From josef.pktd at gmail.com Tue Oct 13 20:26:02 2015 From: josef.pktd at gmail.com (Josef Pktd) Date: Tue, 13 Oct 2015 17:26:02 -0700 (PDT) Subject: Strong typing implementation for Python In-Reply-To: <561d09c6$0$1585$c3e8da3$5496439d@news.astraweb.com> References: <561b0025$0$1608$c3e8da3$5496439d@news.astraweb.com> <87wpusovex.fsf@elektro.pacujo.net> <561c4b4a$0$1585$c3e8da3$5496439d@news.astraweb.com> <561d09c6$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: <610edc94-10c2-4a17-b112-f12ca1d9ba79@googlegroups.com> On Tuesday, October 13, 2015 at 9:40:56 AM UTC-4, Steven D'Aprano wrote: > On Tue, 13 Oct 2015 06:55 pm, Todd wrote: > > > On Oct 13, 2015 2:11 AM, "Steven D'Aprano" <...> wrote: > > >> Consider the following piece of code: > >> > >> def addone(x): > >> return x + 1 > >> > >> > >> The human programmer reading that can trivially infer that x must be a > >> number (or at least something which supports numeric addition). So can > >> the compiler. In a strongly typed language with no numeric promotion, the > >> compiler can infer that x must be an int. In a language with numeric > >> promotion, it can infer that x must be an int or float. > > > > Or a decimal, complex number, numpy array, any one of a dozen or so pandas > > classes, any one of the dozen or so units classes, sympy variable, etc... A good example is `y = x * 2` followed by long calculations with y. I have no idea what this does if I don't know the type of x. (list and tuples get duplicated, arrays as in numpy or pandas multiply elementwise, matrix packages use dot (@) product. Two out of three will give us the wrong result but don't raise a runtime exception.) The flip side of the flexibility with dynamic typing is that we spend a lot of time and effort in asserting or converting types. There are cases when being able to quack is not enough, it needs to have the right quack. And when we allow for different sounds created by the duck look-a-likes, then code can get complicated and avoiding subtle mistakes will become very difficult. Annotations might help the editors, but doesn't enforce the right behavior. Also, in some cases we don't want to restrict ducktyping in the function or method arguments but we need to protect our calculations. Function annotations won't help her. One common pattern then guarantees fixed types within a function: def calculate_something(x): x = numpy.asarray(x, numpy.float64) # convert anything array_like to array do calculations that only use numpy arrays return result In the center we have static types (as far as numpy arrays are static), and we don't have to guess on what methods are actually doing, and code inspection could infer this. Outside we still have all the flexibility of duck typing. I guess it's gradual typing but not through unenforced function annotations. Josef > > I knew my over-simplification would get me in trouble... > > Firstly, if we're talking about Python specifically, the compiler won't > actually infer anything (see PEP 484, which "assumes the existence of a > separate off-line type checker which users can run over their source code > voluntarily"). It is up to the external type checker (or linter, IDE, > documentation generator, refactoring tool, etc) to perform any type checks. > > Secondly, what the tool actually infers will depend on the tool. I would > expect that a basic type checker (say, in a text editor) will infer that x > is an int or float only. A more powerful checker might infer the Number ABC > (Abstract Base Class). A specialist checker might even know about numpy, > pandas, units and sympy, but I wouldn't expect a general-purpose type > checker to infer them. > > If the programmer cares about such specialist types, then she can easily add > type hints to supplement the checker's type inference, or the checker > itself may be configurable. That's a *quality of implementation* detail. > > The beauty of *gradual typing* is that you don't have to care about every > possible class in the entire universe of Python code, only about the > classes you actually care about in the parts of your code you choose to > type check. > > http://wphomes.soic.indiana.edu/jsiek/what-is-gradual-typing/ > > Because the Python interpreter itself doesn't care about the compile-time > type checking, if the checker gets in your way, you can just *not run it*. > I also expect that good checkers will include directives to skip sections > of code, so you can include annotations as documentation while still > silencing over-strict or incorrect compile-time type errors. (Runtime type > errors will still occur as normal.) > > > > -- > Steven From tjreedy at udel.edu Tue Oct 13 22:38:13 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 13 Oct 2015 22:38:13 -0400 Subject: Strict comparisons in Python 2 In-Reply-To: <561d0a9a$0$1585$c3e8da3$5496439d@news.astraweb.com> References: <561d0a9a$0$1585$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 10/13/2015 9:43 AM, Steven D'Aprano wrote: > In Python 3, comparisons between arbitrary types raise TypeError: > > py> None < 2 > Traceback (most recent call last): > File "", line 1, in > TypeError: unorderable types: NoneType() < int() > > > In Python 2, that same comparison will arbitrarily return True or False, > according to some implementation-dependent rule. > > Is there some way to force the Python 3 rules into Python 2? Something like > a __future__ import? Not what you want, but ... 1. Only compare instances of classes with rich comparison methods that act as in Py 3, subsetting or wrapping builtins as needed. 2. Replace binary operation such as `None < 2` with a. Conditional expression: None < 2 if compatible(a, b, comp) else None where compatible returns True for py3, True or TypeError for py2 b. Generic comparison function compare(a, b, comp): if compatible(a, b, comp): if comp = 'lt': return a < b c. Specific comparison functon, such as lt(a, b). I think a 2&3 package should have something like 2c, but I don't know any particulars. -- Terry Jan Reedy From laverdure02 at gmail.com Tue Oct 13 23:03:31 2015 From: laverdure02 at gmail.com (laverdure02 at gmail.com) Date: Wed, 14 Oct 2015 03:03:31 +0000 Subject: =?utf-8?Q?Error_see_image?= Message-ID: <5a8cbc299df74f4eb76a36a75b29d428@gmail.com> hello I have this error while trying to re-install the program and it?s still show can you please help me ? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot 2015-10-13 23.03.09.png Type: image/png Size: 56216 bytes Desc: Screenshot 2015-10-13 23.03.09.png URL: From zachary.ware+pylist at gmail.com Tue Oct 13 23:47:45 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Tue, 13 Oct 2015 22:47:45 -0500 Subject: request In-Reply-To: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> References: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> Message-ID: On Tue, Oct 13, 2015 at 5:45 AM, Uday Pethakamsetty wrote: > Hi > > I am working on python 2.x for long time. > > I thought of testing python 3.5 for possible usage. > > The problem is that when I installed python 3.5, all the pip installs are > directing to python 3.5, instead of my native python 2.7. > > I heard of a feature called pylauancher; but I didn?t find any satisfying > documentation on it. > > Either pylauncer, or something else Solution?could you help reply the > possible solution to work comfortably on either versions, without > interfering, in my windows 64 bit machine. The Python Launcher for Windows is installed by default with Python 3.3+. It should be on your PATH, and is called 'py.exe'. It will launch any Python it can find in the registry, including Python 2.7. To use it to install something to the global Python 2.7 site-packages, do `py -2.7 -m pip install `. Hope this helps, -- Zach From dieter at handshake.de Wed Oct 14 01:58:04 2015 From: dieter at handshake.de (dieter) Date: Wed, 14 Oct 2015 07:58:04 +0200 Subject: [mdione@grulic.org.ar: modifying locals] References: <20151012072738.GH2798@diablo.grulicueva.local> Message-ID: <87pp0iat5f.fsf@handshake.de> Marcos Dione writes: > ... > My problem is modifying the > locals ... In Python 2.7, I succeeded with the following code: >>> def f(): ... x = 1 ... exec('x=2') ... return x ... >>> f() 2 From airween at gmail.com Wed Oct 14 02:11:44 2015 From: airween at gmail.com (Ervin =?utf-8?Q?Heged=C3=BCs?=) Date: Wed, 14 Oct 2015 08:11:44 +0200 Subject: Extended functions in embedded code In-Reply-To: <201510132202.t9DM2a5M032292@fido.openend.se> References: <201510131251.t9DCpLhs024862@fido.openend.se> <20151013145957.GA26706@arxnet.hu> <20151013152946.GA27067@arxnet.hu> <20151013202854.GA1526@arxnet.hu> <201510132202.t9DM2a5M032292@fido.openend.se> Message-ID: <20151014061144.GB28910@arxnet.hu> On Wed, Oct 14, 2015 at 12:02:36AM +0200, Laura Creighton wrote: > In a message of Tue, 13 Oct 2015 22:28:54 +0200, Ervin Heged?s writes: > >Hi Chris, > > > >what I misses: currently I'm using Python 2.7. > > > >On Wed, Oct 14, 2015 at 02:48:57AM +1100, Chris Angelico wrote: [...] > > > >PyModule_AddFunction was introduced in Python 3.5. Most of stable > >Linux distribution has Python 3.4 > > > >> instead of the current module initialization. You import the name > >> 'builtins', stuff some extra stuff into it, and then go on your merry > >> way. It should be reasonably easy. > > > >Is there any other solution to add functions to builtins? > > > > You can stuff things into the __dict__ of __builtin__ if you like. > It's highly frowned upon. > But see discussion attatched to: > http://code.activestate.com/recipes/577888-see-what-the-builtins-are/ As I understand this, it shows the Python's builtins (or __builtins__) capabilities. As Chris wrote, the soultion would be, that I'm loading the __builtins__ module in C (through API), and add/extend its __dict__ with my funtions. The link above doesn't help me in this :). Thanks, a. From uday3prakash at gmail.com Wed Oct 14 02:23:27 2015 From: uday3prakash at gmail.com (udhay prakash pethakamsetty) Date: Wed, 14 Oct 2015 11:53:27 +0530 Subject: request In-Reply-To: References: <0388041CB96250438BB9E9A905B92648B207F2@INHYWEXMBX1.infor.com> Message-ID: Yes! it is working, and do you have any idea about pylauncher. If possible, could you brief something about it. *UDHAY PRAKASH* Ph:+91-9533787794 udhayprakash.blogspot.com On Wed, Oct 14, 2015 at 1:01 AM, Mathew Carrick wrote: > Hi Uday, > > Pip should support using the pip{version} command to install > version-specific packages. Try using pip2.7 to install 2.7 packages. > > Best, > Mathew Carrick > > On Tue, Oct 13, 2015 at 2:45 AM, Uday Pethakamsetty < > Uday.Pethakamsetty at infor.com> wrote: > >> Hi >> >> >> >> I am working on python 2.x for long time. >> >> >> >> I thought of testing python 3.5 for possible usage. >> >> >> >> The problem is that when I installed python 3.5, all the pip installs are >> directing to python 3.5, instead of my native python 2.7. >> >> >> >> I heard of a feature called pylauancher; but I didn?t find any satisfying >> documentation on it. >> >> >> >> Either pylauncer, or something else Solution?could you help reply the >> possible solution to work comfortably on either versions, without >> interfering, in my windows 64 bit machine. >> >> >> >> >> >> Thanks & regards >> >> >> >> Udhay Prakash >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Wed Oct 14 03:40:44 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 14 Oct 2015 09:40:44 +0200 Subject: =?utf-8?Q?Error_see_image?= In-Reply-To: <5a8cbc299df74f4eb76a36a75b29d428@gmail.com> References: <5a8cbc299df74f4eb76a36a75b29d428@gmail.com> Message-ID: <201510140740.t9E7eiGD010077@fido.openend.se> In a message of Wed, 14 Oct 2015 03:03:31 -0000, laverdure02 at gmail.com writes: >hello I have this error >while trying to re-install the program and it?s still show >can you please help me ? 1. If you are running XP, you cannot run 3.5. XP is not supported. 2. Otherwise The api-ms-win-crt-runtime-l1-1-0-dll is Microsofts Universal CRT. Get it here http://www.microsoft.com/en-us/download/details.aspx?id=48234 and try again. Laura From newsleecher at spam.com Wed Oct 14 05:55:45 2015 From: newsleecher at spam.com (NewsLeecher User) Date: Wed, 14 Oct 2015 09:55:45 GMT Subject: Python for Dummies exaple Message-ID: Hello, I have the book Python for Dummies and i downloaden from the Dummiesite some python examples. But with this script i get an error: But i have not so many experience to see what the error is. Good someone help me with this ? #Chapter 3 #Basic Elements and Syntax #===== #SHORT EXAMPLES #===== #while loop example countdown = 10 while countdown: print countdown, countdown -= 1 print "blastoff!" # # #try statement with input user_input = raw_input("Enter an integer: ") try: number = int(user_input) print "You entered", number except ValueError: print "Integers, please!" #class example class SayMyName: def __init__(self, myname): self.myname = myname def say(self): print "Hello, my name is", self.myname name1 = SayMyName("Aahz") name1.say() # # -- --------------------------------- --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From rosuav at gmail.com Wed Oct 14 06:04:05 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 14 Oct 2015 21:04:05 +1100 Subject: Python for Dummies exaple In-Reply-To: References: Message-ID: On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User wrote: > But with this script i get an error: > But i have not so many experience to see what the error is. > Good someone help me with this ? You need to tell us what the error is :) But, looking in my crystal ball, I find a hint that you're using Python 3 and a book that's teaching an older version of Python. Solution: Get a better book. ChrisA From edmondo.giovannozzi at gmail.com Wed Oct 14 07:41:51 2015 From: edmondo.giovannozzi at gmail.com (edmondo.giovannozzi at gmail.com) Date: Wed, 14 Oct 2015 04:41:51 -0700 (PDT) Subject: Python for Dummies exaple In-Reply-To: References: Message-ID: <5afc8984-b08a-4212-8d5d-ac2c19ead032@googlegroups.com> Il giorno mercoled? 14 ottobre 2015 12:04:30 UTC+2, Chris Angelico ha scritto: > On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User wrote: > > But with this script i get an error: > > But i have not so many experience to see what the error is. > > Good someone help me with this ? > > You need to tell us what the error is :) > > But, looking in my crystal ball, I find a hint that you're using > Python 3 and a book that's teaching an older version of Python. > Solution: Get a better book. > > ChrisA And using the same cristal ball, assuming you are using python 3.x, put brackets around the arguments of print like: print(countdown) ... print("Hello, my name is", self.myname) etc. forget for the moment about the ending comma. From rosuav at gmail.com Wed Oct 14 07:58:01 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 14 Oct 2015 22:58:01 +1100 Subject: Python for Dummies exaple In-Reply-To: References: Message-ID: On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User wrote: > #class example > class SayMyName: > def __init__(self, myname): > self.myname = myname > def say(self): > print "Hello, my name is", self.myname Side point: This is a poor example for _any_ Python. In Py2, that makes an old-style class, which will work fine until you try to use a feature that it can't handle, and then you'll wonder what on earth is wrong. And in Py3, the print calls need their parens. But it's a pointless example of a class, which leaves you wondering why a better example couldn't be found... Definitely look for a better book, preferably one aimed at Python 3.4 or 3.5. ChrisA From newsleecher at spam.com Wed Oct 14 08:32:33 2015 From: newsleecher at spam.com (NewsLeecher User) Date: Wed, 14 Oct 2015 12:32:33 GMT Subject: Python for Dummies exaple References: <5afc8984-b08a-4212-8d5d-ac2c19ead032@googlegroups.com> Message-ID: In reply to "edmondo.giovannozzi at gmail.com" who wrote the following: > Il giorno mercoled=EC 14 ottobre 2015 12:04:30 UTC+2, Chris Angelico ha scr= > itto: > > On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User wrote: > > > But with this script i get an error: > > > But i have not so many experience to see what the error is. > > > Good someone help me with this ? > > =20 > > You need to tell us what the error is :) > > =20 > > But, looking in my crystal ball, I find a hint that you're using > > Python 3 and a book that's teaching an older version of Python. > > Solution: Get a better book. > > =20 > > ChrisA > > And using the same cristal ball, assuming you are using python 3.x, put bra= > ckets around the arguments of print like: > > print(countdown) > ... > print("Hello, my name is", self.myname) > > etc. > forget for the moment about the ending comma. Thanks for the reply. Oh i did not look good enough that the examples are written in python 2.7 But there are also good things explaning in the book so i will keep it. Thanks -- --------------------------------- --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From __peter__ at web.de Wed Oct 14 08:47:06 2015 From: __peter__ at web.de (Peter Otten) Date: Wed, 14 Oct 2015 14:47:06 +0200 Subject: Python for Dummies exaple References: Message-ID: Chris Angelico wrote: > On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User > wrote: >> #class example >> class SayMyName: >> def __init__(self, myname): >> self.myname = myname >> def say(self): >> print "Hello, my name is", self.myname > > Side point: This is a poor example for _any_ Python. In Py2, that > makes an old-style class, which will work fine until you try to use a > feature that it can't handle, and then you'll wonder what on earth is > wrong. And in Py3, the print calls need their parens. But it's a > pointless example of a class, which leaves you wondering why a better > example couldn't be found... > > Definitely look for a better book, preferably one aimed at Python 3.4 or > 3.5. If I were to write a book about Python 2 I would defer the "always inherit from object" mantra until the features that require newstyle classes are introduced. In any way, judging a book from one example you disagree with is premature. Personally I expect to find many minor nits in the most excellent book. OP, the differences between Python 2 and Python 3 are big enough to make the attempt to learn one with a book using the other a rather displeasant experience. Either switch to a book that is geared at Python 3 (recommended, particularly if you speak a language using non-ascii letters) or install Python 2 and run the examples from your current book with the older 2.7 interpreter. From rosuav at gmail.com Wed Oct 14 09:02:43 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 15 Oct 2015 00:02:43 +1100 Subject: Python for Dummies exaple In-Reply-To: References: Message-ID: On Wed, Oct 14, 2015 at 11:47 PM, Peter Otten <__peter__ at web.de> wrote: > Chris Angelico wrote: > >> On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User >> wrote: >>> #class example >>> class SayMyName: >>> def __init__(self, myname): >>> self.myname = myname >>> def say(self): >>> print "Hello, my name is", self.myname >> >> Side point: This is a poor example for _any_ Python. In Py2, that >> makes an old-style class, which will work fine until you try to use a >> feature that it can't handle, and then you'll wonder what on earth is >> wrong. And in Py3, the print calls need their parens. But it's a >> pointless example of a class, which leaves you wondering why a better >> example couldn't be found... >> >> Definitely look for a better book, preferably one aimed at Python 3.4 or >> 3.5. > > If I were to write a book about Python 2 I would defer the "always inherit > from object" mantra until the features that require newstyle classes are > introduced. In any way, judging a book from one example you disagree with is > premature. Personally I expect to find many minor nits in the most excellent > book. Agreed, which is why I prefixed that part with "Side point". The old-style vs new-style class concern is a very minor one. The reason I recommend looking for a better book is mainly because people should be learning Py3 with a Py3 book. > OP, the differences between Python 2 and Python 3 are big enough to make the > attempt to learn one with a book using the other a rather displeasant > experience. Either switch to a book that is geared at Python 3 (recommended, > particularly if you speak a language using non-ascii letters) or install > Python 2 and run the examples from your current book with the older 2.7 > interpreter. Yeah. Those are the two options, and I definitely recommend the former. The advantages of Py3 over Py2 increase with every new version. ChrisA From kk at biblio.tu-bs.de Wed Oct 14 09:27:28 2015 From: kk at biblio.tu-bs.de (=?UTF-8?Q?Kristof_Ke=c3=9fler?=) Date: Wed, 14 Oct 2015 15:27:28 +0200 Subject: Python printing as a service - migration from WinXP to Win7/8 - issue with Win service privileges? Message-ID: <561E5840.1070303@biblio.tu-bs.de> Dear all, this is my first post to the list, so if I am not sufficiently detailed let me know. Not even sure if this is the best list to send this to as it seems to be an issue with Windows service privileges. We have been running a package of python scripts as services on a Windows XP machine for several years. These scripts include one that checks a mail server, processes mails and then prints to the attachements to the default printer. This is the only part that does not work, as a service, when migrating the package to Win7/8. The printing script works fine when executing it from the console. An odd thing also is that the script runs smoothly through as a service with not error message, but does not print. The inital script was in Python 2.4: -------- print_service.py --- ... printcmd = "C:/Python24/python.exe C:/Application/printpostdelivery.py" ... cmd = "%s %s" % (printcmd ,pdfname ) (stdout, stdin, stderr) = popen2.popen3( cmd ) screen = stdout.read() err_screen = stderr.read() ... --- printpostdelivery.py --- ... win32api.ShellExecute(0, "print", dateiname, None, ".", 0); ... --- -------- I upgraded to Python 2.7 and changed to lines in print_service.py accordingly: -------- print_service.py --- ... printcmd = "C:/Python27/python.exe C:/Application/printpostdelivery.py" ... cmd = "%s %s" % (printcmd ,pdfname ) p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr) screen = child_stdout.read() err_screen = child_stderr.read() ... --- -------- I played around with the service settings and ran it as administrator, but that did not help...well, only that initially there was an error message when running the service with Python 2.7: pywintypes.error: (31, 'ShellExecute', 'A device attached to the system is not functioning.') But that disappeared when I ran the service as an administrator. Then it was the same all over again. Script runs through smoothly with no error, but the documents were not printed. Any suggestions? Thanks! All the best Kristof From gengyangcai at gmail.com Wed Oct 14 13:04:52 2015 From: gengyangcai at gmail.com (Cai Gengyang) Date: Wed, 14 Oct 2015 10:04:52 -0700 (PDT) Subject: Execute Python Scripts Message-ID: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> So I am going through this article on Python for newbies ---http://askpython.com/execute-python-scripts/ Managed to create a file with these contents : 1 #!/usr/bin/env python3 2 3 print('hello world') and saved it as hello.py Next step, I wanted to open the 'command line' so I can type 'python hello.py' to execute the scripts. Where do I find the "command line" ? From paul.hermeneutic at gmail.com Wed Oct 14 13:17:41 2015 From: paul.hermeneutic at gmail.com (paul.hermeneutic at gmail.com) Date: Wed, 14 Oct 2015 11:17:41 -0600 Subject: Execute Python Scripts In-Reply-To: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> References: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> Message-ID: > Where do I find the "command line" ? Welcome to Python. Starting a command shell depends on which operating system you are running. If you are on Microsoft Windows, choose the Start button, then type "cmd" into the edit control, then press Enter. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gengyangcai at gmail.com Wed Oct 14 13:23:31 2015 From: gengyangcai at gmail.com (Cai Gengyang) Date: Wed, 14 Oct 2015 10:23:31 -0700 (PDT) Subject: Execute Python Scripts In-Reply-To: References: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> Message-ID: <316e9f9a-72dc-447c-8d0b-b503e9ce6679@googlegroups.com> On Thursday, October 15, 2015 at 1:18:27 AM UTC+8, paul.her... at gmail.com wrote: > > Where do I find the "command line" ? > > Welcome to Python. > > Starting a command shell depends on which operating system you are running. > > If you are on Microsoft Windows, choose the Start button, then type "cmd" into the edit control, then press Enter. Pleasure to meet you ... I am using a Mac OS X Yosemite Version 10.10.2 Operating System. Is the command line on this operating system the "Terminal" (black screen) ? From admin at hexhost.net Wed Oct 14 13:26:06 2015 From: admin at hexhost.net (James DeVincentis) Date: Wed, 14 Oct 2015 17:26:06 +0000 Subject: Problem with copy.deepcopy and multiprocessing Message-ID: <00f301d106a5$6326e940$2974bbc0$@hexhost.net> I've got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). I've tried 'del' the object before reusing it but it still reallocates to the same address space. I'm at a complete loss. 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: -------------- next part -------------- An HTML attachment was scrubbed... URL: From admin at hexhost.net Wed Oct 14 13:41:00 2015 From: admin at hexhost.net (James DeVincentis) Date: Wed, 14 Oct 2015 17:41:00 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue Message-ID: <010001d106a7$7ac98fb0$705caf10$@hexhost.net> I've got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). I've tried 'del' the object before reusing it but it still reallocates to the same address space. I'm at a complete loss. 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Wed Oct 14 13:46:32 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 14 Oct 2015 11:46:32 -0600 Subject: Execute Python Scripts In-Reply-To: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> References: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> Message-ID: On Wed, Oct 14, 2015 at 11:04 AM, Cai Gengyang wrote: > So I am going through this article on Python for newbies ---http://askpython.com/execute-python-scripts/ That looks like a terrible resource. There are plenty of tutorials and books out there that are actually good. I suggest starting with the tutorial from the Python docs: https://docs.python.org/3/tutorial/index.html > Pleasure to meet you ... I am using a Mac OS X Yosemite Version 10.10.2 Operating System. > > Is the command line on this operating system the "Terminal" (black screen) ? Yes. You will also need to "cd" to the same directory where you saved the script. For example, if you saved it to your Documents directory, then type "cd Documents" at the command line. You might also want to read a tutorial on the Mac OS X command line, e.g.: http://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line From hayesstw at telkomsa.net Wed Oct 14 13:48:37 2015 From: hayesstw at telkomsa.net (Steve Hayes) Date: Wed, 14 Oct 2015 19:48:37 +0200 Subject: Python for Dummies exaple References: <5afc8984-b08a-4212-8d5d-ac2c19ead032@googlegroups.com> Message-ID: On Wed, 14 Oct 2015 12:32:33 GMT, NewsLeecher User wrote: >In reply to "edmondo.giovannozzi at gmail.com" who wrote the following: > >> Il giorno mercoled=EC 14 ottobre 2015 12:04:30 UTC+2, Chris Angelico ha scr= >> itto: >> > On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User wrote: >> > > But with this script i get an error: >> > > But i have not so many experience to see what the error is. >> > > Good someone help me with this ? >> > =20 >> > You need to tell us what the error is :) >> > =20 >> > But, looking in my crystal ball, I find a hint that you're using >> > Python 3 and a book that's teaching an older version of Python. >> > Solution: Get a better book. >> > =20 >> > ChrisA >> >> And using the same cristal ball, assuming you are using python 3.x, put bra= >> ckets around the arguments of print like: >> >> print(countdown) >> ... >> print("Hello, my name is", self.myname) >> >> etc. >> forget for the moment about the ending comma. > >Thanks for the reply. >Oh i did not look good enough that the examples are written in python 2.7 >But there are also good things explaning in the book so i will keep it. I found all the Python books available dealt with version 2.x, so eventually I installed that for the purpose of learning Python. It's much easier, and you don't have to spend hours searching online for differences between 3.x and 2.x just to find what caused an error in an example script. Once you've l;earnt it, then you can start learning the differences, and maybe by that time there will be a book that deals with 3.x, but until there is, it's just not worth the hassle unless you're seriously into Unicode. -- 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 --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From gengyangcai at gmail.com Wed Oct 14 14:05:36 2015 From: gengyangcai at gmail.com (Cai Gengyang) Date: Wed, 14 Oct 2015 11:05:36 -0700 (PDT) Subject: Execute Python Scripts In-Reply-To: References: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> Message-ID: <5fe2c80a-de93-4793-9231-937afd31409f@googlegroups.com> Ok thanks ... this --- https://docs.python.org/3/tutorial/index.html looks like a way more comprehensive resource. Paul Graham has written an excellent essay called "The Python Paradox" : http://www.paulgraham.com/pypar.html. Putting it here for sharing and discussion ... On Thursday, October 15, 2015 at 1:47:50 AM UTC+8, Ian wrote: > On Wed, Oct 14, 2015 at 11:04 AM, Cai Gengyang wrote: > > So I am going through this article on Python for newbies ---http://askpython.com/execute-python-scripts/ > > That looks like a terrible resource. There are plenty of tutorials and > books out there that are actually good. I suggest starting with the > tutorial from the Python docs: > > https://docs.python.org/3/tutorial/index.html > > > Pleasure to meet you ... I am using a Mac OS X Yosemite Version 10.10.2 Operating System. > > > > Is the command line on this operating system the "Terminal" (black screen) ? > > Yes. You will also need to "cd" to the same directory where you saved > the script. For example, if you saved it to your Documents directory, > then type "cd Documents" at the command line. > > You might also want to read a tutorial on the Mac OS X command line, > e.g.: http://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line From john2james at gmail.com Wed Oct 14 15:05:28 2015 From: john2james at gmail.com (John S. James) Date: Wed, 14 Oct 2015 12:05:28 -0700 (PDT) Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? Message-ID: I installed 3.5.0 today and it's working fine -- either from the command prompt, or running a .py script. But the Python 3.4 that was previously installed on the computer had a Python34 folder, which contained DDLs, Doc, include, Lib, and various other folders and files. I haven't found a comparable Python35 folder anywhere. I'd like to find the 3.5 Doc folder at least. I looked for the installation directory using the command prompt, but at c:\Users\(my name)\ there is no AppData. Where can I find that folder? Or can I just ignore it for now (and get the documentation elsewhere)? From python at mrabarnett.plus.com Wed Oct 14 15:21:12 2015 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 14 Oct 2015 20:21:12 +0100 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: <010001d106a7$7ac98fb0$705caf10$@hexhost.net> References: <010001d106a7$7ac98fb0$705caf10$@hexhost.net> Message-ID: <561EAB28.3010302@mrabarnett.plus.com> On 2015-10-14 18:41, James DeVincentis wrote: > I?ve got a bit of a problem with copy.deepcopy and using > multiprocessing.Queue. > > I have an HTTPAPI that gets exposed to add objects to a > multiprocessing.Qeue. Source code here: > https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 > > The trouble is, even using deepcopy, my debugging shows that it keeps > re-using the same address space on every iteration of the loop (and/or > fork since it uses the Forking TCP server mixin). > > This is reflected when the reference to that address space gets removed > from the Queue. Source code: > https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py > > So I submit a few objects very rapidly to the HTTP server. It places > them in the queue. For some reason on the second iteration copy.deepcopy > stops using new address spaces for deepcopied objects. As such the queue > processes that object only once (even though Queue.put() is called > repeatedly for the same address space). > > I?ve tried ?del? the object before reusing it but it still reallocates > to the same address space. I?m at a complete loss. > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: > > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: > > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > Could it just be re-using space that it has recently freed? From tjreedy at udel.edu Wed Oct 14 15:23:25 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 14 Oct 2015 15:23:25 -0400 Subject: Python for Dummies exaple In-Reply-To: References: <5afc8984-b08a-4212-8d5d-ac2c19ead032@googlegroups.com> Message-ID: > I found all the Python books available dealt with version 2.x, I searched "python 3 book" and immediately come up with Programming in Python 3 Dive Into Python 3 Python 3 for Absolute Beginners + 'free' Non-Programmer's Tutorial for Python 3 https://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3 http://www.onlineprogrammingbooks.com/python/ has Learning to Program Using Python (2&3) Python Cookbook Third Edition (py 3) http://www.openbookproject.net/thinkcs/python/english3e/ How to Think Like a Computer Scientist:Learning with Python 3 Many of these are updated versions (2 or 3 years old) of well known py2 books. -- Terry Jan Reedy From paul.hermeneutic at gmail.com Wed Oct 14 15:25:31 2015 From: paul.hermeneutic at gmail.com (paul.hermeneutic at gmail.com) Date: Wed, 14 Oct 2015 13:25:31 -0600 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: References: Message-ID: > Where can I find that folder? Or can I just ignore it for now (and get the documentation elsewhere)? If the install was done for "all users" on the machine, then the Python installation directory will be under " %SystemRoot%\Program Files\" for 64-bit or "%SystemRoot%\Program Files (x86)\" for 32-bit Python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zachary.ware+pylist at gmail.com Wed Oct 14 15:31:11 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Wed, 14 Oct 2015 14:31:11 -0500 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: References: Message-ID: On Wed, Oct 14, 2015 at 2:05 PM, John S. James wrote: > I installed 3.5.0 today and it's working fine -- either from the command prompt, or running a .py script. > > But the Python 3.4 that was previously installed on the computer had a Python34 folder, which contained DDLs, Doc, include, Lib, and various other folders and files. I haven't found a comparable Python35 folder anywhere. I'd like to find the 3.5 Doc folder at least. > > I looked for the installation directory using the command prompt, but at c:\Users\(my name)\ there is no AppData. > > Where can I find that folder? Or can I just ignore it for now (and get the documentation elsewhere)? Python 3.5 changed the default install directory on Windows to better fit in with other Windows software and to alleviate security concerns (C:\Python34, for example, is world-writable, whereas C:\Program Files\Python 3.5\, which is the new default all-users install location, can only be written to by administrators). True per-user installs are now also possible, and install to your user directory. You can find where Python is installed using Python itself: try `py -3.5 -c "import sys, os;os.system('explorer ' + sys.prefix)"` at the Command Prompt, which uses the Python Launcher for Windows to start Python 3.5 and execute a command to start a Windows Explorer instance in the directory containing Python. By the way, C:\Users\(your name)\AppData does exist, but is hidden by default. It will tab-complete, though; at Command Prompt do `dir C:\Users\(your name)\App`. You can also get always-up-to-date documentation from https://docs.python.org/3.5/. There's also a download page at https://docs.python.org/3.5/download.html if you prefer a local copy of one of the various formats available there. Hope this helps, -- Zach From python at mrabarnett.plus.com Wed Oct 14 15:36:01 2015 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 14 Oct 2015 20:36:01 +0100 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: References: Message-ID: <561EAEA1.7050405@mrabarnett.plus.com> On 2015-10-14 20:05, John S. James wrote: > I installed 3.5.0 today and it's working fine -- either from the > command prompt, or running a .py script. > > But the Python 3.4 that was previously installed on the computer had > a Python34 folder, which contained DDLs, Doc, include, Lib, and > various other folders and files. I haven't found a comparable > Python35 folder anywhere. I'd like to find the 3.5 Doc folder at > least. > > I looked for the installation directory using the command prompt, but > at c:\Users\(my name)\ there is no AppData. > > Where can I find that folder? Or can I just ignore it for now (and > get the documentation elsewhere)? > The AppData folder probably _is_ there, but hidden. There's a checkbox to show hidden items. It's on the View menu in Windows 10. From c.candide at laposte.net Wed Oct 14 17:11:20 2015 From: c.candide at laposte.net (candide) Date: Wed, 14 Oct 2015 14:11:20 -0700 (PDT) Subject: Sets vs lists loop behaviour if size changes Message-ID: <7d40a4c6-5201-4a09-ac98-c320ede97c18@googlegroups.com> If set size changes during a for loop, a runtime exception is raised: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ S = {2015} for z in S: S.add(42) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Traceback (most recent call last): File "_.py", line 2, in for z in S: RuntimeError: Set changed size during iteration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Surprisingly, if a for loop changes the size of a list it is iterating on, no exception is raised : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ L = [2015] for z in L: L.append(42) print(len(L)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The code above falls into an infinite loop, printing : 2 3 4 5 6 7 8 9 ... 198435 198436 198437 ^Z So why lists and sets don't react the same way? From ian.g.kelly at gmail.com Wed Oct 14 17:29:32 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 14 Oct 2015 15:29:32 -0600 Subject: Sets vs lists loop behaviour if size changes In-Reply-To: <7d40a4c6-5201-4a09-ac98-c320ede97c18@googlegroups.com> References: <7d40a4c6-5201-4a09-ac98-c320ede97c18@googlegroups.com> Message-ID: On Wed, Oct 14, 2015 at 3:11 PM, candide via Python-list wrote: > If set size changes during a for loop, a runtime exception is raised: > > [SNIP] > > Surprisingly, if a for loop changes the size of a list it is iterating on, no exception is raised : > > [SNIP] > > So why lists and sets don't react the same way? Because the behavior of iteration over a set (or dict) that changes while it's being iterated over is much more difficult to predict. Though you shouldn't insert or delete items in a list before the current iteration point, it's generally safe to append items while iterating. With a set or dict, *any* items that are added or deleted [1] during iteration could cause the entire data structure to be rebuilt, changing the buckets that everything is in and fundamentally altering the order of iteration. If that happens, all bets are off as to which items will be iterated over multiple times, which will not be iterated at all, or how the number of items iterated over will compare to the actual size of the set or dict. [1] Merely changing the value of a particular key in a dict is perfectly safe, however. From motoom at xs4all.nl Wed Oct 14 17:36:08 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Wed, 14 Oct 2015 23:36:08 +0200 Subject: Sets vs lists loop behaviour if size changes In-Reply-To: <7d40a4c6-5201-4a09-ac98-c320ede97c18@googlegroups.com> References: <7d40a4c6-5201-4a09-ac98-c320ede97c18@googlegroups.com> Message-ID: <9DE87FFE-8422-43FB-85BA-2BA26A5E1ED9@xs4all.nl> > On 14 Oct 2015, at 23:11, candide via Python-list wrote: > > If set size changes during a for loop, a runtime exception is raised A set is a kind of dictionary (without values). And why it can't be resized, is explained by Brandon Rhodes in his excellent talk 'The Mighty Dictionary', https://www.youtube.com/watch?v=C4Kc8xzcA68 , starting at 21:24 "Because of resizing, a dictionary (or set) can completely reorder during an otherwise innocent insert". Greetings, From c.candide at laposte.net Wed Oct 14 17:47:40 2015 From: c.candide at laposte.net (candide) Date: Wed, 14 Oct 2015 14:47:40 -0700 (PDT) Subject: Sets vs lists loop behaviour if size changes In-Reply-To: <7d40a4c6-5201-4a09-ac98-c320ede97c18@googlegroups.com> References: <7d40a4c6-5201-4a09-ac98-c320ede97c18@googlegroups.com> Message-ID: Thanks for the response and the reference, indeed sets and lists behave differently... From eryksun at gmail.com Wed Oct 14 19:20:22 2015 From: eryksun at gmail.com (eryksun) Date: Wed, 14 Oct 2015 18:20:22 -0500 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: References: Message-ID: On 10/14/15, Zachary Ware wrote: > > You can find where Python is installed using Python itself: try `py > -3.5 -c "import sys, os;os.system('explorer ' + sys.prefix)"` at the > Command Prompt, Here's a slightly simpler way to open the folder: py -3.5 -c "import os, sys; os.startfile(sys.prefix)" > By the way, C:\Users\(your name)\AppData does exist, but is hidden by > default. It will tab-complete, though; at Command Prompt do `dir > C:\Users\(your name)\App`. You can list all files and directories using the /a switch of cmd's dir command, and just directories (including hidden ones) using /ad, e.g. dir /ad %userprofile% From prajoshi at microsoft.com Wed Oct 14 20:32:28 2015 From: prajoshi at microsoft.com (Prasad Joshi) Date: Thu, 15 Oct 2015 00:32:28 +0000 Subject: help(string) commands not working on pyton 3.5 Message-ID: Hi, I have installed the "Windows x86-64 executable installer" on my desktop but I cannot get help ( ) or help (string) command working. What could be an issue? Thanks! Prasad Joshi. -------------- next part -------------- An HTML attachment was scrubbed... URL: From orgnut at yahoo.com Wed Oct 14 21:41:07 2015 From: orgnut at yahoo.com (Larry Hudson) Date: Wed, 14 Oct 2015 18:41:07 -0700 Subject: Execute Python Scripts In-Reply-To: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> References: <4350da82-f2ae-4334-a1fe-97b9defeed29@googlegroups.com> Message-ID: On 10/14/2015 10:04 AM, Cai Gengyang wrote: > So I am going through this article on Python for newbies ---http://askpython.com/execute-python-scripts/ > > Managed to create a file with these contents : > > 1 #!/usr/bin/env python3 > 2 > 3 print('hello world') > > and saved it as hello.py > You did write that file _without_ the line numbers, I hope. Line numbers are sometimes used in text to discuss a Python program, but they are _NOT_ used in an actual program. -=- Larry -=- From john2james at gmail.com Wed Oct 14 21:47:07 2015 From: john2james at gmail.com (John S James) Date: Wed, 14 Oct 2015 21:47:07 -0400 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: References: Message-ID: Thank you, this is very helpful. John On Wed, Oct 14, 2015 at 3:31 PM, Zachary Ware wrote: > On Wed, Oct 14, 2015 at 2:05 PM, John S. James > wrote: > > I installed 3.5.0 today and it's working fine -- either from the command > prompt, or running a .py script. > > > > But the Python 3.4 that was previously installed on the computer had a > Python34 folder, which contained DDLs, Doc, include, Lib, and various other > folders and files. I haven't found a comparable Python35 folder anywhere. > I'd like to find the 3.5 Doc folder at least. > > > > I looked for the installation directory using the command prompt, but at > c:\Users\(my name)\ there is no AppData. > > > > Where can I find that folder? Or can I just ignore it for now (and get > the documentation elsewhere)? > > Python 3.5 changed the default install directory on Windows to better > fit in with other Windows software and to alleviate security concerns > (C:\Python34, for example, is world-writable, whereas C:\Program > Files\Python 3.5\, which is the new default all-users install > location, can only be written to by administrators). True per-user > installs are now also possible, and install to your user directory. > > You can find where Python is installed using Python itself: try `py > -3.5 -c "import sys, os;os.system('explorer ' + sys.prefix)"` at the > Command Prompt, which uses the Python Launcher for Windows to start > Python 3.5 and execute a command to start a Windows Explorer instance > in the directory containing Python. > > By the way, C:\Users\(your name)\AppData does exist, but is hidden by > default. It will tab-complete, though; at Command Prompt do `dir > C:\Users\(your name)\App`. > > You can also get always-up-to-date documentation from > https://docs.python.org/3.5/. There's also a download page at > https://docs.python.org/3.5/download.html if you prefer a local copy > of one of the various formats available there. > > Hope this helps, > -- > Zach > -- John S. James www.AgeTreatmentNews.org - Biomedical research to slow or reverse aging; also on Twitter at AgeTreatment Other projects: www.affinity99.org www.MassSponsorship.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason.swails at gmail.com Wed Oct 14 21:49:33 2015 From: jason.swails at gmail.com (Jason Swails) Date: Wed, 14 Oct 2015 21:49:33 -0400 Subject: Stylistic question regarding no-op code and tests Message-ID: Hi everyone, I'd like to get some opinions about some coding constructs that may seem at first glance to serve no purpose, but does have *some* non-negligible purpose, and I think I've come to the right place :). The construct is this: def my_function(arg1, arg2, filename=None): """ Some function. If a file is given, it is processed """ # Some code that performs my_function if filename is not None: process_file(filename) else: pass My question is, what do you think of the "else: pass" statement? It is a complete no-op and is syntactically equivalent to the same code with those lines removed. Up until earlier today, I would look at that and cringe (I still do, a little). What I recently realized, though, that what this construct allows is for the coverage testing package (which I have recently started employing for my project... thanks Ned and others!) to detect whether or not both code paths are covered in the test suite. I think my opinion here is that this construct is useful to use when the two code paths are very different operationally from each other, one is an unusual path that you are not >100% sure is well-covered in your test suite, but that your first instinct should be to avoid such code. What do you think? Thanks! Jason -- Jason M. Swails BioMaPS, Rutgers University Postdoctoral Researcher -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Wed Oct 14 21:58:47 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 15 Oct 2015 12:58:47 +1100 Subject: Stylistic question regarding no-op code and tests In-Reply-To: References: Message-ID: On Thu, Oct 15, 2015 at 12:49 PM, Jason Swails wrote: > My question is, what do you think of the "else: pass" statement? It is a > complete no-op and is syntactically equivalent to the same code with those > lines removed. Up until earlier today, I would look at that and cringe (I > still do, a little). > > What I recently realized, though, that what this construct allows is for the > coverage testing package (which I have recently started employing for my > project... thanks Ned and others!) to detect whether or not both code paths > are covered in the test suite. If that's the case, it absolutely MUST have some acknowledgement in the code. Maybe a comment, or maybe replace the 'pass' with an 'assert', or (a neat trick I've used in a few places) a statistical counter: if filename is not None: process_file(filename) files_processed += 1 else: nonfiles_not_processed += 1 Your coverage tester should be just as happy with that, and it doesn't look pointless. ChrisA From ben+python at benfinney.id.au Wed Oct 14 22:07:15 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 15 Oct 2015 13:07:15 +1100 Subject: Stylistic question regarding no-op code and tests References: Message-ID: <85twpssx4c.fsf@benfinney.id.au> Jason Swails writes: > What I recently realized, though, that what this construct allows is > for the coverage testing package (which I have recently started > employing for my project... thanks Ned and others!) to detect whether > or not both code paths are covered in the test suite. Coverage.py has, for many releases now, had good measurement of branch coverage by your tests. Enable it with the ?--branch? option to ?run? . -- \ ?They who can give up essential liberty to obtain a little | `\ temporary safety, deserve neither liberty nor safety.? | _o__) ?Benjamin Franklin, 1775-02-17 | Ben Finney From hayesstw at telkomsa.net Wed Oct 14 23:01:30 2015 From: hayesstw at telkomsa.net (Steve Hayes) Date: Thu, 15 Oct 2015 05:01:30 +0200 Subject: Python for Dummies exaple References: <5afc8984-b08a-4212-8d5d-ac2c19ead032@googlegroups.com> Message-ID: On Wed, 14 Oct 2015 15:23:25 -0400, Terry Reedy wrote: > >> I found all the Python books available dealt with version 2.x, > >I searched "python 3 book" and immediately come up with >Programming in Python 3 >Dive Into Python 3 >Python 3 for Absolute Beginners > >+ 'free' >Non-Programmer's Tutorial for Python 3 >https://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3 > >http://www.onlineprogrammingbooks.com/python/ has >Learning to Program Using Python (2&3) >Python Cookbook Third Edition (py 3) > >http://www.openbookproject.net/thinkcs/python/english3e/ >How to Think Like a Computer Scientist:Learning with Python 3 > >Many of these are updated versions (2 or 3 years old) of well known py2 >books. That may be so, but I've not seen any of them in any bookshops or libraries. -- 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 --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From vincent at vincentdavis.net Thu Oct 15 01:24:41 2015 From: vincent at vincentdavis.net (Vincent Davis) Date: Wed, 14 Oct 2015 23:24:41 -0600 Subject: write csv to object and read into pandas Message-ID: I have a csv file I have to make some changes to before I read it into pandas. Currently I open the csv read each row, make changes and save it to a new file. Then read it into pandas with pandas.read_csv(). How do I skip writing the file to disk? Using python3.5. This is what I am doing now. with open(infile,"r") as fin: with open(outfile,"w") as fout: writer=csv.writer(fout) for row in csv.reader(fin): #do stuff to the row writer.writerow(row) df = pandas.csv_reader(outfile) Vincent Davis 720-301-3003 -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Oct 15 04:16:10 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 15 Oct 2015 10:16:10 +0200 Subject: write csv to object and read into pandas References: Message-ID: Vincent Davis wrote: > I have a csv file I have to make some changes to before I read it into > pandas. Currently I open the csv read each row, make changes and save it > to a new file. Then read it into pandas with pandas.read_csv(). How do I > skip writing the file to disk? Using python3.5. > > This is what I am doing now. > > with open(infile,"r") as fin: > with open(outfile,"w") as fout: > writer=csv.writer(fout) > for row in csv.reader(fin): > #do stuff to the row > writer.writerow(row) > > df = pandas.csv_reader(outfile) If you can implement "do stuff to the row" in pandas I'd recommend that. If not, the following should work (though I'm not a pandas expert): def preprocess(filename): with open(filename) as f: for row in csv.reader(f): # do stuff yield row rows = preprocess("pandas.csv") df = pandas.DataFrame.from_records(rows, columns=next(rows)) df = df.convert_objects(convert_numeric=True) If the csv file doesn't have a header row omit the columns=next(rows) argument. From __peter__ at web.de Thu Oct 15 06:14:37 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 15 Oct 2015 12:14:37 +0200 Subject: Stylistic question regarding no-op code and tests References: Message-ID: Jason Swails wrote: > Hi everyone, > > I'd like to get some opinions about some coding constructs that may seem > at first glance to serve no purpose, but does have *some* non-negligible > purpose, and I think I've come to the right place :). > > The construct is this: > > def my_function(arg1, arg2, filename=None): > """ Some function. If a file is given, it is processed """ > # Some code that performs my_function > if filename is not None: > process_file(filename) > else: > pass > > My question is, what do you think of the "else: pass" statement? It is a > complete no-op and is syntactically equivalent to the same code with those > lines removed. Up until earlier today, I would look at that and cringe (I > still do, a little). > > What I recently realized, though, that what this construct allows is for > the coverage testing package (which I have recently started employing for > my project... thanks Ned and others!) to detect whether or not both code > paths are covered in the test suite. > > I think my opinion here is that this construct is useful to use when the > two code paths are very different operationally from each other, one is an > unusual path that you are not >100% sure is well-covered in your test > suite, but that your first instinct should be to avoid such code. > > What do you think? Rewrite my_function() in such a way that you can devise unit tests that verify the process_file path is taken if and only if filename is not None. The minimal change would be def my_function(arg1, arg2, filename=None): """ Some function. If a file is given, it is processed """ # Some code that performs my_function if filename is not None: process_file(filename) return True else: return False but there are certainly options that better reflect the actual purpose of my_function(). coverage.py is a nice addition, but tests are the first line of defense against buggy code. From oscar.j.benjamin at gmail.com Thu Oct 15 06:20:14 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 15 Oct 2015 11:20:14 +0100 Subject: write csv to object and read into pandas In-Reply-To: References: Message-ID: On 15 October 2015 at 09:16, Peter Otten <__peter__ at web.de> wrote: > > def preprocess(filename): > with open(filename) as f: > for row in csv.reader(f): > # do stuff > yield row > > rows = preprocess("pandas.csv") Take the with statement outside of the generator and do something like: def preprocess(lines): for row in csv.reader(lines): # do stuff yield row with open("pandas.csv") as pandasfile: rows = preprocess(pandasfile) df = pandas... # etc. This ensures that the file will be closed if an exception occurs outside the generator or if the generator is not fully consumed. > df = pandas.DataFrame.from_records(rows, columns=next(rows)) next(rows) can raise StopIteration which can be problematic so perhaps something like: try: fieldnames = next(rows) except StopIteration: raise ValueError df = pandas... (columns=fieldnames) # etc -- Oscar From gandalf at shopzeus.com Thu Oct 15 07:25:34 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Thu, 15 Oct 2015 13:25:34 +0200 Subject: How to implement an async message bus Message-ID: <561F8D2E.10600@shopzeus.com> I'm new to Python 3.5 async / await syntax. I would like to create a class - let's call it AsyncBus - that can be used to listen for keys, and send messages for keys ansynchronously. class BusTimeoutError(Exception): pass class AsyncBus(object): def __init__(self, add_timeout): """add_timeout should be a function that uses the current event loop implementation to call back" .... async def notify(self, key, message): """Notify a single waiter about a key. Return if somebody was waiting for it.""" .... async def notifyall(self, key, message): """Notify all waiters. Return the number of waiters notified.""" .... async def waitfor(self, keys, timeout=None): """Wait until a message comes in for any of the given key(s). Raise BusTimeoutError after the given timedelta.""" .... Internally, the waitfor method would use the add_timeout to resume itself and raise the BusTimeoutError exception after the given timeout, and this should be the only place where a periodic (system time based) sleep would occur. The notify/notifyall methods would also resume execution in waitfor() call(s), but they would provide the message for the waiter instead of raising an exception. Here is an example use case: * Write a chat server, where all the users are running the chat client in a browser * The browser sends long polling ajax request to the server, that returns any new messages immediatelly, or block for at most timeout=10 seconds before returning without any message. This long poll would be called in an infinite loop in the browser. Internally, long poll requests would end in bus.waitfor() calls on the server. * When the user sends a new message to another user, then bus.notifyall() is awaited. notifyall() awakens all bus.waitfor() calls, delivers the message to all clients, and finally gives back the number of clients notified to the sender of the message. The sender can see how many clients got the message. I have examined code for long polling in other projects, and I have found that most of them use add_timeout to check for new messages periodically. I do not want to follow this practice. * let's say there are 1000 clients connected. * if I use a lower timeout (say 0.1 seconds) for periodic checks, then the server will be woken up 1000 times in ever 0.1 seconds. Avg. in every 0.0001 seconds. It will do nothing usefull in 99.99% of that time,. That seems to be bad. * if I use a higher timeout (say 10 seconds) then messages won't be delivered for an average of 5 seconds which is also bad. So messages should NOT be delivered by periodic checks. They should be delivered from events triggered by incoming messages. In other words: when a new message comes in, it should wake up the clients waiting for messages (for the given user) and deliver the message instantaneously. Question is: how to write the AsyncBus class? Here is what I have tried - but I don't know how to create the waiter object at the bottom. class BusTimeoutError(Exception): """Raised when the waiter has been waiting for too long.""" pass class AsnycBus(object): """Asynchronous notification bus.""" def __init__(self, add_timeout): self._waiters = {} self._add_timeout = add_timeout async def notify(self, key, message): """Notify a single waiter. Return if there was a waiter waiting for the key.""" if key in self._waiters: self._waiters[key][0].send((key, message)) return True else: return False async def notifyall(self, key, message): """Notify all waiters. Return the number of waiters notified.""" if key in self._waiters: # Get all waiters waiters = self._waiters[key] for waiter in waiters: # Send the message to the waiter waiter.send((key, message)) return len(waiters) else: return 0 async def waitfor(self, keys, timeout=None): """Wait for keys. :arg keys: An iterable of immutable keys. :arg timeout: Raise TimeoutError if nothing hits the bus for this amount of time. None means: wait indefinitely. It should be a datetime.timedelta object. """ # Register for keys if not keys: raise Exception("Need some keys to wait for...") waiter = ????????????????????????????? for key in keys: if key in self._waiters: self._waiters[key].append(waiter) else: self._waiters[key] = [waiter] try: # Add timeout and wake me up if nothing comes in. if timeout: self._add_timeout(timeout, functools.partial(waiter.throw, BusTimeoutError)) return await waiter finally: for key in keys: if key in self._waiters: self._waiters[key].remove(waiter) -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcasale at activenetwerx.com Thu Oct 15 07:27:58 2015 From: jcasale at activenetwerx.com (Joseph L. Casale) Date: Thu, 15 Oct 2015 11:27:58 +0000 Subject: Enum class Message-ID: <1444908477659.65832@activenetwerx.com> Is it possible to?override __contains__ from?the meta class?in the derived class with the Enum type? Thanks, jlc From gvanem at yahoo.no Thu Oct 15 07:39:41 2015 From: gvanem at yahoo.no (Gisle Vanem) Date: Thu, 15 Oct 2015 13:39:41 +0200 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: References: Message-ID: <561F907D.1090407@yahoo.no> eryksun wrote: > Here's a slightly simpler way to open the folder: > > py -3.5 -c "import os, sys; os.startfile(sys.prefix)" And what to do if the Pylauncher itself seems confused or the Registry settings for PythonCore is messed up? The WOW64 mess MS has have seems to have caused some problems here. With: c:\> set PYLAUNCH_DEBUG=1 & py -3 -c "import os, sys; print(sys.prefix)" I get: ... locating Pythons in 64bit registry locate_pythons_for_key: unable to open PythonCore key in HKCU locate_pythons_for_key: unable to open PythonCore key in HKLM locating Pythons in native registry locate_pythons_for_key: unable to open PythonCore key in HKCU locate_pythons_for_key: F:\ProgramFiler\Python27\python.exe is a 32bit executable ... locate_pythons_for_key: F:\ProgramFiler-x86\Python35\python.exe: Systemet finner ikke angitt bane. locate_pythons_for_key: F:\ProgramFiler-x86\Python35\PCBuild\win32\python.exe: Systemet finner ikke angitt bane. locate_pythons_for_key: F:\ProgramFiler-x86\Python35\PCBuild\amd64\python.exe: Systemet finner ikke angitt bane. found no configured value for 'python3' search for Python version '3' found no interpreter Requested Python version (3) not installed ("Systemet finner ikke angitt bane." == "File not found"). This is non-sense. I do have Python2 + 3 both on PATH (but both 32-bits). Not sure if PyLauncher looks for 64-bit registry entries only. But is there a way for py.exe to use '%USERPROFILE%\Local\py.ini' only? I failed to find any good documentation on it's format. -- --gv From bgailer at gmail.com Thu Oct 15 08:09:09 2015 From: bgailer at gmail.com (Bob Gailer) Date: Thu, 15 Oct 2015 08:09:09 -0400 Subject: help(string) commands not working on pyton 3.5 In-Reply-To: References: Message-ID: Please show us exactly what you tried and exactly what the results were. For example: >>> help() Syntax error... On Oct 15, 2015 7:34 AM, "Prasad Joshi" wrote: > Hi, > > > > I have installed the ?Windows x86-64 executable installer > ? on my > desktop but I cannot get help ( ) or help (string) command working. > > What could be an issue? > > > > Thanks! > > Prasad Joshi. > > -- > https://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Oct 15 08:11:37 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 15 Oct 2015 14:11:37 +0200 Subject: write csv to object and read into pandas References: Message-ID: Oscar Benjamin wrote: > On 15 October 2015 at 09:16, Peter Otten <__peter__ at web.de> wrote: >> >> def preprocess(filename): >> with open(filename) as f: >> for row in csv.reader(f): >> # do stuff >> yield row >> >> rows = preprocess("pandas.csv") > > Take the with statement outside of the generator and do something like: When will I ever learn :( From __peter__ at web.de Thu Oct 15 08:29:48 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 15 Oct 2015 14:29:48 +0200 Subject: Enum class References: <1444908477659.65832@activenetwerx.com> Message-ID: Joseph L. Casale wrote: > Is it possible to override __contains__ from the meta class in the derived > class with the Enum type? >>> import enum >>> class M(enum.EnumMeta): ... def __contains__(self, value): ... print("checking", value) ... return super().__contains__(value) ... >>> class Colors(enum.Enum, metaclass=M): ... red = 1 ... green = 2 ... blue = 3 ... >>> Colors.red in Colors checking Colors.red True Is that what you're asking for? If not can you give an example? From eryksun at gmail.com Thu Oct 15 08:40:35 2015 From: eryksun at gmail.com (eryksun) Date: Thu, 15 Oct 2015 07:40:35 -0500 Subject: help(string) commands not working on pyton 3.5 In-Reply-To: References: Message-ID: On 10/14/15, Prasad Joshi wrote: > Hi, > > I have installed the "Windows x86-64 executable > installer" > on my desktop but I cannot get help ( ) or help (string) command working. > What could be an issue? > It may help to know which version of Windows you're using -- XP, Vista, 7, 8, or 10? help() may work after switching to a plain pager: import pydoc pydoc.pager = pydoc.plainpager in which case, check whether the following prints "test": pydoc.tempfilepager('test', 'more <') If not, please reply with the traceback or error message, if any. From jason.swails at gmail.com Thu Oct 15 08:55:26 2015 From: jason.swails at gmail.com (Jason Swails) Date: Thu, 15 Oct 2015 08:55:26 -0400 Subject: Stylistic question regarding no-op code and tests In-Reply-To: <85twpssx4c.fsf@benfinney.id.au> References: <85twpssx4c.fsf@benfinney.id.au> Message-ID: On Wed, Oct 14, 2015 at 10:07 PM, Ben Finney wrote: > Jason Swails writes: > > > What I recently realized, though, that what this construct allows is > > for the coverage testing package (which I have recently started > > employing for my project... thanks Ned and others!) to detect whether > > or not both code paths are covered in the test suite. > > Coverage.py has, for many releases now, had good measurement of branch > coverage by your tests. Enable it with the ?--branch? option to ?run? > ?Oh, cool. I'm actually using coverage indirectly through nose, so I haven't really looked through the coverage docs (although nosetests has a --cover-branches option that toggles this feature). Now I can go back to cringing about "else: pass" in peace :). Thanks! Jason -- Jason M. Swails BioMaPS, Rutgers University Postdoctoral Researcher -------------- next part -------------- An HTML attachment was scrubbed... URL: From gandalf at shopzeus.com Thu Oct 15 09:16:54 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Thu, 15 Oct 2015 15:16:54 +0200 Subject: How to implement an async message bus In-Reply-To: <561F8D2E.10600@shopzeus.com> References: <561F8D2E.10600@shopzeus.com> Message-ID: <561FA746.7020409@shopzeus.com> > async def waitfor(self, keys, timeout=None): > """Wait for keys. > > :arg keys: An iterable of immutable keys. > :arg timeout: Raise TimeoutError if nothing hits the > bus for this amount of time. > None means: wait indefinitely. It should be a > datetime.timedelta object. > """ > # Register for keys > if not keys: > raise Exception("Need some keys to wait for...") > > waiter = ????????????????????????????? > > for key in keys: > if key in self._waiters: > self._waiters[key].append(waiter) > else: > self._waiters[key] = [waiter] > try: > # Add timeout and wake me up if nothing comes in. > if timeout: > self._add_timeout(timeout, > functools.partial(waiter.throw, BusTimeoutError)) > return await waiter > finally: > for key in keys: > if key in self._waiters: > self._waiters[key].remove(waiter) The waiter should be an awaitable that suspends execution and is resumed when waiter.throw() or waiter.send() is called explicitely. Here are the options for awaitable objects (https://www.python.org/dev/peps/pep-0492/#await-expression): * A native coroutine object - of course this is ouf of the question because I'm programming in pure python. * Objects defined with CPython C API with a tp_as_async.am_await function - out of the question for the same reason * An object with an __await__ method returning an interator - does not help me, because it leaves me with a missing iterator implementation with the same problem in its next(). * A generator based object returned from a function decorated by types.coroutine() - this might work I have tried this: @types.coroutinedef _create_waiter():_key, _value = yield# Suspend execution of this coroutine and resume when send() or throw() is called on it. return _key, _valuewaiter = _create_waiter() However, I got this exception: File "C:/Python/Projects/_test/main.py", line 104, in post username = await login_notifier.waitfor(self.sid, timeout=datetime.timedelta(seconds=10)) File "C:\Python\Projects\_test\asyncbus.py", line 63, in waitfor return await waiter File "C:\Python\Projects\_test\asyncbus.py", line 50, in _create_waiter _key, _value = yield File "C:\Python35\lib\site-packages\tornado-4.3.dev1-py3.5-win-amd64.egg\tornado\gen.py", line 999, in run value = future.result() File "C:\Python35\lib\site-packages\tornado-4.3.dev1-py3.5-win-amd64.egg\tornado\concurrent.py", line 232, in result raise_exc_info(self._exc_info) File "", line 3, in raise_exc_info File "C:\Python35\lib\site-packages\tornado-4.3.dev1-py3.5-win-amd64.egg\tornado\gen.py", line 1081, in handle_yield self.future = convert_yielded(yielded) File "C:\Python35\lib\functools.py", line 743, in wrapper return dispatch(args[0].__class__)(*args, **kw) File "C:\Python35\lib\site-packages\tornado-4.3.dev1-py3.5-win-amd64.egg\tornado\gen.py", line 1213, in convert_yielded raise BadYieldError("yielded unknown object %r" % (yielded,)) tornado.gen.BadYieldError: yielded unknown object None Apparently, the following statement: _key, _value = yield yielded None to the ioloop event loop runner, and it wanted to something with it. But why? -------------- next part -------------- An HTML attachment was scrubbed... URL: From abbasmo at centralfoundationboys.co.uk Thu Oct 15 09:29:24 2015 From: abbasmo at centralfoundationboys.co.uk (abbasmo at centralfoundationboys.co.uk) Date: Thu, 15 Oct 2015 06:29:24 -0700 (PDT) Subject: How to repeat a loop once it is finished Message-ID: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> import time #this is so that i can set a timer print ("only print numbers as your answers (Round all numbers up) also the programme adds 0.5 extra for cost of : ") time.sleep(2) #this is to let the person know what format to write it in# answer = input ("enter the height of the room walls between 2 to 6 metres: ") #this is the first input to understand what the client wants# print (answer) #this is to let the client know what value they have put in to see if they have made a mistake# while answer == range(2,6): Q1 #this lets the programme know which figures are acceptable# Q1 = input("enter length of room walls between 1 to 25 metres: ") #this the second question that is chosen# print (Q1) #This is again to let the client know what number they have inserted in case they have made an error while Q1 == range(1,25): Q2 #this is to let the programme know the numbers that are acceptable# Q2 = input("choose the price of paint that you want. Luxury = 175 Standard cost 100 Economy = 45 ALL PRICES MULTIPLIED BY 100 : ") #this is the final question that is asked# print (Q2) #this the final indication of what the client has inserted into the equasion# y = (int(answer) * int(Q1)* int(Q2)) #This tells the programme to multiply the numbers together# print (y/100 + 0.5) #this is because the programme only accepts whole numbers and to get the real value i needed to devide by 100 time.sleep(25) what would be a small thing that I could add to make this thing run again? From abbasmo at centralfoundationboys.co.uk Thu Oct 15 09:31:47 2015 From: abbasmo at centralfoundationboys.co.uk (abbasmo at centralfoundationboys.co.uk) Date: Thu, 15 Oct 2015 06:31:47 -0700 (PDT) Subject: How to repeat a loop once it is finished In-Reply-To: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> References: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> Message-ID: if you could write a small piece of code for me it would great From gandalf at shopzeus.com Thu Oct 15 09:44:59 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Thu, 15 Oct 2015 15:44:59 +0200 Subject: How to repeat a loop once it is finished In-Reply-To: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> References: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> Message-ID: <561FADDB.1060500@shopzeus.com> > what would be a small thing that I could add to make this thing run again? Something like this? TERMINATOR = "STOP" def read_int(prompt,minvalue,maxvalue): while True: answer = raw_input(prompt) if answer.lower().strip() == TERMINATOR.lower().strip(): print "User abort." raise SystemExit(0) try: result = int(answer) if resultmaxvalue: print "Only number between %s and %s are accepted."%(minvalue,maxvalue) continue except ValueError: print "That is not a number." continue return result def main(): h = read_int("Enter height between 2 and 6:",2,6) l = read_int("Enter length between 2 and 6:",1,25) price = read_int("Enter price of paing Luxury=170, economy = 45:",1,200) y = h*l*price print (y/100 + 0.5) # If you want to do this multiple times: print("\n\nYou can terminate anytime by giving %s as the answer.\n\n"%TERMINATOR) while True: main() From gunjal.satish at gmail.com Thu Oct 15 09:48:17 2015 From: gunjal.satish at gmail.com (gunjal.satish at gmail.com) Date: Thu, 15 Oct 2015 06:48:17 -0700 (PDT) Subject: Adding Bottle framework in existing python script Message-ID: In my python script I am doing bluetooth and RF communication on individual threads respectively. I want to add Rest Web Method in same script using Bottle web framework. If I add below code, in existing python script, it wont work. How to make it work in existing script. from bottle import Bottle, run app = Bottle() @app.route('/hello') def hello(): return "Hello World!" run(app, host='localhost', port=8080, debug = True) From breamoreboy at yahoo.co.uk Thu Oct 15 09:51:05 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 15 Oct 2015 14:51:05 +0100 Subject: How to repeat a loop once it is finished In-Reply-To: References: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> Message-ID: On 15/10/2015 14:31, abbasmo at centralfoundationboys.co.uk wrote: > if you could write a small piece of code for me it would great > If you used your favourite search engine in an attempt to write the code before you ask questions about it, then that would be even better. Knowing what piece of code would also help us to help you. As a starter here is a small piece of code. a = 1 Is that adequate? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From vjdeluccie at gmail.com Thu Oct 15 10:04:31 2015 From: vjdeluccie at gmail.com (vjdeluccie at gmail.com) Date: Thu, 15 Oct 2015 14:04:31 +0000 Subject: =?utf-8?Q?issues_with_Python?= Message-ID: <561fb5ea.c6a66b0a.ac30.14c9@mx.google.com> I am using the Python Programming third edition for absolute beginners. I was able to create my Game over program, but I do not have the start menu with the icons and cannot seem to find it. I have the Shell and the script mode but I am not able to find the start menu with the icons the book speaks of. When I try to edit the Idle/Shell screen I cannot. I am un installing and going to re-install, but wanted you to be aware. Sent from Windows Mail -------------- next part -------------- An HTML attachment was scrubbed... URL: From abbasmo at centralfoundationboys.co.uk Thu Oct 15 10:06:05 2015 From: abbasmo at centralfoundationboys.co.uk (abbasmo at centralfoundationboys.co.uk) Date: Thu, 15 Oct 2015 07:06:05 -0700 (PDT) Subject: How to repeat a loop once it is finished In-Reply-To: References: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> Message-ID: could you change it to python v3.4 From denismfmcmahon at gmail.com Thu Oct 15 10:19:29 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 15 Oct 2015 14:19:29 +0000 (UTC) Subject: How to repeat a loop once it is finished References: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> Message-ID: On Thu, 15 Oct 2015 14:51:05 +0100, Mark Lawrence wrote: > On 15/10/2015 14:31, abbasmo at centralfoundationboys.co.uk wrote: >> if you could write a small piece of code for me it would great >> >> > If you used your favourite search engine in an attempt to write the code > before you ask questions about it, then that would be even better. > Knowing what piece of code would also help us to help you. As a starter > here is a small piece of code. > > a = 1 > > Is that adequate? If not, perhaps: b = [c for c in range(20)] d = {e:b for e in b} can help? -- Denis McMahon, denismfmcmahon at gmail.com From denismfmcmahon at gmail.com Thu Oct 15 10:27:58 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 15 Oct 2015 14:27:58 +0000 (UTC) Subject: How to repeat a loop once it is finished References: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> Message-ID: On Thu, 15 Oct 2015 06:29:24 -0700, abbasmo wrote: > what would be a small thing that I could add to make this thing run > again? See what happens when you run the following code. Then adapt it to your application. stop = False while not stop: x = input("enter something, quit, stop or end to exit: ") print("you entered: ", x) if x in ["stop","quit","end"]: stop = True print("Finished now") -- Denis McMahon, denismfmcmahon at gmail.com From jcasale at activenetwerx.com Thu Oct 15 10:38:54 2015 From: jcasale at activenetwerx.com (Joseph L. Casale) Date: Thu, 15 Oct 2015 14:38:54 +0000 Subject: Enum class In-Reply-To: References: <1444908477659.65832@activenetwerx.com>, Message-ID: <1444919934418.62509@activenetwerx.com> >>>> import enum >>>> class M(enum.EnumMeta): >... def __contains__(self, value): >... print("checking", value) >... return super().__contains__(value) >... >>>> class Colors(enum.Enum, metaclass=M): >... red = 1 >... green = 2 >... blue = 3 >... >>>> Colors.red in Colors >checking Colors.red >True > >Is that what you're asking for? If not can you give an example? Hi Peter, That is exactly what I was referring to, I just wondered if I overlooked some way to apply it after the initial meta class built the instance. It appears not... Thanks! jlc From ian.g.kelly at gmail.com Thu Oct 15 10:44:40 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 15 Oct 2015 08:44:40 -0600 Subject: How to implement an async message bus In-Reply-To: <561F8D2E.10600@shopzeus.com> References: <561F8D2E.10600@shopzeus.com> Message-ID: On Thu, Oct 15, 2015 at 5:25 AM, Nagy L?szl? Zsolt wrote: > I'm new to Python 3.5 async / await syntax. I would like to create a class - > let's call it AsyncBus - that can be used to listen for keys, and send > messages for keys ansynchronously. > > class BusTimeoutError(Exception): > pass > > class AsyncBus(object): > def __init__(self, add_timeout): > """add_timeout should be a function that uses the current event loop > implementation to call back" > .... > > async def notify(self, key, message): > """Notify a single waiter about a key. Return if somebody was > waiting for it.""" > .... > > async def notifyall(self, key, message): > """Notify all waiters. Return the number of waiters notified.""" > .... > > async def waitfor(self, keys, timeout=None): > """Wait until a message comes in for any of the given key(s). Raise > BusTimeoutError after the given timedelta.""" > .... > > > Internally, the waitfor method would use the add_timeout to resume itself > and raise the BusTimeoutError exception after the given timeout, and this > should be the only place where a periodic (system time based) sleep would > occur. The notify/notifyall methods would also resume execution in waitfor() > call(s), but they would provide the message for the waiter instead of > raising an exception. My first instinct is to suggest that you not reinvent the wheel and point you at the asyncio.Condition class. However, it apparently doesn't support setting a timeout on wait, which seems odd since the threading.Condition class that it's based on does. You could use asyncio.wait to wait for it with a timeout, but that wouldn't remove the waiter from the Condition. Maybe this would be a useful feature request + patch. > Question is: how to write the AsyncBus class? Here is what I have tried - > but I don't know how to create the waiter object at the bottom. > > > class BusTimeoutError(Exception): > """Raised when the waiter has been waiting for too long.""" > pass > > > class AsnycBus(object): > """Asynchronous notification bus.""" > > def __init__(self, add_timeout): > self._waiters = {} > self._add_timeout = add_timeout > > async def notify(self, key, message): > """Notify a single waiter. Return if there was a waiter waiting for > the key.""" > if key in self._waiters: > self._waiters[key][0].send((key, message)) > return True > else: > return False It looks like you're assuming that the waiter object will be a coroutine and trying to call its send method directly rather than going through the event loop? That seems like a bad idea. In asyncio, a coroutine is something that you can await or schedule with loop.create_task(). Don't try to use those low-level methods. I think a better approach would be to make the waiter a Future and signal it by setting its result. Something like this, as a rough sketch: async def waitfor(self, keys, timeout=None): waiter = asyncio.Future() for key in keys: self._waiters[key].add(waiter) handle = None if timeout: handle = asyncio.call_later(timeout, self._handle_timeout, waiter) try: return await waiter finally: # TODO: Use a context manager to add and remove the keys. for key in keys: self._waiters[key].discard(waiter) if handle: handle.cancel() def notify(self, key, message): if key in self._waiters and self._waiters[key]: waiter = next(iter(self._waiters[key])) waiter.set_result((key, message)) return True return False def _handle_timeout(self, waiter): waiter.set_exception(new BusTimeoutError()) From eryksun at gmail.com Thu Oct 15 10:55:07 2015 From: eryksun at gmail.com (eryksun) Date: Thu, 15 Oct 2015 09:55:07 -0500 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: <561F907D.1090407@yahoo.no> References: <561F907D.1090407@yahoo.no> Message-ID: On 10/15/15, Gisle Vanem wrote: > > This is non-sense. I do have Python2 + 3 both on PATH (but both 32-bits). > Not sure if PyLauncher looks for 64-bit registry entries only. Running "py -3" doesn't use PATH. The launcher only uses PATH when evaluating "/usr/bin/env" in a virtual shebang, e.g. "#!/usr/bin/env python". The version of py.exe distributed with Python 3 is a 32-bit application, so when the debug output says it's looking in the "native" registry, it's referring to the WOW64 redirected registry path, i.e. "HKLM\Software\Wow6432Node\Python". If py.exe can't find your installation of Python 3 in the registry, then the installation is broken or non-standard. Try to repair or reinstall. If python.exe can be found on PATH, then you can use "where python", or open all found folders using a cmd shell for loop: for /f %f in ('where python') do @start "" "%~dpf" > But is there a way for py.exe to use '%USERPROFILE%\Local\py.ini' only? > I failed to find any good documentation on it's format. The launcher looks for py.ini in "%LOCALAPPDATA%", which is "%USERPROFILE%\AppData\Local". The ini file allows setting defaults such as setting "python3=3.5-32" in the [defaults] section. This is documented here: https://docs.python.org/3/using/windows.html#customization-via-ini-files The [commands] section is undocumented, but this section only creates convenience commands for use with shebangs. You can always use the absolute path to an executable in the shebang if you need to associate a script with some other Python implementation, such as PyPy. From vincent at vincentdavis.net Thu Oct 15 11:11:16 2015 From: vincent at vincentdavis.net (Vincent Davis) Date: Thu, 15 Oct 2015 09:11:16 -0600 Subject: write csv to object and read into pandas In-Reply-To: References: Message-ID: That worked, Thanks! Vincent Davis 720-301-3003 On Thu, Oct 15, 2015 at 6:11 AM, Peter Otten <__peter__ at web.de> wrote: > Oscar Benjamin wrote: > > > On 15 October 2015 at 09:16, Peter Otten <__peter__ at web.de> wrote: > >> > >> def preprocess(filename): > >> with open(filename) as f: > >> for row in csv.reader(f): > >> # do stuff > >> yield row > >> > >> rows = preprocess("pandas.csv") > > > > Take the with statement outside of the generator and do something like: > > When will I ever learn :( > > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Oct 15 11:11:49 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 15 Oct 2015 17:11:49 +0200 Subject: Enum class References: <1444908477659.65832@activenetwerx.com> <1444919934418.62509@activenetwerx.com> Message-ID: Joseph L. Casale wrote: >>>>> import enum >>>>> class M(enum.EnumMeta): >>... def __contains__(self, value): >>... print("checking", value) >>... return super().__contains__(value) >>... >>>>> class Colors(enum.Enum, metaclass=M): >>... red = 1 >>... green = 2 >>... blue = 3 >>... >>>>> Colors.red in Colors >>checking Colors.red >>True >> >>Is that what you're asking for? If not can you give an example? > > Hi Peter, > That is exactly what I was referring to, I just wondered if I overlooked > some way to apply it after the initial meta class built the instance. It > appears not... Like that? >>> class M2(enum.EnumMeta): ... def __contains__(self, value): ... print(value, "? never", sep="") ... return False ... >>> Colors.__class__ >>> Colors.red in Colors checking Colors.red True >>> Colors.__class__ = M2 >>> Colors.red in Colors Colors.red? never False From ian.g.kelly at gmail.com Thu Oct 15 11:16:08 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 15 Oct 2015 09:16:08 -0600 Subject: issues with Python In-Reply-To: <561fb5ea.c6a66b0a.ac30.14c9@mx.google.com> References: <561fb5ea.c6a66b0a.ac30.14c9@mx.google.com> Message-ID: On Thu, Oct 15, 2015 at 8:04 AM, wrote: > > I am using the Python Programming third edition for absolute beginners. > I was able to create my Game over program, but I do not have the start menu > with the icons and cannot seem to find it. I have the Shell and the script > mode but I am not able to find the start menu with the icons the book speaks > of. When I try to edit the Idle/Shell screen I cannot. > > I am un installing and going to re-install, but wanted you to be aware. I'm not familiar with the book, but by "start menu" might it mean the *Windows* start menu? From airween at gmail.com Thu Oct 15 11:40:37 2015 From: airween at gmail.com (=?UTF-8?Q?Ervin_Heged=C3=BCs?=) Date: Thu, 15 Oct 2015 17:40:37 +0200 Subject: Extended functions in embedded code In-Reply-To: References: Message-ID: Hi, I've read many docs and examples, then I made a usable test version. If anybody interested about this (and for the mailing list archives), then it could be found here: https://code.activestate.com/recipes/579110-add-function-to-__builtin__-module-through-c-api/ Hope this helps, and many thanks for all help. Cheers, a. ps: after I've done, I realized, that will not good for me :). Nevermind, this was a funny work. On Tue, Oct 13, 2015 at 1:36 PM, Ervin Heged?s wrote: > Hello there, > > I'm interesting for the embeding of Python code - the examples and docs > are very helpfully. The main code, which embeds the Python interpreter, had > written in C. There are several functions, what I have to use in embedded > (Python) code, so I must to write them as Python extension. > > That's no problem - I found a solution for that, I don't need to made (and > I don't _want_) a separated .so file (a new Python module): the extension > in same C source, where the embedded code exists, like this: > > #include > #include > > /* python mymodule */ > static PyObject* > mymodule_usleep(PyObject *self, PyObject *args) > { > ... > } > > ... > static PyMethodDef mymodule_methods[] = { > {"usleep", mymodule_usleep, METH_VARARGS, > mymodule_usleep_doc}, > {NULL, NULL} > }; > > PyMODINIT_FUNC > initmymodule(void) > { > (void) Py_InitModule("mymodule", mymodule_methods); > } > > /* python mymodule */ > > > /* python embedding */ > void foo() { > Py_Initialize(); > initmymodule(); > .... > Py_Finalize(); > } > > /* python embedding */ > > > Then I have a Python file, which the code above calls: > > import mymodule > > def bar(d) > do_something() > mymodule.usleep(10000) > return something > > > Just my "2 cents" question: is there any way to make the extension without > "import" keyword? Or is there a way to leave that? > > > Thanks, > > > a. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gvanem at yahoo.no Thu Oct 15 11:50:46 2015 From: gvanem at yahoo.no (Gisle Vanem) Date: Thu, 15 Oct 2015 17:50:46 +0200 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: References: <561F907D.1090407@yahoo.no> Message-ID: <561FCB56.1070306@yahoo.no> eryksun wrote: > The version of py.exe distributed with Python 3 is a 32-bit > application, so when the debug output says it's looking in the > "native" registry, it's referring to the WOW64 redirected registry > path, i.e. "HKLM\Software\Wow6432Node\Python". If py.exe can't find > your installation of Python 3 in the registry, then the installation > is broken or non-standard. Try to repair or reinstall. Thanks for the detailed info. I fixed some paths under: HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.5-32 Now my Python3.5 almost works. But something is wrong with the Python3 sys.prefix: c:> py -2 -c "import os, sys; print(sys.prefix)" F:\ProgramFiler\Python27 c:> py -3 -c "import os, sys; print(sys.prefix)" F:\ProgramFiler Where should I look for the reason for this? -- --gv From gary719_list1 at verizon.net Thu Oct 15 12:39:58 2015 From: gary719_list1 at verizon.net (Gary Roach) Date: Thu, 15 Oct 2015 09:39:58 -0700 Subject: Pyvenv use Message-ID: <561FD6DE.7050006@verizon.net> Hi all, I needed to switch a projects from python 2.7 to 3.4 and had trouble setting up the virtual environment using the virtualenvwrapper utility. It seemed to want to install python 2.7 no matter what I did. I switched to pyvenv which solved the problem. But I now need to completely clean out the virtual environment and can't seem to figure you how to do this. The utilities like lsvirtualenv and rmvirtualenv are not available and I can no longer find a .vertualenv file. Is anyone conversant enough with pyvenv to help. There are several howto's showing how to use pyvenv to set up a virtual environment but nothing showing how to locate and clean house afterwards. The --clean may work but requires a reinstall. The resulting environment gives error messages when I try using pip to reinstall django or python. Further, trying to start a new project with django-admin.py loads the bin, include and lib directories into the project instead of the normal django setup. django 1.8 Debian 8 (jessie) OS python 3.4 Any help will be sincerely appreciated. Gary R. From gandalf at shopzeus.com Thu Oct 15 13:16:28 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Thu, 15 Oct 2015 19:16:28 +0200 Subject: How to implement an async message bus In-Reply-To: References: <561F8D2E.10600@shopzeus.com> Message-ID: <561FDF6C.9020405@shopzeus.com> >> async def waitfor(self, keys, timeout=None): >> """Wait until a message comes in for any of the given key(s). Raise >> BusTimeoutError after the given timedelta.""" >> .... >> >> >> Internally, the waitfor method would use the add_timeout to resume itself >> and raise the BusTimeoutError exception after the given timeout, and this >> should be the only place where a periodic (system time based) sleep would >> occur. The notify/notifyall methods would also resume execution in waitfor() >> call(s), but they would provide the message for the waiter instead of >> raising an exception. > My first instinct is to suggest that you not reinvent the wheel and > point you at the asyncio.Condition class. However, it apparently > doesn't support setting a timeout on wait, which seems odd since the > threading.Condition class that it's based on does. You could use > asyncio.wait to wait for it with a timeout, but that wouldn't remove > the waiter from the Condition. Maybe this would be a useful feature > request + patch. I can submit a feature request, but I cannot patch the CPython implementation. :-) In order to schedule a callback in the future, you would have to have a standard event loop interface for scheduling. We do have a base class asyncio.BaseEventLoop, but tornado's ioloop is NOT a descendant of it. (It is based on tornado.util.Configureable, which is based on "object"). BaseEventLoop.call_later and tornado.ioloop.IOLoop.add_timeout are similar, but also they are quite different. I'm confused. How they are working together? In order to have a timeout on the asyncio.Condition.wait, the Condition object would have to know how to wait for the given amount of time. But asyncio.call_after and tornado ioloop.add_timeout are fundamentally different. Aren't they? If I use multiple io loops (which is uncommon but possible), then how would the Condition object know what loop should be used for the callback? >> async def notify(self, key, message): >> """Notify a single waiter. Return if there was a waiter waiting for >> the key.""" >> if key in self._waiters: >> self._waiters[key][0].send((key, message)) >> return True >> else: >> return False > It looks like you're assuming that the waiter object will be a > coroutine and trying to call its send method directly rather than > going through the event loop? Well, not exactly. When a message comes in, an external event is generated (in this case: starts with a network I/O interrupt that continues as an event inside tornado's ioloop). So the call chain DOES start in the event loop, and it will eventually calls the send() method of the waiter directly. The call will continue to run in code that writes back response to the client waiting for it and finish that request. Yes, send() is called explicitely. But calling generator.send(None) is equivalent of next(generator), and we do that all the time. Why is that a bad idea? I do not see anywhere in the documentation that send() should not be called. Maybe I'm wrong. > That seems like a bad idea. In asyncio, > a coroutine is something that you can await or schedule with > loop.create_task(). Don't try to use those low-level methods. But here, you refer to BaseEventLoop.create_task(). I cannot use it with tornado. :-( In Tornado, most tasks are not created explicitely. They are started when an external interrupt (http request) comes in. There is also support for "add_timeout" but I guess it does not use asyncio.call_later. Frankly I don't know what is the difference in their implementation. The thing I want to achieve is "suspend me, give back execution to MY CURRENT event loop, and resume me when somebody wants to resume me explicitely (from the same event loop)". This is a basic feature, and I thought it could be implemented in a way that is independent of the event loop implementation. (Just like async, await, yield, send and throw are independent - they can be used with twisted, tornado or BaseEventLoop etc.) > I think a better approach would be to make the waiter a Future and > signal it by setting its result. Something like this, as a rough > sketch: > > async def waitfor(self, keys, timeout=None): > waiter = asyncio.Future() > for key in keys: > self._waiters[key].add(waiter) > handle = None > if timeout: > handle = asyncio.call_later(timeout, self._handle_timeout, waiter) Will this work if I use tornado's ioloop? I'm sorry but I do not see what is the difference between tornado ioloop.add_timeout and asyncio.call_later. Are they fundamentally different? Or can I just use asyncio.call_later and expect that it will work with any event loop implementation? > try: > return await waiter > finally: > # TODO: Use a context manager to add and remove the keys. > for key in keys: > self._waiters[key].discard(waiter) > if handle: > handle.cancel() > > def notify(self, key, message): > if key in self._waiters and self._waiters[key]: > waiter = next(iter(self._waiters[key])) > waiter.set_result((key, message)) I think this is what I needed. I'm going to try this tomorrow. From ian.g.kelly at gmail.com Thu Oct 15 14:53:08 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 15 Oct 2015 12:53:08 -0600 Subject: How to implement an async message bus In-Reply-To: <561FDF6C.9020405@shopzeus.com> References: <561F8D2E.10600@shopzeus.com> <561FDF6C.9020405@shopzeus.com> Message-ID: On Thu, Oct 15, 2015 at 11:16 AM, Nagy L?szl? Zsolt wrote: > In order to schedule a callback in the future, you would have to have a > standard event loop interface for scheduling. We do have a base class > asyncio.BaseEventLoop, but tornado's ioloop is NOT a descendant of it. > (It is based on tornado.util.Configureable, which is based on > "object"). BaseEventLoop.call_later and > tornado.ioloop.IOLoop.add_timeout are similar, but also they are quite > different. I'm confused. How they are working together? In order to have > a timeout on the asyncio.Condition.wait, the Condition object would have > to know how to wait for the given amount of time. But asyncio.call_after > and tornado ioloop.add_timeout are fundamentally different. Aren't they? > If I use multiple io loops (which is uncommon but possible), then how > would the Condition object know what loop should be used for the callback? Sorry, I didn't realize that you were using tornado and not asyncio. Presumably it should be on whatever loop the wait call was awaited in, but I have no idea how compatible asyncio constructs are with tornado event loops. >> It looks like you're assuming that the waiter object will be a >> coroutine and trying to call its send method directly rather than >> going through the event loop? > Well, not exactly. When a message comes in, an external event is > generated (in this case: starts with a network I/O interrupt that > continues as an event inside tornado's ioloop). So the call chain DOES > start in the event loop, and it will eventually calls the send() method > of the waiter directly. The call will continue to run in code that > writes back response to the client waiting for it and finish that > request. Yes, send() is called explicitely. But calling > generator.send(None) is equivalent of next(generator), and we do that > all the time. Why is that a bad idea? I do not see anywhere in the > documentation that send() should not be called. Maybe I'm wrong. I think it's a bad idea because then you're using the generator synchronously (at which point it might as well just be a function) rather than as an asynchronous coroutine. For example: def waiter(): key, message = yield do_something(key, message) waiter().send((key, message)) This is really not very different from: def waiter(key, message): do_something(key, message) waiter(key, message) What if do_something needs to make an async call? Of course it can always just make a call using a callback, but that's so last decade. If you want to express it as a coroutine, then you have to use the first form and then have it yield futures back to the event loop. Problem: any futures yielded from here aren't going to go to the event loop, but to the caller of send. That caller then has to loop on the send call, yielding any futures it gets back to the event loop, and then sending the results back on to waiter again. At this point, you've basically implemented await and you might as well have just used await instead of send in the first place. > The thing I want to achieve is "suspend me, give back execution to MY > CURRENT event loop, and resume me when somebody wants to resume me > explicitely (from the same event loop)". This is a basic feature, and I > thought it could be implemented in a way that is independent of the > event loop implementation. (Just like async, await, yield, send and > throw are independent - they can be used with twisted, tornado or > BaseEventLoop etc.) I think that resuming a generator asynchronously is always going to be dependent on the event loop. Async and await technically don't require an event loop to be used, but they're kind of useless without one. >> I think a better approach would be to make the waiter a Future and >> signal it by setting its result. Something like this, as a rough >> sketch: >> >> async def waitfor(self, keys, timeout=None): >> waiter = asyncio.Future() >> for key in keys: >> self._waiters[key].add(waiter) >> handle = None >> if timeout: >> handle = asyncio.call_later(timeout, self._handle_timeout, waiter) > Will this work if I use tornado's ioloop? I'm sorry but I do not see > what is the difference between tornado ioloop.add_timeout and > asyncio.call_later. Are they fundamentally different? Or can I just use > asyncio.call_later and expect that it will work with any event loop > implementation? I wouldn't expect asyncio.call_later to work with a tornado event loop, but you should be able to use the tornado equivalent to pretty much the same effect. >> try: >> return await waiter >> finally: >> # TODO: Use a context manager to add and remove the keys. >> for key in keys: >> self._waiters[key].discard(waiter) >> if handle: >> handle.cancel() >> >> def notify(self, key, message): >> if key in self._waiters and self._waiters[key]: >> waiter = next(iter(self._waiters[key])) >> waiter.set_result((key, message)) > I think this is what I needed. I'm going to try this tomorrow. Yes, putting aside the asyncio/tornado distinction, I think a Future will still solve the problem for you. From eryksun at gmail.com Thu Oct 15 16:18:28 2015 From: eryksun at gmail.com (eryksun) Date: Thu, 15 Oct 2015 15:18:28 -0500 Subject: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc? In-Reply-To: <561FCB56.1070306@yahoo.no> References: <561F907D.1090407@yahoo.no> <561FCB56.1070306@yahoo.no> Message-ID: On 10/15/15, Gisle Vanem wrote: > > Thanks for the detailed info. I fixed some paths under: > HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.5-32 > > Now my Python3.5 almost works. But something is wrong with the > Python3 sys.prefix: > c:> py -2 -c "import os, sys; print(sys.prefix)" > F:\ProgramFiler\Python27 > > c:> py -3 -c "import os, sys; print(sys.prefix)" > F:\ProgramFiler > > Where should I look for the reason for this? The directory for 32-bit program files is localized to "Programfiler (x86)" in Norwegian. Is Python 3.5 installed in "F:\Programfiler (x86)\Python 3.5"? What's the value of sys.executable? From breamoreboy at yahoo.co.uk Thu Oct 15 16:42:42 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 15 Oct 2015 21:42:42 +0100 Subject: How to repeat a loop once it is finished In-Reply-To: References: <7fdd8dc6-316e-4452-b89d-ef1aa5c180fe@googlegroups.com> Message-ID: On 15/10/2015 15:06, abbasmo at centralfoundationboys.co.uk wrote: > could you change it to python v3.4 > Sorry no, try python 1.5, it's got far fewer bugs. As an alternative, please tell us what the hell you're on about, we're not mind readers. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From admin at hexhost.net Thu Oct 15 18:02:50 2015 From: admin at hexhost.net (James DeVincentis) Date: Thu, 15 Oct 2015 22:02:50 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue Message-ID: <01de01d10795$3a917db0$afb47910$@hexhost.net> Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. From: James DeVincentis [mailto:admin at hexhost.net] Sent: Wednesday, October 14, 2015 12:41 PM To: 'python-list at python.org' Subject: Problem with copy.deepcopy and multiprocessing.Queue I've got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). I've tried 'del' the object before reusing it but it still reallocates to the same address space. I'm at a complete loss. 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: 2015-10-14 17:03:30 APIHTTP WARNING Storing object: -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Oct 15 18:42:49 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 15 Oct 2015 16:42:49 -0600 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: <01de01d10795$3a917db0$afb47910$@hexhost.net> References: <01de01d10795$3a917db0$afb47910$@hexhost.net> Message-ID: On Thu, Oct 15, 2015 at 4:02 PM, James DeVincentis wrote: > > Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. I'll second MRAB's response from yesterday: could it just be reusing space that it has recently freed? As a debugging measure, what happens if you try to keep the objects in memory, e.g. by adding them to some long-lived list? Do you start seeing different addresses? -------------- next part -------------- An HTML attachment was scrubbed... URL: From admin at hexhost.net Thu Oct 15 19:36:14 2015 From: admin at hexhost.net (James DeVincentis) Date: Thu, 15 Oct 2015 23:36:14 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: References: <01de01d10795$3a917db0$afb47910$@hexhost.net> Message-ID: I think I tracked this down and resolved it. It appears taking an object from a multiprocess.Queue and placing it into a queue.Queue is a no-no even if the queue.Queue isn?t shared across processes. I have a series of workers (multiprocessing) that share a multiprocess.Queue across all processes. Each worker has it?s own local queue (Queue.queue) that is shared within only it?s own threads. It appears that when taking an object from a multiprocessing queue and moving it into a Queue.queue it breaks things. I don?t know what or how, but it does. As soon as I switched the local queue to a multiprocess.Queue it fixed the issue. Kind of odd to me. Not sure if anyone wants to look into it. > On Oct 15, 2015, at 5:42 PM, Ian Kelly wrote: > > On Thu, Oct 15, 2015 at 4:02 PM, James DeVincentis wrote: > > > > Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. > > I'll second MRAB's response from yesterday: could it just be reusing space that it has recently freed? > > As a debugging measure, what happens if you try to keep the objects in memory, e.g. by adding them to some long-lived list? Do you start seeing different addresses? From admin at hexhost.net Thu Oct 15 19:39:45 2015 From: admin at hexhost.net (James DeVincentis) Date: Thu, 15 Oct 2015 23:39:45 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: References: <01de01d10795$3a917db0$afb47910$@hexhost.net> Message-ID: <8805B757-86BA-47AE-98A0-A36C70B8D374@hexhost.net> I take that back. It?s not entirely fixed. Something else strange is going on here. More debugging needed. > On Oct 15, 2015, at 6:36 PM, James DeVincentis wrote: > > I think I tracked this down and resolved it. > > It appears taking an object from a multiprocess.Queue and placing it into a queue.Queue is a no-no even if the queue.Queue isn?t shared across processes. > > I have a series of workers (multiprocessing) that share a multiprocess.Queue across all processes. Each worker has it?s own local queue (Queue.queue) that is shared within only it?s own threads. It appears that when taking an object from a multiprocessing queue and moving it into a Queue.queue it breaks things. I don?t know what or how, but it does. As soon as I switched the local queue to a multiprocess.Queue it fixed the issue. > > Kind of odd to me. Not sure if anyone wants to look into it. > >> On Oct 15, 2015, at 5:42 PM, Ian Kelly wrote: >> >> On Thu, Oct 15, 2015 at 4:02 PM, James DeVincentis wrote: >>> >>> Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. >> >> I'll second MRAB's response from yesterday: could it just be reusing space that it has recently freed? >> >> As a debugging measure, what happens if you try to keep the objects in memory, e.g. by adding them to some long-lived list? Do you start seeing different addresses? > > -- > https://mail.python.org/mailman/listinfo/python-list From admin at hexhost.net Thu Oct 15 20:37:50 2015 From: admin at hexhost.net (James DeVincentis) Date: Fri, 16 Oct 2015 00:37:50 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: <01de01d10795$3a917db0$afb47910$@hexhost.net> References: <01de01d10795$3a917db0$afb47910$@hexhost.net> Message-ID: Looking into it, I seem to have found a race condition where a multiprocessing.Queue.get() can get hung waiting for an object even if there are objects in the Queue when being placed into the queue by a forked process and then the process ending quickly. I don?t know how to track this down any farther or fix it. 1. Server gets booted. This spawns the following - API Server - HTTPServer(socketserver.ForkingMixIn, http.server.HTTPServer) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/server.py - Workers - Process(multiprocessing.Process) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L93 2. HTTP Request comes in and is handled by Handler(http.server.BaseHTTPRequestHandler) in this case using do_PUT https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L226 3. Object is created and placed in the global queue: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 4. HTTP Request Process dies since request has been handled. 5. Worker Process has task manager thread that takes the object from a global queue and places it into a local queue https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L64 6. one of many (30+) threads on the worker process picks up the object from the local queue and processes it https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L12 It seems the task management threads are getting hung up waiting for an object from the global queue, even though the global queue has objects in it? Ignore the ERRORS they aren?t actually errors. I did it for temporary visibility. 2015-10-16 00:20:07 Manager #3 ERROR Put into local queue 2015-10-16 00:20:07 Manager #4 ERROR Got from global queue 2015-10-16 00:20:07 Manager #4 ERROR Put into local queue 2015-10-16 00:23:05 Manager #1 ERROR Waiting for item from global queue 2015-10-16 00:23:05 Manager #2 ERROR Waiting for item from global queue 2015-10-16 00:23:05 Manager #3 ERROR Waiting for item from global queue 2015-10-16 00:23:05 Manager #4 ERROR Waiting for item from global queue 2015-10-16 00:23:08 Manager #1 ERROR Got from global queue 2015-10-16 00:23:08 Manager #1 ERROR Put into local queue 2015-10-16 00:23:08 Manager #1 ERROR Waiting for item from global queue 2015-10-16 00:23:08 Manager #2 ERROR Got from global queue 2015-10-16 00:23:08 Manager #2 ERROR Put into local queue 2015-10-16 00:23:08 Manager #2 ERROR Waiting for item from global queue ? Nothing else gets logged by the manager threads at all, even if I continue adding objects to the global queue. 2015-10-16 00:25:00 worker #1 DEBUG Local Queue Size: 0 2015-10-16 00:25:00 worker #3 DEBUG Local Queue Size: 0 2015-10-16 00:25:00 worker #4 DEBUG Local Queue Size: 0 2015-10-16 00:25:00 worker #2 DEBUG Local Queue Size: 0 2015-10-16 00:25:00 MAIN DEBUG Global Queue Size: 572 2015-10-16 00:25:05 worker #1 DEBUG Local Queue Size: 0 2015-10-16 00:25:05 worker #3 DEBUG Local Queue Size: 0 2015-10-16 00:25:05 worker #4 DEBUG Local Queue Size: 0 2015-10-16 00:25:05 worker #2 DEBUG Local Queue Size: 0 2015-10-16 00:25:05 MAIN DEBUG Global Queue Size: 572 > On Oct 15, 2015, at 5:02 PM, James DeVincentis wrote: > > Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. > > From: James DeVincentis [mailto:admin at hexhost.net] > Sent: Wednesday, October 14, 2015 12:41 PM > To: 'python-list at python.org' > Subject: Problem with copy.deepcopy and multiprocessing.Queue > > I?ve got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. > > I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 > > The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). > > This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py > > So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). > > I?ve tried ?del? the object before reusing it but it still reallocates to the same address space. I?m at a complete loss. > > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > 2015-10-14 17:03:30 APIHTTP WARNING Storing object: > > > -- > https://mail.python.org/mailman/listinfo/python-list From briankeithroby at yahoo.com Thu Oct 15 21:08:03 2015 From: briankeithroby at yahoo.com (briankeithroby at yahoo.com) Date: Fri, 16 Oct 2015 01:08:03 +0000 Subject: =?utf-8?Q?Idle_subprocess_error?= Message-ID: <748083.62698.bm@smtp110.mail.ne1.yahoo.com> Idle subprocess error cant use editor. Sent from Windows Mail -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcasale at activenetwerx.com Thu Oct 15 21:52:05 2015 From: jcasale at activenetwerx.com (Joseph L. Casale) Date: Fri, 16 Oct 2015 01:52:05 +0000 Subject: Enum class In-Reply-To: References: <1444908477659.65832@activenetwerx.com> <1444919934418.62509@activenetwerx.com> Message-ID: > Like that? > > >>> class M2(enum.EnumMeta): >... def __contains__(self, value): >... print(value, "? never", sep="") >... return False >... > >>> Colors.__class__ > > >>> Colors.red in Colors > checking Colors.red > True > >>> Colors.__class__ = M2 > >>> Colors.red in Colors > Colors.red? never > False Hah, that's pretty clever:) I was thinking without creating my own meta class, but modifying the Colors class. It's not really a big deal all the solutions here are more than adequate! Thanks a lot Peter, jlc From gandalf at shopzeus.com Fri Oct 16 02:30:39 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Fri, 16 Oct 2015 08:30:39 +0200 Subject: How to implement an async message bus In-Reply-To: References: <561F8D2E.10600@shopzeus.com> <561FDF6C.9020405@shopzeus.com> Message-ID: <5620998F.8000100@shopzeus.com> > Sorry, I didn't realize that you were using tornado and not asyncio. > Presumably it should be on whatever loop the wait call was awaited in, > but I have no idea how compatible asyncio constructs are with tornado > event loops. Exactly. I had the same doubts. > I think it's a bad idea because then you're using the generator > synchronously (at which point it might as well just be a function) > rather than as an asynchronous coroutine. For example: > > def waiter(): > key, message = yield > do_something(key, message) > > waiter().send((key, message)) > > This is really not very different from: > > def waiter(key, message): > do_something(key, message) > > waiter(key, message) I wanted to make a big difference - give back execution to the event loop by the "key, message = yield" statement. But apparently, it is not possible to give back control to the event loop with a simple yield, I would have to yield a Future. (As I said: I'm new to async programming and it was a beginner's mistake.) > > What if do_something needs to make an async call? Of course it can > always just make a call using a callback, but that's so last decade. > If you want to express it as a coroutine, then you have to use the > first form and then have it yield futures back to the event loop. > Problem: any futures yielded from here aren't going to go to the event > loop, but to the caller of send. That caller then has to loop on the > send call, yielding any futures it gets back to the event loop, and > then sending the results back on to waiter again. At this point, > you've basically implemented await and you might as well have just > used await instead of send in the first place. Good point. :-) > >> The thing I want to achieve is "suspend me, give back execution to MY >> CURRENT event loop, and resume me when somebody wants to resume me >> explicitely (from the same event loop)". This is a basic feature, and I >> thought it could be implemented in a way that is independent of the >> event loop implementation. (Just like async, await, yield, send and >> throw are independent - they can be used with twisted, tornado or >> BaseEventLoop etc.) > I think that resuming a generator asynchronously is always going to be > dependent on the event loop. Async and await technically don't require > an event loop to be used, but they're kind of useless without one. Yes, they they need an event loop to be useful. I just wanted them to be independent of the concrete implementation. This is why we have abstract classes like BaseEventLoop, right? I would like to express my idea in a way that uses standard (asyncio) synchronization only, and will work with any event loop implementation. > >>> I think a better approach would be to make the waiter a Future and >>> signal it by setting its result. Something like this, as a rough >>> sketch: >>> >>> async def waitfor(self, keys, timeout=None): >>> waiter = asyncio.Future() >>> for key in keys: >>> self._waiters[key].add(waiter) >>> handle = None >>> if timeout: >>> handle = asyncio.call_later(timeout, self._handle_timeout, waiter) >> Will this work if I use tornado's ioloop? I'm sorry but I do not see >> what is the difference between tornado ioloop.add_timeout and >> asyncio.call_later. Are they fundamentally different? Or can I just use >> asyncio.call_later and expect that it will work with any event loop >> implementation? > I wouldn't expect asyncio.call_later to work with a tornado event > loop, but you should be able to use the tornado equivalent to pretty > much the same effect. And this is why I was confused! asyncio event loop uses asyncio.sleep, tornado uses gen.sleep ( http://www.tornadoweb.org/en/stable/gen.html#tornado.gen.sleep ). asyncio uses "call_later" but tornado uses "add_timeout". This is why I had the add_timeout parameter in my AsyncBus class - tried to make it independent of the event loop implementation. The standard way to get the current event loop is asyncio.get_event_loop(). But then again, we have tornado.ioloop.IOLoop.current(). And they are totally different: ioloop = tornado.ioloop.IOLoop.current() import asyncio def f(): print(asyncio.get_event_loop()) print(ioloop) ioloop.add_timeout(1, f) ioloop.start() Result is: <_WindowsSelectorEventLoop running=False closed=False debug=False> It is so confusing! tornado has added support for async/await in version 4.3, but they do not use the standard library, and they do not call asyncio.set_event_loop. Maybe I could write a wrapper object around tornado's ioloop, and call asyncio.set_event_loop(), but that is not something a normal end user of the library should do, right? I like Python because it is so high level, and so expressive. But I just can't figure out how to write my AsyncBus class in a way that works with asyncio event loops and tornado's ioloop as well. It is very annoying that async, await, yield, Future, Condition, Lock and almost all other async constructs work with any event loop; but simple things like "sleep for 10 seconds" are totally incompatible. But I guess I'll have to live with that for now. Thanks, Laszlo -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Fri Oct 16 03:22:55 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 16 Oct 2015 18:22:55 +1100 Subject: Idle subprocess error In-Reply-To: <748083.62698.bm@smtp110.mail.ne1.yahoo.com> References: <748083.62698.bm@smtp110.mail.ne1.yahoo.com> Message-ID: On Fri, Oct 16, 2015 at 12:08 PM, briankeithroby--- via Python-list wrote: > Idle subprocess error cant use editor. > > > Sent from Windows Mail > Email error insufficient data. Sent from a person who's unable to make something out of nothing. ChrisA From tjreedy at udel.edu Fri Oct 16 03:38:26 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 16 Oct 2015 03:38:26 -0400 Subject: Idle subprocess error In-Reply-To: <748083.62698.bm@smtp110.mail.ne1.yahoo.com> References: <748083.62698.bm@smtp110.mail.ne1.yahoo.com> Message-ID: On 10/15/2015 9:08 PM, briankeithroby--- via Python-list wrote: > Idle subprocess error cant use editor. You probably need to restart IDLE with the -n argument. See the doc. -- Terry Jan Reedy From gandalf at shopzeus.com Fri Oct 16 04:10:33 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Fri, 16 Oct 2015 10:10:33 +0200 Subject: How to implement an async message bus In-Reply-To: <5620998F.8000100@shopzeus.com> References: <561F8D2E.10600@shopzeus.com> <561FDF6C.9020405@shopzeus.com> <5620998F.8000100@shopzeus.com> Message-ID: <5620B0F9.8090808@shopzeus.com> > > It is very annoying that async, await, yield, Future, Condition, Lock > and almost all other async constructs work with any event loop; but > simple things like "sleep for 10 seconds" are totally incompatible. > But I guess I'll have to live with that for now. > Some more incompatibilty: * ioloop.add_timeout accepts a datetime.timedelta for the timeout * asyncio.call_later accepts the number of seconds * handler = asyncio.call_later() stands in pair with handler.cancel() * Tornado's handler = ioloop.add_timeout() stands in pair with ioloop.remove_timeout(handler). Even the syntax is different. It looks like I must write a wrapper or subclasses for different event loop implementations. I strongly feel that because we have a standard abstract base class asyncio.BaseEventLoop for event loops, tornado.IOLoop should be a descendant of it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From antti.lagus at gmail.com Fri Oct 16 04:50:11 2015 From: antti.lagus at gmail.com (Antti Lagus) Date: Fri, 16 Oct 2015 11:50:11 +0300 Subject: pip problem Message-ID: hello, installed pyton3.5 to NOT default folder. tried to install cx_Freeze, but countered errors where pip tried to copy/import stuff from default install location. please fix -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at pearwood.info Fri Oct 16 05:17:51 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 16 Oct 2015 20:17:51 +1100 Subject: pip problem References: Message-ID: <5620c0c1$0$1594$c3e8da3$5496439d@news.astraweb.com> On Fri, 16 Oct 2015 07:50 pm, Antti Lagus wrote: > hello, > > installed pyton3.5 to NOT default folder. > tried to install cx_Freeze, but countered errors where pip tried to > copy/import stuff from default install location. > > please fix Okay, I'm looking into my crystal ball, and I see you're using Windows 95 on a Mac Plus with 1MB of RAM and two floppy disk drives. The crystal ball tells me that the "stuff" you tried to copy was a 2GB .mkv of The Spice Girls Movie, and the error you got was a Guru Meditation Error. Sadly, I think my crystal ball is not working very well today. Perhaps if you tell us what operating system you are using, where you installed Python 3.5, what command you gave to install cx_Freeze, and what errors you got, we might be able to help you a little better. Otherwise, the best I can do is look in the crystal ball, which tells me you need to try turning the computer off and on again. Sorry I can't be of more help. I-knew-I-should-have-paid-more-than-$2.95-for-a-magic-crystal-ball-ly y'rs, -- Steven From gandalf at shopzeus.com Fri Oct 16 05:22:01 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Fri, 16 Oct 2015 11:22:01 +0200 Subject: How to implement an async message bus In-Reply-To: References: <561F8D2E.10600@shopzeus.com> <561FDF6C.9020405@shopzeus.com> Message-ID: <5620C1B9.9080707@shopzeus.com> >>> try: >>> return await waiter >>> finally: >>> # TODO: Use a context manager to add and remove the keys. >>> for key in keys: >>> self._waiters[key].discard(waiter) >>> if handle: >>> handle.cancel() >>> >>> def notify(self, key, message): >>> if key in self._waiters and self._waiters[key]: >>> waiter = next(iter(self._waiters[key])) >>> waiter.set_result((key, message)) >> I think this is what I needed. I'm going to try this tomorrow. > Yes, putting aside the asyncio/tornado distinction, I think a Future > will still solve the problem for you. No, it won't. :-( Finally, I got it working, by replacing asyncio.Future with tornado.concurrent.Future. At least it is consistent. But it is also missing key features. For example, there is no tornado.concurrent.Condition. From lucasfneves14 at gmail.com Fri Oct 16 05:44:37 2015 From: lucasfneves14 at gmail.com (lucasfneves14) Date: Fri, 16 Oct 2015 04:44:37 -0500 Subject: TCP sockets python timeout public IP adresss References: Message-ID: How did you do it? From steve at pearwood.info Fri Oct 16 12:25:03 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sat, 17 Oct 2015 03:25:03 +1100 Subject: Cryptographically strong random numbers Message-ID: <562124e0$0$1597$c3e8da3$5496439d@news.astraweb.com> Hello folks, Over on the Python-Dev mailing list there is an argument going on about PEP 506, the "secrets" module, for generating crypto random numbers and tokens. If you have written crypto code that needs random numbers as described below, I am looking for your feedback. Python-Dev is arguing about which of the following three functions should be included: randbelow(end): return a random integer in the half-open interval 0...end (including 0, excluding end) randint(start, end): return a random integer in the closed interval start...end (including both start and end) randrange([start=0,] end [, step=1]): return a random integer in the half-open range(start, stop, step) It has been claimed that most applications of crypto random numbers will only need to generate them in the half-open range 0...end (excluding end). If you have experience with using crypto random numbers, do you agree? Which of the three functions would you use? Please note that nothing will change about the random module and it's API. If you are worried that random.randint will be removed, or random.randrange, don't be concerned, that is completely off the cards. This discussion is purely about what will be offered in the "secrets" module. https://www.python.org/dev/peps/pep-0506/ -- Steven From marko at pacujo.net Fri Oct 16 13:13:37 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 16 Oct 2015 20:13:37 +0300 Subject: Cryptographically strong random numbers References: <562124e0$0$1597$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87eggulose.fsf@elektro.pacujo.net> Steven D'Aprano : > Python-Dev is arguing about which of the following three functions should be > included: > > randbelow(end): > return a random integer in the half-open interval 0...end > (including 0, excluding end) > > randint(start, end): > return a random integer in the closed interval start...end > (including both start and end) > > randrange([start=0,] end [, step=1]): > return a random integer in the half-open range(start, stop, step) > > > It has been claimed that most applications of crypto random numbers > will only need to generate them in the half-open range 0...end > (excluding end). If you have experience with using crypto random > numbers, do you agree? Which of the three functions would you use? I wouldn't really ever *need* anything but randbelow(). It has the most natural semantics for "end." However, why not emulate the random module? secrets.randrange(stop) secrets.randrange(start, stop[, step]) secrets.randint(a, b) IOW, keep each function and name them (as well as the arguments) exactly the same. Marko From blindanagram at nowhere.net Fri Oct 16 13:17:59 2015 From: blindanagram at nowhere.net (Brian Gladman) Date: Fri, 16 Oct 2015 18:17:59 +0100 Subject: Cryptographically strong random numbers In-Reply-To: <562124e0$0$1597$c3e8da3$5496439d@news.astraweb.com> References: <562124e0$0$1597$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 16/10/2015 17:25, Steven D'Aprano wrote: > Hello folks, [snip detail] > randbelow(end): > return a random integer in the half-open interval 0...end > (including 0, excluding end) > > randint(start, end): > return a random integer in the closed interval start...end > (including both start and end) > > randrange([start=0,] end [, step=1]): > return a random integer in the half-open range(start, stop, step) I don't see the third option as being of much, if any, use. Either of the first two would be fine. Of these two, I personally prefer randbelow because it is consistent with what I expect from ranges in Python (randint() always disappoints me because it is inconsistent in this respect). From oscar.j.benjamin at gmail.com Fri Oct 16 13:22:15 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Fri, 16 Oct 2015 17:22:15 +0000 Subject: Cryptographically strong random numbers In-Reply-To: <87eggulose.fsf@elektro.pacujo.net> References: <562124e0$0$1597$c3e8da3$5496439d@news.astraweb.com> <87eggulose.fsf@elektro.pacujo.net> Message-ID: On Fri, 16 Oct 2015 18:16 Marko Rauhamaa wrote: Steven D'Aprano : > Python-Dev is arguing about which of the following three functions should be > included: > > randbelow(end): > return a random integer in the half-open interval 0...end > (including 0, excluding end) > > randint(start, end): > return a random integer in the closed interval start...end > (including both start and end) > > randrange([start=0,] end [, step=1]): > return a random integer in the half-open range(start, stop, step) > > > It has been claimed that most applications of crypto random numbers > will only need to generate them in the half-open range 0...end > (excluding end). If you have experience with using crypto random > numbers, do you agree? Which of the three functions would you use? I wouldn't really ever *need* anything but randbelow(). It has the most natural semantics for "end." However, why not emulate the random module? secrets.randrange(stop) secrets.randrange(start, stop[, step]) secrets.randint(a, b) IOW, keep each function and name them (as well as the arguments) exactly the same. Given that the random module API won't change and is already known by many people that would be simple to understand. Also it makes it trivially easy to correct insecure RNG usage where needed. -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From pkpearson at nowhere.invalid Fri Oct 16 13:26:04 2015 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 16 Oct 2015 17:26:04 GMT Subject: Cryptographically strong random numbers References: <562124e0$0$1597$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, 17 Oct 2015 03:25:03 +1100, Steven D'Aprano wrote: [snip] > randbelow(end): > return a random integer in the half-open interval 0...end > (including 0, excluding end) > > randint(start, end): > return a random integer in the closed interval start...end > (including both start and end) > > randrange([start=0,] end [, step=1]): > return a random integer in the half-open range(start, stop, step) Having done quite a bit of serious crypto implementation over the past 25 years, I don't recall ever wanting anything like randrange, and if I *did* need it, I'd probably build it inline from randbelow rather than force some hapless future code maintainer to look up the specs on randrange. My opinion, FWIW: I like randbelow, because in modern crypto one very frequently works with integers in the range [0,M-1] for some large modulus M, and there is a constant risk of asking for something in [0,M] when one meant [0,M-1]. One can eliminate this risk, as randbelow does, by building in the -1, which normally introduces a risk of making a mistake that gives you [0,M-2], but the name "randbelow" seems like a neat fix to that problem. I can see the attraction of randint for programming languages that have limited ranges of integers, since randint lets you specify the whole range of positive integers without having to pass an argument that is outside that range. Take a moment to savor the joy of Python. -- To email me, substitute nowhere->runbox, invalid->com. From denismfmcmahon at gmail.com Fri Oct 16 13:30:35 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Fri, 16 Oct 2015 17:30:35 +0000 (UTC) Subject: pip problem References: Message-ID: On Fri, 16 Oct 2015 11:50:11 +0300, Antti Lagus wrote: > hello, > > installed pyton3.5 to NOT default folder. > tried to install cx_Freeze, but countered errors where pip tried to > copy/import stuff from default install location. > > please fix Hi, I waved my magic wand, and your problem should be fixed. If your problem is not fixed, manual intervention may be needed. We can probably tell you what you need to do, but more details of the problem are needed first. What OS? Where did you get python from and What command are you using to install it? Do you have all the permissions needed to write to the directories you're asking it to put files in? Did you run the installation process with those permissions? -- Denis McMahon, denismfmcmahon at gmail.com From frederickauthur at hotmail.com Fri Oct 16 13:59:13 2015 From: frederickauthur at hotmail.com (513-3M1L1X- TR19) Date: Fri, 16 Oct 2015 18:59:13 +0100 Subject: No subject Message-ID: Hello I was trying to install python35 on my windows laptop and I am told that the python35.dll files is missing Tried to repair many times but still the same problem. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jon+usenet at unequivocal.co.uk Fri Oct 16 14:10:03 2015 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Fri, 16 Oct 2015 18:10:03 +0000 (UTC) Subject: Cryptographically strong random numbers References: <562124e0$0$1597$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2015-10-16, Steven D'Aprano wrote: > If you have written crypto code that needs random numbers as described > below, I am looking for your feedback. > > Python-Dev is arguing about which of the following three functions should be > included: > > randbelow(end): > return a random integer in the half-open interval 0...end > (including 0, excluding end) > > randint(start, end): > return a random integer in the closed interval start...end > (including both start and end) > > randrange([start=0,] end [, step=1]): > return a random integer in the half-open range(start, stop, step) > > > It has been claimed that most applications of crypto random numbers will > only need to generate them in the half-open range 0...end (excluding end). > If you have experience with using crypto random numbers, do you agree? > Which of the three functions would you use? Given that the latter incorporates all of the functionality of the former two without being noticeably more complicated, I don't see why it isn't the obvious one to go for. Also, isn't uuid4() an obvious shoo-in for this module too? From breamoreboy at yahoo.co.uk Fri Oct 16 17:31:16 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 16 Oct 2015 22:31:16 +0100 Subject: pip problem In-Reply-To: References: Message-ID: On 16/10/2015 09:50, Antti Lagus wrote: > hello, > > installed pyton3.5 to NOT default folder. > tried to install cx_Freeze, but countered errors where pip tried to > copy/import stuff from default install location. > > please fix > Please fix what? What do you think we are? No mention of your platform, nothing precise about what you've tried or the precise error message(s). Please try again, this isn't stackoverflow or reddit, you'll find professionals here who work on facts. -- 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 Oct 16 17:32:44 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 16 Oct 2015 22:32:44 +0100 Subject: TCP sockets python timeout public IP adresss In-Reply-To: References: Message-ID: On 16/10/2015 10:44, lucasfneves14 wrote: > How did you do it? > I conned my way in, nobody suspected it. -- 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 Fri Oct 16 17:45:16 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 16 Oct 2015 21:45:16 +0000 (UTC) Subject: TCP sockets python timeout public IP adresss References: Message-ID: On 2015-10-16, lucasfneves14 wrote: > How did you do it? I just climbed in and pushed the button. Same as always. -- Grant Edwards grant.b.edwards Yow! This MUST be a good at party -- My RIB CAGE is gmail.com being painfully pressed up against someone's MARTINI!! From prajoshi at microsoft.com Fri Oct 16 18:34:52 2015 From: prajoshi at microsoft.com (Prasad Joshi) Date: Fri, 16 Oct 2015 22:34:52 +0000 Subject: help(string) commands not working on pyton 3.5 In-Reply-To: References: Message-ID: Thanks for the reply. I am using windows 10. >>> import math >>> >>> >>> help (math) 'more' is not recognized as an internal or external command, operable program or batch file. >>> help Type help() for interactive help, or help(object) for help about object. >>> help(math) 'more' is not recognized as an internal or external command, operable program or batch file. >>> >>> help(print) 'more' is not recognized as an internal or external command, operable program or batch file. >>> Also help worked when I switched to plain integer as you mentioned below but looks like it didn't save it. Btw - I am pretty new to python hence asking these questions. Thanks again! Prasad Joshi. -----Original Message----- From: eryksun [mailto:eryksun at gmail.com] Sent: Thursday, October 15, 2015 5:41 AM To: python-list at python.org Cc: Prasad Joshi Subject: Re: help(string) commands not working on pyton 3.5 On 10/14/15, Prasad Joshi wrote: > Hi, > > I have installed the "Windows x86-64 executable > installer" > on my desktop but I cannot get help ( ) or help (string) command working. > What could be an issue? > It may help to know which version of Windows you're using -- XP, Vista, 7, 8, or 10? help() may work after switching to a plain pager: import pydoc pydoc.pager = pydoc.plainpager in which case, check whether the following prints "test": pydoc.tempfilepager('test', 'more <') If not, please reply with the traceback or error message, if any. From random832 at fastmail.com Fri Oct 16 18:57:55 2015 From: random832 at fastmail.com (Random832) Date: Fri, 16 Oct 2015 18:57:55 -0400 Subject: TCP sockets python timeout public IP adresss References: Message-ID: <87pp0ewhe4.fsf@fastmail.com> lucasfneves14 writes: > How did you do it? That's an impressive reply gap. If anyone's wondering, this is apparently in reply to this from March: http://thread.gmane.org/gmane.comp.python.general/774441 From eryksun at gmail.com Fri Oct 16 19:02:17 2015 From: eryksun at gmail.com (eryksun) Date: Fri, 16 Oct 2015 18:02:17 -0500 Subject: help(string) commands not working on pyton 3.5 In-Reply-To: References: Message-ID: On 10/16/15, Prasad Joshi wrote: > > I am using windows 10. > >>>> import math >>>> >>>> >>>> help (math) > 'more' is not recognized as an internal or external command, > operable program or batch file. What do you get for the following? import os windir = os.environ['SystemRoot'] more_path = os.path.join(windir, 'System32', 'more.com') print(os.path.exists(more_path)) If more.com doesn't exist, your Windows installation needs to be repaired. If it does exist, then probably PATHEXT is missing .COM. Ensure it's listed in the output of the following: import os print(os.environ['PATHEXT']) From sohcahtoa82 at gmail.com Fri Oct 16 20:49:56 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Fri, 16 Oct 2015 17:49:56 -0700 (PDT) Subject: TCP sockets python timeout public IP adresss In-Reply-To: References: Message-ID: <88d83374-7325-4ffe-a3cc-f97941b48415@googlegroups.com> On Friday, October 16, 2015 at 2:44:53 AM UTC-7, lucasfneves14 wrote: > How did you do it? I took the advice of just being myself. From gheskett at wdtv.com Sat Oct 17 00:59:06 2015 From: gheskett at wdtv.com (Gene Heskett) Date: Sat, 17 Oct 2015 00:59:06 -0400 Subject: Idle subprocess error In-Reply-To: References: <748083.62698.bm@smtp110.mail.ne1.yahoo.com> Message-ID: <201510170059.06105.gheskett@wdtv.com> On Friday 16 October 2015 03:22:55 Chris Angelico wrote: > On Fri, Oct 16, 2015 at 12:08 PM, briankeithroby--- via Python-list > > wrote: > > Idle subprocess error cant use editor. > > > > > > Sent from Windows Mail > > Email error insufficient data. > > Sent from a person who's unable to make something out of nothing. > > ChrisA Not even a molehill? 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 manjunatha.mahalingappa at gmail.com Sat Oct 17 01:47:18 2015 From: manjunatha.mahalingappa at gmail.com (manjunatha.mahalingappa at gmail.com) Date: Fri, 16 Oct 2015 22:47:18 -0700 (PDT) Subject: How to log the output from the multiple telnet sessions to separate log file Message-ID: Hello All, I'm very much new to python. I'm doing the automation for networking device testing , I will be opening the 4 telnet session, and doing some testing operations on each of those telnet sessions and capture or log the respective output in 4 different log files. As of now all the 4 log files have the same content kindly help me to log the output respective log file. Code snippet is given below: ---------------------------------------- import sys import PmTelnet2 import logging import re import time class Logger(): def __init__(self,log): self.terminal = sys.stdout self.log = log def write(self, message): self.terminal.write(message) self.log.write(message) #This function is to open the telnet session and open the file for each device. def IP_port(file) : global Testbed_info Testbed_info = [] F = open(file, 'r') F.seek(0) line = F.read() tuples = re.findall(r'(.+ \d)\s+(.+?)\s+(\d+)', line) for (dname, ip, port) in tuples : logfile = dname.replace(" ","") + ".log" log = open(logfile, "a") Telnet_handle=PmTelnet2.TelnetSession(ip,port) sys.stdout =Logger(log) tuple = (dname, ip, port, Telnet_handle) Testbed_info.append(tuple) #T.append(T1) return(Testbed_info) # Here I'm passing the device name, IP, port details using the IP_port.txt file file = '/users/manmahal/MANJU/IP_port.txt' Testbed_info = IP_port(file) #Here I'm using the telnet object to execute some command, What ever I execute here on each telnet session to be logged into separate log file. for (dname, ip, port, Telnet, fp ) in Testbed_info : My_handle = Telnet My_handle.Write("\n") My_handle.Write("show config \n") time.sleep(2) print My_handle.ReadBuffer() Content of the IP_port file is as below: ----------------------------------------------------- RSP 0 172.27.40.60 2001 RSP 1 172.27.40.60 2002 LC 0 172.27.40.60 2010 LC 1 172.27.40.59 2011 Please note that total number of the telnet session may change as requirement of Testing. Hence It would be great if some give me generic solution to log the log messages for each telnet session and output should to logged into respective log file. Thanks in advance...!! Regards Manju From rosuav at gmail.com Sat Oct 17 02:05:48 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 17 Oct 2015 17:05:48 +1100 Subject: How to log the output from the multiple telnet sessions to separate log file In-Reply-To: References: Message-ID: On Sat, Oct 17, 2015 at 4:47 PM, wrote: > class Logger(): > def __init__(self,log): > self.terminal = sys.stdout > self.log = log > > def write(self, message): > self.terminal.write(message) > self.log.write(message) > > > for (dname, ip, port) in tuples : > sys.stdout =Logger(log) Every time you construct a Logger, it snapshots the previous value of sys.stdout. By the time you've set them all up, sys.stdout is the last Logger created, which will chain to the one created previous to it, then the one before that, and finally to the actual console. Do you need to use sys.stdout at all? It would be a lot easier to ignore stdout and just write your logs directly to files. ChrisA From dieter at handshake.de Sat Oct 17 02:10:52 2015 From: dieter at handshake.de (dieter) Date: Sat, 17 Oct 2015 08:10:52 +0200 Subject: How to log the output from the multiple telnet sessions to separate log file References: Message-ID: <87r3ku6n4j.fsf@handshake.de> manjunatha.mahalingappa at gmail.com writes: > I'm very much new to python. > I'm doing the automation for networking device testing , I will be opening the 4 telnet session, and doing some testing operations on each of those telnet sessions and capture or log the respective output in 4 different log files. Personally, I find it a bit strange that each (telnet) session should get its own logfile, but, if that is what you need, I would approach it as follows: * define a class "TelnetSession"; create a logger in its "__init__" method; use this logger for all operations inside a "TelnetSession" * instantiate the class "TelnetSession" for each telnet session you want to open. Use those objects method to operate on the sessions. From nilsherolindemann at googlemail.com Sat Oct 17 09:23:27 2015 From: nilsherolindemann at googlemail.com (Nils-Hero Lindemann) Date: Sat, 17 Oct 2015 15:23:27 +0200 Subject: Python 3.5.0 Feedback Message-ID: <20151017152327.de19a922.nilsherolindemann@gmail.com> Hallo, Zuerst mal, ein dickes Danke an alle, die an Python mitarbeiten! Hier ein paar Dinge, die mir an 3.5.0 aufgefallen sind (ich komme von 3.2.3): === Informitis === * Die Namen der Links im Startmen? und die erste Zeile der interaktiven Kommandozeile sind von (noch gr??erer) Informitis befallen. Wie auch schon die Doku seit langem. Informitis: Informationen im unpassenden Format an eine unpassende Stelle setzen. === Symbole === * Die Python-Dateien haben keine Symbole im Explorer. * Das Symbol von IDLE is grau und wenig ansehnlich. * In der Symboleiste: 16x16 Symbole von Kommandozeilen haben einen schwarzen "Schmutzfleck" oben links. Gr??lich! === Installer === * Der neue Installer l?sst beim Vorkompilieren nicht mehr die gerade kompilierten Dateien durchrasen, so wirkt es, als sei der Installer eingefroren. * Auch verwendet der Installer bei der fortgeschrittenen Installation einige Formulierungen, die schwer zu verstehen sein k?nnten: "requires Elevation" (Was ist "Elevation"? leo.org gibt nur: "Erh?hung") "Install Debugging Symbols" (Was sind Debugging Symbole? Icons?) "Create Shortcuts for installed applications" (Das sollte "create shortcuts in Startmenu and on Desktop" sein) === HTML Doku === * JavaScript-Suchfunktion der HTML Doku zeigt in der Beschreibung von gefundenen Links Dinge wie '===== (etc)' an. * Globale Funktionen wie 'open' sind nicht mehr an der ersten Stelle bei der Suche (welches Sie zwischendurch mal waren, glaube ich). === Bugs === * Python 3.5 vertr?gt a=input('\n') nicht. Gru?, Nils -- Nils-Hero Lindemann From glennmschultz at gmail.com Sat Oct 17 10:08:46 2015 From: glennmschultz at gmail.com (Glenn Schultz) Date: Sat, 17 Oct 2015 07:08:46 -0700 (PDT) Subject: New to Python and setting up Message-ID: <71f45d79-f1c7-4196-a543-d9932b7b3cfc@googlegroups.com> Hello All, I am setting a Python deployment which is a refactor of an R package which I programmed (BondLab). Below is the github link to the python bond lab https://github.com/glennmschultz/Bond_Lab Following the example of Ivan7777 I have setup A folder structure. My understand is that if each folder has an __init__.py From what it is considered a module. Have I set this up correctly? In the time_value module I have a function present_value_factor. I am having trouble documenting the function. How is this done? Finally, I have read something to the effect that when creating a deployment locally use a virtual environment but I am not sure what that means in this case. What is the workflow here? I am having a hard time finding good primers on the subject. I would like to get Bond Lab python up to speed before I open BondLab R. Basically, the idea is to let them shoot it out (Bond Lab Py and BondLab R) for supremacy. Thanks, Glenn From jeffarcher7 at gmail.com Sat Oct 17 12:25:01 2015 From: jeffarcher7 at gmail.com (Jeff Archer) Date: Sat, 17 Oct 2015 12:25:01 -0400 Subject: Trying to build Python Message-ID: I am trying to build Python on windows. I have gotten the source in compressed form, Python-3.5.0.tgz. Attempting to follow PCBuild\readme.txt Ran the get_externals.bat in the PCBuild folder. No apparent errors. Trying to build and getting errors: 1> abort: there is no Mercurial repository here (.hg not found) 1>C:\Dev.ThirdParty\Python-3.5.0\PCbuild\pythoncore.vcxproj(403,5): warning MSB3073: The command "hg id -b > "C:\Dev.ThirdParty\Python-3.5.0\PCbuild\obj\\win32_Debug\pythoncore\hgbranch.txt"" exited with code 255. 1> abort: there is no Mercurial repository here (.hg not found) 1>C:\Dev.ThirdParty\Python-3.5.0\PCbuild\pythoncore.vcxproj(404,5): warning MSB3073: The command "hg id -i > "C:\Dev.ThirdParty\Python-3.5.0\PCbuild\obj\\win32_Debug\pythoncore\hgversion.txt"" exited with code 255. 1> abort: there is no Mercurial repository here (.hg not found) Seems like this is indicating that I need to get the source from a Mercurial repo to be able to built it. Windows 8.1 Visual Studio 2015 -------------- next part -------------- An HTML attachment was scrubbed... URL: From manjunatha.mahalingappa at gmail.com Sat Oct 17 13:19:48 2015 From: manjunatha.mahalingappa at gmail.com (manjunatha.mahalingappa at gmail.com) Date: Sat, 17 Oct 2015 10:19:48 -0700 (PDT) Subject: How to log the output from the multiple telnet sessions to separate log file In-Reply-To: References: Message-ID: <71766066-8b6f-4ee0-8078-9b13d7caea22@googlegroups.com> On Friday, October 16, 2015 at 11:06:24 PM UTC-7, Chris Angelico wrote: > On Sat, Oct 17, 2015 at 4:47 PM, wrote: > > class Logger(): > > def __init__(self,log): > > self.terminal = sys.stdout > > self.log = log > > > > def write(self, message): > > self.terminal.write(message) > > self.log.write(message) > > > > > > for (dname, ip, port) in tuples : > > sys.stdout =Logger(log) > > Every time you construct a Logger, it snapshots the previous value of > sys.stdout. By the time you've set them all up, sys.stdout is the last > Logger created, which will chain to the one created previous to it, > then the one before that, and finally to the actual console. > > Do you need to use sys.stdout at all? It would be a lot easier to > ignore stdout and just write your logs directly to files. > > ChrisA Hello ChrisA, Thank you so much for the replay, objective is to collect all terminal output, if we have any other option to do the same with out using stdout your most welcome to suggest me. Regards Manju From manjunatha.mahalingappa at gmail.com Sat Oct 17 13:25:05 2015 From: manjunatha.mahalingappa at gmail.com (manjunatha.mahalingappa at gmail.com) Date: Sat, 17 Oct 2015 10:25:05 -0700 (PDT) Subject: How to log the output from the multiple telnet sessions to separate log file In-Reply-To: References: Message-ID: <9caffa57-861e-4a3c-aae8-cdc693f8f16f@googlegroups.com> On Friday, October 16, 2015 at 11:11:58 PM UTC-7, dieter wrote: > manjunatha.mahalingappa at gmail.com writes: > > I'm very much new to python. > > I'm doing the automation for networking device testing , I will be opening the 4 telnet session, and doing some testing operations on each of those telnet sessions and capture or log the respective output in 4 different log files. > > Personally, I find it a bit strange that each (telnet) session > should get its own logfile, but, if that is what you need, I would > approach it as follows: > > * define a class "TelnetSession"; create a logger in its "__init__" method; > use this logger for all operations inside a "TelnetSession" > > * instantiate the class "TelnetSession" for each telnet session you > want to open. > Use those objects method to operate on the sessions. Hello Dieter, Thank you so much for the reply and suggestion.. I believe this approch should work for me..!! thanks for your time.. Regards Manju From andybrookestar at googlemail.com Sat Oct 17 15:42:36 2015 From: andybrookestar at googlemail.com (andybrookestar at googlemail.com) Date: Sat, 17 Oct 2015 12:42:36 -0700 (PDT) Subject: string class variable to sqlite3 Message-ID: i'm mainly a PHP man but playing with python recently! I have a very small class that retrieves data from a very small sqlite3 db called encyclopedia,which has a table called wiki & two field called one & two (yes I know - no imagination, I should get out more!): import sqlite3 class do: def doConn(self): self.conn = sqlite3.connect('encyclopedia') self.myText = "sulphur" print "Opened database successfully"; cursor = self.conn.execute("SELECT * from wiki WHERE one LIKE 'alan turing' ") for row in cursor: print "first field = ", row[0] print "second filed = ", row[1] print "Operation done successfully"; self.conn.close() x = do() x.doConn() #the above works when I pass a string as an argument such as the above where I use 'alan turing' i want to pass an argument as a variable which in PHP could be $somevariable or $this->somevariable which say equal "some string" I have played around with passing self.myText instead of 'alan turing' and it doesn't like it- oh Alan I wish you were here! From breamoreboy at yahoo.co.uk Sat Oct 17 15:59:13 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 17 Oct 2015 20:59:13 +0100 Subject: string class variable to sqlite3 In-Reply-To: References: Message-ID: On 17/10/2015 20:42, andybrookestar--- via Python-list wrote: > i'm mainly a PHP man but playing with python recently! > > I have a very small class that retrieves data from a very small sqlite3 db called encyclopedia,which has a table called wiki & two field called one & two (yes I know - no imagination, I should get out more!): > > > > import sqlite3 > class do: > > > def doConn(self): > > self.conn = sqlite3.connect('encyclopedia') > self.myText = "sulphur" > print "Opened database successfully"; > cursor = self.conn.execute("SELECT * from wiki WHERE one LIKE 'alan turing' ") > for row in cursor: > print "first field = ", row[0] > print "second filed = ", row[1] > print "Operation done successfully"; > self.conn.close() > > > > x = do() > x.doConn() > > #the above works when I pass a string as an argument such as the above where I use 'alan turing' > i want to pass an argument as a variable which in PHP could be $somevariable or $this->somevariable which say equal "some string" > > I have played around with passing self.myText instead of 'alan turing' and it doesn't like it- oh Alan I wish you were here! > From https://docs.python.org/3/library/sqlite3.html t = ('RHAT',) c.execute('SELECT * FROM stocks WHERE symbol=?', t) print(c.fetchone()) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From admin at hexhost.net Sat Oct 17 16:19:15 2015 From: admin at hexhost.net (James DeVincentis) Date: Sat, 17 Oct 2015 20:19:15 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: References: <01de01d10795$3a917db0$afb47910$@hexhost.net> Message-ID: <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> So, whatever is causing this is a bit deeper in the multiprocessing.Queue class. I tried using a non-blocking multiprocessing.Queue.get() by setting the first parameter to false and then catching the queue.Empty exception. For some reason even though there are objects in the queue (as evidenced by multiprocessing.Queue.qsize(), the queue.Empty exception is being thrown. I dug into the multiprocessing.Queue class it looks like when calling multiprocessing.Queue.get() multiprocessing.Queue._poll() is coming up false causing it to throw the Empty exception. However, according to multiprocessing.Queue._sem there are still locks acquired on it thus giving me a multiprocessing.Queue.qsize() > 0. It looks like it is possible for a process to die (which includes that process?s local multiprocessing.Queue._feed() thread) off before multiprocessing.Queue._buffer is fed out using multiprocessing.Queue._feed(). Thoughts from anyone? > On Oct 15, 2015, at 7:37 PM, James DeVincentis wrote: > > Looking into it, I seem to have found a race condition where a multiprocessing.Queue.get() can get hung waiting for an object even if there are objects in the Queue when being placed into the queue by a forked process and then the process ending quickly. > > I don?t know how to track this down any farther or fix it. > > 1. Server gets booted. This spawns the following > - API Server - HTTPServer(socketserver.ForkingMixIn, http.server.HTTPServer) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/server.py > - Workers - Process(multiprocessing.Process) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L93 > > 2. HTTP Request comes in and is handled by Handler(http.server.BaseHTTPRequestHandler) in this case using do_PUT https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L226 > 3. Object is created and placed in the global queue: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 > 4. HTTP Request Process dies since request has been handled. > 5. Worker Process has task manager thread that takes the object from a global queue and places it into a local queue https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L64 > 6. one of many (30+) threads on the worker process picks up the object from the local queue and processes it https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L12 > > It seems the task management threads are getting hung up waiting for an object from the global queue, even though the global queue has objects in it? > > Ignore the ERRORS they aren?t actually errors. I did it for temporary visibility. > > 2015-10-16 00:20:07 Manager #3 ERROR Put into local queue > 2015-10-16 00:20:07 Manager #4 ERROR Got from global queue > 2015-10-16 00:20:07 Manager #4 ERROR Put into local queue > 2015-10-16 00:23:05 Manager #1 ERROR Waiting for item from global queue > 2015-10-16 00:23:05 Manager #2 ERROR Waiting for item from global queue > 2015-10-16 00:23:05 Manager #3 ERROR Waiting for item from global queue > 2015-10-16 00:23:05 Manager #4 ERROR Waiting for item from global queue > 2015-10-16 00:23:08 Manager #1 ERROR Got from global queue > 2015-10-16 00:23:08 Manager #1 ERROR Put into local queue > 2015-10-16 00:23:08 Manager #1 ERROR Waiting for item from global queue > 2015-10-16 00:23:08 Manager #2 ERROR Got from global queue > 2015-10-16 00:23:08 Manager #2 ERROR Put into local queue > 2015-10-16 00:23:08 Manager #2 ERROR Waiting for item from global queue > ? Nothing else gets logged by the manager threads at all, even if I continue adding objects to the global queue. > > > 2015-10-16 00:25:00 worker #1 DEBUG Local Queue Size: 0 > 2015-10-16 00:25:00 worker #3 DEBUG Local Queue Size: 0 > 2015-10-16 00:25:00 worker #4 DEBUG Local Queue Size: 0 > 2015-10-16 00:25:00 worker #2 DEBUG Local Queue Size: 0 > 2015-10-16 00:25:00 MAIN DEBUG Global Queue Size: 572 > > 2015-10-16 00:25:05 worker #1 DEBUG Local Queue Size: 0 > 2015-10-16 00:25:05 worker #3 DEBUG Local Queue Size: 0 > 2015-10-16 00:25:05 worker #4 DEBUG Local Queue Size: 0 > 2015-10-16 00:25:05 worker #2 DEBUG Local Queue Size: 0 > 2015-10-16 00:25:05 MAIN DEBUG Global Queue Size: 572 > > > > >> On Oct 15, 2015, at 5:02 PM, James DeVincentis wrote: >> >> Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. >> >> From: James DeVincentis [mailto:admin at hexhost.net] >> Sent: Wednesday, October 14, 2015 12:41 PM >> To: 'python-list at python.org' >> Subject: Problem with copy.deepcopy and multiprocessing.Queue >> >> I?ve got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. >> >> I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >> >> The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). >> >> This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py >> >> So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). >> >> I?ve tried ?del? the object before reusing it but it still reallocates to the same address space. I?m at a complete loss. >> >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list > > -- > https://mail.python.org/mailman/listinfo/python-list From geneva.storey at fultonind.kyschools.us Sat Oct 17 19:46:10 2015 From: geneva.storey at fultonind.kyschools.us (Storey, Geneva) Date: Sat, 17 Oct 2015 23:46:10 +0000 Subject: teacher need help! Message-ID: [cid:116d034a-818f-4cfe-b051-5e19107197bb] Hello there, I am teaching a coding class to students grades 7-12. We have been using Python, which seems to be a perfect fit. Everything was going great until this week when I began teaching turtle. Suddenly, of the 13 computers that I have, 3 began giving the message on the above screen shot. This is a problem since I have 24 students! I have uninstalled and reinstalled and done all that I know to do. Any suggestions? Thank you in advance for your help, Geneva Geneva Storey Fulton High School Spanish, Mathematics Bulldog Academy -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pastedImage.png Type: image/png Size: 53266 bytes Desc: pastedImage.png URL: From peachykeen2020 at gmail.com Sat Oct 17 23:27:22 2015 From: peachykeen2020 at gmail.com (Peachy Keen) Date: Sat, 17 Oct 2015 20:27:22 -0700 Subject: Where is the menu bar for 3.5? Message-ID: <4dkyyhu668lydy8a48uig9vg.1445138842876@email.android.com> Good evening, I am learning to code and I downloaded Python 3.5 32bit. But I can't find the menu bar and after much frustration I uninstalled the program. I would like to get started again so if you could assist it would be appreciated. Peachy -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Sun Oct 18 02:17:32 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 18 Oct 2015 07:17:32 +0100 Subject: teacher need help! In-Reply-To: References: Message-ID: <5623397C.40205@timgolden.me.uk> On 18/10/2015 00:46, Storey, Geneva wrote: > I am teaching a coding class to students grades 7-12. We have been > using Python, which seems to be a perfect fit. Everything was going > great until this week when I began teaching turtle. Suddenly, of the 13 > computers that I have, 3 began giving the message on the above screen > shot. This is a problem since I have 24 students! I have uninstalled > and reinstalled and done all that I know to do. Any suggestions? Geneva, Thanks for attaching a clear error message. Because of the ways in which this list is published, some people will only see text, not attachments. In this case, you could just cut-and-paste the text (which also, conveniently, includes the Python banner which tells us you're using 32-bit Python 3.5 on Windows). [ The code is from a file on a user's desktop which does: import turtle and the traceback comes from line 2 of a file called turtle.py in c:\windows\system32 with the code: t=turtle.Pen() ] The code seems to be picking up a module called "turtle.py" from the Windows system directory which is presumably some student's file, saved to the wrong location, since its second line is "t=turtle.Pen()". I wouldn't have expected Python to look in system32 for pure-python modules, but that may well be a side-effect of some changes made for Python 3.5. Can I suggest you find the turtle.py module in c:\windows\system32, move it to somewhere more suitable and try the code again? TJG From tjreedy at udel.edu Sun Oct 18 02:30:20 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 18 Oct 2015 02:30:20 -0400 Subject: Where is the menu bar for 3.5? In-Reply-To: <4dkyyhu668lydy8a48uig9vg.1445138842876@email.android.com> References: <4dkyyhu668lydy8a48uig9vg.1445138842876@email.android.com> Message-ID: On 10/17/2015 11:27 PM, Peachy Keen wrote: > Good evening, > > I am learning to code and I downloaded Python 3.5 32bit. But I can't > find the menu bar and after much frustration I uninstalled the program. > I would like to get started again so if you could assist it would be > appreciated. What OS? Windows Command Prompt has no menu bar, so if you run Python interactively on Windows, there is none. You just enter commands. If you use IDLE, the situation is different. -- Terry Jan Reedy From auriocus at gmx.de Sun Oct 18 03:38:13 2015 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sun, 18 Oct 2015 09:38:13 +0200 Subject: Python 3.5.0 Feedback In-Reply-To: References: Message-ID: Am 17.10.15 um 15:23 schrieb Nils-Hero Lindemann: > Hallo, > Zuerst mal, ein dickes Danke an alle, die an Python mitarbeiten! This is an English speaking newsgroup. If you want discussion in German, post to de.comp.lang.python I'm not on Windows myself, so I can't comment on many of your points. > Hier ein paar Dinge, die mir an 3.5.0 aufgefallen sind (ich komme von > 3.2.3): > > === Informitis === > > * Die Namen der Links im Startmen? und die erste Zeile der interaktiven > Kommandozeile sind von (noch gr??erer) Informitis befallen. Wie auch > schon die Doku seit langem. Informitis: Informationen im unpassenden > Format an eine unpassende Stelle setzen. What exactly is the information you think is superfluous in the start menu links and the startup prompt, how should it be? Are you talking about the Windows terminal window or about IDLE? > > === Symbole === > > * Die Python-Dateien haben keine Symbole im Explorer. Are the python files associated with Python, i.e. do they run when you double-click them? If not, there can't be icons. > * Das Symbol von IDLE is grau und wenig ansehnlich. [idle has an ugly icon] -> you are welcome to submit a new design > * In der Symboleiste: 16x16 Symbole von Kommandozeilen haben einen > schwarzen "Schmutzfleck" oben links. Gr??lich! I don't understand what you mean by "the icons of the command line" - does a command line have icons? Are you still talking about IDLE? As said, I'm not on Windows so I can't take a look at what you see. Upload screenshots. > === Installer === > > * Der neue Installer l?sst beim Vorkompilieren nicht mehr die > gerade kompilierten Dateien durchrasen, so wirkt es, als sei der > Installer eingefroren. > > * Auch verwendet der Installer bei der fortgeschrittenen Installation > einige Formulierungen, die schwer zu verstehen sein k?nnten: > > "requires Elevation" > (Was ist "Elevation"? leo.org gibt nur: "Erh?hung") Elevation probably means administrator privileges here, not an increase in altitude:) If so, I agree it should be written as "requires admin rights" or similar > "Install Debugging Symbols" > (Was sind Debugging Symbole? Icons?) "Debug symbols" are additional data that you need if you want to debug *Python itself*, which is written in C, as opposed to debugging your program. Icons are usually not called "symbols" in English in an IT context. > "Create Shortcuts for installed applications" > (Das sollte "create shortcuts in Startmenu and on Desktop" sein) > > === HTML Doku === > > * JavaScript-Suchfunktion der HTML Doku zeigt in der > Beschreibung von gefundenen Links Dinge wie > '===== (etc)' > an. > > * Globale Funktionen wie 'open' sind nicht mehr an der ersten Stelle bei > der Suche (welches Sie zwischendurch mal waren, glaube ich). > > === Bugs === > > * Python 3.5 vertr?gt > a=input('\n') > nicht. What does it mean, it doesn't work? What should happen in your opinion, and what happens? If it is a real bug, submit a ticket at https://bugs.python.org/ Christian From admin at hexhost.net Sun Oct 18 04:22:50 2015 From: admin at hexhost.net (James DeVincentis) Date: Sun, 18 Oct 2015 08:22:50 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> References: <01de01d10795$3a917db0$afb47910$@hexhost.net> <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> Message-ID: I?ve managed to partially confirm this theory. I switched the HTTPServer to use the ThreadingMixIn instead of the ForkingMixIn. This causes the queue to behave correctly. The queue is created before any items are forked, then all of the processes are forked out that support the HTTPServer. It appears to be a problem specifically with forks that come from the HTTPServer using the ForkingMixIn. Now I just need to dig harder and find out what is keeping the handler that flushes the buffer to the connection.pipe before the thread/process terminates from occurring. > On Oct 17, 2015, at 3:19 PM, James DeVincentis wrote: > > So, whatever is causing this is a bit deeper in the multiprocessing.Queue class. I tried using a non-blocking multiprocessing.Queue.get() by setting the first parameter to false and then catching the queue.Empty exception. For some reason even though there are objects in the queue (as evidenced by multiprocessing.Queue.qsize(), the queue.Empty exception is being thrown. > > I dug into the multiprocessing.Queue class it looks like when calling multiprocessing.Queue.get() multiprocessing.Queue._poll() is coming up false causing it to throw the Empty exception. However, according to multiprocessing.Queue._sem there are still locks acquired on it thus giving me a multiprocessing.Queue.qsize() > 0. > > It looks like it is possible for a process to die (which includes that process?s local multiprocessing.Queue._feed() thread) off before multiprocessing.Queue._buffer is fed out using multiprocessing.Queue._feed(). > > Thoughts from anyone? > > >> On Oct 15, 2015, at 7:37 PM, James DeVincentis wrote: >> >> Looking into it, I seem to have found a race condition where a multiprocessing.Queue.get() can get hung waiting for an object even if there are objects in the Queue when being placed into the queue by a forked process and then the process ending quickly. >> >> I don?t know how to track this down any farther or fix it. >> >> 1. Server gets booted. This spawns the following >> - API Server - HTTPServer(socketserver.ForkingMixIn, http.server.HTTPServer) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/server.py >> - Workers - Process(multiprocessing.Process) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L93 >> >> 2. HTTP Request comes in and is handled by Handler(http.server.BaseHTTPRequestHandler) in this case using do_PUT https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L226 >> 3. Object is created and placed in the global queue: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >> 4. HTTP Request Process dies since request has been handled. >> 5. Worker Process has task manager thread that takes the object from a global queue and places it into a local queue https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L64 >> 6. one of many (30+) threads on the worker process picks up the object from the local queue and processes it https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L12 >> >> It seems the task management threads are getting hung up waiting for an object from the global queue, even though the global queue has objects in it? >> >> Ignore the ERRORS they aren?t actually errors. I did it for temporary visibility. >> >> 2015-10-16 00:20:07 Manager #3 ERROR Put into local queue >> 2015-10-16 00:20:07 Manager #4 ERROR Got from global queue >> 2015-10-16 00:20:07 Manager #4 ERROR Put into local queue >> 2015-10-16 00:23:05 Manager #1 ERROR Waiting for item from global queue >> 2015-10-16 00:23:05 Manager #2 ERROR Waiting for item from global queue >> 2015-10-16 00:23:05 Manager #3 ERROR Waiting for item from global queue >> 2015-10-16 00:23:05 Manager #4 ERROR Waiting for item from global queue >> 2015-10-16 00:23:08 Manager #1 ERROR Got from global queue >> 2015-10-16 00:23:08 Manager #1 ERROR Put into local queue >> 2015-10-16 00:23:08 Manager #1 ERROR Waiting for item from global queue >> 2015-10-16 00:23:08 Manager #2 ERROR Got from global queue >> 2015-10-16 00:23:08 Manager #2 ERROR Put into local queue >> 2015-10-16 00:23:08 Manager #2 ERROR Waiting for item from global queue >> ? Nothing else gets logged by the manager threads at all, even if I continue adding objects to the global queue. >> >> >> 2015-10-16 00:25:00 worker #1 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:00 worker #3 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:00 worker #4 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:00 worker #2 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:00 MAIN DEBUG Global Queue Size: 572 >> >> 2015-10-16 00:25:05 worker #1 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:05 worker #3 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:05 worker #4 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:05 worker #2 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:05 MAIN DEBUG Global Queue Size: 572 >> >> >> >> >>> On Oct 15, 2015, at 5:02 PM, James DeVincentis wrote: >>> >>> Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. >>> >>> From: James DeVincentis [mailto:admin at hexhost.net] >>> Sent: Wednesday, October 14, 2015 12:41 PM >>> To: 'python-list at python.org' >>> Subject: Problem with copy.deepcopy and multiprocessing.Queue >>> >>> I?ve got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. >>> >>> I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >>> >>> The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). >>> >>> This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py >>> >>> So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). >>> >>> I?ve tried ?del? the object before reusing it but it still reallocates to the same address space. I?m at a complete loss. >>> >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >> >> -- >> https://mail.python.org/mailman/listinfo/python-list > > -- > https://mail.python.org/mailman/listinfo/python-list From admin at hexhost.net Sun Oct 18 04:33:31 2015 From: admin at hexhost.net (James DeVincentis) Date: Sun, 18 Oct 2015 08:33:31 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> References: <01de01d10795$3a917db0$afb47910$@hexhost.net> <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> Message-ID: Seems I found the cause. os._exit() is used in ForkingMixIn for SocketServer and it?s child classes. Since os._exit() doesn?t flush buffers or clean anything up (hence not running the Finalize hooks that multiprocess.Queue use to make sure data gets flushed), this breaks multiprocess.Queue. https://hg.python.org/cpython/file/3.5/Lib/socketserver.py#l605 https://hg.python.org/cpython/file/3.5/Lib/socketserver.py#l611 Sigh. Now the question is why is it necessary to call os._exit() ? > On Oct 17, 2015, at 3:19 PM, James DeVincentis wrote: > > So, whatever is causing this is a bit deeper in the multiprocessing.Queue class. I tried using a non-blocking multiprocessing.Queue.get() by setting the first parameter to false and then catching the queue.Empty exception. For some reason even though there are objects in the queue (as evidenced by multiprocessing.Queue.qsize(), the queue.Empty exception is being thrown. > > I dug into the multiprocessing.Queue class it looks like when calling multiprocessing.Queue.get() multiprocessing.Queue._poll() is coming up false causing it to throw the Empty exception. However, according to multiprocessing.Queue._sem there are still locks acquired on it thus giving me a multiprocessing.Queue.qsize() > 0. > > It looks like it is possible for a process to die (which includes that process?s local multiprocessing.Queue._feed() thread) off before multiprocessing.Queue._buffer is fed out using multiprocessing.Queue._feed(). > > Thoughts from anyone? > > >> On Oct 15, 2015, at 7:37 PM, James DeVincentis wrote: >> >> Looking into it, I seem to have found a race condition where a multiprocessing.Queue.get() can get hung waiting for an object even if there are objects in the Queue when being placed into the queue by a forked process and then the process ending quickly. >> >> I don?t know how to track this down any farther or fix it. >> >> 1. Server gets booted. This spawns the following >> - API Server - HTTPServer(socketserver.ForkingMixIn, http.server.HTTPServer) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/server.py >> - Workers - Process(multiprocessing.Process) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L93 >> >> 2. HTTP Request comes in and is handled by Handler(http.server.BaseHTTPRequestHandler) in this case using do_PUT https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L226 >> 3. Object is created and placed in the global queue: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >> 4. HTTP Request Process dies since request has been handled. >> 5. Worker Process has task manager thread that takes the object from a global queue and places it into a local queue https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L64 >> 6. one of many (30+) threads on the worker process picks up the object from the local queue and processes it https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L12 >> >> It seems the task management threads are getting hung up waiting for an object from the global queue, even though the global queue has objects in it? >> >> Ignore the ERRORS they aren?t actually errors. I did it for temporary visibility. >> >> 2015-10-16 00:20:07 Manager #3 ERROR Put into local queue >> 2015-10-16 00:20:07 Manager #4 ERROR Got from global queue >> 2015-10-16 00:20:07 Manager #4 ERROR Put into local queue >> 2015-10-16 00:23:05 Manager #1 ERROR Waiting for item from global queue >> 2015-10-16 00:23:05 Manager #2 ERROR Waiting for item from global queue >> 2015-10-16 00:23:05 Manager #3 ERROR Waiting for item from global queue >> 2015-10-16 00:23:05 Manager #4 ERROR Waiting for item from global queue >> 2015-10-16 00:23:08 Manager #1 ERROR Got from global queue >> 2015-10-16 00:23:08 Manager #1 ERROR Put into local queue >> 2015-10-16 00:23:08 Manager #1 ERROR Waiting for item from global queue >> 2015-10-16 00:23:08 Manager #2 ERROR Got from global queue >> 2015-10-16 00:23:08 Manager #2 ERROR Put into local queue >> 2015-10-16 00:23:08 Manager #2 ERROR Waiting for item from global queue >> ? Nothing else gets logged by the manager threads at all, even if I continue adding objects to the global queue. >> >> >> 2015-10-16 00:25:00 worker #1 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:00 worker #3 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:00 worker #4 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:00 worker #2 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:00 MAIN DEBUG Global Queue Size: 572 >> >> 2015-10-16 00:25:05 worker #1 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:05 worker #3 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:05 worker #4 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:05 worker #2 DEBUG Local Queue Size: 0 >> 2015-10-16 00:25:05 MAIN DEBUG Global Queue Size: 572 >> >> >> >> >>> On Oct 15, 2015, at 5:02 PM, James DeVincentis wrote: >>> >>> Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. >>> >>> From: James DeVincentis [mailto:admin at hexhost.net] >>> Sent: Wednesday, October 14, 2015 12:41 PM >>> To: 'python-list at python.org' >>> Subject: Problem with copy.deepcopy and multiprocessing.Queue >>> >>> I?ve got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. >>> >>> I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >>> >>> The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). >>> >>> This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py >>> >>> So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). >>> >>> I?ve tried ?del? the object before reusing it but it still reallocates to the same address space. I?m at a complete loss. >>> >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>> >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >> >> -- >> 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 admin at hexhost.net Sun Oct 18 04:41:56 2015 From: admin at hexhost.net (James DeVincentis) Date: Sun, 18 Oct 2015 08:41:56 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: References: <01de01d10795$3a917db0$afb47910$@hexhost.net> <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> Message-ID: I get why it needs to be called, but this looks like a serious annoyance. Now I need help figuring this out. socketserver.ForkingMixIn needs to use os._exit() so that the process never makes it past handling the request. However, if there is a thread running inside that process that manages a multiprocess.Queue that I?m attached to, how do I ensure it?s buffer gets flushed before it dies? The only way I can think of is to somehow force the flush while I?m inside the HTTP request. This is kind of a stupid hack to have to put in place but it seems since python doesn?t implement a way to exit nicely (not raising a SystemExit), AND flush the buffers, sooooo I?m stuck in a stupid edge case. > On Oct 18, 2015, at 3:33 AM, James DeVincentis wrote: > > Seems I found the cause. os._exit() is used in ForkingMixIn for SocketServer and it?s child classes. > > Since os._exit() doesn?t flush buffers or clean anything up (hence not running the Finalize hooks that multiprocess.Queue use to make sure data gets flushed), this breaks multiprocess.Queue. > > https://hg.python.org/cpython/file/3.5/Lib/socketserver.py#l605 > https://hg.python.org/cpython/file/3.5/Lib/socketserver.py#l611 > > Sigh. Now the question is why is it necessary to call os._exit() ? > >> On Oct 17, 2015, at 3:19 PM, James DeVincentis > wrote: >> >> So, whatever is causing this is a bit deeper in the multiprocessing.Queue class. I tried using a non-blocking multiprocessing.Queue.get() by setting the first parameter to false and then catching the queue.Empty exception. For some reason even though there are objects in the queue (as evidenced by multiprocessing.Queue.qsize(), the queue.Empty exception is being thrown. >> >> I dug into the multiprocessing.Queue class it looks like when calling multiprocessing.Queue.get() multiprocessing.Queue._poll() is coming up false causing it to throw the Empty exception. However, according to multiprocessing.Queue._sem there are still locks acquired on it thus giving me a multiprocessing.Queue.qsize() > 0. >> >> It looks like it is possible for a process to die (which includes that process?s local multiprocessing.Queue._feed() thread) off before multiprocessing.Queue._buffer is fed out using multiprocessing.Queue._feed(). >> >> Thoughts from anyone? >> >> >>> On Oct 15, 2015, at 7:37 PM, James DeVincentis > wrote: >>> >>> Looking into it, I seem to have found a race condition where a multiprocessing.Queue.get() can get hung waiting for an object even if there are objects in the Queue when being placed into the queue by a forked process and then the process ending quickly. >>> >>> I don?t know how to track this down any farther or fix it. >>> >>> 1. Server gets booted. This spawns the following >>> - API Server - HTTPServer(socketserver.ForkingMixIn, http.server.HTTPServer) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/server.py >>> - Workers - Process(multiprocessing.Process) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L93 >>> >>> 2. HTTP Request comes in and is handled by Handler(http.server.BaseHTTPRequestHandler) in this case using do_PUT https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L226 >>> 3. Object is created and placed in the global queue: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >>> 4. HTTP Request Process dies since request has been handled. >>> 5. Worker Process has task manager thread that takes the object from a global queue and places it into a local queue https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L64 >>> 6. one of many (30+) threads on the worker process picks up the object from the local queue and processes it https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L12 >>> >>> It seems the task management threads are getting hung up waiting for an object from the global queue, even though the global queue has objects in it? >>> >>> Ignore the ERRORS they aren?t actually errors. I did it for temporary visibility. >>> >>> 2015-10-16 00:20:07 Manager #3 ERROR Put into local queue >>> 2015-10-16 00:20:07 Manager #4 ERROR Got from global queue >>> 2015-10-16 00:20:07 Manager #4 ERROR Put into local queue >>> 2015-10-16 00:23:05 Manager #1 ERROR Waiting for item from global queue >>> 2015-10-16 00:23:05 Manager #2 ERROR Waiting for item from global queue >>> 2015-10-16 00:23:05 Manager #3 ERROR Waiting for item from global queue >>> 2015-10-16 00:23:05 Manager #4 ERROR Waiting for item from global queue >>> 2015-10-16 00:23:08 Manager #1 ERROR Got from global queue >>> 2015-10-16 00:23:08 Manager #1 ERROR Put into local queue >>> 2015-10-16 00:23:08 Manager #1 ERROR Waiting for item from global queue >>> 2015-10-16 00:23:08 Manager #2 ERROR Got from global queue >>> 2015-10-16 00:23:08 Manager #2 ERROR Put into local queue >>> 2015-10-16 00:23:08 Manager #2 ERROR Waiting for item from global queue >>> ? Nothing else gets logged by the manager threads at all, even if I continue adding objects to the global queue. >>> >>> >>> 2015-10-16 00:25:00 worker #1 DEBUG Local Queue Size: 0 >>> 2015-10-16 00:25:00 worker #3 DEBUG Local Queue Size: 0 >>> 2015-10-16 00:25:00 worker #4 DEBUG Local Queue Size: 0 >>> 2015-10-16 00:25:00 worker #2 DEBUG Local Queue Size: 0 >>> 2015-10-16 00:25:00 MAIN DEBUG Global Queue Size: 572 >>> >>> 2015-10-16 00:25:05 worker #1 DEBUG Local Queue Size: 0 >>> 2015-10-16 00:25:05 worker #3 DEBUG Local Queue Size: 0 >>> 2015-10-16 00:25:05 worker #4 DEBUG Local Queue Size: 0 >>> 2015-10-16 00:25:05 worker #2 DEBUG Local Queue Size: 0 >>> 2015-10-16 00:25:05 MAIN DEBUG Global Queue Size: 572 >>> >>> >>> >>> >>>> On Oct 15, 2015, at 5:02 PM, James DeVincentis > wrote: >>>> >>>> Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. >>>> >>>> From: James DeVincentis [mailto:admin at hexhost.net ] >>>> Sent: Wednesday, October 14, 2015 12:41 PM >>>> To: 'python-list at python.org ' >>>> Subject: Problem with copy.deepcopy and multiprocessing.Queue >>>> >>>> I?ve got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. >>>> >>>> I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >>>> >>>> The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). >>>> >>>> This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py >>>> >>>> So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). >>>> >>>> I?ve tried ?del? the object before reusing it but it still reallocates to the same address space. I?m at a complete loss. >>>> >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>> >>>> >>>> -- >>>> https://mail.python.org/mailman/listinfo/python-list >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >> >> -- >> 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 admin at hexhost.net Sun Oct 18 04:46:06 2015 From: admin at hexhost.net (James DeVincentis) Date: Sun, 18 Oct 2015 08:46:06 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: References: <01de01d10795$3a917db0$afb47910$@hexhost.net> <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> Message-ID: I see, looks like I?ll have to use Queue.close() Didn?t think it would be necessary since I was assuming it would be garbage collected. Sigh. Bug, fixed. Thanks everyone! > On Oct 18, 2015, at 3:41 AM, James DeVincentis wrote: > > I get why it needs to be called, but this looks like a serious annoyance. > > Now I need help figuring this out. > > socketserver.ForkingMixIn needs to use os._exit() so that the process never makes it past handling the request. However, if there is a thread running inside that process that manages a multiprocess.Queue that I?m attached to, how do I ensure it?s buffer gets flushed before it dies? The only way I can think of is to somehow force the flush while I?m inside the HTTP request. > > This is kind of a stupid hack to have to put in place but it seems since python doesn?t implement a way to exit nicely (not raising a SystemExit), AND flush the buffers, sooooo I?m stuck in a stupid edge case. > >> On Oct 18, 2015, at 3:33 AM, James DeVincentis > wrote: >> >> Seems I found the cause. os._exit() is used in ForkingMixIn for SocketServer and it?s child classes. >> >> Since os._exit() doesn?t flush buffers or clean anything up (hence not running the Finalize hooks that multiprocess.Queue use to make sure data gets flushed), this breaks multiprocess.Queue. >> >> https://hg.python.org/cpython/file/3.5/Lib/socketserver.py#l605 >> https://hg.python.org/cpython/file/3.5/Lib/socketserver.py#l611 >> >> Sigh. Now the question is why is it necessary to call os._exit() ? >> >>> On Oct 17, 2015, at 3:19 PM, James DeVincentis > wrote: >>> >>> So, whatever is causing this is a bit deeper in the multiprocessing.Queue class. I tried using a non-blocking multiprocessing.Queue.get() by setting the first parameter to false and then catching the queue.Empty exception. For some reason even though there are objects in the queue (as evidenced by multiprocessing.Queue.qsize(), the queue.Empty exception is being thrown. >>> >>> I dug into the multiprocessing.Queue class it looks like when calling multiprocessing.Queue.get() multiprocessing.Queue._poll() is coming up false causing it to throw the Empty exception. However, according to multiprocessing.Queue._sem there are still locks acquired on it thus giving me a multiprocessing.Queue.qsize() > 0. >>> >>> It looks like it is possible for a process to die (which includes that process?s local multiprocessing.Queue._feed() thread) off before multiprocessing.Queue._buffer is fed out using multiprocessing.Queue._feed(). >>> >>> Thoughts from anyone? >>> >>> >>>> On Oct 15, 2015, at 7:37 PM, James DeVincentis > wrote: >>>> >>>> Looking into it, I seem to have found a race condition where a multiprocessing.Queue.get() can get hung waiting for an object even if there are objects in the Queue when being placed into the queue by a forked process and then the process ending quickly. >>>> >>>> I don?t know how to track this down any farther or fix it. >>>> >>>> 1. Server gets booted. This spawns the following >>>> - API Server - HTTPServer(socketserver.ForkingMixIn, http.server.HTTPServer) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/server.py >>>> - Workers - Process(multiprocessing.Process) - https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L93 >>>> >>>> 2. HTTP Request comes in and is handled by Handler(http.server.BaseHTTPRequestHandler) in this case using do_PUT https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L226 >>>> 3. Object is created and placed in the global queue: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >>>> 4. HTTP Request Process dies since request has been handled. >>>> 5. Worker Process has task manager thread that takes the object from a global queue and places it into a local queue https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L64 >>>> 6. one of many (30+) threads on the worker process picks up the object from the local queue and processes it https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py#L12 >>>> >>>> It seems the task management threads are getting hung up waiting for an object from the global queue, even though the global queue has objects in it? >>>> >>>> Ignore the ERRORS they aren?t actually errors. I did it for temporary visibility. >>>> >>>> 2015-10-16 00:20:07 Manager #3 ERROR Put into local queue >>>> 2015-10-16 00:20:07 Manager #4 ERROR Got from global queue >>>> 2015-10-16 00:20:07 Manager #4 ERROR Put into local queue >>>> 2015-10-16 00:23:05 Manager #1 ERROR Waiting for item from global queue >>>> 2015-10-16 00:23:05 Manager #2 ERROR Waiting for item from global queue >>>> 2015-10-16 00:23:05 Manager #3 ERROR Waiting for item from global queue >>>> 2015-10-16 00:23:05 Manager #4 ERROR Waiting for item from global queue >>>> 2015-10-16 00:23:08 Manager #1 ERROR Got from global queue >>>> 2015-10-16 00:23:08 Manager #1 ERROR Put into local queue >>>> 2015-10-16 00:23:08 Manager #1 ERROR Waiting for item from global queue >>>> 2015-10-16 00:23:08 Manager #2 ERROR Got from global queue >>>> 2015-10-16 00:23:08 Manager #2 ERROR Put into local queue >>>> 2015-10-16 00:23:08 Manager #2 ERROR Waiting for item from global queue >>>> ? Nothing else gets logged by the manager threads at all, even if I continue adding objects to the global queue. >>>> >>>> >>>> 2015-10-16 00:25:00 worker #1 DEBUG Local Queue Size: 0 >>>> 2015-10-16 00:25:00 worker #3 DEBUG Local Queue Size: 0 >>>> 2015-10-16 00:25:00 worker #4 DEBUG Local Queue Size: 0 >>>> 2015-10-16 00:25:00 worker #2 DEBUG Local Queue Size: 0 >>>> 2015-10-16 00:25:00 MAIN DEBUG Global Queue Size: 572 >>>> >>>> 2015-10-16 00:25:05 worker #1 DEBUG Local Queue Size: 0 >>>> 2015-10-16 00:25:05 worker #3 DEBUG Local Queue Size: 0 >>>> 2015-10-16 00:25:05 worker #4 DEBUG Local Queue Size: 0 >>>> 2015-10-16 00:25:05 worker #2 DEBUG Local Queue Size: 0 >>>> 2015-10-16 00:25:05 MAIN DEBUG Global Queue Size: 572 >>>> >>>> >>>> >>>> >>>>> On Oct 15, 2015, at 5:02 PM, James DeVincentis > wrote: >>>>> >>>>> Anyone have any ideas? I feel like this could be a bug with the garbage collector across multiprocessing. >>>>> >>>>> From: James DeVincentis [mailto:admin at hexhost.net ] >>>>> Sent: Wednesday, October 14, 2015 12:41 PM >>>>> To: 'python-list at python.org ' >>>>> Subject: Problem with copy.deepcopy and multiprocessing.Queue >>>>> >>>>> I?ve got a bit of a problem with copy.deepcopy and using multiprocessing.Queue. >>>>> >>>>> I have an HTTPAPI that gets exposed to add objects to a multiprocessing.Qeue. Source code here: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/api/handler.py#L283 >>>>> >>>>> The trouble is, even using deepcopy, my debugging shows that it keeps re-using the same address space on every iteration of the loop (and/or fork since it uses the Forking TCP server mixin). >>>>> >>>>> This is reflected when the reference to that address space gets removed from the Queue. Source code: https://github.com/jmdevince/cifpy3/blob/master/lib/cif/worker/worker.py >>>>> >>>>> So I submit a few objects very rapidly to the HTTP server. It places them in the queue. For some reason on the second iteration copy.deepcopy stops using new address spaces for deepcopied objects. As such the queue processes that object only once (even though Queue.put() is called repeatedly for the same address space). >>>>> >>>>> I?ve tried ?del? the object before reusing it but it still reallocates to the same address space. I?m at a complete loss. >>>>> >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> 2015-10-14 17:03:30 THREAD #1-1 WARNING Got Observable with Object: >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> 2015-10-14 17:03:30 THREAD #2-1 WARNING Got Observable with Object: >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> 2015-10-14 17:03:30 APIHTTP WARNING Storing object: >>>>> >>>>> >>>>> -- >>>>> https://mail.python.org/mailman/listinfo/python-list >>>> >>>> -- >>>> https://mail.python.org/mailman/listinfo/python-list >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >> >> -- >> 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 mail at timgolden.me.uk Sun Oct 18 05:15:34 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 18 Oct 2015 10:15:34 +0100 Subject: Trying to build Python In-Reply-To: References: Message-ID: <56236336.5080900@timgolden.me.uk> On 17/10/2015 17:25, Jeff Archer wrote: > I am trying to build Python on windows. I have gotten the source in > compressed form, Python-3.5.0.tgz. Attempting to follow PCBuild\readme.txt > > Ran the get_externals.bat in the PCBuild folder. No apparent errors. > > Trying to build and getting errors: > 1> abort: there is no Mercurial repository here (.hg not found) > 1>C:\Dev.ThirdParty\Python-3.5.0\PCbuild\pythoncore.vcxproj(403,5): > warning MSB3073: The command "hg id -b > > "C:\Dev.ThirdParty\Python-3.5.0\PCbuild\obj\\win32_Debug\pythoncore\hgbranch.txt"" > exited with code 255. > 1> abort: there is no Mercurial repository here (.hg not found) > 1>C:\Dev.ThirdParty\Python-3.5.0\PCbuild\pythoncore.vcxproj(404,5): > warning MSB3073: The command "hg id -i > > "C:\Dev.ThirdParty\Python-3.5.0\PCbuild\obj\\win32_Debug\pythoncore\hgversion.txt"" > exited with code 255. > 1> abort: there is no Mercurial repository here (.hg not found) > > Seems like this is indicating that I need to get the source from a > Mercurial repo to be able to built it. > > Windows 8.1 > Visual Studio 2015 Jeff, I've just tried to reproduce by downloading the .tgz and running "build -e" from within PCBuild. It successfully builds a python.exe inside the win32/ folder. That project pre-build step (the one which calls hg id) is set to continue on failure so you might see a warning (with a somewhat scary "abort" prefix), but the build should still complete. Are you seeing a completed build? Or is it failing altogether? TJG From giuseppecostanzi at gmail.com Sun Oct 18 06:17:18 2015 From: giuseppecostanzi at gmail.com (Beppe) Date: Sun, 18 Oct 2015 03:17:18 -0700 (PDT) Subject: Converting tuple of lists of variable length into dictionary Message-ID: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> hi to everybody, I must turn a tuple of lists into a dictionary. something like (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) note that the length af each list is variable must return a ['b', 'c', 'd', 'e', 'f'] b ['a', 'c', 'd', 'e', 'f'] c ['a', 'b', 'd', 'e', 'f'] d ['a', 'b', 'c', 'e', 'f'] e ['a', 'b', 'c', 'd', 'f'] f ['a', 'b', 'c', 'd', 'e'] g ['h', 'i'] h ['g', 'i'] i ['g', 'h'] l ['m', 'n', 'o'] m ['l', 'n', 'o'] n ['l', 'm', 'o'] o ['l', 'm', 'n'] I have done this but it doesn't convince a lot me. my_tuple = (['a','b','c','d','e','f'], ['g','h','i',], ['l','m','n','o'],) my_dict = {} LETTERS = [] for letters in my_tuple: LETTERS = letters[:] for letter in sorted(LETTERS): if my_dict.has_key(str(letter)): my_dict.append(letters) else: letters.remove(str(letter)) my_dict[letter]= letters letters = LETTERS[:] for k,v in sorted(my_dict.iteritems()): print k,v Suggestions? regards beppe From __peter__ at web.de Sun Oct 18 07:00:05 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 18 Oct 2015 13:00:05 +0200 Subject: Converting tuple of lists of variable length into dictionary References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: Beppe wrote: > hi to everybody, I must turn a tuple of lists into a dictionary. > > something like > > (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) > > note that the length af each list is variable > > must return > > a ['b', 'c', 'd', 'e', 'f'] > b ['a', 'c', 'd', 'e', 'f'] > c ['a', 'b', 'd', 'e', 'f'] > d ['a', 'b', 'c', 'e', 'f'] > e ['a', 'b', 'c', 'd', 'f'] > f ['a', 'b', 'c', 'd', 'e'] > g ['h', 'i'] > h ['g', 'i'] > i ['g', 'h'] > l ['m', 'n', 'o'] > m ['l', 'n', 'o'] > n ['l', 'm', 'o'] > o ['l', 'm', 'n'] What do you want to do with items that occur in more than one list? If there are no such duplicate items it's easy: >>> lists = (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) >>> d = { ... c: items[:i] + items[i+1:] ... for items in lists ... for i, c in enumerate(items) ... } >>> pprint.pprint(d) {'a': ['b', 'c', 'd', 'e', 'f'], 'b': ['a', 'c', 'd', 'e', 'f'], 'c': ['a', 'b', 'd', 'e', 'f'], 'd': ['a', 'b', 'c', 'e', 'f'], 'e': ['a', 'b', 'c', 'd', 'f'], 'f': ['a', 'b', 'c', 'd', 'e'], 'g': ['h', 'i'], 'h': ['g', 'i'], 'i': ['g', 'h'], 'l': ['m', 'n', 'o'], 'm': ['l', 'n', 'o'], 'n': ['l', 'm', 'o'], 'o': ['l', 'm', 'n']} From giuseppecostanzi at gmail.com Sun Oct 18 08:23:49 2015 From: giuseppecostanzi at gmail.com (Beppe) Date: Sun, 18 Oct 2015 05:23:49 -0700 (PDT) Subject: Converting tuple of lists of variable length into dictionary In-Reply-To: References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: Il giorno domenica 18 ottobre 2015 13:00:44 UTC+2, Peter Otten ha scritto: > Beppe wrote: > > > hi to everybody, I must turn a tuple of lists into a dictionary. > > > > something like > > > > (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) > > > > note that the length af each list is variable > > > > must return > > > > a ['b', 'c', 'd', 'e', 'f'] > > b ['a', 'c', 'd', 'e', 'f'] > > c ['a', 'b', 'd', 'e', 'f'] > > d ['a', 'b', 'c', 'e', 'f'] > > e ['a', 'b', 'c', 'd', 'f'] > > f ['a', 'b', 'c', 'd', 'e'] > > g ['h', 'i'] > > h ['g', 'i'] > > i ['g', 'h'] > > l ['m', 'n', 'o'] > > m ['l', 'n', 'o'] > > n ['l', 'm', 'o'] > > o ['l', 'm', 'n'] > > What do you want to do with items that occur in more than one list? > > If there are no such duplicate items it's easy: > > >>> lists = (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', > 'n', 'o']) > >>> d = { > ... c: items[:i] + items[i+1:] > ... for items in lists > ... for i, c in enumerate(items) > ... } > >>> pprint.pprint(d) > {'a': ['b', 'c', 'd', 'e', 'f'], > 'b': ['a', 'c', 'd', 'e', 'f'], > 'c': ['a', 'b', 'd', 'e', 'f'], > 'd': ['a', 'b', 'c', 'e', 'f'], > 'e': ['a', 'b', 'c', 'd', 'f'], > 'f': ['a', 'b', 'c', 'd', 'e'], > 'g': ['h', 'i'], > 'h': ['g', 'i'], > 'i': ['g', 'h'], > 'l': ['m', 'n', 'o'], > 'm': ['l', 'n', 'o'], > 'n': ['l', 'm', 'o'], > 'o': ['l', 'm', 'n']} hi Peter, you are right, no duplicates are admitted between lists, anyway your solution,works on python 3 but not on 2. however beautiful list comprehension solution. I will try to suit it for the python version i need regards beppe From rosuav at gmail.com Sun Oct 18 08:35:27 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 18 Oct 2015 23:35:27 +1100 Subject: Converting tuple of lists of variable length into dictionary In-Reply-To: References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: On Sun, Oct 18, 2015 at 11:23 PM, Beppe wrote: > hi Peter, you are right, no duplicates are admitted between lists, > anyway your solution,works on python 3 but not on 2. > however beautiful list comprehension solution. > I will try to suit it for the python version i need Should work fine on 2.7. What Py2 version are you running? ChrisA From giuseppecostanzi at gmail.com Sun Oct 18 08:44:07 2015 From: giuseppecostanzi at gmail.com (Beppe) Date: Sun, 18 Oct 2015 05:44:07 -0700 (PDT) Subject: Converting tuple of lists of variable length into dictionary In-Reply-To: References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: Il giorno domenica 18 ottobre 2015 14:35:53 UTC+2, Chris Angelico ha scritto: > On Sun, Oct 18, 2015 at 11:23 PM, Beppe wrote: > > hi Peter, you are right, no duplicates are admitted between lists, > > anyway your solution,works on python 3 but not on 2. > > however beautiful list comprehension solution. > > I will try to suit it for the python version i need > > Should work fine on 2.7. What Py2 version are you running? > > ChrisA Python2.6 Python 2.6.6 (r266:84292, Aug 12 2014, 07:57:07) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> lists = (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm','n', 'o']) >>> ... d = {c: items[:i] + items[i+1:] for items in lists for i, c in enumerate(items)} File "", line 2 d = {c: items[:i] + items[i+1:] for items in lists for i, c in enumerate(items)} ^ SyntaxError: invalid syntax From __peter__ at web.de Sun Oct 18 08:47:11 2015 From: __peter__ at web.de (Peter Otten) Date: Sun, 18 Oct 2015 14:47:11 +0200 Subject: Converting tuple of lists of variable length into dictionary References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: Beppe wrote: > Il giorno domenica 18 ottobre 2015 13:00:44 UTC+2, Peter Otten ha scritto: >> Beppe wrote: >> >> > hi to everybody, I must turn a tuple of lists into a dictionary. >> > >> > something like >> > >> > (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) >> > >> > note that the length af each list is variable >> > >> > must return >> > >> > a ['b', 'c', 'd', 'e', 'f'] >> > b ['a', 'c', 'd', 'e', 'f'] >> > c ['a', 'b', 'd', 'e', 'f'] >> > d ['a', 'b', 'c', 'e', 'f'] >> > e ['a', 'b', 'c', 'd', 'f'] >> > f ['a', 'b', 'c', 'd', 'e'] >> > g ['h', 'i'] >> > h ['g', 'i'] >> > i ['g', 'h'] >> > l ['m', 'n', 'o'] >> > m ['l', 'n', 'o'] >> > n ['l', 'm', 'o'] >> > o ['l', 'm', 'n'] >> >> What do you want to do with items that occur in more than one list? >> >> If there are no such duplicate items it's easy: >> >> >>> lists = (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', >> 'n', 'o']) >> >>> d = { >> ... c: items[:i] + items[i+1:] >> ... for items in lists >> ... for i, c in enumerate(items) >> ... } >> >>> pprint.pprint(d) >> {'a': ['b', 'c', 'd', 'e', 'f'], >> 'b': ['a', 'c', 'd', 'e', 'f'], >> 'c': ['a', 'b', 'd', 'e', 'f'], >> 'd': ['a', 'b', 'c', 'e', 'f'], >> 'e': ['a', 'b', 'c', 'd', 'f'], >> 'f': ['a', 'b', 'c', 'd', 'e'], >> 'g': ['h', 'i'], >> 'h': ['g', 'i'], >> 'i': ['g', 'h'], >> 'l': ['m', 'n', 'o'], >> 'm': ['l', 'n', 'o'], >> 'n': ['l', 'm', 'o'], >> 'o': ['l', 'm', 'n']} > > hi Peter, you are right, no duplicates are admitted between lists, > anyway your solution,works on python 3 but not on 2. > however beautiful list comprehension solution. > I will try to suit it for the python version i need The above code will work without changes in Python 2.7. For older Python versions you can replace the dict comprehension with a generator expression: >>> d = dict( ... (c, items[:i] + items[i+1:]) ... for items in lists ... for i, c in enumerate(items) ... ) >>> pprint.pprint(d) {'a': ['b', 'c', 'd', 'e', 'f'], 'b': ['a', 'c', 'd', 'e', 'f'], 'c': ['a', 'b', 'd', 'e', 'f'], 'd': ['a', 'b', 'c', 'e', 'f'], 'e': ['a', 'b', 'c', 'd', 'f'], 'f': ['a', 'b', 'c', 'd', 'e'], 'g': ['h', 'i'], 'h': ['g', 'i'], 'i': ['g', 'h'], 'l': ['m', 'n', 'o'], 'm': ['l', 'n', 'o'], 'n': ['l', 'm', 'o'], 'o': ['l', 'm', 'n']} I have no Python below 2.7 ready to test, but this version should work for Python 2.4 and above. If you find explict loops easier to understand: >>> d = {} >>> for items in lists: ... for i, c in enumerate(items): ... assert c not in d ... d[c] = items[:i] + items[i+1:] ... should work for Python 2.3 and above (untested). I have smuggled in an assertion that checks for duplicate keys. From giuseppecostanzi at gmail.com Sun Oct 18 09:04:59 2015 From: giuseppecostanzi at gmail.com (Beppe) Date: Sun, 18 Oct 2015 06:04:59 -0700 (PDT) Subject: Converting tuple of lists of variable length into dictionary In-Reply-To: References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: <88e08a61-e872-47f7-a954-5d28f0ddfd89@googlegroups.com> Il giorno domenica 18 ottobre 2015 14:47:34 UTC+2, Peter Otten ha scritto: > Beppe wrote: > > > Il giorno domenica 18 ottobre 2015 13:00:44 UTC+2, Peter Otten ha scritto: > >> Beppe wrote: > >> > >> > hi to everybody, I must turn a tuple of lists into a dictionary. > >> > > >> > something like > >> > > >> > (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) > >> > > >> > note that the length af each list is variable > >> > > >> > must return > >> > > >> > a ['b', 'c', 'd', 'e', 'f'] > >> > b ['a', 'c', 'd', 'e', 'f'] > >> > c ['a', 'b', 'd', 'e', 'f'] > >> > d ['a', 'b', 'c', 'e', 'f'] > >> > e ['a', 'b', 'c', 'd', 'f'] > >> > f ['a', 'b', 'c', 'd', 'e'] > >> > g ['h', 'i'] > >> > h ['g', 'i'] > >> > i ['g', 'h'] > >> > l ['m', 'n', 'o'] > >> > m ['l', 'n', 'o'] > >> > n ['l', 'm', 'o'] > >> > o ['l', 'm', 'n'] > >> > >> What do you want to do with items that occur in more than one list? > >> > >> If there are no such duplicate items it's easy: > >> > >> >>> lists = (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', > >> 'n', 'o']) > >> >>> d = { > >> ... c: items[:i] + items[i+1:] > >> ... for items in lists > >> ... for i, c in enumerate(items) > >> ... } > >> >>> pprint.pprint(d) > >> {'a': ['b', 'c', 'd', 'e', 'f'], > >> 'b': ['a', 'c', 'd', 'e', 'f'], > >> 'c': ['a', 'b', 'd', 'e', 'f'], > >> 'd': ['a', 'b', 'c', 'e', 'f'], > >> 'e': ['a', 'b', 'c', 'd', 'f'], > >> 'f': ['a', 'b', 'c', 'd', 'e'], > >> 'g': ['h', 'i'], > >> 'h': ['g', 'i'], > >> 'i': ['g', 'h'], > >> 'l': ['m', 'n', 'o'], > >> 'm': ['l', 'n', 'o'], > >> 'n': ['l', 'm', 'o'], > >> 'o': ['l', 'm', 'n']} > > > > hi Peter, you are right, no duplicates are admitted between lists, > > anyway your solution,works on python 3 but not on 2. > > however beautiful list comprehension solution. > > I will try to suit it for the python version i need > > The above code will work without changes in Python 2.7. For older Python > versions you can replace the dict comprehension with a generator expression: > > >>> d = dict( > ... (c, items[:i] + items[i+1:]) > ... for items in lists > ... for i, c in enumerate(items) > ... ) > >>> pprint.pprint(d) > {'a': ['b', 'c', 'd', 'e', 'f'], > 'b': ['a', 'c', 'd', 'e', 'f'], > 'c': ['a', 'b', 'd', 'e', 'f'], > 'd': ['a', 'b', 'c', 'e', 'f'], > 'e': ['a', 'b', 'c', 'd', 'f'], > 'f': ['a', 'b', 'c', 'd', 'e'], > 'g': ['h', 'i'], > 'h': ['g', 'i'], > 'i': ['g', 'h'], > 'l': ['m', 'n', 'o'], > 'm': ['l', 'n', 'o'], > 'n': ['l', 'm', 'o'], > 'o': ['l', 'm', 'n']} > > I have no Python below 2.7 ready to test, but this version should work for > Python 2.4 and above. If you find explict loops easier to understand: > > >>> d = {} > >>> for items in lists: > ... for i, c in enumerate(items): > ... assert c not in d > ... d[c] = items[:i] + items[i+1:] > ... > > should work for Python 2.3 and above (untested). I have smuggled in an > assertion that checks for duplicate keys. spectacular...:) both version work fine on 2.6 I'm shooting 'print' everywhere to understand what are you do... thank you very much ciao beppe From andybrookestar at googlemail.com Sun Oct 18 11:11:35 2015 From: andybrookestar at googlemail.com (andybrookestar at googlemail.com) Date: Sun, 18 Oct 2015 08:11:35 -0700 (PDT) Subject: string class variable to sqlite3 In-Reply-To: References: Message-ID: <53279bac-c993-4ed9-b8d9-8c807a6770d5@googlegroups.com> cheers Mark, it was the syntax that was foxing me; I don't like the example of the select statement via the insecure approach because the writer is adding an element of ambiguity since the table has a field called and a variable also called #modifying my class to import sqlite3 class do: myString1 = 'uranium' myString2 = ('lead',) def doConn(self): self.conn = sqlite3.connect('encyclopedia') print "Opened database successfully" myString3 = 'sulphur' cursor = self.conn.execute("SELECT * from wiki WHERE one LIKE '%s' "% self.myString1) #cursor = self.conn.execute("SELECT * from wiki WHERE one =?", self.myString2) #cursor = self.conn.execute("SELECT * from wiki WHERE one LIKE '%s'" % myString3 ) for row in cursor: print "ID = ", row[0] print "NAME = ", row[1] print "Operation done successfully" self.conn.close() x = do() x.doConn() #all select statements work , the first two strings are defined under class so referencing with 'self' works. other is defined inside method so doesn't need it. From marko at pacujo.net Sun Oct 18 11:31:15 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Sun, 18 Oct 2015 18:31:15 +0300 Subject: string class variable to sqlite3 References: <53279bac-c993-4ed9-b8d9-8c807a6770d5@googlegroups.com> Message-ID: <87vba4i470.fsf@elektro.pacujo.net> andybrookestar at googlemail.com: > cursor = self.conn.execute("SELECT * from wiki WHERE one LIKE '%s' "% > self.myString1) That's really dangerous. See: Now, I don't know if there are any better stdlib ways to quote SQL strings properly. Marko From ian.g.kelly at gmail.com Sun Oct 18 11:55:13 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 18 Oct 2015 09:55:13 -0600 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: References: <01de01d10795$3a917db0$afb47910$@hexhost.net> <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> Message-ID: On Sun, Oct 18, 2015 at 2:46 AM, James DeVincentis wrote: > > I see, looks like I?ll have to use Queue.close() > > Didn?t think it would be necessary since I was assuming it would be garbage collected. Sigh. Bug, fixed. I'm not really following what the issue is here -- it sounds like it runs pretty deep, and I'm not familiar with the module's internals -- but would you please file a bug against the documentation? The docs suggest that multiprocessing.Queue.close probably does not need to be called, and they should be changed if that's not truly the case. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffarcher7 at gmail.com Sun Oct 18 12:03:03 2015 From: jeffarcher7 at gmail.com (Jeff Archer) Date: Sun, 18 Oct 2015 12:03:03 -0400 Subject: Trying to build Python In-Reply-To: <56236336.5080900@timgolden.me.uk> References: <56236336.5080900@timgolden.me.uk> Message-ID: On Sun, Oct 18, 2015 at 5:15 AM, Tim Golden wrote: > On 17/10/2015 17:25, Jeff Archer wrote: > >> I am trying to build Python on windows. I have gotten the source in >> compressed form, Python-3.5.0.tgz. Attempting to follow >> PCBuild\readme.txt >> >> Ran the get_externals.bat in the PCBuild folder. No apparent errors. >> >> Trying to build and getting errors: >> 1> abort: there is no Mercurial repository here (.hg not found) >> 1>C:\Dev.ThirdParty\Python-3.5.0\PCbuild\pythoncore.vcxproj(403,5): >> warning MSB3073: The command "hg id -b > >> >> "C:\Dev.ThirdParty\Python-3.5.0\PCbuild\obj\\win32_Debug\pythoncore\hgbranch.txt"" >> exited with code 255. >> 1> abort: there is no Mercurial repository here (.hg not found) >> 1>C:\Dev.ThirdParty\Python-3.5.0\PCbuild\pythoncore.vcxproj(404,5): >> warning MSB3073: The command "hg id -i > >> >> "C:\Dev.ThirdParty\Python-3.5.0\PCbuild\obj\\win32_Debug\pythoncore\hgversion.txt"" >> exited with code 255. >> 1> abort: there is no Mercurial repository here (.hg not found) >> >> Seems like this is indicating that I need to get the source from a >> Mercurial repo to be able to built it. >> >> Windows 8.1 >> Visual Studio 2015 >> > > Jeff, > > I've just tried to reproduce by downloading the .tgz and running "build > -e" from within PCBuild. It successfully builds a python.exe inside the > win32/ folder. That project pre-build step (the one which calls hg id) is > set to continue on failure so you might see a warning (with a somewhat > scary "abort" prefix), but the build should still complete. > > Are you seeing a completed build? Or is it failing altogether? > > TJG > Thanks for the help, Tim. Sorry, I forgot to mention that I am trying to build debug. I am running get_externals.bat as a separate step but I can't imagine this is an issue. I am mainly do it this way because ultimately I want to build Debug/Release for 32/64 bit. cd When I build from batch file these errors turn into The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. Which is odd since hg is on the Path and I can reproduce the failures when I run the command directly from the command prompt C:\Dev.ThirdParty\Python_3_5_0\Python-3.5.0\Python-3.5.0\PCbuild>findonpath hg.exe C:\Program Files\TortoiseHg\hg.exe C:\Dev.ThirdParty\Python_3_5_0\Python-3.5.0\Python-3.5.0\PCbuild>hg id -b abort: there is no Mercurial repository here (.hg not found) But I do get the expected binaries, I believe 10/18/2015 11:32 AM 51,200 pythonw_d.exe 10/18/2015 11:32 AM 51,200 python_d.exe 10/18/2015 11:32 AM 463,872 pyw_d.exe 10/18/2015 11:32 AM 462,848 py_d.exe 10/18/2015 11:32 AM 28,160 _freeze_importlib_d.exe 10/18/2015 11:32 AM 26,624 _testembed_d.exe 10/18/2015 11:32 AM 5,603,840 python35_d.dll 10/18/2015 11:32 AM 61,440 python3_d.dll 10/18/2015 11:32 AM 784,384 sqlite3_d.dll 10/18/2015 11:32 AM 2,030,592 tcl86tg.dll 10/18/2015 11:33 AM 1,537,536 tk86tg.dll Can you confirm that these are the expected binaries and correct file sizes? Also, I have noticed that a file gets deleted by the build process Python-3.5.0/Python-3.5.0/externals/openssl-1.0.2d/crypto/buildinf.h Do you see this also? -------------- next part -------------- An HTML attachment was scrubbed... URL: From andybrookestar at googlemail.com Sun Oct 18 12:10:54 2015 From: andybrookestar at googlemail.com (andybrookestar at googlemail.com) Date: Sun, 18 Oct 2015 09:10:54 -0700 (PDT) Subject: string class variable to sqlite3 In-Reply-To: References: Message-ID: I acknowledge the security points & also by the way I omitted using any Try Catch statements , because at this stage coming from PHP I was more focused on getting a select statement to actually work in python. Also I know the end use will be off line and is part of a python & kivy project to android via buildozer ,for an off line searchable version of the digital encyclopedia from SOSchildren. PHP version here: http://www.ginbrookesfoundation.org/showArticle/70 I'm just glad I have half a clue now! Loving python so far anyway! From real-not-anti-spam-address at apple-juice.co.uk Sun Oct 18 14:04:22 2015 From: real-not-anti-spam-address at apple-juice.co.uk (D.M. Procida) Date: Sun, 18 Oct 2015 19:04:22 +0100 Subject: PyCon Namibia 2015 Message-ID: <1mci4wb.1otn1ys1oddjznN%real-not-anti-spam-address@apple-juice.co.uk> PyCon Namibia 2016 will be held in Windhoek, at the University of Namibia, 24th-29th January. for more information. Regards, Daniele From real-not-anti-spam-address at apple-juice.co.uk Sun Oct 18 14:07:34 2015 From: real-not-anti-spam-address at apple-juice.co.uk (D.M. Procida) Date: Sun, 18 Oct 2015 19:07:34 +0100 Subject: PyCon Namibia 2016 (was: PyCon Namibia 2015) References: <1mci4wb.1otn1ys1oddjznN%real-not-anti-spam-address@apple-juice.co.uk> Message-ID: <1mci52j.rl4tvb1q2j3imN%real-not-anti-spam-address@apple-juice.co.uk> D.M. Procida wrote: > PyCon Namibia 2016 will be held in Windhoek, at the University of > Namibia, 24th-29th January. > > for more information. Subject: corrected, sorry. Daniele From admin at hexhost.net Sun Oct 18 14:20:26 2015 From: admin at hexhost.net (James DeVincentis) Date: Sun, 18 Oct 2015 18:20:26 +0000 Subject: Problem with copy.deepcopy and multiprocessing.Queue In-Reply-To: References: <01de01d10795$3a917db0$afb47910$@hexhost.net> <34A47B95-EAB2-4EC4-9255-FC9A6BC35229@hexhost.net> Message-ID: The problem isn?t with multiprocess.Queue. The problem is that socketserver.ForkingMixIn calls os._exit() after the request is handled by the forked process. Which I did not know until I dug into the internals of socket server.ForkingMixIn. This causes the Finalize() hooks inside of multiprocess.Queue to not run. The hooks essentially call multiprocess.Queue.close() and multiprocess.Queue.join_thread(). This guarantees the local thread buffer has been flushed before allowing the process to fully exit. Since os._exit() doesn?t honor any of those, the forked process may die without flushing that buffer. The documentation is correct for multiprocess.Queue() when it says that multiprocess.Queue.close() get?s run automatically when the thread is garbage collected. It just wasn?t being garbage collected due to the os._exit() call caused by socketserver.ForkingMixIn > On Oct 18, 2015, at 10:55 AM, Ian Kelly wrote: > > On Sun, Oct 18, 2015 at 2:46 AM, James DeVincentis > wrote: > > > > I see, looks like I?ll have to use Queue.close() > > > > Didn?t think it would be necessary since I was assuming it would be garbage collected. Sigh. Bug, fixed. > > I'm not really following what the issue is here -- it sounds like it runs pretty deep, and I'm not familiar with the module's internals -- but would you please file a bug against the documentation? The docs suggest that multiprocessing.Queue.close probably does not need to be called, and they should be changed if that's not truly the case. > -- > https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From gaini2002 at libero.it Sun Oct 18 16:31:39 2015 From: gaini2002 at libero.it (gaini2002 at libero.it) Date: Sun, 18 Oct 2015 22:31:39 +0200 (CEST) Subject: Defamation Message-ID: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> Please remove the page https://mail.python.org/pipermail/python-list/2014-September/678498.html Thank You Gabriele Silvagni -------------- next part -------------- An HTML attachment was scrubbed... URL: From denismfmcmahon at gmail.com Sun Oct 18 16:38:26 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Sun, 18 Oct 2015 20:38:26 +0000 (UTC) Subject: Converting tuple of lists of variable length into dictionary References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: On Sun, 18 Oct 2015 03:17:18 -0700, Beppe wrote: > hi to everybody, I must turn a tuple of lists into a dictionary. I went down a different path to Peter, and discovered something perplexing: This failed: d = { i: deepcopy(l).remove(i) for l in t for i in l } So I tried to expand it out to see where the issue was, and ended up with two variants: def f1(l, i): m = deepcopy(l) m.remove(i) return m d = { i: f1(l,i) for l in t for i in l } def f2(l, i): m = deepcopy(l).remove(i) return m d = { i: f2(l,i) for l in t for i in l } The first variant using, m = deepcopy(l); m.remove(i) works fine, generating: {'a': ['b', 'c', 'd', 'e', 'f'], 'c': ['a', 'b', 'd', 'e', 'f'], 'b': ['a', 'c', 'd', 'e', 'f'], 'e': ['a', 'b', 'c', 'd', 'f'], 'd': ['a', 'b', 'c', 'e', 'f'], 'g': ['h', 'i'], 'f': ['a', 'b', 'c', 'd', 'e'], 'i': ['g', 'h'], 'h': ['g', 'i'], 'm': ['l', 'n', 'o'], 'l': ['m', 'n', 'o'], 'o': ['l', 'm', 'n'], 'n': ['l', 'm', 'o']} The second variant using, m = deepcopy(l).remove(i) fails thus: {'a': None, 'c': None, 'b': None, 'e': None, 'd': None, 'g': None, 'f': None, 'i': None, 'h': None, 'm': None, 'l': None, 'o': None, 'n': None} I'm not sure I understand why after m = deepcopy(l); m.remove(i); m is a different value to that which it as after m = deepcopy(l).remove(i). -- Denis McMahon, denismfmcmahon at gmail.com From denismfmcmahon at gmail.com Sun Oct 18 16:44:01 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Sun, 18 Oct 2015 20:44:01 +0000 (UTC) Subject: Converting tuple of lists of variable length into dictionary References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: On Sun, 18 Oct 2015 20:38:26 +0000, Denis McMahon wrote: > On Sun, 18 Oct 2015 03:17:18 -0700, Beppe wrote: > >> hi to everybody, I must turn a tuple of lists into a dictionary. > > I went down a different path to Peter, and discovered something > perplexing: I just realised staring at it again that I'm getting the return value from the remove (ie None) in the failing case, because the remove is operating on the original list, rather than returning an updated copy. -- Denis McMahon, denismfmcmahon at gmail.com From python at lucidity.plus.com Sun Oct 18 16:55:10 2015 From: python at lucidity.plus.com (Erik) Date: Sun, 18 Oct 2015 21:55:10 +0100 Subject: Converting tuple of lists of variable length into dictionary In-Reply-To: References: <567ad269-e8bc-4a6c-a2e7-1f1f86cd85de@googlegroups.com> Message-ID: <5624072E.4050406@lucidity.plus.com> On 18/10/15 21:38, Denis McMahon wrote: > I'm not sure I understand why after m = deepcopy(l); m.remove(i); m is a > different value to that which it as after m = deepcopy(l).remove(i). It's because list.remove() returns None, not 'self'. E. From rosuav at gmail.com Sun Oct 18 20:36:19 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 19 Oct 2015 11:36:19 +1100 Subject: string class variable to sqlite3 In-Reply-To: References: Message-ID: On Mon, Oct 19, 2015 at 3:10 AM, andybrookestar--- via Python-list wrote: > I acknowledge the security points & also by the way I omitted using any Try Catch statements , because at this stage coming from PHP I was more focused on getting a select statement to actually work in python. > That's fine when you're just playing around, starting to get to know the basics. But I hope you'll shift your thinking before deploying anything to production. The PHP model is, as you describe, "do your best to keep going, regardless of what's going wrong". It results in web pages that spew warnings everywhere (possibly revealing internal details of the code's layout, empowering future attacks), tell the user their changes have been saved despite getting an error back from the database, and so on. The Python philosophy is that a correctly-working program is best, next best is one that crashes out with a clean exception, and the very worst is one that barges on and does the wrong thing. I would MUCH rather have my web app throw me back a little 500 (and, by the way, it'll show the end user a simple 500 page, and log the details of the exception for admin eyes only) so it's _obvious_ that the data wasn't saved, or the email wasn't sent, or whatever. Unlike PHP, Python has a simple and trustworthy [1] error handling system. Everything is signalled with a thrown exception; if you know about the error and can handle it, you catch that exception and deal with it. Otherwise, ignore the exception, and someone else will deal with it. You don't have to religiously check return values and remember to handle all those errors that never come up in local testing (like DNS failures and timeouts), not to mention those more obscure errors that you wouldn't even think of (like "disk full" or "out of memory"). Whatever happens, it's an exception. Write your code in this style, and you don't have to worry about the details. ChrisA [1] In PHP, sometimes errors become exceptions, sometimes they become messages printed to the output file, sometimes they get logged, sometimes completely suppressed... and all based on a very complicated set of rules. From jsf80238 at gmail.com Sun Oct 18 20:50:31 2015 From: jsf80238 at gmail.com (Jason Friedman) Date: Sun, 18 Oct 2015 18:50:31 -0600 Subject: teacher need help! In-Reply-To: <5623397C.40205@timgolden.me.uk> References: <5623397C.40205@timgolden.me.uk> Message-ID: > Can I suggest you find the turtle.py module in c:\windows\system32, move it > to somewhere more suitable and try the code again? Or, copy it, rather than move it? It may be that for some students turtle.py is in a terrific place already. From rosuav at gmail.com Sun Oct 18 20:55:09 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 19 Oct 2015 11:55:09 +1100 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk> Message-ID: On Mon, Oct 19, 2015 at 11:50 AM, Jason Friedman wrote: >> Can I suggest you find the turtle.py module in c:\windows\system32, move it >> to somewhere more suitable and try the code again? > > Or, copy it, rather than move it? > It may be that for some students turtle.py is in a terrific place already. If it's copied, the problem will still exist. What's happening here is: 1) A file called test3.py is being run from the user's desktop. 2) It attempts to "import turtle". 3) Python discovers a turtle.py in system32, and runs it. 4) That file also does an "import turtle", getting a reference to itself. 5) turtle.Pen() fails because there isn't one. The problem is step 3, because Python's finding someone's demo file instead of the stdlib module. The solution is to not have the file c:\windows\system32\turtle.py, which means deleting it or renaming/moving it away. Copying it won't fix anything. ChrisA From geneva.storey at fultonind.kyschools.us Sun Oct 18 20:58:58 2015 From: geneva.storey at fultonind.kyschools.us (Storey, Geneva) Date: Mon, 19 Oct 2015 00:58:58 +0000 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk>, Message-ID: <316F8E76-9A34-4373-955B-BEA5D01D8E75@fultonind.kyschools.us> Argh! I cannot find that file! I have deleted all files with Python or having the name turtle, and am in the process of reinstalling. Out of 13 computers, 10 are working perfectly and three give this error-so confused! I'll let you know how it goes. Geneva Sent from my iPhone On Oct 18, 2015, at 7:50 PM, Jason Friedman wrote: >> Can I suggest you find the turtle.py module in c:\windows\system32, move it >> to somewhere more suitable and try the code again? > > Or, copy it, rather than move it? > It may be that for some students turtle.py is in a terrific place already. From geneva.storey at fultonind.kyschools.us Sun Oct 18 21:32:59 2015 From: geneva.storey at fultonind.kyschools.us (Storey, Geneva) Date: Mon, 19 Oct 2015 01:32:59 +0000 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk>, Message-ID: Same issue! See attached. Thanks! Geneva Storey Fulton High School Spanish, Mathematics Bulldog Academy ________________________________________ From: Jason Friedman Sent: Sunday, October 18, 2015 7:50 PM To: Tim Golden Cc: Storey, Geneva; python-list at python.org Subject: Re: teacher need help! > Can I suggest you find the turtle.py module in c:\windows\system32, move it > to somewhere more suitable and try the code again? Or, copy it, rather than move it? It may be that for some students turtle.py is in a terrific place already. -------------- next part -------------- A non-text attachment was scrubbed... Name: python problem.JPG Type: image/jpeg Size: 32080 bytes Desc: python problem.JPG URL: From torriem at gmail.com Sun Oct 18 21:58:32 2015 From: torriem at gmail.com (Michael Torrie) Date: Sun, 18 Oct 2015 19:58:32 -0600 Subject: Where is the menu bar for 3.5? In-Reply-To: <4dkyyhu668lydy8a48uig9vg.1445138842876@email.android.com> References: <4dkyyhu668lydy8a48uig9vg.1445138842876@email.android.com> Message-ID: <56244E48.2060403@gmail.com> On 10/17/2015 09:27 PM, Peachy Keen wrote: > I am learning to code and I downloaded Python 3.5 32bit. But I can't > find the menu bar and after much frustration I uninstalled the > program. I would like to get started again so if you could assist it > would be appreciated. Python itself is in interpreter which executes instructions from an ordinary text file that contains the python program. As such Python itself has no "menu bar" or any user interface beyond an interactive mode that you run from the command line. Thus to actually use Python you can do one of: 1. Use the IDLE program that comes with most distributions of Python. On windows it will install itself to the Start menu. IDLE is a nice integrated development environment that provides an editor (complete with menu bar) and a nice means of running and debugging your Python programs. 2. Use any programmer editor, such as Notepad++ on windows, to make a program file, save it with a .py extension. Since most beginner Python programs have no GUI but do console input and output, you'll want to open up a command prompt, navigate to where your python file is and type: python myfile.py 3. Use an online tool like http://learnpython.org, http://repl.it, or http://www.skulpt.org/ to play around with the Python language without having to install anything. From torriem at gmail.com Sun Oct 18 22:02:04 2015 From: torriem at gmail.com (Michael Torrie) Date: Sun, 18 Oct 2015 20:02:04 -0600 Subject: teacher need help! In-Reply-To: References: Message-ID: <56244F1C.7090406@gmail.com> On 10/17/2015 05:46 PM, Storey, Geneva wrote: > I am teaching a coding class to students grades 7-12. We have been > using Python, which seems to be a perfect fit. Everything was going > great until this week when I began teaching turtle. Suddenly, of the > 13 computers that I have, 3 began giving the message on the above > screen shot. This is a problem since I have 24 students! I have > uninstalled and reinstalled and done all that I know to do. Any > suggestions? That's wonderful that your students are working with Python. The others have already answered your question (which is to remove turtle.py from the system32 directory). I am just posting to direct you to a possible resource I just discovered that may be useful on occasion: http://www.skulpt.org/ This is an implementation of Python in the browser (unfortunately it's not version 3.x) that implements turtle. Most of the online python implementations I've seen don't allow turtle to run. Since it's not Python 3, it's usefulness to you is probably limited. Hope you'll report things are back to working order Monday. From rosuav at gmail.com Mon Oct 19 01:35:25 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 19 Oct 2015 16:35:25 +1100 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk> Message-ID: On Mon, Oct 19, 2015 at 12:32 PM, Storey, Geneva wrote: > Same issue! See attached. > Thanks! I can't really read it in the image. Can you copy and paste the text into the body of the email, please? But I think you still have a file called turtle.py. Avoid that name and you should be fine. ChrisA From dieter at handshake.de Mon Oct 19 02:04:02 2015 From: dieter at handshake.de (dieter) Date: Mon, 19 Oct 2015 08:04:02 +0200 Subject: New to Python and setting up References: <71f45d79-f1c7-4196-a543-d9932b7b3cfc@googlegroups.com> Message-ID: <87y4ezs8bx.fsf@handshake.de> Glenn Schultz writes: > ... > Following the example of Ivan7777 I have setup A folder structure. My understand is that if each folder has an __init__.py From what it is considered a module. Have I set this up correctly? An "__init__.py" in a folder used to indicate that this folder is a package/subpackage (modern Python 3.x version may no longer need such an "__init__.py" for this purpose). A "package/subpackage" is a modularisation unit, where a set of modules and subpackages work closer together to implement the unit's task. > In the time_value module I have a function present_value_factor. I am having trouble documenting the function. How is this done? In the Python world, source code documentation often uses so called "doc string"s (beside documenting comments). For example, when your (non comment) code at the beginning of a module is a string/unicode string, then this is the module's "doc string", conventionally used to describe the module's purpose. Similar for a class and function definition. Python does not prescribe how the "doc string"s should look like. However, often, a documentation tool is used to extract overviews from the source code documentation and those tools may support special annotations to recognize special kinds of objects (e.g. types, return values). If you plan to use such a tool, look for its documentation to find out about details. > Finally, I have read something to the effect that when creating a deployment locally use a virtual environment but I am not sure what that means in this case. What is the workflow here? I am having a hard time finding good primers on the subject. Often, there is no need to use a virtual environment. It is mainly used to isolate a project from other Python projects in order to minimize interference. Advantages of a "virtual environment": * you can set it up locally and extend it (by installing additional packages) without administrator rights. This is especially important when you lack those rights in your development environment * things you are doing in your virtual environment (for a given project) is not likely to interfere with other projects (if they use there own virtual environment). Similarly, you have some protection against the interference from other projects From tjreedy at udel.edu Mon Oct 19 04:23:58 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 19 Oct 2015 04:23:58 -0400 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk> Message-ID: On 10/18/2015 9:32 PM, Storey, Geneva wrote: > Same issue! See attached. -------- >> Can I suggest you find the turtle.py module in c:\windows\system32, move it >> to somewhere more suitable and try the code again? This seems strange. C:/Windows/System32 should only be writable by admin users, and even they should have no reason to put random files there. It would certainly be bad practice. There could be a screw-up with some systems. But we need much more info to say much. -- Terry Jan Reedy From mail at timgolden.me.uk Mon Oct 19 04:39:31 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 19 Oct 2015 09:39:31 +0100 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk> Message-ID: <5624AC43.3080105@timgolden.me.uk> On 19/10/2015 02:32, Storey, Geneva wrote: > Same issue! See attached. > Thanks! Geneva -- please try to post text, not pictures. Just use the mouse to cut-and-paste the entirety of the text from that window into an email. Otherwise some of the people who are trying to help you can't actually see what the problem is! [ Traceback show the same error coming from: c:\windows\system32\turtle.py ] This is a bit more tricky than it appears. If you're running on 64-bit Windows (which I can't tell from your screenshot) but your Python installation is 32-bit (which it is) then the folder which Python sees as "c:\windows\system32" is not the same folder which the normal Windows Explorer sees as "c:\windows\system32". Can you try going to this folder in Explorer: C:\windows\SysWOW64 and see if there's a turtle.py file there? If there is, move or delete it and try again. If that still doesn't work, can you tell us which version of Windows you're running, and whether it's 32 or 64-bit, please? If you're not sure how to get that information, try following the instructions here: http://ramblings.timgolden.me.uk/2015/10/08/what-windows-version-am-i-running/ TJG From a.h.jaffe at gmail.com Mon Oct 19 07:20:45 2015 From: a.h.jaffe at gmail.com (Andrew Jaffe) Date: Mon, 19 Oct 2015 12:20:45 +0100 Subject: OS X Python: can I explicitly set MACOSX_DEPLOYMENT_TARGET for extensions? Message-ID: I use the python.org framework build of Python under recent versions of OS X (i.e., 10.11 El Capitan). I need to build some extensions that rely on recent versions of compilers (e.g., C++-11 features). However the python.org python is built to work on older systems as well, for backward compatibility. Hence, it has the environment variable MACOSX_DEPLOYMENT_TARGET=10.6. This means that extensions are built by default with a toolchain that, I think, mimics gcc-4.2, in particular in terms of what stdlib it searches. In the past, I have fixed this by installing more recent compilers with homebrew and explicitly setting CC, CXX, etc before installation. However, I have tried just setting MACOSX_DEPLOYMENT_TARGET=10.11, and that seems to work. Is this safe? Are there any downsides? (I don't need to distribute these builds, just use them locally?) Conversely, are there any upsides? Does a newer deployment target allow more recent compilers and/or higher optimizations? -Andrew From geneva.storey at fultonind.kyschools.us Mon Oct 19 09:42:21 2015 From: geneva.storey at fultonind.kyschools.us (Storey, Geneva) Date: Mon, 19 Oct 2015 13:42:21 +0000 Subject: teacher need help! In-Reply-To: <5624AC43.3080105@timgolden.me.uk> References: <5623397C.40205@timgolden.me.uk> , <5624AC43.3080105@timgolden.me.uk> Message-ID: Our technician will be here this morning to take a look. I'll let you know what we find. Thanks again, Geneva Storey Fulton High School Spanish, Mathematics Bulldog Academy ________________________________________ From: Tim Golden Sent: Monday, October 19, 2015 3:39 AM To: Storey, Geneva Cc: python-list at python.org Subject: Re: teacher need help! On 19/10/2015 02:32, Storey, Geneva wrote: > Same issue! See attached. > Thanks! Geneva -- please try to post text, not pictures. Just use the mouse to cut-and-paste the entirety of the text from that window into an email. Otherwise some of the people who are trying to help you can't actually see what the problem is! [ Traceback show the same error coming from: c:\windows\system32\turtle.py ] This is a bit more tricky than it appears. If you're running on 64-bit Windows (which I can't tell from your screenshot) but your Python installation is 32-bit (which it is) then the folder which Python sees as "c:\windows\system32" is not the same folder which the normal Windows Explorer sees as "c:\windows\system32". Can you try going to this folder in Explorer: C:\windows\SysWOW64 and see if there's a turtle.py file there? If there is, move or delete it and try again. If that still doesn't work, can you tell us which version of Windows you're running, and whether it's 32 or 64-bit, please? If you're not sure how to get that information, try following the instructions here: http://ramblings.timgolden.me.uk/2015/10/08/what-windows-version-am-i-running/ TJG From rosuav at gmail.com Mon Oct 19 10:14:14 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 20 Oct 2015 01:14:14 +1100 Subject: Defamation In-Reply-To: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> Message-ID: On Mon, Oct 19, 2015 at 7:31 AM, gaini2002--- via Python-list wrote: > Please remove the page > https://mail.python.org/pipermail/python-list/2014-September/678498.html That page is just spam that someone sent to the newsgroup/mailing list. You can ignore it, same as the rest of us do. Even if the page were to be removed, the same content has already been posted to myriad news servers the world over, many of which archive all posts. There's no way to remove it from everywhere. ChrisA From torriem at gmail.com Mon Oct 19 10:36:37 2015 From: torriem at gmail.com (Michael Torrie) Date: Mon, 19 Oct 2015 08:36:37 -0600 Subject: Defamation In-Reply-To: References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> Message-ID: <5624FFF5.8000108@gmail.com> On 10/19/2015 08:14 AM, Chris Angelico wrote: > On Mon, Oct 19, 2015 at 7:31 AM, gaini2002--- via Python-list > wrote: >> Please remove the page > > That page is just spam that someone sent to the newsgroup/mailing > list. You can ignore it, same as the rest of us do. > > Even if the page were to be removed, the same content has already been > posted to myriad news servers the world over, many of which archive > all posts. There's no way to remove it from everywhere. Guess spam filtering is getting good as I don't recall ever seeing the original message last year, thank goodness. The message in question is not just ordinary spam. It is very specific spam, focused entirely on one person, claiming all kinds of bizarre things, with the intent to skew google search results to show this message when people search for that name. Clearly the post is from a mentally ill person as it barely makes much sense. While it's true that this message has now been duplicated across Usenet, it certainly can be removed from the pipermail archives. The OP can email python-list-owner at python.org and request it. It may not happen but it doesn't hurt to ask. From ian.g.kelly at gmail.com Mon Oct 19 11:01:37 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 19 Oct 2015 09:01:37 -0600 Subject: Defamation In-Reply-To: <5624FFF5.8000108@gmail.com> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <5624FFF5.8000108@gmail.com> Message-ID: On Mon, Oct 19, 2015 at 8:36 AM, Michael Torrie wrote: > On 10/19/2015 08:14 AM, Chris Angelico wrote: >> On Mon, Oct 19, 2015 at 7:31 AM, gaini2002--- via Python-list >> wrote: >>> Please remove the page >> >> That page is just spam that someone sent to the newsgroup/mailing >> list. You can ignore it, same as the rest of us do. >> >> Even if the page were to be removed, the same content has already been >> posted to myriad news servers the world over, many of which archive >> all posts. There's no way to remove it from everywhere. > > Guess spam filtering is getting good as I don't recall ever seeing the > original message last year, thank goodness. The message in question is > not just ordinary spam. It is very specific spam, focused entirely on > one person, claiming all kinds of bizarre things, with the intent to > skew google search results to show this message when people search for > that name. Clearly the post is from a mentally ill person as it barely > makes much sense. > > While it's true that this message has now been duplicated across Usenet, > it certainly can be removed from the pipermail archives. The OP can > email python-list-owner at python.org and request it. It may not happen > but it doesn't hurt to ask. Which is the same thing the OP was told the last time he posted a removal request publicly to this list. I do note that the subject of the previous request appears to have since been removed. I've taken the liberty of forwarding this request on to python-list-owner, on the theory that this will be more useful than discussion about it here. From Ralf.Hildebrandt at charite.de Mon Oct 19 11:08:25 2015 From: Ralf.Hildebrandt at charite.de (Ralf Hildebrandt) Date: Mon, 19 Oct 2015 17:08:25 +0200 Subject: Defamation In-Reply-To: References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <5624FFF5.8000108@gmail.com> Message-ID: <20151019150825.GG20343@charite.de> * Ian Kelly : > Which is the same thing the OP was told the last time he posted a > removal request publicly to this list. I do note that the subject of > the previous request appears to have since been removed. > > I've taken the liberty of forwarding this request on to > python-list-owner, on the theory that this will be more useful than > discussion about it here. > -- > https://mail.python.org/mailman/listinfo/python-list The right place is postmaster at python.org, since the owner cannot clean the archives. -- Ralf Hildebrandt Charite Universit?tsmedizin Berlin ralf.hildebrandt at charite.de Campus Benjamin Franklin http://www.charite.de Hindenburgdamm 30, 12203 Berlin Gesch?ftsbereich IT, Abt. Netzwerk fon: +49-30-450.570.155 From lac at openend.se Mon Oct 19 12:28:10 2015 From: lac at openend.se (Laura Creighton) Date: Mon, 19 Oct 2015 18:28:10 +0200 Subject: Defamation In-Reply-To: References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> Message-ID: <201510191628.t9JGSAAI029463@fido.openend.se> In a message of Tue, 20 Oct 2015 01:14:14 +1100, Chris Angelico writes: >On Mon, Oct 19, 2015 at 7:31 AM, gaini2002--- via Python-list > wrote: >> Please remove the page >> https://mail.python.org/pipermail/python-list/2014-September/678498.html > >That page is just spam that someone sent to the newsgroup/mailing >list. You can ignore it, same as the rest of us do. > >Even if the page were to be removed, the same content has already been >posted to myriad news servers the world over, many of which archive >all posts. There's no way to remove it from everywhere. > >ChrisA Actually, this one was part of a huge set of defaming articles sent a year ago we were requested to remove, and did. European Law may require us to do so. I checked, and this article wasn't one on our list, which is why we missed this one. Laura From lac at openend.se Mon Oct 19 12:29:58 2015 From: lac at openend.se (Laura Creighton) Date: Mon, 19 Oct 2015 18:29:58 +0200 Subject: Defamation In-Reply-To: <5624FFF5.8000108@gmail.com> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <5624FFF5.8000108@gmail.com> Message-ID: <201510191629.t9JGTwlw029692@fido.openend.se> In a message of Mon, 19 Oct 2015 08:36:37 -0600, Michael Torrie writes: >On 10/19/2015 08:14 AM, Chris Angelico wrote: >> On Mon, Oct 19, 2015 at 7:31 AM, gaini2002--- via Python-list >> wrote: >>> Please remove the page >> >> That page is just spam that someone sent to the newsgroup/mailing >> list. You can ignore it, same as the rest of us do. >> >> Even if the page were to be removed, the same content has already been >> posted to myriad news servers the world over, many of which archive >> all posts. There's no way to remove it from everywhere. > >Guess spam filtering is getting good as I don't recall ever seeing the >original message last year, thank goodness. The message in question is >not just ordinary spam. It is very specific spam, focused entirely on >one person, claiming all kinds of bizarre things, with the intent to >skew google search results to show this message when people search for >that name. Clearly the post is from a mentally ill person as it barely >makes much sense. > >While it's true that this message has now been duplicated across Usenet, >it certainly can be removed from the pipermail archives. The OP can >email python-list-owner at python.org and request it. It may not happen >but it doesn't hurt to ask. I've already asked postmaster, which is the place where such things get done. There was something close to 100 of these things originally. Laura From rosuav at gmail.com Mon Oct 19 12:31:39 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 20 Oct 2015 03:31:39 +1100 Subject: Defamation In-Reply-To: <201510191628.t9JGSAAI029463@fido.openend.se> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <201510191628.t9JGSAAI029463@fido.openend.se> Message-ID: On Tue, Oct 20, 2015 at 3:28 AM, Laura Creighton wrote: >>Even if the page were to be removed, the same content has already been >>posted to myriad news servers the world over, many of which archive >>all posts. There's no way to remove it from everywhere. >> >>ChrisA > > Actually, this one was part of a huge set of defaming articles sent a > year ago we were requested to remove, and did. European Law may > require us to do so. I checked, and this article wasn't one on > our list, which is why we missed this one. It's still impossible to remove it from _everywhere_. Whether that makes it pointless to remove it from the python-list archive is a matter for debate, and as several have pointed out, such removal can be done; but there will be other archives elsewhere, so the content is still out there and visible. ChrisA From mail at timgolden.me.uk Mon Oct 19 12:36:00 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 19 Oct 2015 17:36:00 +0100 Subject: Defamation In-Reply-To: <201510191629.t9JGTwlw029692@fido.openend.se> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <5624FFF5.8000108@gmail.com> <201510191629.t9JGTwlw029692@fido.openend.se> Message-ID: <56251BF0.6010801@timgolden.me.uk> On 19/10/2015 17:29, Laura Creighton wrote: > In a message of Mon, 19 Oct 2015 08:36:37 -0600, Michael Torrie writes: >> On 10/19/2015 08:14 AM, Chris Angelico wrote: >>> On Mon, Oct 19, 2015 at 7:31 AM, gaini2002--- via Python-list >>> wrote: >>>> Please remove the page >>> >>> That page is just spam that someone sent to the newsgroup/mailing >>> list. You can ignore it, same as the rest of us do. >>> >>> Even if the page were to be removed, the same content has already been >>> posted to myriad news servers the world over, many of which archive >>> all posts. There's no way to remove it from everywhere. >> >> Guess spam filtering is getting good as I don't recall ever seeing the >> original message last year, thank goodness. The message in question is >> not just ordinary spam. It is very specific spam, focused entirely on >> one person, claiming all kinds of bizarre things, with the intent to >> skew google search results to show this message when people search for >> that name. Clearly the post is from a mentally ill person as it barely >> makes much sense. >> >> While it's true that this message has now been duplicated across Usenet, >> it certainly can be removed from the pipermail archives. The OP can >> email python-list-owner at python.org and request it. It may not happen >> but it doesn't hurt to ask. > > I've already asked postmaster, which is the place where such things get > done. There was something close to 100 of these things originally. ... and I've been kicking them out of moderation at the rate of about 2 a week ever since, I think. (At least: that's what it feels like). TJG From jeanmichel at sequans.com Mon Oct 19 13:42:50 2015 From: jeanmichel at sequans.com (jmp) Date: Mon, 19 Oct 2015 19:42:50 +0200 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk> , <5624AC43.3080105@timgolden.me.uk> Message-ID: On 10/19/2015 03:42 PM, Storey, Geneva wrote: > Our technician will be here this morning to take a look. I'll let you know what we find. > Thanks again, > > Geneva Storey import turtle print turtle.__file__ may help you find the offending file. jm From JonRob Mon Oct 19 14:39:36 2015 From: JonRob (JonRob) Date: Mon, 19 Oct 2015 14:39:36 -0400 Subject: variable scope of class objects Message-ID: Hi, I've having trouble understanding the self concept as it applies to variables. I think I understand how it affects methods. I haven't been able to fully grasp the scope of class variables and the effect of the "self" to the scope of the variable. I (think) I understand that in the below case, the word self could be replaced with "BME280" to explicitly call out a variable. But even still I don't know how explicit call out effects the scope of a variable. The below pseudo code is distilled from my 1st attempt at a functional Python program on the RasPi. My questions are: What is the scope of class variables? does the self. prefix modify this scope? Thanks Regards JonRob #!/usr/bin/python # -- developed using Python 2.7.3 class BME280: # all the below are class variables # those preceded by an underscore are predefined to some constant # those without the underscore are to be "working" variables. _regT1 = 0x88 _regH6 = 0xE7 _coeff_P2 = 0x82 _coeff_P6 = 0x32 filter = 0 #should these be "self"? t_fine = 0 def __init__(self, address=0x76, debug=True): self.i2c = Adafruit_I2C(address) self.address = address self.debug = debug def pressure_calc(self): var1 = self.i2c.readU16(self._regT1,False) p = (1048576.0 - var1) * _coeff_P2 return p def read_pressure(self): #called by main application pressure_hPa = pressure_calc(self) /10 # apply compensation return pressure_hPa From random832 at fastmail.com Mon Oct 19 15:01:14 2015 From: random832 at fastmail.com (Random832) Date: Mon, 19 Oct 2015 15:01:14 -0400 Subject: variable scope of class objects References: Message-ID: <87fv167ked.fsf@fastmail.com> JonRob at mail.python.org writes: > > The below pseudo code is distilled from my 1st attempt at a functional > Python program on the RasPi. > > My questions are: > What is the scope of class variables? You must access them as members of the class or an instance of the class. > does the self. prefix modify this scope? self just refers to the instance of the class that the function was called with. It can be any name. Python automatically transforms any reference to "[object].func" into a function (specifically, a bound method object) that will prefix [object] to the argument list of the defined function. > #!/usr/bin/python > # -- developed using Python 2.7.3 > > class BME280: > > # all the below are class variables > # those preceded by an underscore are predefined to some constant Constants should be in uppercase, not prefixed with an underscore. Names prefixed with an underscore imply that they are "private" (not really) and therefore other code should not use them directly > # those without the underscore are to be "working" variables. I don't know what you mean by "working". > > _regT1 = 0x88 > _regH6 = 0xE7 > _coeff_P2 = 0x82 > _coeff_P6 = 0x32 > > filter = 0 #should these be "self"? > t_fine = 0 I don't know, should they? If so they need to be in __init__. You haven't provided any functions that use them, so it's not clear what they're for. > > def __init__(self, address=0x76, debug=True): > self.i2c = Adafruit_I2C(address) > self.address = address > self.debug = debug > > def pressure_calc(self): > var1 = self.i2c.readU16(self._regT1,False) > p = (1048576.0 - var1) * _coeff_P2 > return p > > def read_pressure(self): #called by main application > pressure_hPa = pressure_calc(self) /10 > # apply compensation > return pressure_hPa From manjunatha.mahalingappa at gmail.com Mon Oct 19 17:48:41 2015 From: manjunatha.mahalingappa at gmail.com (manjunatha.mahalingappa at gmail.com) Date: Mon, 19 Oct 2015 14:48:41 -0700 (PDT) Subject: How to log the output from the multiple telnet sessions to separate log file In-Reply-To: References: Message-ID: <1d1cd0e5-ed4f-4dc0-a8c3-fcc11b0f8ae3@googlegroups.com> On Friday, October 16, 2015 at 11:11:58 PM UTC-7, dieter wrote: > manjunatha.mahalingappa at gmail.com writes: > > I'm very much new to python. > > I'm doing the automation for networking device testing , I will be opening the 4 telnet session, and doing some testing operations on each of those telnet sessions and capture or log the respective output in 4 different log files. > > Personally, I find it a bit strange that each (telnet) session > should get its own logfile, but, if that is what you need, I would > approach it as follows: > > * define a class "TelnetSession"; create a logger in its "__init__" method; > use this logger for all operations inside a "TelnetSession" > > * instantiate the class "TelnetSession" for each telnet session you > want to open. > Use those objects method to operate on the sessions. Hello Dieter, I created the my own class MyLogger and passing log file name to it. I'm seeing no log is being written to passed log file instead everything is written to the logfilename [actually logfilename is variable with file name] I'm trying to create MyLogger object for each telnet session. and use that object. MyLogger is beeing called inside the Telnetsession class. those are present in PmTelnet3.py file. class MyLogger(): import logging def __init__(self,logfilename): #create logger with 'spam_application' self.logger = self.logging.getLogger('TelnetSession') self.logger.setLevel(self.logging.INFO) # create file handler which logs even debug messages #self.fh = self.logging.FileHandler(logfile) print "The log file name is %s\n" % logfilename self.logging.basicConfig(filename = logfilename, level = self.logging.INFO , format= '%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%m-%d %H:%M', filemode='w') # create console handler with a higher log level self.ch = self.logging.StreamHandler() def Log(self): self.logger.setLevel(self.logging.INFO) self.fh.setLevel(self.logging.INFO) self.ch.setLevel(self.logging.INFO) self.fh.setFormatter(self.formatter) self.ch.setFormatter(self.formatter) self.logger.addHandler(self.ch) class TelnetSession: import telnetlib import logging def __init__(self, inHost, inPort, Logname): self.log = MyLogger(Logname) self.telnet = self.telnetlib.Telnet(inHost, inPort) ---------------------------------------------------------------------------- def IP_port(file) : global Testbed_info Testbed_info = [] F = open(file, 'r') F.seek(0) line = F.read() tuples = re.findall(r'(.+ \d)\s+(.+?)\s+(\d+)', line) for (dname, ip, port) in tuples : LogFileName = dname.replace(" ","") + ".log" #Log = open(logfile, "a") #Log = MyLogger(LogFileName) Telnet_handle=PmTelnet3.TelnetSession(ip,port,LogFileName) tuple = (dname, ip, port, Telnet_handle ) print tuple Testbed_info.append(tuple) #T.append(T1) return(Testbed_info) #This function is to switch the console file = '/users/manmahal/MANJU/IP_port.txt' Testbed_info = IP_port(file) print "Iam done" for (dname, ip, port, Telnet) in Testbed_info : My_handle = Telnet #My_log = log My_handle.Write("\n") My_handle.Write("show config \n") time.sleep(2) output = My_handle.ReadBuffer() #My_fp.write(My_handle.ReadBuffer()) My_handle.log.logger.info(output) My_handle.log.logger.info("HI THERE") Kindly let me know how can I fix this.. From rosuav at gmail.com Mon Oct 19 19:03:45 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 20 Oct 2015 10:03:45 +1100 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk> <5624AC43.3080105@timgolden.me.uk> Message-ID: On Tue, Oct 20, 2015 at 4:42 AM, jmp wrote: > import turtle > > print turtle.__file__ > > may help you find the offending file. > > jm In general, yes. Sadly, that technique doesn't work when the file attempts to import itself, and then errors out; your driver script will simply get an ImportError. (That said, though: The ImportError will include the traceback that gives the file name. But that's no different from what we already know.) ChrisA From sohcahtoa82 at gmail.com Mon Oct 19 19:19:15 2015 From: sohcahtoa82 at gmail.com (sohcahtoa82 at gmail.com) Date: Mon, 19 Oct 2015 16:19:15 -0700 (PDT) Subject: variable scope of class objects In-Reply-To: References: Message-ID: <00fbd018-4188-40da-bacf-394d762c9bed@googlegroups.com> On Monday, October 19, 2015 at 11:39:59 AM UTC-7, JonRob wrote: > Hi, > > I've having trouble understanding the self concept as it applies to > variables. I think I understand how it affects methods. > > I haven't been able to fully grasp the scope of class variables and > the effect of the "self" to the scope of the variable. > > I (think) I understand that in the below case, the word self could be > replaced with "BME280" to explicitly call out a variable. > > But even still I don't know how explicit call out effects the scope of > a variable. > > The below pseudo code is distilled from my 1st attempt at a functional > Python program on the RasPi. > > My questions are: > What is the scope of class variables? > does the self. prefix modify this scope? > > Thanks > > Regards > > JonRob > > > > > #!/usr/bin/python > # -- developed using Python 2.7.3 > > class BME280: > > # all the below are class variables > # those preceded by an underscore are predefined to some constant > # those without the underscore are to be "working" variables. > > _regT1 = 0x88 > _regH6 = 0xE7 > _coeff_P2 = 0x82 > _coeff_P6 = 0x32 > > filter = 0 #should these be "self"? > t_fine = 0 > > def __init__(self, address=0x76, debug=True): > self.i2c = Adafruit_I2C(address) > self.address = address > self.debug = debug > > def pressure_calc(self): > var1 = self.i2c.readU16(self._regT1,False) > p = (1048576.0 - var1) * _coeff_P2 > return p > > def read_pressure(self): #called by main application > pressure_hPa = pressure_calc(self) /10 > # apply compensation > return pressure_hPa Class variables are accessible without creating an instance of a class. Also, changing the value of a class variable affects ALL instances of that class. This is because the variable belongs to the class itself, not any of the instances of that class. "self" is used to tell the interpreter that the variable/function you are accessing is a member of an instance of that class. Here's an example: class MyObject(object): count = 0 def __init__(value): MyObject.count += 1 self.value = value def printStuff(): print("My value is ", self.value) print(MyObject.count) # This will print 0 a = MyObject('a') print(MyObject.count) # This will print 1 print(a.count) # This will also print 1 a.printStuff() # This will print "My value is a" b = MyObject('b') print(a.count) # This will print 2 print(b.count) # This will also print 2 b.printStuff() # This will print "My value is b" From tjreedy at udel.edu Mon Oct 19 20:03:43 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 19 Oct 2015 20:03:43 -0400 Subject: variable scope of class objects In-Reply-To: <00fbd018-4188-40da-bacf-394d762c9bed@googlegroups.com> References: <00fbd018-4188-40da-bacf-394d762c9bed@googlegroups.com> Message-ID: On 10/19/2015 7:19 PM, sohcahtoa82 at gmail.com wrote: > Class variables are accessible without creating an instance of a class. Also, changing the value of a class variable affects ALL instances of that class. This is because the variable belongs to the class itself, not any of the instances of that class. > > "self" is used to tell the interpreter that the variable/function you are accessing is a member of an instance of that class. Wrong. The first parameter of a method is an instance of a class. It is conventionally called 'self' but could be any other name. I use 's' for quick private test examples. > Here's an example: > > class MyObject(object): > count = 0 > def __init__(value): This should be def __init__(self, value): > MyObject.count += 1 > self.value = value > > def printStuff(): def print(self): > print("My value is ", self.value) > a = MyObject('a') In 2.7.10 TypeError: __init__() takes exactly 1 argument (2 given) Please run code before posting. -- Terry Jan Reedy From gandalf at shopzeus.com Tue Oct 20 01:31:02 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Tue, 20 Oct 2015 07:31:02 +0200 Subject: variable scope of class objects In-Reply-To: References: Message-ID: <5625D196.2000403@shopzeus.com> > > #!/usr/bin/python > # -- developed using Python 2.7.3 > > class BME280: Not strictly related to the question, but you probably want to use so called "new style classes" when developing a new program for Python version 2. In other words, use: class BME280(object): instead of class BME280: From gandalf at shopzeus.com Tue Oct 20 01:49:08 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Tue, 20 Oct 2015 07:49:08 +0200 Subject: variable scope of class objects In-Reply-To: References: Message-ID: <5625D5D4.5040006@shopzeus.com> > My questions are: > What is the scope of class variables? In Python, you bind values (objects) to names. It is conceptually different from "setting the value of a variable". In Python, scope applies to names, not variables. When you say "class variable", what do you mean? This may help: A namespace is just a dictionary that binds names to objects. AFAIK there are three kinds of namepaces: local, global and namespaces of other programming tools that can define their own namespaces. Namely: eache modul and class defines its own namespace. So if you bind a name to an object at module level, then that name will be put into the module's namespace. When you bind a name inside a class, for example: class A(object): example_name = 5 then the name "example_name" will be placed in the namespace of the class, and it can be accessed using the class. E.g. "A.example_name". The so called local namespace belongs to functions and methods being called. Any name that is assigned locally inside a method will be a local name of that method, and it will be visible from that method only - except if you explicitely tell that it should be global using the "global" keyword. Formal parameters of methods are also local names, but they get assigned a value when the method is called. The process of assigning actucal objects for formal parameters is called binding. When binding is done, the parameters will become "actual parameters" or "arguments" that have an actual object assigned. Please note the difference between formal parameters and arguments: * Formal parameters are syntactical. They do not have an object (value) assigned. * Arguments are objects bound to formal parameters. They do have an object assigned, but arguments only exist while the method is being called (or ACTIVE, meaning: they are part of the call chain). Methods of objects and classes always have an implicit parameter, that is bound to the object or class the method was called on. In the case of classmethods, it will be a class. In the case of objects, it will be an object. (In case of static methods, there is no implicit parameter.) Apart from being an implicit parameter, there is nothing special about the first parameter of a method. > does the self. prefix modify this scope? It should be clear now, that in this case: def pressure_calc(self): the name "self" is a formal parameter of the "pressure_calc" method, because it is in the formal parameter list. When this method gets called, the name "self" is assigned to the object the method was called on. Because the name "self" is a parameter, it will be a local name of the method, and it will be accessible from inside that method only. -------------- next part -------------- An HTML attachment was scrubbed... URL: From otlucaDELETE at DELETEyahoo.it Tue Oct 20 02:17:16 2015 From: otlucaDELETE at DELETEyahoo.it (Luca Menegotto) Date: Tue, 20 Oct 2015 08:17:16 +0200 Subject: variable scope of class objects References: Message-ID: Il 19/10/2015 20:39, JonRob ha scritto: > I (think) I understand that in the below case, the word self could be > replaced with "BME280" to explicitly call out a variable. > > But even still I don't know how explicit call out effects the scope of > a variable. These two statements make me think you come from C++ or something similar. In Python you can declare variables at class level, but this declaration must NOT be interpreted in the same manner of a similar declaration in C++: they remain at the abstract level of a class, and they have nothing to do with an instance of a class (in fact, to be correctly invoked, they must be preceeded by the class name). 'self' (or a similar representation, you could use 'this' without problem) gives you access to the instance of the class, even in the constructor; it is important, because the constructor is the place where instance variables should be defined. Something like this: class foo: # invoke with foo._imAtClassLevel _imAtClassLevel = 10 def __init__(self): # need to say how this must be invoked? self._imAtInstanceLevel = 0 no confusion is possible, because: class foo2: _variable = 1000 def __init__(self): # let's initialize an instance variable with # a class variable self._variable = foo2._variable Please, note that declaring a variable in the constructor is only a convention: in Python you can add a variable to an object of a class wherever you want in your code (even if it is very dangerous and discouraged). -- Ciao! Luca From gandalf at shopzeus.com Tue Oct 20 02:38:04 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Tue, 20 Oct 2015 08:38:04 +0200 Subject: variable scope of class objects In-Reply-To: References: Message-ID: <5625E14C.2060709@shopzeus.com> > These two statements make me think you come from C++ or something > similar. > > In Python you can declare variables at class level, but this > declaration must NOT be interpreted in the same manner of a similar > declaration in C++: they remain at the abstract level of a class, and > they have nothing to do with an instance of a class (in fact, to be > correctly invoked, they must be preceeded by the class name). When you say "they have nothing to do", it is almost true but not 100%. When accessing attributes of an instance, Python first searches in the namespace of the instance. When not found, it searches in the namespace of its class. So for example: >>> >>> class A(object): ... a = ["value 1"] ... def set_a(self): ... # This will bind the value to the name "a" in the namespace of the instance (!!!), not the class ... self.a = ["value 3"] ... >>> a = A() >>> b = A() >>> print A.a # ["value 1"] ['value 1'] >>> print a.a # ["value 1"] ['value 1'] >>> print b.a # ["value 1"] ['value 1'] >>> A.a.append("value 2") >>> print A.a # ["value 1","value 2"] ['value 1', 'value 2'] >>> print a.a # ["value 1","value 2"] ['value 1', 'value 2'] >>> print b.a # ["value 1","value 2"] ['value 1', 'value 2'] >>> a.set_a() >>> print a.a # ["value 3"] ['value 3'] >>> print A.a # ["value 1","value 2"] ['value 1', 'value 2'] >>> print b.a # ["value 1","value 2"] ['value 1', 'value 2'] >>> print A.a is b.a # True True >>> print a.a is b.a # False False >>> b.a.append("value 4") >>> A.a ['value 1', 'value 2', 'value 4'] >>> del a.a >>> a.a ['value 1', 'value 2', 'value 4'] >>> Some objects are designed this way: the attribute with the same name can be bound to an object stored at class level or at instance level, depending on how the object was created or used. In other words: when you access an attrbute through an object, you can very well reach a class attribute instead of an object attribute; and this behaviour can be different for different instances of the same class. Just look at the last attribute deletion - by deleting an attribute of an instance, further attribute access will hit the class level object. The same behaviour is unthinkable with C++. From otlucaDELETE at DELETEyahoo.it Tue Oct 20 03:23:54 2015 From: otlucaDELETE at DELETEyahoo.it (Luca Menegotto) Date: Tue, 20 Oct 2015 09:23:54 +0200 Subject: variable scope of class objects References: Message-ID: Il 20/10/2015 08:38, Nagy L?szl? Zsolt ha scritto: > When you say "they have nothing to do", it is almost true but not 100%. I know it, but when it comes to eradicate an idea that comes directly from C++-like languages, you must be drastic. Nuances come after... -- Ciao! Luca From ngangsia at gmail.com Tue Oct 20 04:44:31 2015 From: ngangsia at gmail.com (ngangsia akumbo) Date: Tue, 20 Oct 2015 01:44:31 -0700 (PDT) Subject: unsupported operand type(s) python v2.7 Message-ID: <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com> >>> def n(): 34 * 2 >>> def g(): 4 + 2 >>> def ng(): return n() + g() >>> ng() Traceback (most recent call last): File "", line 1, in ng() File "", line 2, in ng return n() + g() TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType' From wolfgang.maier at biologie.uni-freiburg.de Tue Oct 20 05:00:08 2015 From: wolfgang.maier at biologie.uni-freiburg.de (Wolfgang Maier) Date: Tue, 20 Oct 2015 11:00:08 +0200 Subject: unsupported operand type(s) python v2.7 In-Reply-To: <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com> References: <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com> Message-ID: On 20.10.2015 10:44, ngangsia akumbo wrote: >>>> def n(): > 34 * 2 > > >>>> def g(): > 4 + 2 > Your n and g functions do not have an explicit return so, after doing their calculations and throwing the result away, they return None. >>>> def ng(): > return n() + g() > >>>> ng() > > Traceback (most recent call last): > File "", line 1, in > ng() > File "", line 2, in ng > return n() + g() > TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType' > The attempt in ng to add None to None then produce the exception you are seeing. From ngangsia at gmail.com Tue Oct 20 05:08:34 2015 From: ngangsia at gmail.com (ngangsia akumbo) Date: Tue, 20 Oct 2015 02:08:34 -0700 (PDT) Subject: unsupported operand type(s) python v2.7 In-Reply-To: References: <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com> Message-ID: On Tuesday, October 20, 2015 at 10:01:44 AM UTC+1, Wolfgang Maier wrote: > On 20.10.2015 10:44, ngangsia akumbo wrote: > >>>> def n(): > > 34 * 2 > > > > > >>>> def g(): > > 4 + 2 > > > > Your n and g functions do not have an explicit return so, after doing > their calculations and throwing the result away, they return None. > > >>>> def ng(): > > return n() + g() > > > >>>> ng() > > > > Traceback (most recent call last): > > File "", line 1, in > > ng() > > File "", line 2, in ng > > return n() + g() > > TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType' > > > > The attempt in ng to add None to None then produce the exception you are > seeing. thanks From ngangsia at gmail.com Tue Oct 20 05:13:46 2015 From: ngangsia at gmail.com (ngangsia akumbo) Date: Tue, 20 Oct 2015 02:13:46 -0700 (PDT) Subject: unsupported operand type(s) python v2.7 In-Reply-To: References: <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com> Message-ID: On Tuesday, October 20, 2015 at 10:08:51 AM UTC+1, ngangsia akumbo wrote: > On Tuesday, October 20, 2015 at 10:01:44 AM UTC+1, Wolfgang Maier wrote: > > On 20.10.2015 10:44, ngangsia akumbo wrote: > > >>>> def n(): > > > 34 * 2 > > > > > > > > >>>> def g(): > > > 4 + 2 > > > > > > > Your n and g functions do not have an explicit return so, after doing > > their calculations and throwing the result away, they return None. > > > > >>>> def ng(): > > > return n() + g() > > > > > >>>> ng() > > > > > > Traceback (most recent call last): > > > File "", line 1, in > > > ng() > > > File "", line 2, in ng > > > return n() + g() > > > TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType' > > > > > > > The attempt in ng to add None to None then produce the exception you are > > seeing. > > thanks def n(): return 3 * 2 def g(): return 3+ 6 def ng(): return n()+g() print ng() From tjreedy at udel.edu Tue Oct 20 06:33:03 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 20 Oct 2015 06:33:03 -0400 Subject: 1 million new Python 3 users (next spring) Message-ID: From a PSF mailing list, this announcement. http://ntoll.org/article/story-micropython-on-microbit Contributions invited. -- Terry Jan Reedy From Ralf.Hildebrandt at charite.de Tue Oct 20 06:41:50 2015 From: Ralf.Hildebrandt at charite.de (Ralf Hildebrandt) Date: Tue, 20 Oct 2015 12:41:50 +0200 Subject: Defamation In-Reply-To: <201510191628.t9JGSAAI029463@fido.openend.se> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <201510191628.t9JGSAAI029463@fido.openend.se> Message-ID: <20151020104149.GM16569@charite.de> * Laura Creighton : > Actually, this one was part of a huge set of defaming articles sent a > year ago we were requested to remove, and did. European Law may > require us to do so. I checked, and this article wasn't one on > our list, which is why we missed this one. Note that the "next in thread" also was of defamatory content. Removed as well. -- Ralf Hildebrandt Charite Universit?tsmedizin Berlin ralf.hildebrandt at charite.de Campus Benjamin Franklin http://www.charite.de Hindenburgdamm 30, 12203 Berlin Gesch?ftsbereich IT, Abt. Netzwerk fon: +49-30-450.570.155 From steve at pearwood.info Tue Oct 20 09:09:18 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 21 Oct 2015 00:09:18 +1100 Subject: Defamation References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> Message-ID: <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> On Tue, 20 Oct 2015 03:28 am, Laura Creighton wrote: > Actually, this one was part of a huge set of defaming articles sent a > year ago we were requested to remove, and did. European Law may > require us to do so. I checked, and this article wasn't one on > our list, which is why we missed this one. I don't believe that the Python mailing list archives are hosted in a country under the jurisdiction of European Law. If I'm right, then removing posts sets a dangerous precedent of obeying laws in foreign countries that don't apply. Today we're removing allegedly defaming posts because European law may or may not apply (probably doesn't); tomorrow we're removing posts because they fall foul of unreasonable laws anywhere in the world. E.g. suppose I say that the Thai king can't program for crap. If I were under the jurisdiction of Thai law, I might be in trouble for offending the dignity of the king. https://en.wikipedia.org/wiki/L?se-majest? Fortunately I'm not, but if I were, I would hope that my post(s) would not be deleted just because some touchy royal got his nose out of joint. Or if I happen to mention some (hypothetical) data-mining program I've written which demonstrates that the judeo-christian god is clearly derived from earlier polytheistic Hebrew traditions, I might be in trouble for blasphemy in various countries. And let's not even touch on anything to do with sharia law... The point is, obeying laws that don't apply, even if well-meaning, opens us to a dangerous precedent that we shouldn't go near. There's another reason to try very, very hard to avoid deleting archived posts: until such time as python.org moves to Mailman3, deleting a single posts breaks the permalinks for *every single post* for the entire month. -- Steven From zachary.ware+pylist at gmail.com Tue Oct 20 09:24:58 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Tue, 20 Oct 2015 08:24:58 -0500 Subject: unsupported operand type(s) python v2.7 In-Reply-To: References: <695863e0-7c7b-4739-bbc7-6719e40133fb@googlegroups.com> Message-ID: On Oct 20, 2015 4:15 AM, "ngangsia akumbo" wrote: > def n(): > return 3 * 2 > > def g(): > return 3+ 6 > > def ng(): > return n()+g() > > print ng() Much better :) -- Zach (On a phone) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ashwath at nanoheal.com Tue Oct 20 09:45:40 2015 From: ashwath at nanoheal.com (ashwath at nanoheal.com) Date: Tue, 20 Oct 2015 06:45:40 -0700 Subject: Installing pywin32. In-Reply-To: Message-ID: <20151020064540.d600875ec5143fcc53c5b00e1a6550c2.23ecdf2e02.mailapi@email23.secureserver.net> Hi Is it possible to pause and restart the file upload process to S3 AWS ? I ll be happy if you get me a solution for this, I have an account in the S3, so please help with this. Thanking you in advance. I tried with boto3 module but I couldn't do it . Thanks & Regards Ashwath B H --------- Original Message --------- Subject: RE: Re: Re: Installing pywin32. From: "Abhiram R" Date: 9/28/15 7:12 pm To: ashwath at nanoheal.com Cc: "comp. lang. python" > > I will give the team viewer ID of my machine so can you please install the pywin32 module to me. > Hi , It's best if you install it yourself. It isn't really complicated. :) and you'll learn it in the process as well Steps you could possibly Google - 1) installation of Python 3.5 (which i believe is done) 2) set PYTHONPATH in Windows 3) installation of pip on Windows 4) pip install pypiwin32 That's all there is to it. PS- I'm sure you must have searched for your original problem's solution as well. If not, here's the corresponding stackoverflow thread that can possibly help you as well - http://googleweblight.com/?lite_url=http://stackoverflow.com/questions/25257274/python-3-4-importerror-no-module-named-win32api&ei=rMvmto7N&lc=en-IN&s=1&m=978&ts=1443447404&sig=APONPFlqU_v1gaBPeJ1YluSJxcvkrCVpnQ Thanks Abhiram -------------- next part -------------- An HTML attachment was scrubbed... URL: From Ralf.Hildebrandt at charite.de Tue Oct 20 09:46:33 2015 From: Ralf.Hildebrandt at charite.de (Ralf Hildebrandt) Date: Tue, 20 Oct 2015 15:46:33 +0200 Subject: Defamation In-Reply-To: <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20151020134632.GA16569@charite.de> * Steven D'Aprano : > On Tue, 20 Oct 2015 03:28 am, Laura Creighton wrote: > > > Actually, this one was part of a huge set of defaming articles sent a > > year ago we were requested to remove, and did. European Law may > > require us to do so. I checked, and this article wasn't one on > > our list, which is why we missed this one. > > I don't believe that the Python mailing list archives are hosted in a > country under the jurisdiction of European Law. The Netherlands it is. -- Ralf Hildebrandt Charite Universit?tsmedizin Berlin ralf.hildebrandt at charite.de Campus Benjamin Franklin http://www.charite.de Hindenburgdamm 30, 12203 Berlin Gesch?ftsbereich IT, Abt. Netzwerk fon: +49-30-450.570.155 From lac at openend.se Tue Oct 20 10:44:58 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 20 Oct 2015 16:44:58 +0200 Subject: Defamation In-Reply-To: <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201510201444.t9KEiwVr032021@fido.openend.se> In a message of Wed, 21 Oct 2015 00:09:18 +1100, "Steven D'Aprano" writes: >On Tue, 20 Oct 2015 03:28 am, Laura Creighton wrote: > >> Actually, this one was part of a huge set of defaming articles sent a >> year ago we were requested to remove, and did. European Law may >> require us to do so. I checked, and this article wasn't one on >> our list, which is why we missed this one. >Today we're removing allegedly defaming posts because European law may or >may not apply (probably doesn't); tomorrow we're removing posts because >they fall foul of unreasonable laws anywhere in the world. No, we are removing them because we want to. >The point is, obeying laws that don't apply, even if well-meaning, opens us >to a dangerous precedent that we shouldn't go near. Pointedly not doing something you want to because it might make us obedient to some law we don't have to obey seems a matter of cutting off ones nose to spite one's face. >There's another reason to try very, very hard to avoid deleting archived >posts: until such time as python.org moves to Mailman3, deleting a single >posts breaks the permalinks for *every single post* for the entire month. No, I think we were smarter than that in the script. >Steven Laura From geneva.storey at fultonind.kyschools.us Tue Oct 20 12:25:58 2015 From: geneva.storey at fultonind.kyschools.us (Storey, Geneva) Date: Tue, 20 Oct 2015 16:25:58 +0000 Subject: teacher need help! In-Reply-To: <5624AC43.3080105@timgolden.me.uk> References: <5623397C.40205@timgolden.me.uk> , <5624AC43.3080105@timgolden.me.uk> Message-ID: FYI-We formatted the machines, reinstalling everything, including Python. I works with no problems now. Confusing that this would happen on 3 out of 13 machines. Just letting you know, all is well. Thank you for your help! Geneva Geneva Storey Fulton High School Spanish, Mathematics Bulldog Academy ________________________________________ From: Tim Golden Sent: Monday, October 19, 2015 3:39 AM To: Storey, Geneva Cc: python-list at python.org Subject: Re: teacher need help! On 19/10/2015 02:32, Storey, Geneva wrote: > Same issue! See attached. > Thanks! Geneva -- please try to post text, not pictures. Just use the mouse to cut-and-paste the entirety of the text from that window into an email. Otherwise some of the people who are trying to help you can't actually see what the problem is! [ Traceback show the same error coming from: c:\windows\system32\turtle.py ] This is a bit more tricky than it appears. If you're running on 64-bit Windows (which I can't tell from your screenshot) but your Python installation is 32-bit (which it is) then the folder which Python sees as "c:\windows\system32" is not the same folder which the normal Windows Explorer sees as "c:\windows\system32". Can you try going to this folder in Explorer: C:\windows\SysWOW64 and see if there's a turtle.py file there? If there is, move or delete it and try again. If that still doesn't work, can you tell us which version of Windows you're running, and whether it's 32 or 64-bit, please? If you're not sure how to get that information, try following the instructions here: http://ramblings.timgolden.me.uk/2015/10/08/what-windows-version-am-i-running/ TJG From torriem at gmail.com Tue Oct 20 13:39:34 2015 From: torriem at gmail.com (Michael Torrie) Date: Tue, 20 Oct 2015 11:39:34 -0600 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk> , <5624AC43.3080105@timgolden.me.uk> Message-ID: <56267C56.40300@gmail.com> On 10/20/2015 10:25 AM, Storey, Geneva wrote: > FYI-We formatted the machines, reinstalling everything, including > Python. I works with no problems now. Confusing that this would > happen on 3 out of 13 machines. Just letting you know, all is well. > Thank you for your help! Geneva Wow that seems rather drastic. Your tech never found the errant turtle.py files? If this problem happened before, it's bound to happen again, and like has been mentioned, the problem is simply a matter of a student's "turtle.py" file being saved to a place where it interferes with Python's own turtle.py file. In fact I would recommend you encourage your students to not use the name "turtle.py" when saving files. Even one in the same directory as a file that imports turtle will shadow the system one. Will save you pain and suffering anyway. From martin.schoon at gmail.com Tue Oct 20 14:57:03 2015 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 20 Oct 2015 18:57:03 GMT Subject: How to rearrange array using Python? References: <1468455.P0rGZF1LBf@PointedEars.de> Message-ID: It has been a while. I have mastered solving Kenken and Sudoku using Python-constraint. I still have no clue on how to tell the solver how to constrain the number of occupants in rooms: I have made up an simple example with nine persons and three rooms. Wishes for room mates are mild in the extreme so it is very easy for a human to place these nine persons in the three three-bed rooms such that all wishes are fulfilled. Python-constraint set up by me finds 27 solutions of which most place more than three persons in at least one room. Anyone into CSP willing to offer me a hint? /Martin From ian.g.kelly at gmail.com Tue Oct 20 15:26:11 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 20 Oct 2015 13:26:11 -0600 Subject: How to rearrange array using Python? In-Reply-To: References: <1468455.P0rGZF1LBf@PointedEars.de> Message-ID: On Tue, Oct 20, 2015 at 12:57 PM, Martin Sch??n wrote: > It has been a while. > I have mastered solving Kenken and Sudoku using Python-constraint. > > I still have no clue on how to tell the solver how to constrain > the number of occupants in rooms: I have made up an simple example > with nine persons and three rooms. Wishes for room mates are > mild in the extreme so it is very easy for a human to place these > nine persons in the three three-bed rooms such that all wishes are > fulfilled. Python-constraint set up by me finds 27 solutions of > which most place more than three persons in at least one room. > > Anyone into CSP willing to offer me a hint? I assume that your variables are the individuals and the domains of those variables are the rooms. Based on the python-constraint docs, your constraint could look something like this: from collections import Counter ROOM_SIZE = { 'A': 3, 'B': 3, 'C': 4, 'D': 4, 'E': 5, } def room_size_constraint(*v): counter = Counter(v.values()) return all(count <= ROOM_SIZE[room] for room, count in counter.items()) problem.addConstraint(room_size_constraint) From ian.g.kelly at gmail.com Tue Oct 20 15:28:29 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 20 Oct 2015 13:28:29 -0600 Subject: How to rearrange array using Python? In-Reply-To: References: <1468455.P0rGZF1LBf@PointedEars.de> Message-ID: On Tue, Oct 20, 2015 at 1:26 PM, Ian Kelly wrote: > def room_size_constraint(*v): > counter = Counter(v.values()) Sorry, this should just be Counter(v), since v here is a tuple, not a dict. From JonRob Tue Oct 20 17:11:14 2015 From: JonRob (JonRob) Date: Tue, 20 Oct 2015 17:11:14 -0400 Subject: variable scope of class objects References: Message-ID: <8abd2btl2mj6n73prpkc4cp016k08fsb23@4ax.com> Thanks to all who replied to my question. I received a lot of information and points of view that are very helpful. I realize some of you folks spent more that a few minutes. I really appreciate your time. Pardon me that i replied to random832's post and not the original but my original was lost while I was trying to bookmark it. Regards, JonRob On Mon, 19 Oct 2015 15:01:14 -0400, Random832 wrote: >JonRob at mail.python.org writes: >> >> The below pseudo code is distilled from my 1st attempt at a functional >> Python program on the RasPi. >> >> My questions are: >> What is the scope of class variables? > >You must access them as members of the class or an instance of the class. > >> does the self. prefix modify this scope? > >self just refers to the instance of the class that the function was >called with. It can be any name. > >Python automatically transforms any reference to "[object].func" into a >function (specifically, a bound method object) that will prefix [object] >to the argument list of the defined function. > >> #!/usr/bin/python >> # -- developed using Python 2.7.3 >> >> class BME280: >> >> # all the below are class variables >> # those preceded by an underscore are predefined to some constant > >Constants should be in uppercase, not prefixed with an underscore. > >Names prefixed with an underscore imply that they are "private" (not >really) and therefore other code should not use them directly > >> # those without the underscore are to be "working" variables. > >I don't know what you mean by "working". > >> >> _regT1 = 0x88 >> _regH6 = 0xE7 >> _coeff_P2 = 0x82 >> _coeff_P6 = 0x32 >> >> filter = 0 #should these be "self"? >> t_fine = 0 > >I don't know, should they? If so they need to be in __init__. > >You haven't provided any functions that use them, so it's not clear what >they're for. > >> >> def __init__(self, address=0x76, debug=True): >> self.i2c = Adafruit_I2C(address) >> self.address = address >> self.debug = debug >> >> def pressure_calc(self): >> var1 = self.i2c.readU16(self._regT1,False) >> p = (1048576.0 - var1) * _coeff_P2 >> return p >> >> def read_pressure(self): #called by main application >> pressure_hPa = pressure_calc(self) /10 >> # apply compensation >> return pressure_hPa From oscar.j.benjamin at gmail.com Tue Oct 20 17:27:14 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Tue, 20 Oct 2015 21:27:14 +0000 Subject: How to rearrange array using Python? In-Reply-To: References: <1468455.P0rGZF1LBf@PointedEars.de> Message-ID: On Tue, 20 Oct 2015 20:01 Martin Sch??n wrote: It has been a while. I have mastered solving Kenken and Sudoku using Python-constraint. I still have no clue on how to tell the solver how to constrain the number of occupants in rooms: I have made up an simple example with nine persons and three rooms. Wishes for room mates are mild in the extreme so it is very easy for a human to place these nine persons in the three three-bed rooms such that all wishes are fulfilled. Python-constraint set up by me finds 27 solutions of which most place more than three persons in at least one room. Anyone into CSP willing to offer me a hint? How have you defined your constraints? How have you defined the variables you want to solve for? Do you know whether or not the real problem you want to solve typically has any solutions satisfying all constraints? It won't be possible to answer that question a priori without looking at the data and the approach to take differs substantially if the system is overdetermined. Another approach BTW would be to model the wishes as a directed graph with children as vertices and wishes as arcs. This way you can partition the graph into weakly connected components so that your problem is reduced to placing components into rooms rather than individuals. -- Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From JonRob Tue Oct 20 17:33:21 2015 From: JonRob (JonRob) Date: Tue, 20 Oct 2015 17:33:21 -0400 Subject: variable scope of class objects References: Message-ID: <9ocd2btlkq7kp3margtn4sj3mehd7bpimm@4ax.com> Hello Luca, I very much appreciated your comments. And I understand the importance of "doing something right" (i.e. convention). This leads me to another question. Because I am interfacing with an I2C sensor I have many register definations to include (30 register addresses and 26 Variables to be red from some of those registers. In your comment you mentioned that convention is to declare variables (and constants?) in the construction (__ini__). I am concerned that the sheer number of varialbe / constants would make it difficult to read. In your opinion, what would be the best method to structure such code? Regards JonRob On Tue, 20 Oct 2015 08:17:16 +0200, Luca Menegotto wrote: >Il 19/10/2015 20:39, JonRob ha scritto: > >> I (think) I understand that in the below case, the word self could be >> replaced with "BME280" to explicitly call out a variable. >> >> But even still I don't know how explicit call out effects the scope of >> a variable. > >These two statements make me think you come from C++ or something similar. > >In Python you can declare variables at class level, but this declaration >must NOT be interpreted in the same manner of a similar declaration in >C++: they remain at the abstract level of a class, and they have nothing >to do with an instance of a class (in fact, to be correctly invoked, >they must be preceeded by the class name). > >'self' (or a similar representation, you could use 'this' without >problem) gives you access to the instance of the class, even in the >constructor; it is important, because the constructor is the place where >instance variables should be defined. Something like this: > >class foo: > # invoke with foo._imAtClassLevel > _imAtClassLevel = 10 > > def __init__(self): > # need to say how this must be invoked? > self._imAtInstanceLevel = 0 > >no confusion is possible, because: > >class foo2: > _variable = 1000 > > def __init__(self): > # let's initialize an instance variable with > # a class variable > self._variable = foo2._variable > >Please, note that declaring a variable in the constructor is only a >convention: in Python you can add a variable to an object of a class >wherever you want in your code (even if it is very dangerous and >discouraged). From randy.day at sasktel.netx Tue Oct 20 18:05:40 2015 From: randy.day at sasktel.netx (Randy Day) Date: Tue, 20 Oct 2015 16:05:40 -0600 Subject: 2.7.9: PhotoImage get/put Message-ID: I'm writing a simple image manipulation on a PhotoImage (tkinter), and running into an odd problem. The code below works, except for one thing: As the image is scanned, I'd like to observe the pixels getting inverted on the image (as a kind of progress bar). What happens is that the code runs the complete loop before refreshing the photo. I've tried various forms of refresh(), update(), etc., within the loop, but so far no luck. Am I missing something simple? def process(): # Ordinarily this would be process(photo,wdth,hgt) global wdth # but I ran into problems calling it from a button global hgt #command with parameters... global photo # the PhotoImage displayed by the calling code # indents set to 1 to avoid word wrap # Loop through rows and columns of the image v=wdth z=0 a=-1 for y in range (0,hgt): w=v v=z # swap v and z so rows are scanned l/r r/l l/r z=w a=-a # set our inc/dec step for lr->rl scan for x in range(v,z,a): pix = photo.get(x,y) if pix == u'0 0 0' : #pixel_turn_on() photo.put("#%02x%02x%02x" % (255,255,255), (x,y)) else: #pixel_turn_off() photo.put("#%02x%02x%02x" % (0,0,0), (x,y)) --- news://freenews.netfront.net/ - complaints: news at netfront.net --- From python at lucidity.plus.com Tue Oct 20 18:17:55 2015 From: python at lucidity.plus.com (Erik) Date: Tue, 20 Oct 2015 23:17:55 +0100 Subject: variable scope of class objects In-Reply-To: <9ocd2btlkq7kp3margtn4sj3mehd7bpimm@4ax.com> References: <9ocd2btlkq7kp3margtn4sj3mehd7bpimm@4ax.com> Message-ID: <5626BD93.5090907@lucidity.plus.com> On 20/10/15 22:33, JonRob at mail.python.org wrote: > In your comment you mentioned that convention is to declare variables > (and constants?) in the construction (__ini__). I would suggest that 'constants' are not 'declared' in the __init__ method body, but either as class variables or (see later) at module scope. > I am concerned that the sheer number of varialbe / constants would > make it difficult to read. Remember that "instance variables" in Python are just name bindings to another object which are placed in the object's dictionary. Python is not like some other languages where you declare your object's member variables statically and they all magically exist when you create the object (whether you initialise them or not): none of the bindings exist until an assignment is executed. Therefore, you _must_ have a set of assignments which are executed to create the object with the bindings (or "instance variables") that you require. This is _usually_ done in __init__ with a set of assignments to 'self' - either using default values or values passed in to __init__. You may be getting to the point where the best way to structure this is to write your own module (rather than just a class) which you then import from your main script. For example, you might do something like this: mymodule.py: CONSTANT_X = 0x99 CONSTANT_Y = 0xF00 CONSTANT_Z = "Spam" class MyObject(object): def __init__(self, foo, bar): # 'foo' can be anything. 'bar' must be one of # a specific set of values: if bar not in (CONSTANT_X, CONSTANT_Y): raise ValueError("Parameter 'bar'") self.foo = foo self.bar = bar Then, in your main script you might do something like: import mymodule obj = mymodule.MyObject(100, mymodule.CONSTANT_X) ... then start calling methods on 'obj'. So you just define your address and variable constants at module level and import them along with any class and function definitions. E. From emile at fenx.com Tue Oct 20 18:25:14 2015 From: emile at fenx.com (Emile van Sebille) Date: Tue, 20 Oct 2015 15:25:14 -0700 Subject: 2.7.9: PhotoImage get/put In-Reply-To: References: Message-ID: On 10/20/2015 3:05 PM, Randy Day wrote: > I'm writing a simple image manipulation > on a PhotoImage (tkinter), and running > into an odd problem. The code below works, > except for one thing: > > As the image is scanned, I'd like to > observe the pixels getting inverted on > the image (as a kind of progress bar). > What happens is that the code runs the > complete loop before refreshing the > photo. I have no idea why, but here are some ideas I'd try out. So is it refreshing upon completion of the loop, or upon exit from process()? What happens if you put an outer loop around yours to process hght in ten (pick a number) steps? Emile > I've tried various forms of > refresh(), update(), etc., within the > loop, but so far no luck. Am I > missing something simple? > > def process(): # Ordinarily this would be process(photo,wdth,hgt) > global wdth # but I ran into problems calling it from a button > global hgt #command with parameters... > global photo # the PhotoImage displayed by the calling code > > # indents set to 1 to avoid word wrap > > # Loop through rows and columns of the image > v=wdth > z=0 > a=-1 > for y in range (0,hgt): > w=v > v=z # swap v and z so rows are scanned l/r r/l l/r > z=w > a=-a # set our inc/dec step for lr->rl scan > > for x in range(v,z,a): > pix = photo.get(x,y) if pix == u'0 0 0' : > #pixel_turn_on() > photo.put("#%02x%02x%02x" % (255,255,255), (x,y)) > else: > #pixel_turn_off() > photo.put("#%02x%02x%02x" % (0,0,0), (x,y)) > > --- news://freenews.netfront.net/ - complaints: news at netfront.net --- > From steve at pearwood.info Tue Oct 20 19:30:35 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 21 Oct 2015 10:30:35 +1100 Subject: Defamation References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5626ce9d$0$1589$c3e8da3$5496439d@news.astraweb.com> On Wed, 21 Oct 2015 01:44 am, Laura Creighton wrote: > In a message of Wed, 21 Oct 2015 00:09:18 +1100, "Steven D'Aprano" writes: >>On Tue, 20 Oct 2015 03:28 am, Laura Creighton wrote: >> >>> Actually, this one was part of a huge set of defaming articles sent a >>> year ago we were requested to remove, and did. European Law may >>> require us to do so. I checked, and this article wasn't one on >>> our list, which is why we missed this one. > >>Today we're removing allegedly defaming posts because European law may or >>may not apply (probably doesn't); tomorrow we're removing posts because >>they fall foul of unreasonable laws anywhere in the world. > > No, we are removing them because we want to. Who are "we"? You're not talking about *you and me*. According to Ralf, python.org is hosted in the Netherlands, so I think EU law does apply, in which case my comments are irrelevant. I'm not suggesting that the python-list maintainers ignore applicable law. But I'll reply to your comments anyway: >>The point is, obeying laws that don't apply, even if well-meaning, opens >>us to a dangerous precedent that we shouldn't go near. > > Pointedly not doing something you want to because it might make us > obedient to some law we don't have to obey seems a matter of > cutting off ones nose to spite one's face. On the contrary, I think avoiding something that you want to do because you know that it will be bad in the long term is a very adult thing to do. I want to buy peanut butter, but I don't, because I know that when it comes to peanut butter I have no self-control and would eat the entire jar in a single sitting. So I simply don't buy it in the first place, and the problem is solved. If there is something I want to do, whether it is "eat the entire cake", "spend all my money on books", or "delete archived emails I don't approve of", before I do it I try to think about the consequences first. We could have a long and interesting debate over the issue of where and when folks should obey laws belonging to other countries, but here is not the right forum, and if Ralf is right it's not even relevant in this case, so I'll move on. >>There's another reason to try very, very hard to avoid deleting archived >>posts: until such time as python.org moves to Mailman3, deleting a single >>posts breaks the permalinks for *every single post* for the entire month. > > No, I think we were smarter than that in the script. If that's the case, that would be fantastic, but are you *sure* it works like that? Skip Montanaro made it clear that removing posts from the archives regenerates URLs for the whole month: http://www.gossamer-threads.com/lists/python/python/1176035 -- Steven From ben+python at benfinney.id.au Tue Oct 20 20:27:51 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 21 Oct 2015 11:27:51 +1100 Subject: What does it mean for Python to have =?utf-8?B?4oCcY29uc3RhbnRz?= =?utf-8?B?4oCdPw==?= (was: variable scope of class objects) References: <9ocd2btlkq7kp3margtn4sj3mehd7bpimm@4ax.com> Message-ID: <85twployk8.fsf_-_@benfinney.id.au> Dennis Lee Bieber writes: > (Python does not have anything that one might consider a true constant > -- other than the language defined singletons: None, and maybe by now > True and False). Python now deals with those by making the names keywords:: >>> True = object() File "", line 1 SyntaxError: can't assign to keyword >>> False = object() File "", line 1 SyntaxError: can't assign to keyword >>> None = object() File "", line 1 SyntaxError: can't assign to keyword which seems to rather avoid the question of whether they are ?constants? as would be understood by newcomers experienced with that term in other languages. -- \ ?Crime is contagious? if the government becomes a lawbreaker, | `\ it breeds contempt for the law.? ?Justice Louis Brandeis | _o__) | Ben Finney From illusiontechniques at gmail.com Tue Oct 20 21:44:47 2015 From: illusiontechniques at gmail.com (C Smith) Date: Tue, 20 Oct 2015 18:44:47 -0700 Subject: 2.7.9: PhotoImage get/put In-Reply-To: References: Message-ID: >> def process(): # Ordinarily this would be process(photo,wdth,hgt) >> global wdth # but I ran into problems calling it from a button If you want to pass arguments to a command called when a button is clicked, you have to use 'lambda' in tkinter. >> global hgt #command with parameters... >> global photo # the PhotoImage displayed by the calling code >> >> # indents set to 1 to avoid word wrap >> >> # Loop through rows and columns of the image >> v=wdth >> z=0 >> a=-1 >> for y in range (0,hgt): >> w=v >> v=z # swap v and z so rows are scanned l/r r/l l/r >> z=w >> a=-a # set our inc/dec step for lr->rl scan >> >> for x in range(v,z,a): >> pix = photo.get(x,y) if pix == u'0 0 0' : >> #pixel_turn_on() >> photo.put("#%02x%02x%02x" % (255,255,255), (x,y)) >> else: >> #pixel_turn_off() >> photo.put("#%02x%02x%02x" % (0,0,0), (x,y)) You can't expect a delay to happen during the mainloop() of the program. To interrupt the mainloop(), use: parent.after(n,someCommand) Where 'n' is some amount of milliseconds. Just have the parent widget or the root frame call it. From tjreedy at udel.edu Wed Oct 21 00:41:06 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 21 Oct 2015 00:41:06 -0400 Subject: teacher need help! In-Reply-To: References: <5623397C.40205@timgolden.me.uk> Message-ID: On 10/19/2015 4:23 AM, Terry Reedy wrote: > On 10/18/2015 9:32 PM, Storey, Geneva wrote: > >> Same issue! See attached. > -------- > >>> Can I suggest you find the turtle.py module in c:\windows\system32, >>> move it >>> to somewhere more suitable and try the code again? > > This seems strange. C:/Windows/System32 should only be writable by > admin users, and even they should have no reason to put random files > there. It would certainly be bad practice. There could be a screw-up > with some systems. But we need much more info to say much. See https://bugs.python.org/issue25450 The 3.5 Python and IDLE ICONS do not specify a start directory, so python start in c:\windows\system32 (even for a 64 bit install -- whether this is correct or a bug, I do not know). The solution is to add one. On Win 7, Start Menu, Python 3.5, right click, Properties, Shortcut, Start In: add the path to the executable (without python(w).exe at the end), which is in the Target line. BE CAREFUL TO NOT INADVERTENTLY EDIT/DELETE THE TARGET. For Win 10, hides the property dialogs: no Start Menu, only a deformed 'All apps' list with entries that are NOT icons. Find Python35, Python/IDLE. Either click to run or right click, Pin to Taskbar. Either way, right click on the taskbar icon, right click again, select Properties, continue as above. Fix two for a possible problem. Go to /.idlerc/recent-files.lst. Edit and delete any bad entries. I cannot tell from the report here or tracker if this is needed. At worst, delete the file. -- Terry Jan Reedy From ian.g.kelly at gmail.com Wed Oct 21 01:07:31 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 20 Oct 2015 23:07:31 -0600 Subject: teacher need help! In-Reply-To: <56267C56.40300@gmail.com> References: <5623397C.40205@timgolden.me.uk> <5624AC43.3080105@timgolden.me.uk> <56267C56.40300@gmail.com> Message-ID: On Tue, Oct 20, 2015 at 11:39 AM, Michael Torrie wrote: > On 10/20/2015 10:25 AM, Storey, Geneva wrote: >> FYI-We formatted the machines, reinstalling everything, including >> Python. I works with no problems now. Confusing that this would >> happen on 3 out of 13 machines. Just letting you know, all is well. >> Thank you for your help! Geneva > > Wow that seems rather drastic. Well, it sounds like they're just lab computers. Generally simpler to re-image the system than to put in the effort to diagnose and fix the problem, and it takes care of any other latent lingering issues at the same time. From randy.day at sasktel.netx Wed Oct 21 01:50:44 2015 From: randy.day at sasktel.netx (Randy Day) Date: Tue, 20 Oct 2015 23:50:44 -0600 Subject: 2.7.9: PhotoImage get/put References: Message-ID: In article , illusiontechniques at gmail.com says... [snip] > If you want to pass arguments to a command called when a button is > clicked, you have to use 'lambda' in tkinter. Thanks. I just skimmed over lambda before now... > You can't expect a delay to happen during the mainloop() of the > program. To interrupt the mainloop(), use: parent.after(n,someCommand) > Where 'n' is some amount of milliseconds. Just have the parent widget > or the root frame call it. When I read your post, I realized I'm doing a crude animation. After a bit of searching on 'python canvas animation', I found a reference to how it's done: I made my 'root' Tk instance global, and call root.update_idletasks() after the .put It works great! Now back to the lambdas (Ralph the Wonder Lambda, Earl J Lambda, Mike Q Lambda III, et al?). --- news://freenews.netfront.net/ - complaints: news at netfront.net --- From randy.day at sasktel.netx Wed Oct 21 01:59:12 2015 From: randy.day at sasktel.netx (Randy Day) Date: Tue, 20 Oct 2015 23:59:12 -0600 Subject: 2.7.9: PhotoImage get/put References: Message-ID: In article , emile at fenx.com says... [snip] > I have no idea why, but here are some ideas I'd try out. > So is it refreshing upon completion of the loop, or upon exit from > process()? It turns out I need to call root.update_idletasks() for my root Tk object to get it to refresh after I put the pixel. It works great now. --- news://freenews.netfront.net/ - complaints: news at netfront.net --- From gandalf at shopzeus.com Wed Oct 21 02:13:38 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Wed, 21 Oct 2015 08:13:38 +0200 Subject: =?UTF-8?Q?Re:_What_does_it_mean_for_Python_to_have_=e2=80=9cconstan?= =?UTF-8?B?dHPigJ0/?= In-Reply-To: <85twployk8.fsf_-_@benfinney.id.au> References: <9ocd2btlkq7kp3margtn4sj3mehd7bpimm@4ax.com> <85twployk8.fsf_-_@benfinney.id.au> Message-ID: <56272D12.4090109@shopzeus.com> Dennis Lee Bieber writes: >> (Python does not have anything that one might consider a true constant >> -- other than the language defined singletons: None, and maybe by now >> True and False). > Python now deals with those by making the names keywords:: > > >>> True = object() > File "", line 1 > SyntaxError: can't assign to keyword > >>> False = object() > File "", line 1 > SyntaxError: can't assign to keyword > >>> None = object() > File "", line 1 > SyntaxError: can't assign to keyword > > which seems to rather avoid the question of whether they are ?constants? > as would be understood by newcomers experienced with that term in other > languages. > This is true for Python 3, but the OP wrote his program in Python 2. In Python 2, you can do this (unfortunately): >>> True, False = False, True >>> if False: ... print("DOH!") ... DOH! From lac at openend.se Wed Oct 21 02:53:54 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 21 Oct 2015 08:53:54 +0200 Subject: Defamation In-Reply-To: <5626ce9d$0$1589$c3e8da3$5496439d@news.astraweb.com> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <5626ce9d$0$1589$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201510210653.t9L6rsUd005884@fido.openend.se> In a message of Wed, 21 Oct 2015 10:30:35 +1100, "Steven D'Aprano" writes: >On Wed, 21 Oct 2015 01:44 am, Laura Creighton wrote: >> No, we are removing them because we want to. > >Who are "we"? You're not talking about *you and me*. Anybody who was involved in deciding whether or not to remove them. You, me, Ralf, Skip, Tim Golden, Terry, anybody else who is interested. >If that's the case, that would be fantastic, but are you *sure* it works >like that? Skip Montanaro made it clear that removing posts from the >archives regenerates URLs for the whole month: > >http://www.gossamer-threads.com/lists/python/python/1176035 Yes. And if you read the rest of the thread you will see how it was proposed to avoid that problem, with a placeholder, and thereafter Skip wrote a script that implemented exactly that. >-- >Steven What I am objecting to is the 'slippery slope' argument. That, there are bad laws some places, and some bad reasons to remove postings doesn't mean that we should attempt to duck the responsibility of using our own discernment by instituting a mindless policy. That only _buries_ the need for making a judgment call, and makes it harder to make the right one when the right one is 'remove this thing'. Laura From tjreedy at udel.edu Wed Oct 21 03:51:21 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 21 Oct 2015 03:51:21 -0400 Subject: 2.7.9: PhotoImage get/put In-Reply-To: References: Message-ID: On 10/21/2015 1:50 AM, Randy Day wrote: > When I read your post, I realized I'm doing > a crude animation. After a bit of searching > on 'python canvas animation', I found a > reference to how it's done: > > I made my 'root' Tk instance global, and > call root.update_idletasks() after the > .put I did not see the original post, but the alternative way to animate is to use root.after(milliseconds, callback, *args) at the end of callbacks to allow the event loop to process other events before re-calling the same or another callback. -- Terry Jan Reedy From tjreedy at udel.edu Wed Oct 21 04:01:34 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 21 Oct 2015 04:01:34 -0400 Subject: Defamation In-Reply-To: <201510210653.t9L6rsUd005884@fido.openend.se> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <5626ce9d$0$1589$c3e8da3$5496439d@news.astraweb.com> <201510210653.t9L6rsUd005884@fido.openend.se> Message-ID: On 10/21/2015 2:53 AM, Laura Creighton wrote: > In a message of Wed, 21 Oct 2015 10:30:35 +1100, "Steven D'Aprano" writes: >> On Wed, 21 Oct 2015 01:44 am, Laura Creighton wrote: >>> No, we are removing them because we want to. >> >> Who are "we"? You're not talking about *you and me*. > > Anybody who was involved in deciding whether or not to remove them. > You, me, Ralf, Skip, Tim Golden, Terry, anybody else who is interested. > > > >> If that's the case, that would be fantastic, but are you *sure* it works >> like that? Skip Montanaro made it clear that removing posts from the >> archives regenerates URLs for the whole month: >> >> http://www.gossamer-threads.com/lists/python/python/1176035 > > Yes. And if you read the rest of the thread you will see how it was proposed > to avoid that problem, with a placeholder, and thereafter Skip wrote a > script that implemented exactly that. The moderators intend and try to delete such posts as those under discussion before they reach the list, by both automatic and manual filtering. They are doing pretty well, but some posters have actively evaded this process (and give us training examples to improve the process). I think that posts that would have unquestionably been deleted before being distributed are fair game to be replaced at least in our archive after the fact. I appreciate the people who have done this cleanup work. -- Terry Jan Reedy From Ralf.Hildebrandt at charite.de Wed Oct 21 05:52:53 2015 From: Ralf.Hildebrandt at charite.de (Ralf Hildebrandt) Date: Wed, 21 Oct 2015 11:52:53 +0200 Subject: Defamation In-Reply-To: <5626ce9d$0$1589$c3e8da3$5496439d@news.astraweb.com> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <5626ce9d$0$1589$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20151021095253.GE5630@charite.de> > According to Ralf, python.org is hosted in the Netherlands, One could change that. > I want to buy peanut butter, but I don't, because I know that when it comes > to peanut butter I have no self-control and would eat the entire jar in a > single sitting. So I simply don't buy it in the first place, and the > problem is solved. That's what I do when it comes to candy in general ) -- Ralf Hildebrandt Charite Universit?tsmedizin Berlin ralf.hildebrandt at charite.de Campus Benjamin Franklin http://www.charite.de Hindenburgdamm 30, 12203 Berlin Gesch?ftsbereich IT, Abt. Netzwerk fon: +49-30-450.570.155 From ashwath at nanoheal.com Wed Oct 21 07:52:14 2015 From: ashwath at nanoheal.com (ashwath at nanoheal.com) Date: Wed, 21 Oct 2015 04:52:14 -0700 Subject: Pause and Resuming of a file upload process to AWS S3 Message-ID: <20151021045214.d600875ec5143fcc53c5b00e1a6550c2.8e25f5048c.mailapi@email23.secureserver.net> Hi I wanted to know whether it is possible in python to pause and resume the file upload process to AWS S3, I tried a lot but I did not get any solution so I request you to get me a solution for this. If it is possible to do so can you please let me know how to do. My alternate email id = ashwathbhgowda at gmail.com Thanks & Regards Ashwath India -------------- next part -------------- An HTML attachment was scrubbed... URL: From gandalf at shopzeus.com Wed Oct 21 11:18:47 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Wed, 21 Oct 2015 17:18:47 +0200 Subject: PyPi bug? Message-ID: <5627ACD7.20704@shopzeus.com> Today I have tried to register and upload a new package by executing setup.py register I was asked if I want to save the creditentials in a .pypirc file and I answered yes. Next I wanted to run setup.py upload and I got this error: Traceback (most recent call last): File "C:\Python\Projects\some_package\setup.py", line 15, in classifiers=['Topic :: Security', 'Topic :: Internet :: WWW/HTTP'], File "C:\Python35\lib\distutils\core.py", line 148, in setup dist.run_commands() File "C:\Python35\lib\distutils\dist.py", line 955, in run_commands self.run_command(cmd) File "C:\Python35\lib\distutils\dist.py", line 973, in run_command cmd_obj.ensure_finalized() File "C:\Python35\lib\distutils\cmd.py", line 107, in ensure_finalized self.finalize_options() File "C:\Python35\lib\distutils\command\upload.py", line 46, in finalize_options config = self._read_pypirc() File "C:\Python35\lib\distutils\config.py", line 83, in _read_pypirc current[key] = config.get(server, key) File "C:\Python35\lib\configparser.py", line 798, in get d) File "C:\Python35\lib\configparser.py", line 396, in before_get self._interpolate_some(parser, option, L, value, section, defaults, 1) File "C:\Python35\lib\configparser.py", line 445, in _interpolate_some "found: %r" % (rest,)) configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found : *****************' Instead of the many stars, of course there is the password. The problem might be that the password contains a % character, and it was incorrectly saved by distutils. Can somebody please confirm that this is a bug in distutils? The we probably have to submit a bug report. Thanks, Laszlo From port_albert at yahoo.com Wed Oct 21 11:24:21 2015 From: port_albert at yahoo.com (Terry Alexander) Date: Wed, 21 Oct 2015 15:24:21 +0000 (UTC) Subject: UNABLE TO GET IDLE TO RUN References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> Message-ID: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> Hello... I have tried installing both Python 2.7 and 3.5, and in both cases I cannot get IDLE to work. I received the following message both times: IDLE?s subprocess didn?t make connection.? Either IDLE can?t start a subprocess or personalfirewall software is blocking the connection. I am running Norton, and disabled it, but still IDLE will not run. Any suggestions? Thank you... Terry Alexander709-745-2953 -------------- next part -------------- An HTML attachment was scrubbed... URL: From randy.day at sasktel.netx Wed Oct 21 11:31:11 2015 From: randy.day at sasktel.netx (Randy Day) Date: Wed, 21 Oct 2015 09:31:11 -0600 Subject: 2.7.9: PhotoImage get/put References: Message-ID: In article , tjreedy at udel.edu says... [snip] > > I made my 'root' Tk instance global, and > > call root.update_idletasks() after the > > .put > I did not see the original post, but the alternative way to animate is > to use root.after(milliseconds, callback, *args) at the end of callbacks > to allow the event loop to process other events before re-calling the > same or another callback. I could see that being useful for creating a steady frame rate in longer animations. I'll put that one in my Python toolbox as well. --- news://freenews.netfront.net/ - complaints: news at netfront.net --- From bigred04bd3 at gmail.com Wed Oct 21 13:31:04 2015 From: bigred04bd3 at gmail.com (bigred04bd3 at gmail.com) Date: Wed, 21 Oct 2015 10:31:04 -0700 (PDT) Subject: If one IF is satisfied, skip the rest in the nest... Message-ID: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> So here what I have, I have a 3 IF's within the same level. If one IF is satisfied, I would like to "skip" the other IFs and continue with my code. # 4 second open if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0 and wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and wb1_sheet1.cell(row=cell + 3, column=3).value == 0: open += 3 open_seconds += 4 start = wb1_sheet1.cell(row=cell + 4, column=2).coordinate break # 3 second open if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0: open += 3 start = wb1_sheet1.cell(row=cell + 3, column=2).coordinate open_seconds += 3 continue # 2 second open if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1 .cell(row=cell + 1, column=3).value == 0: open += 3 start = wb1_sheet1.cell(row=cell + 2, column=2).coordinate open_seconds += 2 if any but the last IF is true, then all IFs will be true...that's my problem. any help would be great From ian.g.kelly at gmail.com Wed Oct 21 13:39:36 2015 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 21 Oct 2015 11:39:36 -0600 Subject: If one IF is satisfied, skip the rest in the nest... In-Reply-To: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> References: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> Message-ID: On Wed, Oct 21, 2015 at 11:31 AM, wrote: > So here what I have, I have a 3 IF's within the same level. If one IF is satisfied, I would like to "skip" the other IFs and continue with my code. I think you're looking for the elif keyword. An elif branch will only be considered if the previous branches were false. if a: do_something() elif b: do_something_else() elif c: do_something_different() From gordon at panix.com Wed Oct 21 13:46:38 2015 From: gordon at panix.com (John Gordon) Date: Wed, 21 Oct 2015 17:46:38 +0000 (UTC) Subject: If one IF is satisfied, skip the rest in the nest... References: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> Message-ID: In <50a6789a-3965-430b-9a91-b08adcedf7bf at googlegroups.com> bigred04bd3 at gmail.com writes: > So here what I have, I have a 3 IF's within the same level. If one IF is s= > atisfied, I would like to "skip" the other IFs and continue with my code. > # 4 second open > if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0 and wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and wb1_sheet1.cell(row=cell + 3, column=3).value == 0: > open += 3 > open_seconds += 4 > start = wb1_sheet1.cell(row=cell + 4, column=2).coord= > inate > break > # 3 second open > if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 a= > nd wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet= > 1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row= > =cell + 2, column=3).value == 0: > open += 3 > start = wb1_sheet1.cell(row=cell + 3, column=2).coord= > inate > open_seconds += 3 > continue > # 2 second open > if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 a= > nd wb1_sheet1 .cell(row=cell + 1, column=3).value == = > 0: > open += 3 > start = wb1_sheet1.cell(row=cell + 2, column=2).coord= > inate > open_seconds += 2 > if any but the last IF is true, then all IFs will be true...that's my probl= > em. It looks like all three of your if statements start out with this condition: if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 So you could reorganize your code by putting an if statement at the top that only checks this condition. Then, indented underneath, you can check for the other conditions. And be sure to use "else" and "elif" when they are appropriate. -- 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 bigred04bd3 at gmail.com Wed Oct 21 13:55:48 2015 From: bigred04bd3 at gmail.com (bigred04bd3 at gmail.com) Date: Wed, 21 Oct 2015 10:55:48 -0700 (PDT) Subject: If one IF is satisfied, skip the rest in the nest... In-Reply-To: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> References: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> Message-ID: O...M....G I cannot believe I just asked this question ha. I ended up realizing I need to use an elif after I took a break from it and re read everything...Brain fart, thanks for replies. Brice From peter.brittain.os at gmail.com Wed Oct 21 14:30:25 2015 From: peter.brittain.os at gmail.com (Peter Brittain) Date: Wed, 21 Oct 2015 11:30:25 -0700 (PDT) Subject: A high-level cross-platform API for terminal/console access Message-ID: I have recently been working on a terminal/console animation package (https://github.com/peterbrittain/asciimatics). Beyond the high-level animation methods/objects it provides, it also needed to be cross-platform and and simple to install with pip (including any dependencies). This cross-platform requirement meant I needed a curses equivalent for Windows. This appears to have been a regular issue over the years and I've looked around at previous answers on the web and this newsgroup. Now while there's some pretty neat stuff out there, nothing actually gave me everything I needed. 1) colorama only gives you colours and cursor positioning, but no input, resizing or screen-scraping options. 2) blessings/blessed provide better (but incomplete) APIs than the curses package, but no Windows support unless you use colorama (which is still limited as above). 3) console (from effbot.org) is a native installer and so fails the pip test. It does however show direct use of the win32 API is a tenable approach. 4) The other packages I found were either dead projects or relied on a native installation of an open source implementation of curses - with no pip install option available. I therefore started writing a consistent wrapper API (the Screen object) that uses the curses package on Unix variants and pywin32 to access the Windows console API. Over the last few months I've rounded out the features and proved that asciimatics works identically on Linux (various distros), OSX and Windows 7-10. I know that there are still some rough edges due to the history of the project and so I've been deprecating old APIs in preparation for creating a completely clean API when I create the next major (v2.x) release. I suspect that it could be even better though, so am looking for feedback and ideas from the community - both on the high-level animation features and the low-level cross-platform terminal API. Is there something you can see that could be usefully improved? All feedback welcome. From martin.schoon at gmail.com Wed Oct 21 14:47:24 2015 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 21 Oct 2015 18:47:24 GMT Subject: How to rearrange array using Python? References: <1468455.P0rGZF1LBf@PointedEars.de> Message-ID: Den 2015-10-20 skrev Ian Kelly : >> >> Anyone into CSP willing to offer me a hint? > > I assume that your variables are the individuals and the domains of > those variables are the rooms. Based on the python-constraint docs, > your constraint could look something like this: > > from collections import Counter > > ROOM_SIZE = { > 'A': 3, > 'B': 3, > 'C': 4, > 'D': 4, > 'E': 5, > } > > def room_size_constraint(*v): > counter = Counter(v.values()) > return all(count <= ROOM_SIZE[room] > for room, count in counter.items()) > > problem.addConstraint(room_size_constraint) Bingo! Just what I needed but didn't know where to look for. Now I 'only' have to read https://docs.python.org/dev/library/collections.html#counter-objects to understand what's really going on in the code :-) Then I will try less benign examples. /Martin From garabik-news-2005-05 at kassiopeia.juls.savba.sk Wed Oct 21 15:19:59 2015 From: garabik-news-2005-05 at kassiopeia.juls.savba.sk (garabik-news-2005-05 at kassiopeia.juls.savba.sk) Date: Wed, 21 Oct 2015 19:19:59 +0000 (UTC) Subject: ANN: unicode 2 Message-ID: unicode is a simple python command line utility that displays properties for a given unicode character, or searches unicode database for a given name. It was written with Linux in mind, but should work almost everywhere (including MS Windows and MacOSX), UTF-8 console is recommended. ?p??pu??s ?po???u? ??? ?o ?sn p??u??p? pu? s?ld???u???d ??? ?u??????suo??p loo? ??????p??p ?u?ll??x? u? s?? ?I ?s?u??od?po? ?u???????p ?l???ld?o? ?u??sn ?l???? 's?d?l? ?o ?????s ??l?????s ?ll?ns??? o?u?? ?x?? ??? ????uo? o? p??pu??s ?po???u? ??? ?o ???od lln? ??? s???oldx? ???? '????l???n ,?po????d, osl? su????uo? ??????d ??? Changes since previous versions: * substantially rewritten formatting * full python3 support * user defined output format * added --brief for a brief format * dropped python2.5 support URL: http://kassiopeia.juls.savba.sk/~garabik/software/unicode.html License: GPL v3 -- ----------------------------------------------------------- | Radovan Garab?k http://kassiopeia.juls.savba.sk/~garabik/ | | __..--^^^--..__ garabik @ kassiopeia.juls.savba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From lac at openend.se Wed Oct 21 15:41:50 2015 From: lac at openend.se (Laura Creighton) Date: Wed, 21 Oct 2015 21:41:50 +0200 Subject: A high-level cross-platform API for terminal/console access In-Reply-To: References: Message-ID: <201510211941.t9LJfoow007405@fido.openend.se> In a message of Wed, 21 Oct 2015 11:30:25 -0700, Peter Brittain writes: >I have recently been working on a terminal/console animation package (https://github.com/peterbrittain/asciimatics). Beyond the high-level animation methods/objects it provides, it also needed to be cross-platform and and simple to install with pip (including any dependencies). > >This cross-platform requirement meant I needed a curses equivalent for Windows. This appears to have been a regular issue over the years and I've looked around at previous answers on the web and this newsgroup. Now while there's some pretty neat stuff out there, nothing actually gave me everything I needed. > >1) colorama only gives you colours and cursor positioning, but no input, resizing or screen-scraping options. > >2) blessings/blessed provide better (but incomplete) APIs than the curses package, but no Windows support unless you use colorama (which is still limited as above). > >3) console (from effbot.org) is a native installer and so fails the pip test. It does however show direct use of the win32 API is a tenable approach. > >4) The other packages I found were either dead projects or relied on a native installation of an open source implementation of curses - with no pip install option available. > >I therefore started writing a consistent wrapper API (the Screen object) that uses the curses package on Unix variants and pywin32 to access the Windows console API. > >Over the last few months I've rounded out the features and proved that asciimatics works identically on Linux (various distros), OSX and Windows 7-10. I know that there are still some rough edges due to the history of the project and so I've been deprecating old APIs in preparation for creating a completely clean API when I create the next major (v2.x) release. > >I suspect that it could be even better though, so am looking for feedback and ideas from the community - both on the high-level animation features and the low-level cross-platform terminal API. > >Is there something you can see that could be usefully improved? All feedback welcome. >-- Did you try https://pypi.python.org/pypi/UniCurses ? Laura From denismfmcmahon at gmail.com Wed Oct 21 15:48:09 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Wed, 21 Oct 2015 19:48:09 +0000 (UTC) Subject: If one IF is satisfied, skip the rest in the nest... References: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> Message-ID: On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote: > So here what I have, I have a 3 IF's within the same level. If one IF > is satisfied, I would like to "skip" the other IFs and continue with my > code. c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0 c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and wb1_sheet1.cell(row=cell + 3, column=3).value == 0 if c1: if c2: if c3: # c1 && c2 && c3 # 4 second open else: # c1 && c2 # 3 second open else: # only c1 # 2 second open Each condition only gets evaluated once. -- Denis McMahon, denismfmcmahon at gmail.com From invalid at invalid.invalid Wed Oct 21 16:07:21 2015 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 21 Oct 2015 20:07:21 +0000 (UTC) Subject: If one IF is satisfied, skip the rest in the nest... References: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> Message-ID: On 2015-10-21, Denis McMahon wrote: > On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote: > >> So here what I have, I have a 3 IF's within the same level. If one IF >> is satisfied, I would like to "skip" the other IFs and continue with my >> code. > > c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 1, column=3).value == 0 > > c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 2, column=3).value == 0 > > c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 3, column=3).value == 0 > > if c1: > if c2: > if c3: > # c1 && c2 && c3 > # 4 second open > else: > # c1 && c2 > # 3 second open > else: > # only c1 > # 2 second open if c1 && c2 && c3: pass # 4 seconds elif c1 && c2: pass # 3 seconds elif c1: pass # 2 seconds Or if you want to be particulary obtuse: seconds = {0b111:4, 0b110:3, 0b100:2}.get(c1<<2 | c2<<1 | c3<<0, None) > Each condition only gets evaluated once. OK. -- Grant Edwards grant.b.edwards Yow! You were s'posed at to laugh! gmail.com From esawiek at gmail.com Wed Oct 21 17:57:40 2015 From: esawiek at gmail.com (Ek Esawi) Date: Wed, 21 Oct 2015 17:57:40 -0400 Subject: Pandas' loading a CSV file problem Message-ID: Hi All--- I am new to Pandas. I am trying to load a csv file into pandas using import pandas as pd f = pd.read_csv(OSATemp.csv') Even though I was able to read and manipulate the file in Python343, in Pandas the file could not be loaded. When I run the above statement, I get a series of massages such as Traceback (most recent call last): File "C:\Users\EK Esawi\Anaconda3\Scripts\file1.py", line 3, in f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp.csv') File "C:\Users\EK Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 474, in parser_f Any help/suggestion is greatly appreciated?EKE Here is a sample of my csv file: 120891 120891 120873 120890 120890 120754 120891 120890 120890 O Geyser RT Time Interval Duration Preplay Height Prediction 42 Old Faithful 8:16 3:00 43 Old Faithful 9:55 1:39 4:15 9:41 130+ 9:49 44 Old Faithful 11:33 1:38 3:59 11:20 130 11:28 45 Old Faithful 13:00 1:27 4:00 13:00 140 13:06 46 Old Faithful 14:42 1:42 3:44 14:29 150 14:33 47 Old Faithful 16:08 1:26 >4:00 16:02 140+ 16:15 56 Castle E 9:36 9:40ie 75 Old Faithful 7:23 >3:00 76 Old Faithful 9:05 1:42 4:13 8:52 150 8:05 77 Old Faithful 10:37 1:32 4:08 10:32 130 10:38 78 Old Faithful 12:02 1:25 3:00 11:59 130 12:10 79 Old Faithful 13:38 1:36 >3:30 13:27 13:00 80 Old Faithful 15:08 1:30 4:05 15:02 15:01 81 Old Faithful 16:42 1:34 3:54 16:32 150 16:41 -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.brittain.os at gmail.com Wed Oct 21 18:18:44 2015 From: peter.brittain.os at gmail.com (Peter Brittain) Date: Wed, 21 Oct 2015 15:18:44 -0700 (PDT) Subject: A high-level cross-platform API for terminal/console access In-Reply-To: References: Message-ID: <86bf9509-c512-4efa-9712-b51952a311e3@googlegroups.com> > > Did you try https://pypi.python.org/pypi/UniCurses ? > Yes - it failed to install with pip and also looked like a dead project when I followed the project home page URL. From eryksun at gmail.com Wed Oct 21 18:26:17 2015 From: eryksun at gmail.com (eryksun) Date: Wed, 21 Oct 2015 17:26:17 -0500 Subject: A high-level cross-platform API for terminal/console access In-Reply-To: <86bf9509-c512-4efa-9712-b51952a311e3@googlegroups.com> References: <86bf9509-c512-4efa-9712-b51952a311e3@googlegroups.com> Message-ID: On 10/21/15, Peter Brittain wrote: >> >> Did you try https://pypi.python.org/pypi/UniCurses ? >> > > Yes - it failed to install with pip and also looked like a dead project when > I followed the project home page URL. > -- > https://mail.python.org/mailman/listinfo/python-list > Also check out the curses module that's available on Christoph Gohlke's site: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses From JonRob Wed Oct 21 19:35:49 2015 From: JonRob (JonRob) Date: Wed, 21 Oct 2015 19:35:49 -0400 Subject: variable scope of class objects References: <9ocd2btlkq7kp3margtn4sj3mehd7bpimm@4ax.com> Message-ID: <9i7g2b17d3e54cbcf35digbod9216fnovl@4ax.com> @Dennis, Thanks for your example. My structure is very similar. Perhaps I was reading too much into Luca's below statement regarding declaring variables. Regards, JonRob Luca wrote... >Please, note that declaring a variable in the constructor is only a >convention: in Python you can add a variable to an object of a class >wherever you want in your code (even if it is very dangerous and >discouraged). On Tue, 20 Oct 2015 20:18:35 -0400, Dennis Lee Bieber wrote: >On Tue, 20 Oct 2015 17:33:21 -0400, JonRob at mail.python.org declaimed the >following: > >> >> >>Hello Luca, >> >>I very much appreciated your comments. And I understand the >>importance of "doing something right" (i.e. convention). >> >>This leads me to another question. >> >>Because I am interfacing with an I2C sensor I have many register >>definations to include (30 register addresses and 26 Variables to be >>red from some of those registers. >>In your comment you mentioned that convention is to declare variables >>(and constants?) in the construction (__ini__). >>I am concerned that the sheer number of varialbe / constants would >>make it difficult to read. >> > > "Constants" are typically defined at module level, using all capitals >as a hint to the reader (Python does not have anything that one might >consider a true constant -- other than the language defined singletons: >None, and maybe by now True and False). > > Register addresses are likely "constants". Not sure about your "26 >Variables"... Do they map directly to registers, or are they extracted as >fields from the values returned -- that is, a register may have two or more >"variables"? Do you read ALL registers on command and hold the values (note >my usage -- values can be held in lists or dictionaries using a single >"variable") for later retrieval by the user, or only read A register on >command by the user and return that value. > >-=-=-=-=- ># registers for a fictitious motion sensor >GYROXREG = 0x0010 >GYROYREG = 0x0011 >GYROZREG = 0x0001 >... >MAGZREG = 0x0100 > >class SensorA(I2C): #I'm assuming class I2C provides read/write functions > _registers = [GYROXREG, GYROYREG, GYROZREG, > ..., MAGZREG] > def __init__(self, SCLpin, SDApin, slaveAddress): > self._SCL = SCLpin > self._SDA = SDApin > self._addr = slaveAddress > self.update() #initial load of values > def update(self): > #basically a loop over all addresses > #I'm not going to try to pseudo code the full I2C protocol > self.values = {} #yes, a dictionary > for reg in _registers: > aValue = self.read(self._SCL, self._SDA, self._addr, reg) > #inherited from I2C class > self.values[reg] = aValue >.... > >mySensor = SensorA(21, 22, 0x6) > >while True > mySensor.update() > print ("Gyro X: %s, Y: %s, Z: %s" > % (mySensor.values[GYROXREG], > mySensor.values[GYROYREG], > mySensor.values[GYROZREG])) > time.sleep(1.0) > > > > From mail at johnohagan.com Wed Oct 21 20:45:08 2015 From: mail at johnohagan.com (John O'Hagan) Date: Thu, 22 Oct 2015 11:45:08 +1100 Subject: Defamation In-Reply-To: <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20151022114508.1b95c332@mini.home> On Wed, 21 Oct 2015 00:09:18 +1100 Steven D'Aprano wrote: > I don't believe that the Python mailing list archives are hosted in a > country under the jurisdiction of European Law. If I'm right, then > removing posts sets a dangerous precedent of obeying laws in foreign > countries that don't apply. For better or worse, that's not how defamation law works. Generally, the defaming is regarded as happening where the material is read, i.e. at the point of download. The location of upload, hosting etc is irrelevant, although the uploader and the host can both be liable along with the author. Of course, the point is moot if none of those people has assets in that jurisdiction. For example: https://en.wikipedia.org/wiki/Dow_Jones_%26_Co_Inc_v_Gutnick On the specific point, I think it's possible to agree with both Steven and Laura. It's a bad idea to obey laws that don't apply to you if you'd rather not. It's also a good idea if possible to remove defamatory material, not because it might be illegal, but because it's defamatory. Regards John From denismfmcmahon at gmail.com Wed Oct 21 22:08:15 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 22 Oct 2015 02:08:15 +0000 (UTC) Subject: If one IF is satisfied, skip the rest in the nest... References: <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com> Message-ID: On Wed, 21 Oct 2015 20:07:21 +0000, Grant Edwards wrote: > On 2015-10-21, Denis McMahon wrote: >> On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote: >> >>> So here what I have, I have a 3 IF's within the same level. If one IF >>> is satisfied, I would like to "skip" the other IFs and continue with >>> my code. >> >> c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and >> wb1_sheet1.cell(row=cell + 1, column=3).value == 0 >> >> c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and >> wb1_sheet1.cell(row=cell + 2, column=3).value == 0 >> >> c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and >> wb1_sheet1.cell(row=cell + 3, column=3).value == 0 >> >> if c1: >> if c2: >> if c3: >> # c1 && c2 && c3 # 4 second open >> else: >> # c1 && c2 # 3 second open >> else: >> # only c1 # 2 second open > > if c1 && c2 && c3: > pass # 4 seconds > elif c1 && c2: > pass # 3 seconds > elif c1: > pass # 2 seconds > > Or if you want to be particulary obtuse: > > seconds = {0b111:4, 0b110:3, 0b100:2}.get(c1<<2 | c2<<1 | c3<<0, None) Not really valid, because #seconds n is simply a marker to indicate which branch of the OP's code to execute. >> Each condition only gets evaluated once. > > OK. Yes, but in the structure I suggest, you can move the conditions back into the if statements and they still only each get evaluated once. Viz my alternative to the OP's code: if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell (row=cell + 1, column=3).value == 0: if wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0: if wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and wb1_sheet1.cell(row=cell + 3, column=3).value == 0: open += 3 open_seconds += 4 start = wb1_sheet1.cell(row=cell + 4, column=2).coordinate else: open += 3 open_seconds += 3 start = wb1_sheet1.cell(row=cell + 3, column=2).coordinate else: open += 3 open_seconds += 2 start = wb1_sheet1.cell(row=cell + 2, column=2).coordinate Not trying to be obtuse here, trying to suggest a practical solution. Of course, the benefit of reducing the number of times each lookup into the worksheet is performed by reducing the number of times each comparison evaluated is going to depend on the computational and memory manipulation cost of doing so (I assume the workbook is loaded in memory, so no IO costs), and how frequently this set of comparisons is being performed. -- Denis McMahon, denismfmcmahon at gmail.com From steve+comp.lang.python at pearwood.info Thu Oct 22 01:38:52 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 22 Oct 2015 16:38:52 +1100 Subject: select.poll and ppoll Message-ID: <56287672$0$11117$c3e8da3@news.astraweb.com> Using Python 2.6, don't hate me. I have select.poll, but I'm looking for something like ppoll instead. From the Linux man page: ppoll() The relationship between poll() and ppoll() is analogous to the relationship between select(2) and pselect(2): like pselect(2), ppoll() allows an application to safely wait until either a file descriptor becomes ready or until a signal is caught. Technically, *I* don't want this, it's one of my work-colleagues. He says: "My high-level goal is to run a callback function whenever the alsa mixer level changes. The C alsa API provides snd_mixer_elem_set_callback, but the Python API (import alsaaudio) seems to need me to get poll(2) descriptors" -- Steve From otlucaDELETE at DELETEyahoo.it Thu Oct 22 01:55:40 2015 From: otlucaDELETE at DELETEyahoo.it (Luca Menegotto) Date: Thu, 22 Oct 2015 07:55:40 +0200 Subject: variable scope of class objects References: <9ocd2btlkq7kp3margtn4sj3mehd7bpimm@4ax.com> Message-ID: Il 20/10/2015 23:33, JonRob ha scritto: > > > Hello Luca, > > I very much appreciated your comments. And I understand the > importance of "doing something right" (i.e. convention). > > This leads me to another question. > > Because I am interfacing with an I2C sensor I have many register > definations to include (30 register addresses and 26 Variables to be > red from some of those registers. > In your comment you mentioned that convention is to declare variables > (and constants?) in the construction (__ini__). > I am concerned that the sheer number of varialbe / constants would > make it difficult to read. > > In your opinion, what would be the best method to structure such code? > > Regards > JonRob Let's start from constants. Constants, in Python, simply don't exist (and IMHO this is one of the few lacks of Python). All you can do is to declare a variable and treat it as a constant: you never change it! It doesn't make sense to put a constant declaration at instance level, declaring it in the __init__ part of a class. After all, a constant is an information you want to share. The choice is up to you as the project manager: if you think that your constant is deeply related to the class you're designing, declare it as a class variable; otherwise, declare it at global level (in this case, often I use a separate file dedicated to constant declaration). -- Ciao! Luca From no.email at nospam.invalid Thu Oct 22 03:30:20 2015 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 22 Oct 2015 00:30:20 -0700 Subject: select.poll and ppoll References: <56287672$0$11117$c3e8da3@news.astraweb.com> Message-ID: <87lhavxsvn.fsf@jester.gateway.sonic.net> Steven D'Aprano writes: > I have select.poll, but I'm looking for something like ppoll instead. From > the Linux man page: I don't understand your post: do you have a question? Also I thought the current preferred practice was to use epoll. From rosuav at gmail.com Thu Oct 22 03:59:16 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 22 Oct 2015 18:59:16 +1100 Subject: Pandas' loading a CSV file problem In-Reply-To: References: Message-ID: On Thu, Oct 22, 2015 at 8:57 AM, Ek Esawi wrote: > > Traceback (most recent call last): > > File "C:\Users\EK Esawi\Anaconda3\Scripts\file1.py", line 3, in > > f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp.csv') > > File "C:\Users\EK Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 474, in parser_f > > You've missed off the critical line at the end, where it says what the actual error is. Can you copy and paste the whole error text, please? Also, I suspect something might have become mangled in transmission; if you can copy and paste your code as well, and make sure you post as plain text (not "rich text" or "HTML" or "formatted text" or anything like that), that would help. ChrisA From rosuav at gmail.com Thu Oct 22 04:05:04 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 22 Oct 2015 19:05:04 +1100 Subject: Defamation In-Reply-To: <20151022114508.1b95c332@mini.home> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <20151022114508.1b95c332@mini.home> Message-ID: On Thu, Oct 22, 2015 at 11:45 AM, John O'Hagan wrote: > On Wed, 21 Oct 2015 00:09:18 +1100 > Steven D'Aprano wrote: > > >> I don't believe that the Python mailing list archives are hosted in a >> country under the jurisdiction of European Law. If I'm right, then >> removing posts sets a dangerous precedent of obeying laws in foreign >> countries that don't apply. > > For better or worse, that's not how defamation law works. Generally, > the defaming is regarded as happening where the material is read, i.e. > at the point of download. The location of upload, hosting etc is > irrelevant, although the uploader and the host can both be liable > along with the author. Of course, the point is moot if none of those > people has assets in that jurisdiction. So... someone in Europe who rents a server in the US has to worry about defamation law in literally every country on this planet, or else IP-ban people from accessing the server, just in case s/he's liable? Is that really how this works? Ouch. ChrisA From peter.brittain.os at gmail.com Thu Oct 22 05:02:28 2015 From: peter.brittain.os at gmail.com (Peter Brittain) Date: Thu, 22 Oct 2015 02:02:28 -0700 (PDT) Subject: A high-level cross-platform API for terminal/console access In-Reply-To: References: <86bf9509-c512-4efa-9712-b51952a311e3@googlegroups.com> Message-ID: <0c3509e1-e27d-4804-88fb-b17d9d1172b4@googlegroups.com> On Wednesday, October 21, 2015 at 11:26:40 PM UTC+1, eryksun wrote: > > Also check out the curses module that's available on Christoph Gohlke's site: > > http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses Neat. I wasn't aware of this library of wheel installations. I'll have a look at how that works out and see if I can rationalize my mapping code. First impression is that this might be tricky, though, as I've had issues with older Linux distributions using ncurses 5 and so handling 256 colour modes has been difficult due to limits on colour pairs. This meant I had to fall back to looking up and using codes in the terminfo database using tigetstr. According to the PDcurses docs, these APIs are all just stubs that return an error and so I'll probably need a curses and PDcurses mapping layer from the looks of things - which is not much better than a curses and win32 mapping layer. I'm also still not convinced that curses package is the right API to expose for Python. While ncurses does a great job of abstracting away the issues of terminal inter-operation, the Python curses package is just a thin wrapper of that C library and, as can be seen above, not truly cross-platform due to the restrictions of PDcurses. Shouldn't we have a higher level simplification? Something that hides away all the complexity of handling all these different platforms and so exposes a simple API? One that humans can use without worrying about these issues? From lac at openend.se Thu Oct 22 05:07:36 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 22 Oct 2015 11:07:36 +0200 Subject: select.poll and ppoll In-Reply-To: <56287672$0$11117$c3e8da3@news.astraweb.com> References: <56287672$0$11117$c3e8da3@news.astraweb.com> Message-ID: <201510220907.t9M97a9x018130@fido.openend.se> In a message of Thu, 22 Oct 2015 16:38:52 +1100, "Steven D'Aprano" writes: >Using Python 2.6, don't hate me. >Technically, *I* don't want this, it's one of my work-colleagues. He says: > >"My high-level goal is to run a callback function whenever the alsa mixer >level changes. The C alsa API provides snd_mixer_elem_set_callback, but the >Python API (import alsaaudio) seems to need me to get poll(2) descriptors" >-- >Steve > >-- >https://mail.python.org/mailman/listinfo/python-list Do you need alsa-mixer or would pulse-audio work for you? Would this: https://github.com/mk-fg/pulseaudio-mixer-cli do the job? Laura (alsa-mixer hater) From lac at openend.se Thu Oct 22 05:23:42 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 22 Oct 2015 11:23:42 +0200 Subject: A high-level cross-platform API for terminal/console access In-Reply-To: <0c3509e1-e27d-4804-88fb-b17d9d1172b4@googlegroups.com> References: <86bf9509-c512-4efa-9712-b51952a311e3@googlegroups.com> <0c3509e1-e27d-4804-88fb-b17d9d1172b4@googlegroups.com> Message-ID: <201510220923.t9M9Ngdc019699@fido.openend.se> In a message of Thu, 22 Oct 2015 02:02:28 -0700, Peter Brittain writes: >On Wednesday, October 21, 2015 at 11:26:40 PM UTC+1, eryksun wrote: >> >> Also check out the curses module that's available on Christoph Gohlke's site: >> >> http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses > >Neat. I wasn't aware of this library of wheel installations. I'll have a look at how that works out and see if I can rationalize my mapping code. > >First impression is that this might be tricky, though, as I've had issues with older Linux distributions using ncurses 5 and so handling 256 colour modes has been difficult due to limits on colour pairs. This meant I had to fall back to looking up and using codes in the terminfo database using tigetstr. According to the PDcurses docs, these APIs are all just stubs that return an error and so I'll probably need a curses and PDcurses mapping layer from the looks of things - which is not much better than a curses and win32 mapping layer. > >I'm also still not convinced that curses package is the right API to expose for Python. While ncurses does a great job of abstracting away the issues of terminal inter-operation, the Python curses package is just a thin wrapper of that C library and, as can be seen above, not truly cross-platform due to the restrictions of PDcurses. > >Shouldn't we have a higher level simplification? Something that hides away all the complexity of handling all these different platforms and so exposes a simple API? One that humans can use without worrying about these issues? >-- >https://mail.python.org/mailman/listinfo/python-list Fredrik Lundh's console implementation http://effbot.org/zone/console-handbook.htm might be of interest in that case, but I think it is 'old versions of windows only'. But it's a different take on the abstraction problem. I haven't used it for something like 15 years now, though, so can barely remember it ... Laura From otlucaDELETE at DELETEyahoo.it Thu Oct 22 05:59:56 2015 From: otlucaDELETE at DELETEyahoo.it (Luca Menegotto) Date: Thu, 22 Oct 2015 11:59:56 +0200 Subject: variable scope of class objects References: <9ocd2btlkq7kp3margtn4sj3mehd7bpimm@4ax.com> <9i7g2b17d3e54cbcf35digbod9216fnovl@4ax.com> Message-ID: Maybe I've been too cryptic. I apologize. Il 22/10/2015 01:35, JonRob ha scritto: > @Dennis, > > > Thanks for your example. My structure is very similar. And that's ok. But you can also 'attach' the constants to a class, if it makes sense. For example, the same code of Dennis can be written as: class SensorA(): GYROXREG = 0x0010 GYROYREG = 0x0011 GYROZREG = 0x0001 _registers = [GYROXREG, GYROYREG, GYROZREG] And then you can invoke those constants as: SensorA.GYROXREG to emphasize that they are significant to this class, and to this class only. > Luca wrote... >> Please, note that declaring a variable in the constructor is only a >> convention: in Python you can add a variable to an object of a class >> wherever you want in your code (even if it is very dangerous and >> discouraged). This is the cryptic part. I mean: you can do, and it's perfectly legal: class A(): def __init__(self): self.a = 10 if __name__ == '__main__': o = A() print(o.a) # this is a new member, added on the fly o.b = 20 print(o.b) but, for God's sake, use it only if you have a gun at your head! -- Ciao! Luca From mail at johnohagan.com Thu Oct 22 06:10:13 2015 From: mail at johnohagan.com (John O'Hagan) Date: Thu, 22 Oct 2015 21:10:13 +1100 Subject: Defamation In-Reply-To: References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <20151022114508.1b95c332@mini.home> Message-ID: <20151022211013.0720d95a@mini.home> On Thu, 22 Oct 2015 19:05:04 +1100 Chris Angelico wrote: > On Thu, Oct 22, 2015 at 11:45 AM, John O'Hagan [...] > > > > For better or worse, that's not how defamation law works. Generally, > > the defaming is regarded as happening where the material is read, > > i.e. at the point of download. The location of upload, hosting etc > > is irrelevant, although the uploader and the host can both be liable > > along with the author. Of course, the point is moot if none of those > > people has assets in that jurisdiction. > > So... someone in Europe who rents a server in the US has to worry > about defamation law in literally every country on this planet, or > else IP-ban people from accessing the server, just in case s/he's > liable? Is that really how this works? Ouch. > It does seem harsh, and that Gutnick case I linked to was greeted with great alarm around the world back in 2002 for the same reasons as you've raised. In fact, some predicted a new age of "libel tourism", where people would travel to countries with especially harsh laws in order to sue, and the subsequent "death of the internet". But it hasn't turned out as badly as all that. The only noticeable change has been some cautious online publishers requiring readers to register. As I mentioned, it's only an issue if the defamed has reputation and the defamer has assets in the same jurisdiction. Once you think it through, it's pretty logical. If I write a defamatory letter about you and put it in a mailbox (upload it to a server), no defamation has happened yet. If someone reads it later (downloads it) in a country where no-one has heard of you, still no defamation. If someone reads it in a country where everyone knows you, but where I have no property, then technically there is defamation but you have no way to make me pay. It's only a civil claim so it's not like I'll have a criminal record or Interpol on my tail or anything. The other reason it makes sense is the alternative. If server location determined the jurisdiction, you'd have Cayman-style "libel-havens" with super-lax laws, stacked with servers people could use to defame anyone anywhere with impunity. I love free speech but not that much. Regards John From oscar.j.benjamin at gmail.com Thu Oct 22 06:33:13 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 22 Oct 2015 11:33:13 +0100 Subject: Defamation In-Reply-To: References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <20151022114508.1b95c332@mini.home> Message-ID: On 22 October 2015 at 09:05, Chris Angelico wrote: > On Thu, Oct 22, 2015 at 11:45 AM, John O'Hagan wrote: >> On Wed, 21 Oct 2015 00:09:18 +1100 >> Steven D'Aprano wrote: >> >> >>> I don't believe that the Python mailing list archives are hosted in a >>> country under the jurisdiction of European Law. If I'm right, then >>> removing posts sets a dangerous precedent of obeying laws in foreign >>> countries that don't apply. >> >> For better or worse, that's not how defamation law works. Generally, >> the defaming is regarded as happening where the material is read, i.e. >> at the point of download. The location of upload, hosting etc is >> irrelevant, although the uploader and the host can both be liable >> along with the author. Of course, the point is moot if none of those >> people has assets in that jurisdiction. > > So... someone in Europe who rents a server in the US has to worry > about defamation law in literally every country on this planet, or > else IP-ban people from accessing the server, just in case s/he's > liable? Is that really how this works? Ouch. Yeah the idea of national laws being subject to some kind of internationally agreed jurisdiction is nice but has never been implemented. Since you mention the US it's worth noting that some US federal laws effectively have global jurisdiction. This means that someone anywhere in the world can be deemed to have committed a criminal offence under certain US laws even if their actions are entirely legal under local law. I have a feeling that something may have changed recently but certainly until a few years ago we used to have lots of cases of "libel tourism" in the UK. This is where someone decides to bring a libel case which has nothing to do with the UK before the UK courts because libel law here is steeped in favour of the litigant. UK law requires the case to have a connection to the UK but the courts were apparently prepared to accept very tenuous connections (presumably because the whole business could function as an "export" bringing loads of money to all the lawyers involved). AFAIK these cases usually concerned foreign newspaper websites rather than something like the archive here though. Leaving aside the issue of "defamation" the posts that have been removed here are IMO "spam" and it's entirely reasonable to remove them regardless of any legal issues. -- Oscar From peter.brittain.os at gmail.com Thu Oct 22 06:56:35 2015 From: peter.brittain.os at gmail.com (Peter Brittain) Date: Thu, 22 Oct 2015 03:56:35 -0700 (PDT) Subject: A high-level cross-platform API for terminal/console access In-Reply-To: References: <86bf9509-c512-4efa-9712-b51952a311e3@googlegroups.com> <0c3509e1-e27d-4804-88fb-b17d9d1172b4@googlegroups.com> Message-ID: On Thursday, October 22, 2015 at 10:24:11 AM UTC+1, Laura Creighton wrote: > Fredrik Lundh's console implementation > http://effbot.org/zone/console-handbook.htm > might be of interest in that case, but I think it is 'old versions > of windows only'. But it's a different take on the abstraction > problem. I haven't used it for something like 15 years now, though, > so can barely remember it ... Thanks, but I think this is already covered in my original post: I couldn't use it directly due to the pip installation restriction. I've now created a working Windows implementation, so I don't need another mapping for win32. More generally, as these posts begin to show, there was no _simple_ way for me to get a cross-platform console API that "just worked" out of the box. I've had to jump through various hoops to get to where I am and don't think that other people should have to go through the same pain as I have. This is one of the reasons why I've been tidying up my package to make this as simple as possible for the next person. I've now got to the stage where I have something that works for me, but it is almost certainly missing something. Maybe it's not good enough documentation, maybe there's some clunkiness left in the API due to the history of the project, maybe there's an even better way to represent terminals than what I've come up with so far? I was hoping for feedback on this front rather than other ways I could recreate the curses package - unless of course, the general consensus is that this really is the way that Python should expose access to the terminal/console. From oscar.j.benjamin at gmail.com Thu Oct 22 07:10:00 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 22 Oct 2015 12:10:00 +0100 Subject: A high-level cross-platform API for terminal/console access In-Reply-To: References: <86bf9509-c512-4efa-9712-b51952a311e3@googlegroups.com> <0c3509e1-e27d-4804-88fb-b17d9d1172b4@googlegroups.com> Message-ID: On 22 October 2015 at 11:56, Peter Brittain wrote: > On Thursday, October 22, 2015 at 10:24:11 AM UTC+1, Laura Creighton wrote: >> Fredrik Lundh's console implementation >> http://effbot.org/zone/console-handbook.htm >> might be of interest in that case, but I think it is 'old versions >> of windows only'. But it's a different take on the abstraction >> problem. I haven't used it for something like 15 years now, though, >> so can barely remember it ... > > Thanks, but I think this is already covered in my original post: I couldn't use it directly due to the pip installation restriction. I've now created a working Windows implementation, so I don't need another mapping for win32. > > More generally, as these posts begin to show, there was no _simple_ way for me to get a cross-platform console API that "just worked" out of the box. I've had to jump through various hoops to get to where I am and don't think that other people should have to go through the same pain as I have. I've looked for this in the past and I also found that there was no general solution that I could just pick and use for both Windows and everything else. Even just writing a cross-platform getch function is needlessly complicated. > This is one of the reasons why I've been tidying up my package to make this as simple as possible for the next person. I've now got to the stage where I have something that works for me, but it is almost certainly missing something. Maybe it's not good enough documentation, maybe there's some clunkiness left in the API due to the history of the project, maybe there's an even better way to represent terminals than what I've come up with so far? > > I was hoping for feedback on this front rather than other ways I could recreate the curses package - unless of course, the general consensus is that this really is the way that Python should expose access to the terminal/console. Thanks for creating this. I will try it out when I next want to create something like this and give some feedback then. I don't really know when that will be though... -- Oscar From marko at pacujo.net Thu Oct 22 07:18:45 2015 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 22 Oct 2015 14:18:45 +0300 Subject: select.poll and ppoll References: <56287672$0$11117$c3e8da3@news.astraweb.com> Message-ID: <87eggnqhgq.fsf@elektro.pacujo.net> Steven D'Aprano : > I have select.poll, but I'm looking for something like ppoll instead. From > the Linux man page: > > ppoll() > The relationship between poll() and ppoll() is analogous to the > relationship between select(2) and pselect(2): like pselect(2), > ppoll() allows an application to safely wait until either a file > descriptor becomes ready or until a signal is caught. > > Technically, *I* don't want this, it's one of my work-colleagues. He > says: > > "My high-level goal is to run a callback function whenever the alsa > mixer level changes. The C alsa API provides > snd_mixer_elem_set_callback, but the Python API (import alsaaudio) > seems to need me to get poll(2) descriptors" I've never used ppoll or pselect. They are used to fix naive signal handling in a main loop: while not signaled: select.poll(...) ... The loop suffers from a race condition: the "signaled" flag, which is set by a signal handler, might change between "while" and "select.poll". The standard, classic way to solve the race condition is to replace the "signaled" flag with an internal pipe. The signal handler writes a byte into the pipe and select.poll() wakes up when the pipe becomes readable. IOW, ppoll() and pselect() are not needed. Marko From lac at openend.se Thu Oct 22 07:19:14 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 22 Oct 2015 13:19:14 +0200 Subject: Defamation In-Reply-To: References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <20151022114508.1b95c332@mini.home> Message-ID: <201510221119.t9MBJER4027985@fido.openend.se> In a message of Thu, 22 Oct 2015 11:33:13 +0100, Oscar Benjamin writes: >I have a feeling that something may have changed recently but >certainly until a few years ago we used to have lots of cases of >"libel tourism" in the UK. This is where someone decides to bring a >libel case which has nothing to do with the UK before the UK courts >because libel law here is steeped in favour of the litigant. UK law >requires the case to have a connection to the UK but the courts were >apparently prepared to accept very tenuous connections (presumably >because the whole business could function as an "export" bringing >loads of money to all the lawyers involved). AFAIK these cases usually >concerned foreign newspaper websites rather than something like the >archive here though. Very interesting. Any prominent court decisions that could be scaring them off? One thing to recall is that 'who/what can be defamed' varies a lot. In Sweden you cannot defame a corporation. The defamation regulations in the Penal Code only apply to private individuals. If you cannot bleed, you cannot be defamed. In certain situations the Swedish Marketing Act may be used to stop defamation of a corporate entity -- if a rival has, without basis, tainted a rival's reputation -- but this sort of protection is limited. This makes Sweden an attractive place to discuss Mosanto, and their evil practices, even though, like a lot of places Sweden's defamation law does not have a clause saying roughly 'if it is true, it isn't defamation'. Just 'intent to villify' is enough. Laura From gvanem at yahoo.no Thu Oct 22 07:22:24 2015 From: gvanem at yahoo.no (Gisle Vanem) Date: Thu, 22 Oct 2015 13:22:24 +0200 Subject: A high-level cross-platform API for terminal/console access References: Message-ID: <3198262E68F6451DBCF040F61F568832@dev.null> "Peter Brittain" wrote: >I have recently been working on a terminal/console animation package > (https://github.com/peterbrittain/asciimatics). I tried installing your package with "pip.exe -v install asciimatics". Some problem with pypiwin32 it seems: Installing collected packages: pypiwin32, future, Pillow, pyfiglet, asciimatics Cleaning up... Exception: Traceback (most recent call last): File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\basecommand.py", line 232, in main status = self.run(options, args) File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\commands\install.py", line 347, in run root=options.root_path, File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_set.py", line 549, in install **kwargs File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_install.py", line 751, in install self.move_wheel_files(self.source_dir, root=root) File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_install.py", line 960, in move_wheel_files isolated=self.isolated, File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\wheel.py", line 234, in move_wheel_files clobber(source, lib_dir, True) File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\wheel.py", line 212, in clobber shutil.copyfile(srcfile, destfile) File "g:\Programfiler\Python27\lib\shutil.py", line 83, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 13] Permission denied: 'g:\\Programfiler\\Python27\\Lib\\site-packages\\win32\\win32api.pyd' ----- BTW, this is on Python 2.7.9 on Win-XP SP3. --gv From lac at openend.se Thu Oct 22 07:36:34 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 22 Oct 2015 13:36:34 +0200 Subject: Defamation In-Reply-To: <201510221119.t9MBJER4027985@fido.openend.se> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <20151022114508.1b95c332@mini.home> <201510221119.t9MBJER4027985@fido.openend.se> Message-ID: <201510221136.t9MBaYGq029303@fido.openend.se> The UK libel reform act of 2013, I see, may be responsible for the decline in libel tourism. http://www.libelreform.org/ Laura From oscar.j.benjamin at gmail.com Thu Oct 22 07:59:32 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 22 Oct 2015 12:59:32 +0100 Subject: Defamation In-Reply-To: <201510221136.t9MBaYGq029303@fido.openend.se> References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> <20151022114508.1b95c332@mini.home> <201510221119.t9MBJER4027985@fido.openend.se> <201510221136.t9MBaYGq029303@fido.openend.se> Message-ID: On 22 October 2015 at 12:36, Laura Creighton wrote: > > The UK libel reform act of 2013, I see, may be responsible for > the decline in libel tourism. > http://www.libelreform.org/ Yes I think so. From Wikipedia: """ A court does not have jurisdiction to hear and determine any action, unless the court is satisfied that, of all the places in which the statement complained of has been published, England and Wales is clearly the most appropriate. """ https://en.wikipedia.org/wiki/Defamation_Act_2013#Jurisdiction Libel tourism cases often would occur for a foreign publication that was not distributed in printed form in the UK but had a website that was globally accessible. A case might be brought on the strength of say a hundred UK downloads from the website despite the publication having a printed circulation of hundreds of thousands in some other country (and the authors and complainants all being in the same other country). I can't recall any specific cases right now though... If the court needs to be satisfied that England and Wales is the _most_ appropriate place to hear the case then this would rule out the libel tourism cases I used to hear about. Apparently this only applies to England and Wales though leaving Northern Ireland as a new preferred location for libel tourism. -- Oscar From peter.brittain.os at gmail.com Thu Oct 22 08:04:55 2015 From: peter.brittain.os at gmail.com (Peter Brittain) Date: Thu, 22 Oct 2015 05:04:55 -0700 (PDT) Subject: A high-level cross-platform API for terminal/console access In-Reply-To: References: Message-ID: On Thursday, October 22, 2015 at 12:25:09 PM UTC+1, Gisle Vanem wrote: > I tried installing your package with "pip.exe -v install asciimatics". > Some problem with pypiwin32 it seems: > > Installing collected packages: pypiwin32, future, Pillow, pyfiglet, asciimatics > > Cleaning up... > Exception: > Traceback (most recent call last): > File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\basecommand.py", line 232, in main > status = self.run(options, args) > File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\commands\install.py", line 347, in run > root=options.root_path, > File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_set.py", line 549, in install > **kwargs > File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_install.py", line 751, in install > self.move_wheel_files(self.source_dir, root=root) > File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\req\req_install.py", line 960, in move_wheel_files > isolated=self.isolated, > File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\wheel.py", line 234, in move_wheel_files > clobber(source, lib_dir, True) > File "g:\Programfiler\Python27\lib\site-packages\pip-6.0.6-py2.7.egg\pip\wheel.py", line 212, in clobber > shutil.copyfile(srcfile, destfile) > File "g:\Programfiler\Python27\lib\shutil.py", line 83, in copyfile > with open(dst, 'wb') as fdst: > IOError: [Errno 13] Permission denied: 'g:\\Programfiler\\Python27\\Lib\\site-packages\\win32\\win32api.pyd' > > ----- > > BTW, this is on Python 2.7.9 on Win-XP SP3. > > --gv That's a new one on me. The pypiwin32 package has installed fine for me on Python 3 in Windows 7, 8 and 10. Sadly I don't have ready access to an XP machine, so can't easily try a repro myself... Does the file already exist, or are you lacking permissions to update the folder? From rosuav at gmail.com Thu Oct 22 08:09:22 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 22 Oct 2015 23:09:22 +1100 Subject: A high-level cross-platform API for terminal/console access In-Reply-To: <3198262E68F6451DBCF040F61F568832@dev.null> References: <3198262E68F6451DBCF040F61F568832@dev.null> Message-ID: On Thu, Oct 22, 2015 at 10:22 PM, Gisle Vanem wrote: > IOError: [Errno 13] Permission denied: > 'g:\\Programfiler\\Python27\\Lib\\site-packages\\win32\\win32api.pyd' > > ----- > > BTW, this is on Python 2.7.9 on Win-XP SP3. Does that file exist? A .pyd file is a DLL, so if it already exists and is in use, it's entirely possible it can't be overwritten (eg to upgrade it). ChrisA From gvanem at yahoo.no Thu Oct 22 08:42:56 2015 From: gvanem at yahoo.no (Gisle Vanem) Date: Thu, 22 Oct 2015 14:42:56 +0200 Subject: A high-level cross-platform API for terminal/console access References: <3198262E68F6451DBCF040F61F568832@dev.null> Message-ID: <021B824D533D44B9A5218FB08C28E1D5@dev.null> "Chris Angelico" wrote: > On Thu, Oct 22, 2015 at 10:22 PM, Gisle Vanem wrote: >> IOError: [Errno 13] Permission denied: >> 'g:\\Programfiler\\Python27\\Lib\\site-packages\\win32\\win32api.pyd' >> >> ----- >> >> BTW, this is on Python 2.7.9 on Win-XP SP3. > > Does that file exist? A .pyd file is a DLL, so if it already exists > and is in use, it's entirely possible it can't be overwritten (eg to > upgrade it). It exists all right and I do have full access to that folder. I think the Errno 13 (=EACCESS) is due to another module (WConio.pyd) that seems gets loaded via my site-customize.py is using this win32api.pyd. Hence it's is in use and shutil fails in updating it. --gv From esawiek at gmail.com Thu Oct 22 08:44:50 2015 From: esawiek at gmail.com (Ek Esawi) Date: Thu, 22 Oct 2015 08:44:50 -0400 Subject: Pandas' loading a CSV file problem Message-ID: Here is the whole output. EKE Traceback (most recent call last): File "C:\Users\EK Esawi\Anaconda3\Scripts\MyFile.py", line 3, in f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp1.csv') File "C:\Users\EK Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 474, in parser_f return _read(filepath_or_buffer, kwds) File "C:\Users\EK Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 260, in _read return parser.read() File "C:\Users\EK Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 721, in read ret = self._engine.read(nrows) File "C:\Users\EK Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1170, in read data = self._reader.read(nrows) File "pandas\parser.pyx", line 769, in pandas.parser.TextReader.read (pandas\parser.c:7544) File "pandas\parser.pyx", line 791, in pandas.parser.TextReader._read_low_memory (pandas\parser.c:7784) File "pandas\parser.pyx", line 866, in pandas.parser.TextReader._read_rows (pandas\parser.c:8617) File "pandas\parser.pyx", line 973, in pandas.parser.TextReader._convert_column_data (pandas\parser.c:9928) File "pandas\parser.pyx", line 1033, in pandas.parser.TextReader._convert_tokens (pandas\parser.c:10714) File "pandas\parser.pyx", line 1130, in pandas.parser.TextReader._convert_with_dtype (pandas\parser.c:12118) File "pandas\parser.pyx", line 1150, in pandas.parser.TextReader._string_convert (pandas\parser.c:12332) File "pandas\parser.pyx", line 1382, in pandas.parser._string_box_utf8 (pandas\parser.c:17655) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 8: invalid start byte -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Oct 22 08:48:56 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 22 Oct 2015 23:48:56 +1100 Subject: A high-level cross-platform API for terminal/console access In-Reply-To: <021B824D533D44B9A5218FB08C28E1D5@dev.null> References: <3198262E68F6451DBCF040F61F568832@dev.null> <021B824D533D44B9A5218FB08C28E1D5@dev.null> Message-ID: On Thu, Oct 22, 2015 at 11:42 PM, Gisle Vanem wrote: > I think the Errno 13 (=EACCESS) is due to another module (WConio.pyd) that > seems gets loaded via my site-customize.py is using this > win32api.pyd. Hence it's is in use and shutil fails in updating it. Ah, that might well be it. Does it work if you run: python -S -m pip install --upgrade win32api ? That might stop win32api.pyd from getting loaded. ChrisA From oscar.j.benjamin at gmail.com Thu Oct 22 08:56:52 2015 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Thu, 22 Oct 2015 13:56:52 +0100 Subject: A high-level cross-platform API for terminal/console access In-Reply-To: <021B824D533D44B9A5218FB08C28E1D5@dev.null> References: <3198262E68F6451DBCF040F61F568832@dev.null> <021B824D533D44B9A5218FB08C28E1D5@dev.null> Message-ID: On 22 October 2015 at 13:42, Gisle Vanem wrote: > "Chris Angelico" wrote: > >> On Thu, Oct 22, 2015 at 10:22 PM, Gisle Vanem wrote: >>> >>> IOError: [Errno 13] Permission denied: >>> 'g:\\Programfiler\\Python27\\Lib\\site-packages\\win32\\win32api.pyd' >>> >>> ----- >>> >>> BTW, this is on Python 2.7.9 on Win-XP SP3. >> >> >> Does that file exist? A .pyd file is a DLL, so if it already exists >> and is in use, it's entirely possible it can't be overwritten (eg to >> upgrade it). > > > It exists all right and I do have full access to that folder. > > I think the Errno 13 (=EACCESS) is due to another module (WConio.pyd) that > seems gets loaded via my site-customize.py is using this > win32api.pyd. Hence it's is in use and shutil fails in updating it. Does it work if you ask pip to install each dependency separately? i.e. you could just run pip install pypiwin32. -- Oscar From motoom at xs4all.nl Thu Oct 22 09:23:27 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Thu, 22 Oct 2015 15:23:27 +0200 Subject: Pandas' loading a CSV file problem In-Reply-To: References: Message-ID: <0A1D1BBF-7804-4FDB-946E-EC7FAA915C6A@xs4all.nl> Hi Ek, > On 22 Oct 2015, at 14:44, Ek Esawi wrote: > > f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp1.csv') > File "pandas\parser.pyx", line 1382, in pandas.parser._string_box_utf8 (pandas\parser.c:17655) > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 8: invalid start byte I guess you're on Windows and your CSV file is encoded as Windows-1252. Unless you tell Pandas this it'll assume your file is utf-8 encoded. Try this: f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp1.csv', encoding='windows-1252') Greetings, From gvanem at yahoo.no Thu Oct 22 09:42:33 2015 From: gvanem at yahoo.no (Gisle Vanem) Date: Thu, 22 Oct 2015 15:42:33 +0200 Subject: A high-level cross-platform API for terminal/console access References: <3198262E68F6451DBCF040F61F568832@dev.null> <021B824D533D44B9A5218FB08C28E1D5@dev.null> Message-ID: "Chris Angelico" wrote: > Ah, that might well be it. Does it work if you run: > > python -S -m pip install --upgrade win32api Hm. c:\>python2 -S -m pip install --upgrade win32api Collecting win32api Could not find any downloads that satisfy the requirement win32api No distributions at all found for win32api I think you mean 'pypiwin32'. Since: c:\>python2 -S -m pip install --upgrade pypiwin32 Requirement already up-to-date: pypiwin32 in g:\programfiler\python27\lib\site-packages So now, running 'setup.py install' in AsciiMatics' directory, all seems to install okay. But the samples have problems if launched from the sample directory! It seems to be related to my Windows associations for .png files; 'python2 win_demo.py' launches this: g:\util\Graphics\IrfanView\i_view32.exe G:\Programfiler\Python27\Lib\site-packages\AsciiMatics\samples\python.png G:\Programfiler\Python27\Lib\site-packages\AsciiMatics\samples\win_demo.py Yes, all on 1 line. Notice the 'win_demo.py' is last!!?? But 'python2 samples\win_demo.py' works fine (see attached screen-shot). Allthough it messes up the screen's scrollback buffer. Similar to how most PDcurses do on Windows :-( --gv -------------- next part -------------- A non-text attachment was scrubbed... Name: win_demo_output.png Type: image/png Size: 20817 bytes Desc: not available URL: From esawiek at gmail.com Thu Oct 22 10:04:41 2015 From: esawiek at gmail.com (Ek Esawi) Date: Thu, 22 Oct 2015 10:04:41 -0400 Subject: Pandas' loading a CSV file problem Message-ID: Thanks you all for the input. Michiel's suggestion worked. At first It gave me an error about "low_memory"; once i sat low_memory to false, it worked. I am new to pandas and i am working on a 20,000 record csv file with mixed data types and in many cases, one entry (cell) has a combination of string and numeric values which will eventually be separated. Thanks again-EK -------------- next part -------------- An HTML attachment was scrubbed... URL: From input/ldompeling at casema.nl Thu Oct 22 11:07:56 2015 From: input/ldompeling at casema.nl (input/ldompeling at casema.nl) Date: Thu, 22 Oct 2015 15:07:56 GMT Subject: my first script for the GoPiGo Message-ID: I want that this script runs to times from the upper line to the buttom line. I tried with for x in range(2): but that didn't work The GoPiGo is a small robot on wheels. The API codes are here: http://www.dexterindustries.com/GoPiGo/programming/python-programming-for-the- raspberry-pi-gopigo/ from gopigo import * import time for x in range (2): mindist = 70 servo(120) time.sleep(2) fwd() stop() time.sleep(2) bwd() stop() if mindist > us_dist(15): bwd() stop print x -- --------------------------------- --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From steve at pearwood.info Thu Oct 22 11:17:28 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Fri, 23 Oct 2015 02:17:28 +1100 Subject: Defamation References: <1454496840.1661921445200299637.JavaMail.httpd@webmail-50.iol.local> <56263cfe$0$1616$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5628fe09$0$1590$c3e8da3$5496439d@news.astraweb.com> On Thu, 22 Oct 2015 11:45 am, John O'Hagan wrote: > On Wed, 21 Oct 2015 00:09:18 +1100 > Steven D'Aprano wrote: > > >> I don't believe that the Python mailing list archives are hosted in a >> country under the jurisdiction of European Law. If I'm right, then >> removing posts sets a dangerous precedent of obeying laws in foreign >> countries that don't apply. > > For better or worse, that's not how defamation law works. Generally, > the defaming is regarded as happening where the material is read, i.e. > at the point of download. The location of upload, hosting etc is > irrelevant, although the uploader and the host can both be liable > along with the author. Of course, the point is moot if none of those > people has assets in that jurisdiction. > > For example: > > https://en.wikipedia.org/wiki/Dow_Jones_%26_Co_Inc_v_Gutnick You can't generalise from a ruling in one state (Australia) when other country's legal systems may (and almost certainly are) different. For example, the US explicitly prohibits their courts from enforcing foreign libel or defamation suits unless the other country provides at least as much protection for free speech as does the US. Oh, and for what it's worth, I remember that case very well, and I think the judges were terribly naive in some of their comments. Specifically, they poo-pooed the suggestion that the ruling could lead to a flurry of defamation actions in Australia against publications all over the world. If they were right, it was more by good luck than by good reasoning: the UK, not Australia, was the go-to place for "libel tourism". https://en.wikipedia.org/wiki/Libel_tourism > On the specific point, I think it's possible to agree with both > Steven and Laura. It's a bad idea to obey laws that don't apply to > you if you'd rather not. It's also a good idea if possible to remove > defamatory material, not because it might be illegal, but because it's > defamatory. Defamatory according to whom, according to what standards? Standards vary greatly. It is hard to prove defamation in the US, it was ridiculously easy in the UK (things are better since the Simon Singh case inspired the UK government to change the law), and in places like Singapore defamation is a thinly disguised weapons for the ruling party to use to attack political opponents and critics, and protect themselves from having their corrupt activities revealed. http://singaporepress.pbworks.com/w/page/11489265/Defamation%20Act http://www.irrawaddy.org/asia/in-singapore-the-economics-of-defamation.html http://singaporedissident.blogspot.com.au/2012/02/lee-family-will-not-sue-for-defamation.html http://www.singapore-window.org/sw02/020926au.htm Including ordinary bloggers: http://blogs.wsj.com/indonesiarealtime/2014/06/04/libel-suit-turns-singapore-blogger-into-underdog-for-pensioners/ -- Steven From python at mrabarnett.plus.com Thu Oct 22 11:25:18 2015 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 22 Oct 2015 16:25:18 +0100 Subject: my first script for the GoPiGo In-Reply-To: References: Message-ID: <5628FFDE.2050908@mrabarnett.plus.com> On 2015-10-22 16:07, input/ldompeling at casema.nl wrote: > I want that this script runs to times from the upper line to the buttom line. > I tried with for x in range(2): but that didn't work You say "didn't work", but in what way didn't it work? > The GoPiGo is a small robot on wheels. > > The API codes are here: > http://www.dexterindustries.com/GoPiGo/programming/python-programming-for-the- > raspberry-pi-gopigo/ > > > from gopigo import * > import time > > for x in range (2): The lines to be repeated should be indented more than the 'for' line. > mindist = 70 > servo(120) > time.sleep(2) > fwd() > stop() > time.sleep(2) > bwd() > stop() > if mindist > us_dist(15): > bwd() > stop > print x > From input/ldompeling at casema.nl Thu Oct 22 11:45:28 2015 From: input/ldompeling at casema.nl (input/ldompeling at casema.nl) Date: Thu, 22 Oct 2015 15:45:28 GMT Subject: my first script for the GoPiGo References: Message-ID: In reply to "MRAB" who wrote the following: > On 2015-10-22 16:07, input/ldompeling at casema.nl wrote: > > I want that this script runs to times from the upper line to the buttom > > line. > > I tried with for x in range(2): but that didn't work > > You say "didn't work", but in what way didn't it work? > > > The GoPiGo is a small robot on wheels. > > > > The API codes are here: > > http://www.dexterindustries.com/GoPiGo/programming/ > > python-programming-for-the- > > raspberry-pi-gopigo/ > > > > > > from gopigo import * > > import time > > Thanks or the reply. I mean that i want this script running two times. So the first line is mindist = 70 And the last line is print x And that two times So that the robut continues moving two times in this script, from the upperline to the bottum line two times. > > for x in range (2): > > The lines to be repeated should be indented more than the 'for' line. > > > mindist = 70 > > servo(120) > > time.sleep(2) > > fwd() > > stop() > > time.sleep(2) > > bwd() > > stop() > > if mindist > us_dist(15): > > bwd() > > stop > > print x > > -- --------------------------------- --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From python at mrabarnett.plus.com Thu Oct 22 12:40:45 2015 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 22 Oct 2015 17:40:45 +0100 Subject: my first script for the GoPiGo In-Reply-To: References: Message-ID: <5629118D.6010604@mrabarnett.plus.com> On 2015-10-22 16:45, input/ldompeling at casema.nl wrote: > In reply to "MRAB" who wrote the following: > >> On 2015-10-22 16:07, input/ldompeling at casema.nl wrote: >> > I want that this script runs to times from the upper line to the buttom >> > line. >> > I tried with for x in range(2): but that didn't work >> >> You say "didn't work", but in what way didn't it work? >> >> > The GoPiGo is a small robot on wheels. >> > >> > The API codes are here: >> > http://www.dexterindustries.com/GoPiGo/programming/ >> > python-programming-for-the- >> > raspberry-pi-gopigo/ >> > >> > >> > from gopigo import * >> > import time >> > > Thanks or the reply. > > I mean that i want this script running two times. > So the first line is mindist = 70 > And the last line is print x > And that two times > So that the robut continues moving two times in this script, from the upperline > to the bottum line two times. > Then just indent those lines and precede them with the 'for' line. > >> > for x in range (2): >> >> The lines to be repeated should be indented more than the 'for' line. >> >> > mindist = 70 >> > servo(120) >> > time.sleep(2) >> > fwd() >> > stop() >> > time.sleep(2) >> > bwd() >> > stop() >> > if mindist > us_dist(15): >> > bwd() >> > stop >> > print x >> > From kevin.p.dwyer at gmail.com Thu Oct 22 13:40:53 2015 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Thu, 22 Oct 2015 18:40:53 +0100 Subject: PyPi bug? References: <5627ACD7.20704@shopzeus.com> Message-ID: Nagy L?szl? Zsolt wrote: > Today I have tried to register and upload a new package by executing > > setup.py register > > > I was asked if I want to save the creditentials in a .pypirc file and I > answered yes. > > Next I wanted to run > > setup.py upload > > and I got this error: > > > Traceback (most recent call last): > File "C:\Python\Projects\some_package\setup.py", line 15, in > classifiers=['Topic :: Security', 'Topic :: Internet :: WWW/HTTP'], > File "C:\Python35\lib\distutils\core.py", line 148, in setup > dist.run_commands() > File "C:\Python35\lib\distutils\dist.py", line 955, in run_commands > self.run_command(cmd) > File "C:\Python35\lib\distutils\dist.py", line 973, in run_command > cmd_obj.ensure_finalized() > File "C:\Python35\lib\distutils\cmd.py", line 107, in ensure_finalized > self.finalize_options() > File "C:\Python35\lib\distutils\command\upload.py", line 46, in > finalize_options > config = self._read_pypirc() > File "C:\Python35\lib\distutils\config.py", line 83, in _read_pypirc > current[key] = config.get(server, key) > File "C:\Python35\lib\configparser.py", line 798, in get > d) > File "C:\Python35\lib\configparser.py", line 396, in before_get > self._interpolate_some(parser, option, L, value, section, defaults, 1) > File "C:\Python35\lib\configparser.py", line 445, in _interpolate_some > "found: %r" % (rest,)) > configparser.InterpolationSyntaxError: '%' must be followed by '%' or > '(', found > : *****************' > > Instead of the many stars, of course there is the password. The problem > might be that the password contains a % character, and it was > incorrectly saved by distutils. > > Can somebody please confirm that this is a bug in distutils? The we > probably have to submit a bug report. > > Thanks, > > Laszlo Could be http://bugs.python.org/issue20120 ? From gandalf at shopzeus.com Thu Oct 22 14:13:29 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Thu, 22 Oct 2015 20:13:29 +0200 Subject: PyPi bug? In-Reply-To: References: <5627ACD7.20704@shopzeus.com> Message-ID: <56292749.2000301@shopzeus.com> > > Could be http://bugs.python.org/issue20120 ? Almost. Except that the password was saved incorrectly by distutils itself. So maybe the read part should not be fixed, but the write part should. From lac at openend.se Fri Oct 23 05:58:39 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 23 Oct 2015 11:58:39 +0200 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> Message-ID: <201510230958.t9N9weVM029787@fido.openend.se> In a message of Fri, 23 Oct 2015 11:42:54 +0200, Peter Otten writes: >I tried it out: > >$ mkdir test >$ cd test >$ touch string.py >$ idle3 >Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python3.4/idlelib/run.py", line 12, in > from idlelib import CallTips > File "/usr/lib/python3.4/idlelib/CallTips.py", line 16, in > from idlelib.HyperParser import HyperParser > File "/usr/lib/python3.4/idlelib/HyperParser.py", line 14, in > _ASCII_ID_CHARS = frozenset(string.ascii_letters + string.digits + "_") >AttributeError: 'module' object has no attribute 'ascii_letters' > >Then idle shows the message and quits after you hit OK. > >Is there a bug report? I didn't make one at the time. I am not finding one on the tracker that looks like it. Laura From tjreedy at udel.edu Fri Oct 23 06:03:33 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 23 Oct 2015 06:03:33 -0400 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> Message-ID: On 10/23/2015 5:42 AM, Peter Otten wrote: > Laura Creighton wrote: > >> In a message of Fri, 23 Oct 2015 00:19:42 -0400, Terry Reedy writes: >>> On 10/21/2015 11:24 AM, Terry Alexander via Python-list wrote: >>> >>>> I have tried installing both Python 2.7 and 3.5, and in both cases I >>>> cannot get IDLE to work. I received the following message both times: >>> >>> What OS? Windows? which version? How did you start IDLE? Start menu >>> icon? Command line? >>> >>>> IDLE?s subprocess didn?t make connection.Either IDLE can?t start a >>>> subprocess or personal firewall software is blocking the connection. >>>> >>>> I am running Norton, and disabled it, but still IDLE will not run. Any >>>> suggestions? >>> >>> Don't shout with ALL CAPS in the subject line. It usually indicates >>> spam. I already know that this problem is very frustrating. >>> >>> Firewalls are seldom the problems anymore. I occasionally saw this on >>> Win 7 when restarting, but never on startup, and never more than once or >>> twice in a session. >>> >>> What's left is misconfiguration of your network interface that prevents >>> a loopback connection. There might be answers on Stackoverflow that >>> would help, depending on your OS. >>> >>> In the meanwhile, you can start IDLE with the -n option. Either use a >>> command line or create an 'IDLE -n' icon. Again, details depend on >>> exact OS. >>> Terry Jan Reedy >> >> You can also get this message if you run idle in directory where you >> have your own python file whose name shadows something in the >> standard library (that idle is interested in). I think it was >> a file named 'string.py' that did this to a student of mine a >> few years ago. >> Laura I can imagine that a bad socket module might have this effect. With verification that a user file could have this effect, I would augment the message. > I tried it out: > > $ mkdir test > $ cd test > $ touch string.py > $ idle3 > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python3.4/idlelib/run.py", line 12, in > from idlelib import CallTips > File "/usr/lib/python3.4/idlelib/CallTips.py", line 16, in > from idlelib.HyperParser import HyperParser > File "/usr/lib/python3.4/idlelib/HyperParser.py", line 14, in > _ASCII_ID_CHARS = frozenset(string.ascii_letters + string.digits + "_") > AttributeError: 'module' object has no attribute 'ascii_letters' > > Then idle shows the message and quits after you hit OK. > > Is there a bug report? No. Quitting because a stdlib module cannot be imported (or corrupted) is not a bug. AttributeError is a typical symptom. A user file called random.py is probably more common. -- Terry Jan Reedy From gheskett at wdtv.com Fri Oct 23 07:37:15 2015 From: gheskett at wdtv.com (Gene Heskett) Date: Fri, 23 Oct 2015 07:37:15 -0400 Subject: how to get python socket to use a specific interface In-Reply-To: <5629F7ED.6060606@chamonix.reportlab.co.uk> References: <5629F7ED.6060606@chamonix.reportlab.co.uk> Message-ID: <201510230737.15259.gheskett@wdtv.com> On Friday 23 October 2015 05:03:41 Robin Becker wrote: > I need to run lynx on a ubuntu headless server with a specific IP > address in order to try and cancel an email blacklist. > > Lynx doesn't provide a way to do that so I thought to use a local > proxy. I tried pymiproxy and hacked the connection code so it looked > like this > > > proxy.py > ........ > > > from socket import socket, SOL_SOCKET > > ....... > > import os > > BIND_ADDRESS = os.environ.get('PYMIPROXY_BIND_ADDRESS',None) > > BIND_DEVICE = os.environ.get('PYMIPROXY_BIND_DEVICE',None) > > ............. > > # Connect to destination > > sock = self._proxy_sock = socket() > > sock.settimeout(10) > > if BIND_ADDRESS: > > sock.bind((BIND_ADDRESS, 0)) > > if BIND_DEVICE: > > sock.setsockopt(SOL_SOCKET, 25, BIND_DEVICE) > > sock.connect((self.hostname, int(self.port))) > > 25 is derived from /usr/include/asm-generic/socket.h > > > #define SO_BINDTODEVICE 25 > > This works if I export BIND_DEVICE='eth0' and run as root, but my > desired interface is actually called 'eth0:0' and when I run with that > exported I get a device error. Does anyone know what I should call the > device? -- > Robin Becker Using eth0:0 is normally a method to setup eth0 to respond to a 2nd IPV4/IPV6 address. Have you done the ifconfig steps to enable that? If its been done, you will see it's 2nd address in an ifconfig query. Man pages are wunnerful things. I think you can use it as a normal user, but the ifconfig IIRC has to be done by root, or sudo. One of my printers has a cat5 socket, which turns out to be its fastest interface, and I had to setup an eth0:0 in 192.168.0.## block for a day or so until I had wandered thru its menus and found I could put it on my local networks class D block and did, so eth0:0 was no longer required. 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 dore.theo36 at gmail.com Fri Oct 23 09:18:00 2015 From: dore.theo36 at gmail.com (dore.theo36 at gmail.com) Date: Fri, 23 Oct 2015 15:18:00 +0200 Subject: No subject Message-ID: <562a338d.84adc20a.92377.382d@mx.google.com> Provenance?: Courrier pour Windows 10 -------------- next part -------------- An HTML attachment was scrubbed... URL: From israel at ravnalaska.net Fri Oct 23 12:35:06 2015 From: israel at ravnalaska.net (Israel Brewster) Date: Fri, 23 Oct 2015 08:35:06 -0800 Subject: Best way to do background calculations? Message-ID: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> tl;dr: I've been using the multiprocessing module to run some calculations in the background of my CherryPy web app, but apparently this process sometimes gets stuck, causing problems with open sockets piling up and blocking the app. Is there a better way? The (rather wordy) details: I have a moderately busy web app written in python using the CherryPy framework (CherryPy v 3.8.0 with ws4py v 0.3.4 and Python 2.7.6) . One of the primary purposes of this web app is to track user-entered flight logs, and keep a running tally of hours/cycles/landings for each aircraft. To that end, whenever a user enters or modifies a log, I "recalculate" the totals for that aircraft, and update all records with the new totals. There are probably ways to optimize this process, but so far I haven't seen a need to spend the time. Ideally, this recalculation process would happen in the background. There is no need for the user to wait around while the system crunches numbers - they should be able to move on with entering another log or whatever else they need to do. To that end, I implemented the call to the recalc function using the multiprocessing module, so it could start in the background and the main process move on. Lately, though, I've been running into a problem where, when looking at the process list on my server (Mac OS X 10.10.5), I'll see two or more "copies" of my server process running - one master and one or more child processes. As the above described process is the only place I am using the multiprocessing module, I am making the assumption that this is what these additional processes are. If they were only there for a few minutes I would think this is normal, and it wouldn't be a problem. However, what I am seeing is that from time to time (once or twice every couple of days) these additional processes will get "stuck", and when that happens sockets opened by the web app don't get properly closed and start piling up. Looking at a list of open sockets on the server when I have one of these "hung" processes shows a steadily increasing number of sockets in a "CLOSE_WAIT" state (normally I see none in that state). Killing off the hung process(es) clears out these sockets, but if I don't catch it quickly enough these sockets can build up to the point that I am unable to open any more, and the server starts rejecting connections. I'm told this happens because the process retains a reference to all open files/sockets from the parent process, thus preventing the sockets from closing until the process terminates. Regardless of the reason, it can cause a loss of service if I don't catch it quickly enough. As such, I'm wondering if there is a better way. Should I be looking at using the threading library rather than the multiprocessing library? My understanding is that the GIL would prevent that approach from being of any real benefit for a calculation intensive type task, but maybe since the rest of the application is CherryPy threads, it would still work well?. Or perhaps there is a way to not give the child process any references to the parent's files/sockets - although that may not help with the process hanging? Maybe there is a way to "monitor" the process, and automatically kill it if it stops responding? Or am I totally barking up the wrong tree here? Thanks for any insight anyone can provide! ----------------------------------------------- Israel Brewster Systems Analyst II Ravn Alaska 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Israel Brewster.vcf Type: text/directory Size: 417 bytes Desc: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Fri Oct 23 12:53:37 2015 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 23 Oct 2015 17:53:37 +0100 Subject: OT snake_case Message-ID: <562A6611.3000303@mrabarnett.plus.com> I just discovered today that writing names in lowercase with underscores is sometimes called "snake case". Seems kind of apt for Python! :-) Apparently, it was coined in the Ruby community... From inigoserna at gmail.com Fri Oct 23 16:17:08 2015 From: inigoserna at gmail.com (=?utf-8?Q?I=C3=B1igo?= Serna) Date: Fri, 23 Oct 2015 22:17:08 +0200 Subject: ANN: lfm v3.0 Message-ID: <87d1w5e3wb.fsf@inigo.katxi.org> Hi all, after many years, new version of lfm; now compatible with Python 3.4+. Description =========== Last File Manager is a powerful file manager for the UNIX console. It has a curses interface and it's written in Python v3.4+. Licensed under GNU Public License version 3 or later. Some of the features you can find in lfm: - console-based file manager for UNIX platforms - 1-pane or 2-pane view - tabs - files filters - bookmarks - history - VFS for compressed files - tree view - dialogs with entry completion - PowerCLI, a command line interface with advanced features - fast access to the shell - direct integration of find/grep, df and other tools - color files by extension [Andrey Skvortsov] - fully customizable themes (colors) - fully customizable key bindings - support for filenames with wide chars, f.e. East Asian - ...and many others Home page: https://inigo.katxi.org/devel/lfm/ Pypi: https://pypi.python.org/pypi/lfm Code repository: https://bitbucket.org/inigoserna/lfm3 Changes since last version ========================== Version 3.0 ("Only you") - 2015/10/23: + About the code - almost completely rewritten from scratch . it hasn't been tested as much as lfm v2.x series on non-linux OS - requires Python v3.4+ - pyview, the file viewer, has been removed from lfm package - configuration location has changed to a new directory and files: ~/.config/lfm/{lfm.ini, lfm.keys, lfm.theme, lfm.history} + New features - fully customizable themes (colors) - fully customizable key bindings . allow Alt-key shorcuts (A-) . only for main window (not for dialogs) - files filters (using globs) . information in pane frame: ".F" => show dotfiles, active filters . filters are a property of a tab, they remain active even when chdir . Ctrl-f: edit current filter . Some examples: . "*.png,*.jpg" => hide all PNG and JPEG files . "*.jpg,!*shot*" => hide all JPEG files except those with 'shot' in the name . "*,!*py" => hide all except python source files - up to 35 bookmarks (0-9, a-z) . b: go to bookmark, B: set bookmark, C-d: select bookmark . fix: don't delete bookmark at start if path does not exist - nested archive handling (vfs inside vfs) works now - added optional support for filenames with wide chars, f.e. East Asian . to enable, set 'use_wide_chars' flag in configuration or use -w command line flag . it's disabled by default for performance . it's not perfect, but it mostly works - there are 2 different versions of move_file to chose from in the key bindings file: . move_file: old implementation . move_file2: alternative version using shtutil.move instead of copy & delete. Faster but less control of errors - new action: redraw screen (default key A-r) + Changes & improvements (vs v2.x): - chmod & chown/chgrp are 2 different actions now - cursor_goto_file (C-s): find text pattern (no regex or glob) in the whole file name, not at the beginning as v2.x - cursor_goto_file_1char (A-s): go to file by 1st letter of name (old C-s behaviour) - bookmarks have new key bindings: b: go to bookmark, B: set bookmark, C-d: select bookmark - PowerCLI: . ending command with % must be $ now . added new date variables: dm, dc, da, dn . ending command with % must be $ now . added new date variables: dm, dc, da, dn . old $d variable is $p now - find/grep: panelize = create vfs with matched files . if rebuild: all files modifications or deletions are translated to original directory so be careful! - pyview, the file viewer, has been removed from lfm package + Fixes in v3.0 (vs v2.x): - nested archive handling (vfs inside vfs) works now - find & grep with spaces in file name - wide chars file names support (f.e. Eastern languages) => lfm -w - sort by size after show dirs size - move_file: not overwritten files in destination are not deleted Of course, all comments, suggestions, etc. are welcome. Best regards, I?igo Serna From joshuastar at iprimus.com.au Fri Oct 23 17:38:01 2015 From: joshuastar at iprimus.com.au (Joshua Star) Date: Sat, 24 Oct 2015 08:38:01 +1100 Subject: Python 32 bit error Message-ID: <4D4E52FCF36646AC86D865A0BA0F436A@ASUSEeePCJoshua> I am running a 32 bit computer, (Windows XP) and when I finish with the installer program, I try to run either of the two executable files that are put on my computer and they both come up with the message "python.exe is not a valid Win32 application" Also, in the installer program, some of the buttons are invisible. >From Joshua. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pulivarthivijay at gmail.com Sat Oct 24 15:00:50 2015 From: pulivarthivijay at gmail.com (Vijay kumar) Date: Sat, 24 Oct 2015 14:00:50 -0500 Subject: Error while launching python idle. Message-ID: Hi, I recently installed python 2.7 on my windows 10 laptop. When i launch python by clicking the python idle the following error appears even before i do anything. Could you please send support for this issue. I have attached a screenshot of the error. I hope to see a response as soon as possible. Thanking you, Regards, Vijay Kumar Pulivarthi -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot (10).png Type: image/png Size: 222686 bytes Desc: not available URL: From ganesh1pal at gmail.com Sun Oct 25 02:05:47 2015 From: ganesh1pal at gmail.com (Ganesh Pal) Date: Sun, 25 Oct 2015 11:35:47 +0530 Subject: Ignore stderr and use return code Message-ID: Hi Teamm In the below code, we found that the command i.e cmd = "mount /filesystem1" succeeded. But the test failed due to the weaker stderr def mount_me(): cmd = "mount /filesystem1" proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = proc.communicate() if err != "": logging.error("Can't run %s got %s!" % (cmd, err)) return False Verification: >> print err 10/25/2015 12:10:28 PM ERROR:Can't run mount /filesystem1 got : mount_err: Reading GUID from 1213: No such file or directory #df -kh Filesystem Size Used Avail Use% Mounted on Filesystem 38G 5.5G 30G 16% /filesystem1 - To handle this case, Iam planning to use return code and modify the above code as below ( Any other suggestions please let me know) def mount_me(): cmd = ("mount /filesystem1") out, err, ret = run(cmd, timeout=60) # run is the wrapper, returns (stdout, stderr, returncode) if ret != 0: # zero means succeeded logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) return False - Do I need to add more check to ensure the mount actually succeeds, may be a function? if ret != 0 and check_df_output(): logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) Iam using python 2.7 on Linux Regards, Ganesh From ben+python at benfinney.id.au Sun Oct 25 18:10:53 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 26 Oct 2015 09:10:53 +1100 Subject: Please post =?utf-8?B?4oCcdGV4dC9wbGFpbuKAnQ==?= message body (was: Best way to do background calculations?) References: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> Message-ID: <85d1w2oaz6.fsf@benfinney.id.au> Israel Brewster writes: [no text] Please ensure your email message body is ?text/plain? (and preferably not HTML) when posting to unfamiliar recipients ? which is always, on a public forum like this. -- \ ?Pinky, are you pondering what I'm pondering?? ?Umm, I think | `\ so, Brain, but three men in a tub? Ooh, that's unsanitary!? | _o__) ?_Pinky and The Brain_ | Ben Finney From ben+python at benfinney.id.au Sun Oct 25 19:23:47 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 26 Oct 2015 10:23:47 +1100 Subject: OT snake_case References: <562A6611.3000303@mrabarnett.plus.com> Message-ID: <854mheo7lo.fsf@benfinney.id.au> MRAB writes: > I just discovered today that writing names in lowercase with > underscores is sometimes called "snake case". > > Seems kind of apt for Python! :-) Cute! > Apparently, it was coined in the Ruby community... Do you have references for tracing the origin of that term? -- \ ?You can be a theist, and you can be a skeptic. But if you're | `\ both, you're not very good at one of them.? ?Dave Silverman, | _o__) 2011-11-19 | Ben Finney From breamoreboy at yahoo.co.uk Sun Oct 25 19:43:02 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 25 Oct 2015 23:43:02 +0000 Subject: OT snake_case In-Reply-To: <562A6611.3000303@mrabarnett.plus.com> References: <562A6611.3000303@mrabarnett.plus.com> Message-ID: On 23/10/2015 17:53, MRAB wrote: > I just discovered today that writing names in lowercase with > underscores is sometimes called "snake case". > > Seems kind of apt for Python! :-) > > Apparently, it was coined in the Ruby community... So when I get around to forking Python to produce 2.8 the name will have to be Camel :) Or is that already taken? -- 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 Sun Oct 25 20:05:08 2015 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 26 Oct 2015 00:05:08 +0000 Subject: Best way to do background calculations? In-Reply-To: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> References: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> Message-ID: <562D6E34.90909@mrabarnett.plus.com> On 2015-10-23 17:35, Israel Brewster wrote: > tl;dr: I've been using the multiprocessing module to run some > calculations in the background of my CherryPy web app, but apparently > this process sometimes gets stuck, causing problems with open sockets > piling up and blocking the app. Is there a better way? > > The (rather wordy) details: > > I have a moderately busy web app written in python using the CherryPy > framework (CherryPy v 3.8.0 with ws4py v 0.3.4 and Python 2.7.6) . One > of the primary purposes of this web app is to track user-entered flight > logs, and keep a running tally of hours/cycles/landings for each > aircraft. To that end, whenever a user enters or modifies a log, I > "recalculate" the totals for that aircraft, and update all records with > the new totals. There are probably ways to optimize this process, but so > far I haven't seen a need to spend the time. > > Ideally, this recalculation process would happen in the background. > There is no need for the user to wait around while the system crunches > numbers - they should be able to move on with entering another log or > whatever else they need to do. To that end, I implemented the call to > the recalc function using the multiprocessing module, so it could start > in the background and the main process move on. > > Lately, though, I've been running into a problem where, when looking at > the process list on my server (Mac OS X 10.10.5), I'll see two or more > "copies" of my server process running - one master and one or more child > processes. As the above described process is the only place I am using > the multiprocessing module, I am making the assumption that this is what > these additional processes are. If they were only there for a few > minutes I would think this is normal, and it wouldn't be a problem. > > However, what I am seeing is that from time to time (once or twice every > couple of days) these additional processes will get "stuck", and when > that happens sockets opened by the web app don't get properly closed and > start piling up. Looking at a list of open sockets on the server when I > have one of these "hung" processes shows a steadily increasing number of > sockets in a "CLOSE_WAIT" state (normally I see none in that state). > Killing off the hung process(es) clears out these sockets, but if I > don't catch it quickly enough these sockets can build up to the point > that I am unable to open any more, and the server starts rejecting > connections. > > I'm told this happens because the process retains a reference to all > open files/sockets from the parent process, thus preventing the sockets > from closing until the process terminates. Regardless of the reason, it > can cause a loss of service if I don't catch it quickly enough. As such, > I'm wondering if there is a better way. Should I be looking at using the > threading library rather than the multiprocessing library? My > understanding is that the GIL would prevent that approach from being of > any real benefit for a calculation intensive type task, but maybe since > the rest of the application is CherryPy threads, it would still work > well?. Or perhaps there is a way to not give the child process any > references to the parent's files/sockets - although that may not help > with the process hanging? Maybe there is a way to "monitor" the process, > and automatically kill it if it stops responding? Or am I totally > barking up the wrong tree here? > It sounds like the multiprocessing module is forking the new process, which inherits the handles. Python 3.4 added the ability to spawn the new process, which won't inherit the handles. It's unfortunate that you're using Python 2.7.6! Could you start the background process early, before any of those sockets have been opened, and then communicate with it via queues? From montana.burr at gmail.com Sun Oct 25 20:17:28 2015 From: montana.burr at gmail.com (Montana Burr) Date: Sun, 25 Oct 2015 17:17:28 -0700 Subject: Detection of a specific sound Message-ID: I'm looking for a library that will allow Python to listen for the shriek of a smoke alarm. Once it detects this shriek, it is to notify someone. Ideally, specificity can be adjusted for the user's environment. For example, I expect to need moderate specificity as I live in a quiet neighborhood, but an apartment dweller might need more. I'm thinking of recording a smoke alarm and having the program try to find the recorded sound in the stream from the microphone. Any help is greatly appreciated! -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Sun Oct 25 22:03:16 2015 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 26 Oct 2015 02:03:16 +0000 Subject: Detection of a specific sound In-Reply-To: References: Message-ID: <562D89E4.7020207@mrabarnett.plus.com> On 2015-10-26 00:17, Montana Burr wrote: > I'm looking for a library that will allow Python to listen for the > shriek of a smoke alarm. Once it detects this shriek, it is to notify > someone. Ideally, specificity can be adjusted for the user's > environment. For example, I expect to need moderate specificity as I > live in a quiet neighborhood, but an apartment dweller might need more. > > I'm thinking of recording a smoke alarm and having the program try to > find the recorded sound in the stream from the microphone. > > Any help is greatly appreciated! > Here are a couple of questions from stackoverflow that might be of help: Python frequency detection http://stackoverflow.com/questions/2648151/python-frequency-detection Recognising tone of the audio http://stackoverflow.com/questions/1797631/recognising-tone-of-the-audio From joel.goldstick at gmail.com Sun Oct 25 22:19:54 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Sun, 25 Oct 2015 22:19:54 -0400 Subject: OT snake_case In-Reply-To: <562A6611.3000303@mrabarnett.plus.com> References: <562A6611.3000303@mrabarnett.plus.com> Message-ID: On Fri, Oct 23, 2015 at 12:53 PM, MRAB wrote: > I just discovered today that writing names in lowercase with > underscores is sometimes called "snake case". > > Seems kind of apt for Python! :-) > > Apparently, it was coined in the Ruby community... > -- > https://mail.python.org/mailman/listinfo/python-list > I just got this message delivered at 10 pm Sunday. But it is an interesting piece of info. -- Joel Goldstick http://joelgoldstick.com/stats/birthdays -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben+python at benfinney.id.au Sun Oct 25 22:41:24 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 26 Oct 2015 13:41:24 +1100 Subject: Ignore stderr and use return code References: Message-ID: <85y4eqmjvv.fsf@benfinney.id.au> Ganesh Pal writes: > In the below code, we found that the command i.e cmd = "mount > /filesystem1" succeeded. But the test failed due to the weaker stderr I don't know what you mean by stderr being ?weaker?. > def mount_me(): > cmd = "mount /filesystem1" > proc = subprocess.Popen(shlex.split(cmd), > stdout=subprocess.PIPE, stderr=subprocess.PIPE) > out, err = proc.communicate() > if err != "": > logging.error("Can't run %s got %s!" % (cmd, err)) > return False The test ?if err != ""? implies you are checking *only* whether the value is an empty string. It might be clearer if you write ?if err?. The error message implies the process *could not* run, but that's not the case. If that line is reached, the process did run to completion. The presence of output on stderr does not imply the process failed. If instead you want to check whether the process failed, check its exit status. The ?exit status? of a process, indicating success or failure, is ?returned? by the subprocess back to Python and is available as ?Popen.returncode?:: EXIT_STATUS_SUCCESS = 0 if proc.returncode != EXIT_STATUS_SUCCESS: logging.error( "Subprocess {cmd} failed with code {code:d}," " error output {err}".format( cmd=cmd, code=proc.returncode, err=err)) > Verification: I don't quite understand the claim of ?weaker?, so I don't know what is verified here. > - To handle this case, Iam planning to use return code and modify the > above code as below ( Any other suggestions please let me know) You may also want to think about whether raising an exception is appropriate (rather than just returning False). > - Do I need to add more check to ensure the mount actually succeeds, > may be a function? I'd suggest relying on the exit status from the command, unless you have good evidence it is unreliable. -- \ ?When people believe that they have absolute knowledge, with no | `\ test in reality, this [the Auschwitz crematorium] is how they | _o__) behave.? ?Jacob Bronowski, _The Ascent of Man_, 1973 | Ben Finney From rosuav at gmail.com Sun Oct 25 22:48:23 2015 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 26 Oct 2015 13:48:23 +1100 Subject: Best way to do background calculations? In-Reply-To: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> References: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> Message-ID: On Sat, Oct 24, 2015 at 3:35 AM, Israel Brewster wrote: > > Ideally, this recalculation process would happen in the background. There is > no need for the user to wait around while the system crunches numbers - they > should be able to move on with entering another log or whatever else they > need to do. To that end, I implemented the call to the recalc function using > the multiprocessing module, so it could start in the background and the main > process move on. One way to get around this would be to separate the processes completely, and simply alert the other process (maybe via a socket) to ask it to do the recalculation. That way, the background process would never have any of the main process's sockets, and can't affect them in any way. ChrisA From python at mrabarnett.plus.com Sun Oct 25 23:14:17 2015 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 26 Oct 2015 03:14:17 +0000 Subject: OT snake_case In-Reply-To: <854mheo7lo.fsf@benfinney.id.au> References: <562A6611.3000303@mrabarnett.plus.com> <854mheo7lo.fsf@benfinney.id.au> Message-ID: <562D9A89.3050704@mrabarnett.plus.com> On 2015-10-25 23:23, Ben Finney wrote: > MRAB writes: > >> I just discovered today that writing names in lowercase with >> underscores is sometimes called "snake case". >> >> Seems kind of apt for Python! :-) > > Cute! > >> Apparently, it was coined in the Ruby community... > > Do you have references for tracing the origin of that term? > https://groups.google.com/forum/#!msg/comp.lang.ruby/ra5WDzNGwGU/oe_mnvRVclUJ From cs at zip.com.au Mon Oct 26 00:34:55 2015 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 26 Oct 2015 15:34:55 +1100 Subject: Ignore stderr and use return code In-Reply-To: References: Message-ID: <20151026043455.GA57347@cskk.homeip.net> On 25Oct2015 11:35, Ganesh Pal wrote: >In the below code, we found that the command i.e cmd = "mount >/filesystem1" succeeded. But the test failed due to the weaker stderr [...] > out, err = proc.communicate() > if err != "": Checking stderr is never the correct way to do this. [...] > - To handle this case, Iam planning to use return code and modify the >above code as below ( Any other suggestions please let me know) > def mount_me(): > cmd = ("mount /filesystem1") > out, err, ret = run(cmd, timeout=60) # run is the wrapper, >returns (stdout, stderr, returncode) > if ret != 0: # zero means succeeded This is the correct approach. > logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) > return False >- Do I need to add more check to ensure the mount actually succeeds, >may be a function? No. Mount should have a zero status if it succeeds and anon-zero exit status if it fails. There is no grey area here. > if ret != 0 and check_df_output(): > logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) Rather than looking at the stdout or stderr of df, consider calling os.statvfs() directly from Python: https://docs.python.org/3/library/os.html#os.statvfs > Iam using python 2.7 on Linux It is the same in Python 2. Cheers, Cameron Simpson From robin at reportlab.com Mon Oct 26 08:33:43 2015 From: robin at reportlab.com (Robin Becker) Date: Mon, 26 Oct 2015 12:33:43 +0000 Subject: how to get python socket to use a specific interface In-Reply-To: <201510230737.15259.gheskett@wdtv.com> References: <5629F7ED.6060606@chamonix.reportlab.co.uk> <201510230737.15259.gheskett@wdtv.com> Message-ID: <562E1DA7.9060903@chamonix.reportlab.co.uk> ............. >> device? -- >> Robin Becker > > Using eth0:0 is normally a method to setup eth0 to respond to a 2nd > IPV4/IPV6 address. Have you done the ifconfig steps to enable that? If > its been done, you will see it's 2nd address in an ifconfig query. Man > pages are wunnerful things. yes I have done that and the address is responding, problem is it has been email blacklisted > $ ifconfig > eth0 Link encap:Ethernet HWaddr 00:.......4 GB) > Interrupt:16 > > eth0:0 Link encap:Ethernet HWa....... > > lo Link encap:Local Loopback ...... The problem is as stated in the original email; when I try to execute the commands to bind to that device I get an error eg ># ~rptlab/tmp/proxy/bin/python > Python 2.7.5 (default, Aug 20 2013, 15:27:38) > [GCC 4.6.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> from socket import socket, SOL_SOCKET >>>> BIND_DEVICE='eth0:0' >>>> sock = socket() >>>> sock.settimeout(10) >>>> sock.setsockopt(SOL_SOCKET, 25, BIND_DEVICE) > Traceback (most recent call last): > File "", line 1, in > File "/home/rptlab/LOCAL/lib/python2.7/socket.py", line 224, in meth > return getattr(self._sock,name)(*args) > socket.error: [Errno 19] No such device >>>> so I guess I'm not using the right name for the device. I tried a leter python 3.5 in case my python 2.7 is too old, but that also fails. -- Robin Becker From __peter__ at web.de Mon Oct 26 09:55:46 2015 From: __peter__ at web.de (Peter Otten) Date: Mon, 26 Oct 2015 14:55:46 +0100 Subject: UNABLE TO GET IDLE TO RUN References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> Message-ID: Terry Reedy wrote: > On 10/23/2015 5:42 AM, Peter Otten wrote: >> Laura Creighton wrote: >> >>> In a message of Fri, 23 Oct 2015 00:19:42 -0400, Terry Reedy writes: >>>> On 10/21/2015 11:24 AM, Terry Alexander via Python-list wrote: >>>> >>>>> I have tried installing both Python 2.7 and 3.5, and in both cases I >>>>> cannot get IDLE to work. I received the following message both times: >>>> >>>> What OS? Windows? which version? How did you start IDLE? Start menu >>>> icon? Command line? >>>> >>>>> IDLE?s subprocess didn?t make connection.Either IDLE can?t start a >>>>> subprocess or personal firewall software is blocking the connection. >>>>> >>>>> I am running Norton, and disabled it, but still IDLE will not run. Any >>>>> suggestions? >>>> >>>> Don't shout with ALL CAPS in the subject line. It usually indicates >>>> spam. I already know that this problem is very frustrating. >>>> >>>> Firewalls are seldom the problems anymore. I occasionally saw this on >>>> Win 7 when restarting, but never on startup, and never more than once >>>> or twice in a session. >>>> >>>> What's left is misconfiguration of your network interface that prevents >>>> a loopback connection. There might be answers on Stackoverflow that >>>> would help, depending on your OS. >>>> >>>> In the meanwhile, you can start IDLE with the -n option. Either use a >>>> command line or create an 'IDLE -n' icon. Again, details depend on >>>> exact OS. >>>> Terry Jan Reedy >>> >>> You can also get this message if you run idle in directory where you >>> have your own python file whose name shadows something in the >>> standard library (that idle is interested in). I think it was >>> a file named 'string.py' that did this to a student of mine a >>> few years ago. >>> Laura > > I can imagine that a bad socket module might have this effect. With > verification that a user file could have this effect, I would augment > the message. > >> I tried it out: >> >> $ mkdir test >> $ cd test >> $ touch string.py >> $ idle3 >> Traceback (most recent call last): >> File "", line 1, in >> File "/usr/lib/python3.4/idlelib/run.py", line 12, in >> from idlelib import CallTips >> File "/usr/lib/python3.4/idlelib/CallTips.py", line 16, in >> from idlelib.HyperParser import HyperParser >> File "/usr/lib/python3.4/idlelib/HyperParser.py", line 14, in >> _ASCII_ID_CHARS = frozenset(string.ascii_letters + string.digits + >> "_") >> AttributeError: 'module' object has no attribute 'ascii_letters' >> >> Then idle shows the message and quits after you hit OK. >> >> Is there a bug report? > > No. Quitting because a stdlib module cannot be imported (or corrupted) > is not a bug. AttributeError is a typical symptom. A user file called > random.py is probably more common. The "bug" or misfeature is that idle automatically adds the working directory to sys.path. Ideally the editor should see the unaltered path while scripts started from within idle might be allowed to import from the working directory. From gandalf at shopzeus.com Mon Oct 26 11:11:46 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Mon, 26 Oct 2015 16:11:46 +0100 Subject: ANN: clefstorm Message-ID: <562E42B2.4020809@shopzeus.com> ClefSform provides a simple module that can be used from a Tornado server to authenticate users with Clef (www.getclef.com) two-factor authentication. This is a pre-release, it can only be used with tornado version 4.3. That version is still beta, but that is the only version that supports async def statements with tornado's ioloop. The PyPi package contains the module for the API only. The repository contains an example web server that can be used to understand how Clef single sign out works. PyPi: https://pypi.python.org/pypi/clefstorm Documentation: http://pythonhosted.org/clefstorm/ Repository: https://bitbucket.org/nagylzs/clefstorm Cheers, Laszlo From gandalf at shopzeus.com Mon Oct 26 11:17:01 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Mon, 26 Oct 2015 16:17:01 +0100 Subject: ANN: orcastorm Message-ID: <562E43ED.5040909@shopzeus.com> OrcaStorm provides a simple module that can be used from a Tornado server to authenticate users with SaasPass (www.saaspass.com) two-factor authentication. This is a pre-release, it can only be used with tornado version 4.3. That version is still beta, but that is the only version that supports async def statements with tornado's ioloop. The PyPi package contains the module for the API only. The repository contains an example web server that can be used to understand how SaasPass reverse ajax callback works for login pages. PyPi: https://pypi.python.org/pypi/orcastorm Documentation: http://pythonhosted.org/orcastorm/ Repository: https://bitbucket.org/nagylzs/orcastorm Orcastorm supports authentication by: * reading a barcode * entering an OTP code * instant login (single sign on) But it does not support remote logouts. In contrast, Clef does have support for remote logouts, but it cannot authenticate with OTP codes, you cannot be logged in with different accounts at the same time by default, and the only method for logging in (AFAIK) is with oauth2. Cheers, Laszlo -------------- next part -------------- An HTML attachment was scrubbed... URL: From israel at ravnalaska.net Mon Oct 26 12:55:33 2015 From: israel at ravnalaska.net (Israel Brewster) Date: Mon, 26 Oct 2015 08:55:33 -0800 Subject: Best way to do background calculations? In-Reply-To: <562D6E34.90909@mrabarnett.plus.com> References: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> <562D6E34.90909@mrabarnett.plus.com> Message-ID: On Oct 25, 2015, at 4:05 PM, MRAB wrote: > > On 2015-10-23 17:35, Israel Brewster wrote: >> tl;dr: I've been using the multiprocessing module to run some >> calculations in the background of my CherryPy web app, but apparently >> this process sometimes gets stuck, causing problems with open sockets >> piling up and blocking the app. Is there a better way? >> >> The (rather wordy) details: >> >> I have a moderately busy web app written in python using the CherryPy >> framework (CherryPy v 3.8.0 with ws4py v 0.3.4 and Python 2.7.6) . One >> of the primary purposes of this web app is to track user-entered flight >> logs, and keep a running tally of hours/cycles/landings for each >> aircraft. To that end, whenever a user enters or modifies a log, I >> "recalculate" the totals for that aircraft, and update all records with >> the new totals. There are probably ways to optimize this process, but so >> far I haven't seen a need to spend the time. >> >> Ideally, this recalculation process would happen in the background. >> There is no need for the user to wait around while the system crunches >> numbers - they should be able to move on with entering another log or >> whatever else they need to do. To that end, I implemented the call to >> the recalc function using the multiprocessing module, so it could start >> in the background and the main process move on. >> >> Lately, though, I've been running into a problem where, when looking at >> the process list on my server (Mac OS X 10.10.5), I'll see two or more >> "copies" of my server process running - one master and one or more child >> processes. As the above described process is the only place I am using >> the multiprocessing module, I am making the assumption that this is what >> these additional processes are. If they were only there for a few >> minutes I would think this is normal, and it wouldn't be a problem. >> >> However, what I am seeing is that from time to time (once or twice every >> couple of days) these additional processes will get "stuck", and when >> that happens sockets opened by the web app don't get properly closed and >> start piling up. Looking at a list of open sockets on the server when I >> have one of these "hung" processes shows a steadily increasing number of >> sockets in a "CLOSE_WAIT" state (normally I see none in that state). >> Killing off the hung process(es) clears out these sockets, but if I >> don't catch it quickly enough these sockets can build up to the point >> that I am unable to open any more, and the server starts rejecting >> connections. >> >> I'm told this happens because the process retains a reference to all >> open files/sockets from the parent process, thus preventing the sockets >> from closing until the process terminates. Regardless of the reason, it >> can cause a loss of service if I don't catch it quickly enough. As such, >> I'm wondering if there is a better way. Should I be looking at using the >> threading library rather than the multiprocessing library? My >> understanding is that the GIL would prevent that approach from being of >> any real benefit for a calculation intensive type task, but maybe since >> the rest of the application is CherryPy threads, it would still work >> well?. Or perhaps there is a way to not give the child process any >> references to the parent's files/sockets - although that may not help >> with the process hanging? Maybe there is a way to "monitor" the process, >> and automatically kill it if it stops responding? Or am I totally >> barking up the wrong tree here? >> > It sounds like the multiprocessing module is forking the new process, > which inherits the handles. > > Python 3.4 added the ability to spawn the new process, which won't inherit the handles. Well, that might be a reason to look at moving to 3 then. It's been on my to-do list :-) > > It's unfortunate that you're using Python 2.7.6! > > Could you start the background process early, before any of those > sockets have been opened, and then communicate with it via queues? Possibly. Simply have the process always running, and tell it to kick off calculations as needed via queues. It's worth investigating for sure. > > -- > https://mail.python.org/mailman/listinfo/python-list From israel at ravnalaska.net Mon Oct 26 12:58:07 2015 From: israel at ravnalaska.net (Israel Brewster) Date: Mon, 26 Oct 2015 08:58:07 -0800 Subject: Best way to do background calculations? In-Reply-To: References: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> Message-ID: <67E2B1B9-5B04-42FE-859E-DE47321857B3@ravnalaska.net> On Oct 25, 2015, at 3:40 PM, Dennis Lee Bieber wrote: > > On Fri, 23 Oct 2015 08:35:06 -0800, Israel Brewster > declaimed the following: > >> tl;dr: I've been using the multiprocessing module to run some calculations in the background of my CherryPy web app, but apparently this process sometimes gets stuck, causing problems with open sockets piling up and blocking the app. Is there a better way? >> >> The (rather wordy) details: >> > The less wordy first impression... > >> I have a moderately busy web app written in python using the CherryPy framework (CherryPy v 3.8.0 with ws4py v 0.3.4 and Python 2.7.6) . One of the primary purposes of this web app is to track user-entered flight logs, and keep a running tally of hours/cycles/landings for each aircraft. To that end, whenever a user enters or modifies a log, I "recalculate" the totals for that aircraft, and update all records with the new totals. There are probably ways to optimize this process, but so far I haven't seen a need to spend the time. >> > Off-hand -- this sounds like something that should be in a database... > Unless your calculations are really nasty, rather than just aggregates, a > database engine should be able to apply them in SQL queries or stored > procedures. Sounds like a potentially valid approach. Would require some significant re-tooling, but could work. I'll look into it. ----------------------------------------------- Israel Brewster Systems Analyst II Ravn Alaska 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > -- > https://mail.python.org/mailman/listinfo/python-list From israel at ravnalaska.net Mon Oct 26 13:01:29 2015 From: israel at ravnalaska.net (Israel Brewster) Date: Mon, 26 Oct 2015 09:01:29 -0800 Subject: Best way to do background calculations? In-Reply-To: References: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> Message-ID: <65B16802-7A2B-46E9-9747-82F798E0B7E5@ravnalaska.net> On Oct 25, 2015, at 6:48 PM, Chris Angelico wrote: > > On Sat, Oct 24, 2015 at 3:35 AM, Israel Brewster wrote: >> >> Ideally, this recalculation process would happen in the background. There is >> no need for the user to wait around while the system crunches numbers - they >> should be able to move on with entering another log or whatever else they >> need to do. To that end, I implemented the call to the recalc function using >> the multiprocessing module, so it could start in the background and the main >> process move on. > > One way to get around this would be to separate the processes > completely, and simply alert the other process (maybe via a socket) to > ask it to do the recalculation. That way, the background process would > never have any of the main process's sockets, and can't affect them in > any way. Sounds similar to MRAB's suggestion of starting the process before any sockets have been opened. Certainly worth investigating, and I think it should be doable. Thanks! ----------------------------------------------- Israel Brewster Systems Analyst II Ravn Alaska 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Mon Oct 26 13:07:05 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 27 Oct 2015 04:07:05 +1100 Subject: Best way to do background calculations? In-Reply-To: <65B16802-7A2B-46E9-9747-82F798E0B7E5@ravnalaska.net> References: <737CA123-3241-4A79-8E99-6BDDCBEEFFD9@ravnalaska.net> <65B16802-7A2B-46E9-9747-82F798E0B7E5@ravnalaska.net> Message-ID: On Tue, Oct 27, 2015 at 4:01 AM, Israel Brewster wrote: > Sounds similar to MRAB's suggestion of starting the process before any sockets have been opened. Certainly worth investigating, and I think it should be doable. Thanks! Yep, either would work. My suggestion would be to not fork off from your main web server process _at all_, and have your background process managed some other way (eg a systemd service or Upstart job), but forking earlier will have a similar effect. ChrisA From hinerfeldrichard at yahoo.com Mon Oct 26 13:14:50 2015 From: hinerfeldrichard at yahoo.com (Richard Hinerfeld) Date: Mon, 26 Oct 2015 10:14:50 -0700 Subject: Fw: Python 3.5.0 (32-bit) won't install to Windows XP Message-ID: <1445879690.63365.YahooMailBasic@web161305.mail.bf1.yahoo.com> --- On Fri, 10/23/15, Richard Hinerfeld wrote: > From: Richard Hinerfeld > Subject: Python 3.5.0 (32-bit) won't install to Windows XP > To: "python-list at python.org" > Date: Friday, October 23, 2015, 9:10 PM > I am > sending you the log with all the errors. > -------------- next part -------------- A non-text attachment was scrubbed... Name: Python 3.5.0 (32-bit)_20151023210511.log Type: application/octet-stream Size: 64972 bytes Desc: not available URL: From python at mrabarnett.plus.com Mon Oct 26 14:21:12 2015 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 26 Oct 2015 18:21:12 +0000 Subject: OT snake_case In-Reply-To: References: <562A6611.3000303@mrabarnett.plus.com> Message-ID: <562E6F18.1000606@mrabarnett.plus.com> On 2015-10-25 23:43, Mark Lawrence wrote: > On 23/10/2015 17:53, MRAB wrote: >> I just discovered today that writing names in lowercase with >> underscores is sometimes called "snake case". >> >> Seems kind of apt for Python! :-) >> >> Apparently, it was coined in the Ruby community... > > So when I get around to forking Python to produce 2.8 the name will have > to be Camel :) Or is that already taken? > There's Caml, of which OCaml is the main implementation, so it might be confusing. Also, a camel (dromedary) is used on the cover of the Perl book published by O'Reilly. From cs at zip.com.au Mon Oct 26 18:29:53 2015 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 27 Oct 2015 09:29:53 +1100 Subject: how to get python socket to use a specific interface In-Reply-To: <562E1DA7.9060903@chamonix.reportlab.co.uk> References: <562E1DA7.9060903@chamonix.reportlab.co.uk> Message-ID: <20151026222953.GA35568@cskk.homeip.net> On 26Oct2015 12:33, Robin Becker wrote: >............. >>>device? -- >>>Robin Becker >> >>Using eth0:0 is normally a method to setup eth0 to respond to a 2nd >>IPV4/IPV6 address. Have you done the ifconfig steps to enable that? If >>its been done, you will see it's 2nd address in an ifconfig query. Man >>pages are wunnerful things. >yes I have done that and the address is responding, problem is it has >been email blacklisted > >>$ ifconfig >>eth0 Link encap:Ethernet HWaddr 00:.......4 GB) >> Interrupt:16 >> >>eth0:0 Link encap:Ethernet HWa....... Do you need to bind to the device itself? Using the correct IP address should normally be sufficient. The system you're talking to won't know anything about the device, only the address. Try skipping the device binding step. Cheers, Cameron Simpson From tjreedy at udel.edu Mon Oct 26 18:55:21 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 26 Oct 2015 18:55:21 -0400 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> Message-ID: On 10/26/2015 9:55 AM, Peter Otten wrote: > The "bug" or misfeature is that idle automatically adds the working > directory to sys.path. I am not sure what you mean by 'working directory' here. When one runs a program with 'python somepath/file.py', python prepends somepath to sys.path. > Ideally the editor should see the unaltered path I don't know what you mean here. The editor does not look as sys.path. > while scripts started from within idle might be allowed to import from the > working directory. Programs run from the editor are intended to run as much as possible the same as if run from a command line. To do this, IDLE must prepend somepath to sys.path the same as python itself does. As a result, if somepath/file.py contains import sys print(sys.path) then when run, sys.path starts with os.abspath(somepath). -- Terry Jan Reedy From tjreedy at udel.edu Mon Oct 26 19:28:48 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 26 Oct 2015 19:28:48 -0400 Subject: Error while launching python idle. In-Reply-To: References: Message-ID: On 10/24/2015 3:00 PM, Vijay kumar wrote: > Hi, > > I recently installed python 2.7 on my windows 10 laptop. When i launch > python by clicking the python idle the following error appears In attached image. You should also type the text so it appears in responses. > even before i do anything. Just click OK and continue. This should really be a warning, not an error. You will see it once each session, but only once. The recent files list will not be saved for when you restart IDLE the next time. It is up to you to determine why it cannot be written in your home directory and whether you can change permissions. -- Terry Jan Reedy From luyijie at whty.com.cn Mon Oct 26 21:18:21 2015 From: luyijie at whty.com.cn (luyijie) Date: Tue, 27 Oct 2015 09:18:21 +0800 Subject: Python Version 3.5 required which was not found in the registry Message-ID: <201510270918214049614@whty.com.cn> python-list? when i install pop "Python Version 3.5 required which was not found in the registry" I do not know how to do... Best regards ?????????????? ??????? ??? ?? 13437109862 ?? ???????????????????????18??B?5? ???430223 ---------------------------------------------------------- Disclaimer: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. If you have received this email in error please notify WHTY. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of WHTY. Finally, the recipient should check this email and any attachments for the presence of viruses. WHTY accepts no liability for any damage caused by any virus transmitted by this email -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Oct 26 22:31:38 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 27 Oct 2015 13:31:38 +1100 Subject: Ignore stderr and use return code In-Reply-To: <20151026043455.GA57347@cskk.homeip.net> References: <20151026043455.GA57347@cskk.homeip.net> Message-ID: On Mon, Oct 26, 2015 at 3:34 PM, Cameron Simpson wrote: > No. Mount should have a zero status if it succeeds and anon-zero exit status > if it fails. There is no grey area here. This is the general case. For specific programs, you can often check their man pages; for the mount(8) on my system, it's bitwise: 1 incorrect invocation or permissions 2 system error (out of memory, cannot fork, no more loop devices) 4 internal mount bug 8 user interrupt 16 problems writing or locking /etc/mtab 32 mount failure 64 some mount succeeded It's also theoretically possible to get a return value of 127, indicating that the 'mount' command was itself not found. That might not seem likely, but if someone has a restricted $PATH, you might run into that. Likewise 126 might indicate that "mount" exists but is non-executable - again, unlikely in the case of mount, but possible. In any case, you can generally depend on a non-zero exit status indicating failure and zero being reserved for success. ChrisA From rosuav at gmail.com Tue Oct 27 00:14:30 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 27 Oct 2015 15:14:30 +1100 Subject: Python 32 bit error In-Reply-To: <4D4E52FCF36646AC86D865A0BA0F436A@ASUSEeePCJoshua> References: <4D4E52FCF36646AC86D865A0BA0F436A@ASUSEeePCJoshua> Message-ID: On Sat, Oct 24, 2015 at 8:38 AM, Joshua Star wrote: > I am running a 32 bit computer, (Windows XP) and when I finish with the > installer program, I try to run either of the two executable files that are > put on my computer and they both come up with the message "python.exe is not > a valid Win32 application" > > Also, in the installer program, some of the buttons are invisible. Is this the installer for Python 3.5? It doesn't support XP. You'll need to get a newer and better operating system (Windows 7, Ubuntu Linux, etc), or use Python 3.4 instead. ChrisA From kb at sparklight.com Tue Oct 27 00:17:35 2015 From: kb at sparklight.com (Ken Brooks) Date: Mon, 26 Oct 2015 21:17:35 -0700 Subject: Building a python extension on Windows Message-ID: <30AB5F71DF2C40A495DF74729E3EEECD@KenPC> I checked out a copy of svn.python.org/projects/stackless/trunk because it seems to have a good sample project (PC/example_nt) for building a Python extension on Windows. That directory has a Microsoft Visual C++ solution file which can be updated to my Visual C++ version (8, of 2005). First I tried cd-ing to that directory, as they recommend, and saying "python setup.py install". The result? A very common complaint, "Unable to find vcvarsall.bat". A search using Windows would suggest that that file doesn't exist anywhere on my system. So I followed the VC++ build instructions, and copied the example_nt directory up one level in the tree before building it. But when I actually try to build the solution it wants to look in the PCBuild directory for python27.lib, which isn't there. Nor can I find that library anywhere else. What gives? Is this project somehow hopelessly out of date? And more to the point, can someone direct me to a nice, fresh example project that will build a little Python extension on Windows? Thanks, Ken ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Oct 27 02:00:47 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 27 Oct 2015 17:00:47 +1100 Subject: Detection of a specific sound In-Reply-To: References: Message-ID: On Mon, Oct 26, 2015 at 1:54 PM, Dennis Lee Bieber wrote: > One difficulty -- there is no standard "smoke alarm" sound... While > they are using piezo-electric buzzers, the control processor may cycle the > buzzer in different patterns from maker to maker, or slightly different > pitches. Maybe not, but since most smoke alarms have a simple "Test" button, it should be possible to have the program record a sample of the alarm it's listening for. That would make detection easier. I personally have no idea how it would work, but in theory, this should be equivalent to voice navigation - use the same kind of code that detects spoken commands, just with a different "language". ChrisA From mail at johnohagan.com Tue Oct 27 02:43:08 2015 From: mail at johnohagan.com (John O'Hagan) Date: Tue, 27 Oct 2015 17:43:08 +1100 Subject: Detection of a specific sound In-Reply-To: References: Message-ID: <20151027174308.1c6d034a@mini.home> On Sun, 25 Oct 2015 17:17:28 -0700 Montana Burr wrote: > I'm looking for a library that will allow Python to listen for the > shriek of a smoke alarm. Once it detects this shriek, it is to notify > someone. Ideally, specificity can be adjusted for the user's > environment. I've used python to detect and record ambient sound by launching the simple command-line program sox (in its guise as "rec") as a python subprocess. I hope someone corrects me, but the few python audio libraries seemed to me to be overkill in terms of coding required and underkill in terms of features. With sox, it's easy to set things like length of recording and a triggering threshold etc.. The latter is good for your use-case because you can set it high enough to only start recording when something is loud enough to be an alarm. Once you have your recording, as others have pointed out, what you do to detect an alarm sound in it will depend on what alarms sound like where you live. > I'm thinking of recording a smoke alarm and having the program try to > find the recorded sound in the stream from the microphone. That kind of matching is IMO unlikely to work. The human ear (or rather the brain's auditory processing) is very good at picking out the same general sound in different contexts. Getting software to do this is hard. I had a quick look at the acoustid module, which uses Shazam-style acoustic fingerprinting. It has a method for measuring the similarity of different recordings, but my little trials weren't promising. A test recording of my ringtone measured as identical to itself (so far so good), but only about 25% identical to another recording of the same ringtone. A recording of me randomly whistling also measured about 25% similar to the ringtones. If your smoke alarms are anything like mine, they have a fixed pitch, volume and pulse, simple machine-friendly properties that are unlikely to happen by accident. You could try the aubio module (not a typo, that's aubio with a "b"). I've never used it and it's python 2 only, but it has pitch, onset time and "beat" detection. You might be able to use it to measure those properties from a sample recording, and then check your monitored recordings to see if they have roughly the same measurements. Regards John From tjreedy at udel.edu Tue Oct 27 03:42:55 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 27 Oct 2015 03:42:55 -0400 Subject: Error while launching python idle. In-Reply-To: References: Message-ID: On 10/26/2015 7:28 PM, Terry Reedy wrote: > On 10/24/2015 3:00 PM, Vijay kumar wrote: >> Hi, >> >> I recently installed python 2.7 on my windows 10 laptop. When i launch >> python by clicking the python idle the following error appears > > In attached image. You should also type the text so it appears in > responses. > >> even before i do anything. > > Just click OK and continue. This should really be a warning, not an I changed the 'error' to a warning and expanded the message a bit, including 'select OK and continue'. > error. You will see it once each session, but only once. The recent > files list will not be saved for when you restart IDLE the next time. > It is up to you to determine why it cannot be written in your home > directory and whether you can change permissions. Before IDLE tries to write to $Home/.idlerc/recent-files.lst it reads it, so it exists. It does this on startup. Something or someone other than IDLE made it read only. -- Terry Jan Reedy From __peter__ at web.de Tue Oct 27 04:15:34 2015 From: __peter__ at web.de (Peter Otten) Date: Tue, 27 Oct 2015 09:15:34 +0100 Subject: UNABLE TO GET IDLE TO RUN References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> Message-ID: Terry Reedy wrote: > On 10/26/2015 9:55 AM, Peter Otten wrote: > >> The "bug" or misfeature is that idle automatically adds the working >> directory to sys.path. > > I am not sure what you mean by 'working directory' here. After $ cd /foo/bar the working directory is /foo/bar > When one runs a > program with 'python somepath/file.py', python prepends somepath to > sys.path. If /foo/bar contains a string.py (for example) module and you run the following sequence $ cd /foo/bar $ python3 /usr/bin/idle3 /foo/bar/string.py will shade string.py from the standard library. The relevant code in idle is https://hg.python.org/cpython/file/tip/Lib/idlelib/PyShell.py#l1522 """ else: dir = os.getcwd() if dir not in sys.path: sys.path.insert(0, dir) """ I think this is a misfeature. >> Ideally the editor should see the unaltered path > > I don't know what you mean here. The editor does not look as sys.path. idle should see the sys.path as it was before inserting os.getcwd(). >> while scripts started from within idle might be allowed to import from >> the working directory. > > Programs run from the editor are intended to run as much as possible the > same as if run from a command line. To do this, IDLE must prepend > somepath to sys.path the same as python itself does. As a result, if > somepath/file.py contains > > import sys > print(sys.path) > > then when run, sys.path starts with os.abspath(somepath). Yes, if inside the shell shown by idle the user types >>> import string this should import /foo/bar/string.py rather than the stdlib version. Different behaviour for "idle the editor" and "idle the shell" is of course only possible if both use distinct processes. I don't know idle's architecture, so I cannot say if that's already the case or if it would require a major rewrite. From robin at reportlab.com Tue Oct 27 06:00:46 2015 From: robin at reportlab.com (Robin Becker) Date: Tue, 27 Oct 2015 10:00:46 +0000 Subject: how to get python socket to use a specific interface In-Reply-To: <20151026222953.GA35568@cskk.homeip.net> References: <562E1DA7.9060903@chamonix.reportlab.co.uk> <20151026222953.GA35568@cskk.homeip.net> Message-ID: <562F4B4E.3040603@chamonix.reportlab.co.uk> On 26/10/2015 22:29, Cameron Simpson wrote: > On 26Oct2015 12:33, Robin Becker wrote: >> ............. ........ >>> $ ifconfig >>> eth0 Link encap:Ethernet HWaddr 00:.......4 GB) >>> Interrupt:16 >>> >>> eth0:0 Link encap:Ethernet HWa....... > > Do you need to bind to the device itself? Using the correct IP address should > normally be sufficient. The system you're talking to won't know anything about > the device, only the address. Try skipping the device binding step. > According to the stackoverflow articles here http://stackoverflow.com/questions/335607/how-do-i-make-an-outgoing-socket-to-a-specific-network-interface http://stackoverflow.com/questions/8437726/can-python-select-what-network-adapter-when-opening-a-socket binding to the local IP seems to be a windows only thing. I have tried just binding to the local IP, but my packets were from the default address (the one connected to eth0). After reading the 8437726 article again I think I may be on the wrong track anyway. > Cheers, > Cameron Simpson -- Robin Becker From tjreedy at udel.edu Tue Oct 27 07:18:42 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 27 Oct 2015 07:18:42 -0400 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> Message-ID: On 10/27/2015 4:15 AM, Peter Otten wrote: > Terry Reedy wrote: >> When one runs a >> program with 'python somepath/file.py', python prepends somepath to >> sys.path. > > If /foo/bar contains a string.py (for example) module and you run the > following sequence > > $ cd /foo/bar > $ python3 /usr/bin/idle3 I am curious what 'import sys; sys.path' prints in interactive mode, for both 'python3' and the above, of whichever *nix you are running. > /foo/bar/string.py will shade string.py from the standard library. Please reread what I wrote. IDLE is imitating Python. This shading the same behavior as if you just typed $ python3. From https://docs.python.org/3/library/sys.html#sys.path "sys.path A list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default. As initialized upon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to search modules in the current directory first. Notice that the script directory is inserted before the entries inserted as a result of PYTHONPATH. " Modules in the current directory shade stdlib modules of the same name. This is a feature for people who want this behavior. It is a problem for people who are caught by it. The most common example here is beginners who write their own random.py, for instance, and then another file with 'import random', expecting to get the stdlib module. This has nothing to do with IDLE. If you do not like this behavior, criticize python, not IDLE. "A program is free to modify this list for its own purposes." IDLE's purpose is to imitate what python does, in both interactive and batch modes. There are bugs relative to this (and I just opened https://bugs.python.org/issue25488), but the bug is not 'imitating python' but the failure to do so. If you find a non-trivial divergence in how code is executed that I am not aware of, I would like to know. > The relevant code in idle is > > https://hg.python.org/cpython/file/tip/Lib/idlelib/PyShell.py#l1522 > """ > else: > dir = os.getcwd() > if dir not in sys.path: > sys.path.insert(0, dir) > """ Nope, not in IDLE's normal mode, in which user code is executed in a separate process. The above is for sys.process in the idle process. I suspect it is a holdover from when Idle ran user code in its own process (which is still does when -n is given on the command line). In the previous line, before 'else', the directory of all files given as args to be edited is added to sys.path. I suspect that this is to enable completions in single process mode, which is deprecated. > I think this is a misfeature. Why do you think it a misfeature for IDLE to execute code the way Python does? -- Terry Jan Reedy From ganesh1pal at gmail.com Tue Oct 27 07:54:28 2015 From: ganesh1pal at gmail.com (Ganesh Pal) Date: Tue, 27 Oct 2015 17:24:28 +0530 Subject: How to make this simple code look better Message-ID: from myPopen import run def configure_network(): """ Prepare network for test """ try: cmd = ("netadm enable -p ncp DefaultFixed") out, err, ret = run(cmd, timeout=60) if ret != "": logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) return False cmd = ("ipadm create-ip net3") out, err, ret = run(cmd, timeout=60) if ret != "": logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) return False cmd = ("ipadm create-addr -a 192.168.84.3/24 net3") out, err, ret = run(cmd, timeout=60) if ret != "": logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) return False cmd = (" route -p add default 192.168.84.1") out, err, ret = run(cmd, timeout=60) if ret != "": logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) return False except Exception, e: logging.exception("Failed to run %s got %s" % (cmd, e)) return False logging.info("Configuring network .Done !!!") return True Q1.How to make this code look better (in terms of quality) Q2. Iam using the except clause, just to maintain the syntax, will any exception be caught in this case. Q3. Any other observations made Thanks, Iam on Python 2.7 and freebsd. From python.list at tim.thechases.com Tue Oct 27 08:08:53 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 27 Oct 2015 07:08:53 -0500 Subject: How to make this simple code look better In-Reply-To: References: Message-ID: <20151027070853.0440a5ac@bigbox.christie.dr> On 2015-10-27 17:24, Ganesh Pal wrote: > from myPopen import run > > def configure_network(): > """ > Prepare network for test > """ > try: > cmd = ("netadm enable -p ncp DefaultFixed") > out, err, ret = run(cmd, timeout=60) > if ret != "": > logging.error("Can't run %s got %s (%d)!" % (cmd, err, > ret)) return False > cmd = ("ipadm create-ip net3") > out, err, ret = run(cmd, timeout=60) > if ret != "": > logging.error("Can't run %s got %s (%d)!" % (cmd, err, > ret)) return False > cmd = ("ipadm create-addr -a 192.168.84.3/24 net3") > out, err, ret = run(cmd, timeout=60) > if ret != "": > logging.error("Can't run %s got %s (%d)!" % (cmd, err, > ret)) return False > cmd = (" route -p add default 192.168.84.1") > out, err, ret = run(cmd, timeout=60) > if ret != "": > logging.error("Can't run %s got %s (%d)!" % (cmd, err, > ret)) return False > except Exception, e: > logging.exception("Failed to run %s got %s" % (cmd, e)) > return False > logging.info("Configuring network .Done !!!") > return True > > > Q1.How to make this code look better (in terms of quality) I'd be tempted 1) to put it in a loop 2) just test the "ret" string directly instead of comparing it to the empty string 3) to do your exception testing on each command rather than wrapping the entire loop for cmd in [ "netadm enable -p ncp DefaultFixed", "ipadm create-ip net3", "ipadm create-addr -a 192.168.84.3/24 net3", "route -p add default 192.168.84.1", ]: try: out, err, ret = run(cmd, timeout=60) if ret: logging.exception("Can't run %s got %s (d)!", cmd, err, ret) return False except Exception, e: logging.exception("Failed to run %s", cmd) return False logging.info("Configuring network done.") return True It reduces the redundant code and also brings all of the commands together in one place to see the expected steps. > Q2. Iam using the except clause, just to maintain the syntax, will > any exception be caught in this case. All regular exceptions will be caught. I think certain errors (rather than exceptions) may still behave properly. -tkc From lac at openend.se Tue Oct 27 08:08:54 2015 From: lac at openend.se (Laura Creighton) Date: Tue, 27 Oct 2015 13:08:54 +0100 Subject: Fw: Python 3.5.0 (32-bit) won't install to Windows XP In-Reply-To: <1445879690.63365.YahooMailBasic@web161305.mail.bf1.yahoo.com> References: <1445879690.63365.YahooMailBasic@web161305.mail.bf1.yahoo.com> Message-ID: <201510271208.t9RC8sJE000728@fido.openend.se> Python.org is not supporting XP for 3.5 and beyond. You need to upgrade your OS, or stick with 3.4 Laura Creighton From motoom at xs4all.nl Tue Oct 27 08:21:46 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Tue, 27 Oct 2015 13:21:46 +0100 Subject: Python Version 3.5 required which was not found in the registry In-Reply-To: <201510270918214049614@whty.com.cn> References: <201510270918214049614@whty.com.cn> Message-ID: <02CAAF41-08C4-4397-BDF3-F97D7E7E6795@xs4all.nl> > On 27 Oct 2015, at 02:18, luyijie wrote: > > when i install > pop "Python Version 3.5 required which was not found in the registry" > I do not know how to do... Wat version of Windows are you using? Greetings, From rosuav at gmail.com Tue Oct 27 08:33:00 2015 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 27 Oct 2015 23:33:00 +1100 Subject: Detection of a specific sound In-Reply-To: <10pu2b5r2digco2olh581gnns6lvhfrqj7@4ax.com> References: <10pu2b5r2digco2olh581gnns6lvhfrqj7@4ax.com> Message-ID: On Tue, Oct 27, 2015 at 11:06 PM, Dennis Lee Bieber wrote: > It would almost be faster to attach a thin, high-impedance (since one > doesn't want to weaken the actual sounder) wire to the Piezo buzzer, and > poll for activity. No false positive from an alarm clock or microwave > chirping. Or wire up a second smoke alarm (those things honestly aren't all that expensive) with the noisemaker replaced by something that signals your application. Actually, it's probably already been done - internet-enabled smoke alarms... ChrisA From python at mrabarnett.plus.com Tue Oct 27 08:34:22 2015 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 27 Oct 2015 12:34:22 +0000 Subject: Python Version 3.5 required which was not found in the registry In-Reply-To: <201510270918214049614@whty.com.cn> References: <201510270918214049614@whty.com.cn> Message-ID: <562F6F4E.2040700@mrabarnett.plus.com> On 2015-10-27 01:18, luyijie wrote: > python-list? > when i install > pop "Python Version 3.5 required which was not found in the registry" > I do not know how to do... > Have you installed Python 3.5? From python at mrabarnett.plus.com Tue Oct 27 08:40:03 2015 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 27 Oct 2015 12:40:03 +0000 Subject: How to make this simple code look better In-Reply-To: References: Message-ID: <562F70A3.8020302@mrabarnett.plus.com> On 2015-10-27 11:54, Ganesh Pal wrote: > from myPopen import run > > def configure_network(): > """ > Prepare network for test > """ > try: > cmd = ("netadm enable -p ncp DefaultFixed") > out, err, ret = run(cmd, timeout=60) > if ret != "": > logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) > return False > cmd = ("ipadm create-ip net3") > out, err, ret = run(cmd, timeout=60) > if ret != "": > logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) > return False > cmd = ("ipadm create-addr -a 192.168.84.3/24 net3") > out, err, ret = run(cmd, timeout=60) > if ret != "": > logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) > return False > cmd = (" route -p add default 192.168.84.1") > out, err, ret = run(cmd, timeout=60) > if ret != "": > logging.error("Can't run %s got %s (%d)!" % (cmd, err, ret)) > return False > except Exception, e: > logging.exception("Failed to run %s got %s" % (cmd, e)) > return False > logging.info("Configuring network .Done !!!") > return True > > > Q1.How to make this code look better (in terms of quality) > Q2. Iam using the except clause, just to maintain the syntax, will > any exception be caught in this case. > Q3. Any other observations made > > Thanks, Iam on Python 2.7 and freebsd. > According to the format strings, 'ret' is a number. If that's the case, it's not a string, so ret != "" will always be true. Why are you wrapping the command string literals in (...)? That's not necessary. You're doing the same thing with each of the command strings, so why not put them into a list and then iterate over them? It'll save a lot of duplication. From skip.montanaro at gmail.com Tue Oct 27 09:23:21 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Tue, 27 Oct 2015 08:23:21 -0500 Subject: Paramiko SSHClient.connect() problem Message-ID: I'm trying to use paramiko (for the first time) to connect to both the localhost and a remote host as I read along in Jesse Noller's blog post . That host is listed in ~/.ssh/known_hosts three different ways: unqualified hostname, fully qualified hostname, partially qualified hostname, and IP address. In all cases, it raises an SSHException. Here's an attempt to connect to localhost: >>> import paramiko >>> ssh = paramiko.SSHClient() >>> conn = ssh.connect("127.0.0.1") SSHException Server '127.0.0.1' not found in known_hosts [||1] [paramiko/client.py|connect|288] [paramiko/client.py|missing_host_key|570] I'm using paramiko 1.15.2 on an OpenSuSE 12.2 system. It's true that "127.0.0.1" doesn't appear in known_hosts, but the remote host I care about does, and it gets the same result: >>> ssh = paramiko.SSHClient() >>> conn = ssh.connect("firefly") SSHException Server 'firefly' not found in known_hosts [||1] [paramiko/client.py|connect|288] [paramiko/client.py|missing_host_key|570] Finally, there is also a "localhost" record in known_hosts. Connecting to that fails with a different exception: >>> ssh = paramiko.SSHClient() >>> conn = ssh.connect("localhost") error getsockaddrarg: bad family [||1] [paramiko/client.py|connect|251] [paramiko/util.py|retry_on_signal|270] [paramiko/client.py||251] [/opt/TWWfsw/python27/lib/python2.7/socket.py|meth|224] I use host key authentication, not password authentication. Any pointers appreciated. Skip -------------- next part -------------- An HTML attachment was scrubbed... URL: From ganesh1pal at gmail.com Tue Oct 27 10:51:38 2015 From: ganesh1pal at gmail.com (Ganesh Pal) Date: Tue, 27 Oct 2015 20:21:38 +0530 Subject: How to make this simple code look better In-Reply-To: <562F70A3.8020302@mrabarnett.plus.com> References: <562F70A3.8020302@mrabarnett.plus.com> Message-ID: > According to the format strings, 'ret' is a number. If that's the case, > it's not a string, so ret != "" will always be true. > > Why are you wrapping the command string literals in (...)? That's not > necessary. > > You're doing the same thing with each of the command strings, so why > not put them into a list and then iterate over them? It'll save a lot > of duplication. > > -- Thanks for pointing the ret !="" error . It should be ret!=0 , yes let me put into the string and try to iterate. From skip.montanaro at gmail.com Tue Oct 27 10:52:33 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Tue, 27 Oct 2015 09:52:33 -0500 Subject: Paramiko SSHClient.connect() problem In-Reply-To: References: Message-ID: On Tue, Oct 27, 2015 at 8:23 AM, Skip Montanaro wrote: > >>> ssh = paramiko.SSHClient() > >>> conn = ssh.connect("firefly") > SSHException Server 'firefly' not found in known_hosts > [||1] [paramiko/client.py|connect|288] > [paramiko/client.py|missing_host_key|570] > I figured out that I needed to call ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) I guess that has the side effect of actually reading my known_hosts file? Skip -------------- next part -------------- An HTML attachment was scrubbed... URL: From ganesh1pal at gmail.com Tue Oct 27 11:53:08 2015 From: ganesh1pal at gmail.com (Ganesh Pal) Date: Tue, 27 Oct 2015 21:23:08 +0530 Subject: How to make this simple code look better In-Reply-To: <20151027070853.0440a5ac@bigbox.christie.dr> References: <20151027070853.0440a5ac@bigbox.christie.dr> Message-ID: On Tue, Oct 27, 2015 at 5:38 PM, Tim Chase wrote: > It reduces the redundant code and also brings all of the commands > together in one place to see the expected steps. Thanks your suggested code looks nice , I easily knocked off half the lines of my code :) From chris at crwilcox.com Tue Oct 27 14:06:41 2015 From: chris at crwilcox.com (Christopher Wilcox) Date: Tue, 27 Oct 2015 11:06:41 -0700 Subject: Building a python extension on Windows In-Reply-To: <30AB5F71DF2C40A495DF74729E3EEECD@KenPC> References: <30AB5F71DF2C40A495DF74729E3EEECD@KenPC> Message-ID: <562fbd31.a45e440a.aee90.3555@mx.google.com> If you are building c extensions on windows with 2.7 you need to get the matching compiler from http://aka.ms/vcpython27. You should also make sure you are running the latest setup tools. If you are using 2.7.10 you should have them already. Finally, I suggest using ?pip install .? instead of ?python setup.py install?. You can get setup.py install to work on your machine with some configuration, but pip install will just work. So, in summary, run the following from the PC directory: pip install setuptools ?upgrade pip install . -Chris From: Ken Brooks Sent: Tuesday, October 27, 2015 5:09 To: python-list at python.org Cc: Ken Brooks Subject: Building a python extension on Windows I checked out a copy of svn.python.org/projects/stackless/trunk because it seems to have a good sample project (PC/example_nt)?for building a Python extension on Windows. That directory has a Microsoft Visual C++ solution file which can be updated to my Visual C++ version (8, of 2005). First I tried cd-ing to that directory, as they recommend, and saying "python setup.py install". The result? A very common complaint, "Unable to find vcvarsall.bat". A search using Windows would suggest that that file doesn't exist anywhere on my system. So I followed the VC++ build instructions, and copied the example_nt directory?up one level in the tree before building it. But when I actually try to build the solution it wants to look in the PCBuild directory for python27.lib, which isn't there. Nor can I find that library anywhere else. What gives? Is this project somehow hopelessly out of date? And more to the point, can someone direct me to a nice, fresh example project that will build a little Python extension on Windows? Thanks, Ken ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Oct 27 14:33:25 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 28 Oct 2015 05:33:25 +1100 Subject: Building a python extension on Windows In-Reply-To: <30AB5F71DF2C40A495DF74729E3EEECD@KenPC> References: <30AB5F71DF2C40A495DF74729E3EEECD@KenPC> Message-ID: On Tue, Oct 27, 2015 at 3:17 PM, Ken Brooks wrote: > I checked out a copy of svn.python.org/projects/stackless/trunk because it > seems to have a good sample project (PC/example_nt) for building a Python > extension on Windows. That directory has a Microsoft Visual C++ solution > file which can be updated to my Visual C++ version (8, of 2005). Building Python extensions on Windows depends heavily on the exact versions of the MS C compiler and CPython you use. Specifically, to use your extension with the standard python.org downloadable Python, you *must* use the same compiler that was used to build it. You mentioned that it went looking for python27.lib, which implies that you're using Python 2.7. That uses (and thus requires) a version of the MS compiler that is no longer supported in the normal way, but you can get it here: http://www.microsoft.com/en-au/download/details.aspx?id=44266 Unless you have a good reason for using 2.7, I would strongly recommend grabbing Python 3.5 instead. Starting with 3.5, the Windows builds of CPython are using a new "universal library" that will allow future compilers to be much more compatible with current versions, so you'll have an easier time of it down the track. Check out Steve Dower's blog on the subject: http://stevedower.id.au/blog/building-for-python-3-5-part-two/ If that doesn't help, you might do well to join the python-win32 mailing list, where you'll find a lot of people who know about the specific details and difficulties of building Windows extensions. ChrisA From rosuav at gmail.com Tue Oct 27 14:40:30 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 28 Oct 2015 05:40:30 +1100 Subject: Paramiko SSHClient.connect() problem In-Reply-To: References: Message-ID: On Wed, Oct 28, 2015 at 12:23 AM, Skip Montanaro wrote: > Finally, there is also a "localhost" record in known_hosts. Connecting to > that fails with a different exception: > >>>> ssh = paramiko.SSHClient() >>>> conn = ssh.connect("localhost") > error getsockaddrarg: bad family > [||1] [paramiko/client.py|connect|251] > [paramiko/util.py|retry_on_signal|270] [paramiko/client.py||251] > [/opt/TWWfsw/python27/lib/python2.7/socket.py|meth|224] > > I use host key authentication, not password authentication. > > Any pointers appreciated. The "bad family" error suggests that there's a mismatch between IPv4 and IPv6. It's common for /etc/hosts to contain two references to localhost, one as 127.0.0.1 and another as ::1 (IPv4 and IPv6 respectively), and if ssh.connect() is picking the wrong one, it'll have trouble. If you hack your hosts file to have only one localhost, does the problem disappear? ChrisA From skip.montanaro at gmail.com Tue Oct 27 15:56:58 2015 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Tue, 27 Oct 2015 14:56:58 -0500 Subject: Paramiko SSHClient.connect() problem In-Reply-To: References: Message-ID: On Tue, Oct 27, 2015 at 1:40 PM, Chris Angelico wrote: > If you hack your hosts file to have only one localhost, > does the problem disappear? > Yes, that appears to solve the problem. Thanks. I hadn't even thought there would be IPv4/IPv6 distinctions here. Interestingly enough, the box does seem to support IPv6: % ssh ::1 Warning: Permanently added '::1' (ECDSA) to the list of known hosts. Last login: Tue Oct 27 07:31:10 2015 from 10.100.0.191 ... Would I have been able to solve the problem in my paramiko calls by suitable changes to ssh.connect()? I don't see anything obvious, though perhaps I could give a non-default "sock" argument? Skip -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Tue Oct 27 17:23:44 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 27 Oct 2015 21:23:44 +0000 Subject: Windows 10 pip2.7.exe uninstall fails Message-ID: Let's install something. C:\>Python27\Scripts\pip2.7.exe install tox Collecting tox Using cached tox-2.1.1-py2.py3-none-any.whl Collecting virtualenv>=1.11.2 (from tox) Using cached virtualenv-13.1.2-py2.py3-none-any.whl Collecting py>=1.4.17 (from tox) Using cached py-1.4.30-py2.py3-none-any.whl Collecting pluggy<0.4.0,>=0.3.0 (from tox) Using cached pluggy-0.3.1-py2.py3-none-any.whl Installing collected packages: virtualenv, py, pluggy, tox Successfully installed pluggy-0.3.1 py-1.4.30 tox-2.1.1 virtualenv-13.1.2 Let's get rid of it. C:\>Python27\Scripts\pip2.7.exe uninstall tox A message box is displayed:- "This app can't run on your PC To find a version for your PC, check with the software publisher". Close the message box and:- "Access is denied." Searching hasn't thrown up a single reference to uninstall errors like this, any ideas? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From zachary.ware+pylist at gmail.com Tue Oct 27 17:26:27 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Tue, 27 Oct 2015 16:26:27 -0500 Subject: Building a python extension on Windows In-Reply-To: <30AB5F71DF2C40A495DF74729E3EEECD@KenPC> References: <30AB5F71DF2C40A495DF74729E3EEECD@KenPC> Message-ID: On Mon, Oct 26, 2015 at 11:17 PM, Ken Brooks wrote: > I checked out a copy of svn.python.org/projects/stackless/trunk Sorry I don't have the time at the moment for a more complete answer, but I will point out that that is not the right repository for anything anymore. For one thing, it's very outdated (see http://svn.python.org/view/stackless/, 'trunk' was last modified 5 years ago!); we migrated from Subversion to Mercurial (https://hg.python.org/) 4 years ago. For another, that's the repository for Stackless Python, which is not what you want (unless you do actually want Stackless Python :). In that case, Stackless development has moved to BitBucket: https://bitbucket.org/stackless-dev/stackless); Stackless is a fork of CPython. The upshot is, the repository you most likely want is at https://hg.python.org/cpython. -- Zach From jeffarcher7 at gmail.com Tue Oct 27 17:43:34 2015 From: jeffarcher7 at gmail.com (Jeff Archer) Date: Tue, 27 Oct 2015 17:43:34 -0400 Subject: Building a python extension on Windows In-Reply-To: <562fbd31.a45e440a.aee90.3555@mx.google.com> References: <30AB5F71DF2C40A495DF74729E3EEECD@KenPC> <562fbd31.a45e440a.aee90.3555@mx.google.com> Message-ID: Ken, I have been successful with building Python on Windows by downloading Python-3.5.0.tgz. Expand it and follow the instructions in Python-3.5.0\PCBuild\readme.txt. Basically, run get_externals.bat, then use build.bat. I have not however been successful building with VS2015 IDE. Can't remember the specific issues off-hand but since I was successful using the batch files, I didn't worry about it. With this build of Python I have gotten rudimentary extensions working with Boost.Python and straight C code. Had to build Boost against this build of Python to make that work. jeff *From: *Ken Brooks > *Sent: *Tuesday, October 27, 2015 5:09 > *To: *python-list at python.org > *Cc: *Ken Brooks > *Subject: *Building a python extension on Windows > > > > > > I checked out a copy of svn.python.org/projects/stackless/trunk because > it seems to have a good sample project (PC/example_nt) for building a > Python extension on Windows. That directory has a Microsoft Visual C++ > solution file which can be updated to my Visual C++ version (8, of 2005). > > First I tried cd-ing to that directory, as they recommend, and saying > "python setup.py install". The result? A very common complaint, "Unable to > find vcvarsall.bat". A search using Windows would suggest that that file > doesn't exist anywhere on my system. > > So I followed the VC++ build instructions, and copied the example_nt > directory up one level in the tree before building it. But when I actually > try to build the solution it wants to look in the PCBuild directory for > python27.lib, which isn't there. Nor can I find that library anywhere else. > > What gives? Is this project somehow hopelessly out of date? And more to > the point, can someone direct me to a nice, fresh example project that will > build a little Python extension on Windows? > > Thanks, > > Ken > > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Oct 27 18:59:06 2015 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 28 Oct 2015 09:59:06 +1100 Subject: Paramiko SSHClient.connect() problem In-Reply-To: References: Message-ID: On Wed, Oct 28, 2015 at 6:56 AM, Skip Montanaro wrote: > On Tue, Oct 27, 2015 at 1:40 PM, Chris Angelico wrote: >> >> If you hack your hosts file to have only one localhost, >> does the problem disappear? > > > Yes, that appears to solve the problem. Thanks. I hadn't even thought there > would be IPv4/IPv6 distinctions here. > > Interestingly enough, the box does seem to support IPv6: > > % ssh ::1 > Warning: Permanently added '::1' (ECDSA) to the list of known hosts. > Last login: Tue Oct 27 07:31:10 2015 from 10.100.0.191 > ... > > Would I have been able to solve the problem in my paramiko calls by suitable > changes to ssh.connect()? I don't see anything obvious, though perhaps I > could give a non-default "sock" argument? I've no idea. At this point, it's sounding like a paramiko issue - possibly even a bug, I don't know. Something to explore, at least. ChrisA From cs at zip.com.au Tue Oct 27 19:33:48 2015 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 28 Oct 2015 10:33:48 +1100 Subject: how to get python socket to use a specific interface In-Reply-To: <562F4B4E.3040603@chamonix.reportlab.co.uk> References: <562F4B4E.3040603@chamonix.reportlab.co.uk> Message-ID: <20151027233348.GA6216@cskk.homeip.net> On 27Oct2015 10:00, Robin Becker wrote: >On 26/10/2015 22:29, Cameron Simpson wrote: >>On 26Oct2015 12:33, Robin Becker wrote: >>>............. >........ >>>>$ ifconfig >>>>eth0 Link encap:Ethernet HWaddr 00:.......4 GB) >>>> Interrupt:16 >>>> >>>>eth0:0 Link encap:Ethernet HWa....... >> >>Do you need to bind to the device itself? Using the correct IP address should >>normally be sufficient. The system you're talking to won't know anything about >>the device, only the address. Try skipping the device binding step. > >According to the stackoverflow articles here > >http://stackoverflow.com/questions/335607/how-do-i-make-an-outgoing-socket-to-a-specific-network-interface > >http://stackoverflow.com/questions/8437726/can-python-select-what-network-adapter-when-opening-a-socket > >binding to the local IP seems to be a windows only thing. No, it is a pretty standard BSD socket layer thing. (Windows got its original TCP stack from there too). I just tested a Linux RHEL6 host binding to a specific address just now using telnet: /usr/bin/telnet -b x.x.x.193 x.x.x.174 22 where the .193 is not the primary address - it is an additional local address. The connection was correctly received by the target as from the alias address, not the base address: Oct 28 10:28:18 HOSTNAME sshd[7531]: Connection from x.x.x.193 port 61621 An strace says: socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3 bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("203.166.218.193")}, 16) = 0 setsockopt(3, SOL_IP, IP_TOS, [16], 4) = 0 connect(3, {sa_family=AF_INET, sin_port=htons(22), sin_addr=inet_addr("203.166.218.174")}, 16) = 0 so you can see it just binds the source address and goes. No device names involved. >I have tried just binding to the local IP, but my packets were from the >default address (the one connected to eth0). After reading the 8437726 article >again I think I may be on the wrong track anyway. Please show me the exact code you're using. This really should work without annoying "device" binding. The counter examples in the articules you cite are for particularly weird circumstances, such as where the routing table cannot correctly deduce the interface (distinct attached networks with the _same_ network numbering - ghastly). They don't say "binding to the local IP seems to be a windows only thing" that I can see. Please post your failing code. I suspect you're missing something. Cheers, Cameron Simpson From ben+python at benfinney.id.au Tue Oct 27 21:15:08 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 28 Oct 2015 12:15:08 +1100 Subject: How to make this simple code look better References: <562F70A3.8020302@mrabarnett.plus.com> Message-ID: <85lhann68z.fsf@benfinney.id.au> Dennis Lee Bieber writes: > Actually, if 0 is success, and you are testing for a failure, it > should probably just be > > if ret: > #do error That obscures the intent; there is nothing about ?is ?ret? false?? that tells me what the meaning of that test is. It happens to be the case that ?success? is a false-y value, but that's not clear from reading a simple ?if ret? test. Instead, I advise making it clear *why* we're checking zero in particular: because in this case zero means success. That's not obvious, and should be explicit. EXIT_CODE_SUCCESS = 0 # ? (stdout_content, stderr_content) = proc.communicate() if proc.returncode != EXIT_CODE_SUCCESS: handle_the_failure(proc) -- \ ?The process by which banks create money is so simple that the | `\ mind is repelled.? ?John Kenneth Galbraith, _Money: Whence It | _o__) Came, Where It Went_, 1975 | Ben Finney From dieter at handshake.de Wed Oct 28 02:52:25 2015 From: dieter at handshake.de (dieter) Date: Wed, 28 Oct 2015 07:52:25 +0100 Subject: How to log the output from the multiple telnet sessions to separate log file References: <1d1cd0e5-ed4f-4dc0-a8c3-fcc11b0f8ae3@googlegroups.com> Message-ID: <87d1vzfpsm.fsf@handshake.de> manjunatha.mahalingappa at gmail.com writes: > ... > I created the my own class MyLogger and passing log file name to it. I'm seeing no log is being written to passed log file instead everything is written to the logfilename [actually logfilename is variable with file name] I'm trying to create MyLogger object for each telnet session. and use that object. > > MyLogger is beeing called inside the Telnetsession class. those are present in PmTelnet3.py file. > > > class MyLogger(): > import logging > def __init__(self,logfilename): > #create logger with 'spam_application' > self.logger = self.logging.getLogger('TelnetSession') This will always give you the same logger object. I recommend to carefully read the "logging" related documentation to understand its architecture. In your context, the logger hierarchy and the concept of "logging handler" are of great importance. > ... > self.logging.basicConfig(filename = logfilename, > level = self.logging.INFO , > format= '%(asctime)s %(name)-12s %(levelname)-8s %(message)s', > datefmt='%m-%d %H:%M', > filemode='w') This will configure the so called "root" logger - the object at the root of the logger hierarchy. Loggers lower down in the hiearrchy will "inherit" from loggers higher up, unless they override things. Therefore, you will usually have a single "basicConfig" call, which globally (independent of the individual telnet sessions) configures common aspects. In the individual telnet sessions, you would use session specific loggers (below the "root" logger) which would inherit the common configuration and override session specific things (e.g. the log file via a specific handler). From dieter at handshake.de Wed Oct 28 02:59:58 2015 From: dieter at handshake.de (dieter) Date: Wed, 28 Oct 2015 07:59:58 +0100 Subject: Pause and Resuming of a file upload process to AWS S3 References: <20151021045214.d600875ec5143fcc53c5b00e1a6550c2.8e25f5048c.mailapi@email23.secureserver.net> Message-ID: <878u6nfpg1.fsf@handshake.de> ashwath at nanoheal.com writes: > I wanted to know whether it is possible in python to pause and resume the file upload process to AWS S3 Have you checked that "AWS S3" supports it? If so, you will be able to do it with Python -- however, you likely need to use low level modules (such as "httplib", maybe "ftplib") where you can fit in the technical details you learn from your "AWS S3" analysis. From robin at reportlab.com Wed Oct 28 06:41:48 2015 From: robin at reportlab.com (Robin Becker) Date: Wed, 28 Oct 2015 10:41:48 +0000 Subject: how to get python socket to use a specific interface In-Reply-To: <20151027233348.GA6216@cskk.homeip.net> References: <562F4B4E.3040603@chamonix.reportlab.co.uk> <20151027233348.GA6216@cskk.homeip.net> Message-ID: <5630A66C.1050802@chamonix.reportlab.co.uk> .......... >> >> binding to the local IP seems to be a windows only thing. > > No, it is a pretty standard BSD socket layer thing. (Windows got its original > TCP stack from there too). I just tested a Linux RHEL6 host binding to a > specific address just now using telnet: > > /usr/bin/telnet -b x.x.x.193 x.x.x.174 22 > > where the .193 is not the primary address - it is an additional local address. > The connection was correctly received by the target as from the alias address, > not the base address: I don't think I'll be able to do all I need with telnet :( ........ > > Please show me the exact code you're using. This really should work without > annoying "device" binding. > > The counter examples in the articules you cite are for particularly weird > circumstances, such as where the routing table cannot correctly deduce the > interface (distinct attached networks with the _same_ network numbering - > ghastly). They don't say "binding to the local IP seems to be a windows only > thing" that I can see. > > Please post your failing code. I suspect you're missing something. ....... Well originally I was hacking on miproxy to try and get it to use a specific ip address. I must have messed up somewhere there as when I try this more obvious code > from socket import socket, SOL_SOCKET > BIND_DEVICE='eth0.0' > sock = socket() > sock.settimeout(10) > sock.bind(('xx.xx.xx.13', 0)) > #sock.setsockopt(SOL_SOCKET, 25, BIND_DEVICE) > sock.connect(("int.hhhhhh.com", 80)) > sock.send("GET / HTTP/1.0\r\n\r\n") > print sock.recv(20) > sock.close() it does work as intended and I can see the .13 address hitting the remote server. I guess my hack of the miproxy code didn't work as intended. Anyhow my upstream provider has taken over the problem so hopefully I will get the address cleared at some point. -- Robin Becker From robin at reportlab.com Wed Oct 28 08:22:38 2015 From: robin at reportlab.com (Robin Becker) Date: Wed, 28 Oct 2015 12:22:38 +0000 Subject: Windows 10 pip2.7.exe uninstall fails In-Reply-To: References: Message-ID: <5630BE0E.40009@chamonix.reportlab.co.uk> ........ > A message box is displayed:- > > "This app can't run on your PC > To find a version for your PC, check with the software publisher". > > Close the message box and:- > > "Access is denied." > > Searching hasn't thrown up a single reference to uninstall errors like this, any > ideas? > FWIW on my 64bit windows 7 > C:\tmp>\python27\Scripts\pip.exe install tox > Downloading/unpacking tox > Downloading tox-2.1.1-py2.py3-none-any.whl > Downloading/unpacking pluggy>=0.3.0,<0.4.0 (from tox) > Downloading pluggy-0.3.1-py2.py3-none-any.whl > Requirement already satisfied (use --upgrade to upgrade): virtualenv>=1.11.2 in c:\python27\lib\site-packages\virtualenv > -1.11.6-py2.7.egg (from tox) > Downloading/unpacking py>=1.4.17 (from tox) > Installing collected packages: tox, pluggy, py > Successfully installed tox pluggy py > Cleaning up... > > C:\tmp>\python27\Scripts\pip.exe uninstall tox > Uninstalling tox: > c:\python27\lib\site-packages\tox-2.1.1.dist-info\description.rst > c:\python27\lib\site-packages\tox-2.1.1.dist-info\entry_points.txt > c:\python27\lib\site-packages\tox-2.1.1.dist-info\metadata > c:\python27\lib\site-packages\tox-2.1.1.dist-info\metadata.json > c:\python27\lib\site-packages\tox-2.1.1.dist-info\record > c:\python27\lib\site-packages\tox-2.1.1.dist-info\top_level.txt > c:\python27\lib\site-packages\tox-2.1.1.dist-info\wheel > c:\python27\lib\site-packages\tox\__init__.py > c:\python27\lib\site-packages\tox\__init__.pyc > c:\python27\lib\site-packages\tox\__main__.py > c:\python27\lib\site-packages\tox\__main__.pyc > c:\python27\lib\site-packages\tox\_pytestplugin.py > c:\python27\lib\site-packages\tox\_pytestplugin.pyc > c:\python27\lib\site-packages\tox\_quickstart.py > c:\python27\lib\site-packages\tox\_quickstart.pyc > c:\python27\lib\site-packages\tox\_verlib.py > c:\python27\lib\site-packages\tox\_verlib.pyc > c:\python27\lib\site-packages\tox\config.py > c:\python27\lib\site-packages\tox\config.pyc > c:\python27\lib\site-packages\tox\hookspecs.py > c:\python27\lib\site-packages\tox\hookspecs.pyc > c:\python27\lib\site-packages\tox\interpreters.py > c:\python27\lib\site-packages\tox\interpreters.pyc > c:\python27\lib\site-packages\tox\result.py > c:\python27\lib\site-packages\tox\result.pyc > c:\python27\lib\site-packages\tox\session.py > c:\python27\lib\site-packages\tox\session.pyc > c:\python27\lib\site-packages\tox\venv.py > c:\python27\lib\site-packages\tox\venv.pyc > c:\python27\scripts\tox-quickstart.exe > c:\python27\scripts\tox.exe > Proceed (y/n)? y > Successfully uninstalled tox > > C:\tmp> so perhaps yours is an exceptional case -- Robin Becker From motoom at xs4all.nl Wed Oct 28 09:50:55 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Wed, 28 Oct 2015 14:50:55 +0100 Subject: Pause and Resuming of a file upload process to AWS S3 In-Reply-To: <20151021045214.d600875ec5143fcc53c5b00e1a6550c2.8e25f5048c.mailapi@email23.secureserver.net> References: <20151021045214.d600875ec5143fcc53c5b00e1a6550c2.8e25f5048c.mailapi@email23.secureserver.net> Message-ID: Hi, > I wanted to know whether it is possible in python to pause and resume the file upload process to AWS S3 Have a look at s3tools/s3cmd at http://s3tools.org/s3cmd, in http://s3tools.org/usage I read: --continue-put Continue uploading partially uploaded files Greetings, From __peter__ at web.de Wed Oct 28 12:10:58 2015 From: __peter__ at web.de (Peter Otten) Date: Wed, 28 Oct 2015 17:10:58 +0100 Subject: UNABLE TO GET IDLE TO RUN References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> Message-ID: Terry Reedy wrote: Thank you for your patience. > Why do you think it a misfeature for IDLE to execute code the way Python > does? Sadly I wasn't aware that the interactive interpreter is also vulnerable. I should have been, but failed to add one and one. Until now I have often started python in a directory with unknown contents, to use it as a calculator or to explore the files in that directory. I will stop doing so. From larry.martell at gmail.com Wed Oct 28 12:25:30 2015 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 28 Oct 2015 12:25:30 -0400 Subject: List comprehension with if-else Message-ID: I'm trying to do a list comprehension with an if and that requires an else, but in the else case I do not want anything added to the list. For example, if I do this: white_list = [l.control_hub.serial_number if l.wblist == wblist_enum['WHITE'] else None for l in wblist] I end up with None in my list for the else cases. Is there a way I can do this so for the else cases nothing is added to the list? From zachary.ware+pylist at gmail.com Wed Oct 28 12:36:00 2015 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Wed, 28 Oct 2015 11:36:00 -0500 Subject: List comprehension with if-else In-Reply-To: References: Message-ID: On Wed, Oct 28, 2015 at 11:25 AM, Larry Martell wrote: > I'm trying to do a list comprehension with an if and that requires an > else, but in the else case I do not want anything added to the list. > > For example, if I do this: > > white_list = [l.control_hub.serial_number if l.wblist == wblist_enum['WHITE'] else None for l in wblist] Switch the 'if' and the 'for': white_list = [l.control_hub.serial_number for l in wblist if l.wblist == wblist_enum['WHITE']] -- Zach From carl at oddbird.net Wed Oct 28 12:36:06 2015 From: carl at oddbird.net (Carl Meyer) Date: Wed, 28 Oct 2015 10:36:06 -0600 Subject: List comprehension with if-else In-Reply-To: References: Message-ID: <5630F976.60703@oddbird.net> Hi Larry, On 10/28/2015 10:25 AM, Larry Martell wrote: > I'm trying to do a list comprehension with an if and that requires an > else, but in the else case I do not want anything added to the list. > > For example, if I do this: > > white_list = [l.control_hub.serial_number if l.wblist == > wblist_enum['WHITE'] else None for l in wblist] > > I end up with None in my list for the else cases. Is there a way I can > do this so for the else cases nothing is added to the list? You're not really using the if clause of the list comprehension here, you're just using a ternary if-else in the result expression. List comprehension if clauses go at the end, and don't require an else: [l.foo for l in wblist if l.bar == "baz"] Carl -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From torriem at gmail.com Wed Oct 28 13:34:59 2015 From: torriem at gmail.com (Michael Torrie) Date: Wed, 28 Oct 2015 11:34:59 -0600 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> Message-ID: <56310743.3070708@gmail.com> On 10/28/2015 10:10 AM, Peter Otten wrote: > Terry Reedy wrote: > > Thank you for your patience. > >> Why do you think it a misfeature for IDLE to execute code the way Python >> does? > > Sadly I wasn't aware that the interactive interpreter is also vulnerable. > I should have been, but failed to add one and one. > > Until now I have often started python in a directory with unknown contents, > to use it as a calculator or to explore the files in that directory. > > I will stop doing so. I'm curious what behavior you would suggest? In the case of the bare interactive interpreter, since there's no script loaded, the current directory is added so you can import modules you are working on. I do this all the time to help with testing and development of my projects' modules. This behavior makes perfect sense to me and I don't see any other practical alternative that is useful, expect for some syntax that differentiates between "local" imports and system ones. Not being able to easily import local modules would make the interactive interpreter next to useless for me. Given that this is only the behavior for interactive Python anyway, I don't see this as a significant vulnerability. If a bad guy is littering your working directories with malicious python programs you might import, you've already lost. No amount of Python tweaks are going to save you. From __peter__ at web.de Wed Oct 28 14:21:01 2015 From: __peter__ at web.de (Peter Otten) Date: Wed, 28 Oct 2015 19:21:01 +0100 Subject: UNABLE TO GET IDLE TO RUN References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> Message-ID: Michael Torrie wrote: > On 10/28/2015 10:10 AM, Peter Otten wrote: >> Terry Reedy wrote: >> >> Thank you for your patience. >> >>> Why do you think it a misfeature for IDLE to execute code the way Python >>> does? >> >> Sadly I wasn't aware that the interactive interpreter is also vulnerable. >> I should have been, but failed to add one and one. >> >> Until now I have often started python in a directory with unknown >> contents, to use it as a calculator or to explore the files in that >> directory. >> >> I will stop doing so. > > I'm curious what behavior you would suggest? I didn't suggest anything, because I didn't see a practical remedy. > In the case of the bare interactive interpreter, since there's no script > loaded, the current directory is added so you can import modules you are > working on. I do this all the time to help with testing and development > of my projects' modules. This behavior makes perfect sense to me and I > don't see any other practical alternative that is useful, expect for > some syntax that differentiates between "local" imports and system ones. > Not being able to easily import local modules would make the > interactive interpreter next to useless for me. > > Given that this is only the behavior for interactive Python anyway, I > don't see this as a significant vulnerability. If a bad guy is littering > your working directories with malicious python programs you might > import, you've already lost. No amount of Python tweaks are going to > save you. The problematic module might not even be malicious, it could just lack the if __name__ == "__main__": ... guard. And I am the bad guy I have in mind ;) When I download a Python project, have a look at it and then fire up an editor... $ hg clone http://www.example.com/whatever $ cd whatever $ ls -1 interesting_stuff.py ... string.py ... also_interesting.py ... readline.py ... $ idle # or $ python I don't want to check if there are any modules in the project that have names that will cause idle or python to import them instead of those it actually needs. Safer behaviour might be achieved by deferring the addition of the current directory to the path until idle or the interactive interpreter is completely set up or even by limiting import during the interpreter startup to built-in modules or a whitelist. PS: The shell people have learned their lesson and no longer include the working directory in the PATH: $ ls # the real thing $ ./ls # use at your own risk So maybe >>> import string # stdlib >>> from . import string # whatever you dropped into your working directory OK, probably not (just brainstorming). From larry.martell at gmail.com Wed Oct 28 14:31:18 2015 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 28 Oct 2015 14:31:18 -0400 Subject: List comprehension with if-else In-Reply-To: References: Message-ID: On Wed, Oct 28, 2015 at 12:36 PM, Zachary Ware wrote: > On Wed, Oct 28, 2015 at 11:25 AM, Larry Martell wrote: >> I'm trying to do a list comprehension with an if and that requires an >> else, but in the else case I do not want anything added to the list. >> >> For example, if I do this: >> >> white_list = [l.control_hub.serial_number if l.wblist == wblist_enum['WHITE'] else None for l in wblist] > > Switch the 'if' and the 'for': > > white_list = [l.control_hub.serial_number for l in wblist if > l.wblist == wblist_enum['WHITE']] Perfect. Thanks From cs at zip.com.au Wed Oct 28 18:15:01 2015 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 29 Oct 2015 09:15:01 +1100 Subject: how to get python socket to use a specific interface In-Reply-To: <5630A66C.1050802@chamonix.reportlab.co.uk> References: <5630A66C.1050802@chamonix.reportlab.co.uk> Message-ID: <20151028221501.GA47606@cskk.homeip.net> On 28Oct2015 10:41, Robin Becker wrote: >>>binding to the local IP seems to be a windows only thing. >>No, it is a pretty standard BSD socket layer thing. (Windows got its original >>TCP stack from there too). I just tested a Linux RHEL6 host binding to a >>specific address just now using telnet: >> >> /usr/bin/telnet -b x.x.x.193 x.x.x.174 22 >> >>where the .193 is not the primary address - it is an additional local address. >>The connection was correctly received by the target as from the alias address, >>not the base address: >I don't think I'll be able to do all I need with telnet :( Indeed:-( But it is very handy as a test for basic connection stuff in the field. >>Please show me the exact code you're using. This really should work without >>annoying "device" binding. [...] > >Well originally I was hacking on miproxy to try and get it to use a specific >ip address. I must have messed up somewhere there as when I try this more >obvious code [...] > >>from socket import socket, SOL_SOCKET >>BIND_DEVICE='eth0.0' >>sock = socket() >>sock.settimeout(10) >>sock.bind(('xx.xx.xx.13', 0)) >>#sock.setsockopt(SOL_SOCKET, 25, BIND_DEVICE) >>sock.connect(("int.hhhhhh.com", 80)) >>sock.send("GET / HTTP/1.0\r\n\r\n") >>print sock.recv(20) >>sock.close() > >it does work as intended and I can see the .13 address hitting the >remote server. I guess my hack of the miproxy code didn't work as >intended. That is reassuring to me. Thanks for checking. Reaching for a particular device is annoying and weird and possibly even pointless. >Anyhow my upstream provider has taken over the problem so hopefully I will get >the address cleared at some point. Ok. Cheers, Cameron Simpson From glicerinu at gmail.com Wed Oct 28 18:30:06 2015 From: glicerinu at gmail.com (Marc Aymerich) Date: Wed, 28 Oct 2015 23:30:06 +0100 Subject: Most space-efficient way to store log entries Message-ID: Hi, I'm writting an application that saves historical state in a log file. I want to be really efficient in terms of used bytes. What I'm doing now is: 1) First use zlib.compress 2) And then remove all new lines using binascii.b2a_base64, so I have a log entry per line. but b2a_base64 is far from ideal: adds lots of bytes to the compressed log entry. So, I wonder if perhaps there is a better way to remove new lines from the zlib output? or maybe a different approach? Anyone? Thanks!! -- Marc From rosuav at gmail.com Wed Oct 28 18:38:07 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 29 Oct 2015 09:38:07 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: On Thu, Oct 29, 2015 at 9:30 AM, Marc Aymerich wrote: > I'm writting an application that saves historical state in a log file. > I want to be really efficient in terms of used bytes. Why, exactly? By zipping the state, you make it utterly opaque. It'll require some sort of tool to tease it apart before you can read anything. Much more useful would be to have some sort of textual delimiter, followed by the content - then when you come to read it, all you need is a text viewer. Disk space is not expensive. Even if you manage to cut your file by a factor of four (75% compression, which is entirely possible if your content is plain text, but far from guaranteed), that's maybe three years of Moore's Law at most. You can get 3-4 terabytes of storage for roughly $100-$200, depending on exactly where you buy it, which dollar you're using, etc. How long will your program have to run to generate that much data? If you can't do that in, say, two years, don't bother compressing. ChrisA From python.list at tim.thechases.com Wed Oct 28 18:53:35 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 28 Oct 2015 17:53:35 -0500 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: <20151028175335.5ee9f9f5@bigbox.christie.dr> On 2015-10-29 09:38, Chris Angelico wrote: > On Thu, Oct 29, 2015 at 9:30 AM, Marc Aymerich > wrote: > > I'm writting an application that saves historical state in a log > > file. I want to be really efficient in terms of used bytes. > > Why, exactly? > > By zipping the state, you make it utterly opaque. If it's only zipped, it's not opaque. Just `zcat` or `zgrep` and process away. The whole base64+minus_newlines thing does opaquify and doesn't really save all that much for the trouble. > Disk space is not expensive. Even if you manage to cut your file by > a factor of four (75% compression, which is entirely possible if > your content is plain text, but far from guaranteed) Though one also has to consider the speed of reading it off the drive for processing. If you have spinning-rust drives, it's pretty slow (and SSD is still not like accessing RAM), and reading zipped content can shovel a LOT more data at your CPU than if it is coming off the drive uncompressed. Logs aren't much good if they aren't being monitored and processed for the information they contain. If nobody is monitoring the logs, just write them to /dev/null for 100% compression. ;-) -tkc From breamoreboy at yahoo.co.uk Wed Oct 28 20:21:13 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 29 Oct 2015 00:21:13 +0000 Subject: Most space-efficient way to store log entries In-Reply-To: <20151028175335.5ee9f9f5@bigbox.christie.dr> References: <20151028175335.5ee9f9f5@bigbox.christie.dr> Message-ID: On 28/10/2015 22:53, Tim Chase wrote: > On 2015-10-29 09:38, Chris Angelico wrote: >> On Thu, Oct 29, 2015 at 9:30 AM, Marc Aymerich >> wrote: >>> I'm writting an application that saves historical state in a log >>> file. I want to be really efficient in terms of used bytes. >> >> Why, exactly? >> >> By zipping the state, you make it utterly opaque. > > If it's only zipped, it's not opaque. Just `zcat` or `zgrep` and > process away. The whole base64+minus_newlines thing does opaquify > and doesn't really save all that much for the trouble. > >> Disk space is not expensive. Even if you manage to cut your file by >> a factor of four (75% compression, which is entirely possible if >> your content is plain text, but far from guaranteed) > > Though one also has to consider the speed of reading it off the drive > for processing. If you have spinning-rust drives, it's pretty slow > (and SSD is still not like accessing RAM), and reading zipped > content can shovel a LOT more data at your CPU than if it is coming > off the drive uncompressed. Logs aren't much good if they aren't > being monitored and processed for the information they contain. If > nobody is monitoring the logs, just write them to /dev/null for 100% > compression. ;-) > > -tkc > Can you get better than 100% compression if you write them to somewhere other than /dev/null/ ? -- 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 Oct 28 20:39:26 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 29 Oct 2015 11:39:26 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: <20151028175335.5ee9f9f5@bigbox.christie.dr> References: <20151028175335.5ee9f9f5@bigbox.christie.dr> Message-ID: On Thu, Oct 29, 2015 at 9:53 AM, Tim Chase wrote: > On 2015-10-29 09:38, Chris Angelico wrote: >> On Thu, Oct 29, 2015 at 9:30 AM, Marc Aymerich >> wrote: >> > I'm writting an application that saves historical state in a log >> > file. I want to be really efficient in terms of used bytes. >> >> Why, exactly? >> >> By zipping the state, you make it utterly opaque. > > If it's only zipped, it's not opaque. Just `zcat` or `zgrep` and > process away. The whole base64+minus_newlines thing does opaquify > and doesn't really save all that much for the trouble. If you zip the whole file as a whole, yes. If you zip individual pieces, you can't zcat it (at least, I don't think so?). Conversely, zipping the whole file means you have no choice but to sequentially scan it - you can't pull up the last section of the file. It's still a binary blob to many tools - we as humans may have handy tools around, but it's still going to be an extra step for any tool that doesn't intrinsically support it. >> Disk space is not expensive. Even if you manage to cut your file by >> a factor of four (75% compression, which is entirely possible if >> your content is plain text, but far from guaranteed) > > Though one also has to consider the speed of reading it off the drive > for processing. If you have spinning-rust drives, it's pretty slow > (and SSD is still not like accessing RAM), and reading zipped > content can shovel a LOT more data at your CPU than if it is coming > off the drive uncompressed. Logs aren't much good if they aren't > being monitored and processed for the information they contain. If > nobody is monitoring the logs, just write them to /dev/null for 100% > compression. ;-) Yeah. There are lots of considerations, but frankly, I don't think disk _capacity_ is a big one. Sometimes you _might_ get some benefit from compression (writing less sectors might save you time), but I almost never fill up my hard drives, and when I do, it's usually with already-compressed data (movies and stuff). ChrisA From rosuav at gmail.com Wed Oct 28 20:40:45 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 29 Oct 2015 11:40:45 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: References: <20151028175335.5ee9f9f5@bigbox.christie.dr> Message-ID: On Thu, Oct 29, 2015 at 11:21 AM, Mark Lawrence wrote: >> Though one also has to consider the speed of reading it off the drive >> for processing. If you have spinning-rust drives, it's pretty slow >> (and SSD is still not like accessing RAM), and reading zipped >> content can shovel a LOT more data at your CPU than if it is coming >> off the drive uncompressed. Logs aren't much good if they aren't >> being monitored and processed for the information they contain. If >> nobody is monitoring the logs, just write them to /dev/null for 100% >> compression. ;-) >> >> -tkc >> > > Can you get better than 100% compression if you write them to somewhere > other than /dev/null/ ? If you write them to /dev/sda, you might be able to create free space where there was none before. It all depends on the exact content of your logs :) ChrisA From cs at zip.com.au Wed Oct 28 21:09:13 2015 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 29 Oct 2015 12:09:13 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: <20151029010913.GA13062@cskk.homeip.net> On 29Oct2015 11:39, Chris Angelico wrote: >> If it's only zipped, it's not opaque. Just `zcat` or `zgrep` and >> process away. The whole base64+minus_newlines thing does opaquify >> and doesn't really save all that much for the trouble. > >If you zip the whole file as a whole, yes. If you zip individual >pieces, you can't zcat it (at least, I don't think so?). If it is pure gzip, then yes you can. So this: gunzip < file1.gz; gunzip < file2.gz and this: cat file1.gz file2.gz | gunzip should produce the same output. I think this works at the record level too. Of course all bets are off once you wrap the records in some outer layer (I have a file format with is little records which may have the data section zipped). >Conversely, >zipping the whole file means you have no choice but to sequentially >scan it - you can't pull up the last section of the file. It's still a >binary blob to many tools - we as humans may have handy tools around, >but it's still going to be an extra step for any tool that doesn't >intrinsically support it. Yes. But if you're keeping a lot of data or you're using a very constrained system you probably do want compression somewhere in there. Maybe the OP is optimising prematurely, but again, maybe not. However it sounds like the OP wants a text log encoding some test state, and is just compressing to gain a little room; I suspect that with a short record you might put on a line the compression obtained will be small and the loss from any base64 post step will undo it all. He may be better off keeping conventional text logs and just rotating them and compressing the rotated copies. Cheers, Cameron Simpson Hoping to shave precious seconds off the time it would take me to get through the checkout process and on my way home, I opted for the express line ("9 Items Or Less [sic]" Why nine items? Where do they come up with these rules, anyway? It's the same way at most stores -- always some oddball number like that, instead of a more understandable multiple of five. Like "five.") - Geoff Miller, geoffm at purplehaze.Corp.Sun.COM From rosuav at gmail.com Wed Oct 28 21:47:33 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 29 Oct 2015 12:47:33 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: <20151029010913.GA13062@cskk.homeip.net> References: <20151029010913.GA13062@cskk.homeip.net> Message-ID: On Thu, Oct 29, 2015 at 12:09 PM, Cameron Simpson wrote: > On 29Oct2015 11:39, Chris Angelico wrote: >>> >>> If it's only zipped, it's not opaque. Just `zcat` or `zgrep` and >>> process away. The whole base64+minus_newlines thing does opaquify >>> and doesn't really save all that much for the trouble. >> >> >> If you zip the whole file as a whole, yes. If you zip individual >> pieces, you can't zcat it (at least, I don't think so?). > > > If it is pure gzip, then yes you can. So this: > > gunzip < file1.gz; gunzip < file2.gz > > and this: > > cat file1.gz file2.gz | gunzip > > should produce the same output. I think this works at the record level too. > > Of course all bets are off once you wrap the records in some outer layer (I > have a file format with is little records which may have the data section > zipped). I was thinking in terms of having them wrapped, yes. Though I didn't think of the possibility of merely abutting compressed streams; with a bit of seeking and footling around, you could possibly make the file more tailable. Lots of options, but I still think uncompressed text is best. ChrisA From python.list at tim.thechases.com Wed Oct 28 22:09:42 2015 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 28 Oct 2015 21:09:42 -0500 Subject: Most space-efficient way to store log entries In-Reply-To: References: <20151028175335.5ee9f9f5@bigbox.christie.dr> Message-ID: <20151028210942.7bb5f57c@bigbox.christie.dr> On 2015-10-29 00:21, Mark Lawrence wrote: > On 28/10/2015 22:53, Tim Chase wrote: >> If nobody is monitoring the logs, just write them to /dev/null >> for 100% compression. ;-) > > Can you get better than 100% compression if you write them to > somewhere other than /dev/null/ ? Well, /dev/null is a device. I don't know what happens if you remove it and make it a sub-directory. But sure, you can use the "rm -rf /*" utility to compress your files and you'll get more space on your disk than you had before you started. It works by commenting out all of your drive's content...note the beginning of the C-style comment token. You might also have to run it as root or prefixed with `sudo` because getting >100% compression requires super-user permissions. If-you-wipe-your-drive-don't-blame-me'ly yers, -tkc From torriem at gmail.com Wed Oct 28 22:13:31 2015 From: torriem at gmail.com (Michael Torrie) Date: Wed, 28 Oct 2015 20:13:31 -0600 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> Message-ID: <563180CB.5080303@gmail.com> On 10/28/2015 12:21 PM, Peter Otten wrote: > PS: The shell people have learned their lesson and no longer include the > working directory in the PATH: > $ ls # the real thing > $ ./ls # use at your own risk Sure but this is a somewhat different genre. > > So maybe > >>>> import string # stdlib >>>> from . import string # whatever you dropped into your working directory > > OK, probably not (just brainstorming). > It's actually not just interactive Python sessions where people are attacked by themselves by covering other modules in the path. It happens in programs too, like recently on the list where someone called their python program turtle.py and managed to stick it in a weird path, but one that is normally in the Python search path, and then when someone wanted to import turtle from the stdlib, they got the one in C:\windows\system32. Granted that is really a misconfiguration problem on the part of the OS for allowing a normal user to write to a system location. So yeah I dunno. From martin at linux-ip.net Wed Oct 28 23:28:31 2015 From: martin at linux-ip.net (Martin A. Brown) Date: Wed, 28 Oct 2015 20:28:31 -0700 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: Hello Marc, I think you have gotten quite a few answers already, but I'll add my voice. > I'm writting an application that saves historical state in a log > file. If I were in your shoes, I'd probably use the logging module rather than saving state in my own log file. That allows the application to send all historical state to the system log. Then, it could be captured, recorded, analyzed and purged (or neglected) along with all of the other logging. But, this may not be appropriate for your setup. See also my final two questions at the bottom. > I want to be really efficient in terms of used bytes. It is good to want to be efficient. Don't cost your (future) self or some other poor schlub future working or computational efficiency, though! Somebody may one day want to extract utility out of the application's log data. So, don't make that data too hard to read. > What I'm doing now is: > > 1) First use zlib.compress ... assuming you are going to write your own files, then, certainly. If you also want better compression (quantified in a table below) at a higher CPU cost, try bz2 or lzma (Python3). Note that there is not a symmetric CPU cost for compression and decompression. Usually, decompression is much cheaper. # compress = bz2.compress # compress = lzma.compress compress = zlib.compress To read the logging data, then the programmer, application analyst or sysadmin will need to spend CPU to uncompress. If it's rare, that's probably a good tradeoff. Here's my small comparison matrix of the time it takes to transform a sample log file that was roughly 33MB (in memory, no I/O costs included in timing data). The chart also shows the size of the compressed data, in bytes and percentage (to demonstrate compression efficiency). format bytes pct walltime raw 34311602 1.00% 0.00000s base64-encode 46350762 1.35% 0.43066s zlib-compress 3585508 0.10% 0.54773s bz2-compress 2704835 0.08% 4.15996s lzma-compress 2243172 0.07% 15.89323s base64-decode 34311602 1.00% 0.18933s bz2-decompress 34311602 1.00% 0.62733s lzma-decompress 34311602 1.00% 0.22761s zlib-decompress 34311602 1.00% 0.07396s The point of a sample matrix like this is to examine the tradeoff between time (for compression and decompression) and to think about how often you, your application or your users will decompress the historical data. Also consider exactly how sensitive you are to bytes on disk. (N.B. Data from a single run of the code.) Finally, simply make a choice for one of the compression algorithms. > 2) And then remove all new lines using binascii.b2a_base64, so I > have a log entry per line. I'd also suggest that you resist the base64 temptation. As others have pointed out, there's a benefit to keeping the logs compressed using one of the standard compression tools (zgrep, zcat, bzgrep, lzmagrep, xzgrep, etc.) Also, see the statistics above for proof--base64 encoding is not compression. Rather, it usually expands input data to the tune of one third (see above, the base64 encoded string is 135% of the raw input). That's not compression. So, don't do it. In this case, it's expansion and obfuscation. If you don't need it, don't choose it. In short, base64 is actively preventing you from shrinking your storage requirement. > but b2a_base64 is far from ideal: adds lots of bytes to the > compressed log entry. So, I wonder if perhaps there is a better > way to remove new lines from the zlib output? or maybe a different > approach? Suggestion: Don't worry about the single-byte newline terminator. Look at a whole logfile and choose your best option. Lastly, I have one other pair of questions for you to consider. Question one: Will your application later read or use the logging data? If no, and it is intended only as a record for posterity, then, I'd suggest sending that data to the system logs (see the 'logging' module and talk to your operational people). If yes, then question two is: What about resilience? Suppose your application crashes in the middle of writing a (compressed) logfile. What does it do? Does it open the same file? (My personal answer is always 'no.') Does it open a new file? When reading the older logfiles, how does it know where to resume? Perhaps you can see my line of thinking. Anyway, best of luck, -Martin P.S. The exact compression ratio is dependent on the input. I have rarely seen zlib at 10% or bz2 at 8%. I conclude that my sample log data must have been more homogeneous than the data on which I derived my mental bookmarks for textual compression efficiencies of around 15% for zlib and 12% for bz2. I have no mental bookmark for lzma yet, but 7% is an outrageously good compression ratio. -- Martin A. Brown http://linux-ip.net/ From nagu.koppula at lazada.com Thu Oct 29 01:02:37 2015 From: nagu.koppula at lazada.com (Nagu Koppula) Date: Thu, 29 Oct 2015 13:02:37 +0800 Subject: system error - api-ms-win-crt-runtime-l1-1-0.dll Message-ID: <000001d11207$09674950$1c35dbf0$@lazada.com> Hi Could you help me to resolve below error in my windows 7 laptop? I had tried re-installing / repair, still error persists. Error - screenshot Regards, Nagu -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 7458 bytes Desc: not available URL: From tjreedy at udel.edu Thu Oct 29 02:48:02 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 29 Oct 2015 02:48:02 -0400 Subject: system error - api-ms-win-crt-runtime-l1-1-0.dll In-Reply-To: <000001d11207$09674950$1c35dbf0$@lazada.com> References: <000001d11207$09674950$1c35dbf0$@lazada.com> Message-ID: On 10/29/2015 1:02 AM, Nagu Koppula wrote: > Hi > > Could you help me to resolve below error in my windows 7 laptop? > > I had tried re-installing / repair, still error persists. > > Error - screenshot Copy the relevant parts into your text message. Ever heard of a search bar? Google? This error message is not specific to Python. Here is one hit. http://blog.spreendigital.de/2015/09/01/how-to-fix-the-api-ms-win-crt-runtime-l1-1-0-dll-is-missing-error-for-delphi-10-seattle/ Many others. -- Terry Jan Reedy From lac at openend.se Thu Oct 29 03:53:35 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 08:53:35 +0100 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: <563180CB.5080303@gmail.com> References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> Message-ID: <201510290753.t9T7rZqR032272@fido.openend.se> I think that it would be useful if IDLE spit out a warning: Warning: local file /u/lac/junk/string.py shadows module named string in the Standard Library Laura From lac at openend.se Thu Oct 29 04:15:55 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 09:15:55 +0100 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: <201510290815.t9T8Ftu2001920@fido.openend.se> Did the OP say he wanted to keep his compressed logfiles on a local disk? What if he wants to send them across the internet to some other machine and would like the transfer to happen as quickly as possible? Laura From lac at openend.se Thu Oct 29 04:34:19 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 09:34:19 +0100 Subject: system error - api-ms-win-crt-runtime-l1-1-0.dll In-Reply-To: <000001d11207$09674950$1c35dbf0$@lazada.com> References: <000001d11207$09674950$1c35dbf0$@lazada.com> Message-ID: <201510290834.t9T8YJLF003318@fido.openend.se> 1. If you are running XP, you cannot run Python 3.5. XP is not supported. You need to get a newer OS. 2. Otherwise, the api-ms-win-crt-runtime-l1-1-0-dll is Microsofts Universal CRT. You don't have one. You need to install it. Get it here: http://www.microsoft.com/en-us/download/details.aspx?id=48234 Laura From nagu.koppula at lazada.com Thu Oct 29 04:41:28 2015 From: nagu.koppula at lazada.com (Nagu Koppula) Date: Thu, 29 Oct 2015 16:41:28 +0800 Subject: system error - api-ms-win-crt-runtime-l1-1-0.dll In-Reply-To: <201510290834.t9T8YJLF003318@fido.openend.se> References: <000001d11207$09674950$1c35dbf0$@lazada.com> <201510290834.t9T8YJLF003318@fido.openend.se> Message-ID: <000001d11225$9c5b3cd0$d511b670$@lazada.com> Hi Laura, Thanks for your quick response and help! It is windows 7 and it is working after I downloaded the Microsoft's Universal CRT. Regards, Nagu -----Original Message----- From: Laura Creighton [mailto:lac at openend.se] Sent: Thursday, October 29, 2015 4:34 PM To: Nagu Koppula Cc: python-list at python.org; lac at openend.se Subject: Re: system error - api-ms-win-crt-runtime-l1-1-0.dll 1. If you are running XP, you cannot run Python 3.5. XP is not supported. You need to get a newer OS. 2. Otherwise, the api-ms-win-crt-runtime-l1-1-0-dll is Microsofts Universal CRT. You don't have one. You need to install it. Get it here: http://www.microsoft.com/en-us/download/details.aspx?id=48234 Laura -------------- next part -------------- An HTML attachment was scrubbed... URL: From David.Aldrich at EMEA.NEC.COM Thu Oct 29 05:52:56 2015 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Thu, 29 Oct 2015 09:52:56 +0000 Subject: Problem working with subprocess.check_call Message-ID: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> Hi I am working on Linux with Python 3.4. I want to do a bash diff on two text files and show just the first 20 lines of diff's output. So I tried: >>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')' >>> subprocess.check_call(cmd, shell=True) The command contained in cmd works ok from the bash prompt but not from Python code. In Python I get: /bin/sh: -c: line 0: syntax error near unexpected token `(' I think the problem is that check_call is not using the bash shell. So I also tried: >>> subprocess.check_call("bash", "-O", "extglob", "-c", cmd) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.4/subprocess.py", line 556, in check_call retcode = call(*popenargs, **kwargs) File "/usr/local/lib/python3.4/subprocess.py", line 537, in call with Popen(*popenargs, **kwargs) as p: File "/usr/local/lib/python3.4/subprocess.py", line 767, in __init__ raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer Can anyone help me with this please? Best regards David -------------- next part -------------- An HTML attachment was scrubbed... URL: From songofacandy at gmail.com Thu Oct 29 05:57:04 2015 From: songofacandy at gmail.com (INADA Naoki) Date: Thu, 29 Oct 2015 18:57:04 +0900 Subject: Problem working with subprocess.check_call In-Reply-To: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> References: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> Message-ID: On Thu, Oct 29, 2015 at 6:52 PM, David Aldrich wrote: > Hi > > > > I am working on Linux with Python 3.4. > > > > I want to do a bash diff on two text files and show just the first 20 > lines of diff?s output. So I tried: > > > > >>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')' > > >>> subprocess.check_call(cmd, shell=True) > > > > The command contained in cmd works ok from the bash prompt but not from > Python code. In Python I get: > > > > /bin/sh: -c: line 0: syntax error near unexpected token `(' > > > > I think the problem is that check_call is not using the bash shell. So I > also tried: > > > > >>> subprocess.check_call("bash", "-O", "extglob", "-c", cmd) > Try this subprocess.check_call(["bash", "-O", "extglob", "-c", cmd]) > Traceback (most recent call last): > > File "", line 1, in > > File "/usr/local/lib/python3.4/subprocess.py", line 556, in check_call > > retcode = call(*popenargs, **kwargs) > > File "/usr/local/lib/python3.4/subprocess.py", line 537, in call > > with Popen(*popenargs, **kwargs) as p: > > File "/usr/local/lib/python3.4/subprocess.py", line 767, in __init__ > > raise TypeError("bufsize must be an integer") > > TypeError: bufsize must be an integer > > > > Can anyone help me with this please? > > > > Best regards > > > > David > > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -- INADA Naoki -------------- next part -------------- An HTML attachment was scrubbed... URL: From David.Aldrich at EMEA.NEC.COM Thu Oct 29 06:05:42 2015 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Thu, 29 Oct 2015 10:05:42 +0000 Subject: Problem working with subprocess.check_call In-Reply-To: References: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> Message-ID: <41302A7145AC054FA7A96CFD03835A0A0B9F4F27@EX10MBX02.EU.NEC.COM> > Try this > subprocess.check_call(["bash", "-O", "extglob", "-c", cmd]) That worked. Thanks very much! David From contact at stridebird.com Thu Oct 29 06:06:24 2015 From: contact at stridebird.com (Pete Dowdell) Date: Thu, 29 Oct 2015 17:06:24 +0700 Subject: Problem working with subprocess.check_call In-Reply-To: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> References: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> Message-ID: <5631EFA0.3070508@stridebird.com> On 29/10/15 16:52, David Aldrich wrote: > > Hi > > I am working on Linux with Python 3.4. > > I want to do a bash diff on two text files and show just the first 20 > lines of diff?s output. So I tried: > > >>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')' > > >>> subprocess.check_call(cmd, shell=True) > You could use a shell pipe in your command - and use str.format() too for better readability, perhaps: > cmd = 'diff {} {} | head -20'.format( file1, file2 ) > subprocess.check_call(cmd, shell=True) Although this approach would not be recommended if file1 or file2 are not sanitised pd -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Oct 29 06:11:17 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 29 Oct 2015 11:11:17 +0100 Subject: Problem working with subprocess.check_call References: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> Message-ID: David Aldrich wrote: > I am working on Linux with Python 3.4. > > I want to do a bash diff on two text files and show just the first 20 > lines of diff's output. So I tried: > >>>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')' >>>> subprocess.check_call(cmd, shell=True) > > The command contained in cmd works ok from the bash prompt but not from > Python code. In Python I get: > > /bin/sh: -c: line 0: syntax error near unexpected token `(' > > I think the problem is that check_call is not using the bash shell. I think your diagnosis is correct. > So I > also tried: > >>>> subprocess.check_call("bash", "-O", "extglob", "-c", cmd) > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python3.4/subprocess.py", line 556, in check_call > retcode = call(*popenargs, **kwargs) > File "/usr/local/lib/python3.4/subprocess.py", line 537, in call > with Popen(*popenargs, **kwargs) as p: > File "/usr/local/lib/python3.4/subprocess.py", line 767, in __init__ > raise TypeError("bufsize must be an integer") > TypeError: bufsize must be an integer > > Can anyone help me with this please? Try specifying the shell explicitly: check_call(["/bin/bash", "-c", cmd]) Or use a command that works with the default shell: check_call("diff ... | head -n20", shell=True) From lac at openend.se Thu Oct 29 06:11:17 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 11:11:17 +0100 Subject: Problem working with subprocess.check_call In-Reply-To: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> References: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> Message-ID: <201510291011.t9TABHm4010711@fido.openend.se> In a message of Thu, 29 Oct 2015 09:52:56 +0000, David Aldrich writes: >Hi > >I am working on Linux with Python 3.4. > >I want to do a bash diff on two text files and show just the first 20 lines of diff's output. So I tried: > >>>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')' >>>> subprocess.check_call(cmd, shell=True) I am reading https://docs.python.org/3.5/library/subprocess.html because my first thought was that shell should be False here. The doc doesn't say. Filing doc bug now. Laura From lac at openend.se Thu Oct 29 06:16:16 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 11:16:16 +0100 Subject: Problem working with subprocess.check_call In-Reply-To: <201510291011.t9TABHm4010711@fido.openend.se> References: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> <201510291011.t9TABHm4010711@fido.openend.se> Message-ID: <201510291016.t9TAGGmo011135@fido.openend.se> In a message of Thu, 29 Oct 2015 11:11:17 +0100, Laura Creighton writes: >In a message of Thu, 29 Oct 2015 09:52:56 +0000, David Aldrich writes: >>Hi >> >>I am working on Linux with Python 3.4. >> >>I want to do a bash diff on two text files and show just the first 20 lines of diff's output. So I tried: >> >>>>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')' >>>>> subprocess.check_call(cmd, shell=True) > >I am reading https://docs.python.org/3.5/library/subprocess.html > >because my first thought was that shell should be False here. >The doc doesn't say. Filing doc bug now. > >Laura False alarm, I just cannot read today. Inject more caffeine and try again. Laura From David.Aldrich at EMEA.NEC.COM Thu Oct 29 06:19:27 2015 From: David.Aldrich at EMEA.NEC.COM (David Aldrich) Date: Thu, 29 Oct 2015 10:19:27 +0000 Subject: Problem working with subprocess.check_call In-Reply-To: References: <41302A7145AC054FA7A96CFD03835A0A0B9F4EF4@EX10MBX02.EU.NEC.COM> Message-ID: <41302A7145AC054FA7A96CFD03835A0A0B9F4F66@EX10MBX02.EU.NEC.COM> Thanks for all your answers. David From tjreedy at udel.edu Thu Oct 29 06:33:55 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 29 Oct 2015 06:33:55 -0400 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: <201510290753.t9T7rZqR032272@fido.openend.se> References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> <201510290753.t9T7rZqR032272@fido.openend.se> Message-ID: On 10/29/2015 3:53 AM, Laura Creighton wrote: > I think that it would be useful if IDLE spit out a warning: User code is compiled and executed by builtin compile and exec, so it would have to be python (exec) that emit a warning. > Warning: local file /u/lac/junk/string.py shadows module named string in the Standard Library -- Terry Jan Reedy From glicerinu at gmail.com Thu Oct 29 06:35:02 2015 From: glicerinu at gmail.com (Marc Aymerich) Date: Thu, 29 Oct 2015 11:35:02 +0100 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: On Wed, Oct 28, 2015 at 11:30 PM, Marc Aymerich wrote: > Hi, > I'm writting an application that saves historical state in a log file. > I want to be really efficient in terms of used bytes. > > What I'm doing now is: > > 1) First use zlib.compress > 2) And then remove all new lines using binascii.b2a_base64, so I have > a log entry per line. > > but b2a_base64 is far from ideal: adds lots of bytes to the compressed > log entry. So, I wonder if perhaps there is a better way to remove new > lines from the zlib output? or maybe a different approach? > > Anyone? [....] wow, lots of interesting replies here, allow me to clarify my situation and answear some of the questions. I'm writing a toy project for my master thesis, which is never going into production. What I'm doing is a decentralized file system for configuration managemente (without centralized authority). This means: 1) Each node on the cluster needs to keep track of *all* the changes that ever ocurred. So far, each node is storing each change as individual lines on a file (the "historical state log" I was referring to, the concept is very similar to the bitcoin blockchain) 2) The main communication channel is driven by a UDP gossip protocol. >From the performance perspective, it makes a huge difference if the whole log entry fits into the UDP payload (512B), otherwise the log entry has to be transferred by other means. Because config files are mostly text, almost every single one of them can fit into a UDP packet, if properly compressed. After reading your replies I'm concluding that 1) I should use the most space-efficient encoding *only* for transferring the log entry, just lzma compress it. 2) I should use the most readable one for storing the block on the log file. Leave metadata as text and compress+base64 the "actual file content" so it fits in an space-less ascii block, something like: # $ cat log # a5438566b83b4383899500c6b70dcac1 1446054664 WRITE /.keys TUY4Q0FRRUVHQHNkl6MTNtZz09Cg== 2d:ce:6d:c5:95:54:cb:d2:fe:ba:68:ed:1d:8e:74:0f iPDxBYuUEjlZl99/xGCNzpbuDezJJfolr+eNLNrXEYAgG/0yme3bu9DCkPO9Gq7+ cb4f67a712964699a5c2d49a42e48946 1446054664 WRITE /.cluster MTcyLjE3LjLjEK 2d:ce:6d:c5:95:54:cb:d2:fe:ba:68:ed:1d:8e:74:0f /VKMeVG95MT9VdObRyhidzxIgiTef+7nl3flgQpqVAgRfhqrBGRB4XTgJFSelvCo 5041fba6b6534dfe92bf99ed5ead8fa6 1446055543 MKDIR /etc 2d:ce:6d:c5:95:54:cb:d2:fe:ba:68:ed:1d:8e:74:0f +CMeVp33FxXFSfczbmkoW4tnalu5ojuC1WprMkc7Kxp/WHlMsx9Os3Zal0Bi/uD8 80c47cd5a73e4881b7284eed465ab10a 1446055843 WRITE /etc/node.conf aG9sYQo= 2d:ce:6d:c5:95:54:cb:d2:fe:ba:68:ed:1d:8e:74:0f oQVF7UCAFRCC7cC0Ln8V16f8mnON465sdXoIEIGCKBUOWOBE5daFmJTu0thAkXVf -- Marc From rosuav at gmail.com Thu Oct 29 06:52:16 2015 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 29 Oct 2015 21:52:16 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: On Thu, Oct 29, 2015 at 9:35 PM, Marc Aymerich wrote: > 1) Each node on the cluster needs to keep track of *all* the changes > that ever ocurred. So far, each node is storing each change as > individual lines on a file (the "historical state log" I was referring > to, the concept is very similar to the bitcoin blockchain) > > 2) The main communication channel is driven by a UDP gossip protocol. > From the performance perspective, it makes a huge difference if the > whole log entry fits into the UDP payload (512B), otherwise the log > entry has to be transferred by other means. Because config files are > mostly text, almost every single one of them can fit into a UDP > packet, if properly compressed. > > After reading your replies I'm concluding that > > 1) I should use the most space-efficient encoding *only* for > transferring the log entry, just lzma compress it. > 2) I should use the most readable one for storing the block on the log > file. Leave metadata as text and compress+base64 the "actual file > content" so it fits in an space-less ascii block, something like: I agree with those conclusions. If anything goes wrong, you have the tidy log in a form that's easily dug into, and then compression is used for transmission only. A couple of points of interest, though: 1) Conflicts - since you lack any concept of central authority, there's the possibility that two peers will simultaneously make incompatible changes, and then begin propagating them through the farm. What happens when a node receives a change it can't apply? 2) UDP is unreliable. What happens if a node misses out on a change? Can it figure out that it's missed something, and go ask? I'm assuming you've thought about these, and am curious as to how you've solved them - might be useful in some of the things I've played with. ChrisA From glicerinu at gmail.com Thu Oct 29 07:57:09 2015 From: glicerinu at gmail.com (Marc Aymerich) Date: Thu, 29 Oct 2015 12:57:09 +0100 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: On Thu, Oct 29, 2015 at 11:52 AM, Chris Angelico wrote: > On Thu, Oct 29, 2015 at 9:35 PM, Marc Aymerich wrote: >> 1) Each node on the cluster needs to keep track of *all* the changes >> that ever ocurred. So far, each node is storing each change as >> individual lines on a file (the "historical state log" I was referring >> to, the concept is very similar to the bitcoin blockchain) >> >> 2) The main communication channel is driven by a UDP gossip protocol. >> From the performance perspective, it makes a huge difference if the >> whole log entry fits into the UDP payload (512B), otherwise the log >> entry has to be transferred by other means. Because config files are >> mostly text, almost every single one of them can fit into a UDP >> packet, if properly compressed. >> >> After reading your replies I'm concluding that >> >> 1) I should use the most space-efficient encoding *only* for >> transferring the log entry, just lzma compress it. >> 2) I should use the most readable one for storing the block on the log >> file. Leave metadata as text and compress+base64 the "actual file >> content" so it fits in an space-less ascii block, something like: > > I agree with those conclusions. If anything goes wrong, you have the > tidy log in a form that's easily dug into, and then compression is > used for transmission only. > > A couple of points of interest, though: > > 1) Conflicts - since you lack any concept of central authority, > there's the possibility that two peers will simultaneously make > incompatible changes, and then begin propagating them through the > farm. What happens when a node receives a change it can't apply? Yes, my solution is very similar to the bitcoin blockchain double spending solution [1]. I have one blockchain for every path, all log entries contain the hash of its ancestor, when more than one log entry has the same ancestor we have a conflict (branching). Solving this conflict just means that all nodes on the network should agree on choosing the same branch. Bitcoin uses proof-of-work: the longest chain (more CPU power) is always chosen. My nodes will chose the branch with: 1) more log entries with higher authority signatures (allowing to support key revoking)** 2) if equal, the one with more different valid signatures (more participants say its the good one) 3) if equal, higher hash (arbitrary but it has to be deterministic) :P Notice that the file system is eventual consistent, the branch that is valid now, may not be tomorrow. **My solution for decentralized authority is having a .keys file on each directory containing the keys that are authorized to write in it, higher authority just means that a log entry signature belongs to a key that appears higher in the file system hierarchy (kind of proof-of-stake, the branch with higher authority wins so key revoking is possible) [1] https://en.bitcoin.it/wiki/How_bitcoin_works#Double_spending > 2) UDP is unreliable. What happens if a node misses out on a change? > Can it figure out that it's missed something, and go ask? I'm still pending to read some papers on the matter (just starting), but as far as I can tell gossip protocols take a probabilistic approach when disseminating information, like the spread of a disease, one particular node is exposed multiple times to the same messages by different nodes, making gossip protocols very resilient to packet loss. Also when a node recovers from failure (or rejoins the cluster after a network partition) I perform a full state sync, but I still don't know if this is sufficient or I'll need to do periodic syncs, still learning. Btw, I'm using serf[1] which in turn uses SWIM[2], and there are a lot of other interesting papers, just didn't read them, yet. [1] https://www.serfdom.io/docs/internals/gossip.html [2] https://www.cs.cornell.edu/~asdas/research/dsn02-swim.pdf -- Marc From snafuclan at web.de Thu Oct 29 12:14:25 2015 From: snafuclan at web.de (Steffen Herzfeldt) Date: Thu, 29 Oct 2015 17:14:25 +0100 Subject: python.exe is not a valid win32 executable Message-ID: An HTML attachment was scrubbed... URL: From gandalf at shopzeus.com Thu Oct 29 12:30:07 2015 From: gandalf at shopzeus.com (=?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?=) Date: Thu, 29 Oct 2015 17:30:07 +0100 Subject: How to implement an async message bus In-Reply-To: <5620C1B9.9080707@shopzeus.com> References: <561F8D2E.10600@shopzeus.com> <561FDF6C.9020405@shopzeus.com> <5620C1B9.9080707@shopzeus.com> Message-ID: <5632498F.5080304@shopzeus.com> >>>> try: >>>> return await waiter >>>> finally: >>>> # TODO: Use a context manager to add and remove the keys. >>>> for key in keys: >>>> self._waiters[key].discard(waiter) >>>> if handle: >>>> handle.cancel() >>>> >>>> def notify(self, key, message): >>>> if key in self._waiters and self._waiters[key]: >>>> waiter = next(iter(self._waiters[key])) >>>> waiter.set_result((key, message)) >>> I think this is what I needed. I'm going to try this tomorrow. >> Yes, putting aside the asyncio/tornado distinction, I think a Future >> will still solve the problem for you. > No, it won't. :-( > > Finally, I got it working, by replacing asyncio.Future with > tornado.concurrent.Future. > > At least it is consistent. But it is also missing key features. For > example, there is no tornado.concurrent.Condition. I was corrected, as follows: > asyncio.Futures depend on the asyncio event loop, so you must > configure Tornado to use the asyncio loop: > > > tornado.ioloop.IOLoop.configure('tornado.platform.asyncio.AsyncIOMainLoop') > > This could definitely use some better documentation. It would be nice > if it could fail in a more graceful way (give an error message instead > of hanging), but I'm not sure if there's any way to do that. > So tornado can be used with asyncio, but it requires configuration (and it is not yet very well documented). > Also, for your python-list message: there is now (since 4.2) a Tornado > Condition class, but it lives in tornado.locks instead of > tornado.concurrent. There is a little incosistency here, but at least there is a Condition class. I think the tornado team is trying to make tornado fully compatible with asyncio, just the are not there yet. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Oct 29 12:36:36 2015 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 30 Oct 2015 03:36:36 +1100 Subject: python.exe is not a valid win32 executable In-Reply-To: References: Message-ID: On Fri, Oct 30, 2015 at 3:14 AM, Steffen Herzfeldt wrote: > Hi, > today i downloaded python3.5.0 x86 (win32) installer. > after the programm installed the files into its standard directory without > asking me if i wanted it in a different position, i tried running a program > that was written for python 3.3.x > the response of my system was an error message "python.exe is not a valid 32 > bit executable." . > > I just wanted to let you know that your program just doesn't work on WinXP. Yes, that's correct. > I guess you just think "Linux is better anyway" to which i agree until it > comes to games requiring directx, but that doesn't change the fact that the > installer was labeled as working on win32 systems. Python 3.5 *does* work on Win32 systems that are still supported by Microsoft - specifically, Windows 7, 8, and 10, as well as the server builds that are still in support. Maintaining support for Windows XP would mean avoiding the benefit of newer APIs and other features, and the policy of the Python development team is to support only those releases of Windows which still have upstream support as of when they are released. You can use Python 3.4 and 2.7 on XP, and you can use Python 3.5 on Win 7 or better. > I hope you solve the problem. There isn't a problem to be solved, except for the one that a 12-year-old release of a closed-source operating system is still in use. Do you expect the latest Python builds to run on Windows 98SE? No. It's time to move on. Well, actually, there is one issue here, and that's that the installer goes all the way through until the very end, and then you get that cryptic error message. That's a known flaw in the installer, and once Python 3.5.1 is released, that should be fixed - but it's "fixed" in the sense that you now will get a simple and clear message, rather than being "fixed" in terms of letting you run Python 3.5 on Win XP. > keep up the good work and once Linux natively handles directx i'll dump MS > immediately. I don't know what you mean by "natively", but I play a number of DirectX games on my Debian Linux. Give it a try! You might find that it all works perfectly. ChrisA From lac at openend.se Thu Oct 29 13:14:25 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 18:14:25 +0100 Subject: python.exe is not a valid win32 executable In-Reply-To: References: Message-ID: <201510291714.t9THEPt2009109@fido.openend.se> In a message of Thu, 29 Oct 2015 17:14:25 +0100, "Steffen Herzfeldt" writes: >Hi, >today i downloaded python3.5.0 x86 (win32) installer. >after the programm installed the files into its standard directory without >asking me if i wanted it in a different position, i tried running a program >that was written for python 3.3.x >the response of my system was an error message "python.exe is not a valid >32 bit executable." . > >I just wanted to let you know that your program just doesn't work on WinXP. Thank you. We have a bug report in about detecting winXP early and saying that 3.5 requires a newer version of windows. The next installer should report this properly. >I guess you just think "Linux is better anyway" to which i agree until it >comes to games requiring directx, but that doesn't change the fact that the >installer was labeled as working on win32 systems. You are wrong about the thinking -- indeed the installer was written by a Microsoft employee, Steven Dower. He just missed having it detect winXP. >I hope you solve the problem. Alas, it is a 'won't fix' for python.org. Maybe Activestate or Continuum.io will support XP with their 3.5 packages, but python-dev is not going to. >keep up the good work and once Linux natively handles directx i'll dump MS >immediately. *oh how I wish* >with best regards, > >Steffen H. Sorry we didn't do a better job of telling you this will not work, Laura From lac at openend.se Thu Oct 29 13:22:22 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 18:22:22 +0100 Subject: python.exe is not a valid win32 executable In-Reply-To: References: Message-ID: <201510291722.t9THMMS7009842@fido.openend.se> In a message of Fri, 30 Oct 2015 03:36:36 +1100, Chris Angelico writes: >I don't know what you mean by "natively", but I play a number of >DirectX games on my Debian Linux. Give it a try! You might find that >it all works perfectly. Or, if you develop games, you might not.... http://www.pcworld.com/article/2940470/hey-gamers-directx-11-is-coming-to-linux-thanks-to-codeweavers-and-wine.html has us all crossing our fingers and waiting, waiting, anxiously waiting ... Laura From mail at timgolden.me.uk Thu Oct 29 13:28:39 2015 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 29 Oct 2015 17:28:39 +0000 Subject: python.exe is not a valid win32 executable In-Reply-To: References: Message-ID: <56325747.4020009@timgolden.me.uk> On 29/10/2015 16:14, Steffen Herzfeldt wrote: > I just wanted to let you know that your program just doesn't work on WinXP. > I guess you just think "Linux is better anyway" to which i agree until > it comes to games requiring directx, but that doesn't change the fact > that the installer was labeled as working on win32 systems. Others have replied that the installer has a fix for the next release which will highlight this sooner. I would point out that we have gradually dropped support for *several* win32-based systems over the last few years, more or less following Microsoft's own deprecation regime. Win9x was dropped in 2.6; 2000 was dropped in 3.3. There's a balance to be had in everything: every system we support adds some burden of maintenance. There's no pro-Linux conspiracy here: just the development team making pragmatic choices about maintenance and support. TJG From breamoreboy at yahoo.co.uk Thu Oct 29 13:39:34 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 29 Oct 2015 17:39:34 +0000 Subject: python.exe is not a valid win32 executable In-Reply-To: <56325747.4020009@timgolden.me.uk> References: <56325747.4020009@timgolden.me.uk> Message-ID: On 29/10/2015 17:28, Tim Golden wrote: > On 29/10/2015 16:14, Steffen Herzfeldt wrote: >> I just wanted to let you know that your program just doesn't work on >> WinXP. >> I guess you just think "Linux is better anyway" to which i agree until >> it comes to games requiring directx, but that doesn't change the fact >> that the installer was labeled as working on win32 systems. > > Others have replied that the installer has a fix for the next release > which will highlight this sooner. I would point out that we have > gradually dropped support for *several* win32-based systems over the > last few years, more or less following Microsoft's own deprecation > regime. Win9x was dropped in 2.6; 2000 was dropped in 3.3. > Specifically from https://www.python.org/dev/peps/pep-0011/#microsoft-windows, the first three paragraphs. Microsoft has established a policy called product support lifecycle [1] . Each product's lifecycle has a mainstream support phase, where the product is generally commercially available, and an extended support phase, where paid support is still available, and certain bug fixes are released (in particular security fixes). CPython's Windows support now follows this lifecycle. A new feature release X.Y.0 will support all Windows releases whose extended support phase is not yet expired. Subsequent bug fix releases will support the same Windows releases as the original feature release (even if the extended support phase has ended). Because of this policy, no further Windows releases need to be listed in this PEP. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From gvanem at yahoo.no Thu Oct 29 14:21:14 2015 From: gvanem at yahoo.no (Gisle Vanem) Date: Thu, 29 Oct 2015 19:21:14 +0100 Subject: python.exe is not a valid win32 executable In-Reply-To: References: <56325747.4020009@timgolden.me.uk> Message-ID: <5632639A.7000909@yahoo.no> Mark Lawrence wrote: > CPython's Windows support now follows this lifecycle. A new feature > release X.Y.0 will support all Windows releases whose extended support > phase is not yet expired. Subsequent bug fix releases will support the > same Windows releases as the original feature release (even if the > extended support phase has ended). The reason for error message the OP reported is what the MSVC 2015 (?) linker puts in the PE optional header. From 'pedump python3.exe': Optional Header Magic 010B linker version 14.00 ... file align 200 required OS version 6.00 << !! Hence the error on Win-XP (i.e. 5.x). Wouldn't it be more elegant of Python (and it's installer) to put a '-subsystem:console,5.02' in the link flags? And then detect Win-XP later on and refuse a further install? -- --gv From lac at openend.se Thu Oct 29 14:39:28 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 19:39:28 +0100 Subject: python.exe is not a valid win32 executable In-Reply-To: <5632639A.7000909@yahoo.no> References: <56325747.4020009@timgolden.me.uk> <5632639A.7000909@yahoo.no> Message-ID: <201510291839.t9TIdSHb015426@fido.openend.se> In a message of Thu, 29 Oct 2015 19:21:14 +0100, Gisle Vanem writes: >Wouldn't it be more elegant of Python (and it's installer) >to put a '-subsystem:console,5.02' in the link flags? >And then detect Win-XP later on and refuse a further install? > >-- >--gv >-- >https://mail.python.org/mailman/listinfo/python-list In 3.5.1 it will (already does, I think). Actually I do not know how Steve Dower chose to detect XP early, but that would be a good way. see https://bugs.python.org/issue25143 And add your idea if you like. Laura From cs at zip.com.au Thu Oct 29 17:28:07 2015 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 30 Oct 2015 08:28:07 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: <201510290815.t9T8Ftu2001920@fido.openend.se> References: <201510290815.t9T8Ftu2001920@fido.openend.se> Message-ID: <20151029212807.GA71261@cskk.homeip.net> On 29Oct2015 09:15, Laura Creighton wrote: >Did the OP say he wanted to keep his compressed logfiles on a >local disk? What if he wants to send them across the internet >to some other machine and would like the transfer to happen as >quickly as possible? Then he's still better off keeping them uncompressed and using compression in the transfer. "ssh -o compression=yes" or "rsync -z", etc. Cheers, Cameron Simpson From lac at openend.se Thu Oct 29 18:16:23 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 23:16:23 +0100 Subject: Most space-efficient way to store log entries In-Reply-To: <20151029212807.GA71261@cskk.homeip.net> References: <201510290815.t9T8Ftu2001920@fido.openend.se> <20151029212807.GA71261@cskk.homeip.net> Message-ID: <201510292216.t9TMGNqq031672@fido.openend.se> In a message of Fri, 30 Oct 2015 08:28:07 +1100, Cameron Simpson writes: >On 29Oct2015 09:15, Laura Creighton wrote: >>Did the OP say he wanted to keep his compressed logfiles on a >>local disk? What if he wants to send them across the internet >>to some other machine and would like the transfer to happen as >>quickly as possible? > >Then he's still better off keeping them uncompressed and using compression in >the transfer. "ssh -o compression=yes" or "rsync -z", etc. > >Cheers, >Cameron Simpson "ssh -o compression=yes" is what I am using. But I am all ears for a better idea. We can do no better? Laura From cs at zip.com.au Thu Oct 29 18:47:42 2015 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 30 Oct 2015 09:47:42 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: <201510292216.t9TMGNqq031672@fido.openend.se> References: <201510292216.t9TMGNqq031672@fido.openend.se> Message-ID: <20151029224742.GA18223@cskk.homeip.net> On 29Oct2015 23:16, Laura Creighton wrote: >In a message of Fri, 30 Oct 2015 08:28:07 +1100, Cameron Simpson writes: >>On 29Oct2015 09:15, Laura Creighton wrote: >>>Did the OP say he wanted to keep his compressed logfiles on a >>>local disk? What if he wants to send them across the internet >>>to some other machine and would like the transfer to happen as >>>quickly as possible? >> >>Then he's still better off keeping them uncompressed and using compression in >>the transfer. "ssh -o compression=yes" or "rsync -z", etc. >> >>Cheers, >>Cameron Simpson > >"ssh -o compression=yes" is what I am using. >But I am all ears for a better idea. > >We can do no better? Depends on your criteria for "better". Absent other constraints I'm broadly for: keeping logs uncompressed and unencoded, for ease of eyeballing and processing with text tools rotating and compressing logs if feasible avoiding compression and other encoding within log lines Another post suggests that the OP is transferring log info in UDP packets and hopes to keep the state within a maximum packet size, hence his desire for compact representation. I suspect that personally I'd be going for some efficient text encoding of the state and putting whatever compression he intends in the UDP throw/catch: take text log line compress send over UDP receive UDP packet decompress store in clear text or bypass UDP altogether, but I imagine the OP has his reasons. Cheers, Cameron Simpson From lac at openend.se Thu Oct 29 18:57:03 2015 From: lac at openend.se (Laura Creighton) Date: Thu, 29 Oct 2015 23:57:03 +0100 Subject: Most space-efficient way to store log entries In-Reply-To: <20151029224742.GA18223@cskk.homeip.net> References: <201510292216.t9TMGNqq031672@fido.openend.se> <20151029224742.GA18223@cskk.homeip.net> Message-ID: <201510292257.t9TMv31B002333@fido.openend.se> In a message of Fri, 30 Oct 2015 09:47:42 +1100, Cameron Simpson writes: >Another post suggests that the OP is transferring log info in UDP packets and >hopes to keep the state within a maximum packet size, hence his desire for >compact representation. I suspect that personally I'd be going for some >efficient text encoding of the state and putting whatever compression he >intends in the UDP throw/catch: > > take text log line > compress > send over UDP > receive UDP packet > decompress > store in clear text > >or bypass UDP altogether, but I imagine the OP has his reasons. I'd bypass UDP altogether. But in terms of my problem ssh -o compression=yes Can we get my files over faster? This is plenty fast enough for our nightly (Should the americans nuke us, we can get the kayaking club up ok) transfer out of country. :) I have never worried of if before. But, efficiency for its own sake. Way useless, but way cool. can I get my files out faster? Laura From glicerinu at gmail.com Thu Oct 29 19:35:30 2015 From: glicerinu at gmail.com (Marc Aymerich) Date: Fri, 30 Oct 2015 00:35:30 +0100 Subject: Most space-efficient way to store log entries In-Reply-To: <201510292257.t9TMv31B002333@fido.openend.se> References: <201510292216.t9TMGNqq031672@fido.openend.se> <20151029224742.GA18223@cskk.homeip.net> <201510292257.t9TMv31B002333@fido.openend.se> Message-ID: On Thu, Oct 29, 2015 at 11:57 PM, Laura Creighton wrote: > In a message of Fri, 30 Oct 2015 09:47:42 +1100, Cameron Simpson writes: >>Another post suggests that the OP is transferring log info in UDP packets and >>hopes to keep the state within a maximum packet size, hence his desire for >>compact representation. I suspect that personally I'd be going for some >>efficient text encoding of the state and putting whatever compression he >>intends in the UDP throw/catch: >> >> take text log line >> compress >> send over UDP >> receive UDP packet >> decompress >> store in clear text >> >>or bypass UDP altogether, but I imagine the OP has his reasons. > > I'd bypass UDP altogether. > > But in terms of my problem > > ssh -o compression=yes > > Can we get my files over faster? > > This is plenty fast enough for our nightly > (Should the americans nuke us, we can get the > kayaking club up ok) transfer out of country. :) > > I have never worried of if before. > > But, efficiency for its own sake. > Way useless, but way cool. > > can I get my files out faster? Usually I use my home router (which has an attached HDD) for downloading movies and stuff (big files) from the WAN... it has a 800Mhz mips cpu... anyway my experience with it is that: rsync tops at ~400Kbps apache+wget tops at ~1.1Mbps netcat tops at ~1.4Mbps -- Marc From tjreedy at udel.edu Thu Oct 29 20:46:40 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 29 Oct 2015 20:46:40 -0400 Subject: python.exe is not a valid win32 executable In-Reply-To: <201510291714.t9THEPt2009109@fido.openend.se> References: <201510291714.t9THEPt2009109@fido.openend.se> Message-ID: On 10/29/2015 1:14 PM, Laura Creighton wrote: > Alas, it is a 'won't fix' for python.org. Maybe Activestate or > Continuum.io will support XP with their 3.5 packages, It would be an unpleasant task at best. CPython does not work with xp because is uses shiny new system features that first appeared in Vista. Either they were not used before, or the code contained version-based conditions to either use the new feature or use an inferior workaround. Suppose you want to use 'yield from' in a 3.x module. You have 3 choices: 1. don't use it; 2. use it conditionally and also provide a workaround based on 'yield'; 3. use it and as a consequence, require 3.4+. By analogy, the cpython developers felt constrained to use options 1 or 2, both of which have their costs, and support xp for as long as Microsoft supported xp. When Microsoft dropped support for xp, they felt free to switch to option 3 *for new versions*. I don't know if there are any new-in-win7 features that coredevs are just waiting to use when Vista goes off MS support. -- Terry Jan Reedy From cs at zip.com.au Thu Oct 29 22:33:48 2015 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 30 Oct 2015 13:33:48 +1100 Subject: Most space-efficient way to store log entries In-Reply-To: References: Message-ID: <20151030023348.GA78993@cskk.homeip.net> On 30Oct2015 00:35, Marc Aymerich wrote: >Usually I use my home router (which has an attached HDD) for >downloading movies and stuff (big files) from the WAN... it has a >800Mhz mips cpu... anyway my experience with it is that: > >rsync tops at ~400Kbps Rsync is not a maximally efficient file transfer tool. What it excels at is incremental transfer, when you have some of a set of files, or a portion of a file you need to extend, such as updating a copy of a growing log file. >apache+wget tops at ~1.1Mbps >netcat tops at ~1.4Mbps You might also try scp or sftp. On a LAN or if one endpoint is CPU constrained (probably the data source) you may find that compression is actually a lose. If your source data is already low redundancy (video, many audio formats, most image data, already compressed files like .gz or .zip) then compression is definitely a lose. Finally, on a LAN you may be able to mount one end or the other as a remote filesystem. Then you can benchmark plain old "cp" over SMB or NFS etc. Cheers, Cameron Simpson From breamoreboy at yahoo.co.uk Fri Oct 30 00:16:50 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 30 Oct 2015 04:16:50 +0000 Subject: Windows 10 pip2.7.exe uninstall fails In-Reply-To: <5630BE0E.40009@chamonix.reportlab.co.uk> References: <5630BE0E.40009@chamonix.reportlab.co.uk> Message-ID: On 28/10/2015 12:22, Robin Becker wrote: > ........ >> A message box is displayed:- >> >> "This app can't run on your PC >> To find a version for your PC, check with the software publisher". >> >> Close the message box and:- >> >> "Access is denied." >> >> Searching hasn't thrown up a single reference to uninstall errors like >> this, any >> ideas? >> > so perhaps yours is an exceptional case pip.exe and pip2.exe 96kb, pip2.7.exe 0kb might explain things. Please don't ask, I don't know :( -- 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 Oct 30 08:14:24 2015 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 30 Oct 2015 08:14:24 -0400 Subject: pip trouble Message-ID: I have a custom-compiled numpy 1.10.0. But as you see, pip wants to install a new numpy, even though the requirement (numpy>=1.6) was already satisfied. WTF? All are installed into --user. This is on fedora 22 linux. pip install --up --user matplotlib Collecting matplotlib Using cached matplotlib-1.5.0.tar.gz Collecting numpy>=1.6 (from matplotlib) Using cached numpy-1.10.1.tar.gz Requirement already up-to-date: python-dateutil in ./.local/lib/python2.7/site-packages (from matplotlib) Collecting pytz (from matplotlib) Using cached pytz-2015.7-py2.py3-none-any.whl Collecting cycler (from matplotlib) Using cached cycler-0.9.0-py2.py3-none-any.whl Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib) Using cached pyparsing-2.0.5-py2.py3-none-any.whl Collecting six>=1.5 (from python-dateutil->matplotlib) Using cached six-1.10.0-py2.py3-none-any.whl Installing collected packages: numpy, pytz, six, cycler, pyparsing, matplotlib Found existing installation: numpy 1.10.0 DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Uninstalling numpy-1.10.0: Successfully uninstalled numpy-1.10.0 Running setup.py install for numpy From josephineewers at yahoo.com Fri Oct 30 10:53:35 2015 From: josephineewers at yahoo.com (josephine ewers) Date: Fri, 30 Oct 2015 14:53:35 +0000 (UTC) Subject: problems using python in PowerShell References: <58590053.215822.1446216815274.JavaMail.yahoo@mail.yahoo.com> Message-ID: <58590053.215822.1446216815274.JavaMail.yahoo@mail.yahoo.com> Hi,I am doing an online training course to learn python but when I enter 'python' in Microsoft PowerShell as I am supposed to do I always get an error message. Best regards,Josephine -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Fri Oct 30 11:09:27 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2015 02:09:27 +1100 Subject: problems using python in PowerShell In-Reply-To: <58590053.215822.1446216815274.JavaMail.yahoo@mail.yahoo.com> References: <58590053.215822.1446216815274.JavaMail.yahoo@mail.yahoo.com> <58590053.215822.1446216815274.JavaMail.yahoo@mail.yahoo.com> Message-ID: On Sat, Oct 31, 2015 at 1:53 AM, josephine ewers via Python-list wrote: > Hi, > I am doing an online training course to learn python but when I enter > 'python' in Microsoft PowerShell as I am supposed to do I always get an > error message. What error message, exactly? Is Python installed? Which Python is installed? What OS are you running? What is your $PATH (or %PATH%)? We can't help you with no information. ChrisA From motoom at xs4all.nl Fri Oct 30 11:21:30 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Fri, 30 Oct 2015 16:21:30 +0100 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> <201510290753.t9T7rZqR032272@fido.openend.se> Message-ID: <5A7F323C-ED4A-4CCA-A392-2C6F64EA6A6F@xs4all.nl> Hi, Laura wrote: > I think that it would be useful if IDLE spit out a warning An ounce of prevention is worth a pound of cure. Maybe it's an idea that IDLE gives a warning when you're trying to save a file with a name that would shadow an existing module? Greetings, From RobinsW1 at sutterhealth.org Fri Oct 30 12:20:23 2015 From: RobinsW1 at sutterhealth.org (Robinson, Wendy) Date: Fri, 30 Oct 2015 09:20:23 -0700 Subject: Puzzled Message-ID: <4CFEDC132D44AC49BA0E91FBEB947119084A742852@DCBL123VX.root.sutterhealth.org> Hi there, I installed Python 3.5.0 64-bit for Windows yesterday and tried some basic programs successfully. This morning I rebooted my computer and can't get a single one to work. The interpreter seems to be fine and the environment variables look correct. But every py file I try to run at the >>> prompt gives me a NameError. I tried running the Repair installation, but that did not help. Any suggestions? Thank you Wendy Robinson Audit Analyst (916) 566-4994 phone [cid:image001.jpg at 01D112F4.341BC390] NOTICE OF CONFIDENTIALITY: This email is for the sole use of the intended recipient and may contain material that is confidential and protected by state and federal regulations. If you are not the intended recipient please immediately delete it and contact the sender. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 3699 bytes Desc: image001.jpg URL: From rahimi.nv at gmail.com Fri Oct 30 12:22:37 2015 From: rahimi.nv at gmail.com (navid Rahimi) Date: Fri, 30 Oct 2015 19:52:37 +0330 Subject: problems using python in PowerShell In-Reply-To: References: <58590053.215822.1446216815274.JavaMail.yahoo@mail.yahoo.com> Message-ID: What error message do you get exactly ? without error message how people gonna know what is going on? best wishes, -navid On Fri, Oct 30, 2015 at 6:39 PM, Chris Angelico wrote: > On Sat, Oct 31, 2015 at 1:53 AM, josephine ewers via Python-list > wrote: >> Hi, >> I am doing an online training course to learn python but when I enter >> 'python' in Microsoft PowerShell as I am supposed to do I always get an >> error message. > > What error message, exactly? > > Is Python installed? Which Python is installed? What OS are you > running? What is your $PATH (or %PATH%)? We can't help you with no > information. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From lac at openend.se Fri Oct 30 12:29:34 2015 From: lac at openend.se (Laura Creighton) Date: Fri, 30 Oct 2015 17:29:34 +0100 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: <5A7F323C-ED4A-4CCA-A392-2C6F64EA6A6F@xs4all.nl> References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> <201510290753.t9T7rZqR032272@fido.openend.se> <5A7F323C-ED4A-4CCA-A392-2C6F64EA6A6F@xs4all.nl> Message-ID: <201510301629.t9UGTY2i013568@fido.openend.se> In a message of Fri, 30 Oct 2015 16:21:30 +0100, Michiel Overtoom writes: >Hi, > >Laura wrote: >> I think that it would be useful if IDLE spit out a warning > >An ounce of prevention is worth a pound of cure. Maybe it's an idea that IDLE gives a warning when you're trying to save a file with a name that would shadow an existing module? > >Greetings, You might want to add that idea here: https://bugs.python.org/issue25514 Laura From kwpolska at gmail.com Fri Oct 30 12:38:25 2015 From: kwpolska at gmail.com (Chris Warrick) Date: Fri, 30 Oct 2015 17:38:25 +0100 Subject: pip trouble In-Reply-To: References: Message-ID: On 30 October 2015 at 13:14, Neal Becker wrote: > I have a custom-compiled numpy 1.10.0. But as you see, pip wants to install > a new numpy, even though the requirement (numpy>=1.6) was already satisfied. > WTF? > > All are installed into --user. > > This is on fedora 22 linux. > > pip install --up --user matplotlib > Collecting matplotlib > Using cached matplotlib-1.5.0.tar.gz > Collecting numpy>=1.6 (from matplotlib) > Using cached numpy-1.10.1.tar.gz > Requirement already up-to-date: python-dateutil in > ./.local/lib/python2.7/site-packages (from matplotlib) > Collecting pytz (from matplotlib) > Using cached pytz-2015.7-py2.py3-none-any.whl > Collecting cycler (from matplotlib) > Using cached cycler-0.9.0-py2.py3-none-any.whl > Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib) > Using cached pyparsing-2.0.5-py2.py3-none-any.whl > Collecting six>=1.5 (from python-dateutil->matplotlib) > Using cached six-1.10.0-py2.py3-none-any.whl > Installing collected packages: numpy, pytz, six, cycler, pyparsing, > matplotlib > Found existing installation: numpy 1.10.0 > DEPRECATION: Uninstalling a distutils installed project (numpy) has been > deprecated and will be removed in a future version. This is due to the fact > that uninstalling a distutils project will only partially uninstall the > project. > Uninstalling numpy-1.10.0: > Successfully uninstalled numpy-1.10.0 > Running setup.py install for numpy > > -- > https://mail.python.org/mailman/listinfo/python-list You used --up (aka -U, --upgrade). That option tries to upgrade the package you asked for *and* all dependencies. And since numpy 1.10.1 is newer than what you have installed, pip will try to install that. -- Chris Warrick PGP: 5EAAEA16 From ndbecker2 at gmail.com Fri Oct 30 13:45:15 2015 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 30 Oct 2015 13:45:15 -0400 Subject: pip trouble References: Message-ID: Chris Warrick wrote: > On 30 October 2015 at 13:14, Neal Becker wrote: >> I have a custom-compiled numpy 1.10.0. But as you see, pip wants to >> install a new numpy, even though the requirement (numpy>=1.6) was already >> satisfied. WTF? >> >> All are installed into --user. >> >> This is on fedora 22 linux. >> >> pip install --up --user matplotlib >> Collecting matplotlib >> Using cached matplotlib-1.5.0.tar.gz >> Collecting numpy>=1.6 (from matplotlib) >> Using cached numpy-1.10.1.tar.gz >> Requirement already up-to-date: python-dateutil in >> ./.local/lib/python2.7/site-packages (from matplotlib) >> Collecting pytz (from matplotlib) >> Using cached pytz-2015.7-py2.py3-none-any.whl >> Collecting cycler (from matplotlib) >> Using cached cycler-0.9.0-py2.py3-none-any.whl >> Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib) >> Using cached pyparsing-2.0.5-py2.py3-none-any.whl >> Collecting six>=1.5 (from python-dateutil->matplotlib) >> Using cached six-1.10.0-py2.py3-none-any.whl >> Installing collected packages: numpy, pytz, six, cycler, pyparsing, >> matplotlib >> Found existing installation: numpy 1.10.0 >> DEPRECATION: Uninstalling a distutils installed project (numpy) has >> been >> deprecated and will be removed in a future version. This is due to the >> fact that uninstalling a distutils project will only partially uninstall >> the project. >> Uninstalling numpy-1.10.0: >> Successfully uninstalled numpy-1.10.0 >> Running setup.py install for numpy >> >> -- >> https://mail.python.org/mailman/listinfo/python-list > > You used --up (aka -U, --upgrade). That option tries to upgrade the > package you asked for *and* all dependencies. And since numpy 1.10.1 > is newer than what you have installed, pip will try to install that. > How can I ask to upgrade just matplotlib, and not deps? From rosuav at gmail.com Fri Oct 30 18:00:26 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2015 09:00:26 +1100 Subject: pip trouble In-Reply-To: References: Message-ID: On Sat, Oct 31, 2015 at 4:45 AM, Neal Becker wrote: > How can I ask to upgrade just matplotlib, and not deps? Unconfirmed, but can you say: pip install --up --user matplotlib numpy==1.10.0 ? That should bind to an exact version. ChrisA From breamoreboy at yahoo.co.uk Fri Oct 30 19:27:52 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 30 Oct 2015 23:27:52 +0000 Subject: pip trouble In-Reply-To: References: Message-ID: On 30/10/2015 17:45, Neal Becker wrote: > Chris Warrick wrote: > >> On 30 October 2015 at 13:14, Neal Becker wrote: >>> I have a custom-compiled numpy 1.10.0. But as you see, pip wants to >>> install a new numpy, even though the requirement (numpy>=1.6) was already >>> satisfied. WTF? >>> >>> All are installed into --user. >>> >>> This is on fedora 22 linux. >>> >>> pip install --up --user matplotlib >>> Collecting matplotlib >>> Using cached matplotlib-1.5.0.tar.gz >>> Collecting numpy>=1.6 (from matplotlib) >>> Using cached numpy-1.10.1.tar.gz >>> Requirement already up-to-date: python-dateutil in >>> ./.local/lib/python2.7/site-packages (from matplotlib) >>> Collecting pytz (from matplotlib) >>> Using cached pytz-2015.7-py2.py3-none-any.whl >>> Collecting cycler (from matplotlib) >>> Using cached cycler-0.9.0-py2.py3-none-any.whl >>> Collecting pyparsing!=2.0.4,>=1.5.6 (from matplotlib) >>> Using cached pyparsing-2.0.5-py2.py3-none-any.whl >>> Collecting six>=1.5 (from python-dateutil->matplotlib) >>> Using cached six-1.10.0-py2.py3-none-any.whl >>> Installing collected packages: numpy, pytz, six, cycler, pyparsing, >>> matplotlib >>> Found existing installation: numpy 1.10.0 >>> DEPRECATION: Uninstalling a distutils installed project (numpy) has >>> been >>> deprecated and will be removed in a future version. This is due to the >>> fact that uninstalling a distutils project will only partially uninstall >>> the project. >>> Uninstalling numpy-1.10.0: >>> Successfully uninstalled numpy-1.10.0 >>> Running setup.py install for numpy >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >> >> You used --up (aka -U, --upgrade). That option tries to upgrade the >> package you asked for *and* all dependencies. And since numpy 1.10.1 >> is newer than what you have installed, pip will try to install that. >> > > How can I ask to upgrade just matplotlib, and not deps? > Try https://pip.readthedocs.org/en/stable/reference/pip_install/ or "pip install --help" -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From random832 at fastmail.com Fri Oct 30 20:39:43 2015 From: random832 at fastmail.com (Random832) Date: Fri, 30 Oct 2015 20:39:43 -0400 Subject: problems using python in PowerShell References: <58590053.215822.1446216815274.JavaMail.yahoo@mail.yahoo.com> <58590053.215822.1446216815274.JavaMail.yahoo@mail.yahoo.com> <88183bdosufbpmj5597e38ahorf4bmpa76@4ax.com> Message-ID: <874mh7rhv4.fsf@fastmail.com> Dennis Lee Bieber writes: > On Sat, 31 Oct 2015 02:09:27 +1100, Chris Angelico >>On Sat, Oct 31, 2015 at 1:53 AM, josephine ewers via Python-list >>> Hi, >>> I am doing an online training course to learn python but when I enter >>> 'python' in Microsoft PowerShell as I am supposed to do I always get an >>> error message. >> >>What error message, exactly? >> >>Is Python installed? Which Python is installed? What OS are you >>running? What is your $PATH (or %PATH%)? We can't help you with no >>information. >> > I'd add: is the behavior the same if using the regular Windows > "command > prompt" instead of PowerShell? PowerShell tends to have lots of security > aspects that prevent some things from running unless the security level has > been changed. Also, is this on the console PowerShell or PowerShell ISE? From tjreedy at udel.edu Fri Oct 30 21:15:08 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 30 Oct 2015 21:15:08 -0400 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: <201510301629.t9UGTY2i013568@fido.openend.se> References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> <201510290753.t9T7rZqR032272@fido.openend.se> <5A7F323C-ED4A-4CCA-A392-2C6F64EA6A6F@xs4all.nl> <201510301629.t9UGTY2i013568@fido.openend.se> Message-ID: On 10/30/2015 12:29 PM, Laura Creighton wrote: > In a message of Fri, 30 Oct 2015 16:21:30 +0100, Michiel Overtoom writes: >> Hi, >> >> Laura wrote: >>> I think that it would be useful if IDLE spit out a warning >> >> An ounce of prevention is worth a pound of cure. Maybe it's an idea that IDLE gives a warning when you're trying to save a file with a name that would shadow an existing module? > You might want to add that idea here: > https://bugs.python.org/issue25514 A warning requires a list to check against. I just suggested on python-ideas the addition of a 'module' module, similar to the 'keyword' module, that would have the needed lists and functions. Support for the idea (on python-ideas list) is welcome. -- Terry Jan Reedy From steve at pearwood.info Fri Oct 30 21:16:08 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sat, 31 Oct 2015 12:16:08 +1100 Subject: [ANN] Python 3 Cheat Sheet v2.0 References: <5633cb68$0$21247$426a74cc@news.free.fr> Message-ID: <56341659$0$1587$c3e8da3$5496439d@news.astraweb.com> On Sat, 31 Oct 2015 06:56 am, Laurent Pointal wrote: > Hello, > > I just updated my one recto-verso sheet Python 3 Cheat Sheet > > https://perso.limsi.fr/pointal/python:memento Very nice! Thank you! Some small typos in the English version: Page 2, Conditional loop statement: "? be careful of inifinite loops !" Should be "infinite". Remove space between "loops" and exclamation mark. Page 2, Display/Input: "items to display: litteral values, variables, expressions" Should be "literal". Page 2, Strings formatting: "Conversion: s (readable text) or r (litteral representation)" Should be "literal". Some errors of fact: Page 2, Generator of int sequences: "range returns a ?generator?" This is not correct, `range` returns a lazy immutable sequence where the values are constructed as needed, not in advance. https://docs.python.org/3/library/functions.html#func-range Page 2, Files: "text file ? read/write only strings, convert from/to required type" While that is true for text files, it implies that open() always uses text files. This is not correct. You can open binary files too, and read/write raw bytes: https://docs.python.org/3/library/functions.html#open https://docs.python.org/3/glossary.html#term-binary-file -- Steven From steve at pearwood.info Fri Oct 30 21:28:35 2015 From: steve at pearwood.info (Steven D'Aprano) Date: Sat, 31 Oct 2015 12:28:35 +1100 Subject: Unittests and serial workflows References: Message-ID: <56341944$0$1619$c3e8da3$5496439d@news.astraweb.com> On Tue, 27 Oct 2015 03:10 pm, Fabien wrote: > Hi all, > > I am not trained as a software developer and have only superficial > knowledge about the theories and good practices of software testing. > > Say I have several tasks (functions) A(), B(), C(), etc., each of them > depending on the previous one. My understanding of unit testing is that > each function should be tested alone and each test should be > independent, Yes, that's the standard definition of unit testing. However, unit testing frameworks are often perfectly well suited to other forms of tests, like regression tests, integration tests, and others. Sometimes it is perfectly reasonable to write a test which, strictly speaking, doesn't fall under the unit test definition. > so that currently my tests look like this: > > class TestTasks(unittest.TestCase): > > def test_a(self): > out = A() > self.assertStuffs(out) > > def test_b(self): > tmp = A() > out = B(tmp) > self.assertStuffs(out) That's fine and meets the definition of a unit tests. Unit tests are allowed to assume that other components of the module are working. In test_b, you assume that A() is working correctly, and test B(). If A() is not in fact working correctly, then the test may be invalid, or a bug in A() may cause cascading failures: test_a will hopefully fail, and test_b then fail as well. Sometimes you want to avoid such cascading failures. To do that, rather than call A() inside test_b, you create a simulation of A(), or hard-code a value that could have been generated by A(). Such things are often called mocks and stubs. Something like this perhaps: def test_a(self): out = A() self.assertEqual(out, (1, 2, 3, 4)) def test_b(self): tmp = (1, 2, 3, 4) out = B(tmp) self.assertStuffs(out) Now, even if A() is buggy and returns something invalid, the argument to B() is fine and you can test B() in isolation to A(). > And so forth. The order in which unittest is running the test is not the > one given by the code (it seems to be alphabetical?) so that I am not > guaranteed that my functions are tested in the right order (my real > tasks of course are not sorted alphabetically). In my opinion, if your unit tests need to be run in a specific order, they aren't sufficiently isolated. But, I accept that sometimes reality bites, and you have to deal with tests which aren't sufficiently isolated. You don't have time to fix the tests, and you can't fix the code you're testing. Sucks to be you... It's times like that you want to use a *subclass* of unittest which gives you a predictable order. Have fun writing one :-) > Furthermore, it is inefficient since task A() is going to be run many > times. You shouldn't care (too much) about the efficiency of tests. You don't want them to be *horribly* inefficient, of course, but it it takes 30 seconds to run the tests, who cares? Even a minute or so is no big deal. A big test suite like that for Python itself, with dozens of modules to be tested, might take ten minutes to run, just long enough for you to stretch your legs, get the cobwebs out of your brain, and make a coffee. Of course you need the ability to run individual test suites, for those rapid debug/run tests/debug cycles. But don't worry about optimizing each test. That's a waste of time, and likely to introduce bugs into the tests themselves. Write your tests in the simplest, most fool-proof way you can, and don't be too clever. > Of course I could run all the tasks once, store the results and > run my tests afterwards one by one but this contradicts somehow the idea > of unit testing. And I like to be able to run each test alone (in > PyCharm a mouse click alone starts a single test). > > My question(s): is Unittest the "right" framework for my needs? Should I > move to Nosetests? Any hint to a useful, not too long document about > testing framework and good practices? http://thedailywtf.com/articles/Testing-Done-Right And of course, read the Daily WTF for plenty of examples of what not to do. They have plenty of examples of bad testing. -- Steven From rosuav at gmail.com Fri Oct 30 21:46:53 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 31 Oct 2015 12:46:53 +1100 Subject: Unittests and serial workflows In-Reply-To: <56341944$0$1619$c3e8da3$5496439d@news.astraweb.com> References: <56341944$0$1619$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Oct 31, 2015 at 12:28 PM, Steven D'Aprano wrote: >> And so forth. The order in which unittest is running the test is not the >> one given by the code (it seems to be alphabetical?) so that I am not >> guaranteed that my functions are tested in the right order (my real >> tasks of course are not sorted alphabetically). > > In my opinion, if your unit tests need to be run in a specific order, they > aren't sufficiently isolated. But, I accept that sometimes reality bites, > and you have to deal with tests which aren't sufficiently isolated. You > don't have time to fix the tests, and you can't fix the code you're > testing. Sucks to be you... If the order of test execution affects the overall pass/fail of the test set, then yes, that's a problem. But if, as in the OP's example, some tests assume the correct operation of features tested individually elsewhere, it would be kinda nice to say "do these low-level tests first, and if they pass, go on to test these higher-level features". Is there a way to express that in unittest? ChrisA From tjreedy at udel.edu Sat Oct 31 01:59:36 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 31 Oct 2015 01:59:36 -0400 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> <201510290753.t9T7rZqR032272@fido.openend.se> <5A7F323C-ED4A-4CCA-A392-2C6F64EA6A6F@xs4all.nl> <201510301629.t9UGTY2i013568@fido.openend.se> Message-ID: On 10/30/2015 9:15 PM, Terry Reedy wrote: > On 10/30/2015 12:29 PM, Laura Creighton wrote: >> In a message of Fri, 30 Oct 2015 16:21:30 +0100, Michiel Overtoom writes: >>> Hi, >>> >>> Laura wrote: >>>> I think that it would be useful if IDLE spit out a warning >>> >>> An ounce of prevention is worth a pound of cure. Maybe it's an idea >>> that IDLE gives a warning when you're trying to save a file with a >>> name that would shadow an existing module? > >> You might want to add that idea here: >> https://bugs.python.org/issue25514 This is a different issue than IDLE avoiding clashes. I opened https://bugs.python.org/issue25522 > A warning requires a list to check against. I just suggested on > python-ideas the addition of a 'module' module, similar to the 'keyword' > module, that would have the needed lists and functions. Guido pointed me to sys.builtin_module_names, which is needed for the issue above. -- Terry Jan Reedy From lac at openend.se Sat Oct 31 02:42:55 2015 From: lac at openend.se (Laura Creighton) Date: Sat, 31 Oct 2015 07:42:55 +0100 Subject: Unittests and serial workflows In-Reply-To: References: <56341944$0$1619$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201510310642.t9V6gtTt012035@fido.openend.se> In a message of Sat, 31 Oct 2015 12:46:53 +1100, Chris Angelico writes: >If the order of test execution affects the overall pass/fail of the >test set, then yes, that's a problem. But if, as in the OP's example, >some tests assume the correct operation of features tested >individually elsewhere, it would be kinda nice to say "do these >low-level tests first, and if they pass, go on to test these >higher-level features". Is there a way to express that in unittest? > >ChrisA >-- >https://mail.python.org/mailman/listinfo/python-list I know how to do this with pytest http://pytest.org/dev/example/parametrize.html#a-quick-port-of-testscenarios Since this is a port of something Robert Collins wrote for unittest, I am pretty sure you can do it there, as well, but I haven't researched the how. Laura From input/ldompeling at casema.nl Sat Oct 31 06:28:46 2015 From: input/ldompeling at casema.nl (input/ldompeling at casema.nl) Date: Sat, 31 Oct 2015 10:28:46 GMT Subject: GoPiGo script References: <105057e9-3747-4f25-bda7-336f0cafa510@googlegroups.com> Message-ID: I intended the rules under while True: The script is working now only the wheels go's only forward "(fwd)",so the sensor not detect any obstacles.(sensor=us_dist(15). ------------------------------------------------------------------------------- from gopigo import * import time set_right_speed(150) set_left_speed(105) while True: #def test(): enable_servo() mindist = 80 servo(90) fwd() print ("forward1x") #time.sleep(5) #stop() if mindist > us_dist(15): #enc_tgt(1,1,72) bwd() print ("backward1x",us_dist(15)) time.sleep(2) left_rot() print("left rot",us_dist(15)) time.sleep(3) stop() if mindist < us_dist(15): #enc_tgt(1,1,72) fwd() print("forward2x",us_dist(15)) time.sleep(2) stop() for x in range(3): if mindist > us_dist(15): bwd() print("backward2x",us_dist(15)) In reply to "hakugin.gin at gmail.com" who wrote the following: > On Friday, October 30, 2015 at 2:19:21 PM UTC-4, input/ld... at casema.nl wrot= > e: > > Thank you or the reply. > > This is the errorwith while True: > > =20 > > File "test03.py", line 10 > > enable_servo() > > =20 > > =20 > > In reply to "haku... at gmail.com" who wrote the following: > > =20 > > > On Friday, October 30, 2015 at 12:58:43 PM UTC-4, input/ld... at casema.nl= > =20 > > wrote: > > > > The GoPiGo is a little robot on wheels. > > > > =20 > > > > > > enable_servo() > > > If it is returning an error with "enable_servo()" then there are a few poss= > ible causes. I would make sure everything is indented correctly, as well as= > check and ensure the function is in the gopigo library. Those would be the= > 2 most likely causes. As for the issue with the while loop, I would defini= > tely follow Peter's advice. I started to create a small example script but = > found that what I classify as simple may not be as simple for others, but I= > will do my best to get something done over the weekend if you haven't foun= > d a solution by Monday. -- --------------------------------- --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From laurent.pointal at free.fr Sat Oct 31 12:20:22 2015 From: laurent.pointal at free.fr (Laurent Pointal) Date: 31 Oct 2015 16:20:22 GMT Subject: [ANN] Python 3 Cheat Sheet v2.0 References: <5633cb68$0$21247$426a74cc@news.free.fr> <56341659$0$1587$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5634ea46$0$3195$426a74cc@news.free.fr> Le Sat, 31 Oct 2015 12:16:08 +1100, Steven D'Aprano a ?crit?: > On Sat, 31 Oct 2015 06:56 am, Laurent Pointal wrote: >> https://perso.limsi.fr/pointal/python:memento > > > Very nice! Thank you! > > > Some small typos in the English version: Thanks for your comments. Q? Did you read version 1.2.2 or version 2.0 ? Some typos propagate between versions (I fixed the "litteral"s), but I modified some parts (ex. for while loops the warning become "beware of infinite loops !" [I still have a space to remove before ! french/english typo differences] > Some errors of fact: > > Page 2, Generator of int sequences: > > "range returns a ?generator?" > > This is not correct, `range` returns a lazy immutable sequence where the > values are constructed as needed, not in advance. > > https://docs.python.org/3/library/functions.html#func-range Now (v2.0) range is presented as an integer sequence - without detail, dont know if beginners understand 'lasy' in our meaning. > Page 2, Files: > > "text file ? read/write only strings, convert from/to required type" > > While that is true for text files, it implies that open() always uses > text files. This is not correct. You can open binary files too, and > read/write raw bytes: > > https://docs.python.org/3/library/functions.html#open > https://docs.python.org/3/glossary.html#term-binary-file Our students mainly work with text files, they have to convert all other values to str before writing. Its hard to be more complete within the remaining space. I'll see if I can add a small sentence about "text by default but can be binary with bytes content" Thanks. A+ Laurent. From python at mrabarnett.plus.com Sat Oct 31 13:42:04 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 31 Oct 2015 17:42:04 +0000 Subject: GoPiGo script In-Reply-To: References: <105057e9-3747-4f25-bda7-336f0cafa510@googlegroups.com> Message-ID: <5634FD6C.3020502@mrabarnett.plus.com> On 2015-10-31 10:28, input/ldompeling at casema.nl wrote: > I intended the rules under while True: > The script is working now only the wheels go's only forward "(fwd)",so the > sensor not detect any obstacles.(sensor=us_dist(15). > > ------------------------------------------------------------------------------- > > from gopigo import * > import time > > > set_right_speed(150) > set_left_speed(105) > The body of the 'while' loop extends from the line: enable_servo() to the line: print ("forward1x") Would that explain it? > while True: > #def test(): > enable_servo() > mindist = 80 > servo(90) > fwd() > print ("forward1x") > #time.sleep(5) > #stop() > > if mindist > us_dist(15): > #enc_tgt(1,1,72) > bwd() > print ("backward1x",us_dist(15)) > time.sleep(2) > left_rot() > print("left rot",us_dist(15)) > time.sleep(3) > stop() > > if mindist < us_dist(15): > #enc_tgt(1,1,72) > fwd() > print("forward2x",us_dist(15)) > time.sleep(2) > stop() > > for x in range(3): > > if mindist > us_dist(15): > bwd() > print("backward2x",us_dist(15)) > From input/ldompeling at casema.nl Sat Oct 31 14:59:31 2015 From: input/ldompeling at casema.nl (input/ldompeling at casema.nl) Date: Sat, 31 Oct 2015 18:59:31 GMT Subject: GoPiGo script References: Message-ID: > The body of the 'while' loop extends from the line: > > enable_servo() > > to the line: > > print ("forward1x") > > Would that explain it? When i run this scipt its only print a lot off print1x. Do you mean that ? Thanks In reply to "MRAB" who wrote the following: > On 2015-10-31 10:28, input/ldompeling at casema.nl wrote: > > I intended the rules under while True: > > The script is working now only the wheels go's only forward "(fwd)",so the > > sensor not detect any obstacles.(sensor=us_dist(15). > > > > ---------------------------------------------------------------------------- > > --- > > > > from gopigo import * > > import time > > > > > > set_right_speed(150) > > set_left_speed(105) > > > The body of the 'while' loop extends from the line: > > enable_servo() > > to the line: > > print ("forward1x") > > Would that explain it? > > > while True: > > #def test(): > > enable_servo() > > mindist = 80 > > servo(90) > > fwd() > > print ("forward1x") > > #time.sleep(5) > > #stop() > > > > if mindist > us_dist(15): > > #enc_tgt(1,1,72) > > bwd() > > print ("backward1x",us_dist(15)) > > time.sleep(2) > > left_rot() > > print("left rot",us_dist(15)) > > time.sleep(3) > > stop() > > > > if mindist < us_dist(15): > > #enc_tgt(1,1,72) > > fwd() > > print("forward2x",us_dist(15)) > > time.sleep(2) > > stop() > > > > for x in range(3): > > > > if mindist > us_dist(15): > > bwd() > > print("backward2x",us_dist(15)) > > -- --------------------------------- --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From python at mrabarnett.plus.com Sat Oct 31 15:42:30 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 31 Oct 2015 19:42:30 +0000 Subject: GoPiGo script In-Reply-To: References: Message-ID: <563519A6.9070903@mrabarnett.plus.com> On 2015-10-31 18:59, input/ldompeling at casema.nl wrote: >> The body of the 'while' loop extends from the line: >> >> enable_servo() >> >> to the line: >> >> print ("forward1x") >> >> Would that explain it? > > When i run this scipt its only print a lot off print1x. > Do you mean that ? > It does not only print; it also calls enable_servo, servo and fwd repeatedly. > > In reply to "MRAB" who wrote the following: > >> On 2015-10-31 10:28, input/ldompeling at casema.nl wrote: >> > I intended the rules under while True: >> > The script is working now only the wheels go's only forward "(fwd)",so the >> > sensor not detect any obstacles.(sensor=us_dist(15). >> > >> > > ---------------------------------------------------------------------------- >> > --- >> > >> > from gopigo import * >> > import time >> > >> > >> > set_right_speed(150) >> > set_left_speed(105) >> > >> The body of the 'while' loop extends from the line: >> >> enable_servo() >> >> to the line: >> >> print ("forward1x") >> >> Would that explain it? >> >> > while True: >> > #def test(): >> > enable_servo() >> > mindist = 80 >> > servo(90) >> > fwd() >> > print ("forward1x") >> > #time.sleep(5) >> > #stop() >> > >> > if mindist > us_dist(15): >> > #enc_tgt(1,1,72) >> > bwd() >> > print ("backward1x",us_dist(15)) >> > time.sleep(2) >> > left_rot() >> > print("left rot",us_dist(15)) >> > time.sleep(3) >> > stop() >> > >> > if mindist < us_dist(15): >> > #enc_tgt(1,1,72) >> > fwd() >> > print("forward2x",us_dist(15)) >> > time.sleep(2) >> > stop() >> > >> > for x in range(3): >> > >> > if mindist > us_dist(15): >> > bwd() >> > print("backward2x",us_dist(15)) >> > From input/ldompeling at casema.nl Sat Oct 31 16:18:21 2015 From: input/ldompeling at casema.nl (input/ldompeling at casema.nl) Date: Sat, 31 Oct 2015 20:18:21 GMT Subject: GoPiGo script References: Message-ID: > It does not only print; it also calls enable_servo, servo and fwd > repeatedly. > Then I am misinformed, because someone told me in this group to use while True: Is there another function that I can use for to restart this script? Thanks In reply to "MRAB" who wrote the following: > On 2015-10-31 18:59, input/ldompeling at casema.nl wrote: > > > The body of the 'while' loop extends from the line: > > > > > > enable_servo() > > > > > > to the line: > > > > > > print ("forward1x") > > > > > > Would that explain it? > > > > When i run this scipt its only print a lot off print1x. > > Do you mean that ? > > > It does not only print; it also calls enable_servo, servo and fwd > repeatedly. > > > > > In reply to "MRAB" who wrote the following: > > > > > On 2015-10-31 10:28, input/ldompeling at casema.nl wrote: > > > > I intended the rules under while True: > > > > The script is working now only the wheels go's only forward "(fwd)",so > > > > the > > > > sensor not detect any obstacles.(sensor=us_dist(15). > > > > > > > > > > ---------------------------------------------------------------------------- > > > > --- > > > > > > > > from gopigo import * > > > > import time > > > > > > > > > > > > set_right_speed(150) > > > > set_left_speed(105) > > > > > > > The body of the 'while' loop extends from the line: > > > > > > enable_servo() > > > > > > to the line: > > > > > > print ("forward1x") > > > > > > Would that explain it? > > > > > > > while True: > > > > #def test(): > > > > enable_servo() > > > > mindist = 80 > > > > servo(90) > > > > fwd() > > > > print ("forward1x") > > > > #time.sleep(5) > > > > #stop() > > > > > > > > if mindist > us_dist(15): > > > > #enc_tgt(1,1,72) > > > > bwd() > > > > print ("backward1x",us_dist(15)) > > > > time.sleep(2) > > > > left_rot() > > > > print("left rot",us_dist(15)) > > > > time.sleep(3) > > > > stop() > > > > > > > > if mindist < us_dist(15): > > > > #enc_tgt(1,1,72) > > > > fwd() > > > > print("forward2x",us_dist(15)) > > > > time.sleep(2) > > > > stop() > > > > > > > > for x in range(3): > > > > > > > > if mindist > us_dist(15): > > > > bwd() > > > > print("backward2x",us_dist(15)) > > > > -- --------------------------------- --- -- - Posted with NewsLeecher v7.0 Beta 2 Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From python at mrabarnett.plus.com Sat Oct 31 17:12:20 2015 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 31 Oct 2015 21:12:20 +0000 Subject: GoPiGo script In-Reply-To: References: Message-ID: <56352EB4.7070703@mrabarnett.plus.com> On 2015-10-31 20:18, input/ldompeling at casema.nl wrote: >> It does not only print; it also calls enable_servo, servo and fwd >> repeatedly. >> > Then I am misinformed, because someone told me in this group to use while True: > Is there another function that I can use for to restart this script? > The lines that you want to repeat should be indented more than the 'while True' line. In the code you posted, only the lines from: enable_servo() to: print ("forward1x") were indented more than the 'while True' line, so only those lines will be repeated. If you want the lines that follow them also to be repeated, then indent then too. > > In reply to "MRAB" who wrote the following: > >> On 2015-10-31 18:59, input/ldompeling at casema.nl wrote: >> > > The body of the 'while' loop extends from the line: >> > > >> > > enable_servo() >> > > >> > > to the line: >> > > >> > > print ("forward1x") >> > > >> > > Would that explain it? >> > >> > When i run this scipt its only print a lot off print1x. >> > Do you mean that ? >> > >> It does not only print; it also calls enable_servo, servo and fwd >> repeatedly. >> >> > >> > In reply to "MRAB" who wrote the following: >> > >> > > On 2015-10-31 10:28, input/ldompeling at casema.nl wrote: >> > > > I intended the rules under while True: >> > > > The script is working now only the wheels go's only forward "(fwd)",so >> > > > the >> > > > sensor not detect any obstacles.(sensor=us_dist(15). >> > > > >> > > > >> > > ---------------------------------------------------------------------------- >> > > > --- >> > > > >> > > > from gopigo import * >> > > > import time >> > > > >> > > > >> > > > set_right_speed(150) >> > > > set_left_speed(105) >> > > > >> > > The body of the 'while' loop extends from the line: >> > > >> > > enable_servo() >> > > >> > > to the line: >> > > >> > > print ("forward1x") >> > > >> > > Would that explain it? >> > > >> > > > while True: >> > > > #def test(): >> > > > enable_servo() >> > > > mindist = 80 >> > > > servo(90) >> > > > fwd() >> > > > print ("forward1x") >> > > > #time.sleep(5) >> > > > #stop() >> > > > >> > > > if mindist > us_dist(15): >> > > > #enc_tgt(1,1,72) >> > > > bwd() >> > > > print ("backward1x",us_dist(15)) >> > > > time.sleep(2) >> > > > left_rot() >> > > > print("left rot",us_dist(15)) >> > > > time.sleep(3) >> > > > stop() >> > > > >> > > > if mindist < us_dist(15): >> > > > #enc_tgt(1,1,72) >> > > > fwd() >> > > > print("forward2x",us_dist(15)) >> > > > time.sleep(2) >> > > > stop() >> > > > >> > > > for x in range(3): >> > > > >> > > > if mindist > us_dist(15): >> > > > bwd() >> > > > print("backward2x",us_dist(15)) >> > > > > > > > From werotizy at freent.dd Sat Oct 31 17:28:08 2015 From: werotizy at freent.dd (Tom P) Date: Sat, 31 Oct 2015 22:28:08 +0100 Subject: Nearest neighbours of points In-Reply-To: <81947104-f6dd-48b3-ba7b-f03b0c5b6f39@googlegroups.com> References: <81947104-f6dd-48b3-ba7b-f03b0c5b6f39@googlegroups.com> Message-ID: On 10/24/2015 10:05 PM, Poul Riis wrote: > I have N points in 3D, organized in a list. I want to to point out the numbers of the two that have the smallest distance. > With scipy.spatial.distance.pdist I can make a list of all the distances, and I can point out the number of the minimum value of that list (see simple example below - the line with pts.append... should be indented three times). But I guess there is a standard (numpy?) routine which points out the numbers of the corresponding two points but I cannot find it. Can someone help? > > Poul Riis > > > > > import numpy as np > import scipy > from scipy.spatial.distance import pdist > > > pts=[] > for i in range(-1,2): > for j in range(-1,2): > for k in range(-1,2): pts.append((i+np.random.random()/10,j+np.random.random()/10,k+np.random.random()/10)) > for i in range(0,len(pts)): > print(pts[i]) > distances=scipy.spatial.distance.pdist(pts) > n=np.argmin(distances) > for i in range(0,len(distances)): > print(i,distances[i]) > print('The minimum distance is: ',min(distances),' which has number ',n) > I won't claim to have the definitive answer but - is this a clustering problem? Did you look at any machine learning packages? From motoom at xs4all.nl Sat Oct 31 21:45:57 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Sun, 1 Nov 2015 02:45:57 +0100 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> <201510290753.t9T7rZqR032272@fido.openend.se> <5A7F323C-ED4A-4CCA-A392-2C6F64EA6A6F@xs4all.nl> <201510301629.t9UGTY2i013568@fido.openend.se> Message-ID: > On 31 Oct 2015, at 06:59, Terry Reedy wrote: > This is a different issue than IDLE avoiding clashes. I opened > https://bugs.python.org/issue25522 Terry, thanks for recording this into the issue tracker. I'd go even a step further. I think IDLE should not only warn, but completely prevent saving a file which shadows a stdlib module, which will effectively render Python unusable. I remember from a few weeks back, a teacher with the same problem posted this on the mailinglist. Eventually she had a technician coming in to reinstall Windows, just to fix this problem ;-) What an overkill... Greetings, From rosuav at gmail.com Sat Oct 31 21:59:59 2015 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 1 Nov 2015 12:59:59 +1100 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> <201510290753.t9T7rZqR032272@fido.openend.se> <5A7F323C-ED4A-4CCA-A392-2C6F64EA6A6F@xs4all.nl> <201510301629.t9UGTY2i013568@fido.openend.se> Message-ID: On Sun, Nov 1, 2015 at 12:45 PM, Michiel Overtoom wrote: > I'd go even a step further. I think IDLE should not only warn, but completely prevent saving a file which shadows a stdlib module, which will effectively render Python unusable. I remember from a few weeks back, a teacher with the same problem posted this on the mailinglist. Eventually she had a technician coming in to reinstall Windows, just to fix this problem ;-) What an overkill... > Trouble is, that applies only if Idle was the thing that saved it under that name and in that location. And that still only prevents access to one module (imagine, for instance, shadowing wave.py - how many programs will really break?). Not sure it should *prevent* anything like that. A warning, sure, but not an absolute error. ChrisA From tjreedy at udel.edu Sat Oct 31 22:50:20 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 31 Oct 2015 22:50:20 -0400 Subject: UNABLE TO GET IDLE TO RUN In-Reply-To: References: <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <1501485483.555358.1445441061800.JavaMail.yahoo@mail.yahoo.com> <201510230905.t9N95FPe025528@fido.openend.se> <56310743.3070708@gmail.com> <563180CB.5080303@gmail.com> <201510290753.t9T7rZqR032272@fido.openend.se> <5A7F323C-ED4A-4CCA-A392-2C6F64EA6A6F@xs4all.nl> <201510301629.t9UGTY2i013568@fido.openend.se> Message-ID: On 10/31/2015 9:45 PM, Michiel Overtoom wrote: > >> On 31 Oct 2015, at 06:59, Terry Reedy wrote: >> This is a different issue than IDLE avoiding clashes. I opened >> https://bugs.python.org/issue25522 > > Terry, thanks for recording this into the issue tracker. > > I'd go even a step further. I think IDLE should not only warn, but The warning will require a choice, with the default (if one just hits ) being to reject the duplicate and go back to the Save-as dialog. Please add yourself as nosy on the issue so you can comment on the message whenever I get around to adding a patch. > completely prevent saving a file which shadows a stdlib module, which > will effectively render Python unusable. That is too authoritarian for Python. As Chris noted, all I can do with IDLE patches is improve the situation, not solve it. > I remember from a few weeks > back, a teacher with the same problem posted this on the mailinglist. That involved the additional problem of the working directory being /windows/system32. This was fixed today for 3.5.1. > Eventually she had a technician coming in to reinstall Windows, just > to fix this problem ;-) What an overkill... If her classroom budget was not charged for that, that may have been the cheapest solution *for her*, though not for the school or whoever paid the tech. -- Terry Jan Reedy From tjreedy at udel.edu Sat Oct 31 23:00:54 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 31 Oct 2015 23:00:54 -0400 Subject: Nearest neighbours of points In-Reply-To: References: <81947104-f6dd-48b3-ba7b-f03b0c5b6f39@googlegroups.com> Message-ID: On 10/31/2015 5:28 PM, Tom P wrote: > On 10/24/2015 10:05 PM, Poul Riis wrote: >> I have N points in 3D, organized in a list. I want to to point out the >> numbers of the two that have the smallest distance. >> With scipy.spatial.distance.pdist I can make a list of all the >> distances, and I can point out the number of the minimum value of that >> list (see simple example below distances is conceptually a 2-d matrix, but since it would be symmetrical, I gather that it is stored as 1-d represention You should be able to find the formula that converts the linear index to the indexes of the corresponding symmetric matrix. It depends on whether distances represent the upper or lower triangle of the symmetric matrix and whether the triangular matrix is stored by rows or columns. -- Terry Jan Reedy