You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from lpython import i32
def main0(i: i32):
x: i32
x = (2+3)*5+i
print(x)
if __name__ == "__main__":
main0(5)
This works with cpython, it will ignore the lpython.py.
#2328 Suppose you have a file named lpython.py that defines the i32 type and any other functionality you need. Your lpython.py file could look like this:
lpython.py
class i32:
def init(self, value: int):
self.value = value
Activity
Lavanyajc commentedon Sep 17, 2023
#2328 Suppose you have a file named lpython.py that defines the i32 type and any other functionality you need. Your lpython.py file could look like this:
lpython.py
class i32:
def init(self, value: int):
self.value = value
#Now, you can modify your main script to work with the lpython module:
from future import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from lpython import i32
def main0(i: i32):
x: i32
x = (i32(2) + i32(3)) * i + i
print(x)
if name == "main":
from lpython import i32 # Import the i32 type from lpython
main0(i32(5)) # Pass an i32 instance to main0
i hope its right