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
Why not just get your plots in numpy?!

Seriously, that's the question!

Why not just have simple
plot1(values,size,title, scatter=True, pt_color, ...)->np.ndarray
function API that gives you your plot (parts like figure and grid, axis, labels, etc) as numpy arrays for you to overlay, mask, render, stretch, transform, etc how you need with your usual basic array/tensor operations at whatever location of the frame/canvas/memory you need?

Sample implementation: https://github.com/bedbad/justpyplot

# What my project does?

Just implements the function above

When I render it, it already beats matplotlib and not by a small margin and it's not the ideal yet:

Plotting itself done in vectorized approach and can be done right utilising the GPUs fully

plot1, plot2 .. plotN is just dependency dimensionality you're plotting (1D values, 2D, add more can add more if wanted)

Target Audience? What it Compares against?
Whoever needs real-time or composable or standalone plotting library or generally use and don't like performance of matplotlib [1, 2, 3\]

I use something similar thing based on that for all of my work plotting needs and proved to be useful in robotics where you have a physical feedback loop based on the dependency you're plotting when you manipulating it by hand such as steering the drone;


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

# Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

## How it Works:

1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.

## Guidelines:

* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.

## Recommended Resources:

* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.

## Example Questions:

1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the

/r/Python
https://redd.it/1f7lwin
pytest vs unittest?

I keep reading from Django’s official site to use unittest, but I’m reading more about pytest and find some aspects really interesting and intuitive. What does the community at large prefer?

/r/django
https://redd.it/1f7maoe
Anyone made the switch from ASP.NET Core?

I'm a .NET developer by daytrade, and I'm starting side projects from time to time. Usually it's been Node.js/Go/ASP.NET, but I've never done Django yet. I'm just not a big Python user in general.

However, it now looks like I have to build an admin panel by myself for a side project I've just started, and Django entered my mind as it's got one by default. It looks like Django + DRF is sort of a ASP.NET/Spring lite-edition, so I'm looking to see some feedback if anyone has actually moved from ASP.NET to Django, or just used both and have some feedback to share.

One thing I'm kind of suspicious about is the performance. ASP.NET is what, 10x faster than Django? However I know it probably won't make a real difference, but seems a shame if there is no real benefit to using Django.

/r/django
https://redd.it/1f7ezda
Web scraping with GPT-4o: powerful but expensive

Hey folks,

So I've been messing around with OpenAI's new structured outputs feature and decided to build an AI-powered web scraper. Thought I'd share some of the cool (and not so cool) stuff I found.

**The Good:**

* This thing can parse some pretty complex tables. I threw a 10-day weather forecast at it with all sorts of nested data, and it handled it like well.
* It's smart enough to figure out merged cells and hidden data in the HTML.

**The Bad:**

* Wikipedia tables with combined rows? Yeah, that broke it.
* Asking it to give XPaths directly was a mess. Had to do some workarounds.

**The Ugly:**

* GPT-4o is expensive! Spent $24 in two days just messing around.

I made a quick demo with Streamlit if anyone wants to check it out: [https://orange-resonance-9766.ploomberapp.io](https://orange-resonance-9766.ploomberapp.io)

Source code's on GitHub if you're curious: [https://github.com/edublancas/posts/tree/main/ai-web-scraping](https://github.com/edublancas/posts/tree/main/ai-web-scraping)

Anyone else played with AI for web scraping? What's been your experience?

P.S. If you want the full nerdy details, I wrote a blog post about it: [https://blancas.io/blog/ai-web-scraper/](https://blancas.io/blog/ai-web-scraper/)

/r/Python
https://redd.it/1f7g0t9
Looking for fellow learners

TLDR: If you are interested in learning and then building in Django, Please DM me and we can start ASAP. I am a beginner in Django.

I am looking for one to two people to learn and practice Django together. This way we all can learn faster and build something cool together.

Requirements:

Must be serious learners who want to learn quick and start building.

Must be proficient with programming in general and have decent knowledge of Python. Quick Learner and positive mindset.

Plus Points: If you are experienced.

About Me: I am a software Engineer proficient in C++ & Python, Strong knowledge of Programming & DSA. Have almost 2 YOE.

To people who have commented: I have zero experience with Django, know basic things like views, models, app, users, admin etc. but would like to start from square 1 which i think should take like a week to get done with basics and jump on to building. Just telling it so that you have clear idea about my Django Knowledge and what to expect.

/r/django
https://redd.it/1f7awk6
Deploying on Choreo.dev?

Hi Guys,

I am testing out different options for hosting my django + postgresql + react application. I found https://choreo.dev/ very convenient because i can manage all parts of the application on one dashboard instead of using 3 different providers.

However, it makes me a little suspicious that you can hardly find anything about choreo on the internet + the documentation is also not that extensive.

Do any of you have experience with the provider, and if so, what do you think?

/r/django
https://redd.it/1f7yhrx
Spyder 6 IDE Released

Spyder 6 has been released. The Spyder IDE now has standalone installers for Windows, Linux and Mac. Alternatively it can be installed using a conda-forge Python environment:

https://github.com/spyder-ide/spyder/releases

/r/Python
https://redd.it/1f7w2rn
Please help us test new Flask deployment tooling

Hi,

I work for Canonical, the creators of Ubuntu. We have been working on some new tooling to make it easier to deploy Flask applications in production using Kubernetes. This includes tooling to create Docker images as well as tooling to make it easy to connect to a database, configure ingress and integrate with observability. We would love your help and feedback for further development. We have a couple of tutorials:

[Creating a production ready Docker image](https://documentation.ubuntu.com/rockcraft/en/latest/tutorial/flask/)
Deploy a Flask App on Kubernetes

Please share any feedback you have. We are also running user experience research which takes about an hour to complete. Please let us know if you are interested (DM me or comment below). Thank you!

/r/flask
https://redd.it/1f7tj1m
Generators underused in corporate settings?

I've worked at a couple of places that used Python. And I've rarely seen anyone regularly using the yield keyword. I also very rarely see people using lazy "comprehensions" like

foo = (parse(line) for line in file)
bar = sum(postprocess(item) for item in foo)


And so, I'll use these features, because to me, they simplify things a lot. But generally people shy away from them. And, in some cases, this is going to be because they were burned by prior experiences. Or in other cases it's because people just don't know about these language features.


Has this been your experience? What was the school of thought that was in place on your prior teams?

/r/Python
https://redd.it/1f7zh22
Is there any plugin or Django app like this?

Supposing you have multiple users on your website and they receive points for doing something (posting, writing reviews, anything you choose to) and there are a few groups of users, each group having different rights and privileges on your website and the users are upgraded or downgraded to different groups based on accumulated points.

How to do this in Django? Is there any plugin or app helping you with this? If you just need to use pure Django then how this should be done?

Thank you in advance!

/r/djangolearning
https://redd.it/1f7s2gr
Using HTMX with Django is much easier than I thought!

I have recently given HTMX a try halfway through working on a Django project that needed dynamic content loading. It took me so long to give it a try because I thought that it would be hard to learn, but I was sooooo wrong. 😅

So it turns out that to add dynamic content loading all I had to do is:

1. Make a partial template of what I wanted to dynamically load.
2. Add HTMX to project
3. Add HTMX attributes to HTML

For this project, where I dynamically loaded available properties based on selected dates and number of guests I used these 3 HTMX attributes on my form element:

1. hx-get : to make an asynchronous HTTP GET request when an event is triggered
2. hx- target : to select the target element where we want to load the dynamic content.
3. Hx-swap: defines how the content retrieved via an HTMX request should be inserted into the target element on the page.

I found two things a little difficult to figure out:

1. Choosing the correct swap attribute: at first I tried outerHTML, but after some trial and error, I realized that innerHTML was the right choice.

1. Detecting HTMX requests in my Django view: It took me some

/r/django
https://redd.it/1f80vnq
D Self-Promotion Thread

Please post your personal projects, startups, product placements, collaboration needs, blogs etc.

Please mention the payment and pricing requirements for products and services.

Please do not post link shorteners, link aggregator websites , or auto-subscribe links.

--

Any abuse of trust will lead to bans.

Encourage others who create new posts for questions to post here instead!

Thread will stay alive until next one so keep posting after the date in the title.

--

Meta: This is an experiment. If the community doesnt like this, we will cancel it. This is to encourage those in the community to promote their work by not spamming the main threads.

/r/MachineLearning
https://redd.it/1f63rhf
Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

/r/Python
https://redd.it/1f8f4hr
Can't make the user login

I don't know what is happening. Already tried copilot and gpt. But they're not help at ALL
all i have is
[04/Sep/2024 03:26:28\] "POST /accounts/login/ HTTP/1.1" 200 4157
and not redirecting. i have the LOGIN_REDIRECT_URL
Its not just redirecting. I don't know what to do anymore

/r/django
https://redd.it/1f8mgxr
Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

/r/Python
https://redd.it/1f8f4hr
Understanding apps, forms, and the structure of a project/app

Hello everyone,

I am basically a beginner trying to use Django in order to build an app for a business I work for. I have experience with programming, but I never built any app (or web based one).

After going through the Tutorial of Django, I jumped and started programming.

I decided to use various apps instead of having one app because I couldn't focus on the tasks needed and it was a cluster of code.

I began with 2 applications: forms - allows essentially forms management/everything to do with forms: processing, validation etc, and users app - user management, authentication, user settings and so on.

I started to create a login form and login form view. the login form has its own clean methods, and the login form view allows me to forward the form and reder it in HTML loginForm/. I decided to render only the form itself, but I will have a proper "login/" page will the loginForm/ will be imported to. As I said earlier, it is because the forms app is only responsible for the forms, and the rest of the page will be done by something else.

after I wrote all of what I mentioned, I realized that Django has

/r/djangolearning
https://redd.it/1f8qcyw
P Free RSS feed for tousands of jobs in AI/ML/Data Science every day

This is for all of you interested in a constant flow of freshly curated jobs in Artificial Intelligence, Machine Learning, NLP, Computer Vision, Data Engineering, Data Analytics, Big Data, and Data Science in general via RSS format. Jobs are aggregated through aijobs.net and it provides 200 listings at a time. The feed is updated about every hour with the latest jobs.

URL: https://aijobs.net/feed/

No sign-up needed - just add it to your favourite feed reader and be in the loop about new opportunities at any time 🚀

/r/MachineLearning
https://redd.it/1f8nw8f
Alternatives to Jinja for Flask-Based Desktop App Using PyInstaller and WebView

I'm developing a desktop application using the following tech stack:

Frontend: HTML, CSS, JavaScript, Jinja2 (current template engine)
Backend: Flask
Packaging: PyInstaller to create a `.exe`
UI: WebView for Windows

I am currently using Jinja2 for templating, but I want to explore other template engines that might provide better performance or additional features. My main requirements are:

1. Compatibility with Flask: Should integrate easily without much configuration.
2. Support for Desktop Apps: Must work well with PyInstaller when packaging the app.
3. Efficient Rendering: Performance is key, as the app is intended for desktop use.

Are there any good alternatives to Jinja2 that would fit well within this stack? Any advice on integration or potential challenges would be appreciated!

Thank you!

/r/flask
https://redd.it/1f8me1y