Re: Psycopg2 pool clarification

2017-06-06 Thread dieter
israel writes: > Since I've gotten no replies to this, I was wondering if someone could > at least confirm which behavior (my expected or my observed) is > *supposed* to be the correct? Should a psycopg2 pool keep connections > open when returned to the pool (if closed is False), or should it > cl

Generator and return value

2017-06-06 Thread Frank Millman
Hi all It would be nice to write a generator in such a way that, in addition to 'yielding' each value, it performs some additional work and then 'returns' a final result at the end. From Python 3.3, anything 'returned' becomes the value of the StopIteration exception, so it is possible, but

Re: script output appears correct but still raises AssertionError

2017-06-06 Thread Chris Angelico
On Wed, Jun 7, 2017 at 10:58 AM, john polo wrote: > I am learning about assertions. I wrote a small script that takes 2 inputs, > an amino acid sequence and one residue symbol. The script should return what > percent of the sequence is residue in output. The point of this script is to > use assert

script output appears correct but still raises AssertionError

2017-06-06 Thread john polo
Python People, I am learning about assertions. I wrote a small script that takes 2 inputs, an amino acid sequence and one residue symbol. The script should return what percent of the sequence is residue in output. The point of this script is to use assert for debugging. My script seems to work

Re: Access flles on a Android device from Windows PC

2017-06-06 Thread eryk sun
On Tue, Jun 6, 2017 at 7:36 PM, Fred Fishbin wrote: > > I want to write little program that my friend can run - he'll plug a USB drive > into his Windows 7 PC, plug his phone in a USB port on same PC, then run my > program and it'll xfer some audiobook files over for him. > > I plugged the USB dri

Re: Bug or intended behavior?

2017-06-06 Thread Steve D'Aprano
On Wed, 7 Jun 2017 03:16 am, Terry Reedy wrote: >> Personally I prefer a less compact but more explicit alternative: >> >> "foo {}".format(1-2) > > More compact: > >>> f'foo {1-2}' > 'foo -1' Also more mysterious and magical, and not backwards compatible. "Good news everybody! We have

Re: Access flles on a Android device from Windows PC

2017-06-06 Thread Gregory Ewing
Fred Fishbin wrote: the phone plugged in and became just "SAMSUNG-SM-G930V", no drive designation, just a Portable Media Device. ... what do I use for a path? It's probably something like \\SAMSUNG-SM-G930V One way to find out is to open it with Windows Explorer and then click up in the

Re: New to Python - Career question

2017-06-06 Thread Larry Martell
On Tue, Jun 6, 2017 at 6:37 PM, Marko Rauhamaa wrote: > pta...@gmail.com: > >> New to Python and have been at it for about a month now. I'm doing >> well and like it very much. Considering a career change down the road >> and have been wondering... What are the job prospects for a middle age >> en

Re: Python program ends with 154 snakes dead; should it continue?

2017-06-06 Thread Chris Angelico
On Wed, Jun 7, 2017 at 8:43 AM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> Well, no. Once a Python program ends, it should not continue. At that >> point, you're supposed to go back to the OS. > > > Well, the OS is a program, too. True, but I don't know of any OS written in Python. I hav

Re: Python program ends with 154 snakes dead; should it continue?

2017-06-06 Thread Gregory Ewing
Chris Angelico wrote: Well, no. Once a Python program ends, it should not continue. At that point, you're supposed to go back to the OS. Well, the OS is a program, too. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: New to Python - Career question

2017-06-06 Thread Marko Rauhamaa
pta...@gmail.com: > New to Python and have been at it for about a month now. I'm doing > well and like it very much. Considering a career change down the road > and have been wondering... What are the job prospects for a middle age > entry level programmer. Just trying to get a better understandin

Re: Finding the name of an object's source file

2017-06-06 Thread Gregory Ewing
Matt Wheeler wrote: import importlib, os importlib.import_module(os.path.split.__module__).__file__ '/Users/matt/.pyenv/versions/3.6.0/lib/python3.6/posixpath.py' Or just look the module name up in sys.modules, if we know (as we do here) that the module has already been imported. -- Greg --

Re: New to Python - Career question

2017-06-06 Thread Larry Martell
On Tue, Jun 6, 2017 at 5:39 PM, wrote: > New to Python and have been at it for about a month now. I'm doing well and > like it very much. Considering a career change down the road and have been > wondering... What are the job prospects for a middle age entry level > programmer. Just trying to

Re: Unhelpful error message

2017-06-06 Thread Thomas Nyberg
On 06/06/2017 02:32 PM, Chris Angelico wrote: > > That's what I thought. If the OP's happy to upgrade to 3.6/3.7, of > course, the problem disappears. > > ChrisA > As far as I can tell this affects all versions of python. Here are some versions I played with: 2.7: >>> float("") Traceback (most

New to Python - Career question

2017-06-06 Thread ptanyc
New to Python and have been at it for about a month now. I'm doing well and like it very much. Considering a career change down the road and have been wondering... What are the job prospects for a middle age entry level programmer. Just trying to get a better understanding where I stand career

Re: Unhelpful error message

2017-06-06 Thread Chris Angelico
On Wed, Jun 7, 2017 at 7:28 AM, Terry Reedy wrote: >> Yeah. Unfortunately this exception doesn't make good use of its args, >> so you can't get programmatic information from it (this is true in 3.7 >> too actually). So if a change were to be made, I'd recommend putting >> the actual string into e.

Re: Unhelpful error message

2017-06-06 Thread Terry Reedy
On 6/6/2017 2:29 PM, Chris Angelico wrote: On Wed, Jun 7, 2017 at 4:22 AM, Skip Montanaro wrote: On Tue, Jun 6, 2017 at 12:27 PM, Chris Angelico wrote: Or perhaps showing the repr of the string would be clearer. This would definitely be better, I think, and require no special casing of the

RE: Namedtuple problem #32.11.d

2017-06-06 Thread Deborah Swanson
Richard Moseley wrote, on Tuesday, June 06, 2017 8:16 AM > > On 06/06/17 13:29, Neil Cerutti wrote: > > On 2017-06-06, Deborah Swanson wrote: > >> I have a list of namedtuples: > >> > >>[{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='') > >>. . . > >>{Record}(r0=v0, r1=v1,..

RE: Namedtuple problem #32.11.d

2017-06-06 Thread Deborah Swanson
Neil Cerutti wrote, on Tuesday, June 06, 2017 5:29 AM > > On 2017-06-06, Deborah Swanson wrote: > > I have a list of namedtuples: > > > > [{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='') > > . . . > > {Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='')] > > > > In the fir

Re: Unhelpful error message

2017-06-06 Thread Chris Angelico
On Wed, Jun 7, 2017 at 4:31 AM, Thomas Nyberg wrote: > Does it make sense to open a bug report? I'm always a bit intimidated by > contributing to python, but the following patch does seem to work > (against a new clone of the master branch): Your original post talked about 2.7; when you say "mast

RE: Namedtuple problem #32.11.d

2017-06-06 Thread Deborah Swanson
Peter Otten wrote, on Tuesday, June 06, 2017 1:31 AM > > Deborah Swanson wrote: > > > [{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='') > > Lovely column names ;) Not very sexy names, I agree ;) The columns do have real names. The first 10 are friendly and semi-friendly names, but the na

Access flles on a Android device from Windows PC

2017-06-06 Thread Fred Fishbin
Hi I want to write little program that my friend can run - he'll plug a USB drive into his Windows 7 PC, plug his phone in a USB port on same PC, then run my program and it'll xfer some audiobook files over for him. I plugged the USB drive in and it became "G:\", but the phone plugged in and b

Re: Unhelpful error message

2017-06-06 Thread Jon Ribbens
On 2017-06-06, Thomas Nyberg wrote: > On 06/06/2017 11:46 AM, Jon Ribbens wrote: >> On 2017-06-06, Thomas Nyberg wrote: >>> My changes feel a bit hacky. I wanted to just drop a straight repr() in, >>> but I didn't want to change the code too much since I assume the string >>> formatting is alread

Re: Unhelpful error message

2017-06-06 Thread Thomas Nyberg
On 06/06/2017 11:38 AM, Jon Ribbens wrote: > On 2017-06-06, Peter Otten <__pete...@web.de> wrote: >> ...but not the empty string: >> > float("") >> Traceback (most recent call last): >> File "", line 1, in >> ValueError: could not convert string to float: >> >> Maybe there were some backwar

Re: Unhelpful error message

2017-06-06 Thread Thomas Nyberg
On 06/06/2017 11:46 AM, Jon Ribbens wrote: > On 2017-06-06, Thomas Nyberg wrote: >> My changes feel a bit hacky. I wanted to just drop a straight repr() in, >> but I didn't want to change the code too much since I assume the string >> formatting is already there for a reason (e.g. "%.200s"). > >

Re: Unhelpful error message

2017-06-06 Thread Jon Ribbens
On 2017-06-06, Thomas Nyberg wrote: > My changes feel a bit hacky. I wanted to just drop a straight repr() in, > but I didn't want to change the code too much since I assume the string > formatting is already there for a reason (e.g. "%.200s"). Just change the '%.200s' to '%.200R' and it should w

Re: Unhelpful error message

2017-06-06 Thread Jon Ribbens
On 2017-06-06, Peter Otten <__pete...@web.de> wrote: > ...but not the empty string: > float("") > Traceback (most recent call last): > File "", line 1, in > ValueError: could not convert string to float: > > Maybe there were some backward compatibility concerns that I lack the > fantasy t

Re: Unhelpful error message

2017-06-06 Thread Thomas Nyberg
On 06/06/2017 11:22 AM, Skip Montanaro wrote: > On Tue, Jun 6, 2017 at 12:27 PM, Chris Angelico wrote: >> Or perhaps showing the repr of the string would be clearer. > > This would definitely be better, I think, and require no special > casing of the empty string. Still, I doubt this would ever b

Re: Unhelpful error message

2017-06-06 Thread Chris Angelico
On Wed, Jun 7, 2017 at 4:22 AM, Skip Montanaro wrote: > On Tue, Jun 6, 2017 at 12:27 PM, Chris Angelico wrote: >> Or perhaps showing the repr of the string would be clearer. > > This would definitely be better, I think, and require no special > casing of the empty string. Still, I doubt this woul

Re: Unhelpful error message

2017-06-06 Thread Skip Montanaro
On Tue, Jun 6, 2017 at 12:27 PM, Chris Angelico wrote: > Or perhaps showing the repr of the string would be clearer. This would definitely be better, I think, and require no special casing of the empty string. Still, I doubt this would ever be backported for fear of breaking code might be out the

Re: Unhelpful error message

2017-06-06 Thread Peter Otten
Stephen Tucker wrote: > Hi, > > I have just been thrown through an unecessary loop because of an unhelpful > error message. > > I am running Python 2.7.10 on a Windows 10 machine. > > I incorporate sample output from IDLE: > > ~~~ > print float ("123.456") > 123.4

Re: Unhelpful error message

2017-06-06 Thread Chris Angelico
On Wed, Jun 7, 2017 at 3:09 AM, Stephen Tucker wrote: > I have just been thrown through an unecessary loop because of an unhelpful > error message. > > I am running Python 2.7.10 on a Windows 10 machine. > print float ("") > > Traceback (most recent call last): > File "", line 1, in >

Re: Bug or intended behavior?

2017-06-06 Thread Chris Angelico
On Wed, Jun 7, 2017 at 2:44 AM, Peter Pearson wrote: > On Tue, 6 Jun 2017 03:10:05 +1000, Chris Angelico wrote: >> On Tue, Jun 6, 2017 at 3:01 AM, Peter Pearson wrote: > [snip] >>> Say >>> "foo %s" % (1-2) >>> not >>> ("foo %s" % 1) - 2 >>> . >>> >>> Personally I prefer a less compact but

Re: Bug or intended behavior?

2017-06-06 Thread Terry Reedy
On 6/5/2017 1:01 PM, Peter Pearson wrote: On Fri, 2 Jun 2017 10:17:05 -0700 (PDT), sean.diza...@gmail.com wrote: [snip] print "foo %s" % 1-2 Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for -: 'str' and 'int' Others have already pointed out

Unhelpful error message

2017-06-06 Thread Stephen Tucker
Hi, I have just been thrown through an unecessary loop because of an unhelpful error message. I am running Python 2.7.10 on a Windows 10 machine. I incorporate sample output from IDLE: ~~~ >>> print float ("123.456") 123.456 >>> print float ("") Traceback (most recent

Re: Bug or intended behavior?

2017-06-06 Thread Peter Pearson
On Tue, 6 Jun 2017 03:10:05 +1000, Chris Angelico wrote: > On Tue, Jun 6, 2017 at 3:01 AM, Peter Pearson wrote: [snip] >> Say >> "foo %s" % (1-2) >> not >> ("foo %s" % 1) - 2 >> . >> >> Personally I prefer a less compact but more explicit alternative: >> >> "foo {}".format(1-2) > > The

Re: Python program ends with 154 snakes dead; should it continue?

2017-06-06 Thread Chris Angelico
On Wed, Jun 7, 2017 at 1:07 AM, Larry Martell wrote: > I saw this headline and my first thought was what kind of program was this??? > > http://www.mypalmbeachpost.com/weather/new-python-program-ends-with-154-snakes-dead-should-continue/UtI3GeaBflGHEZzlfoHYgN/ > > We now return you to your regular

Re: Python program ends with 154 snakes dead; should it continue?

2017-06-06 Thread Skip Montanaro
> I saw this headline and my first thought was what kind of program was this??? > > http://www.mypalmbeachpost.com/weather/new-python-program-ends-with-154-snakes-dead-should-continue/UtI3GeaBflGHEZzlfoHYgN/ If only getting rid of invasive species was a SMOP. Skip -- https://mail.python.org/mail

Re: Namedtuple problem #32.11.d

2017-06-06 Thread Richard Moseley
On 06/06/17 13:29, Neil Cerutti wrote: On 2017-06-06, Deborah Swanson wrote: I have a list of namedtuples: [{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='') . . . {Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='')] In the first section of code, I process so

Re: Psycopg2 pool clarification

2017-06-06 Thread israel
Since I've gotten no replies to this, I was wondering if someone could at least confirm which behavior (my expected or my observed) is *supposed* to be the correct? Should a psycopg2 pool keep connections open when returned to the pool (if closed is False), or should it close them as long as th

Python program ends with 154 snakes dead; should it continue?

2017-06-06 Thread Larry Martell
I saw this headline and my first thought was what kind of program was this??? http://www.mypalmbeachpost.com/weather/new-python-program-ends-with-154-snakes-dead-should-continue/UtI3GeaBflGHEZzlfoHYgN/ We now return you to your regularly scheduled programming. -- https://mail.python.org/mailman/

Re: Download

2017-06-06 Thread Yubin Ruan
On Mon, Jun 05, 2017 at 05:16:55PM +0200, Maria Alonso-Martirena wrote: > Good morning, > > > > You asked me to subscribe before writing to you and i've already done so. I > need your help: I’ve just downloaded Python for Windows (versión 3.6.1.). > However, when I try to open it, it just says “

Re: Finding the name of an object's source file

2017-06-06 Thread Friedrich Rentsch
On 06/06/2017 03:52 PM, Matt Wheeler wrote: On Tue, 6 Jun 2017 at 11:20 Peter Otten <__pete...@web.de> wrote: import os inspect.getsourcefile(os.path.split) '/usr/lib/python3.4/posixpath.py' And so much more fun than scanning the documentation :) Alternatively, without using inspect, we c

Re: Finding the name of an object's source file

2017-06-06 Thread Matt Wheeler
On Tue, 6 Jun 2017 at 11:20 Peter Otten <__pete...@web.de> wrote: > > >>> import os > >>> inspect.getsourcefile(os.path.split) > '/usr/lib/python3.4/posixpath.py' > > And so much more fun than scanning the documentation :) > Alternatively, without using inspect, we can get around `Object.__module

Re: Namedtuple problem #32.11.d

2017-06-06 Thread Neil Cerutti
On 2017-06-06, Deborah Swanson wrote: > I have a list of namedtuples: > > [{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='') > . . . > {Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='')] > > In the first section of code, I process some of the first 10 > columns (r0=v0

Re: Finding the name of an object's source file

2017-06-06 Thread Peter Otten
Friedrich Rentsch wrote: > Hi all, > > Developing a project, I have portions that work and should be assembled > into a final program. Some parts don't interconnect when they should, > because of my lack of rigor in managing versions. So in order to get on, > I should next tidy up the mess and th

Finding the name of an object's source file

2017-06-06 Thread Friedrich Rentsch
Hi all, Developing a project, I have portions that work and should be assembled into a final program. Some parts don't interconnect when they should, because of my lack of rigor in managing versions. So in order to get on, I should next tidy up the mess and the way I can think of to do it is t

Re: Namedtuple problem #32.11.d

2017-06-06 Thread Peter Otten
Deborah Swanson wrote: > [{Record}(r0=v0, r1=v1,...,r10=v10,r11='',...r93='') Lovely column names ;) > Because, I can't say > > r = r._replace(getattr(r, column) = data) When r is mutable, i. e. *not* a namedtuple, you can write setattr(r, column, data) This assumes column is the column