Questions tagged [types]

Types, and type systems, are used to enforce levels of abstraction in programs.

The concept of types classifies values, expressions, data structures and modules into sets.

The type system is the syntactic framework to describe, infer and enforce this classification. The typing and their checks can be performed at compile-time or at run-time.

See also

28480 questions
7486
votes
66 answers

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!";
Lance Fisher
  • 25,684
  • 22
  • 96
  • 122
2163
votes
55 answers

Check if a value is an object in JavaScript

How do you check if a value is an object in JavaScript?
Danny Fox
  • 38,659
  • 28
  • 68
  • 94
2127
votes
15 answers

Determine the type of an object?

Is there a simple way to determine if a variable is a list, dictionary, or something else?
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
2122
votes
22 answers

How to determine a Python variable's type?

How do I see the type of a variable? (e.g. unsigned 32 bit)
user46646
  • 153,461
  • 44
  • 78
  • 84
1856
votes
15 answers

Type Checking: typeof, GetType, or is?

I've seen many people use the following code: Type t = typeof(SomeType); if (t == typeof(int)) // Some code here But I know you could also do this: if (obj1.GetType() == typeof(int)) // Some code here Or this: if (obj1 is int) // Some…
jasonh
  • 29,297
  • 11
  • 59
  • 61
1842
votes
16 answers

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 number" - either expecting Python 3.x input to convert…
Herge
  • 20,857
  • 4
  • 23
  • 17
1540
votes
8 answers

What are the differences between type() and isinstance()?

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 isinstance: if isinstance(a, dict): …
abbot
  • 27,408
  • 6
  • 54
  • 57
1475
votes
16 answers

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 specific types? In this case, I want to convert…
user1642513
1209
votes
9 answers

What are POD types in C++?

I've come across this term POD-type a few times. What does it mean?
oz10
  • 153,307
  • 27
  • 93
  • 128
1192
votes
13 answers

What are "named tuples" in Python?

What are named tuples and how do I use them? When should I use named tuples instead of normal tuples, or vice versa? Are there "named lists" too? (i.e. mutable named tuples) For the last question specifically, see also Existence of mutable named…
Denilson Sá Maia
  • 47,466
  • 33
  • 109
  • 111
1124
votes
8 answers

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?
readonly
  • 343,444
  • 107
  • 203
  • 205
1014
votes
22 answers

How to check if type of a variable is string?

Is there a way to check if the type of a variable in python is a string, like: isinstance(x,int); for integer values?
c_pleaseUpvote
  • 10,173
  • 3
  • 15
  • 6
963
votes
13 answers

Difference between text and varchar (character varying)

What's the difference between the text data type and the character varying (varchar) data types? According to the documentation If character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
918
votes
12 answers

Limit file format when using ?

I'd like to restrict the type of file that can be chosen from the native OS file chooser when the user clicks the Browse button in the element in HTML. I have a feeling it's impossible, but I'd like to know if there is a…
Bojangles
  • 99,427
  • 50
  • 170
  • 208
913
votes
11 answers

How to create a new object instance from a Type

One may not always know the Type of an object at compile-time, but may need to create an instance of the Type. How do you get a new object instance from a Type?
tags2k
  • 82,117
  • 31
  • 79
  • 106
1
2 3
99 100