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
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/101s3ce
2,000 free sign ups available for the "Automate the Boring Stuff with Python" online course. (Jan 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=JAN2023FREE

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

Udemy has changed their promo code and severely limited the number of sign ups I can provide each month, so only sign up if you are reasonably certain you can eventually finish the course. 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

/r/Python
https://redd.it/101p7xy
I am still making a video editor in Python. I am still crazy. Please help me(really).

# IF YOU ARE INTERESTED IN WORKING ON THIS PROJECT, ADD ME ON DISCORD Relt#4423

So it has been some time. The project has evolved countless of times, but i finally came up with a road forward.

# What? What editor?

I am making a video editor in Python and its called CZEditor (reason for name is a story LITERALLY TOO LONG TO EXPLAIN WITHOUT CONTEXT. it involves inside jokes, niche communities, and kids being in these niche communities, being cringy as ever). It will be free, open source, yadda yadda, you've heard this before.

Luckily, i got some stuff you have NOT heard before.Mainly:

CZEditor uses "keyframes" instead of clips for sequencing media. Clips are too clunky and take up space. While they might look nice, they are a pain to use. We do not care if a video exists at every frame from 0 to 3519, we care that a video starts at 0, and ends at 3519.
CZEditor ACTUALLY will target content creators. With the stuff that content creators really want, rather than the same corporate bullcrap that has been said by everyone else. CZEditor will support many features and make them easily accessible and accessibly easy. The features include:

1. Stylized/Realistic

/r/Python
https://redd.it/101hu89
D Simple Questions Thread

Please post your questions here instead of creating a new thread. 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.

Thanks to everyone for answering questions in the previous thread!

/r/MachineLearning
https://redd.it/100mjlp
D life advice to relatively late bloomer ML theory researcher.

Hi ML Community out there, I'm 27 M. I'm a machine learning incoming PhD student based out of Germany. I have been trying to get into a PhD program since last 4 years (since 2018). When I gave up and got into a masters instead with 3yoe. Now I'm about to complete my masters thesis and start a PhD.

I already have mixed feelings about my PhD journey now. I have gotten a really good opportunity to do ML theory at University of Saarlandes in Germany. Initially, when I had started, I was really driven to understand maths and underlying concepts of ML. However, more recently I have become more confused about the value of theoretical research and it's "real" impact. Of what skills I would have in my career later that would make me desirable to employers (considering I may not get tenured in academia).

Is it more advisable in long run to stay and get your PhD or just leave and join some ML role in industry that takes Masters guys and get some real world experience on how to use ML to generate business value ?

There is this added fomo of being 27 and just

/r/MachineLearning
https://redd.it/101qbfl
R Massive Language Models Can Be Accurately Pruned in One-Shot

Paper : https://arxiv.org/abs/2301.00774

Abstract :

>We show for the first time that large-scale generative pretrained transformer (GPT) family models can be pruned to at least 50% sparsity in one-shot, without any retraining, at minimal loss of accuracy. This is achieved via a new pruning method called SparseGPT, specifically designed to work efficiently and accurately on massive GPT-family models. When executing SparseGPT on the largest available open-source models, OPT-175B and BLOOM-176B, we can reach 60% sparsity with negligible increase in perplexity: remarkably, more than 100 billion weights from these models can be ignored at inference time. SparseGPT generalizes to semi-structured (2:4 and 4:8) patterns, and is compatible with weight quantization approaches.

/r/MachineLearning
https://redd.it/1027geh
Thoughts on these Courses?

Good morning, I'm looking to learn ML and AI with python with Udemy courses, did anyone already took any of these courses? I want to know if they worth it

​

​

https://preview.redd.it/dobm0q58du9a1.png?width=1143&format=png&auto=webp&s=bd5c165bad2e8d0d94f633635db56a7eb3c23ce5

https://preview.redd.it/ulf303x9du9a1.png?width=1089&format=png&auto=webp&s=9ce3c87a211495707e5677baf8b47879eb1d757b

/r/Python
https://redd.it/102a6mu
Is there a simple way to show a loading screen/icon while waiting on an API?

New to Django here. In this side-project I'm working on, I'm calling a public API to display some info for a simple game. Is there an easy way to show some "loading...." status while it waits for the GET request to resolve? I read some posts online suggesting to get jquery or htmx involved but I'd rather not if possible. I don't want it to just be blank until it resolves.

/r/djangolearning
https://redd.it/101xjro
Celery Task needs User Data

I have a Celery Task running that outputs a constantly updating dataframe. Doing this with non user-oriented variables is simple. Being able to create the dataframe off of user stored data seems to be a bit of a problem. From the documentation I read online, it seems that Celery Tasks are not meant to be user-centric.

What other way can I go about this so that a dataframe pulls through and constantly updates a "live table" based on a stored stock symbol for the user? Or if I need to look at this in a different light, please let me know. TIA.

/r/djangolearning
https://redd.it/101olfs
Page not found (404) in Post/Detail view

Hello! I've been working on a blog project with Django and I'm having trouble with a CBV.

Context:

I want to add comments to my detailed post template. To do so, I'm following this approach: https://docs.djangoproject.com/en/4.1/topics/class-based-views/mixins/#an-alternative-better-solution

The app renders the form but when I post the comment, I get a 404 (Page not found at /post/5/) saying "No comment found matching the query".

These are my files:

​

views.py:

from django.views.generic import DetailView, FormView, View
from django.views.generic.detail import SingleObjectMixin
from .models import Post, Comment
from .forms import CommentForm
from django.urls import reverse
from django.http import HttpResponseForbidden

class PostDetailView(DetailView):
model = Post
templatename = "postdetail.html"

def getcontextdata(self, kwargs):
context = super().getcontextdata(kwargs)
context"form" = CommentForm()
return context




/r/djangolearning
https://redd.it/101myu1
How to reverse an item list like this in the Django admin panel where the most recent item entered appears the first in the list

/r/djangolearning
https://redd.it/10185w6
Bootstrap misbehaving in Django

Hello guys, I'm working on django project whereby I'm using bootstrap4. The input fileds, buttons and everything are working fine but the date-time picker, select option dropdown, and file uploader are not display properly as they should do. If I render my HTML code outside django project everything is working fine but If I put it in django it's breaking

/r/djangolearning
https://redd.it/1019xqs
any idea how to make that check box in the Django admin panel a lil bit bigger

/r/djangolearning
https://redd.it/100yhoj
export to excel(.xls)

i am using python xlwt module to convert my database query into an excel sheet.everything works fine,but now i want to adjust my date coloumn as below

def tonerdetails_export_toexcel(request,id):
toner_model = find_toner_model(id)
fmt = '%Y-%m-%d %H:%M:%S'
response =HttpResponse(content_type='application/ms-excel')
response['Content-Disposition']='attachment; filename=TonerReport ' + str(toner_model) + '.xls'
wb=xlwt.Workbook(encoding='utf=8')
ws=wb.add_sheet('Toner Report')
row_num=0
font_style=xlwt.XFStyle()
font_style.font.bold=True
date_format = xlwt.XFStyle()
date_format.num_format_str = 'yyyy/mm/dd'
columns=['Toner Model','Issued To','Employee Name','Employee Designation','Date Dispatched','Status']
for col_num in range (len(columns)):
ws.write(row_num,col_num,columns[col_num],font_style)
font_style = xlwt.XFStyle()
rows=TonerDetails.objects.filter(toner_model_id=id).values_list('toner_model_id__ton
er_model','issued_to_id__name','employee_name',

/r/djangolearning
https://redd.it/zzp557
Cómo hago para relacionar una ForeignKey de un models a la view o base de datos?

Realicé un models con relaciones de tablas utilizando ForeignKeys. Realicé su respectivos forms y views. Solo que ahora no se cargan los datos ingresados a la base de datos de esa ForeignKey, en este caso es num_dni.

Adjunto mi código:

Models

class Dueno(models.Model):
localidad = models.CharField('Localidad', maxlength=150, null=True)

class Persona(models.Model):

nombre = models.CharField('Nombre/s', max
length=150)
apellido = models.CharField('Apellido/s', maxlength=150)
direccion = models.CharField('Dirección', max
length=150)
telefono = models.IntegerField('Teléfono')
nummatricula = models.ForeignKey(Empleado, ondelete=models.PROTECT, null=True)
numdni = models.ForeignKey(Dueno, ondelete=models.PROTECT, null=True)

Form:

class DuenoPaciente(forms.Form):
nombre = forms.CharField(label='Nombre', max
length=150)
apellido = forms.CharField(label='Apellido', maxlength=150)
telefono = forms.IntegerField(label='Teléfono')
direccion = forms.CharField(label='Dirección', max
length=150)
dni = forms.CharField(label='DNI')


Views:



/r/djangolearning
https://redd.it/zzu49i