[libvirt] [PATCH sandbox-image 8/9] cli: Remove redundant global statements

Radostin Stoyanov posted 9 patches 7 years ago
[libvirt] [PATCH sandbox-image 8/9] cli: Remove redundant global statements
Posted by Radostin Stoyanov 7 years ago
The global statement is needed for assignment of variables in global
scope [1]. In this case, we only read the value of those variables,
therefore we do not need to explicitly use the global statement.

[1] https://docs.python.org/3/reference/simple_stmts.html#the-global-statement

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 libvirt_sandbox_image/cli.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libvirt_sandbox_image/cli.py b/libvirt_sandbox_image/cli.py
index e96d422..95c5147 100644
--- a/libvirt_sandbox_image/cli.py
+++ b/libvirt_sandbox_image/cli.py
@@ -167,13 +167,11 @@ def requires_connect(parser):
                         help=_("Connect string for libvirt"))
 
 def requires_template_dir(parser):
-    global default_template_dir
     parser.add_argument("-t", "--template-dir",
                         default=default_template_dir,
                         help=_("Template directory for saving templates"))
 
 def requires_image_dir(parser):
-    global default_image_dir
     parser.add_argument("-I", "--image-dir",
                         default=default_image_dir,
                         help=_("Image directory for saving images"))
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH sandbox-image 8/9] cli: Remove redundant global statements
Posted by Cedric Bosdonnat 7 years ago
On Wed, 2018-04-18 at 21:57 +0100, Radostin Stoyanov wrote:
> The global statement is needed for assignment of variables in global
> scope [1]. In this case, we only read the value of those variables,
> therefore we do not need to explicitly use the global statement.
> 
> [1] https://docs.python.org/3/reference/simple_stmts.html#the-global-statement
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  libvirt_sandbox_image/cli.py | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libvirt_sandbox_image/cli.py b/libvirt_sandbox_image/cli.py
> index e96d422..95c5147 100644
> --- a/libvirt_sandbox_image/cli.py
> +++ b/libvirt_sandbox_image/cli.py
> @@ -167,13 +167,11 @@ def requires_connect(parser):
>                          help=_("Connect string for libvirt"))
>  
>  def requires_template_dir(parser):
> -    global default_template_dir
>      parser.add_argument("-t", "--template-dir",
>                          default=default_template_dir,
>                          help=_("Template directory for saving templates"))
>  
>  def requires_image_dir(parser):
> -    global default_image_dir
>      parser.add_argument("-I", "--image-dir",
>                          default=default_image_dir,
>                          help=_("Image directory for saving images"))


ACK
--
Cedric

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list