Saturday, March 8, 2014

Python Study Note: "Help-like" command & Data Structures Intro.

In "raw" Python language, there are quite a few command to help me to understand what is going one with the software, these commands act like "help" functions for me. They are:

1. dir
    Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object.
    So, if I have no idea about how many variables are existing in the space, I run "dir()"; if I forget what attributes a variable has, I can run "dir(variable_name)", quite handy.

2. type
    With one argument, return the type of an object. The return value is a type object.
    Many times I may forget what is the type of some variable, and may not be able to add any functions on it! Type could help this very much.
    Ex. >> type('') is str


Basic data structure is the basis for any "fancy" structures (Pandas.DataFrame, etc). They are:
1. Basic: int, float, string
2. List
3. Tuple
4. Dictionary
5. Set
6. Sequence

The data structures are quite rich, and will write something about them in a separate Post.

No comments:

Post a Comment