- When you access an attribute, the resulting value may come from several different places. For example, a.name in the previous example returns the name attribute of the instance a. However, a.deposit returns the deposit attribute (a method) of the Account class.When you access an attribute, the instance is checked first and if nothing is known, the search moves to the instance’s class instead.This is the underlying mechanism by which a class shares its attributes with all of its instances.
- **The lack of scoping in classes is one area where Python differs from C++ or Java. If you have used those languages, the self parameter in Python is the same as the this pointer. The explicit use of self is required because Python does not provide a means to explicitly declare variables (that is, a declaration such as int x or float y in C). Without this, there is no way to know whether an assignment to a variable in a method is supposed to be a local variable or if it’s supposed to be saved as an instance attribut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# export the book Learn Vimscript the Hard Way | |
# git clone https://github.com/sjl/learnvimscriptthehardway.git | |
# copy the file in learnvimscriptthehardway folder. | |
import os | |
ROOTPATH = os.path.dirname(__file__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from selenium import webdriver | |
a = webdriver.chrome.options.Options() | |
a.binary_location = None | |
driver = webdriver.Chrome() # Optional argument, if not specified will search path. | |
driver.get('http://www.google.com/xhtml') | |
time.sleep(5) # Let the user actually see something! | |
search_box = driver.find_element_by_name('q') | |
search_box.send_keys('ChromeDriver') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** Test Cases *** | |
Hello haha | |
Log hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** Keywords *** | |
a simple for loop | |
[documentation] just a for loop test | |
# in range | |
:for ${i} in range 10 | |
\ run keyword if ${i} == 6 exit for loop | |
\ log ${i} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
创建测试文件 | |
1 测试文件语法 | |
1.1 测试用例文件和目录的组织层次结构: | |
测试用例在测试用例文件中创建;一个测试用例文件自动的创建一个包含文件中所有测试用例的测试集;一个包含测试用例文件的目录构成一个更高级的测试集,这个测试集(目录)包含每一个测试用例文件形成的子测试集;测试集目录可以包含子测试集目录,子测试集目录又可以包含孙子测试集目录,只有需要,可以嵌套多层;测试集目录可以有一个特殊的初始化文件(__init__.txt,类似于python)。 | |
此外:测试库包含最低级的关键字;资源文件包含变量和更高级的用户自定义关键字;变量文件提供比资源文件更灵活的定义变量的形式。 | |
1.2 支持文件格式: | |
Robot Framework的测试数据被定义为表格形式,支持HTML\TSV\reST\Txt(从2.7.6开始,txt文件后缀名可以为.robot,方便与普通txt文件区分)。Robot Framework根据文件后缀判断文件类型,进行解析。后缀名不区分大小写。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from glob import glob | |
from os import chdir, sep as SEP | |
from os.path import abspath, dirname, join | |
from time import localtime | |
from zipfile import ZipFile, ZIP_DEFLATED | |
NAME = 'robotframework-c-example' | |
ZIP_NAME = NAME + '-%d%02d%02d.zip' % localtime()[:3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO Anywhere | |
export SVN_EDITOR=vim | |
alias ..='cd ..' | |
alias ...='cd ../..' | |
alias ....='cd ../../..' | |
alias .....='cd ../../../..' | |
alias ......='cd ../../../../..' | |
alias autopep8='autopep8 --in-place --aggressive' | |
alias du='du -sh' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import random | |
def randomMAC(): | |
mac = [ 0x52, 0x54, 0x00, | |
random.randint(0x00, 0x7f), |
OlderNewer