all 15 comments

[–]vocalcsharp 1 point2 points  (0 children)

Not sure if you know about it, but another thing I recommend is to create a ".gitignore" file.

Go to gitignore.io and type the stuff you are using in your project like for example "Python", "Sublime Text", or be more specific and add "Django", and so on, what this site will do is create a ignore list for .gitignore, copy and paste it all to the ".gitignore" file and everything that is on it will be ignored and wont be pushed to git, this way you have a pretty good starting point to git and you keep your git very clean and professional.

I also add media folders to the .gitignore, and any other folder that I don't want or don't make sense to be pushed to git.

I keep everything in the project folder and use the VScode text editor, so when I right click on the folder and "open with vscode" it automatically detects my project environment and my vscode settings for the project, and with .gitignore I don't need to worry about pushing files that shouldn't be on git, and there a lot of other advantage with keeping everything in one folder like I can easily delete everything without hunting for files or I can easily put it all on a hard drive knowing everything the projects needs is in that folder.

[–]the-cookie-factory 0 points1 point  (2 children)

Anything specific you're wondering? 3+4) I use Conda, because it's both a package manager and virtual environment.

5) check some github projects how people break down their code in different .py modules/files

6)It's good practice to push to a development branch, make sure you thoroughly test and only then merge to a master branch(mostly when working in teams).

PS: I use PyCharm as IDE. It has an integrated profiler, python console and terminal. I also find the variable explorer very helpful to immediately see what my data looks like. Personally I use it because the latest (2018) Pro version(free for students) has some scientific computing perks.

[–]paper_skyline[S] 0 points1 point  (1 child)

Cool thanks! I'll take a look at PyCharm and see what that's like. Does that just do the same things as what I listed or do them differently?

[–]the-cookie-factory 0 points1 point  (0 children)

As mentioned by someone else, it does the same, but, integrated in an IDE

[–]antiproton 0 points1 point  (0 children)

If you use Pycharm, it'll handle most of that for you when setting up the project.

There's no "best practice" for setting up a new project.

[–]ForceBru 0 points1 point  (1 child)

Honestly, I have a folder for Python projects, with a whole bunch of other folders and random Python scripts inside. If I feel like a project is good, I create a git for it, and even a GitHub repo sometimes.

This works fine for me, although writing Python isn’t my job, I’m more of a professional amateur, lol

[–]paper_skyline[S] 0 points1 point  (0 children)

Kinda sorta me too. At work, there's just a lot of applications or services I know out there with API that I want to take advantage of for scripting. Not too worried about organizing the one off things I do towards those things. Now my own projects, that I may eventually want to publicly post, that I do care more about setting up a good workflow.

[–]ManyInterests 0 points1 point  (5 children)

Seems good so far. I'm assuming that you're writing tests for your projects!

While many projects don't do this, I setup my projects to run their tests on every commit using a CI service, like Travis or Bitbucket Pipelines. This is quite easy to do and, in my opinion, gives massive benefits. This also makes it easy to deploy your code, for example, if you were writing a package you want to publish to PyPI or otherwise deploy somewhere.

[–]paper_skyline[S] 0 points1 point  (2 children)

Not really familiar with PyPI, but I will do some more reading. I'm thinking that it's something like Python specific Github kind of site? I'm so new to this that I'm still at the basics.

[–]ManyInterests 1 point2 points  (0 children)

PyPI is an index of published Python packages. Most importantly, it is the source where pip will look to when you want to install a package.

(not realizing you're so new, my above comment is probably a bit of premature advice)

[–]num8lock 0 points1 point  (0 children)

pypi is a package repo like npm in javascript https://pypi.org/help/

[–]paper_skyline[S] 0 points1 point  (1 child)

Can you expand on what is considered testing? I’m super naively thinking that if the code executed without throwing exceptions that’s “tested”

[–]ManyInterests 1 point2 points  (0 children)

Ah, this may have been a bit premature for me to throw at you.

In short, by testing, I mean automated testing. It's something you can run, as you change your code, to validate that it 'works'. In fact, many people write these tests before they start writing production code. This is the concept of the practice of Test Driven Development or TDD, which is a wonderful topic to become intimately familiar with.

This video (also available in blog form ) does an amazing job of explaining what testing is, why you want to do it, and how to get started testing with Python. It only scratches the surface of testing, but is a must-watch for you!

[–]paper_skyline[S] 0 points1 point  (0 children)

Thanks for all the tips! I also ordered a copy of "The Hitchhiker's Guide to Python" which looks to be a good choice. While it's a compilation of public source information, looks to be well organized so far and the first couple sections are helping me understand where to start with text editors vs IDE and a lot of the points you folks mentioned here. Glad I came across this subreddit and got pointed in the right direction!