src/pylib

Source   Edit  

Welcome to NimPyLib 0.9.15

Nim Pylib

Just write Python code in Nim!

import pylib

The mostly suggested style is

import pkg/pylib

However, omitting the pkg/ prefix shall be fine at most cases:

import pylib

import Python-like stdlib

under pyimports macro, you can write as if in Python, except for import *:

For star import, use import *MOD instead of from MOD import *, for example:

pyimports:
  import *random
# or a single line `pyimportAll random`

Appendix: Cheatsheet for rough alternative between Nim and Python

Outside pyimports macro, beware you're writing Nim, following is cheatsheet.

Nim pylibPython
from demo/LIB import nilimport demo.LIB
import demo/LIBfrom demo.LIB import *
from demo/LIB import XXXimport demo.LIB; from demo.LIB import XXX

Deprecated stdlib import notations

The traditional notation for importing pystdlib is deprecated and may be unavailable in the future.

For example, import pylib/Lib/math shall be replaced with pyimportAll math.


Wondering how many libs are available in NimPylib?

Here are the Lib Docs.

Warning: std/lenientops was imported automatically. Compile with -d:pylibNoLenient to disable it if you wish to do int->float conversions yourself

Templates

template timeit(repetitions: int; statements: untyped): untyped {....deprecated: "will be removed from main pylib since 0.10, import it from `pylib/Lib` instead".}
Deprecated: will be removed from main pylib since 0.10, import it from `pylib/Lib` instead

EXT.

Mimics Pythons timeit.timeit(), output shows more information than Pythons.

Source   Edit