Best Python code snippet using elementium_python
descriptor_.py
Source:descriptor_.py
...105 @classmethod106 def get_version(cls):107 return cls.version108 @staticmethod109 def find_version():110 return PythonSite.version111# ç±»æ¹æ³ @classmethodè£
饰å¨112# ç±»æ¹æ³ä½¿ç¨@classmethod è£
饰å¨å®ä¹ï¼113# ç»è¿è¯¥è£
饰å¨çæ¹æ³æ¯ä¸ä¸ªæè¿°å¨114# ç±»åå®ä¾é½å¯ä»¥è°ç¨ç±»æ¹æ³115ps = PythonSite('ghost')116print ps.get_version117# <bound method type.get_version of <class '__main__.PythonSite'>>118print ps.get_version()119# 0.01120print PythonSite.get_version121# <bound method type.get_version of <class '__main__.PythonSite'>>122print PythonSite.get_version()123# 0.01124# get_version æ¯ä¸ä¸ªbound æ¹æ³ã125# ps.get_version è¿ä¸ªè°ç¨ä¼å
æ¥æ¾å®ç__dict__ æ¯å¦æget_version è¿ä¸ªå±æ§126# å¦æ没æï¼åæ¥æ¾å®çç±»127print vars(ps)128# {'site': 'ghost'}129print type(ps).__dict__['get_version']130# <classmethod object at 0x101c3cc58>131print type(ps).__dict__['get_version'].__get__(ps, type(ps))132# <bound method type.get_version of <class '__main__.PythonSite'>>133print type(ps).__dict__['get_version'].__get__(ps, type(ps)) == ps.get_version134# True # !!!135# 并ä¸vars(ps)ä¸ï¼__dict__并没æget_versionè¿ä¸ªå±æ§ï¼136# ä¾æ®æè¿°å¨åè®®ï¼å°ä¼è°ç¨type(ps).__dict__['get_version']æè¿°å¨ç__get__æ¹æ³ï¼137# å 为psæ¯å®ä¾ï¼å æ¤object.__getattribute__()ä¼è¿æ ·è°ç¨__get__(obj, type(obj))ã138print PythonSite.__dict__['get_version']139# <classmethod object at 0x1094e2c58>140print PythonSite.__dict__['get_version'].__get__(None, PythonSite)141# <bound method type.get_version of <class '__main__.PythonSite'>>142print PythonSite.__dict__['get_version'].__get__(None, PythonSite) == PythonSite.get_version143# True144# éææ¹æ³ @staticmethod145# å®ä¾åç±»ä¹å¯ä»¥è°ç¨éææ¹æ³146print ps.find_version147# <function find_version at 0x1021979b0>148print ps.find_version()149# 0.01150print vars(ps)151# {'site': 'ghost'}152print type(ps).__dict__['find_version']153# <staticmethod object at 0x102199cc8>154print type(ps).__dict__['find_version'].__get__(ps, type(ps))155# <function find_version at 0x108cbf9b0>156print type(ps).__dict__['find_version'].__get__(ps, type(ps)) == ps.find_version157# True158print PythonSite.find_version()159# 0.01160print PythonSite.find_version161# <function find_version at 0x108cbf9b0>162print type(ps).__dict__['find_version'].__get__(None, type(ps))163# <function find_version at 0x108cbf9b0>164print type(ps).__dict__['find_version'].__get__(None, type(ps)) == PythonSite.find_version165# True166# å®ä¾æ¹æ³167print ps.get_site168# <bound method PythonSite.get_site of <__main__.PythonSite object at 0x1089784d0>>169print ps.get_site()170# ghost171print type(ps).__dict__['get_site']172# <function get_site at 0x10896f8c0>...
os-x-minimum-system-version
Source:os-x-minimum-system-version
1#!/usr/bin/env python2import sys3import subprocess4def find_version(version, should_generalize=True):5 """Returns a normalized OS X version string.6 7 >>> find_version("10.8")8 '10.8.0'9 >>> find_version("10.8.2")10 '10.8.0'11 >>> find_version("10.3.9", False)12 '10.3.9'13 """14 parts = version.split(".")15 major = parts[0]16 minor = parts[1]17 bug = "0"18 if not should_generalize and len(parts) == 3:19 bug = parts[2]20 return ".".join([major, minor, bug])21if __name__ == '__main__':22 if len(sys.argv) == 2:23 print find_version(sys.argv[1], False)24 else:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!