From e810404cdae5155190641502a2b5e86520627c7f Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Wed, 22 Apr 2015 13:32:23 +0100 Subject: [PATCH] Updated Nim for Python Programmers (markdown) --- Nim-for-Python-Programmers.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Nim-for-Python-Programmers.md b/Nim-for-Python-Programmers.md index c8e938f..eb722ad 100644 --- a/Nim-for-Python-Programmers.md +++ b/Nim-for-Python-Programmers.md @@ -128,6 +128,17 @@ So, when using inheritance, be sure to inherit using refs, unless you know what ## From Python to Nim +### Python strings + +Use double quotes: "foo" or """foo""", not 'foo' + +Strings are always unicode. Remember to use runes() to iterate over unicode characters instead of bytes. + +``` Nim +var a = "hello" +echo a[0..1] # returns "he": ranges are inclusive! +``` + ### Python tuples Nim Tuples are close to Python nametuples, see [manual](http://nim-lang.org/manual.html#tuples-and-object-types).