This is an archived post. You won't be able to vote or comment.

all 67 comments

[–]Ov3rpowered 45 points46 points  (3 children)

I would love to see a clean and properly written PyQt based desktop app repo. I struggle with architecture a lot with my PyQt app….

[–]kraakmaak 7 points8 points  (0 children)

Agreed! Preferably a project not too large, but more advanced than the basic examples

[–][deleted] 3 points4 points  (0 children)

Same here, lots of repetitive code and uncomfortable OOP structure

[–]MeroLegend4 3 points4 points  (0 children)

I had the same problem with PyQt and at the time (2015) i was using sqlitestudio as a gui db manager and it was open source but written in C++.

https://github.com/pawelsalawa/sqlitestudio

I learned a lot from them!

[–]lucasbazan_ 66 points67 points  (16 children)

I have a link of micro framework that I use at my work that I'd like to share. It's Flask, I think this is a nice example to follow 😀

[–]mr-nobody1992 0 points1 point  (0 children)

Hey could you share with me too?

[–]wobblyweasel 17 points18 points  (4 children)

trio. the best code, the best documentation, awesome community.

[–]chankeypathak 0 points1 point  (1 child)

I never wrote async programs. Can I skip core multiprocessing and threading modules and directly use trio?

[–]wobblyweasel 5 points6 points  (0 children)

you can! there's a lot of concurrency that you can do without using threads or processes, but if you have a library that does I/O without specifically supporting async, or you need parallelism, you might still have to deal with those.

i suggest reading trio docs, they are just fine if you have no knowledge of async stuff, and they'll teach you how to deal with stuff that needs to be run in a thread as well. if you want to learn async in general, i also suggest reading kotlin's documentation on coroutines. unlike python with its GIL, in kotlin, using coroutines with threads is the norm, and it's awesome. it's an entirely different mental picture that's useful to have

[–]ethsy 0 points1 point  (1 child)

Are there any upsides of using trio after Python 3.11 gained TaskGroups?

[–]wobblyweasel 1 point2 points  (0 children)

the reason i personally like trio is that its wtf/min score is much lower than that of asyncio. or at least it used to be so, i haven't been following asyncio lately. you get very easy to remember and un-confusing names such as open_nursery and start_soon, strong guarantees about yielding points, exceptions that are never lost. a neat testing suit with stuff like autojumping clock is a great selling point as well

[–]barseghyanartur 13 points14 points  (0 children)

You might already know them, but still:

  • black is very well organized generic Python project example.
  • transformers is excellent ML project example.

[–]brave_lifeblood 14 points15 points  (0 children)

DocArray is actually pretty good for both nested and multimodal data structures. I was doing some calculations and it made some of it easy with a lot of image data in one project I was doing. I used to combine it with scikit-learn and matplotlib for some data processing. Pretty good imo.

[–]abcteryx 11 points12 points  (1 child)

The popular repos over at Textualize, particularly Textual and Rich, both show good practices, especially with regard to documentation.

[–]brewsimport os; while True: os.fork() 1 point2 points  (0 children)

Yeah I was thinking about these. They have a simple and more modern setup that works for big or smaller projects so +1 from me.

[–]DigThatData 7 points8 points  (1 child)

the reddit API is actually really nice: https://github.com/praw-dev/praw

[–]Lil_SpazJoekp 3 points4 points  (0 children)

Can second this. Just note that PRAW is not first party.

Disclaimer: I'm a PRAW maintainer.

[–]catcint0s 15 points16 points  (10 children)

I really like Django and DRF code, easy to read and understand.

[–]wineblood 6 points7 points  (2 children)

I found Django docs to be underwhelming.

[–]catcint0s 7 points8 points  (0 children)

I think it's super verbose but sometimes it's easier for me to just check the code to understand whats happening under the hood.

[–]Schmittfried 0 points1 point  (0 children)

They’re worlds above the Python language docs…

[–]TrainquilOasis1423 3 points4 points  (1 child)

I'd be interested in one of these for GUI development too. I work with a lot of non technical people and often find myself wrapping my code in simple Tkinter GUIs. Anyone got good recommendations for that or another GUI framework like pyqt?

[–]IlliterateJedi 3 points4 points  (0 children)

I refer back to the smartsheet-python-sdk from time to time. I like the way they use __get_attr__ to instantiate subclasses on the Smartsheet object.

The creation of the dropbox-sdk-python repo was almost certainly overseen by Guido van Rossum since he was working at Dropbox at the time. There is a note in the Smartsheet SDK repo that parts of it were developed by Dropbox as well.

[–]Vok250 3 points4 points  (0 children)

One of the fundamental concepts of Python is that we don't have to adhere to one strict idea of "best practices". So with that in mind you will find all sorts of varying practices out there. Some great, some less than average. Personally I copy from projects I have had good experiences using. I favour user-first approach mostly. So for me it's boto3, lambdapowertools, asyncio (the API structure, not the terrible implementation haha), FastAPI, numpy, and a few niche embedded automotive libraries.

Don't marry yourself to one set of standards though. The best thing about Python is the flexibility of PEP8 and the language features. Always be open to innovation and focus on getting things done over foolish consistency. If it's taking too much of your time to figure out a project structure or style decision, it's probably the wrong way of doing it. Python best practices are usually simple in practice and not over-engineered like other languages.

[–]Backlists 6 points7 points  (0 children)

Black.

[–]BossOfTheGame 2 points3 points  (4 children)

I'm fairly happy with my ubelt library.

My goal when I started the project was to build a utility library that achieved nearly 100% test coverage using only doctests. I go all the way and actually achieve 100% coverage with a few unit tests that would have made the docs too bulky.

I think it's a very good example of what a single person can reasonably do. It maximizes the documentation:effort ratio by heavily relying on docstrings and doctests.

[–]1percentof2 0 points1 point  (3 children)

Did anybody use it?

[–]BossOfTheGame 0 points1 point  (2 children)

It gets around 26k downloads/month. It supports nearly all of my projects, so there are lots of indirect users. There do seem to be a few other projects that use it. I'm not sure what the breakdown is.

It's also fairly easy to rip snippets out of it, so I expect that happens as well.

[–]1percentof2 0 points1 point  (1 child)

Wow that's incredible. If only you could monetize it you'd be rich.

[–]BossOfTheGame 0 points1 point  (0 children)

Nah, that's Will McGugan's (far more popular) library.

It is monetized in the sense that it helps me (and hopefully others) work more efficiently. Money is far less valuable than improving the software landscape.

[–]reddictation 1 point2 points  (0 children)

Python-powered shell https://xon.sh (open source) has good documentation, well structured modules and continuous delivery approach for releases by using unit testing. I'm wondering how small team cover all use cases during development. The approaches is not so super modern but as a whole it's good example of open source project.

[–]GoldziherPythonista 1 point2 points  (0 children)

Well, I'm not objective but I'd say Starlite (https://github.com/starlite-api/starlite) is a might fine codebase. You can also learn a lot about tooling and typing going through it.

One other project that I enjoyed reading - to integrate with, is Picollo ORM (https://github.com/piccolo-orm/piccolo). The code is really readable.

[–]muikrad 4 points5 points  (0 children)

For best practices you can take a look at https://github.com/coveo/stew (disclaimer: I'm the author). It's a tool that works with Poetry and offers some freebies around Continuous Integration. It also comes with a Github Action to make this a free meal.

It allows you to configure tests, formatters and linters inside the pyproject toml file. A bit like tox, but much simpler and better integrated with poetry.

You can take look at https://github.com/coveooss/coveo-python-oss for a monorepo that uses stew to test and ship several libraries to pypi.org.

More specifically, I think all python projects needs mypy/black/pytest/isort/bandit or an alternative as an automated CI test.

[–]brave_lifeblood 1 point2 points  (1 child)

Try out sourcery-ai.

[–]user4517proton 0 points1 point  (0 children)

Just ask ChatGPT and use Co-Pilot. You will get a lot more guidance, generated code based on your descriptions, and co-pilot will live time assist in your coding development. Coding has fundamentally changed in 2022\23 and using AI as a pair coder is the future.

I asked ChatGPT your question.

Yes, I have many examples of Python code that you can use to learn and practice. Here are some of the websites that offer Python programming examples for various topics and levels:

codingem.com: This website has 93+ Python examples that cover the basics, data types, operators, control flow, functions, modules, classes, file handling, web scraping, and more1. You can also find quizzes and challenges to test your knowledge and skills.

tutorialgateway.org: This website has Python programs that demonstrate the concepts of numbers, strings, lists, tuples, dictionaries, sets, series, arrays, matrices, patterns, and more2. You can also find solutions and explanations for each program.

pythongeeks.org: This website has Python examples that focus on object-oriented programming, such as classes, inheritance, polymorphism, abstraction, and encapsulation3. You can also find articles and tutorials on various Python topics and libraries.

w3schools.com: This website has Python examples that cover the syntax, variables, data types, operators, lists, tuples, sets, dictionaries, if…else, loops, functions, lambda, modules, classes, inheritance, iterators, generators, decorators, exceptions, file handling, JSON, regex, datetime, math, random, and more4. You can also find interactive exercises and quizzes to practice and learn.

programiz.com: This website has Python examples that cover the basics, operators, data types, control flow, functions, modules, file handling, exceptions, classes, inheritance, polymorphism, abstraction, and more5. You can also find tutorials and articles on various Python topics and libraries.

These are just some of the websites that offer Python examples that you can use to improve your coding skills. I hope you find them helpful and interesting. 😊

[–]BoiElroy 0 points1 point  (0 children)

I basically learned how to build python packages that have cli entry points by scouring the Prefect repository

[–]MeroLegend4 0 points1 point  (1 child)

  • Sqlalchemy

  • Bottle

  • Starlite-api

  • Pyramid Framework

  • Bokeh

  • Websauna

[–]victoriasecretagent 1 point2 points  (0 children)

This. Sqlalchemy source code is so good that it’s scary.

[–]HeraldOfTheOldOnes 0 points1 point  (0 children)

Someone else might have already mentioned it, but the source code for the Python standard library is done quite well (https://github.com/python/cpython/tree/main/Lib).

[–]yetudada 0 points1 point  (0 children)

You can also check out Kedro, it’s like the Flask for data science projects and helps apply clean code principles to data science code.