Lil'Nish
Lil'Nish
MModular
Created by Lil'Nish on 11/16/2024 in #questions
Vale Status
That would be a good place to go wouldn't it? Thanks!
5 replies
MModular
Created by Lil'Nish on 11/15/2024 in #questions
Clarification on the Meaning of Python Superset
Hey Caroline, thanks for the response. Great to see that supersetting Python is still on the road map!
5 replies
MModular
Created by banananas on 10/23/2024 in #questions
Creating files from code
The only difference from "x" mode is that it will overwrite an existing file with the same name (if it's there) instead of throwing an exception
10 replies
MModular
Created by banananas on 10/23/2024 in #questions
Creating files from code
"w" mode also creates the file
10 replies
MModular
Created by banananas on 10/23/2024 in #questions
Creating files from code
However, I don't think Mojo supports opening a file in "x" mode yet, so you'll need to ensure that the file doesn't already exist manually
10 replies
MModular
Created by banananas on 10/23/2024 in #questions
Creating files from code
You can use the open() function in a context manager in Mojo the same way you would in python, there's no need to interop any python code for this.
fn create_proj(filepath: String) raises:
if os.path.exists(filepath):
raise Error("File already exists.")

with open(filepath, "w") as f:
f.write(String("text goes here"))
fn create_proj(filepath: String) raises:
if os.path.exists(filepath):
raise Error("File already exists.")

with open(filepath, "w") as f:
f.write(String("text goes here"))
10 replies
MModular
Created by Lil'Nish on 10/22/2024 in #questions
Could Mojo be the first all purpose language?
I was referring to programming languages rather than query languages or proof verification tools, but thanks for the input! Wouldn't Mojo need to support dynamic typing and python libraries to be a super set of python? Or are you saying that even if this is true, it won't matter since using the pythonic syntax would be frowned upon.
15 replies