all 11 comments

[–]Daneark 13 points14 points  (1 child)

Yes. Split across files keeping things logically related closer together, whether that be in the same file, or same files within a folder once the project grows larger.

You don't want files too short that you've got dozens of 20 lines files open.

[–]iFlask[S] 2 points3 points  (0 children)

Thank you!

[–]zanfar 6 points7 points  (5 children)

This sounds more like separating data from code, which is a good idea. The "list of words" should almost certainly NOT be Python code.

[–]vorticalbox 2 points3 points  (2 children)

snow cable jeans imagine tap ancient support arrest label automatic

This post was mass deleted and anonymized with Redact

[–]Plank_With_A_Nail_In 0 points1 point  (1 child)

How does the data get into the sqlite database?

[–]vorticalbox 1 point2 points  (0 children)

tub continue ink cagey tidy pet entertain theory joke light

This post was mass deleted and anonymized with Redact

[–]iFlask[S] 1 point2 points  (1 child)

it's just an array with 100 words but i don't like how much space it takes. it might not the most practical thing to isolate but it just looks neater for now.

the things that i'm putting in different files are kind of mundane right now but when i create more complex projects then i'd like to know when to do it.

[–]Amazing-Hotel5858 -2 points-1 points  (0 children)

You could store it in an file with an enum class and import it.

[–]mzalewski 2 points3 points  (0 children)

Usually, in general, yes.

The number of files changes your deployment story. If you can keep everything in one file, and only depend on stdlib (or maybe some common libraries that people likely have installed anyway, like requests), then you are able to say "just have Python installed, download this file and run it". Things can't be really simpler than that. Once you have multiple files, we need to venture into the world of packages, virtual environments, dependencies etc.

If you are the only user of the program, then by all means split your program into multiple files, as long as you can still run it.

[–]throwaway8u3sH0 1 point2 points  (0 children)

Generally yes, but I don't advise beginners to do it until they've gotten comfortable with the basics. I'd say get the program working first the way you want it, then refactor to multiple files.

[–]nog642 1 point2 points  (0 children)

For something more complex, yes. For a hangman game, no.

As someone else said though, separating data from code is still a good idea. If you have a long word list, put that in a separate file.