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
Reading in large text data using numba?

I want to read a large text file in and then use numba operations on it (and do this in parallel using prange). Does anyone have any good resources or tips on how to do this?

So far, I tried creating a generator to read text, but numba would not let me pass it in as a parameter (which I'm confused about, because [here](http://numba.pydata.org/numba-doc/0.18.1/developer/generators.html) it mentions that generators are supported by numba.

/r/Python
https://redd.it/bdmnbp
What did Fluent Python help you work on with Django?

I will read it in a few weeks, many recommend it, and I want to know what it helps in the Django scenario. For now, besides the basic python, I just needed to learn decorators and super(), but there is a difference between using a framework and learning to program.

/r/django
https://redd.it/bdndaj
Swagger without DRF?

Hello,

I want to have swagger ui in my project but I don't use Django Rest Framework but all the packages I found are specifically for DRF, like [https://django-rest-swagger.readthedocs.io/en/latest/](https://django-rest-swagger.readthedocs.io/en/latest/)


Is there a package for django that I could use to generate swagger docs without DRF?

/r/django
https://redd.it/bdpxrt
Learning Django for the first time. Need help with error. TemplateSyntaxError - Invalid block tag 'endif'

Hi, I'm new to Django, and Python in general.

I've been following Corey Schafer's Django tutorial but got stuck with an invalid blog tag error: [https://pastebin.com/816QTzDy](https://pastebin.com/816QTzDy)

My base.html looks like this: [https://pastebin.com/ndsbJKi4](https://pastebin.com/ndsbJKi4)

​

At 26:30 in this tutorial: [https://www.youtube.com/watch?v=q4jPR-M0TAQ](https://www.youtube.com/watch?v=q4jPR-M0TAQ)

​

Would appreciate if anyone can help me out here. Thanks in advance!

/r/django
https://redd.it/bdrp3u
Unaffected variables

Hello everyone.

I am doing some little benchmarks with loops on python's data structures

and I would like to know if python is doing some kind of optimization in these

following cases :

​

`for i in l:`

`i`

​

is Python computing the value of `i` even if it is not affected/used ?

​

Same with this for example :

`i = 0`

`while i < SIZE:`

`l[i]`

&#x200B;

Is `l[i]` computed anyway ?

&#x200B;

Thanks

/r/Python
https://redd.it/bdtyp9
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/bdudq2
[P] I used a Variational Autoencoder to build a feature-based face editing software

Hey reddit,

In my latest weekend-project I have been using a Variational Autoencoder to build a feature-based face editor. The model is explained in my youtube video:

https://youtu.be/uszj2MOLY08

You can inspect the code at Github:

https://github.com/SteffenCzolbe/FeatureTransferApp

The feature editing is based on modifying the latent distribution of the VAE. After training of the VAE is completed, the latent space is mapped by encoding the training data once more. Latent space vectors of each feature are determined based on the labels of the training data. Then to edit an image, we can add a combination of feature vectors to its latent distribution, and then reconstruct it. The reconstruction creates an altered version of the original image, based on the featrures we added to the latent representation.

The model used is heavily inspired by the Bate-VAE used in this paper by google deepmind (https://pdfs.semanticscholar.org/a902/26c41b79f8b06007609f39f82757073641e2.pdf). I made some adjustments to it to incorporate more recent advancements in neural network architecture, like using a Leaky ReLu activation function. The dataset used is celebA, which consist of 200.000 annotated images of celebrities. I aligned and cropped the images to a 64x64 resolution before training. The model is implememted in PyTorch, and PyGame has been used for the GUI. Training on my

/r/MachineLearning
https://redd.it/bdtmgh
Provide safe downloads of digital products?

Hi, r/flask!

I am working on a webpage for a friend that's selling beats. The project is nearing an end, but I need to develop a way to provide downloads for the products we sell.

My main focus needs to be security and efficiency. The store needs to provide immediate downloads to customers, and it is naturally very important to prevent unauthorized access to these files.

How can I solve this? What should my main concern be? Where can I get help/info about things like this?


Thanks in advance.

/r/flask
https://redd.it/bds8n4
[D] I couldn’t find a good resource for data scientists to learn Linux/shell scripting, so I made a cheat sheet and uploaded three hours of lessons. Enjoy!

I’ve taught Linux/UNIX/shell scripting at my past few jobs and realized I should record lessons and put them online. This is for everyone who wants/needs to learn Linux on the fly. Hopefully it’s useful.

[The cheat sheet is located here](https://www.dropbox.com/s/k7athu9i8lmmeln/Linux%20Cheat%20Sheet%20David%20Relyea.pdf)

[The three hours of lessons are located here](https://www.youtube.com/playlist?list=PLdfA2CrAqQ5kB8iSbm5FB1ADVdBeOzVqZ)

/r/MachineLearning
https://redd.it/bdviis
https://github.com/JaDogg/expressPython - A small Python editor for learning and competitive programming

/r/Python
https://redd.it/bduzsr
[RANT] Fabric 2 jumped the shark with it's complete rewrite

As you may know there's a major new version of [fabric](http://www.fabfile.org/) (out for some months actually); a complete *rewrite to do everything now in the proper way* in version 2.

I used to love fabric, because

* It fills a gap of doing repetetive task doing manually and using a full-blown automation and provisioning tool like ansible
* It's simple to use, but also powerful enough to do everything you need

Despite all dependencies being ready, there was never a port to Python 3 of the old and beloved fabric 1, so I thought I'd use version 2 for a new project, but damn, does it seem over-engineered now, making everything harder and more annoying:


## No real compatibility with the old fabfiles

Yes, the API is rewritten, and the [changes are major](http://www.fabfile.org/upgrading.html). Since the old fabric won't ever be compatible with Python3, you must use the new fabric (thankfully there's [`fabric3`](https://pypi.org/project/Fabric3/) which was forked from the old fabric to be compatible with Python 3. Apparently, it was not that hard to port, but fabric's original author [preferred to ignore attempts making version 1 Python 3 compatible](https://github.com/fabric/fabric/issues/1378)).

Also, the project is now split into multiple dependencies, like [Invoke](https://www.pyinvoke.org/), [Invocations](https://invocations.readthedocs.io/en/latest/), [Patchwork](https://fabric-patchwork.readthedocs.io/en/latest/).

## No `local` command to run tasks

/r/django
https://redd.it/be193q
[AF] Query an existing MySQL view with Flask-SQLAlchemy / SQLAlchemy

I'm working with a schema that I originally created by declaring models and then using the db.create_all() method to generate everything. Since then, I've created a view manually in MySQL Workbench. I tried just declaring the view as its own model after I had run the script containing the .create_all() call, but it has some weird behavior in that query.all() doesn't return all the results. Additionally, if I try to drop and recreate the schema using my database creation script, I get an "Unknown table" error.

What is the best way to approach this?

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