Sibbs Gambling
Sibbs Gambling

Reputation: 20375

Start a Python Project with Spyder?

I used to have very short Python codes. So I did not bother to build a project and have separate .py files.

But now, I will have a big Python project. I find myself unfamiliar with how Python projects are organized and built step by step, even though I have good knowledge in Java projects with Eclipse.

How may I start building up my Python project (I am using Spyder as IDE, if this helps)?

Or where can I get some good Python project examples so that I know how the project is usually organized in Python?

Upvotes: 3

Views: 11253

Answers (1)

Shashank
Shashank

Reputation: 13869

Large Python projects usually make use of packages. You can read about the organization of packages and subpackages here. One way would be to have a main library package called lib that contains several smaller subpackages for other components of your code. You can call your main method from main.py within a library package like this:

from lib import main

if __name__ == '__main__':
    main.main()

That's usually all I put in my access point level script on the upper level directory.

A great place to browse large python projects (without downloading them) is GitHub and other similar code repositories.

For general tips on building up a large project...Python is focused on object-oriented programming and readability so make sure to use as many classes and modules as possible to organize your code. Your code should always be readable and the concepts should be fairly easy to grasp. Usually I like to start large projects by outlining all the classes, methods and functions, that I think I'll need and using pass as a lazy placemarker for the actual implementation. Then I reroll over all the pass statements and start writing implementations one by one and testing them using a test suite. I usually do not move on to another implementation until I'm sure that all previous implementations that I have written work properly.

Upvotes: 2

Related Questions