In [1]:
lists = [i for i in range(5)]
lists?
%timeit range(1000)
In [2]:
%lsmagic
Out[2]:
In [3]:
%run test_run.py
In [4]:
!iPython profile locate default
In [5]:
ls /Users/weixi/.ipython/profile_default
In [6]:
from IPython.lib import passwd
my_psss = passwd('weixi')
my_psss
Out[6]:
In [7]:
%who
In [8]:
class MyData(object):
pass
mathObj = MyData()
mathObj.x = 10
mathObj.y = 20
z = mathObj.x + mathObj.y
z
Out[8]:
In [9]:
class AddressBook(object):
def __init__(self, name, phone):
self.name = name
self.phone = phone
print "Address create: {}, {}".format(self.name, self.phone)
class EmpolyeeAB(AddressBook):
def __init__(self, name, phone, title):
# super(EmpolyeeAB, self).__init__(name, phone)
AddressBook.__init__(self, name, phone)
self.title = title
print "Employee create: {}".format(self.title)
eab = EmpolyeeAB("weixi", "130", "cxo")
print eab.title, eab.name, eab.phone
In [10]:
import this
In [11]:
colors = ['red','green','blue']
str_colors = ','.join(colors)
str_colors
Out[11]:
In [12]:
type(range(10))
type(reversed(range(10)))
list(reversed(range(10)))
Out[12]:
In [13]:
a = [1, 2, 3, 4, 5, 6]
zip(*([iter(a)]*1))
from itertools import islice
In [14]:
def one(*x):
print x[0]
a = [1, 2, 3, 4, 5, 6]
one(*a)
In [15]:
import keyword
print keyword.kwlist
In [ ]: