Anindya
Anindya
Explore posts from servers
MModular
Created by Anindya on 6/14/2024 in #questions
How to declare a function type in a trait?
yes, I am thinking of not adding try block but then you saying just using a raise would work with an if?
10 replies
MModular
Created by Anindya on 6/14/2024 in #questions
How to declare a function type in a trait?
Hi, so there was one more problem I am facing
from python import Python


struct Module:
var func_module: PythonObject

fn __init__(inout self, module_path: String):
try:
Python.add_to_path(module_path)
self.func_module = Python.import_module("func")
except Exception:
pass
from python import Python


struct Module:
var func_module: PythonObject

fn __init__(inout self, module_path: String):
try:
Python.add_to_path(module_path)
self.func_module = Python.import_module("func")
except Exception:
pass
So, in any how I was not able to initialize my func_module which is taken from func.py file. I got to insert it under try block other wise giving me error, and once that done, I am getting this kind of error:
/Users/anindyadeepsannigrahi/workspace/Mojo/autograd.mojo:7:8: error: 'self.func_module' is uninitialized at the implicit return from this function
fn __init__(inout self, module_path: String):
^
/Users/anindyadeepsannigrahi/workspace/Mojo/autograd.mojo:7:23: note: 'self' declared here
fn __init__(inout self, module_path: String):
^
mojo: error: failed to run the pass manager
/Users/anindyadeepsannigrahi/workspace/Mojo/autograd.mojo:7:8: error: 'self.func_module' is uninitialized at the implicit return from this function
fn __init__(inout self, module_path: String):
^
/Users/anindyadeepsannigrahi/workspace/Mojo/autograd.mojo:7:23: note: 'self' declared here
fn __init__(inout self, module_path: String):
^
mojo: error: failed to run the pass manager
10 replies
MModular
Created by Anindya on 6/14/2024 in #questions
How to declare a function type in a trait?
I see, but still it is a good start, thanks and now I am starting to see the cons of strong typings .. ughh
10 replies
MModular
Created by Anindya on 6/14/2024 in #questions
How to declare a function type in a trait?
Thanks for the answer, so is it not possible to be more flexible with this apperoach in any ways?
10 replies