python tips

f'{:.2f}' When you want to specify significant figures and display while using f'{}'

Use tqdm

Use tqdm when you want to manage the progress. The basics about tqdm are nicely organized in other articles, so please refer to that. It is for people who want to get rid of "I'm surrounded by tqdm for the time being ...".

ind=3
txt = f'{ind:3d}.npy'

Display a message

pbar = tqdm(lis)
for something in pbar:
    pbar.set_description("Processing %s" % something)

Is the basic. I often use pathlib, so

from pathlib import Path
path = Path('hoge')
objects = path.glob('*/hoge')
pbar = tqdm(objects)
for object in pbar:
    pbar.set_description("Processing %s" % object.name)

You can display the name of the file you are currently processing by doing something like.

Recommended Posts

python tips
python tips
Python Tips
Python tips
Python Conda Tips
Python click tips
Unexpectedly (?) Python tips
Python and numpy tips
Python
Python Tips (my memo)
Python PyTorch install tips
[Blender x Python] Blender Python tips (11/100)
Python / Numpy np.newaxis thinking tips
Receiving standard input tips @ python
[Tips] Handle Athena with Python
[Python + Selenium] Tips for scraping
Google Drive Api Tips (Python)
~ Tips for beginners to Python ③ ~
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python comprehension
Python technique
Python 2.7 Countdown
Python memorandum
Python FlowFishMaster
Python service
python function ①
Python basics
Python memo
Tips on Python file input / output
ufo-> python (3)
Python comprehension
Jupyter Tips 4
install python
LaTeX, Python tips in master's thesis
Python Singleton
Python basics ④
Python Memorandum 2
python memo
Python Jinja2
Python increment
atCoder 173 Python
[Python] function
Python installation
numpy tips
Installing Python 3.4.3.
Try python
Python memo
Python iterative
Jupyter Tips 5
Python algorithm
Python2 + word2vec
Scapy Tips
[Python] Variables
Python functions
Python sys.intern ()
Python tutorial
Python decimals