sukri12 / pysal

Automatically exported from code.google.com/p/pysal
Other
0 stars 0 forks source link

pysal cannot be imported in python2.5 #100

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
My build of python2.5.1 cannot import pysal.  At pysal.org it says that 
python2.5 or later is 
supported.  The issue is caused by Distance.py, which contains the *args 
operator followed by a 
keyword argument in lines 253 and 380. 

Here is the error...

Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import pysal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/SVN/pysal/trunk/pysal/__init__.py", line 49, in <module>
    from esda.moran import Moran, Moran_BV, Moran_BV_matrix, Moran_Local
  File "/SVN/pysal/trunk/pysal/esda/moran.py", line 10, in <module>
    from pysal.weights.spatial_lag import lag as slag
  File "/SVN/pysal/trunk/pysal/weights/__init__.py", line 841, in <module>
    from Distance import *
  File "/SVN/pysal/trunk/pysal/weights/Distance.py", line 253
    W.__init__(self,*self._k_to_W(ids),id_order=ids)
                                              ^
SyntaxError: invalid syntax
>>> 

Here is the general problem...

Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> def func(a,b,c):
...  print a,b,c
... 
>>> func(1,2,3)
1 2 3
>>> t=(7,8)
>>> func(6,*t)
6 7 8
>>> func(*t,9)
  File "<stdin>", line 1
    func(*t,9)
            ^
SyntaxError: invalid syntax
>>> func(*t,c=9)
  File "<stdin>", line 1
    func(*t,c=9)
            ^
SyntaxError: invalid syntax
>>> 

Original issue reported on code.google.com by dfo...@gmail.com on 20 May 2010 at 1:30

GoogleCodeExporter commented 8 years ago
keyword arguments have to come before variable length arguments. i believe mh 
added the keyword arguments 
that raise this error in 2.5 - not sure why the tests past for 2.6 on sal-dev 
however.

Original comment by sjsrey on 20 May 2010 at 1:53

GoogleCodeExporter commented 8 years ago

Original comment by mhwa...@gmail.com on 20 May 2010 at 6:32