Re: What's the best way to minimize the need of run time checks?

2016-08-27 Thread Chris Angelico
On Sun, Aug 28, 2016 at 4:13 PM, Jussi Piitulainen wrote: >> This is where I'm less sure. Sometimes a variable's type should be >> broader than just one concrete type - for instance, a variable might >> hold 1 over here, and 1.5 over there, and thus is storing either "int >> or float" or "any numb

Re: What's the best way to minimize the need of run time checks?

2016-08-27 Thread Jussi Piitulainen
Chris Angelico writes: > On Sun, Aug 28, 2016 at 2:30 PM, Steve D'Aprano wrote: >> But in dynamic typing, the type information isn't associated with the >> name "x", but with the value 1 currently assigned to it. Change the >> assignment, and the type changes. As a consequence, it is necessary >>

Re: What's the best way to minimize the need of run time checks?

2016-08-27 Thread Juan Pablo Romero Méndez
2016-08-27 21:30 GMT-07:00 Steve D'Aprano : > On Sun, 28 Aug 2016 12:31 pm, Juan Pablo Romero Méndez wrote: > > > 2016-08-14 7:29 GMT-07:00 Steven D'Aprano : > > > >> On Thu, 11 Aug 2016 06:33 am, Juan Pablo Romero Méndez wrote: > >> > >> > I've been trying to find (without success so far) an exam

Re: What's the best way to minimize the need of run time checks?

2016-08-27 Thread Chris Angelico
On Sun, Aug 28, 2016 at 2:30 PM, Steve D'Aprano wrote: > But the author of this piece ignores that standard distinction and invents > his own non-standard one: to him, classes are merely different > representations of the same data. E.g. his example of complex numbers, > shown as Cartesian (x, y)

Re: What's the best way to minimize the need of run time checks?

2016-08-27 Thread Juan Pablo Romero Méndez
2016-08-27 21:30 GMT-07:00 Steve D'Aprano : > On Sun, 28 Aug 2016 12:31 pm, Juan Pablo Romero Méndez wrote: > > > 2016-08-14 7:29 GMT-07:00 Steven D'Aprano : > > > >> On Thu, 11 Aug 2016 06:33 am, Juan Pablo Romero Méndez wrote: > >> > >> > I've been trying to find (without success so far) an exam

Re: What's the best way to minimize the need of run time checks?

2016-08-27 Thread Steve D'Aprano
On Sun, 28 Aug 2016 12:31 pm, Juan Pablo Romero Méndez wrote: > 2016-08-14 7:29 GMT-07:00 Steven D'Aprano : > >> On Thu, 11 Aug 2016 06:33 am, Juan Pablo Romero Méndez wrote: >> >> > I've been trying to find (without success so far) an example of a >> > situation where the dynamic features of a l

Re: What's the best way to minimize the need of run time checks?

2016-08-27 Thread Juan Pablo Romero Méndez
2016-08-14 7:29 GMT-07:00 Steven D'Aprano : > On Thu, 11 Aug 2016 06:33 am, Juan Pablo Romero Méndez wrote: > > > I've been trying to find (without success so far) an example of a > > situation where the dynamic features of a language like Python provides a > > clear advantage over languages with

Re: Is duck-typing misnamed?

2016-08-27 Thread Ben Finney
c...@zip.com.au writes: > They want to burn her because she's supposedly a witch, but the > scientific test was that she weighed as much as a duck. So I think > your second example is also duck typing: functioning like a duck. Excellent reasoning! (Also, I agree that describing objects with “loo

Re: Is duck-typing misnamed?

2016-08-27 Thread ROGER GRAYDON CHRISTMAN
Your response is appreciated. I just thought I'd comment a little more on the script: Woman: I'm not a witch! I'm not a witch! V: ehh... but you are dressed like one. W: They dressed me up like this! All: naah no we didn't... no. W: And this isn't my nose, it's a false one. (V lifts up

Re: Is duck-typing misnamed?

2016-08-27 Thread Joel Goldstick
On Sat, Aug 27, 2016 at 6:34 PM, Terry Reedy wrote: > On 8/26/2016 7:58 PM, ROGER GRAYDON CHRISTMAN wrote: >> >> "If it walks like a duck, quacks like a duck,... " >> >> so there is indeed precedence for this so-called 'duck typing' >> >> >> but wouldn't it be more Pythonic to call this 'witch typ

Re: Is duck-typing misnamed?

2016-08-27 Thread cs
On 26Aug2016 19:58, ROGER GRAYDON CHRISTMAN wrote: "If it walks like a duck, quacks like a duck,... " so there is indeed precedence for this so-called 'duck typing' but wouldn't it be more Pythonic to call this 'witch typing'? "How do you know she is a witch?" "She looks like one." etc. I do g

Re: Multimeter USB output

2016-08-27 Thread Terry Reedy
On 8/27/2016 3:35 PM, Joe wrote: Hi, I'm using Python 3.5.1 with PyUSB 1.0 under Win 10 (64). We try to read the USB output of a DMM 'UT61B'. import usb.core import usb.util import usb.backend.libusb1 def Gosub(): dev = usb.core.find(idVendor=0x1a86, idProduct=0xe008) # Digital Multimeter

Re: Is duck-typing misnamed?

2016-08-27 Thread Terry Reedy
On 8/26/2016 7:58 PM, ROGER GRAYDON CHRISTMAN wrote: "If it walks like a duck, quacks like a duck,... " so there is indeed precedence for this so-called 'duck typing' but wouldn't it be more Pythonic to call this 'witch typing'? "How do you know she is a witch?" "She looks like one." Given

Re: Error numpy install

2016-08-27 Thread breamoreboy
On Saturday, August 27, 2016 at 5:45:58 PM UTC+1, GP wrote: > I have installed numpy using the command pip install numpy from command > prompt and I am getting the following error: > Traceback (most recent call last): > File "", line 1, in > import numpy > File > "C:\Users\GP\AppData\Loc

Re: integer's methods

2016-08-27 Thread Grant Edwards
On 2016-08-27, Random832 wrote: > On Sat, Aug 27, 2016, at 13:24, Grant Edwards wrote: >> Becuase the parser thinks you've entered a floating point number with >> a fractional part of "bit_length". > > 123.+456 doesn't think that the fractional part is "+456". That's because the parser (or more t

Multimeter USB output

2016-08-27 Thread Joe
Hi, I'm using Python 3.5.1 with PyUSB 1.0 under Win 10 (64). We try to read the USB output of a DMM 'UT61B'. import usb.core import usb.util import usb.backend.libusb1 def Gosub(): dev = usb.core.find(idVendor=0x1a86, idProduct=0xe008) # Digital Multimeter UT61B if dev == None:

Re: PEP 492: isn't the "await" redundant?

2016-08-27 Thread Kouli
Thank you for all your answers. After all, I am more confident with the current syntax. The most important reason for 'await' to me now is the fact you quite _often_ need to prepare the 'awaitable' object to wait for it later (like the ChrisA's example with print()), i.e. split the expression into

Error numpy install

2016-08-27 Thread GP
I have installed numpy using the command pip install numpy from command prompt and I am getting the following error: Traceback (most recent call last): File "", line 1, in import numpy File "C:\Users\GP\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\__init__.py", line 18

Re: integer's methods

2016-08-27 Thread Random832
On Sat, Aug 27, 2016, at 13:24, Grant Edwards wrote: > Becuase the parser thinks you've entered a floating point number with > a fractional part of "bit_length". 123.+456 doesn't think that the fractional part is "+456". (Of course, the real reason is "because it would be even more annoying to ge

Re: integer's methods

2016-08-27 Thread Grant Edwards
On 2016-08-18, ast wrote: > Hello > > I wonder why calling a method on an integer > doesn't work ? > 123.bit_length() > SyntaxError: invalid syntax Becuase the parser thinks you've entered a floating point number with a fractional part of "bit_length". You need to enter the integer such tha

Re: Is duck-typing misnamed?

2016-08-27 Thread Larry Martell
On Fri, Aug 26, 2016 at 7:58 PM, ROGER GRAYDON CHRISTMAN wrote: > "If it walks like a duck, quacks like a duck,... " > > so there is indeed precedence for this so-called 'duck typing' > > > but wouldn't it be more Pythonic to call this 'witch typing'? > > "How do you know she is a witch?" > > "She

Re: Python script for searching variable strings between two constant strings

2016-08-27 Thread ddream . merchantt
Thanks for the lead. I have big log file nearly 2 GB. Lets say I just want to extract the ;name' field only eg. AutoAuthOSUserSubmit.The code is failing with errors. Can you just give a tested code only for the name field. Other fields I will try to work out. --- On Saturday, August 27,

Re: Is duck-typing misnamed?

2016-08-27 Thread Ned Batchelder
On Saturday, August 27, 2016 at 5:50:30 AM UTC-4, ROGER GRAYDON CHRISTMAN wrote: > "If it walks like a duck, quacks like a duck,... " > > so there is indeed precedence for this so-called 'duck typing' > > > but wouldn't it be more Pythonic to call this 'witch typing'? > > "How do you know sh

Re: Is duck-typing misnamed?

2016-08-27 Thread breamoreboy
This should go to Python ideas as it would involve a substantial change to the docs. Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list

Is duck-typing misnamed?

2016-08-27 Thread ROGER GRAYDON CHRISTMAN
"If it walks like a duck, quacks like a duck,... " so there is indeed precedence for this so-called 'duck typing' but wouldn't it be more Pythonic to call this 'witch typing'? "How do you know she is a witch?" "She looks like one." etc. I do grant that ultimately, the duck does come into

Python script for searching variable strings between two constant strings

2016-08-27 Thread ddream . merchantt
import re infile = open('document.txt','r') outfile= open('output.txt','w') copy = False for line in infile: if line.strip() == "--operation():": bucket = [] copy = True elif line.strip() == "StartOperation": for strings in bucket: outfile.write( strin