10from xonsh.platform import PYTHON_VERSION_INFO_BYTES
11
12
13def _splitpath(path, sofar=[]): 14 folder, path = os.path.split(path)
15 if path == "":
16 return sofar[::-1]
766 return self._instance_or_null(Repository, json)
767
768 @requires_auth
769 def create_hook(self, name, config, events=['push'], active=True): 770 """Create a hook on this repository.
771
772 :param str name: (required), name of the hook
58 return self._boolean(self._delete(self._api), 204, 404)
59
60 @requires_auth
61 def edit(self, config={}, events=[], add_events=[], rm_events=[], 62 active=True):
63 """Edit this hook.
64
58 return self._boolean(self._delete(self._api), 204, 404)
59
60 @requires_auth
61 def edit(self, config={}, events=[], add_events=[], rm_events=[], 62 active=True):
63 """Edit this hook.
64
58 return self._boolean(self._delete(self._api), 204, 404)
59
60 @requires_auth
61 def edit(self, config={}, events=[], add_events=[], rm_events=[], 62 active=True):
63 """Edit this hook.
64
Do not use a mutable like list
or dictionary
as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.
def my_function(elem, l=[]):
l.append(elem)
return l
print(my_function(2)) # [2]
print(my_function(5)) # [2, 5]
def my_function(elem, l=None):
if l is None:
l = []
l.append(elem)
return l
print(my_function(2)) # [2]
print(my_function(5)) # [5]