Skip to content

mtshiba/pythonify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pythonify

License: MIT

Install

nimble install https://github.com/gmshiba/pythonify

Available Libraries

  • datetime
  • glob
  • math(as pymath)
  • os(as pyos)
  • random(as pyrandom)
  • sys
  • time

Examples

def

import pythonify

def add(x, y):
    return x + y

with

import pythonify

with pyopen("foo.txt", "r") as f:
    print(f.read())

decorator

import pythonify/datetime as datetime
import pythonify/time as time

proc lap(fn: proc): proc =
        proc inner() =
            echo "---start---"
            var start = pydatetime.now()
            fn()
            echo "---end---"
            echo "time: ", pydatetime.now() - start
        return inner

@lap:
    def testfunc():
        time.sleep(1000)
        print("1 sec")

testfunc()

Exceptions

import pythonify

if true:
    raise SyntaxError("Error!")

str methods

import pythonify
import pythonify/pymath as math

print("pi: {0} e: {1}".pyformat(math.pi, math.e))
print(pyf"pi: {math.pi} e: {math.e}")
print("aaaa".rjust(10))

About

You can write Nim codes with Python style

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages