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
Best way to design website (just visual stuff)?

Once I've created my website (models, tests, etc), what's the best way to actually design it, in terms of HTML+CSS? Last summer (when I made a django website), I downloaded pre-made HTML pages and edited them to be used as templates in my django site, but I have the feeling that downloaded some HTML files and editing them line-by-line isn't the best way to do things (as in, add static images, design sidebars, etc). I tried downloading a theme-type thing, but it hasn't been updated to Django 2.0, so it won't work.

Edit: essentially, I want to know if there's a way to design WYSIWYG HTML shit (sidebars, generic pages, home pages, etc), that I can download the HTML of so that I'm not hardcoding every bit of HTML

/r/django
https://redd.it/8ezpcr
ELi5 Flask Restful

So I'm really new to fpython. I've used flask to manage afew simple flask webpages but I keep hearing about flaskRestful. What is it? why should I care? and how can I implement it in my projects? Any good tutorials that show the entire process say from building a simple html/css website to actual flaskrestful impllementation would be really welcome

/r/flask
https://redd.it/8ezkr3
Univarsal manga downloader (for offline reading)

Hello!

I have long thought whether to do this thread on reddit. In the end, I am writing this.


I would like to share my software with you.

If you like manga, it can be useful.

Sometimes it happens that there is no internet on phone or tablet.

This software helps to save all the manga chapters to disk, so you can transfer the files to your phone / tablet.

I will be very glad to the reviews and bugreports.

In the future, it is planned, possibly, gui and server version (web-interface).

Now works only cli.

The software now supports about 240 sites. Full list here: https://yuru-yuri.github.io/manga-dl/#resources-list


**Link on sources: https://github.com/yuru-yuri/manga-dl**


**Supported OS: Linux/Mac/Windows.**


Requires:

* python >= 3.5

(more here [requirements.txt](https://github.com/yuru-yuri/manga-dl/blob/master/requirements.txt) )


Current development status: Beta


Thank you for your attention!


Sorry for my english.


/r/Python
https://redd.it/8f1fid
How can I search code into jupyter files directory?

Hello everyone.I want to search python code into jupyter files directory.
For example, I want to search folllowing code:

"csvrows=csv.reader(csvfile,delimiter=',')"

Into the following directory:

|-r/

|-notebooks/

|-notebook1.ipynb

|-notebook2.ipynb

|-...

How can I do that?
I tried jupyter-tree-filter but it doesn't look for jupyter notebooks which are in subdirectories.

/r/IPython
https://redd.it/8ewo5f
[AF] How to sort posts more efficiently?

Hi, so I've been working on a reddit clone, for practice, and was wondering how to sort through posts more efficiently. Here is the code I have now to display posts on the main page:

def index():
posts = Post.query.all()
for post in posts:
post.set_hotness()
posts = Post.query.order_by(Post.hotness).all()
return render_template('index.html', title='Dopenet: You can do anything', posts=posts )

The set_hotness() function mentioned here is in the Posts table, which can be found [here](https://github.com/ModoUnreal/dopenet/blob/master/app/models.py).

I know my method of sorting through posts is highly inefficient and not scalable.

What am I doing wrong and how can I fix it?

/r/flask
https://redd.it/8exlzm
[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
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
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
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
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
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