python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
How to typecheck real numbers, and type-safely compare them to ints
I have a function that inputs a real number. In practice it might be an int or a float. and I want it to check if it is >0
For example
def f(x):
return x > 0
Now I want that function to be t...
Nephanth
Votes: 0
Answers: 0
Why does mis-typed type hints work well in the code while it does not in debug console?
What I tried to do was:
from typing import List
class Board():
def __init__(self, width, height):
self.width = width
self.height = height
self.layout: List[List[int]] = [] ...
keizikang
Votes: 0
Answers: 1
In python typing in the Class method __init__ the argument type annotation I have for 1 attribute is: Callable = None, what does the annotation state?
The init function inside a Class is annotated the following way:
def __init__(self, directory: str, transforms: Callable = None, extension: str = '.jpg'):
The question is what Callable = None is ...
Alex
Votes: 0
Answers: 2
Casting of generic type does not compile
Please have a look at the following code. Why do I get a compile-error?
I don't get it!
Casting is a way of telling the compiler that I know more about the objects than it does. And in this case, I kn...
Andreas
Votes: 0
Answers: 4