Getting a Generator Object returned when I want the data
<p>I am very very new to Python 3, so please be nice.</p>

<p>I have looked at all the documentation I could find regarding this - there does seem to be a lot, it's just I still cannot figure out what to do.</p>

<p>This is my code:</p>

<pre><code>poly = [[36606.0,53223.0],[37332.0,52224.0],[39043.0,53223.0],
[41603.0,53223.0],[42657.0,53278.0],[43123.0,52060.0],
[44054.0,51156.0],[45806.0,51498.0],[46751.0,53237.0],
[46983.0,54606.0],[45861.0,57057.0],[44971.0,58836.0],
[44054.0,60616.0],[43451.0,58138.0],[41850.0,59179.0],
[40850.0,60370.0],[39906.0,59233.0],[38674.0,59179.0],
[35566.0,56249.0],[37592.0,57536.0]]

def perimeter():
     return (sum((abs((x1 - x0)**2)+abs((y1 - y0)**2))**.5)
                        for ((x0, y0), (x1, y1)) in parts1(poly))

def parts1(poly):
    return poly[0:] + [poly[0]]

print(perimeter())
</code></pre>

<p>It is running <em>without</em> any errors but I am getting a return of:</p>

<p><code>generator object perimeter.locals.genexpr at 0x7f47d8671c50</code></p>

<p>How do I make it so that it gives me the value/answer?
I am really not sure what is going on.</p>

<p>Your code has two problems. One is due to parentheses as @TigerhawkT3 pointed out, and the other is you're not iterating through the points properly. The code below addresses both these issues.</p>

<pre><code>poly = [[36606.0,53223.0],[37332.0,52224.0],[39043.0,53223.0],
        [41603.0,53223.0],[42657.0,53278.0],[43123.0,52060.0],
        [44054.0,51156.0],[45806.0,51498.0],[46751.0,53237.0],
        [46983.0,54606.0],[45861.0,57057.0],[44971.0,58836.0],
        [44054.0,60616.0],[43451.0,58138.0],[41850.0,59179.0],
        [40850.0,60370.0],[39906.0,59233.0],[38674.0,59179.0],
        [35566.0,56249.0],[37592.0,57536.0]]

def pairwise(iterable):
    "s -&gt; (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = iter(iterable), iter(iterable)
    next(b, None)
    return zip(a, b)

def parts1(poly):
    return poly[0:] + [poly[0]]

def perimeter():
    return sum((abs((x1 - x0)**2)+abs((y1 - y0)**2))**.5
                    for ((x0, y0), (x1, y1)) in pairwise(parts1(poly)))

print(perimeter())  # -&gt; 41095.327046386046
</code></pre>

<p>Also note that you could simplify (and speed up) the calculation you're doing by using the built-in <a href="https://docs.python.org/3/library/math.html#math.hypot" rel="nofollow"><code>math.hypot()</code></a> function:</p>

<pre><code>import math

def perimeter2():
    return sum(math.hypot(x1-x0, y1-y0) 
                for ((x0, y0), (x1, y1)) in pairwise(parts1(poly)))

print(perimeter2())  # -&gt; 41095.327046386046
</code></pre>

python python-3.x generator