Skip to content

Latest commit

 

History

History
356 lines (186 loc) · 2.15 KB

README.md

File metadata and controls

356 lines (186 loc) · 2.15 KB

Py_Trans

Customized python syntax with LangTrans

Customized Syntax Original Syntax
p"Hello World"
print("Hello World")
inc = (x) => x+1
inc = lambda x: x+1
twice(x) = 2*x
add(x,y) = x+y
twice = lambda x:2*x
add = lambda x,y:x+y
1 -> inc
|> twice -> print
print(twice(inc(1)))
print<-inc<-twice<-1
print(inc(twice(1)))
try inc("1") Exception print("Error:",err)
try:
  inc("1")
except Exception as err:
  print("Error:",err)
print((x||True)?"Done":"Failed")
print("Done" if (x if 'x' in locals() else True) else "Failed")
print('x is not defined') if !x
if 'x' not in locals():
   print('x is not defined')
print((inc+twice)(3))
print(inc(3)+twice(3))
make type name(object):
    x = 1
    if x==1:
      pass
    y = 3

make dict test:
    this =  "this"
    if this == "this":
      pass
    that = "that"
def name():
    x = 1
    if x==1:
      return locals()
    y = 3
    return locals()
name = type("name", (object,), name())

def test():
    this =  "this"
    if this == "this":
        return locals()
    that = "that"
    return locals()

test = test()
#scope1#
print("Scope1")
print("Done")

#scope2#
print("Scope2")
print("Done")
def scope1():
    print("Scope1")
    print("Done")
scope1()

def scope2():
    print("Scope2")
    print("Done")
scope2()

This is an example, feel free to edit the syntax in your way.