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
[D] An example of machine learning bias on popular. Is this specific case a problem? Thoughts?

/r/MachineLearning
https://redd.it/ma8xbq
Tab completion be like

/r/django
https://redd.it/maojw9
The Python Discord Topic for the week of March 22: Profiling and Optimization in Python

## Topic for the week of March 22: Profiling and Optimization in Python
> We are partnering with the Python Discord community to explore topics related to the python language each week. On the discords sidebar, under Weekly Topic you can find a live chat to discuss and explore this topic, or click here to jump directly to it. These topics are curated and organized by /u/Kutiekatj9

Python is typically known as a "slow" language compared to C, C++, and other statically typed languages. This slowness comes partially from the fact that Python is a dynamically typed language.

This feature is great for shortening developer time, but it does mean there's extra overhead in the interpreter with type checking. Luckily, Python is fast enough for most applications and the cases where it isn't, we already have solutions!

We're going to discuss the solutions that aren't "switch to Rust": profiling and optimization of Python!

Let's set some ground rules first:
1) Premature optimization is the root of all evil. Don't assume you need faster code until you have a verified use case that you actually do.
2) When you do, or trying to figure out if you do, you profile it first. The slowdown may

/r/Python
https://redd.it/mateua
Cryptocurrency trading bot

Hi guys,

I started a project of a cryptocurrency trading bot with a GUI last year around this time, and I just wanted to the share the current status of this project.

Currently, you can run a simulation, backtest, or a real live bot with the program. You have to write your strategies yourself in the Strategy class, but once that's done, the GUI updates itself automatically and you can select your strategies from the GUI itself.

The program also has Telegram integration, ability to download past data, view news, and a bit more.

I would love to see what you guys think, and it would be awesome if people wanted to contribute to this project (it's open-source after all).

Since this is my first real project out of college, the code is a bit of a mess, but I tried my best. Any constructive criticism is greatly appreciated. One main thing to do right now is revert all the insertions to appends in the code. Not sure why, but when I started, the code had the newest data in the front of the list, so every time there's new data, it had to be inserted to the front of the list which

/r/Python
https://redd.it/mao7qk
API endpoint or ORM management command for adding web-scraped data to database ?

I am web scraping football scores using selenium and wondering whether I should setup an API (Rest Framework) endpoint and run the script from my local PC, or set up the script as Django management command using the ORM.

Any thoughts ? Thanks

/r/django
https://redd.it/mal188
I resurrected an abandoned tiling window manager

PyTyle is a tiling manager for Linux meant to be used on top of other window managers. This project was abandoned by its creator 11 years ago. I spent the last month adjusting it for Python 3, fixing bugs, writing documentation and optimizing. I've just started adding new features requested by users.

I intend to continue developing and maintaining PyTyle.

https://preview.redd.it/qt39eydqqmo61.png?width=1920&format=png&auto=webp&s=60e7e8fbedcc73ba823fdd8ee5aea03af39bd53d

/r/Python
https://redd.it/mavrii
No-code or learn Django?

Hi all,

I’ve been trying to build a social bookmarking site with discussions similar to Reddit. I’ve been using the no-code platform Bubble so far. On the surface, the progress is amazing. Logins and UI is all there. But I am having some issues. Nested comments are almost impossible (I have checked on the bubble forums). Working on large lists times things out. There are also some speed issues. Lastly, if I ever want to migrate to in-house traditional building, there is vendor lock-in and I can’t move users to a new platform (or do I save passwords??). Should I just keep making workarounds or learn a framework. I have a few months free coming and have a bit of background with Django. Do you think it would be worth it or even possible? My background is in economics and finance? I know that there are some Reddit clones built on Django floating around so I could work off of them. My only issues is I will be going back to a very intense job (consulting) so I am worried I won’t have enough time to learn enough to get it all working and on the job my skills will likely

/r/django
https://redd.it/mb0h2x
Finally, I was able to fetch raw heart rate and sleep data from Fitbit API today and plot them using python. I am so excited about this.

I have requested data from the Fitbit API using tokens and plotted the Heart rate data and sleep data using pandas for the last 4 days. The gaps in the middle of the Heart rate plot indicate I was not wearing the device.

​

HR Data

​

Sleep data



Here is the detailed Description + code How I made it to work. It took me a long time to figure out as there are no good online resources on this. So, I am happy to share it with you.

How to get the API token: https://github.com/arpanghosh8453/programs/blob/master/Fitbit%20Data%20Analyzer/How%20to%20get%20the%20OAuth%20Token.pdf

Python code + ipynb file ( Jupyter notebook): https://github.com/arpanghosh8453/programs/tree/master/Fitbit%20Data%20Analyzer

I am a beginner and this is one of my biggest achievements without any significant help :)

/r/Python
https://redd.it/maokdp
Post-save signal on e-commerce app

Hello,

I am creating an e-commerce app and am struggling with how my CartItem and Cart models interact.

I am looking to create or update the Cart based on the creation of new CartItem instances, which I believe can be done by using post-save signals. However, a Cart instance is not created.

* [signals.py](https://wtools.io/code/raw/b4oJ)

* [relevant models](https://wtools.io/code/raw/b4oI)

* [relevant views](https://wtools.io/code/raw/b4oH)

Any help would be greatly appreciated! If there is any missing relevant info, let me know and I can provide that as well.

Thanks in advance!

/r/djangolearning
https://redd.it/mayrey
Does django.contrib.auth need a Registration view?

I realize there's a bunch of ways to register users, including using CreateView and FormView (or writing a function based view), but why do the auth views include everything but registration? You would think getting a user signed up and logged in would be something we're all doing every time.

Thoughts?

/r/django
https://redd.it/mbb41i
Recommendations For Using Django DB Sessions With Graphql

Lately I've been learning a modern frontend stack - React and Apollo - and I've been using django-graphene for the graphql implementation.

After reading about the differences between JWT and the default DB based session mechanism which Django uses the latter seems the safest and simplest in many respects. Without graphql, logging in and signing up is easy with the default django forms and views. With graphql, I wasn't sure. In my research for handling authentication with graphql I stumbled upon django-graphql-auth (https://github.com/PedroBern/django-graphql-auth) but it seems to be based on jwt. I cannot seem to find anything else similar which supports the default django session mechanism.

So my question is what is the most painless way for handling authentication for a graphql client using the default django server side session mechanism?

/r/django
https://redd.it/mbdext
Run a long task using threads.

app.py

from flask import Flask, redirect, url_for, render_template
import time
import threading
app = Flask(__name__)


@app.route('/')
def hello():
return render_template('result.html')
def training():
print('training...')
time.sleep(10)
print('training done.')
# return redirect(url_for('done'))
return '<h1> Done </h1>'
@app.route('/done')
def done():
t1= threading.Thread(target=training)
t2 = threading.Thread(target=done)
t1.start()
t2.start()
return '<h1> Working on it... </h1>'
if __name__ == '__main__':
app.run(debug=True)

&#x200B;

result.html

<body>
<a href="{url_for('training')}">Start!</a>
</body>

So I have simulated a long process called 'training'. How do I run training in the background? While it's training in the background I want to return 'working on it...', and after 10 secs I want to display 'done'. I really want to implement threading and not Celery, but if you know the sol using Celery, do let me know. Thank you!

/r/flask
https://redd.it/mbe65e
[P] Release of lightly 1.1.3 - A python library for self-supervised learning

We just released a new version of lightly (https://github.com/lightly-ai/lightly) and after the valuable feedback from this subreddit, we thought some of you might be interested in the updates.

Lightly now supports more models: In addition to SimCLR and MoCo, we have added SimSiam and Barlow Twins (a big thank you to our open-source contributors!). More models, such as BYOL and SwAV are in the pipeline.

We did some benchmarking (https://docs.lightly.ai/getting_started/benchmarks.html) on cifar10 and show the various frameworks in action using different training epochs and batch sizes.
Most models run well on multi-GPU setups using PyTorch Lightning in distributed data-parallel settings.

We are curious to hear your feedback.

/r/MachineLearning
https://redd.it/mbb7cl
starlette-jsonapi now with OpenAPI 3.x support

Disclaimer: I'm the maintainer, trying to make this a bit more visible and gather some feedback.

The latest version of starlette-jsonapi now has "experimental" OpenAPI 3.x (f.k.a. Swagger) support.

GitHub: https://github.com/vladmunteanu/starlette-jsonapi
Documentation: https://starlette-jsonapi.readthedocs.io/en/latest/
Examples: https://github.com/vladmunteanu/starlette-jsonapi/tree/master/examples

/r/Python
https://redd.it/mbc4f9
BlackJack Game!

Hey all! Just learning python, and did a project where I made a fully functional blackjack script! found it quite fun to play so i linked the GitHub link :)if anyone would know how to make it a little bit more compact? if there is anything i can improve just in general feel free :) hope you enjoy!

/r/Python
https://redd.it/mbjdf7
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/mbsiju