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
Best method to share Python environments on Windows machine

We have a group of users on a single Windows server (using separate accounts) hoping to create, share and use Python virtual environments for their work.

I know Anaconda has a solution for this:

https://docs.anaconda.com/free/navigator/tutorials/manage-environments/

But I'm curious if there is another, better, easier way to do this which will minimize my time as the sysadmin!

Thanks in advance!

/r/Python
https://redd.it/187ztin
Using Flask/connexion for both web and OpenApi server.

Hi Guys, I had this requirement of writing simple web page for this project. It already hosts Openapi server inside a docker container. I thought of using the connexion app server used by openapi to render the web page too.
My question is when I try to fetch the api from the Javascript if I mention the host as localhost it's getting timed out. But if I give container ip it works fine. Currently I am opening the web page in the same host machine. If I open the web page in different machines what should be the host in this case.

/r/flask
https://redd.it/187wkc7
List of Python projects and source code

We Just started a new app that will help beginners to practice and also provide a list of python projects with examples for free.

If you are interested to check out please download it and provide your valuable review. This will be great for us

If you are interested you can download it from the below link


https://play.google.com/store/apps/details?id=com.ideasorblogs.app

/r/Python
https://redd.it/18857ql
Issues with Pydantic

I've been experimenting with a few Django-related libraries and they all seem to encounter the same problem:

>pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'function'>. Set \\arbitrary\_types\_allowed=True\\ in the model\_config to ignore this error or implement \`\_\_get\_pydantic\_core\_schema\_\_\` on your type to fully support it.\`\`
>
>If you got this error by calling handler(<some type>) within \\\_\_get\_pydantic\_core\_schema\_\_\\ then you likely need to call \`handler.generate\_schema(<some type>)\` since we do not call \`\_\_get\_pydantic\_core\_schema\_\_\` on \`<some type>\` otherwise to avoid infinite recursion.\`\`

The issue occured often when I'm trying to run code that's coming directly from their tutorials, so I'm confused as to whether something changes in Pydantic that's causing these libraries to fail. In this case, I'm testing the `django-ninja` code that appears in their tutorial on `auth` (here):

https://preview.redd.it/06ca60ptsm3c1.png?width=845&format=png&auto=webp&s=60c97d63e8721d4a72e02668165ade278a87c718

/r/django
https://redd.it/1885jie
the eval game

https://oskaerik.github.io/theevalgame/

I made a Python game inspired by "The Password Game", highlighting some of the more obscure aspects of the language. Give it a try and test your skills (or maybe creativity...) 😉

I'm happy to receive any feedback!

/r/Python
https://redd.it/1884j69
D I'm interviewing Rich Sutton in a week, what should I ask him?

Rich is an author of the RL book, and more recently, he founded the OpenMind Research Institute with some colleagues.

&#x200B;

The interview is in 1 week. I have a background in RL and already have some ideas on questions and topics, but I also want to source questions outside of the Alberta RL bubble. Technical questions are the best, though I am open to anything. Thank you!

&#x200B;

I'll post an update in this thread in a couple weeks after the interview is published.

/r/MachineLearning
https://redd.it/187nbv8
Server Error (500) in Production of a Django App on Render.com

I am trying to deploy a Django Application on Render.

In my project, I have some number of apps that have their own urls.py file. Then, in the project's url, I included them. Have a look at the project's url:

urlpatterns =
path('admin/', admin.site.urls),
path('', include('home.urls')),
path('about/', include('about.urls')),
path('kbdash/', include('management.urls')),


And for every app the url looks like this:

urlpatterns =
path('', about_page, name='about'),


all these urls work except for the

path('kbdash/', include('management.urls'))

Below is the urls.py of management app:


urlpatterns =
path('', views.Dashboard.as_view(), name='dashboard'),
path('fuels/', views.fuel_list_view, name='fuel_list'),


all the urls in main urls file are working except for the kbdash/

Visiting kbdash/ and any link under kbdash/ throw Server Error (500)

View associated with kbdash/ :

class Dashboard(LoginRequiredMixin, generic.View):


/r/django
https://redd.it/1888vns
How deploy a Django app?

I'm very close to finish my django project and I'm worried about the deploy. So far, I have an EC2 instance in AWS and even tough it's "online", it's just the EC2 running "python3 manage.py runserver" all the time.

I know this is not the best way, so I wanted to ask you guys:

\-How should I manage my Media/Static files?

\-How should I manage the DB?

\-How should I keep running the app?

\-How can I keep my code updated with my repo in github?

I'm pretty newbie in this deployment field, so I'll appreciate your help and comments :D

/r/django
https://redd.it/188g1k8
django-unfold charts

Does anyone know what charts Django-Unfold uses? I love how they look!

/r/django
https://redd.it/188ntjk
PyCharm docker-compose interpreter in WSL

Hey everyone! New coder here.

Building my first web app, I started out with venv in WSL. That worked great for the first 2 months but I've since brought Celery, Mailpit, Redis, and Flower into the equation, which made it very tedious to manage everything manually, so I learned Docker and dockerized my app (I now love Docker, btw :D).

For development, I use Docker Desktop with the WSL-based engine and everything's fine except that I can't configure the Python interpreter in PyCharm to use docker-compose in WSL. The functionality is there but after hooking it all up, it fails with the following errors:

&#x200B;

https://preview.redd.it/trw2ktsfop3c1.png?width=737&format=png&auto=webp&s=251bff65b32721112c177bfa7ca77d218d0b81c4

&#x200B;

https://preview.redd.it/rnayo0ogop3c1.png?width=724&format=png&auto=webp&s=f6ab88afdd27150dcd95312beab1eb604b1dfd19

Over the past 3 days, I've tried reinstalling WSL, Docker Desktop, multiple versions of PyCharm Pro, and seemingly anything in between to no avail.

My question is, has anyone successfully managed to use a Python interpreter hooked to a docker-compose in WSL in PyCharm? I really like PyCharm, but without the above, I can't use the debugger, so I'd probably try running the same setup on native Ubuntu on dual-boot or move to VS Code.

/r/django
https://redd.it/188gb9e
What was for you the biggest thing that happened in the Python ecosystem in 2023?

Of course, there was Python 3.12, but I'm not only talking about version releases or libraries but also about projects that got big this year, events, etc...


EDIT : so nobody cared about pandas 2, mojo or python in Excel ?

/r/Python
https://redd.it/188fo2w
dotenv or config.json

I know both will work, but is it better to access your environment variables (SECRET_KEY, EMAIL_USERNAME, etc) using load_dotenv() or json.load(config_file)? In both cases the variables are being imported from outside the website's folder structure, but is one approach inherently safer than the other? If so, please explain why.

/r/flask
https://redd.it/188ww9f
How to use Flask with SQLAlchemy Core functions?

I found that SQLAlchemy ORM is not what I need, but AFAIK the Flask-SQLAlchemy module is an ORM based one. How can I use SQLAlchemy with Flask without ORM? Is it enough to setup/configure a SQLAlchemy object at the start of app:

db = SQLAlchemy(app)

then get a connection object from it:

conn = db.engine.connect()

and then use it if it was made by the original (non-flask) sqlalchemy?


/r/flask
https://redd.it/187qyzq
2,000 free sign ups available for the "Automate the Boring Stuff with Python" online course. (Dec 2023)

If you want to learn to code, I've released 2,000 free sign ups for my course following my Automate the Boring Stuff with Python book (each has 1,000 sign ups, use the other one if one is sold out):

https://udemy.com/course/automate/?couponCode=DEC2023FREE

https://udemy.com/course/automate/?couponCode=DEC2023FREE2

If you are reading this after the sign ups are used up, you can always find the first 15 of the course's 50 videos are free on YouTube if you want to preview them. YOU CAN ALSO WATCH THE VIDEOS WITHOUT SIGNING UP FOR THE COURSE. All of the videos on the course webpage have "preview" turned on. Scroll down to find and click "Expand All Sections" and then click the preview link. You won't have access to the forums and other materials, but you can watch the videos.

NOTE: Be sure to BUY the course for $0, and not sign up for Udemy's subscription plan. The subscription plan is free for the first seven days and then they charge you. It's selected by default. If you are on a laptop and can't click the BUY checkbox, try shrinking the browser window. Some have reported it works in mobile view.

I'm also working on another Udemy course that follows my recent book "Beyond

/r/Python
https://redd.it/188l3cu
Does Flask-Login 0.7.0 support cookie based authentication? Or is it purely session based? What are the alternatives?

Does Flask-Login 0.7.0 support cookie based authentication? Or is it purely session based? What are the alternatives?

/r/flask
https://redd.it/187iqhp