Hi again
Playing with different parameter configurations, I have found the
next behaviour which I consider an inconsistency (maybe I am wrong).
Suppose the next function
def f1(a, b=2): print a, b
We can write
f1(1,4) or f1(1,b=4)
obtaining correctly
1 4
Using
def f2(a, b=2,*c): print a, b, c
f2(1,4) and f2(1,b=4)
gives correctly
1 4 ()
Again
f2(1,4, 3)
gives (correctly)
1 4 (3)
but
f2(1,b=4, 3)
gives the error: SyntaxError: non-keyword arg after keyword arg
Is this consistent?
josu
El 09-ots-20, a las 15:31, josu jugo escribió:
> For example, if I want a plot function similar to the plot function in
> Matlab with (for instance) the next possibilities
>
> plot(x) plot(x,y,x1,y1) plot(x,y,'-r')
>
> the combination on this kind of parameter possibilties can be
> cumbersome (if you need it) and I think that the use of an "if-else"
> solution will result in a code difficult to maintain/improve.
>
> Other solution can be a similar sintaxis, but no replicating the
> previous one.
>
> josu
>
> El 09-ots-20, a las 13:50, Nicholas Riley escribió:
>
>> In article <D149F8E6-E3A3-4A80-B6B3-6FA8521559F6@...>,
>> josu jugo <josu@...> wrote:
>>
>>> When defining functions, I normally use if-else statement for
>>> parsing
>>> its arguments. However, in this case, I want to define a more
>>> complex
>>> function. can anybody suggest a better way to do this task?
>>
>> Can you give an example? The only other thing I've ever needed was
>> to
>> loop through the positional or keyword arguments, which are no
>> different
>> to any other Python tuple or dictionary in that matter.
>>
>> (Note: for generic Python questions such as the above, you will
>> likely
>> get faster/more responses posting on a Python mailing list.)
>> --
>> Nicholas Riley <njriley@...>
>>
>>
>> ------------------------------------------------------------------------------
>> Open Source Business Conference (OSBC), March 24-25, 2009, San
>> Francisco, CA
>> -OSBC tackles the biggest issue in open source: Open Sourcing the
>> Enterprise
>> -Strategies to boost innovation and cut costs with open source
>> participation
>> -Receive a $600 discount off the registration fee with the source
>> code: SFAD
>> http://p.sf.net/sfu/XcvMzF8H
>> _______________________________________________
>> Jython-users mailing list
>> Jython-users@...
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San
> Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source
> code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users

For example, if I want a plot function similar to the plot function in
Matlab with (for instance) the next possibilities
plot(x) plot(x,y,x1,y1) plot(x,y,'-r')
the combination on this kind of parameter possibilties can be
cumbersome (if you need it) and I think that the use of an "if-else"
solution will result in a code difficult to maintain/improve.
Other solution can be a similar sintaxis, but no replicating the
previous one.
josu
El 09-ots-20, a las 13:50, Nicholas Riley escribió:
> In article <D149F8E6-E3A3-4A80-B6B3-6FA8521559F6@...>,
> josu jugo <josu@...> wrote:
>
>> When defining functions, I normally use if-else statement for parsing
>> its arguments. However, in this case, I want to define a more complex
>> function. can anybody suggest a better way to do this task?
>
> Can you give an example? The only other thing I've ever needed was to
> loop through the positional or keyword arguments, which are no
> different
> to any other Python tuple or dictionary in that matter.
>
> (Note: for generic Python questions such as the above, you will likely
> get faster/more responses posting on a Python mailing list.)
> --
> Nicholas Riley <njriley@...>
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San
> Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source
> code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users

[Prashant]
> The scripts I want to run are written in CPython.
> I am using PythonInterpreter for invoking those scripts.
> This PythonInterpreter is in the jython.jar of Jython 2.1 release.
> The CPython I used was of version 2.6.
OK, so you want to run scripts that are written for cpython 2.6 on jython 2.1.
There are two stages to getting this done
1. You may have to modify the scripts to run on jython 2.1, if they
use syntax or concepts that were introduced after 2.1, e.g. iterators,
generators, list comprehensions, generator comprehensions,
metaclasses, new-style classes, decorators, context managers, etc,
etc, etc. The way to check this is to run the scripts using the jython
2.1 command line interpreter, and see if they run smoothly. If they do
not, e.g. they give syntax errors, then you will have to modify the
scripts; there is no magic way of getting a 2.1 interpreter to
understand 2.6 syntax.
Here are some lists of new features that have been added to the
language since 2.1
http://www.python.org/doc/2.2.3/whatsnew/http://www.python.org/doc/2.3/whatsnew/http://www.python.org/doc/2.4.3/whatsnew/http://docs.python.org/whatsnew/2.5.htmlhttp://docs.python.org/dev/whatsnew/2.6.html
2. Once you have the scripts running on jython 2.1, then you can use
well-documented embedding techniques to run them using a
PythonInterpreter, from inside a java program.
Here is a reference to the old embedding documentation for 2.1
http://www.jython.org/docs/embedding.html
Out of interest, why are you targetting jython 2.1? It would probably
be much easier to target jython 2.5.
HTH,
Alan.

In article <D149F8E6-E3A3-4A80-B6B3-6FA8521559F6@...>,
josu jugo <josu@...> wrote:
> When defining functions, I normally use if-else statement for parsing
> its arguments. However, in this case, I want to define a more complex
> function. can anybody suggest a better way to do this task?
Can you give an example? The only other thing I've ever needed was to
loop through the positional or keyword arguments, which are no different
to any other Python tuple or dictionary in that matter.
(Note: for generic Python questions such as the above, you will likely
get faster/more responses posting on a Python mailing list.)
--
Nicholas Riley <njriley@...>

Really, the answer is yes and no. Certainly, one of the options is the
switch or similar statement. But I was thinking in a kind of parser,
usable in jython, allowing complex sintaxis.
josu
El 09-ots-20, a las 13:38, Josh Juneau escribió:
> Are speaking about using a more complex conditional like a switch
> statement? If so, I don't believe that Python/Jython has a native
> switch statement. However, if you Google the topic then I'm sure you
> will come up with lots of techniques to perform such logic.
>
> I know that I didn't really answer anything, but I hope this helps.
>
> Josh Juneau
> juneau001@...
> http://jj-blogger.blogspot.com
> http://www.gathereventplanning.com
> Twitter ID: javajuneau
>
>
>
> On Fri, Feb 20, 2009 at 3:49 AM, josu jugo <josu@...> wrote:
>> Hi
>>
>> When defining functions, I normally use if-else statement for parsing
>> its arguments. However, in this case, I want to define a more complex
>> function. can anybody suggest a better way to do this task?
>>
>> Thanks
>>
>> josu
>>
>> ------------------------------------------------------------------------------
>> Open Source Business Conference (OSBC), March 24-25, 2009, San
>> Francisco, CA
>> -OSBC tackles the biggest issue in open source: Open Sourcing the
>> Enterprise
>> -Strategies to boost innovation and cut costs with open source
>> participation
>> -Receive a $600 discount off the registration fee with the source
>> code: SFAD
>> http://p.sf.net/sfu/XcvMzF8H
>> _______________________________________________
>> Jython-users mailing list
>> Jython-users@...
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>

Hi
When defining functions, I normally use if-else statement for parsing
its arguments. However, in this case, I want to define a more complex
function. can anybody suggest a better way to do this task?
Thanks
josu

Hello.
I have been playing with jython (2.2 and 2.5) and it is awsome, but I
have a problem when I try to use classess, methods, or variables with
non-ascii characters I get something like this:
>>> á=3
File "<input>", line 1
á=3
^
SyntaxError: Lexical error at line 1, column 1. Encountered: "\u00e1"
(225), after : ""
Im using a windows (latin-1) system. I tried to configure the encoding
in the registry file without success. I dont know what else to do.
When I use the standard python console or the ironpython console i
dont have this problem; I can declare and use variables or classess
with non-ascii characters in its name.
Any thoughts on this?