Linked Questions

-4 votes
3 answers
792 views

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 ...
Chandrahas Balleda's user avatar
0 votes
1 answer
112 views

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 ...
xcalibur's user avatar
76 votes
2 answers
38k views

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: # ...
MutantOctopus's user avatar
19 votes
3 answers
39k views

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 '...
sasuke's user avatar
  • 6,789
4 votes
1 answer
4k views

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 ...
Rishabh Kumar's user avatar
0 votes
2 answers
945 views

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. ...
ParvBanks's user avatar
  • 1,436
-1 votes
1 answer
710 views

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: ...
Avinash Raj's user avatar
0 votes
1 answer
113 views

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) -----------...
Pierre ALBARÈDE's user avatar
-3 votes
2 answers
122 views

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,...
michaelchen's user avatar
2 votes
0 answers
77 views

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'...
MPSC's user avatar
  • 135
0 votes
0 answers
61 views

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,...
klaas's user avatar
  • 1,821