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
How do we pass a variable to include tag?

I have a bunch of html files with files names as id.html. I want to include one of the files in another html file depending on the value of id received from the route. I want to do something like this:

{% include 'files/{{ id }}.html' %}

How do I achieve this?

/r/flask
https://redd.it/umdzoq
Is Jupyter Notebooks unreliable or am I good to hand in this project?

I have a final project for a class that I have used jupyter notebooks to complete. There are a lot of graphs and such in the notebook. When I get into the notebook and use "Run All" and run all of the cells it works, but if I go back in and run an individual cell it will crash.

Also, last night it worked perfectly fine when I did run all, but then this morning I did it and some of the cells crashed and I had to fix them.

It feels like sometimes things work in Jupyter notebooks and sometimes they don't, it is honestly really frustrating and makes me glad that I am taught more application development vs data science, because I can't imagine having to use Jupyter notebooks all the time.

I believe they crash because I change variables later on in the code, and when I run the individual cell again the variables have changed so it crashes, but I am not positive since sometimes it works and sometimes it does not.

If I run all and have all of the cells properly working and displaying their graphs will it appear that way when my professor looks at

/r/JupyterNotebooks
https://redd.it/ul8cbb
Sunday Daily Thread: What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.

/r/Python
https://redd.it/ukpqov
Large plots in Jupyter notebooks (in Windows)

I am doing some mapping/GIS work with Python, which leads to large plots. However, I can't seem to enlarge the plot area - at least vertically. I can't change the backend, as the only ones I seem to have available are backend_agg, backend_nbagg, backend_webagg_core. So: how do I install other backends? Or - how do I enlarge the plot area so that the entire plot is displayed; that is, without scroll bars? Thanks!

/r/JupyterNotebooks
https://redd.it/un4l5m
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!

This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.

/r/Python
https://redd.it/unnmyf
2022 Python Language Summit

The Python Language Summit blogs just dropped: [https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit\_01678898482.html](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit_01678898482.html)

There was a lot of focus on making Python faster this year, in a lot of different ways:

* [Optimising single-threaded code](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit_2.html)
* Creating [a version of Python without the GIL](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit-python_11.html)
* Enabling [multiple interpreters to run inside a single process](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit-per.html)
* [Upstreaming async optimisations from Cinder](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit_60.html)
* A proposal for [lazy imports](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit.html)

There's also coverage on [immortal objects](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit_11.html), [f-strings in the grammar](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit-f.html), [dealing with the issue/PR backlog](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit-dealing.html), and [Python in the browser](https://pyfound.blogspot.com/2022/05/the-2022-python-language-summit-python.html).

/r/Python
https://redd.it/unx80h
Django Templates + React

I currently have a project that is a django-rest-api backend with a react/redux front end. I recently implemented "django-wiki" into my project and customized the cosmetics, this project uses django templates. Has anyone ever used django templates on one portion of the website and a different front end framework like react for another portion? I'm having difficulties syncing the login, in the react portion I use local storage to save the jwt for access and i'm not sure where to implement that on the django end so it flows to both portions of the project.

/r/djangolearning
https://redd.it/uo2jip
Didn't get the job, code review please

Hey all,

Recently I applied for a junior backend position and was sent this assignment:

>Create a REST API for cars. It should contain accounts, CarBrand, UserCar, and CarModels. Each user has to be extended by default Django abstract class and should contain a few more columns (for your choice). Each car object contains relations to the user and CarBrand. Each CarModel contains relation to CarBrand. It is all your decision how you will distribute models to different apps. Please make the API URLs with filters (custom typed). All models should be with soft delete.
>
>Models fields:
CarBrand [name, created_at, deleted_at\]
CarModel [car_brand, name, created_at, update_at\]
UserCar [user, car_brand, car_model, first_reg, odometer, created_at, deleted_at\]
>
>Auth:
Please extend the default Django user class and add some custom fields. Create login, register functionality. User default Django permission classes.

I sent this code:

https://github.com/todortoshev/cars-api

https://carsapp.pythonanywhere.com/cars/all/

"User default Django permission classes." - I assumed this applies to django.contrib.auth in INSTALLED_APPS, so I didn't add permissions in settings.REST_FRAMEWORK.

The assignment also says CarModel has to have a field 'update_at', but doesn't mention 'deleted_at', so I left in 'update_at' and added 'deleted_at', as all models must have soft delete.

/r/django
https://redd.it/uo8gz4
How can I make my test so they don't use other tests?

I am testing APIs using APITestCase. For example, I do a test to make a post request to create an instance in the model A, model B has model A as foreign key. If I execute my tests, it gave me an error in the second test saying that model A does not exist, so the easy solution would be to call the test that creates the instance in model A so model B can use it to execute the test but model A would execute two times. I don't think this is correct because if model C needs an instance of model A and B, I would need to add the test where model A and B are created, but that gave me an error because the test of model A would execute 3 times. So what do I do? I create the instance of model A assuming that test will create an instance of model B, but again, I don't think this is correct because it will make a snowball of tests.

class test_A(APITestCase):

def test_post_request(self):


/r/django
https://redd.it/uoasa3
My math high school project

Hello,

The project is full of shit and is so incomplete. Despite that, I feel it is interesting enough to share it here! https://github.com/salastro/math-expert

Thanks for the time.

/r/Python
https://redd.it/uo3318
SQLAlchemy classes from a pre-existing schema

I have .SQL files of the schema and I need to convert them into SQLAlchemy classes (not trying to create all table classes manually). Can I convert the schema into an sqlite db and then use that db to automap into SQLAlchemy table classes? Is there a better way directly using a schema ?

/r/flask
https://redd.it/uol1vj
Developing a multiplayer co-op zombie survival in pygame and python!

Link to the repo: https://github.com/dille12/2dshooter

Here's some singleplayer gameplay. The multiplayer is only PvP and veeery rough rn, the PvE gamemode is coming next.

https://reddit.com/link/uorh3v/video/9a9gz42sq8z81/player

/r/Python
https://redd.it/uorh3v
[D] Machine Learning - WAYR (What Are You Reading) - Week 137

This is a place to share machine learning research papers, journals, and articles that you're reading this week. If it relates to what you're researching, by all means elaborate and give us your insight, otherwise it could just be an interesting paper you've read.

Please try to provide some insight from your understanding and please don't post things which are present in wiki.

Preferably you should link the arxiv page (not the PDF, you can easily access the PDF from the summary page but not the other way around) or any other pertinent links.

Previous weeks :

|1-10|11-20|21-30|31-40|41-50|51-60|61-70|71-80|81-90|91-100|101-110|111-120|121-130|131-140|
|----|-----|-----|-----|-----|-----|-----|-----|-----|------|-------|-------|-------|-------|
|[Week 1](https://www.reddit.com/4qyjiq)|[Week 11](https://www.reddit.com/57xw56)|[Week 21](https://www.reddit.com/60ildf)|[Week 31](https://www.reddit.com/6s0k1u)|[Week 41](https://www.reddit.com/7tn2ax)|[Week 51](https://reddit.com/9s9el5)|[Week 61](https://reddit.com/bfsx4z)|[Week 71](https://reddit.com/d7vno3)|[Week 81](https://reddit.com/f1f0iq)|[Week 91](https://reddit.com/hlt38o)|[Week 101](https://reddit.com/k81ywb)|[Week 111](https://reddit.com/myg8sm)|[Week 121](https://reddit.com/pmzx3g)|[Week 131](https://reddit.com/srsu2n)||||||||||||
|[Week 2](https://www.reddit.com/4s2xqm)|[Week 12](https://www.reddit.com/5acb1t)|[Week 22](https://www.reddit.com/64jwde)|[Week 32](https://www.reddit.com/72ab5y)|[Week 42](https://www.reddit.com/7wvjfk)|[Week 52](https://reddit.com/a4opot)|[Week 62](https://reddit.com/bl29ov)|[Week 72](https://reddit.com/de8h48)|[Week 82](https://reddit.com/f8fs6z)|[Week 92](https://reddit.com/hu6zq9)|[Week 102](https://reddit.com/kh27nx)|[Week 112](https://reddit.com/n8m6ds)|[Week 122](https://reddit.com/pw14z5)|[Week 132](https://reddit.com/t2xpfe)||
|[Week 3](https://www.reddit.com/4t7mqm)|[Week 13](https://www.reddit.com/5cwfb6)|[Week 23](https://www.reddit.com/674331)|[Week 33](https://www.reddit.com/75405d)|[Week 43](https://www.reddit.com/807ex4)|[Week 53](https://reddit.com/a8yaro)|[Week 63](https://reddit.com/bqlb3v)|[Week 73](https://reddit.com/dkox1s)|[Week 83](https://reddit.com/ffi41b)|[Week 93](https://reddit.com/iaz892)|[Week 103](https://reddit.com/kpsxtc)|[Week 113](https://reddit.com/njfsc6)|[Week 123](https://reddit.com/q5fi12)|[Week 133](https://reddit.com/tdf2gt)||
|[Week 4](https://www.reddit.com/4ub2kw)|[Week 14](https://www.reddit.com/5fc5mh)|[Week 24](https://www.reddit.com/68hhhb)|[Week 34](https://www.reddit.com/782js9)|[Week 44](https://reddit.com/8aluhs)|[Week 54](https://reddit.com/ad9ssz)|[Week 64](https://reddit.com/bw1jm7)|[Week 74](https://reddit.com/dr6nca)|[Week 84](https://reddit.com/fn62r1)|[Week 94](https://reddit.com/ijjcep)|[Week 104](https://reddit.com/kzevku)|[Week 114](https://reddit.com/ntu6lq)|[Week 124](https://reddit.com/qjxfu9)|[Week 134](https://reddit.com/tpruqj)||
|[Week 5](https://www.reddit.com/4xomf7)|[Week 15](https://www.reddit.com/5hy4ur)|[Week 25](https://www.reddit.com/69teiz)|[Week 35](https://www.reddit.com/7b0av0)|[Week 45](https://reddit.com/8tnnez)|[Week 55](https://reddit.com/ai29gi)|[Week 65](https://reddit.com/c7itkk)|[Week 75](https://reddit.com/dxshkg)|[Week 85](https://reddit.com/fvk7j6)|[Week 95](https://reddit.com/is5hj9)|[Week 105](https://reddit.com/l9lvgs)|[Week 115](https://reddit.com/o4dph1)|[Week 125](https://reddit.com/qtzbu1)|[Week 135](https://reddit.com/u0pnhf)||
|[Week 6](https://www.reddit.com/4zcyvk)|[Week 16](https://www.reddit.com/5kd6vd)|[Week 26](https://www.reddit.com/6d7nb1)|[Week 36](https://www.reddit.com/7e3fx6)|[Week 46](https://reddit.com/8x48oj)|[Week 56](https://reddit.com/ap8ctk)|[Week 66](https://reddit.com/cd7gko)|[Week 76](https://reddit.com/e4nmyk)|[Week 86](https://reddit.com/g4eavg)|[Week 96](https://reddit.com/j0xr24)|[Week 106](https://reddit.com/ljx92n)|[Week 116](https://reddit.com/odrudt)|[Week 126](https://reddit.com/r4e8he)|[Week 136](https://reddit.com/ub2xlz)||
|[Week