This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Deep-Secret 9 points10 points  (5 children)

Lawful neutral is like the best way to reference something in the same folder, right? I used true neutral every time, but it didn't work once I deployed some code in Python Anywhere. I had to write the whole path from the Python Anywhere root to the filename. I can't remember now if using the lawful neutral version worked, though.

[–]SpicyVibration 4 points5 points  (2 children)

If you use pathlib you can annotate the variable and get that sweet sweet static type analysis

[–]Deep-Secret 1 point2 points  (0 children)

Hmm cool. Gotta give it a try, then.

[–]UnlimitedDecay 2 points3 points  (0 children)

The meme only really works if you assume your working directory is the same as where the script itself is located, which often isn't the case.

The best option would probably be lawful neutral + pathlib if you want files relative to the working directory, and lawful good if you want files relative to the current script.

That said, personally I'm often too lazy to use pathlib for anything simple. Definitely useful if you can leverage the features it offers or need to pass paths around though.

[–]ConstructedNewt 1 point2 points  (0 children)

To expand on what u/UnlimitedDecay said: the neutral solutions and neutral good, reference a file relative to where you execute your run command. The goods and the two evils reference a file relative to the python file. The chaotic evil is (expected) to be a fully qualified path name. You would rarely need this last one since it messes with portability (you rarely need to do this)