[Gvsig_english] Field Calculator: look for an expression saved in a file

"Jose Manuel Vivó Arnal ( Chema ) "Jose Manuel Vivó Arnal ( Chema )
Wed Dec 14 15:32:16 CET 2011


El 14/12/11 11:32, Antonio Falciano escribió:
> Il 13/12/2011 10.28, iaborsi ha scritto:
>> Hi Antonio,
>> thanks a lot! I've tried that: very easy, and it works perfectly!
>> I take this opportunity to make an additional question: if in writing
>> this Jython function I need additional Modules (typically an original
>> group of functions defined by myself) which is the right path to save
>> this stuff? I guess is the same directory from which I upload my Jython
>> function, isn't it?
>> To be clearer (following you example below): I want to modify your
>> example script "conversion.py" in this way:
>> -------
>> from MyNewModule import *
>>
>> def m2tokm2(value):
>> temp=value/1000000
>> result = MyNewFunction(temp)
>> return result
>> -------
>> where MyNewFunction() is defined within the module MyNewModule.
>>
>> I guess I have to save the module within the same path of conversion.py.
>> Right?
>
> Good idea, Iacopo! Importing further modules would extend the
> potentiality of advanced expressions. It should be possible to import a
> module within the same path, however it returns always a Jython
> exception. Probably the simplest way to use other functions contained in
> other module(s) consists in processing them before, even if it's not
> pythonic at all.
>
> Cheers,
> Antonio
>
I can remember that a file "__init__.py" is needed to import any module 
form a folder [1]. So create a empty file in this folder and try again.

I think it worth a try, doesn't it? ;)

[1] 
http://docs.python.org/release/2.1.2/tut/node8.html#SECTION008400000000000000000

Regards,
Chema.
-- 
Jose Manuel Vivó Arnal
DiSiD Technologies S.L. (http://www.disid.com)


More information about the Gvsig_internacional mailing list