Re: functools.partial [was Re: and on - topic and and off topic]

2016-07-29 Thread Matt Wheeler
On Fri, 29 Jul 2016, 09:20 Steven D'Aprano, wrote: > I'm not sure that partial is intended as an optimization. It may end up > saving time by avoiding evaluating arguments, but that's not why it exists. > It exists to enable the functional programming idiom of partial evaluation > in a simpler, m

Re: TypeError: '_TemporaryFileWrapper' object is not an iterator

2016-07-29 Thread Antoon Pardon
Below is a short program that illustrate the problem It works with python2, whether you use the -c option or not. It only works with python3 if you use the -c option. The problem seems to come from my expectation that a file is its own iterator and in python3 that is no longer true for a NamedTemp

Re: Python text file fetch specific part of line

2016-07-29 Thread Gordon Levi
c...@zip.com.au wrote: >On 28Jul2016 19:28, Gordon Levi wrote: >>Arshpreet Singh wrote: >>>I am writing Imdb scrapper, and getting available list of titles from IMDB >>>website which provide txt file in very raw format, Here is the one part of >>>file(http://pastebin.com/fpMgBAjc) as the file

Re: Why not allow empty code blocks?

2016-07-29 Thread Antoon Pardon
Op 23-07-16 om 16:19 schreef Chris Angelico: > On Sun, Jul 24, 2016 at 12:00 AM, BartC wrote: >> Or, for debugging or other reasons, when you need to comment out the >> contents of a block. Then pass needs to be added. > How often do you comment out an entire block and not its header? I > don't re

Float

2016-07-29 Thread Cai Gengyang
Can someone explain in layman's terms what "float" means ? >>> x = float(input("Write a number")) Write a number 16 -- https://mail.python.org/mailman/listinfo/python-list

Re: Float

2016-07-29 Thread Lutz Horn
Am 07/29/2016 um 11:44 AM schrieb Cai Gengyang: Can someone explain in layman's terms what "float" means ? The Python builtin float[1] > Return a floating point number constructed from a number or string x. A floating point number[2] is number that is not an integer (and not a complex number

Re: Float

2016-07-29 Thread Ben Finney
Cai Gengyang writes: > Can someone explain in layman's terms what "float" means ? They are a compromise: in a known number of bits and with explict very-fast hardware support, represent numbers at a large range of scales. The compromise is that the values have limited precision for representing

Re: Why not allow empty code blocks?

2016-07-29 Thread D'Arcy J.M. Cain
On Fri, 29 Jul 2016 10:58:35 +0200 Antoon Pardon wrote: > As BartC already mentions it happens fairly often during debugging. > Something like. > > try: >Some code > except Some_Exception: ># Commented code for when I am debugging >pass I realize that that's a simplified example but

Re: TypeError: '_TemporaryFileWrapper' object is not an iterator

2016-07-29 Thread eryk sun
On Fri, Jul 29, 2016 at 8:43 AM, Antoon Pardon wrote: > > The problem seems to come from my expectation that a file > is its own iterator and in python3 that is no longer true > for a NamedTemporaryFile. For some reason it uses a generator function for __iter__ instead of returning self, which wo

Re: Why not allow empty code blocks?

2016-07-29 Thread BartC
On 29/07/2016 12:14, D'Arcy J.M. Cain wrote: On Fri, 29 Jul 2016 10:58:35 +0200 Antoon Pardon wrote: As BartC already mentions it happens fairly often during debugging. Something like. try: Some code except Some_Exception: # Commented code for when I am debugging pass I realize tha

Re: Why not allow empty code blocks?

2016-07-29 Thread Ian Kelly
On Jul 29, 2016 7:22 AM, "BartC" wrote: > > On 29/07/2016 12:14, D'Arcy J.M. Cain wrote: >> >> On Fri, 29 Jul 2016 10:58:35 +0200 >> Antoon Pardon wrote: >>> >>> As BartC already mentions it happens fairly often during debugging. >>> Something like. >>> >>> try: >>>Some code >>> except Some_E

Re: Why not allow empty code blocks?

2016-07-29 Thread Steven D'Aprano
On Fri, 29 Jul 2016 11:15 pm, BartC wrote: > On 29/07/2016 12:14, D'Arcy J.M. Cain wrote: >> On Fri, 29 Jul 2016 10:58:35 +0200 >> Antoon Pardon wrote: >>> As BartC already mentions it happens fairly often during debugging. >>> Something like. >>> >>> try: >>>Some code >>> except Some_Excepti

Re: Why not allow empty code blocks?

2016-07-29 Thread Antoon Pardon
Op 29-07-16 om 13:14 schreef D'Arcy J.M. Cain: > On Fri, 29 Jul 2016 10:58:35 +0200 > Antoon Pardon wrote: >> As BartC already mentions it happens fairly often during debugging. >> Something like. >> >> try: >>Some code >> except Some_Exception: >># Commented code for when I am debugging

Re: Why not allow empty code blocks?

2016-07-29 Thread Antoon Pardon
Op 29-07-16 om 15:43 schreef Steven D'Aprano: > Of course it won't, which is why I don't believe all these folks who claim > that they regularly ("all the time", "fairly often") replace except blocks > with `pass`. I call shenanigans -- perhaps you do it *occasionally*, but as > a general rule, you

Re: Float

2016-07-29 Thread Steven D'Aprano
On Fri, 29 Jul 2016 07:44 pm, Cai Gengyang wrote: > Can someone explain in layman's terms what "float" means ? Floating point number: https://en.wikipedia.org/wiki/Floating_point As opposed to fixed point numbers: https://en.wikipedia.org/wiki/Fixed-point_arithmetic Python floats use 64 bits

Re: Why not allow empty code blocks?

2016-07-29 Thread Steven D'Aprano
On Fri, 29 Jul 2016 11:55 pm, Antoon Pardon wrote: > Op 29-07-16 om 15:43 schreef Steven D'Aprano: >> Of course it won't, which is why I don't believe all these folks who >> claim that they regularly ("all the time", "fairly often") replace except >> blocks with `pass`. I call shenanigans -- perha

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-07-29 Thread livetemartin
On Saturday, December 12, 2015 at 1:05:29 AM UTC-8, Harbey Leke wrote: > Create a class called BankAccount > > .Create a constructor that takes in an integer and assigns this to a > `balance` property. > > .Create a method called `deposit` that takes in cash deposit amount and > updates the bal

Re: Why not allow empty code blocks?

2016-07-29 Thread D'Arcy J.M. Cain
On Fri, 29 Jul 2016 14:15:01 +0100 BartC wrote: > > try: > >Some code > > # except Some_Exception: > ># Commented code for when I am debugging > > Will it behave the same way when there is a Some_Exception exception? Of course not. The person writing that was an idiot. Oh wait - I wro

Re: Why not allow empty code blocks?

2016-07-29 Thread D'Arcy J.M. Cain
On Fri, 29 Jul 2016 15:55:07 +0200 Antoon Pardon wrote: > I think the case where you just want to ignore the exception, but it > can at times be useful to get some extra logging information for > debuging purposes, is not that rare as you seem to suggest. The way I handle that is: DEBUG = False

SOAP and Zeep

2016-07-29 Thread Ethan Furman
Greetings! I may have a need in the immediate future to work with SOAP and WSDL services, and a quick search turned up Zeep (http://docs.python-zeep.org/en/latest/) -- does anyone have any experience with it? Or any other libraries that can be recommended? Thanks. -- ~Ethan~ -- https://mail.p

Re: Why not allow empty code blocks?

2016-07-29 Thread Antoon Pardon
Op 29-07-16 om 16:38 schreef Steven D'Aprano: > On Fri, 29 Jul 2016 11:55 pm, Antoon Pardon wrote: > >> Op 29-07-16 om 15:43 schreef Steven D'Aprano: >>> Of course it won't, which is why I don't believe all these folks who >>> claim that they regularly ("all the time", "fairly often") replace exce

Re: TypeError: '_TemporaryFileWrapper' object is not an iterator

2016-07-29 Thread Terry Reedy
On 7/29/2016 4:43 AM, Antoon Pardon wrote: Below is a short program that illustrate the problem It works with python2, whether you use the -c option or not. It only works with python3 if you use the -c option. The problem seems to come from my expectation that a file is its own iterator and in p

Re: TypeError: '_TemporaryFileWrapper' object is not an iterator

2016-07-29 Thread Terry Reedy
On 7/29/2016 7:59 AM, eryk sun wrote: On Fri, Jul 29, 2016 at 8:43 AM, Antoon Pardon wrote: The problem seems to come from my expectation that a file is its own iterator and in python3 that is no longer true for a NamedTemporaryFile. For some reason it uses a generator function for __iter__

Re: Why not allow empty code blocks?

2016-07-29 Thread Terry Reedy
On 7/29/2016 4:58 AM, Antoon Pardon wrote: Op 23-07-16 om 16:19 schreef Chris Angelico: On Sun, Jul 24, 2016 at 12:00 AM, BartC wrote: Or, for debugging or other reasons, when you need to comment out the contents of a block. Then pass needs to be added. How often do you comment out an entire

Re: Why not allow empty code blocks?

2016-07-29 Thread BartC
On 29/07/2016 20:43, Terry Reedy wrote: On 7/29/2016 4:58 AM, Antoon Pardon wrote: Something like. try: Some code except Some_Exception: # Commented code for when I am debugging pass So put in 'pass' whether or not there is no debugging code, commented-out debugging code, or debug

Call function via literal name

2016-07-29 Thread TUA
Rather than do this: if test['method'] == 'GET': res = requests.get(test['endpoint'],auth=test['auth'], verify=False) elif test['method'] == 'POST': res = requests.post(test['endpoint'], auth=test['auth'], verify=False, json=test['bod

Re: Call function via literal name

2016-07-29 Thread Jon Ribbens
On 2016-07-29, TUA wrote: > Rather than do this: > > if test['method'] == 'GET': > res = requests.get(test['endpoint'],auth=test['auth'], > verify=False) > elif test['method'] == 'POST': > res = requests.post(test['endpoint'], auth=tes

Re: Call function via literal name

2016-07-29 Thread Ian Kelly
On Fri, Jul 29, 2016 at 2:35 PM, TUA wrote: > Rather than do this: > > if test['method'] == 'GET': > res = requests.get(test['endpoint'],auth=test['auth'], > verify=False) > elif test['method'] == 'POST': > res = requests.post(test['endpoint'],

Re: Why not allow empty code blocks?

2016-07-29 Thread Marko Rauhamaa
BartC : > On 29/07/2016 20:43, Terry Reedy wrote: >> So put in 'pass' whether or not there is no debugging code, >> commented-out debugging code, or debugging code that runs, or whatever. > > But that's inelegant. > > The language requires that blocks always contains 1 or more > statements. Fair en

Re: Call function via literal name

2016-07-29 Thread TUA
On Friday, 29 July 2016 13:35:30 UTC-7, TUA wrote: > Rather than do this: > > if test['method'] == 'GET': > res = requests.get(test['endpoint'],auth=test['auth'], > verify=False) > elif test['method'] == 'POST': > res = requests.post(te

JSON result parsing

2016-07-29 Thread TUA
Calls to my REST api may either return a dict (for single results) or a list of dicts (for multiple results). I receive these results using the requests library. I want to retrieve the value for a key 'ID' but only if I have a single result and, obviously, if ID is present. How can I do this w

RE: SOAP and Zeep

2016-07-29 Thread Joseph L. Casale
> Or any other libraries that can be recommended? I'd recommend Spyne, code and docs are good, but more importantly the lead dev is responsive and very helpful. Can't speak highly enough about him... http://spyne.io/ hth, jlc -- https://mail.python.org/mailman/listinfo/python-list

Re: TypeError: '_TemporaryFileWrapper' object is not an iterator

2016-07-29 Thread eryk sun
On Fri, Jul 29, 2016 at 7:34 PM, Terry Reedy wrote: > On 7/29/2016 7:59 AM, eryk sun wrote: >> >> On Fri, Jul 29, 2016 at 8:43 AM, Antoon Pardon >> wrote: >>> >>> The problem seems to come from my expectation that a file >>> is its own iterator and in python3 that is no longer true >>> for a Name

Re: Python text file fetch specific part of line

2016-07-29 Thread cs
On 29Jul2016 18:42, Gordon Levi wrote: c...@zip.com.au wrote: On 28Jul2016 19:28, Gordon Levi wrote: Arshpreet Singh wrote: I am writing Imdb scrapper, and getting available list of titles from IMDB website which provide txt file in very raw format, Here is the one part of file(http://past

Re: JSON result parsing

2016-07-29 Thread John Gordon
In TUA writes: > I want to retrieve the value for a key 'ID' but only if I have a single > result and, obviously, if ID is present. > How can I do this with pythonic elegance? > Thanks for all suggestions! if len(results) == 1 and 'ID' in results: return results['ID'] else:

Re: Why not allow empty code blocks?

2016-07-29 Thread Steven D'Aprano
On Sat, 30 Jul 2016 06:19 am, BartC wrote: > The language requires that blocks always contains 1 or more statements. > Fair enough, except that 0 statements are often needed They really aren't. The standard library uses more "pass" statements than most code I've seen, because of the large number

Re: Why not allow empty code blocks?

2016-07-29 Thread Steven D'Aprano
On Sat, 30 Jul 2016 04:32 am, Antoon Pardon wrote: > Op 29-07-16 om 16:38 schreef Steven D'Aprano: >> On Fri, 29 Jul 2016 11:55 pm, Antoon Pardon wrote: >> >>> Op 29-07-16 om 15:43 schreef Steven D'Aprano: Of course it won't, which is why I don't believe all these folks who claim that t

Re: Can math.atan2 return INF?

2016-07-29 Thread Rustom Mody
On Thursday, June 30, 2016 at 11:33:58 PM UTC+5:30, Steven D'Aprano wrote: > On Fri, 1 Jul 2016 01:28 am, Rustom Mody wrote: > > > On Thursday, June 30, 2016 at 1:55:18 PM UTC+5:30, Steven D'Aprano wrote: > > > >> you state that Turing "believes in souls" and that he "wishes to > >> put the soul