[AF] Can't run hello world app with Flask, UnicodeDecodeError
I'm trying to run simple hello world flask app but sockets throws an error on Windows 10, Python 3.6.4
File "D:\Python\Python36-32\lib\socket.py", line 673, in getfqdn:
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xab in position 80: invalid start byte
I know I could hack some code in the source of socket.py but I don't want to do that yet. My hostname is "Pitku" so I don't know what text/character is causing the error. Have already tried changing Code Pages but none have worked.
Is there any way to backtrace/fix this error?
/r/flask
https://redd.it/8eeb94
I'm trying to run simple hello world flask app but sockets throws an error on Windows 10, Python 3.6.4
File "D:\Python\Python36-32\lib\socket.py", line 673, in getfqdn:
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xab in position 80: invalid start byte
I know I could hack some code in the source of socket.py but I don't want to do that yet. My hostname is "Pitku" so I don't know what text/character is causing the error. Have already tried changing Code Pages but none have worked.
Is there any way to backtrace/fix this error?
/r/flask
https://redd.it/8eeb94
reddit
r/flask - [AF] Can't run hello world app with Flask, UnicodeDecodeError
1 votes and 2 so far on reddit
Python Top 10 Open Source of the Month (v.Apr 2018)
https://medium.com/@Mybridge/python-top-10-open-source-of-the-month-v-apr-2018-9e91343756a
/r/Python
https://redd.it/8f1rbl
https://medium.com/@Mybridge/python-top-10-open-source-of-the-month-v-apr-2018-9e91343756a
/r/Python
https://redd.it/8f1rbl
Medium
Python Top 10 Open Source of the Month (v.Apr 2018)
For the past month, we ranked nearly 250 Python Open Source Projects to pick the Top 10.
Learning Python before proceeding to Django?
How much Python should I need to learn before I proceed to learning Django?
/r/djangolearning
https://redd.it/8eyuo9
How much Python should I need to learn before I proceed to learning Django?
/r/djangolearning
https://redd.it/8eyuo9
reddit
r/djangolearning - Learning Python before proceeding to Django?
8 votes and 7 so far on reddit
Arbitrary poetic verse in Python. I don't know why I wrote this.
https://github.com/Astrokiwi/arbitrary_python_verse
/r/Python
https://redd.it/8f346h
https://github.com/Astrokiwi/arbitrary_python_verse
/r/Python
https://redd.it/8f346h
GitHub
Astrokiwi/arbitrary_python_verse
Contribute to arbitrary_python_verse development by creating an account on GitHub.
Flask 1.0 released
https://www.palletsprojects.com/blog/flask-1-0-released/
/r/Python
https://redd.it/8f61xl
https://www.palletsprojects.com/blog/flask-1-0-released/
/r/Python
https://redd.it/8f61xl
package of the day: tqdm
hello and welcome to package of the day, the show where i type a few lines about a package i quite like and would be of use to programmers in a wide variety of contexts
today's package is called "tqdm"
A fast, extensible progress bar for Python and CLI
have you ever written a for loop that iterates over many variables and takes a long time to run?
to track its progress did you just add a print statement inside the loop indicating how far or which variable you're on, producing hundreds if not thousands of lines of text you only look at sparingly?
now you can do better. just import tqdm: `from tqdm import tqdm`
and wrap the structure you're for-ing in the tqdm() function like so: `for i in tqdm(range(10000)):`
now when you run your code, a dynamic progress bar like this one will automatically be generated when you start your loop:
`76%|████████████████████████████ | 7568/10000 [00:33<00:10, 229.00it/s]`
not only will it show you your progress; it'll provide you some simple metrics about how long the loop is taking and will take
try tqdm today!
/r/Python
https://redd.it/8f5wo3
hello and welcome to package of the day, the show where i type a few lines about a package i quite like and would be of use to programmers in a wide variety of contexts
today's package is called "tqdm"
A fast, extensible progress bar for Python and CLI
have you ever written a for loop that iterates over many variables and takes a long time to run?
to track its progress did you just add a print statement inside the loop indicating how far or which variable you're on, producing hundreds if not thousands of lines of text you only look at sparingly?
now you can do better. just import tqdm: `from tqdm import tqdm`
and wrap the structure you're for-ing in the tqdm() function like so: `for i in tqdm(range(10000)):`
now when you run your code, a dynamic progress bar like this one will automatically be generated when you start your loop:
`76%|████████████████████████████ | 7568/10000 [00:33<00:10, 229.00it/s]`
not only will it show you your progress; it'll provide you some simple metrics about how long the loop is taking and will take
try tqdm today!
/r/Python
https://redd.it/8f5wo3
reddit
package of the day: tqdm • r/Python
hello and welcome to package of the day, the show where i type a few lines about a package i quite like and would be of use to programmers in a...
Is there any jupyter extension to search into jupyter directory by file contents?
I have tons .ipynb files.I want to search and filter by jupyter file contents. Hello everyone.I have tons .ipynb files.I want to search and filter by jupyter file contents. I do some search on google and find jupyter-tree-filter which adds a search box on your jupyter directory and filter files by filename, not by file contents.Is there any jupyter extension to search jupyter file contents?
/r/JupyterNotebooks
https://redd.it/8f5okb
I have tons .ipynb files.I want to search and filter by jupyter file contents. Hello everyone.I have tons .ipynb files.I want to search and filter by jupyter file contents. I do some search on google and find jupyter-tree-filter which adds a search box on your jupyter directory and filter files by filename, not by file contents.Is there any jupyter extension to search jupyter file contents?
/r/JupyterNotebooks
https://redd.it/8f5okb
reddit
Is there any jupyter extension to search into... • r/JupyterNotebooks
I have tons .ipynb files.I want to search and filter by jupyter file contents. Hello everyone.I have tons .ipynb files.I want to search and filter...
[N] Google Brain is expanding to Tokyo
https://twitter.com/hardmaru/status/989619084357652481
/r/MachineLearning
https://redd.it/8f6hqn
https://twitter.com/hardmaru/status/989619084357652481
/r/MachineLearning
https://redd.it/8f6hqn
Twitter
hardmaru
Excited about expanding the Google Brain team in Tokyo. If you are excited to work on fresh and interesting AI research, please consider applying! https://t.co/SCI9AyppSN
Checking your snail mail with Python/Docker and Slack!
http://opsandautomation.com/2018/04/26/checking-your-snail-mail-with-python-docker-and-slack-part-1/
/r/Python
https://redd.it/8f7pw3
http://opsandautomation.com/2018/04/26/checking-your-snail-mail-with-python-docker-and-slack-part-1/
/r/Python
https://redd.it/8f7pw3
Flask 1.0 Released 🎉
https://www.palletsprojects.com/blog/flask-1-0-released/
/r/flask
https://redd.it/8f5yn9
https://www.palletsprojects.com/blog/flask-1-0-released/
/r/flask
https://redd.it/8f5yn9
How can I use Python to automate mass-printing in my office?
Hi all! Like many of you, I have an office job with a lot of repetitive daily tasks.
I work for a travel company, and I've recently been put in charge of admin duties which involve physically printing out customized cover letters and selected information sheets (dependent on which tour / location we're sending clients to, which airline they're flying with, transfer companies etc) to mail to our clients pre-departure. I have to spend a lot of time selecting the right documents to send them, and it's really eating up my time when this isn't really my job role.
The problem is, no one else is going to do it, so I'd love to find a way to automate it so I can free up time to do my actual job.
My current theory at the moment would be a basic spreadsheet with boolean values for each airlines, tour operators etc, cover letters, then make a basic loop that grabs the client name, customizes and populates the PDFs and then does a batch print job.
Can anyone suggest a better way to do this, or specific libraries to use, etc? Would love to hear your suggestions :)
Thanks all, and have a good day!
/r/Python
https://redd.it/8fa955
Hi all! Like many of you, I have an office job with a lot of repetitive daily tasks.
I work for a travel company, and I've recently been put in charge of admin duties which involve physically printing out customized cover letters and selected information sheets (dependent on which tour / location we're sending clients to, which airline they're flying with, transfer companies etc) to mail to our clients pre-departure. I have to spend a lot of time selecting the right documents to send them, and it's really eating up my time when this isn't really my job role.
The problem is, no one else is going to do it, so I'd love to find a way to automate it so I can free up time to do my actual job.
My current theory at the moment would be a basic spreadsheet with boolean values for each airlines, tour operators etc, cover letters, then make a basic loop that grabs the client name, customizes and populates the PDFs and then does a batch print job.
Can anyone suggest a better way to do this, or specific libraries to use, etc? Would love to hear your suggestions :)
Thanks all, and have a good day!
/r/Python
https://redd.it/8fa955
reddit
How can I use Python to automate mass-printing in my... • r/Python
Hi all! Like many of you, I have an office job with a lot of repetitive daily tasks. I work for a travel company, and I've recently been put in...
sqlalchemy query as dict
Is there a simple way to return the query result as a dict without much hassle?
I have this query: result = SomeModel.query.with_entities(....).filter(...).all(). With this I get the desired fields as a list. Now I would like to get them with their corresponding column name. Is it possible to do this in the query directly without additional computing? I have tried with label() and with_labels() but with no luck.
/r/flask
https://redd.it/8f3bom
Is there a simple way to return the query result as a dict without much hassle?
I have this query: result = SomeModel.query.with_entities(....).filter(...).all(). With this I get the desired fields as a list. Now I would like to get them with their corresponding column name. Is it possible to do this in the query directly without additional computing? I have tried with label() and with_labels() but with no luck.
/r/flask
https://redd.it/8f3bom
reddit
sqlalchemy query as dict • r/flask
Is there a simple way to return the query result as a dict without much hassle? I have this query: result =...
Strong password and passphrase generator package with entropy calculation
Hey, longtime lurker here. Finally decided to give developing new packages a shot and released a package for generating cryptographically strong passwords and passphrases. I still have a lot to learn so I appreciate any tips or comments on how to improve!
[SPass](https://github.com/Tauag/spass)
/r/Python
https://redd.it/8fby9a
Hey, longtime lurker here. Finally decided to give developing new packages a shot and released a package for generating cryptographically strong passwords and passphrases. I still have a lot to learn so I appreciate any tips or comments on how to improve!
[SPass](https://github.com/Tauag/spass)
/r/Python
https://redd.it/8fby9a
GitHub
Tauag/spass
spass - Generate cryptographically strong passwords and passphrases
Someone is scraping my website, what can I do to automatically block them?
I run a real estate listings site and there is someone scraping the records one-by-one. I track each listing impression and I can see which IP addresses are scraping the data. I've been blocking the IP's but the scraper is now using 3+ IP addresses at a time to scrape.
What can I do to prevent the mad scrapes? Is there some way for my server to automatically ban an IP address if it hits too many impressions during a period of time?
/r/django
https://redd.it/8fcq91
I run a real estate listings site and there is someone scraping the records one-by-one. I track each listing impression and I can see which IP addresses are scraping the data. I've been blocking the IP's but the scraper is now using 3+ IP addresses at a time to scrape.
What can I do to prevent the mad scrapes? Is there some way for my server to automatically ban an IP address if it hits too many impressions during a period of time?
/r/django
https://redd.it/8fcq91
reddit
Someone is scraping my website, what can I do to... • r/django
I run a real estate listings site and there is someone scraping the records one-by-one. I track each listing impression and I can see which IP...
SQLAlchemy vs PostgreSQL Functions
Hey guys, we're using heavily PostgreSQL (we let it handle all business logic, mapping, etc.). We use Flask only to handle requests, call queries on the DB and then respond back the return from the Database.
Now a problem is that SQL is hard to read once it reaches a certain amount of complexity (and that can happen really fast). Production is very slow and the code becomes hard to maintain. On the other hand, one can argue that it's more performant than using a lightweight ORM like SQLAlchemy. Did any of you make similar experience? Would you let handle PostgreSQL everything, as we do, or would you move the logic to Flask?
I hope to read some advices.
Have a great weekend!
/r/flask
https://redd.it/8ff41v
Hey guys, we're using heavily PostgreSQL (we let it handle all business logic, mapping, etc.). We use Flask only to handle requests, call queries on the DB and then respond back the return from the Database.
Now a problem is that SQL is hard to read once it reaches a certain amount of complexity (and that can happen really fast). Production is very slow and the code becomes hard to maintain. On the other hand, one can argue that it's more performant than using a lightweight ORM like SQLAlchemy. Did any of you make similar experience? Would you let handle PostgreSQL everything, as we do, or would you move the logic to Flask?
I hope to read some advices.
Have a great weekend!
/r/flask
https://redd.it/8ff41v
reddit
SQLAlchemy vs PostgreSQL Functions • r/flask
Hey guys, we're using heavily PostgreSQL (we let it handle all business logic, mapping, etc.). We use Flask only to handle requests, call queries...
Basic Docker (Compose) Django + Postgres Setup
https://www.youtube.com/watch?v=90LCcim-wHQ
/r/django
https://redd.it/8ff028
https://www.youtube.com/watch?v=90LCcim-wHQ
/r/django
https://redd.it/8ff028
YouTube
Dockerize your Django Application - Part 1/3
Part 2: https://www.youtube.com/watch?v=pStG1cmXzZo
Website: https://chkr.at
Docker-Compose Documentation: https://docs.docker.com/compose/overview/
Install Docker Tutorial: https://docs.docker.com/install/
Want to say thanks? Subscribe and Like my Videos…
Website: https://chkr.at
Docker-Compose Documentation: https://docs.docker.com/compose/overview/
Install Docker Tutorial: https://docs.docker.com/install/
Want to say thanks? Subscribe and Like my Videos…
A python multithreaded logging handler package that streams records to AWS services(S3, Kinesis)
https://github.com/omrikiei/aws_logging_handlers
/r/Python
https://redd.it/8ffvg8
https://github.com/omrikiei/aws_logging_handlers
/r/Python
https://redd.it/8ffvg8
GitHub
GitHub - omrikiei/aws_logging_handlers: AWS integration for python logging handlers(S3, Kinesis)
AWS integration for python logging handlers(S3, Kinesis) - omrikiei/aws_logging_handlers
Changing Matplotlib fonts: Neophyte who uses Juno Jupyter for scientific plotting.
I know this may be a little more specialized to Matplotlib, as I’m one of those lowly matl*b to Python ship jumpers, for the purposes of plotting pretty data and performing analyses on it. But I’m stuck somewhere that while trivial, will nevertheless drive me nuts as a strongly visual person: If anyone could provide guidance for changing the font on either a global or per-plot basis for all labels and legends in a plot you would have my eternal gratitude. Using rcParams as in the matplotlib documentation gives:
/home/nbuser/anaconda3_501/lib/python3.6/site-packages/matplotlib/font_manager.py:1320: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
/r/JupyterNotebooks
https://redd.it/8fbqru
I know this may be a little more specialized to Matplotlib, as I’m one of those lowly matl*b to Python ship jumpers, for the purposes of plotting pretty data and performing analyses on it. But I’m stuck somewhere that while trivial, will nevertheless drive me nuts as a strongly visual person: If anyone could provide guidance for changing the font on either a global or per-plot basis for all labels and legends in a plot you would have my eternal gratitude. Using rcParams as in the matplotlib documentation gives:
/home/nbuser/anaconda3_501/lib/python3.6/site-packages/matplotlib/font_manager.py:1320: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
/r/JupyterNotebooks
https://redd.it/8fbqru
reddit
Changing Matplotlib fonts: Neophyte who uses... • r/JupyterNotebooks
I know this may be a little more specialized to Matplotlib, as I’m one of those lowly matl*b to Python ship jumpers, for the purposes of...
[AF] Jinja macros and field formatting.
Within jinja2 templates I'm using a macro to render the fields in my forms. The macros handle all the formatting, label placement, validators, etc. Like so:
_forms.html
{% macro render_field(field) %}
<hr class="forms">
{{ field.label }}
{% if field.flags.required %}
*
{% endif %}
<br>
{{ field(**kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<span class="flash">{{ error }}</span><br>
{% endfor %}
{% endif %}
{% endmacro %}
template code:
{% from "_forms.html" import render_field %}
{% extends "base.html" %}
{{ render_field(form.search_by) }}
{{ render_field(form.search_term) }}
{% endblock %}
My question is this: is there any way to pass width/height values to the engine via the macros? If you simply declare the fields directly you can pass parameters to format the field, but these parameters break the macros.
template code:
{% extends "base.html" %}
{{ form.description.label }}{{ form.description(size="100") }}
{% endblock %}
/r/flask
https://redd.it/8fbeil
Within jinja2 templates I'm using a macro to render the fields in my forms. The macros handle all the formatting, label placement, validators, etc. Like so:
_forms.html
{% macro render_field(field) %}
<hr class="forms">
{{ field.label }}
{% if field.flags.required %}
*
{% endif %}
<br>
{{ field(**kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<span class="flash">{{ error }}</span><br>
{% endfor %}
{% endif %}
{% endmacro %}
template code:
{% from "_forms.html" import render_field %}
{% extends "base.html" %}
{{ render_field(form.search_by) }}
{{ render_field(form.search_term) }}
{% endblock %}
My question is this: is there any way to pass width/height values to the engine via the macros? If you simply declare the fields directly you can pass parameters to format the field, but these parameters break the macros.
template code:
{% extends "base.html" %}
{{ form.description.label }}{{ form.description(size="100") }}
{% endblock %}
/r/flask
https://redd.it/8fbeil
reddit
[AF] Jinja macros and field formatting. • r/flask
Within jinja2 templates I'm using a macro to render the fields in my forms. The macros handle all the formatting, label placement, validators,...