Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modules
#1
I was just wondering how big the program needs to be before you just create modules to import? What is the common practice on that subject?
Thank
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#2
Not quite sure what you're asking.

most all scripts import something.
none ever have imports only
technically you can do it, but what's the point?
Reply
#3
I was just curious. Like on the learning project I been working on, I created a database module that connects and does the queries. One line of code verses 15 lines. The sqlite3 version checks to see if it exist or not. It's less code I'm having to look/scroll through within the main code. It's not really that big of a deal.
Just wondering what the common practice is.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#4
I was wondering the same thing. The easiest thing to distribute is one file, but big files are hard to edit and maintain. Eventually you create some modules and import the module into your program. A module should have a well defined purpose, but depending on what you are doing that can result in rather large modules. You get tired of really big modules so your create sub-modules. To organize your sub-modules you create a directory structure.

It took me months to figure out how to organize my code so I could import my modules and my module inter-dependencies and unit tests and example snippets all work. Even though everything is working I have no confidence that I didn't make some really dumb choices and I'll have to reorganize everything once others start using my code. I have searched for anything that discusses this part of Python and there is not much there. Set your path. Use __import__.py files. Here is how you make a package. Good stuff, but more nuts and bolts than theory or practice.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 bmohanraj91 6 8,464 May-25-2017, 08:15 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020