diff --git a/Nim-for-Python-Programmers.md b/Nim-for-Python-Programmers.md index 7494e97..fe84547 100644 --- a/Nim-for-Python-Programmers.md +++ b/Nim-for-Python-Programmers.md @@ -182,17 +182,6 @@ echo lc[ y | ( y <- x, y > 5 ), int ] echo lc[ y*2 | ( y <- x ), int ] ``` -### Python dictionaries - -``` Nim -import tables - -var a = {"hallo": "World", "Key2": "Value2"}.newTable - -for key, value in a: - echo key, " " ,value -``` - ### Python sets Python sets are not like [Nim set type](http://nim-lang.org/docs/manual.html#types-set-type). @@ -206,9 +195,14 @@ Use [Tables](http://nim-lang.org/docs/tables.html) for Python dicts, OrderedTable for Python ordered dicts, and CountTable for Python's Counter. ``` Nim +import tables + var a = {"hi": 1, "there": 2}.toTable echo a["hi"], " ", a.len assert a.hasKey("hi") + +for key, value in a: + echo key, " " ,value ``` ### ABC