Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread boB Stepp
On Sat, Feb 11, 2017 at 7:08 PM, Steven D'Aprano wrote: > On Sat, Feb 11, 2017 at 02:28:42PM -0600, boB Stepp wrote: > >> Back in the main Python list thread, Marko Rauhamaa suggested >> (https://mail.python.org/pipermail/python-list/2017-February/719322.html): >> >> " >> ... >> Haven't been follo

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread Steven D'Aprano
On Sat, Feb 11, 2017 at 09:10:04AM -0800, Alex Kleider wrote: > What your 's' represents seems quite different to 'mine.' > There must be something else going on. > ??? I think there's an easy explanation for that, which is that eryksun probably just created a variable "s" but didn't show the co

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread Steven D'Aprano
On Sat, Feb 11, 2017 at 02:28:42PM -0600, boB Stepp wrote: > Back in the main Python list thread, Marko Rauhamaa suggested > (https://mail.python.org/pipermail/python-list/2017-February/719322.html): > > " > ... > Haven't been following the discussion, but this should be simply: > >ast.liter

Re: [Tutor] Accessing an entry value input by the user

2017-02-11 Thread Alan Gauld via Tutor
On 11/02/17 18:59, Pooja Bhalode wrote: > Hi Alan, > > I had done what you suggested here, I also tried creating another file for > that snipet of the code to see if that section works. The other file works, > but I am not able to figure out why the original one doesn't work. Too late at night fo

Re: [Tutor] Find (list) strings in large textfile

2017-02-11 Thread Danny Yoo
Believe it or not, a change in two characters should make this even faster. :) Change the line: file_list = [i[:-1] for i in my_list.readlines()] to: file_list = {i[:-1] for i in my_list.readlines()} The change is to use a "set comprehension" instead of a "list comprehension". Sets

Re: [Tutor] Find (list) strings in large textfile

2017-02-11 Thread Sylwester Graczyk
It is probably better to store your key file in memory then loop over the large data file and check the line against each key. Better to check 2000 data keys in memory for one loop of the data file. That way you only read the key file and data file once each - 502,000 reads instead of a billion.

Re: [Tutor] Accessing an entry value input by the user

2017-02-11 Thread Pooja Bhalode
Hi Alan, I had done what you suggested here, I also tried creating another file for that snipet of the code to see if that section works. The other file works, but I am not able to figure out why the original one doesn't work. The variable here is entrynumberspeciesvar Code: from Tkinter import *

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread boB Stepp
On Sat, Feb 11, 2017 at 2:06 AM, Steven D'Aprano wrote: > On Fri, Feb 10, 2017 at 07:59:04PM -0600, boB Stepp wrote: > >> He cannot figure out how to reliably tell if the user's input is an >> integer, float or neither. So I thought I would come up with my >> solution, which currently is: >> >> p

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread boB Stepp
On Sat, Feb 11, 2017 at 11:10 AM, Alex Kleider wrote: > On 2017-02-11 00:36, eryk sun wrote: >> >> Note that Python 3 uses the Unicode database to determine the decimal >> value of characters, if any. It's not limited to the ASCII decimal >> digits 0-9. For example: >> >> >>> s >> '௧꘢୩' >

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread boB Stepp
On Sat, Feb 11, 2017 at 11:10 AM, Alex Kleider wrote: > Also of interest (at least to me) was the 'magic' you demonstrated in the > print function parameter list; my efforts to figure it out: Isn't this just argument unpacking? Thus the necessary "*". word = "Hello" print((c for c in

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread boB Stepp
On Fri, Feb 10, 2017 at 7:59 PM, boB Stepp wrote: > I have been following the thread "int vs. float" > (https://mail.python.org/pipermail/python-list/2017-February/719287.html) > on the main list. A search for the OP on the Tutor archive came up > negative, so I am hoping he is not following Tuto

Re: [Tutor] Accessing an entry value input by the user

2017-02-11 Thread Alan Gauld via Tutor
On 11/02/17 15:28, Pooja Bhalode wrote: > I am trying to create a label and an entry widget. I am not able to > understand as to how to access the value input by the user in the entry > widget. > > Label(frame1, text = "Number of species:").grid(row=0, column = 1, sticky=W) > entrynumberspecies =

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread Alex Kleider
On 2017-02-11 00:36, eryk sun wrote: On Sat, Feb 11, 2017 at 8:06 AM, Steven D'Aprano wrote: Valid digits for integers include 0 through 9 in decimal Note that Python 3 uses the Unicode database to determine the decimal value of characters, if any. It's not limited to the ASCII decimal digits

[Tutor] Accessing an entry value input by the user

2017-02-11 Thread Pooja Bhalode
Hi, I am trying to create a label and an entry widget. I am not able to understand as to how to access the value input by the user in the entry widget. Label(frame1, text = "Number of species:").grid(row=0, column = 1, sticky=W) entrynumberspecies = Entry(frame1) entrynumberspecies.grid(row=0, co

Re: [Tutor] Test for type(object) == ???

2017-02-11 Thread Steven D'Aprano
On Sat, Feb 11, 2017 at 01:00:11PM +1100, Ben Finney wrote: > boB Stepp writes: > > > I was playing around with type() tonight. If I type (pun intended), I get: > > > > py3: type(5) > > > > Ceci n'est pas un ‘int’. [...] > https://en.wikipedia.org/wiki/The_Treachery_of_Images> For anyone int

Re: [Tutor] Test for type(object) == ???

2017-02-11 Thread Steven D'Aprano
On Fri, Feb 10, 2017 at 07:34:35PM -0600, boB Stepp wrote: > I was playing around with type() tonight. If I type (pun intended), I get: > > py3: type(5) > > > So I naively thought a test for type int should go like: > > py3: type(5) == "" > False The interactive intepreter is great, but you

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread eryk sun
On Sat, Feb 11, 2017 at 8:06 AM, Steven D'Aprano wrote: > Valid digits for integers include 0 through 9 in decimal Note that Python 3 uses the Unicode database to determine the decimal value of characters, if any. It's not limited to the ASCII decimal digits 0-9. For example: >>> s '௧꘢୩'

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread Steven D'Aprano
On Fri, Feb 10, 2017 at 07:59:04PM -0600, boB Stepp wrote: > He cannot figure out how to reliably tell if the user's input is an > integer, float or neither. So I thought I would come up with my > solution, which currently is: > > py3: def ck_input(): > ... value_to_ck = input('Enter a numbe

Re: [Tutor] Test for type(object) == ???

2017-02-11 Thread eryk sun
On Sat, Feb 11, 2017 at 7:35 AM, boB Stepp wrote: > Has this PEP been implemented yet? I am running Python 3.5.2 and it > appears not to work. Also, in "What's New In Python 3.6" > (https://docs.python.org/3/whatsnew/3.6.html) I did not see a mention > of it. You can see in the document header