Mildly Interesting: The source for the Zen of Python completely violates the Zen of Python
For those that don't know, the Zen of Python is an easter egg included with the language:
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain,
/r/Python
https://redd.it/azuq9g
For those that don't know, the Zen of Python is an easter egg included with the language:
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain,
/r/Python
https://redd.it/azuq9g
reddit
r/Python - Mildly Interesting: The source for the Zen of Python completely violates the Zen of Python
172 votes and 44 comments so far on Reddit
Job execution, celery + flask
Hi,
I need your advices about python jobs execution. I'm working with ad platforms and i have several job with are independant python project which do stuff as data extraction ( from ad platform ) and data insertion ( to my databases ). Thoses jobs take around 30 minutes each. Each time i want to run a job, i clone it from github, install a virtualenv and the requirements. Then i run the job and keep the logs. But now i'll need to expose them trought an API.I was wondering using celery with flask but i saw no one executing job by cloning from github + install venv + requiremenst and at the end delete the job folder.
Am i doing something wrong ?
Does anyone had the same experience ?
Thanks for reading
/r/Python
https://redd.it/b05c20
Hi,
I need your advices about python jobs execution. I'm working with ad platforms and i have several job with are independant python project which do stuff as data extraction ( from ad platform ) and data insertion ( to my databases ). Thoses jobs take around 30 minutes each. Each time i want to run a job, i clone it from github, install a virtualenv and the requirements. Then i run the job and keep the logs. But now i'll need to expose them trought an API.I was wondering using celery with flask but i saw no one executing job by cloning from github + install venv + requiremenst and at the end delete the job folder.
Am i doing something wrong ?
Does anyone had the same experience ?
Thanks for reading
/r/Python
https://redd.it/b05c20
reddit
r/Python - Job execution, celery + flask
15 votes and 3 comments so far on Reddit
Knitty: Jupyter+Pandoc+IDE power in plain Python/Julia/R/any-kernel-lang. Pandoc filter and Atom/Hydrogen friendly literature programming
[**Knitty**](https://github.com/kiwi0fruit/knitty) is a Pandoc filter and [Atom/Hydrogen](https://atom.io/packages/hydrogen)-friendly reproducible report generation tool via Jupyter, Pandoc and Markdown (fork of the [Stitch](https://github.com/kiwi0fruit/knitty/blob/master/docs/stitch.md) that is a [Knitr](http://yihui.name/knitr/)-[RMarkdown](http://rmarkdown.rstudio.com)-like library in Python). Insert python code (or other Jupyter kernel code) *to the Markdown document* **or write in plain Python/Julia/R with block-commented Markdown** and have code's results in the Pandoc output document.
Knitty is an important part of the [Best Python/Jupyter/PyCharm experience + report generation with Pandoc filters](https://github.com/kiwi0fruit/pandoctools/blob/master/docs/best_python_jupyter_pycharm_experience.md) (see there why writing in plain Python/Julia/R is great) but actually
Knitty is language agnostic and can be used with any Jupyter kernel. Can be used independently of Pandoctools and with any IDE of choise. So I guess it deserves a separate post. By the way: Atom/Hydrogen is also language agnostic. You can also try **VS Code** interface to Jupyter from [**vscode-python**](https://github.com/Microsoft/vscode-python) instead of Atom/Hydrogen. I highly recommend to try to think about ipynb as merely an output format like pdf instead of main format or intermediate format (albeit ipynb is great for presenting narrative interactively and it can even [be much more](https://github.com/kiwi0fruit/misc/blob/master/src/pdf_and_word_killer.md)).
[**knitty repo**](https://github.com/kiwi0fruit/knitty).
### P.S.
[Knitty vs. Knitpy](https://github.com/kiwi0fruit/knitty/issues/1) joke.
/r/JupyterNotebooks
https://redd.it/b06wvq
[**Knitty**](https://github.com/kiwi0fruit/knitty) is a Pandoc filter and [Atom/Hydrogen](https://atom.io/packages/hydrogen)-friendly reproducible report generation tool via Jupyter, Pandoc and Markdown (fork of the [Stitch](https://github.com/kiwi0fruit/knitty/blob/master/docs/stitch.md) that is a [Knitr](http://yihui.name/knitr/)-[RMarkdown](http://rmarkdown.rstudio.com)-like library in Python). Insert python code (or other Jupyter kernel code) *to the Markdown document* **or write in plain Python/Julia/R with block-commented Markdown** and have code's results in the Pandoc output document.
Knitty is an important part of the [Best Python/Jupyter/PyCharm experience + report generation with Pandoc filters](https://github.com/kiwi0fruit/pandoctools/blob/master/docs/best_python_jupyter_pycharm_experience.md) (see there why writing in plain Python/Julia/R is great) but actually
Knitty is language agnostic and can be used with any Jupyter kernel. Can be used independently of Pandoctools and with any IDE of choise. So I guess it deserves a separate post. By the way: Atom/Hydrogen is also language agnostic. You can also try **VS Code** interface to Jupyter from [**vscode-python**](https://github.com/Microsoft/vscode-python) instead of Atom/Hydrogen. I highly recommend to try to think about ipynb as merely an output format like pdf instead of main format or intermediate format (albeit ipynb is great for presenting narrative interactively and it can even [be much more](https://github.com/kiwi0fruit/misc/blob/master/src/pdf_and_word_killer.md)).
[**knitty repo**](https://github.com/kiwi0fruit/knitty).
### P.S.
[Knitty vs. Knitpy](https://github.com/kiwi0fruit/knitty/issues/1) joke.
/r/JupyterNotebooks
https://redd.it/b06wvq
GitHub
kiwi0fruit/knitty
Jupyter power in plain Python/Julia/R/any-kernel-lang. Jupyter kernels output as Pandoc filter. Atom/Hydrogen friendly Markdown literature programming. Stitch/Knotr fork. - kiwi0fruit/knitty
How do you separate the Django environment variables, and which ones do you use?
I did a tutorial that I can not remember which one, where some of the settings were in an .env file. I also do not remember which settings were there.
​
By the way, how do you separate some of the settings, like secret key and database? It's a good idea for me to do something like:
.env
source .env // in a linux terminal
​
And inside env file, contain something like
EXPORT DATABASE = 'database settings in a json format here'
​
And then use the .environ and json loads to get these values?
​
If not, how do you do this, more specifically, in a professional environment?
​
EDIT: I used python-decouple, which also uses an .env file or settings.ini, and from what I've seen, it (and others who do this work) will automatically search the file in the project root directory and do things automatically. But from what I've seen, they use it as environment variables, but they search the file directly, instead of exporting to the linux environment and then searching for them.
/r/djangolearning
https://redd.it/azzxeg
I did a tutorial that I can not remember which one, where some of the settings were in an .env file. I also do not remember which settings were there.
​
By the way, how do you separate some of the settings, like secret key and database? It's a good idea for me to do something like:
.env
source .env // in a linux terminal
​
And inside env file, contain something like
EXPORT DATABASE = 'database settings in a json format here'
​
And then use the .environ and json loads to get these values?
​
If not, how do you do this, more specifically, in a professional environment?
​
EDIT: I used python-decouple, which also uses an .env file or settings.ini, and from what I've seen, it (and others who do this work) will automatically search the file in the project root directory and do things automatically. But from what I've seen, they use it as environment variables, but they search the file directly, instead of exporting to the linux environment and then searching for them.
/r/djangolearning
https://redd.it/azzxeg
reddit
r/djangolearning - How do you separate the Django environment variables, and which ones do you use?
4 votes and 7 comments so far on Reddit
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/b087td
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/b087td
reddit
r/Python - What's everyone working on this week?
3 votes and 3 comments so far on Reddit
Status of r/djangolearning common repository
I have seen a few different posts on r/djangolearning regarding creating a common respository for learning purposes. Is there one currently being used? If not, I would love to create one and take charge of managing it.
/r/djangolearning
https://redd.it/azy60d
I have seen a few different posts on r/djangolearning regarding creating a common respository for learning purposes. Is there one currently being used? If not, I would love to create one and take charge of managing it.
/r/djangolearning
https://redd.it/azy60d
reddit
r/djangolearning - Status of r/djangolearning common repository
6 votes and 0 comments so far on Reddit
An explanation of Python metaclasses, and how the Django ORM uses them to work some "magic"
https://www.b-list.org/weblog/2019/mar/04/class/
/r/django
https://redd.it/b09dhn
https://www.b-list.org/weblog/2019/mar/04/class/
/r/django
https://redd.it/b09dhn
reddit
r/django - An explanation of Python metaclasses, and how the Django ORM uses them to work some "magic"
18 votes and 0 comments so far on Reddit
Use cases of Django on Kubernetes
I was curious if anyone knew of good use cases of Django on Kubernetes. It seems a little "heavy" for a microservice compared to a microframework like Flask but maybe there are ways to work around that fact.
/r/django
https://redd.it/b08l5y
I was curious if anyone knew of good use cases of Django on Kubernetes. It seems a little "heavy" for a microservice compared to a microframework like Flask but maybe there are ways to work around that fact.
/r/django
https://redd.it/b08l5y
reddit
r/django - Use cases of Django on Kubernetes
10 votes and 9 comments so far on Reddit
Does your work require mathematical knowledge?
I found a Django work for beginner today, but when I went to the site to apply for the job, first it is necessary to do several tests to reach a minimum score to make the interest available in the works.
​
One is about finding the greatest common divisor between two numbers, okay, that's not difficult, but it's been a long time since I studied math and I do not remember how I do it.
​
There were also other questions involving math. I can not speak much more because I only had 3 questions available so far.
​
Anyway, what do you think of that? Do you use this knowledge in your work with Django?
/r/django
https://redd.it/b0diqr
I found a Django work for beginner today, but when I went to the site to apply for the job, first it is necessary to do several tests to reach a minimum score to make the interest available in the works.
​
One is about finding the greatest common divisor between two numbers, okay, that's not difficult, but it's been a long time since I studied math and I do not remember how I do it.
​
There were also other questions involving math. I can not speak much more because I only had 3 questions available so far.
​
Anyway, what do you think of that? Do you use this knowledge in your work with Django?
/r/django
https://redd.it/b0diqr
reddit
r/django - Does your work require mathematical knowledge?
0 votes and 2 comments so far on Reddit
Help with dynamically creating <img> tags using Vue/javascript in Flask application
I'm currently working with on a Flask + Vue/js application. So far, it's been fairly easy importing images into the project by writing `<img src= "{url_for('static', filename='images/image_name.png') }"` in the html file.
​
However, now I need dynamically load x copies of an image at runtime. The technique above (written in javascript) isn't working (as I should have known from the 'static' retrieval method).
​
Advice?
/r/flask
https://redd.it/b0dbtp
I'm currently working with on a Flask + Vue/js application. So far, it's been fairly easy importing images into the project by writing `<img src= "{url_for('static', filename='images/image_name.png') }"` in the html file.
​
However, now I need dynamically load x copies of an image at runtime. The technique above (written in javascript) isn't working (as I should have known from the 'static' retrieval method).
​
Advice?
/r/flask
https://redd.it/b0dbtp
reddit
r/flask - Help with dynamically creating tags using Vue/javascript in Flask application
4 votes and 3 comments so far on Reddit
Redirecting URLs on Deployed Flask Apps
I'm using PythonAnywhere to host a Flask app. I've redirected my app homepage to a domain I brought which should work (waiting on DNS records to update). How would I go about making sure the other pages such as [www.test.com/page2](https://www.test.com/page2) redirects correctly?
/r/flask
https://redd.it/b0da9o
I'm using PythonAnywhere to host a Flask app. I've redirected my app homepage to a domain I brought which should work (waiting on DNS records to update). How would I go about making sure the other pages such as [www.test.com/page2](https://www.test.com/page2) redirects correctly?
/r/flask
https://redd.it/b0da9o
An explanation of Python metaclasses, and how the Django ORM uses them to work some "magic"
https://www.b-list.org/weblog/2019/mar/04/class/
/r/Python
https://redd.it/b09dsr
https://www.b-list.org/weblog/2019/mar/04/class/
/r/Python
https://redd.it/b09dsr
reddit
r/Python - An explanation of Python metaclasses, and how the Django ORM uses them to work some "magic"
55 votes and 7 comments so far on Reddit
Django: An Unofficial Opinionated FAQ
https://blog.doismellburning.co.uk/django-an-unofficial-opinionated-faq/
/r/django
https://redd.it/b0e06y
https://blog.doismellburning.co.uk/django-an-unofficial-opinionated-faq/
/r/django
https://redd.it/b0e06y
blog.doismellburning.co.uk
Django: An Unofficial Opinionated FAQ - Kristian Glass - Do I Smell Burning?
I really like Django. Django is fast, featureful, secure, scalable, and versatile. It works well with a variety of workflows, approaches, tools, pl...
How to print name to screen when button clicked?
Hi, I'm trying to print the name to the same screen when a user enters a name and clicks the submit button. I'm getting error: hello() missing 1 required positional argument: 'greeting\_id'
Any help would be great, here's my code:
Views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import Greeting
# create hello view
def hello(request, greeting_id):
if request.method == 'POST':
if request.POST['firstname']:
greeting = models.Greeting()
greeting.firstname = request.POST['firstname']
greeting.save()
obj = models.Greeting.objects.get(pk=greeting_id)
/r/django
https://redd.it/b0e4y1
Hi, I'm trying to print the name to the same screen when a user enters a name and clicks the submit button. I'm getting error: hello() missing 1 required positional argument: 'greeting\_id'
Any help would be great, here's my code:
Views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import Greeting
# create hello view
def hello(request, greeting_id):
if request.method == 'POST':
if request.POST['firstname']:
greeting = models.Greeting()
greeting.firstname = request.POST['firstname']
greeting.save()
obj = models.Greeting.objects.get(pk=greeting_id)
/r/django
https://redd.it/b0e4y1
reddit
r/django - How to print name to screen when button clicked?
0 votes and 2 comments so far on Reddit
Machine Learning Resume Generator With Python, TextGenRnn and AWS
I was like one of you folks once, trying to think how to write a resume before I started working as a full-stack dev at a place I love. Over the years I have obsessed about how to make it easy for every one to build their resume. Using some AI magic, I ended up creating a site (a side project) that allows you to create a resume for free. Here’s the link: [https://thisresumedoesnotexist.com/](https://thisresumedoesnotexist.com/)
I've used [https://github.com/minimaxir/textgenrnn/tree/master/textgenrnn](https://github.com/minimaxir/textgenrnn/tree/master/textgenrnn) to generate the text by feeding it data scraped from various resources. My script runs in a "while true" loop and generates a new resume every 3-4 seconds. Resume is then saved to S3 and the same resume is loaded via CloudFront for all users.
I plan to make it more and more awesome, like you add your name and designation and it fills up your resume. But, I thought it would be nice to get a feedback from you folks and see if I can add the to my to-do for the side project.
I’d the following thoughts on why I started working on it:
\- I knew a guy who got a job at Google, who previously couldn’t get a job at an IT
/r/Python
https://redd.it/b099zl
I was like one of you folks once, trying to think how to write a resume before I started working as a full-stack dev at a place I love. Over the years I have obsessed about how to make it easy for every one to build their resume. Using some AI magic, I ended up creating a site (a side project) that allows you to create a resume for free. Here’s the link: [https://thisresumedoesnotexist.com/](https://thisresumedoesnotexist.com/)
I've used [https://github.com/minimaxir/textgenrnn/tree/master/textgenrnn](https://github.com/minimaxir/textgenrnn/tree/master/textgenrnn) to generate the text by feeding it data scraped from various resources. My script runs in a "while true" loop and generates a new resume every 3-4 seconds. Resume is then saved to S3 and the same resume is loaded via CloudFront for all users.
I plan to make it more and more awesome, like you add your name and designation and it fills up your resume. But, I thought it would be nice to get a feedback from you folks and see if I can add the to my to-do for the side project.
I’d the following thoughts on why I started working on it:
\- I knew a guy who got a job at Google, who previously couldn’t get a job at an IT
/r/Python
https://redd.it/b099zl
Thisresumedoesnotexist
ChatGPT Famous Resumes - AI Inspired Resume Examples
Stand out among the competition with over 1000 AI-inspired resume examples. See what works for the resumes of the world’s most successful people, and create a resume that’s just as good.
Question about examsheet model
Hi,
I would like to ask more advanced users how to create examsheet object in Django by correct way? Lets say examsheet must contains Questions and Answers so should we create 3 models with manytomany relations ship like Examsheet, Question, Answer or it's not correct?
/r/django
https://redd.it/b0kh4y
Hi,
I would like to ask more advanced users how to create examsheet object in Django by correct way? Lets say examsheet must contains Questions and Answers so should we create 3 models with manytomany relations ship like Examsheet, Question, Answer or it's not correct?
/r/django
https://redd.it/b0kh4y
reddit
r/django - Question about examsheet model
0 votes and 0 comments so far on Reddit
[D] A Brief Story Of Silicon Valley's Affair With AI
A pessimistic (but entertaining) perspective which I think adds discussion to OpenAI's recent change to LP status
https://blog.piekniewski.info/2019/03/12/a-short-story-of-silicon-valleys-affair-with-ai/
/r/MachineLearning
https://redd.it/b0i72m
A pessimistic (but entertaining) perspective which I think adds discussion to OpenAI's recent change to LP status
https://blog.piekniewski.info/2019/03/12/a-short-story-of-silicon-valleys-affair-with-ai/
/r/MachineLearning
https://redd.it/b0i72m
Piekniewski's blog
A brief story of Silicon Valley's affair with AI
Once upon a time, in the 1980's there was a magical place called Silicon Valley. Wonderful things were about to happen there and many people were about make a ton of money. These things were
Dynamic redirects in Flask
I am building a platform for use in my office. The general idea is that outside freelancers can submit queries about projects. The queries are approved by an in-house project manager and sent to the client for an answer. The project managers then re-approve the answers for view by the external freelancers.
I have pages for adding, editing and answering queries. However, I am having trouble with redirects after the forms are submitted. I have two choices, I can either have a direct redirect path stored in my return statement (such as a main project dashboard). Otherwise, I can use request.referrer to redirect to the previous page. As links for these options can appear on multiple pages for convenience, redirecting to a specific page is a bit confusing to the user.
I run into problems using wtforms and form validators. If a form fails validation, request.referrer becomes the page the user is currently on, and fixing the form errors and re-submitting brings them back to the current page, not the page they clicked the link to add, edit, or answer the query.
Is there any way to prevent request.referrer from updating on failed form submission, or a way to store the value of
/r/flask
https://redd.it/b0mbb0
I am building a platform for use in my office. The general idea is that outside freelancers can submit queries about projects. The queries are approved by an in-house project manager and sent to the client for an answer. The project managers then re-approve the answers for view by the external freelancers.
I have pages for adding, editing and answering queries. However, I am having trouble with redirects after the forms are submitted. I have two choices, I can either have a direct redirect path stored in my return statement (such as a main project dashboard). Otherwise, I can use request.referrer to redirect to the previous page. As links for these options can appear on multiple pages for convenience, redirecting to a specific page is a bit confusing to the user.
I run into problems using wtforms and form validators. If a form fails validation, request.referrer becomes the page the user is currently on, and fixing the form errors and re-submitting brings them back to the current page, not the page they clicked the link to add, edit, or answer the query.
Is there any way to prevent request.referrer from updating on failed form submission, or a way to store the value of
/r/flask
https://redd.it/b0mbb0
reddit
r/flask - Dynamic redirects in Flask
0 votes and 4 comments so far on Reddit
Python stdlib gems: collections.Counter
http://softwaremaniacs.org/blog/2019/03/09/collections-counter/en/
/r/Python
https://redd.it/b0iztp
http://softwaremaniacs.org/blog/2019/03/09/collections-counter/en/
/r/Python
https://redd.it/b0iztp
reddit
r/Python - Python stdlib gems: collections.Counter
119 votes and 22 comments so far on Reddit