Linked Questions
11 questions linked to/from Class vs. Type in Python
-4 votes
3 answers
792 views
Query on type() in Python [duplicate]
When I run the following, I got the output as below: x = [1, 2, 3, 4, 5] print(type(x)) y = "PYTHON" print(type(y)) Output: <class 'list'> <class 'str'> I have read that everything in ...
0 votes
1 answer
112 views
Data types and classes [duplicate]
What is the exact difference between class and data types? For checking the data type in Python, we used type(). For example we have a boolean data type, this will display <class 'bool'> in the ...
76 votes
2 answers
38k views
Name not defined in type annotation [duplicate]
I'm currently working on creating a python linear algebra module for fun and for practice with the language. I recently tried to add type annotations to the module, as such: class Vector: # ...
19 votes
3 answers
39k views
Types and classes in Python
I'm a bit confused about types and classes in Python. For e.g. the following REPL conversation confuses me: >>> class A: pass ... >>> a = A() >>> type(a) <type '...
4 votes
1 answer
4k views
what is the difference between type class and object class in python
I am learning about metaclass and I see that every class is a subclass of type class in python but sometimes I see people are using object class but object class is also a subclass of type class then ...
0 votes
2 answers
945 views
Unable to create a dataframe from a list of dictionaries returned by a RPyC function
I am trying to use a function within a RPyC threaded server which returns the dict containing file attributes such as location, filename by looping over all the folders within the specified path. ...
-1 votes
1 answer
710 views
vscode complains about python's classmethod typing
My vscode editor always complains about the classmethod typing irrespective of the class. from __future__ import annotations class A: @classmethod def foo(cls: type[A]) -> str: ...
0 votes
1 answer
113 views
Inconsistency on module in IPython
IPython seems inconsistent here: In [1]: import sys In [2]: sys.version Out[2]: '3.10.11 (main, May 16 2023, 00:28:57) [GCC 11.2.0]' In [4]: type(sys) Out[4]: module In [5]: type(module) -----------...
-3 votes
2 answers
122 views
What does "class" mean in python 3 built in functions
class int(x=0) class int(x, base=10) Return an integer object constructed from a number or string x, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers,...
2 votes
0 answers
77 views
Why Python2 shows <type 'int'> and Python3 shows <class 'int'> [duplicate]
I am learning Python through a video tutorial and tutor is using Python2. I am using Python3 to test and learn the code. In this process I have noticed the difference: Python2: type(10) <type 'int'...
0 votes
0 answers
61 views
Is there a good way to have something like a bit more semantic type annotations in Python? [duplicate]
I have a concrete example with a method that accepts two timestamps (which are floats), but a type: float in the annotation doesn't tell you anything about the semantics. def myfunc( start_date: float,...