Re: Testing the data type of a value

2019-05-13 Thread Alan Bawden
Luuk writes: ... > Maybe i should have asked this: > > What is the difference between 'type(5)==int'  and 'isinstance(5,int)' > > and, if there is no difference why did someone invent 'isinstance()' ... Look: Python 3.6.6 (default, Aug 13 2018, 18:24:23) [GCC 4.8.5 20150623 (Red Hat

Re: Testing the data type of a value

2019-05-12 Thread Kushal Kumaran
Luuk writes: > On 12-5-2019 16:07, Piet van Oostrum wrote: >> Luuk writes: >> >>> After thinking about this, (i am prettry new to python), i was doing this: >>> >> print(type(5),type(int),type(5)==type(int),type(5)==int) >>> False True >>> >>> Can someone explain why type(5)==int

Re: Testing the data type of a value

2019-05-12 Thread Luuk
On 12-5-2019 16:07, Piet van Oostrum wrote: Luuk writes: After thinking about this, (i am prettry new to python), i was doing this: print(type(5),type(int),type(5)==type(int),type(5)==int) False True Can someone explain why type(5)==int evaluates to True ? print(int) The

Re: Testing the data type of a value

2019-05-12 Thread Piet van Oostrum
Luuk writes: > > After thinking about this, (i am prettry new to python), i was doing this: > print(type(5),type(int),type(5)==type(int),type(5)==int) > False True > > Can someone explain why type(5)==int evaluates to True ? > >>> print(int) The value of int is the class int,

Re: Testing the data type of a value

2019-05-12 Thread Luuk
On 12-5-2019 10:16, Luuk wrote: On 12-5-2019 09:27, binoythomas1...@gmail.com wrote: When I run the following code, I get the following output: print(type(5)) class 'int' Next, I try to compare the data-type of 5 with the earlier output, I get no output: if type(5) == "":

Re: Testing the data type of a value

2019-05-12 Thread Ben Bacarisse
binoythomas1...@gmail.com writes: > When I run the following code, I get the following output: print(type(5)) > class 'int' > > Next, I try to compare the data-type of 5 with the earlier output, I > get no output: if type(5) == "": > print("Integer") > > Why isn't this working?

Re: Testing the data type of a value

2019-05-12 Thread Luuk
On 12-5-2019 09:27, binoythomas1...@gmail.com wrote: When I run the following code, I get the following output: print(type(5)) class 'int' Next, I try to compare the data-type of 5 with the earlier output, I get no output: if type(5) == "": print("Integer") Why isn't this