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
Get data from HTML to another

On a page use data from a model to fill tables and do calculations in Javascript That page is for audits and quality control, but I need another page for data business and graphics. Using Javascript generated tables using data rendered from views and functions.

How do I render from one page to another without having to do the calculations again, each page has an instance assigned to an id

/r/django
https://redd.it/1csx05s
Fantasy sports (golf) app in Flask
https://golfpool.greenkeepa.com/

/r/flask
https://redd.it/1csvtdp
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏢

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

/r/Python
https://redd.it/1cszngw
New

Hi everyone,

I’m pretty new to software development in general but I just deployed my first full stack application using netlify for react and render for flask. Issue with render is it goes to sleep after 15 mins of activity.

If I go up the paid plans, will I resolve this issue? Is anyone using those tiers and how’s your experience with them so far?

Also, I used ElephantSQL for my database but their EOL is approaching. I heard Supabase and Aiven are good alternatives. Any insights would be much appreciated on those also!

Thanks a bunch :)

/r/flask
https://redd.it/1csz9r6
PyCon US 2024 is here!

It’s that time of year again, this time in Pittsburgh, Pennsylvania!

You can chat with others in the Python Discord (discord.gg/python) in the #pycon-us channel or in this thread.

If you’re going, leave a comment below. Maybe include a talk you’re excited to hear or summit your excited to attend.

It’d be really great to meet some of you as well! I’ve got stickers ;)

/r/Python
https://redd.it/1ct1tnh
Facing challenge in django channels require help

Currently grappling with a challenge in Django Channels regarding multi-tenancy. While connections work smoothly on threads, transitioning to channels introduces event loops, leading to multiple processes operating on the same thread and causing potential race conditions when modifying tenants. Any insights, ideas, or assistance on resolving this would be greatly appreciated!

/r/django
https://redd.it/1ct5fn7
Apple Health data exploration with Atlas, Clickhouse, Vega-Altair, Quarto

**What My Project Does**

A few days ago I wrote a simple python script ("[Atlas](https://github.com/atlaslib/atlas)") that turns the Apple Health export.xml file (which is about 1 GB in my case, with about 10 years of data) into a very simple parquet file (a bit like a compressed CSV) that is also way smaller (40 MB).

The parquet file has 5 columns:

* type (e.g. "CyclingDistance")
* value (e.g. "12.100")

and 3 datetime timestamps:

* start
* end
* created

This makes it way easier to do data exploration. Here are a few example charts I generated using Clickhouse (chDB) and Vega-Altair in a Quarto notebook.

Step Count:

[https://x.com/\_\_tosh/status/1785397655784337684](https://x.com/__tosh/status/1785397655784337684)

Environmental Noise:

[https://x.com/\_\_tosh/status/1787530483208786029](https://x.com/__tosh/status/1787530483208786029)

Sleep Duration & States:

[https://x.com/\_\_tosh/status/1786505867438768254](https://x.com/__tosh/status/1786505867438768254)

Coffee Consumption:

[https://x.com/\_\_tosh/status/1783906333911076996](https://x.com/__tosh/status/1783906333911076996)

Coffee after 17:00:

[https://twitter.com/\_\_tosh/status/1789304034442043421/photo/1](https://twitter.com/__tosh/status/1789304034442043421/photo/1)

**Target Audience**

For everyone who would like to explore their own Apple Health data or see how to work with a simple .parquet file using Clickhouse (chDB), Vega-Altair and Quarto.

Quarto notebook: [https://github.com/atlaslib/atlas/blob/main/examples/apple-health-exploration-clickhouse-chdb-altair-quarto/index.qmd](https://github.com/atlaslib/atlas/blob/main/examples/apple-health-exploration-clickhouse-chdb-altair-quarto/index.qmd)

In the repo on Github I've added also added instructions for how to get your export.xml file from Apple Health and how to install the python script via pip to use it as a command line tool:

[https://github.com/atlaslib/atlas](https://github.com/atlaslib/atlas)

(⭐️ star to stay tuned for updates)

Curious if you have charts that you would be interested in. Happy to add more examples over the next days!

**Comparison**

This is me playing around with the

/r/Python
https://redd.it/1css42g
Rant/Seeking Reassurance

It's 5am and I haven't slept a bit because I've been going down a grief rabbit hole searching for information that'll prove otherwise that AI wont fully take over coding/programming.

I can remember when I ran my first code and how the dopamine rewired my brain and while I don't entirely hate AI, it's just discerning that basic-intermediate programming will be gone in probably 5 years.

I feel like programming is all I have and have had. I recently just graduated with a degree in Computer Science, I'm beginning to fear if i made a mistake making programming both my hobby and career(career which I haven't even had lol)

Hell, the reason for this rant is that I'm just desperate for reassurance because I'm miserable.

/r/Python
https://redd.it/1ct5jre
I created a Python script that makes it easier to track how your baby's sleep is improving

My wife and I use the Huckleberry app to track our baby's sleep periods. Although the free version of the app allows you to view a number of sleep-related metrics, I also wanted to see whether his longest nightly sleep stretches were getting longer over time. Therefore, I created a Python project to help me answer this and other questions I had about my baby's sleep.

# What My Project Does

This project reads in data from a Huckleberry .csv export (or a separate custom .csv file); analyzes its sleep information; and then produces a number of visualizations.

Personally, I've found that running the code and viewing its output helps reassure me that our baby is making progress with sleep, even if he seems to have some setbacks now and then! I hope you'll find it useful as well in evaluating the effectiveness of your sleep training approach.

# Target Audience

This project can be useful for any parent who wishes to see how his or her baby's sleep is improving over time. (It could be used for other age ranges as well, but the code and visualizations are geared towards infant sleep data.)

The project's readme has instructions on using the code to track your own baby's sleep data.

# Comparison

This

/r/Python
https://redd.it/1csa6j0
Step-by-Step Tutorial for High Impact Python Streamlit: Beautiful Interactive Maps and Charts

Recently, I have been working hard on coding Python Streamlit for interactive data visualizations - so that you don’t have to.

Specifically, I have been looking at how to put together interactive Streamlit dashboards - with a combination of visualizations.

Let me show you how you can create a Streamlit dashboard with:

1. A dropdown menu allowing the user to select the Year
2. Global Choropleth map by country(updated by year).
3. Horizontal bar chart of top 10 countries (updated by year)

Using a terrific public dataset, you can create a beautiful dashboard using a modular approach.

Tutorial HERE

/r/Python
https://redd.it/1csirwm
Blat AI generates Python code to do web-scraping (code based on Scrapy framework)

Miguel Algorri and Arnau Pont Vílchez here, blat co-founders!

Target Audience
People who need to collect public data from the web (pricing, articles, reviews, leads etc).

What does our Project Do?
At blat we aim to deliver production-ready web scraping code in minutes (written in Python, Scrapy framework).
This is feasible thanks to our Web Scraping AI Agent 🧠Here our CLI to interact with the Web Scraping AI Agent (github). Too good to be true? Check our video

Comparison
There are lots of other tools in the market, like Zyte, Apify, Kadoa. All those are great tools for web scraping purposes. The main difference with our competitors is that we give you the Python code that's ready to use (you host it, you run it). Also, once created, the code does not use AI for parsing HTMLs, so it's more efficient and deterministic.

What are we looking for?
We encourage you to register as a alpha testers 💪 if you are willing to have a better and more automated web scraping experience. 

Here our CLI to interact with the Web Scraping AI Agent (github)

/r/Python
https://redd.it/1ct9cqu
Track the size of your PyInstaller packages in CI

If you have ever wanted to track the size of your PyInstaller packages in CI, Bencher now supports tracking your package size: https://bencher.dev/docs/how-to/track-file-size/

/r/Python
https://redd.it/1csmx2q
Help! { }

# Code

# app/models.py

from django.db import models

class Image(models.Model):
image = models.ImageField(uploadto='images/')
uploaded
at = models.DateTimeField(autonowadd=True)

def str(self):
return f"Image uploaded at {self.uploadedat}"


# app/
forms.py

from django import forms
from .models import Image

class ImageForm(forms.ModelForm):
class Meta:
model = Image
fields = ['image']


# Environment

* **Request Method:** GET
* **Request URL:** \*\*\*\*\*
* **Django Version:** 5.0.4
* **Python Version:** 3.12.2

# Installed Applications

pythonCopy code
INSTALLED
APPS =
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',


/r/djangolearning
[https://redd.it/1ctcc9m
(Something went wrong) Flask Mega Tutorial Part 3

While I was doing Part 3 Web Forms tutorial, something went wrong between 'Receiving Form Data' and 'Improving Field Validation'. The only changes were 'route.py', 'base.html', and 'login.html'.

from flask import rendertemplate, flash, redirect

@app.route('/login', methods=['GET', 'POST'])
def login():
form = LoginForm()
if form.validate
onsubmit():
flash('Login requested for user {}, remember
me={}'.format(
form.username.data, form.rememberme.data))
return redirect('/index')
return render
template('login.html', title='Sign In', form=form)

However, I think this code above is at fault, because the app was undefined (a red underline at the @ part). When I add back, these below

from app import app
from app.forms import LoginForm

Now it said 'No module named 'app'.

/r/flask
https://redd.it/1ctbfc0
Advice on using patch file for installed library

I am using rest_framework_simple_api_key in my production application on python version 3.9 .

On running command

python manage.py generatefernetkey

as given in doc(djangorestframework-simple-apikey) i am getting
File "C:\\Users\\DELL\\anaconda3\\lib\\site-packages\\rest_framework_simple_api_key\\models.py", line 15, in <module>
class AbstractAPIKeyManager(models.Manager):
File "C:\\Users\\DELL\\anaconda3\\lib\\site-packages\\rest_framework_simple_api_key\\models.py", line 16, in AbstractAPIKeyManager
def get_api_key(self, pk: int | str):
TypeError: unsupported operand type(s) for |: 'type' and 'type'

On Searching I got reason is i am getting error is
The error TypeError: unsupported operand type(s) for |: 'type' and 'type' is caused by the use of the int | str syntax for type hinting, which is only supported in Python 3.10 and later versions.

I can't change my python version as it is in production so I came across solution monkey patching then i got this article https://medium.com/lemon-code/monkey-patch-f1de778d61d3

my monkey_patch.py file:

def patchgetapikey():
    print("*********************************EXE****************************************")
    """
    Monkey patch for AbstractAPIKeyManager.get
apikey method to replace the type hint.
    """
    from typing import Union
    def patched
getapikey(self, pk: Unionint, str):


/r/djangolearning
https://redd.it/1ct6z0u
D LWhy are Linear RNNs so performant (in terms of accuracy, not compute)? Looking for mathematical or even intuitive explanations

Trying to familiarise myself with the mamba architecture, hence familiarising myself with SSMs, hence familiarising myself with Linear RNNs. I have looked over resources on SSMs, S4 and Mamba but I’m unable to find an explanation. on why Linear RNNs with SSM parameterization improves performance. I can’t wrap my head around it intuitively either - why are linear transformations sufficient for seq2seq tasks?

Are there any exhaustive mathematical explanations, or even videos on how linear RNNs can outperform transformers on certain tasks?

/r/MachineLearning
https://redd.it/1ctea1i
D Are PyTorch high-level frameworks worth using?

In an attempt to better track experiment results and hyperparameters, not only did I learn about the Weights and Biases library but also ended up finding out about frameworks such as PyTorch Lightning and Ignite. I've always used raw PyTorch, so I'm not sure if these frameworks are really useful. I mostly work with academic research, right now I also need to keep track of the MAE since it's a regression problem and I don't know if these frameworks support this or let me define a custom metric.

Would these frameworks be useful for me? Could it speed up the process when experimenting with different architectures?

If you think they're useful, let me know which one you'd recommend.

/r/MachineLearning
https://redd.it/1ctqzfa
How do I clean a ModelForm field before every other.

For my form validation to work properly, I need to validate one of the fields before all of the others. How do I do this? Here's a simplified version my code:

class Form(ModelForm):
added_field = forms.IntegerField()

class Meta:
model = ModelExample
fields = ["field1"]

def __init__(self, user, *args, **kwargs):
super().__init__(*args, **kwargs)
self.user = user
self.other_model_object = None
for field in self.fields.values():
field.required = False

def clean_added_field(self):


/r/djangolearning
https://redd.it/1ctsbrx
I made a thing

/r/django
https://redd.it/1cthmj8
Friday Daily Thread: r/Python Meta and Free-Talk Fridays

# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

## How it Works:

1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

## Guidelines:

All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.

## Example Topics:

1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟

/r/Python
https://redd.it/1ctrpwz