View the implementation source code in iPython

Super-specifically, I use By in the Python API of WebDriver, but I want to know what this declares. I remember `By.NAME```, but I wonder if it is By.CLASS_NAME``` or `` By.CLASS```.

At that time, I would do something like ``` locate'/ usr * python * webdriver * by *'` ``, which is kind of stupid.

> locate '/usr*python*/webdriver*by*'
/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/by.py
/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/by.pyc

(See in view or emacs)

I will introduce the method of ipython as a bean knowledge. Just add two?

In [1]> from selenium.webdriver.common.by import By
In [2]> By??
Type:        type
String form: <class 'selenium.webdriver.common.by.By'>
File:        /usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/by.py
Source:
class By(object):
    """
    Set of supported locator strategies.
    """

    ID = "id"
    XPATH = "xpath"
    LINK_TEXT = "link text"
    PARTIAL_LINK_TEXT = "partial link text"
    NAME = "name"
    TAG_NAME = "tag name"
    CLASS_NAME = "class name"
    CSS_SELECTOR = "css selector"

    @classmethod
    def is_valid(cls, by):
        for attr in dir(cls):
            if by == getattr(cls, attr):
                return True
        return False

For some reason, there was an introductory article on ipython in the book "Introduction to Data Analysis with Python", and I thought again that it was a shame that I didn't know the tool I was using.

The iPython cheat sheet is as follows.

http://damontallen.github.io/IPython-quick-ref-sheets/

bonus

This is also from the same book, but I was shocked soberly, so for reference (python-matplotlib package etc. are required first)

> ipython --pylab
In [1]> plot(np.random.randn(100).cumsum())

See https://www.youtube.com/watch?v=BrDJssegqwo to see how it works

Recommended Posts

View the implementation source code in iPython
Interrupt registration procedure as seen in the source code
[Python] Read the Flask source code
Interrupt processing flow seen in source code
Get the EDINET code list in Python
Syntax highlighting source code in PowerPoint / Keynote
[Python] Read the source code of Bottle Part 2
How to uniquely identify the source of access in the Django Generic Class View
Argument implementation (with code) in your own language
View the result of geometry processing in Python
[Python] Read the source code of Bottle Part 1
Specify the view URL in your Django template
[Modint] Decoding the AtCoder Library ~ Implementation in Python ~
[Python] Django Source Code Reading View Starting from Zero ①
Code that enumerates URL resolver view names in Django
About testing in the implementation of machine learning models
A reminder about the implementation of recommendations in Python
[Internal_math version (2)] Decoding the AtCoder Library ~ Implementation in Python ~
RNN implementation in python
ValueObject implementation in Python
View images in Matplotlib
SVM implementation in python
Code that sets the default value in case of AttributeError
Test code to check for broken links in the page
Commands often used in the development environment during Python implementation
Remove one-line comments containing Japanese from source code in Python
I tried to summarize the code often used in Pandas
Always check PEP8 while editing Python source code in Emacs