Skip to content

Commit

Permalink
Modern Python: 3rd version
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Oct 13, 2023
1 parent e4f1cf2 commit a5ee45f
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion docs/modern_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,72 @@ PHP Scala

---

## Statická typová kontrola
## To nejlepší z obou světů?

* Volitelné typy

```
Jazyk Technologie pro statické typy
--------------------------------------------
JavaScript TypeScript, Flow
Python Mypy, Pyright, Pyre
Ruby Sorbet
```

---

### Volitelné typy a Python

* Python je dynamicky typovaný
- a nejsou plány to změnit!
* Typy jsou čistě volitelné
- přidáno do Pythonu 3.5
- nazvané "type hints"
- (aby to vývojáře nestrašilo)
* Statické typové kontroly
- mypy, pyright, pyre

---

### Statická typová kontrola a Mypy

---

![Mypy logo](images/mypy.png)

---

```python
def add(a, b):
return a+b
```

* Typ `Any` je přidán automaticky

---

### Typové anotace

```python
def add(a:int, b:int) -> int:
return a+b
```

### `bool` nebo `int`?

* Viz specifikace Pythonu!

```python
def add(a:int, b:int) -> int:
return a+b

print(add(1, 2))
print(add(1, True))
print(add(1, False))
```

---

## Testování

* Základní technologie testování
Expand Down

0 comments on commit a5ee45f

Please sign in to comment.