From fea2ddc0044a136f55a024ef5a4c10dee88f1993 Mon Sep 17 00:00:00 2001 From: Steeve Date: Thu, 10 Apr 2014 11:17:29 +0200 Subject: [PATCH 1/3] key word argument get (kwg) a common usage -especially when overloading class- is to use `*args` array and `**kwargs` dictionary to handle method's arguments this snippet is usefull to quickly get the argument value from the keyword arguments dictionary -kwargs- or setting a default value --- snippets/python.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/python.snippets b/snippets/python.snippets index ac9573b..799e061 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -204,3 +204,5 @@ snippet epydoc snippet dol def ${1:__init__}(self, *args, **kwargs): super(${0:ClassName}, self).$1(*args, **kwargs) +snippet kwg + self.${1:var_name} = kwargs.get('$1', ${2:None})${0:} From 7f65658f47f18b2cf4669a898244c0bbef805d01 Mon Sep 17 00:00:00 2001 From: Steeve Date: Mon, 14 Apr 2014 12:28:03 +0200 Subject: [PATCH 2/3] remove useless $0 --- snippets/python.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/python.snippets b/snippets/python.snippets index 799e061..1ac0dd4 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -205,4 +205,4 @@ snippet dol def ${1:__init__}(self, *args, **kwargs): super(${0:ClassName}, self).$1(*args, **kwargs) snippet kwg - self.${1:var_name} = kwargs.get('$1', ${2:None})${0:} + self.${1:var_name} = kwargs.get('$1', ${2:None}) From 593a3b79dff5ae60b2a18dd2930bd0669c92bd9e Mon Sep 17 00:00:00 2001 From: Steeve Date: Mon, 14 Apr 2014 12:30:29 +0200 Subject: [PATCH 3/3] lkwg LocalKeyWordargumentGet --- snippets/python.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/python.snippets b/snippets/python.snippets index 1ac0dd4..c221f46 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -206,3 +206,5 @@ snippet dol super(${0:ClassName}, self).$1(*args, **kwargs) snippet kwg self.${1:var_name} = kwargs.get('$1', ${2:None}) +snippet lkwg + ${1:var_name} = kwargs.get('$1', ${2:None})