Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Should data be present in Docker-containerized db after applying migrations?

Been struggling with this for about a week now, and I’m probably not googling the right keywords.

I’m new to both django and docker. I’m able to stand up my web app and connect it to the Postgres db I created via docker-compose (db is created as a volume) but I’m running into a problem when I try to access data that should be on the db.

The behavior that confuses me:

If I navigate to localhost:8000 and try the “search” functionality (essentially should just be searching for the query within the db) before applying migrations I see in the logs two things:

1. The database logs trying to query the specific tables
2. Web app returns an error because those tables do not exist yet (need to apply migrations)

I also see the page error out. This is completely expected behavior IMO.

If I try this again after applying migrations (either manually or via an entry point) this is what I see:

1. The web app logs the GET requests of me navigating to the search page and my search query after I hit enter on the search page
2. Nothing is logged for the db container - shouldnt it still query the tables

/r/djangolearning
https://redd.it/l9r781
I’m creating a Django portfolio to both build experience and become a better programmer and was looking for suggestions/tips/tools etc I can incorporate?

The idea here is to start by building a simple personal portfolio that includes apps for an about me page, a projects page, a blog and a ‘versions’ section which will keep note of my progress and modifications.

So far I’ve built out the about me, projects and blog apps using Python, JS and Bootstrap. I would like to continue adding new apps that are built with new concepts, tools and languages. For instance, what I plan on adding next is a Todo app built with React.

I’m looking for any suggestions as far as future apps I can build that can be implemented well with Django and Python. For example, developing a section built with TypeScript or another functional programming language.

Aside from new languages & tools, I’m also looking for general ideas that will test my knowledge and teach me new skills.

I appreciate any feedback or leaning tips that can be provided!

/r/django
https://redd.it/laa3ti
A list of 30 Python language tricks

I wrote this article, 30 Python Language Tricks, on Medium. it's a "friend link" which bypasses the paywall. It contains a wide selection of topics, for both beginners and more advanced level programmers. Enjoy and let me know if you liked it!

/r/Python
https://redd.it/la04qd
Tuesday Daily Thread: Advanced questions

Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.

If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/lai6i5
Flask or MERN for auction-like web applications?

I have experience with both Flask and MERN and there's a client who wants to create a web application for users to sell and bid on other products. Is there a better option between Flask and MERN for a robust web app like this? Do you have other recommendation regarding anything else related?

Thank you so much in advance:)

/r/flask
https://redd.it/la39qp
Introducing SHTK - A Python module that makes it easier to replace BASH scripts with Python

The Python Shell Toolkit (SHTK) reduces the effort necessary to rewrite BASH scripts in pure Python. The module strives to provide (almost) the terseness of BASH while allowing programmers to work with modern language amenities such as classes, namespaces, exceptions, argument parsers and package managers. Together these features provide an unmatched ability to integrate third party applications while maximizing potential for code-reuse.

If you have a moment, please check out the showcase examples on the Github page and let me know what you think of the goal, missing features, or use cases you image would benefit from such a tool. I built it for image and container building, for example with Raspberry Pi images or Docker containers.

Documentation, unit tests, linting and coverage reports included.

Links:

https://github.com/jroose/shtk

https://pypi.org/project/shtk/

https://shtk.readthedocs.io/en/latest/

/r/Python
https://redd.it/lah2qv
How/where to store users' decrypted symmetric keys in session?

Hey all!

I'm working on a bit of a POC Flask app right now, and one thing I'm focusing on is ensuring that 100% of my user-submitted data is encrypted at rest. Currently it looks as follows:

1. Use user password to generate user key with KDF
2. Generate symmetric user key for all data encryption/decryption
3. Encrypt symmetric key with user key
4. Persist encrypted symmetric key to DB

I'm following these steps such that all user data doesn't have to be re-encrypted in the case of a password rotation.

So my question.. I've designed this all such that the entire process is dependent on the user's password, provided at runtime. Naturally, requiring a user to input their password to decrypt their symmetric key every single time I'd need to decrypt and return their data seems like overkill, so I'd like to utilize some type of session.

I've researched this a fair bit online already, and all my research points me towards implementing a server-side session for the user's sensitive data (the decrypted symmetric user key), but this confuses me a bit.. My overall initial intention was to keep no sensitive user data server-side. If the decrypted user keys were found alongside the encrypted user data, there's

/r/flask
https://redd.it/lagm07
Question about embedding html audio tags in pandas table in jupyter notebook

https://imgur.com/a/EJEi8vj

I have managed to embed audio in a Pandas dataframe. I do this with a custom HTML5 snippet rather than using the built in IPython.display.Audio since that tends to not accurately display the duration of the wav. This is very useful for analysing WER or reviewing audio batches which you wish to sort by error.

Questions:

1. If I use the full path to the file e.g. /home/username/data/audio.wav it does not work since the path is assumed not to be complete (like a normal href) so it will append http://localhost:8888/ to the front. So this only works with relative paths, is there a way to prevent this?

2. Why does IPython.display.Audio not display the duration correctly? Is this a known issue? What is the difference between using this and native html <audio>, they look very similar.

3. I tried to include a more fancy audio component (had css/js) and it didn't work. It looks like Jupyter is stopping the notebook loading custom files (possibly for security)? Would the correct way to extend this be with a Jupyter extension?

Any help appreciated!

/r/IPython
https://redd.it/la6afm
7 Ways to Make Money as a Django Developer

Hi :-)

I just published a new video where I talk about seven different ways to make money with Django.

Maybe you’ve been playing around with Django for a while, and now your want to take the next step and make money using it. You might just want a little side income or maybe you want a full time job as a developer.
Anyways, there are many different ways to make money using Django, and in this video I will talk about seven of them.

I would love to get some feedback on this :-)

The video can be found here:
https://www.youtube.com/watch?v=zf6zy\_EoeWs

/r/djangolearning
https://redd.it/laqxy1
Should you be using Pathlib?

I've been working in Python for four years - recently I made the conscious choice to use pathlib rather than the more familiar os & os.path.

It's been a great experience - I wrote a short piece (friend link) comparing the two libraries on common workflows & tasks done with file paths.

/r/Python
https://redd.it/lapus9