Questions tagged [types]
Types, and type systems, are used to enforce levels of abstraction in programs.
types
3,901
questions
1543
votes
17
answers
4.0m
views
Change column type in pandas
I created a DataFrame from a list of lists:
table = [
['a', '1.2', '4.2' ],
['b', '70', '0.03'],
['x', '5', '0' ],
]
df = pd.DataFrame(table)
How do I convert the columns to ...
1227
votes
9
answers
456k
views
What are POD types in C++? [duplicate]
I've come across this term POD-type a few times.
What does it mean?
1925
votes
18
answers
1.6m
views
What's the canonical way to check for type in Python?
How do I check if an object is of a given type, or if it inherits from a given type?
How do I check if the object o is of type str?
Beginners often wrongly expect the string to already be "a ...
182
votes
2
answers
87k
views
How does Python 2 compare objects of different types?
The following snippet is annotated with the output (as seen on ideone.com):
print "100" < "2" # True
print "5" > "9" # False
print "100" < 2 # False
print 100 < "2" ...
207
votes
6
answers
134k
views
Is char signed or unsigned by default?
In the book "Complete Reference of C" it is mentioned that char is by default unsigned.
But I am trying to verify this with GCC as well as Visual Studio. It is taking it as signed by default.
Which ...
209
votes
20
answers
289k
views
Immutable vs Mutable types
I'm confused on what an immutable type is. I know the float object is considered to be immutable, with this type of example from my book:
class RoundFloat(float):
def __new__(cls, val):
...
7555
votes
68
answers
1.3m
views
What is the difference between String and string in C#?
What are the differences between these two, and which one should I use?
string s = "Hello world!";
String s = "Hello world!";
1131
votes
8
answers
275k
views
What is the difference between old style and new style classes in Python?
What is the difference between old style and new style classes in Python? When should I use one or the other?
1562
votes
8
answers
895k
views
What are the differences between type() and isinstance()? [duplicate]
What are the differences between these two code snippets?
Using type:
import types
if type(a) is types.DictType:
do_something()
if type(b) in types.StringTypes:
do_something_else()
Using ...
87
votes
1
answer
8k
views
What is the monomorphism restriction?
I'm puzzled by how the Haskell compiler sometimes infers types that are less
polymorphic than what I'd expect, for example when using point-free definitions.
It seems like the issue is the "...
185
votes
30
answers
885k
views
How can I check if string input is a number?
How do I check if a user's string input is a number (e.g., -1, 0, 1, etc.)?
user_input = input("Enter something:")
if type(user_input) == int:
print("Is a number")
else:
...
307
votes
11
answers
307k
views
Biggest integer that can be stored in a double
What is the biggest "no-floating" integer that can be stored in an IEEE 754 double type without losing precision?
In other words, at would the follow code fragment return:
UInt64 i = 0;
...
872
votes
52
answers
1.0m
views
How do I check that a number is float or integer?
How to find that a number is float or integer?
1.25 --> float
1 --> integer
0 --> integer
0.25 --> float
41
votes
4
answers
73k
views
Auto increment table column
Using Postgres, I'm trying to use AUTO_INCREMENT to number my primary key automatically in SQL. However, it gives me an error.
CREATE TABLE Staff (
ID INTEGER NOT NULL AUTO_INCREMENT,
...
240
votes
2
answers
63k
views
Which is the first integer that an IEEE 754 float is incapable of representing exactly?
For clarity, if I'm using a language that implements IEE 754 floats and I declare:
float f0 = 0.f;
float f1 = 1.f;
...and then print them back out, I'll get 0.0000 and 1.0000 - exactly.
But IEEE ...