aboutsummaryrefslogtreecommitdiff
path: root/challenge-031
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2019-10-27 11:42:10 +0100
committerLubos Kolouch <lubos@kolouch.net>2019-10-27 11:42:10 +0100
commit425c113eeed3e47d4f7a96bccfc19acb4638f7c6 (patch)
tree867394b797e343fbb163a32f6dcdc8602d3dc51f /challenge-031
parented3c98d98bd2ff9313ec4a3efd90970cd937196f (diff)
downloadperlweeklychallenge-club-425c113eeed3e47d4f7a96bccfc19acb4638f7c6.tar.gz
perlweeklychallenge-club-425c113eeed3e47d4f7a96bccfc19acb4638f7c6.tar.bz2
perlweeklychallenge-club-425c113eeed3e47d4f7a96bccfc19acb4638f7c6.zip
Snake solution #2
Diffstat (limited to 'challenge-031')
-rw-r--r--challenge-031/lubos-kolouch/python/ch_2.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/challenge-031/lubos-kolouch/python/ch_2.py b/challenge-031/lubos-kolouch/python/ch_2.py
new file mode 100644
index 0000000000..5b3d151e21
--- /dev/null
+++ b/challenge-031/lubos-kolouch/python/ch_2.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+# -*- coding:utf-8 -*-
+
+import sys
+import argparse
+import pytest
+
+def get_args():
+ parser = argparse.ArgumentParser(\
+ description='Variable creator')
+ parser.add_argument(\
+ '-n',
+ '--name',
+ type=str,
+ help='Name',
+ required=True)
+ return parser.parse_args()
+
+def assign_name(name):
+ # it works, but I would not like to debug it...
+ globals()[name]="test"
+ return 1
+
+def main():
+ if sys.version_info[0] < 3:
+ print("ERROR: Python3 required.")
+ exit(1)
+ param = get_args()
+ param_name=param.name
+ assign_name(param_name)
+
+def test_assign():
+ assign_name("v1")
+ assert(v1=="test")
+
+main()
+
+test_assign()
+#EOF