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/xcsa6v
Pergunta: alguém conhece um Framework CSS para impressão?

Eu tenho gerado alguns relatórios com R e com Python em pdf. Para isso estou usando LaTeX, mas tem sido bastante difícil fazer algumas coisas nele.
Uma alternativa seria gerar em html e converter para pdf.
Então eu procuro um Framework CSS focado em impressão.
Não é necessário ter suporte a paginação ou features avançadas, só uma tipografia já seria o bastante.

/r/IPython
https://redd.it/x4tyj2
I'm Al Sweigart, author of Automate the Boring Stuff with Python. I'm currently doing an AMA about my latest book on recursive algorithms.

Please post question to the AMA thread rather than on this post. Thank you!

https://www.reddit.com/r/IAmA/comments/xcp6jv/im_al_sweigart_author_of_several_free_programming/

/r/Python
https://redd.it/xcr4tt
Optimization of the Django count() query.

Hey!
Anyone can help me on the django count query thing.


for large databases, the count query takes so much time, leading to the user's waiting.
total_count = catalog_items.count()
Like this query is alone taking 8858ms.


Does anyone help me to optimize this query in the database or at any level?
It will be a great help.

/r/django
https://redd.it/xcyiqb
Recruiter asking how much experience is development vs. scripting

Most of my python experience is in scripting and automation, about 5+ years. I am self taught, on the job learner. I have a recruiter asking me to clarify how much of my experience is in pure development.

I have about a year working on a django app, which I guess that would qualify. I assume they would want to grill me on concepts in the interview I might not know well. Such as data structures/algorithms/etc. Or maybe solve a problem on the spot.

I do study some off the clock. If I do get an interview, what would be the best way to prep?

/r/Python
https://redd.it/xd8cu3
Send WhatsApp Notifications Using Django

I need help finding a free third party service to send WhatsApp notification messages using Django.

/r/django
https://redd.it/xdc3cx
Securing a Python CLI application with Auth0

Build Python CLI applications secured by using the device authorization flow with Auth0.

Read more…

/r/Python
https://redd.it/xda30d
Best Practice for multi-framework project

Say there's a project with the following schema ->
|-backend (Django)
|-frontend (React)
|-external (custom data mining scripts in python)

Some of the rules I set for the project were:
- external mines relevant data from the internet and feeds them into my local postgresql db
- All creation and altering of DB schema would be done through Django (backend)
- external sanitizes the data; backend sorts, analyzes etc data
- DRF is used to send data from backend to frontend

It's come to the point where I really want to start utilizing some Django functionality (models) in my external package.

I was going to research exactly all I'd have to do to simply use python import functionality to bring the models into the module and then it hit me that I could also use the DRF API in external where external could C, U and D the data and frontend could only R it

In some of you folks' experience what is the best way to do this? Import the models or use the API?

/r/djangolearning
https://redd.it/xdj5se
Near-Earth Objects - Project Part 7: The Opposition Effect

Hey Pythonistas,

video #7 of my space science related Project "Near-Earth Objects" is out! Last time, I showed you how one can compute the brightness of an asteroid using an empirically derived formula called the "H-G-function". This time I want to show you some strange behaviour of these stony worlds: The Opposition Effect.

What's that?

Well, the brightness of asteroids depends on miscellaneous parameters and geometric considerations, like e.g., the distance between the Sun and the asteroid, as well as the asteroid and the observer (us, the Earth). Additionally, the phase angle between the asteroid - Sun - Earth must be taken into account, too!

For example, a phase angle of 0 degrees corresponds to an imaginary straight line, where the Sun - Earth and asteroid lay on it.

For very small phase angles, the brightness of asteroids "surges" exponentially, but only for a veeery short time: The Opposition Effect.

And in this tutorial I'd like to show you this effect using the corresponding equations.

GitHub Link: https://github.com/ThomasAlbin/Astroniz-YT-Tutorials/blob/main/%5BProject%5D-Near-Earth-Objects/06\_NEO\_Apparent\_Magnitude\_%232.ipynb

YouTube Link: https://www.youtube.com/watch?v=1HgcxmSStFk

If you would like to know more about the scientific background of this effect, I also created a small science video about it: https://www.youtube.com/watch?v=slVkkp4rE7I

I am not a professional YouTuber, I know. I just like to use YouTube to

/r/Python
https://redd.it/xdhbig
how to add line in plot

How can i add a average line showing gender 0.0 earns more?

my current code:

df.plot(x='gender',y='salary', kind='scatter')
y_avg = [np.mean(gender)] * len(gender)

​

https://preview.redd.it/pdy7vp1icmf91.png?width=760&format=png&auto=webp&s=d16ced015651748402f47e2f77a0e63d1d44c370

/r/IPython
https://redd.it/wfqxxs
How to intepret data

How can i interpret this data? From multi regression

plt.scatter(ytest, ypredict)

​

https://preview.redd.it/pw8smowv0nf91.png?width=704&format=png&auto=webp&s=a220d2145a64e77d48ef76b42440fe8db48f4675

/r/IPython
https://redd.it/wfth9f
Wednesday Daily Thread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

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/xdmrzi
how to change axis label in sns plot

my code

sns.countplot("gender", data=df,saturation=0.68)

I want to change the count to salary

https://preview.redd.it/fr7osqdjwgf91.png?width=1266&format=png&auto=webp&s=13b4ccc9490b0675535504cf89a1e6c86ebdac45

/r/IPython
https://redd.it/wf219i
I just wanna give a shout-out to my friends in the Django community

I work with a small business and I don’t get to use Django in my work environment (I’m working with PHP) but I come home and practice with Django, building small things. I love the framework. I hope to make it a professional thing sooner than later.

/r/django
https://redd.it/xdry91
djstripe admin cannot view synced plans or products



I have a problem when I use django admin to view products and prices in djstripe. I have synced everything on Stripe portal. I get an error Exception Type: TypeError at /admin/djstripe/plan/ Exception Value: 'NoneType' object is not subscriptable

How do I solve this? Been stuck here

/r/django
https://redd.it/xdwykx
django all auth twitter error

Can sb check my setup for twitter as a login provider?

settings.py


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',

'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.twitter',
'myapp',
'django_select2',
'django_tables2',
'django_filters',
'bootstrap4'
]


SITE_ID = 1




/r/django
https://redd.it/xdz9em
Having to stop Flask server to run other functions.



I'm currently trying to make a simple flask server that gets input from the local frontend, uses the input to get certain data from a CSV, and then send the data back to the frontend. (I'm brand new to python and web development).

The issue that I'm having is this:

When I run the program, it starts the server and I go onto the frontend and post the input to the backend. It then stores the input in a variable.

I then have to manually stop the server by pressing ctrl-c. This then allows the code after it to run. (The function to get data from the CSV).

Do I then have to automatically restart the server to then send the data to the frontend? This just seems too complicated, and I've been told that you can do all this without stopping the server at all in the first place. I heavily get the sense that I'm missing the trick somewhere, however I'm new to this so pls understand :).

Please let me know if the above makes no sense and I'll try to rephrase.

/r/flask
https://redd.it/xe46js