changeset 803:70e9f82c2443

* prime actually doesnt work; if i had a decent CI for my own software, i would have known that; but i dont * resource_filename.py even _says_ example in it. let us hope it is telling the truth
author Jeff Hammel <k0scist@gmail.com>
date Fri, 28 Oct 2016 17:00:37 -0700
parents b5a59c3e4421
children 624a7fc0d7ca
files python/example/resource_filename.py python/prime.py python/resource_filename.py
diffstat 3 files changed, 21 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/example/resource_filename.py	Fri Oct 28 17:00:37 2016 -0700
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+# example code
+
+import os
+
+def resource_path(path):
+    """
+    getting a resource filename (absolute path)
+    - path: relative path
+    """
+
+    try:
+        # use pkg_resources if available
+        # http://pythonhosted.org/distribute/setuptools.html#non-package-data-files
+        from pkg_resources import Requirement, resource_filename
+        return resource_filename(Requirement.parse("MyProject"),path)
+    except ImportError:
+        # assume file lives relative to this file
+        here = os.path.dirname(os.path.abspath(__file__))
+        return os.path.join(here, path)
--- a/python/prime.py	Fri Oct 28 16:57:50 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#!/usr/bin/env python
-
-"""
-print prime numbers for each argument given
-"""
-
-def prime(number):
-    """determines if `number` is prime"""
-    # XXX this is owefully inefficient and is written as
-    # a (bad) example only
-
-    half = int(number / 2)
-    for i in range(2, half):
-        if not number % i:
-            return False
-    return True
-
-def primes(n):
-    return [i for i in range(2,n)
-            if not [True for j in range(2,1 + i/2)
-                    if not i%j]]
-
-
-if __name__ == '__main__':
-    import argparse
-    parser = argparse.ArgumentParser(description=__doc__)
-    parser.add_argument('arg', type=int, nargs='+',
-                        help="(positive) integer to find the primes for")
-    options = parser.parse_args()
-    for arg in options.arg:
-        print prime(arg)
--- a/python/resource_filename.py	Fri Oct 28 16:57:50 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-#!/usr/bin/env python
-
-# example code
-
-import os
-
-def resource_path(path):
-    """
-    getting a resource filename (absolute path)
-    - path: relative path
-    """
-
-    try:
-        # use pkg_resources if available
-        # http://pythonhosted.org/distribute/setuptools.html#non-package-data-files
-        from pkg_resources import Requirement, resource_filename
-        return resource_filename(Requirement.parse("MyProject"),path)
-    except ImportError:
-        # assume file lives relative to this file
-        here = os.path.dirname(os.path.abspath(__file__))
-        return os.path.join(here, path)