Git Product home page Git Product logo

python-starter's Introduction

Python Starter

This is the base code to start a basic project with Pyhton.

Quick start

# Confirm Python version
python --version

# Run code
python main.py

Set up the environment

# Create a new virtual environment
python -m venv venv

# Activate a virtual environment
source venv/bin/activate

# To deactivate a virtual environment
deactivate

Run the requirements file

# Set up Python environment
pip install -r requirements.txt

# Generate a requirements file
pip freeze > requirements.txt 

Install the dependencies of your package

# Perform an editable install
pip install -e .

# Install the extra dependencies
pip install -e .[extra_feature]

Use consistent naming

Try to follow https://pep8.org/ convention, like:

  • Using underscores for variables and functions
  • Using capital letters for classes
  • Using macro case for constants

Here are some examples:

import os   # STD lib imports first
import sys  # alphabetical

import some_third_party_lib  # 3rd party stuff next
import some_third_party_other_lib  # alphabetical

import local_stuff  # local stuff last
import more_local_stuff


_a_global_var = 2
_b_global_var = 3

A_CONSTANT = 3.14


# 2 empty lines between top-level funcs + classes
def naming_convention():


class NamingConvention(object):

Check your code for consistency

# Install Ruff
pip install ruff

# Run Ruff as a linter
ruff check .                  # Lint all files in the current directory and subdirectories
ruff check path/to/code/*.py  # Lint all `.py` files in `/path/to/code`

# Run Ruff as a formatter
ruff format .                 # Format all files in the current directory and subdirectories
ruff format path/to/code/*.py # Format all `.py` files in `/path/to/code`

python-starter's People

Contributors

rredlich avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.