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
Markdown cells instead of Python comments?

I'm new to Jupyter. I code in Python and am wondering if there is a recommendation when to use Markdown cells and when to use comments in Python.

If I have comments in my Python code then why would I use Markdown cells as the purpose of both is to document what is going on.

Any best practice?

/r/IPython
https://redd.it/b8k98q
Aggregating just the code cells without the markdown cells

Once you have finalized your code and want to save from Jupyter notebook to a tradition python script file is there an easy way to copy / paste the code whilst ignoring the Markdown cells?

/r/IPython
https://redd.it/b8ksyn
[P] Rock Paper Scissors with Artificial Intelligence

Hi! I've created a Rock-Paper-Scissors game that works with artificial intelligence (AI). The AI can see and detect your hand gestures by front-facing camera. Also it can learn your playing strategy in a smart way. The more you play, It gets harder to win!

This app uses TensorFlow and deep learning technologies in order to detect the hand gestures. Sometimes the gestures may not be properly detected, but this will improve in future versions. You can help me in this process by taking pictures of your hand in different positions and sending them as a zip file to rpsapp@outlook.com .

Please Note:

* To get best results in hand gestures detection, put your device on a flat and steady surface.

* In order for the app to work properly, your device should have decent camera and hardware to run relatively heavy calculations.

I've been working on developing this app for a year, so any feedback from you will be a pleasure for me :)

You can get the app on Google Play: https://play.google.com/store/apps/details?id=cc.ramtin.rps

And you can read more about it on XDA: https://www.xda-developers.com/play-rock-paper-scissors-hand-gestures-against-ai-bot/

/r/MachineLearning
https://redd.it/b8htjt
What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.


/r/Python
https://redd.it/b8jq2r
I Wrote My First Python Package!

Just thought I'd share this: I've been working on a Python package that makes it easy to obtain and work with data from the USDA's Standard Reference Database for nutrient composition of different foods. I became interested in the USDA's API as it seems to be the standard for high-quality nutrition data -- it's used by many apps and it has data for \~160 different nutrients. My goal is to make the data much more accessible to developers.

Part of the package also has a feature which will tell you if you are meeting the Recommended Daily Amounts of each nutrient, so it could be helpful for nutritionists or people looking to improve their diet.

This is the first Python package I've made and I uploaded it to PyPI so it can be installed with pip. You can find the code here: 

[https://github.com/noahtren/noms](https://github.com/noahtren/noms)

Thanks for checking it out, and please share any advice on how to make it better. :)

/r/Python
https://redd.it/b8ncrx
People with experience in Django: is it possible to make a web application with a server push feature?



It should be like this:

I have a Raspberry Pi, an Arduino nano connected to the raspberry and other Arduino nano that will communicate with the "central" one.

My central Arduino, the one connected to the raspberry, will receive messages from others and pass them forward to the serial port. My app needs to read this info and do something about it. It can just be ignored, stored, do something on the Arduino end or it can trigger a event in the app. This event should be like a window that pop in front of the web page telling what happened.

I'm aware of the existence of the channels library and the celery one, too. Although I'm not anywhere near sure if it can be pulled together.

So... Can it be done with django?

/r/django
https://redd.it/b8nm6b
How do I prevent POST request on page refresh?

Hello,

Currently I am working on my webpage that has an "add to cart" feature.

​

Everything add to cart is clicked (post request), my session\['cart'\] is updated to include the new product added (list of items in the cart).

​

But there's a problem.

Lets say you add an item to cart, to session\['cart'\] = \[Banana\], if you then refresh the page the session\['cart'\] will become

session\['cart'\]=\[Banana, Banana\].

​

If you refresh again it'll become session\['cart'\]=\[Banana, Banana, Banana\] etc.

​

Is there a way to prevent a page refresh to send POST requests?

​

Thank you,

/r/flask
https://redd.it/b7ennc
How to create unique field with random content with only letters and case sensitive?

I want create random chars for links, such like imgur urls, for example: "abZXy". How to do it?

/r/djangolearning
https://redd.it/b8twbv
This media is not supported in your browser
VIEW IN TELEGRAM
I wrote a Python package to do adaptive sampling of functions in parallel [OC]

/r/Python
https://redd.it/b8xk3a
Call for maintainers for Celery's Django integrations

Since we're beginning our efforts to develop Celery 5 all resources are going to be directed to that effort.

Unlike Django, Celery has a very small team which we are looking to expand.

Part of the reason for expansion is because we no longer have the time to maintain the Django integrations properly.

​

If you are interested in maintaining our Django integrations, comment here or message me.

/r/django
https://redd.it/b8yv8z
Best site I've ever found for learning Python as a beginner.
https://edabit.com/challenges/python3

/r/Python
https://redd.it/b8xf9q
The best way to prevent a django model choicefield from saving any value not available in choices

I have a choice field for my Post model called privacy\_setting. Currently, in my PostSerializer, where I save the post with the validated data, I am somehow able to save any value in the privacy\_setting field that is not available in the choices section. What is the best approach to prevent this from happening?

> post = Post.objects.create(
text=validated\_data\['text'\],
owner=validated\_data\['owner'\],
privacy\_setting=validated\_data\['get\_privacy\_setting\_display'\])

My Post model field:

> privacy\_setting = models.CharField(
max\_length = 2,
choices = POST\_PRIVACY\_CHOICES,
default = PUBLIC
)

​

/r/django
https://redd.it/b93r4w
A package I want to use contains Linux paths for reading data and configs. Is there a way I can use it on a Windows machine without editing the source code?

This [very interesting ML package](https://github.com/facebookresearch/habitat-api) just came out, and like most such packages (especially in early phases), it seems to be designed primarily for Linux. For example, this code:

`env = habitat.Env(`

`config=habitat.get_config(config_file="tasks\\pointnav.yaml")`

`)`

returns an error since it wants to read another file from a path that uses forward slashes. Is there a way to get python to automatically "translate" files to work with Windows paths? In principle it shouldn't be too hard to tinker with the paths in one package, but since this seems to be systematic to many packages it would be quite handy to have an easier way to do it.

​

Thanks!

/r/Python
https://redd.it/b94s72
[Ask Flask] - Utilizing Flask for Obfuscating/Protecting Client/Server Python Application

My team and I are working on a project currently in Python 3 that utilizes a client/server communication model. Both our client and our server are written in Python 3, with the client utilizing the Kivy Framework for a GUI. All of our client/server communication is protected with strong, third-party audited encryption, with any communication between clients being protected by end-to-end encryption. My team and I would like to eventually release this code as an app both on desktop and mobile devices. However, because Python doesn't really make use of anything to protect code, we are hesitant to just throw our client .py file out there to be read (and copied). We are a very small team, and we worry that our idea could be easily snatched up by a company with massively more resources and funding while in it's early stages.

Since .py code can't really be obfuscated well, we were recommended to take a look at Flask for the purpose of using a web server middleman to mask what's happening behind the scenes. If I understand correctly, essentially we would have our GUI client communicate over Flask (I'd assume something like HTTPS?) with

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