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
Python script to Jupyter notebook

Just published a Python package on PyPI called **p2j**. Run

`pip install p2j`

and

`p2j script.py`

to get a Jupyter notebook script.ipynb. Example shown below:

​

PyPI: [https://pypi.org/project/p2j/](https://pypi.org/project/p2j/)

GitHub: [https://github.com/raibosome/python2jupyter](https://github.com/raibosome/python2jupyter)

​

PRs and feedback are greatly appreciated!

[Converting Python script to Jupyter notebook using a Python package](https://i.redd.it/3nmbjeo2omk21.jpg)

/r/JupyterNotebooks
https://redd.it/ay8rxd
How to create toggle buttons for input cells in html output?

Using rmarkdown, one can create html output like this [example](https://murray-cecile.github.io/labor-market-trends/). I've seen some hacky ways to do this some months ago with jupyter notebooks. Is there an easy way to do this now?

/r/JupyterNotebooks
https://redd.it/aybj4e
Learning flask, but stuck on wtforms

(tldr below)I'm an entry level front-end dev trying to understand what happens with the data after I send it from forms. So I've been learning flask, from Miguel Grinberg's The Flask Mega-Tutorial which is great so far but I've hit a roadblock at chapter 3: web forms.

My problem is:

Pretend I work as a front-end dev for a company. I'll make the HTML or possibly react, and pass the file(s) to the back-end dev. If they use flask, and want the csrf protection and validation from wtforms, they have to re-write all the forms using wtforms.

tl;dr: front-end dev writes page in html(or react), passes files to back-end dev who has to re-write in wtforms. Seems like wasted time.

/r/flask
https://redd.it/aybuv3
[N] Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning

Hi,

Coursera released new course with focus on Tensorflow and its best practices and I thought some of you may find it useful. I realise most of you guys are experienced engineers or researchers and already settled for PyTorch or Tensorflow or know both, however every time "PyTorch vs. Tensorflow" post pops up, there are some people unsure where to start with TF.

[https://www.coursera.org/learn/introduction-tensorflow](https://www.coursera.org/learn/introduction-tensorflow)

​

>If you are a software developer who wants to build scalable AI-powered algorithms, you need to understand how to use the tools to build them. This Specialization will teach you best practices for using TensorFlow, a popular open-source framework for machine learning.
>
> The Machine Learning course and Deep Learning Specialization from Andrew Ng teach the most important and foundational principles of Machine Learning and Deep Learning. This new deeplearning.ai TensorFlow Specialization teaches you how to use TensorFlow to implement those principles so that you can start building and applying scalable models to real-world problems. To develop a deeper understanding of how neural networks work, we recommend that you take the Deep Learning Specialization.
>
>The full deeplearning.ai TensorFlow Specialization will be available later this year, but you can get started with Course 1,

/r/MachineLearning
https://redd.it/ayap05
Supervisor for running multiple dynamically started python scripts?

Hey guys, I'm looking for a supervisor that will take care of dynamically created/started/stopped/destroyed python script processes, can you reccomend a good one?

/r/Python
https://redd.it/aycr6t
converting from flask to aiohttp

I'm looking into converting to aiohttp but in flask there is `@app.before_request` and `@app.after_request` that get called before and after each request. I also get as global `g` object. Not sure how to translate this over to aiohttp. Does aiohttp have similar features? I saw a context object possibly for `g` but didn't see anything for before/after request hooks.

/r/Python
https://redd.it/ayd0yn
[P] I built Lambda's $12,500 deep learning rig for $6200

See: http://l7.curtisnorthcutt.com/build-pro-deep-learning-workstation

Hi Reddit! I built a 3-GPU deep learning workstation similar to Lambda's 4-GPU ( RTX 2080 TI ) rig for half the price. In the hopes of helping other researchers, I'm sharing a time-lapse of the build, the parts list, the receipt, and benchmarking versus Google Compute Engine (GCE) on ImageNet. You save $1200 (the cost of an EVGA RTX 2080 ti GPU) per ImageNet training to use your own build instead of GCE. The training time is reduced by over half. In the post, I include 3 GPUs, but the build (increase PSU wattage) will support a 4th RTX 2080 TI GPU for $1200 more ($7400 total). Happy building!

/r/MachineLearning
https://redd.it/ayd01o
Flask + Celery In Docker Container but sharing files.

Hey All,

Know I am asking a lot of questions here lately. But I am learning in leaps and bounds.
Currently I have A Docker Compose file that boots up my flask app. and my celery worker into two different containers. My understanding is this is good practice. However I have a slight problem.

My Flask Application takes a file upload. This file gets uploaded into the static directory of the flask application. Then once the file is written to the host the celery worker picks up the file and processes it in the background. All this works perfectly on my local machine outside of docker.

One small issue. Which I am sure you can already foresee. When I containerise my application. Put the app and the worker into container. The user uploads the file and it goes into the flask containers file system. Then as expected the Celery Worker, In its container picks up the job. However the Celery Worker Cannot Locate the uploaded file for processing cause the file exists in the file system of the Flask App Container and not the Celery Worker Container.

Does any one have any experience working this one out? Any ideas

/r/flask
https://redd.it/aygfbt
Can Atom help tell me what parameters are needed?

/r/django
https://redd.it/ayeoim
First Python Script! Who knew old dogs can learn new tricks!

Woooo!

https://pastebin.com/ASmeZhRm

It's just a small script that tells me how much tea I need to buy for the month based on cup size and number or cups I drink daily...lol

The exercize did say keep the first one simple...

p.s. started with python2 and got shit on at stackexchange for trying to get a more exact output number...
was told flat out to use python3 LOL

https://i.imgur.com/KSfzK0P.jpg

python2 = old and busted

python3 = new hotness

/r/Python
https://redd.it/ayj6ge
What is the recommended way to install and manage Django?

Hello all, I recently started teaching myself python and have found my way to django and I have a couple questions.

I am running Devuan Ascii (basically debian stretch). I have installed pip3. I messed up doing this once already mostly because there are so many new things I'm learning I haven't quite learned how to manage what what way haha.

So here I am starting fresh. So my questions are:

1) Should I install django through my distributions repos? Or through pip?

2) When should I upgrade pip through pip vs through my distributions package manager? I have seen conflicting recommendations on other forums. I feel like I should stick with my distro repos for upgrades, because I suspect that my following a tutorial that had me upgrade pip with pip after having initially installed from distro repos is what caused the issues I had before

​

Any input would be appreciated!

/r/django
https://redd.it/ayncaw
firebase for server UI

I have a flask app which is the backend and has an Android client. How can i use firebase to show notification on the web UI (Backend UI). Does firebase allow sending notification to only clients (Android, IOS, Web) ?

/r/flask
https://redd.it/aym6c5
400GB data-set of Conversational Audio. (Unlabeled) Cross-post from r/NLP [Project]

New here. Currently working on a project to explore the abilities of the transformer architecture to elaborate from data similar to how Open AI's release with GPT-2 does for text. I have scrapped about 400GB of conversational audio data with most files in both .ogg and .mp3 from podcasts and audio books available on [archive.org](https://archive.org). I would be happy to share with anyone that is interested.

​

Here is a link to the readme for my project for those interested in that: [https://github.com/gittb/audiosandbox/blob/master/README.md](https://github.com/gittb/audiosandbox/blob/master/README.md)

​

If anyone has any knowledge into how I would possibly encode an STFT array similar to how text vectors are fed to the GPT-2 model I would love to hear your approach. I'm a current student in college and always looking for explanations and viewpoints.

​

Data Update: Due to the large amount of demand for the data-set, I will be publishing AWS links here tomorrow (Friday) around 2PM Central Time in 50GB chunks, this should enable everyone that wants the data access without compromising the utility of my machine. I plan on hosting the data for 3 months.

/r/MachineLearning
https://redd.it/ayl3wb
UpdateView limit field items

I have a generic UpdateView with a dropdown, but I only want to show items that belong to the current user. How would I go about this? Very new to this, thanks.

/r/djangolearning
https://redd.it/ay6857
Test-Driven Development: Still a little confused...

I was going through the tutorial in the Django documentation and one of the last things covered is tests. The tutorial mentions a bug in the code and then writing a test to fix the bug. The recommendation is to create tests and then write/re-factor code until the test passes. My confusion is around how one would know what tests to create in the first place. I think things just haven't "clicked" for me yet.

Do you generally write a basic placeholder function, then write a detailed test for what output you want to get based on certain inputs, then fill out the function until the test passes? Any clarification on how you approach tests would be greatly appreciated.

/r/django
https://redd.it/ayrtjw