title: Python: Problems with a list comprehension using module laspy
body: <p>recently i understand the great advantage to use the list comprehension. I am working with several milion of points (x,y,z) stored in a special format *.las file. In python there are two way to work with this format:</p>
  
  <pre><code>Liblas module  [http://www.liblas.org/tutorial/python.html][1] (in a C++/Python)
  laspy module [http://laspy.readthedocs.org/en/latest/tut_part_1.html][2] (pure Python)
  </code></pre>
  
  <p>I had several problem with liblas and i wish to test laspy.</p>
  
  <p>in liblas i can use list comprehension as:</p>
  
  <pre><code>from liblas import file as lasfile
  f = lasfile.File(inFile,None,'r') # open LAS
  points = [(p.x,p.y) for p in f] # read in list comprehension
  </code></pre>
  
  <p>in laspy i cannot figurate how do the same:</p>
  
  <pre><code>from laspy.file import File
  f = file.File(inFile, mode='r')
  f
  &lt;laspy.file.File object at 0x0000000013939080&gt;
  (f[0].X,f[0].Y)
  (30839973, 696447860)
  </code></pre>
  
  <p>i tryed several combination as:</p>
  
  <pre><code>points = [(p.X,p.Y) for p in f]
  </code></pre>
  
  <p>but i get this message</p>
  
  <pre><code>Traceback (most recent call last):
   File "&lt;interactive input&gt;", line 1, in &lt;module&gt;
  AttributeError: Point instance has no attribute 'x'
  </code></pre>
  
  <p>I tryed in uppercase and NOT-uppercase because Python is case sensitive:</p>
  
  <pre><code>&gt;&gt;&gt; [(p.x,p.y) for p in f]
  Traceback (most recent call last):
    File "&lt;interactive input&gt;", line 1, in &lt;module&gt;
  AttributeError: Point instance has no attribute 'x'
  &gt;&gt;&gt; [(p.X,p.Y) for p in f]
  Traceback (most recent call last):
    File "&lt;interactive input&gt;", line 1, in &lt;module&gt;
  AttributeError: Point instance has no attribute 'X'
  </code></pre>
  
  <p>this is in interactive prompt:</p>
  
  <pre><code>C:\Python27&gt;python.exe
  Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win
  32
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; from laspy.file import File
  &gt;&gt;&gt; inFile="C:\\04-las_clip_inside_area\\Ku_018_class.las"
  &gt;&gt;&gt; f = File(inFile, None, 'r')
  &gt;&gt;&gt; f
  &lt;laspy.file.File object at 0x00000000024D5E10&gt;
  &gt;&gt;&gt; points = [(p.X,p.Y) for p in f]
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  AttributeError: Point instance has no attribute 'X'
  &gt;&gt;&gt;
  </code></pre>
  
  <p>the print p after the list is:</p>
  
  <pre><code>print dir(p) 
  ['__doc__', '__init__', '__module__', 'make_nice', 'pack', 'packer', 'reader', 'unpacked']
  </code></pre>
  
  <p>in a loop format i have always the same error</p>
  
  <pre><code>&gt;&gt;&gt; for p in f:
  ...     print dir(p)
  ...     print p.X,p.Y
  ...     
  ['__doc__', '__init__', '__module__', 'make_nice', 'pack', 'packer', 'reader', 'unpacked']
  Traceback (most recent call last):
    File "&lt;interactive input&gt;", line 3, in &lt;module&gt;
  AttributeError: Point instance has no attribute 'X'
  </code></pre>
  
  <p>using this code suggested by nneonneo</p>
  
  <pre><code>import numpy as np
  for p in f:
  ...   points = np.array([f.X, f.Y]).T  
  </code></pre>
  
  <p>i can store in an array</p>
  
  <pre><code>points
  array([[ 30839973, 696447860],
         [ 30839937, 696447890],
         [ 30839842, 696447832],
         ..., 
         [ 30943795, 695999984],
         [ 30943695, 695999922],
         [ 30943960, 695999995]])
  </code></pre>
  
  <p>but miss the way to create a list comprehension</p>
  
  <pre><code>points = [np.array(p.X,p.Y).T for p in f]
  Traceback (most recent call last):
    File "&lt;interactive input&gt;", line 1, in &lt;module&gt;
  AttributeError: Point instance has no attribute 'X'
  </code></pre>
  
  <p>thanks in advance for help.
  Gianni</p>