If Python code written by someone else is hard to decipher (Python)

If Python code written by someone else is hard to decipher (Python)

・ ** If Spyder can be used ** On the Editor screen, with the function name selected, press ^ + I (= control + I) to The Object Inspector will show you what the object is. You can use it to see documentation comments about the function.

・ ** If Spyder cannot be used ** In the python console, \ >>> help (function name) And execute. In that case, the documentation comment is also displayed.

from pylab import * After that  >>> help(imshow)  Help on function imshow in module matplotlib.pyplot:    imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None,

extent=None, shape=None, filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, hold=None, **kwargs) Display an image on the axes.

Parameters
-----------
X : array_like, shape (n, m) or (n, m, 3) or (n, m, 4)

(Omitted) It looks like.

In a Python script How to make the library available import library name And how to from library name import function name from library name import * There is a way to do it.

import library name If Library name.function name Referenced in.

import pylab pylab.imshow(image) When import cv2 cv2.imshow("image title", image) like Even if each library has an image display function called imshow () You can use it properly.

from pylab import imshow If, It's hard to tell which library imshow () came from.

from pylab import * If, Which library imshow () came from From just that part of the script It's hard to know how to know it mechanically.

from library import * Then, there is a possibility that the identifier will be rewritten unintentionally before you know it. It will be higher. I intended to save the grayscale image with the variable name gray It will be replaced by the pylab.gray () function.   Summary: If Python code written by others is difficult to decipher ^ + I in Spyder integrated environment Help (function name) except in Spyder integrated environment To use.

Recommended Posts

If Python code written by someone else is hard to decipher (Python)
Rewrite Python2 code to Python3 (2to3)
[Python] tkinter Code that is likely to be reused
What to do if Python IntelliSense is not displayed in VS Code on Windows
I want to initialize if the value is empty (python)
Convert python 3.x code to python 2.x
Data visualization library "folium" by Python is very easy to use
I tried to find out if ReDoS is possible with Python
Code Python to check and graph if it follows Benford's law
Python script written in PyTorch is converted to exe with PyInstaller
What to do if there is a decimal in python json .dumps
What to do if the Pipenv environment is corrupted by updating Homebrew
If pip stops due to SSL, it is better to re-insert python itself
How to automatically notify by phone when the python system is down