[PATCH] examples: network-scan: get rid of global variables

yegorslists at googlemail.com yegorslists at googlemail.com
Wed Feb 24 09:10:00 UTC 2021


From: Yegor Yefremov <yegorslists at googlemail.com>

Move the code into the main() routine.
---
 examples/network-scan-python/network-scan-python | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/examples/network-scan-python/network-scan-python b/examples/network-scan-python/network-scan-python
index 12ee02f7..21dd89f4 100755
--- a/examples/network-scan-python/network-scan-python
+++ b/examples/network-scan-python/network-scan-python
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -26,7 +26,8 @@ gi.require_version('ModemManager', '1.0')
 from gi.repository import Gio, GLib, GObject, ModemManager
 
 
-if __name__ == "__main__":
+def main():
+    """Main routine."""
 
     # Process input arguments
     if len(sys.argv) != 1:
@@ -67,3 +68,7 @@ if __name__ == "__main__":
                         network.get_availability())))
         else:
             print('no networks found')
+
+
+if __name__ == "__main__":
+    main()
-- 
2.17.0



More information about the ModemManager-devel mailing list